discord.py-self
discord.py-self copied to clipboard
Can't Seem To Catch discord.Forbidden Exception
Summary
discord.errors.Forbidden, discord.Forbidden, discord.DiscordException CAN'T be used to catch a forbidden error
Reproduction Steps
try:
cmds = await self.get_channel(channel: int).application_commands()
except discord.DiscordException: # Even Exception or discord.DiscordException won't trigger the code below
print("OOPS")
Code
try:
cmds = await self.get_channel(channel: int).application_commands()
except discord.DiscordException: # Even Exception or discord.DiscordException won't trigger the code below
print("OOPS")
Expected Results
print "OOPS" if the bot can't get the slash commands due to lack of permissions
Actual Results
it doesn't print "OOPS" and the exception is raised
Traceback:
File "c:\Users\ahihiyou20\scoop\apps\python\current\Lib\site-packages\discord\commands.py", line 140, in __call__
return await _wrapped_interaction(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\ducna\scoop\apps\python\current\Lib\site-packages\discord\interactions.py", line 203, in _wrapped_interaction
await state.http.interact(type, data, channel, nonce=nonce, **kwargs)
File "c:\Users\ducna\scoop\apps\python\current\Lib\site-packages\discord\http.py", line 926, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
System Information
- Python v3.12.2-final
- discord.py-self v2.1.0-alpha
- discord.py-self metadata: v2.1.0a4845+g51d43a15
- aiohttp v3.9.3
- system info: Windows 10 10.0.19045
Checklist
- [X] I have searched the open issues for duplicates.
- [X] I have shared the entire traceback.
- [X] I am using a user token (and it isn't visible in the code).
Additional Information
No response