codewars / discord-bot

Codewars Discord Bot
MIT License
22 stars 11 forks source link

Allow permissions to be specified in slash commands #51

Closed DonaldKellett closed 2 years ago

DonaldKellett commented 2 years ago

This changeset lays the foundations for adding privileged slash commands such as /introduce and /warn, by allowing command permissions to be specified individually.

A new environment variable ROLE_EVERYONE is introduced for specifying the ID of the @everyone role in the associated guild, which is optional, though most (all) slash commands will not be available to anyone if not set.

Related: #43

kazk commented 2 years ago

I don't think we should add anything to the unrestricted commands.

Setting default permission to false for restricted commands, and allowing specific roles to use them by adding explicit permissions should be enough. Role ids can be configured through environment variables, or we should be able to find using the name. If we fail to find the id, we can skip registering the restricted commands, and show some warning.

For restricted commands to specify required roles, we can add optional requiredRoles array (ignored unless default permissions is false). Or we can change /introduce to unrestricted, and require mods role to use restricted commands.