Is it possible to add some sort of custom property to commands that can be checked in a precondition
I'm trying to make a precondition that will check for a role on the user, I was wondering if there is some way to add a property to a command, where I can check if it exists in a precondition, for example
requiredRoles: ['ADMIN','MODERATOR']
?Solution:Jump to solution
Yes
https://github.com/skyra-project/skyra/blob/main/src/lib/structures/commands/SkyraCommand.ts
https://github.com/skyra-project/skyra/blob/main/src/preconditions/Administrator.ts...
GitHub
skyra/src/lib/structures/commands/SkyraCommand.ts at main · skyra-p...
A multipurpose Discord Bot designed to carry out most of your server's needs with great performance and stability. - skyra-project/skyra
GitHub
skyra/src/preconditions/Administrator.ts at main · skyra-project/sk...
A multipurpose Discord Bot designed to carry out most of your server's needs with great performance and stability. - skyra-project/skyra
4 Replies
(point of this is that i dont have to make like 10 different preconditions all doing the same thing in practice, just 1 string is changed..)
Solution
Yes
https://github.com/skyra-project/skyra/blob/main/src/lib/structures/commands/SkyraCommand.ts
https://github.com/skyra-project/skyra/blob/main/src/preconditions/Administrator.ts
GitHub
skyra/src/lib/structures/commands/SkyraCommand.ts at main · skyra-p...
A multipurpose Discord Bot designed to carry out most of your server's needs with great performance and stability. - skyra-project/skyra
GitHub
skyra/src/preconditions/Administrator.ts at main · skyra-project/sk...
A multipurpose Discord Bot designed to carry out most of your server's needs with great performance and stability. - skyra-project/skyra
Or alternatively and much easier https://github.com/favware/bloombot/blob/main/src/lib/extensions/BloomComand.ts
GitHub
bloombot/src/lib/extensions/BloomComand.ts at main · favware/bloombot
A private discord bot for the Nightbloom FC Discord server - favware/bloombot
big thanks