GrafeasGroup / buttercup

Our personal assistant in Discord
MIT License
5 stars 2 forks source link

Rework admin command permissions #134

Closed TimJentzsch closed 2 years ago

TimJentzsch commented 2 years ago

Relevant issue: Closes #133

Description:

This reworks how the permissions for admin commands are handled.

Before, the permissions would be checked on command execution. When the user didn't have a specified role, the command would return an error message and log the incident.

Now, we are using the built-in permission system of slash commands. When a user doesn't have the required role in the guild, the admin commands will be grayed out and the user won't be able to execute them.

The implementation is a bit hacky, because the permissions are defined in annotations and we can't directly access the config from there. So now we define a global variable in a cog that we load first and then use that to generate the permissions. This allows us to define the permissions in the config without hard-coding them in the annotation.

⚠️ This requires changing the config of the bot! ⚠️

Checklist: