Modmail icon indicating copy to clipboard operation
Modmail copied to clipboard

[BUG]: USER Issue causing bug

Open auyylaso opened this issue 1 year ago • 4 comments

Bot Version

4.1.0

How are you hosting Modmail?

PM2

Error Logs

Check additional info

Screenshots

No response

Additional Information

0|modmail  | 11/05/24 10:15:24 core.config[295] - INFO: Setting level_permissions.
0|modmail  | 11/05/24 10:15:24 __main__[1122] - INFO: Updating permissions for SUPPORTER, 1293175166150639667 (add=True).
0|modmail  | 11/05/24 10:15:24 cogs.utility[1350] - INFO: Granting Chaos Mod access to Modmail category.
0|modmail  | 11/05/24 10:15:24 __main__[1555] - ERROR: Unexpected exception:
0|modmail  | Traceback (most recent call last):
0|modmail  |   File "/root/.local/share/virtualenvs/modmail-R5e9Y0tA/lib/python3.10/site-packages/discord/ext/commands/core.py", line 235,                                                                                 in wrapped
0|modmail  |     ret = await coro(*args, **kwargs)
0|modmail  |   File "/home/hehe/modmail/cogs/utility.py", line 1351, in permissions_add
0|modmail  |     await self.bot.main_category.set_permissions(key, read_messages=True)
0|modmail  | AttributeError: 'NoneType' object has no attribute 'set_permissions'
0|modmail  | The above exception was the direct cause of the following exception:
0|modmail  | Traceback (most recent call last):
0|modmail  |   File "/root/.local/share/virtualenvs/modmail-R5e9Y0tA/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 1350,                                                                                 in invoke
0|modmail  |     await ctx.command.invoke(ctx)
0|modmail  |   File "/root/.local/share/virtualenvs/modmail-R5e9Y0tA/lib/python3.10/site-packages/discord/ext/commands/core.py", line 1650                                                                                , in invoke
0|modmail  |     await ctx.invoked_subcommand.invoke(ctx)
0|modmail  |   File "/root/.local/share/virtualenvs/modmail-R5e9Y0tA/lib/python3.10/site-packages/discord/ext/commands/core.py", line 1029                                                                                , in invoke
0|modmail  |     await injected(*ctx.args, **ctx.kwargs)  # type: ignore
0|modmail  |   File "/root/.local/share/virtualenvs/modmail-R5e9Y0tA/lib/python3.10/site-packages/discord/ext/commands/core.py", line 244,                                                                                 in wrapped
0|modmail  |     raise CommandInvokeError(exc) from exc
0|modmail  | discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribu                                                                                te 'set_permissions'

If you delete the main_category_id on discord side without updating it in the config command it will cause the bot to throw this error when trying to set "perms add level (LEVEL) Role"

Very simple fix just add a check before trying to update perms in the event the user is an idiot like me :D I know nothing about this project otherwise I'd just make a PR plus I'm awful at python.

auyylaso avatar Nov 05 '24 15:11 auyylaso

Well this is supposed to throw an error as this is unintentional behavior. Not sure what you expect a check to fix because the set permissions will fail anyways.

sebkuip avatar Nov 05 '24 17:11 sebkuip

Just a catch that throws a message in the discord channel that the user is using. It's not needed but would be good to have some sort of feedback that isn't just terminal side.

The catch is already there for the exception. Maybe it's pointless but I'm more so thinking for the less technical savvy that may not know why the bot isn't setting permission and doesn't realize they can use ?debug to print the logs

auyylaso avatar Nov 05 '24 17:11 auyylaso

Duplicate of #3275

raidensakura avatar Nov 05 '24 18:11 raidensakura

Duplicate of #3275

Not exactly the one you posted is an error caused by a lack of permissions aka a 403 response the error that I posted is about a missing category making it so the bot can't change permissions.

auyylaso avatar Nov 05 '24 22:11 auyylaso