Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use @Permission on class #54

Closed
Tenebrosful opened this issue Jun 18, 2021 · 0 comments
Closed

Can't use @Permission on class #54

Tenebrosful opened this issue Jun 18, 2021 · 0 comments

Comments

@Tenebrosful
Copy link

Tenebrosful commented Jun 18, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant