dolfies / discord.py-self

A fork of the popular discord.py for user accounts.
https://discordpy-self.rtfd.io/en/latest/
MIT License
720 stars 165 forks source link

Can't Seem To Catch discord.Forbidden Exception #677

Closed ahihiyou20 closed 6 months ago

ahihiyou20 commented 8 months ago

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

Checklist

Additional Information

No response

dolfies commented 6 months ago

The provided error is not coming from the given code. It's being raised by code that tries to use an app command.