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

Include a message when failing to assign Discord permissions to users #3275

Open
2 tasks
raidensakura opened this issue Apr 9, 2023 · 0 comments
Open
2 tasks
Labels
bug This is a confirmed bug priority: low Something that's not on top of the list. You are free to submit a pull request though

Comments

@raidensakura
Copy link
Member

raidensakura commented Apr 9, 2023

Is your feature request related to a problem? Please elaborate.

Right now, the bot just silently errors out when trying to set Discord permissions that the bot lacks, as follow:

And in the log file:

2023-04-08T05:22:50.557347269Z stdout F 04/08/23 05:22:50 core.config[292] - INFO: Setting level_permissions.
2023-04-08T05:22:50.558089959Z stdout F 04/08/23 05:22:50 __main__[1141] - INFO: Updating permissions for ADMINISTRATOR, 1005104021612277890 (add=True).
2023-04-08T05:22:50.577183806Z stdout F 04/08/23 05:22:50 cogs.utility[1364] - INFO: Granting Elysia access to Modmail category.
2023-04-08T05:22:50.740324959Z stdout F 04/08/23 05:22:50 __main__[1548] - ERROR: Unexpected exception:
2023-04-08T05:22:50.740355311Z stdout F Traceback (most recent call last):
2023-04-08T05:22:50.740360419Z stdout F   File "/usr/local/lib/python3.10/site-packages/discord/ext/commands/core.py", line 190, in wrapped
2023-04-08T05:22:50.740363947Z stdout F     ret = await coro(*args, **kwargs)
2023-04-08T05:22:50.740367406Z stdout F   File "/modmailbot/cogs/utility.py", line 1365, in permissions_add
2023-04-08T05:22:50.740370295Z stdout F     await self.bot.main_category.set_permissions(key, read_messages=True)
2023-04-08T05:22:50.740373773Z stdout F   File "/usr/local/lib/python3.10/site-packages/discord/abc.py", line 937, in set_permissions
2023-04-08T05:22:50.740376631Z stdout F     await http.edit_channel_permissions(
2023-04-08T05:22:50.740380269Z stdout F   File "/usr/local/lib/python3.10/site-packages/discord/http.py", line 738, in request
2023-04-08T05:22:50.74038304Z stdout F     raise Forbidden(response, data)
2023-04-08T05:22:50.740386034Z stdout F discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
2023-04-08T05:22:50.740388852Z stdout F 
2023-04-08T05:22:50.740392122Z stdout F The above exception was the direct cause of the following exception:
2023-04-08T05:22:50.740394754Z stdout F 
2023-04-08T05:22:50.740397056Z stdout F Traceback (most recent call last):
2023-04-08T05:22:50.740399946Z stdout F   File "/usr/local/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 1347, in invoke
2023-04-08T05:22:50.740403046Z stdout F     await ctx.command.invoke(ctx)
2023-04-08T05:22:50.740405969Z stdout F   File "/usr/local/lib/python3.10/site-packages/discord/ext/commands/core.py", line 1605, in invoke
2023-04-08T05:22:50.740409486Z stdout F     await ctx.invoked_subcommand.invoke(ctx)
2023-04-08T05:22:50.740413278Z stdout F   File "/usr/local/lib/python3.10/site-packages/discord/ext/commands/core.py", line 986, in invoke
2023-04-08T05:22:50.740416256Z stdout F     await injected(*ctx.args, **ctx.kwargs)  # type: ignore
2023-04-08T05:22:50.740418995Z stdout F   File "/usr/local/lib/python3.10/site-packages/discord/ext/commands/core.py", line 199, in wrapped
2023-04-08T05:22:50.740437312Z stdout F     raise CommandInvokeError(exc) from exc

Describe the solution you'd like

The bot should inform the user with a missing permission error message on Discord for better UX.

Does your solution involve any of the following?

  • Logviewer
  • New config option

Describe alternatives you've considered

Assigning the Administrator permission to the bot should prevent the permission error but our official guide states that it's optional, and it's generally considered good security practice to not assign Admin permission to a bot.

Who will this benefit?

This will benefit users who would like to fine-tune the permissions for the bot to only have what the bot really needs.

Additional Information

No response

@Taaku18 Taaku18 added bug This is a confirmed bug priority: low Something that's not on top of the list. You are free to submit a pull request though and removed feature request labels Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This is a confirmed bug priority: low Something that's not on top of the list. You are free to submit a pull request though
Projects
None yet
Development

No branches or pull requests

2 participants