CodecademyCommunity / codecademy-discord-bot

Custom moderation bot for the official Codecademy Community Discord server.
https://codecademycommunity.github.io/
MIT License
11 stars 1 forks source link

Discord permissions v2 no longer supports bulk update of interaction command permissions #321

Closed mikejoh12 closed 2 years ago

mikejoh12 commented 2 years ago

Describe the bug

Previously we configured the permissions for the slash-commands on the 'ready' event. This no longer works due to Discord Permissions v2 api changes such as removing the bulk permission setting endpoint (which is being called in our code).

Expected behavior

The permission handling should work for all the slash-commands.

The most straight-forward fix would likely be to implement a permissions handler similar to the current text-command permission handler. This would result in all of the slash-commands being accessible to all users (but they won't have permission to use them and will get a "No permission" type response).

Stack Overflow answer suggesting the simple role check in the code: https://stackoverflow.com/questions/72048570/403-error-when-setting-application-command-permissions-on-discord

Another alternative is for admins to deploy commands with disabled permissions and then manually set command permissions through the Discord UI. But a programmatic solution seems preferable.

To Reproduce

Steps to reproduce the behavior: Start the bot and observe error occurring on ready event: DiscordAPIError: 405: Method Not Allowed

Additional context

Discord API discussing application command permissions: https://discord.com/developers/docs/interactions/application-commands#permissions