owengombas / discord.ts

🤖 Create your discord bot by using TypeScript and decorators!

Home Page:https://owencalvin.github.io/discord.ts/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't use @Permission on class

Tenebrosful opened this issue · comments

Hi, i'm trying to use @Permission decoration to make a Group Slash with a role permission but it always throw me this error

D:\depotsGit\Bot-Discord-IUT-Nancy-Charlemagne\node_modules\reflect-metadata\Reflect.js:544
                        throw new TypeError();
                              ^
TypeError:
    at DecorateConstructor (D:\depotsGit\Bot-Discord-IUT-Nancy-Charlemagne\node_modules\reflect-metadata\Reflect.js:544:31)
    at Reflect.decorate (D:\depotsGit\Bot-Discord-IUT-Nancy-Charlemagne\node_modules\reflect-metadata\Reflect.js:130:24)
    at Object.__decorate (D:\depotsGit\Bot-Discord-IUT-Nancy-Charlemagne\node_modules\tslib\tslib.js:98:96)
    at Object.<anonymous> (D:\depotsGit\Bot-Discord-IUT-Nancy-Charlemagne\commands\Test.ts:6:17)
    at Module._compile (node:internal/modules/cjs/loader:1109:14)
    at Module.m._compile (C:\Users\hugob\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:1295:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
    at Object.require.extensions.<computed> [as .ts] (C:\Users\hugob\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:1298:12)
    at Module.load (node:internal/modules/cjs/loader:989:32)
    at Function.Module._load (node:internal/modules/cjs/loader:829:14)
import { Discord, Slash, Group, Description, Permission } from "@typeit/discord";
import { CommandInteraction, TextChannel } from "discord.js";

@Discord()
@Permission("753182939352793138", 'ROLE')
@Group("maintenance", "Commandes de maintenance réservées aux Admins")
abstract class maintenance {
    @Slash('purgeChannel')
    @Description("Clone et supprime le salon afin de supprimer son contenu")
    private purgeChannel(interaction: CommandInteraction) {
        const channel = <TextChannel>interaction.channel;

        channel.clone({ reason: `Purge du salon demandé par ${interaction.user.username}` });
        channel.delete(`Purge du salon demandé par ${interaction.user.username}`);
    }
}

I also tried with the doc example

import { Discord, Permission, Slash } from '@typeit/discord';

@Discord()
@Permission("227882902031958016", "USER") // Only the role that has this USER_ID can use this command
@Permission("753182939352793138", "ROLE") // Only the role that has this ROLE_ID can use this command
class DiscordBot {
  @Slash("hello") // Only the role that has this ROLE_ID can use this command
  private hello(
  ) {
    // ...
  }

  @Slash("hello2") // Only the role that has this ROLE_ID can use this command
  private hello2(
  ) {
    // ...
  }
}

But it throw the same error.

Thx in advance <3

PS: Idk if it's linked but i can't use multiple @Permission, it only take the last, maybe i will create a different issue for that