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

[BUG]: module 'discord' has no attribute 'BadArgument' when forwarding reaction fails #3218

Closed
Taaku18 opened this issue Oct 20, 2022 · 0 comments
Assignees
Labels
bug This is a confirmed bug

Comments

@Taaku18
Copy link
Collaborator

Taaku18 commented Oct 20, 2022

Bot Version

v2.0.1

How are you hosting Modmail?

Other

Error Logs

N/A (see error below)

Screenshots

No response

Additional Information

Relevant traceback:

Traceback (most recent call last):
  File "/modmailbot/bot.py", line 881, in add_reaction
    await msg.add_reaction(reaction)
  File "/usr/local/lib/python3.9/site-packages/discord/message.py", line 1061, in add_reaction
    await self._state.http.add_reaction(self.channel.id, self.id, emoji)
  File "/usr/local/lib/python3.9/site-packages/discord/http.py", line 740, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 190, in wrapped
    ret = await coro(*args, **kwargs)
  File "/modmailbot/cogs/utility.py", line 52, in command_callback
    return await super().command_callback(ctx, command=command)
  File "/usr/local/lib/python3.9/site-packages/discord/ext/commands/help.py", line 943, in command_callback
    return await self.send_bot_help(mapping)
  File "/modmailbot/cogs/utility.py", line 128, in send_bot_help
    return await session.run()
  File "/modmailbot/core/paginator.py", line 162, in run
    await self.close(delete=False)
  File "/modmailbot/core/paginator.py", line 183, in close
    await self.ctx.bot.add_reaction(self.ctx.message, sent_emoji)
  File "/modmailbot/bot.py", line 882, in add_reaction
    except (discord.HTTPException, discord.BadArgument) as e:
AttributeError: module 'discord' has no attribute 'BadArgument'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 1347, in invoke
    await ctx.command.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 986, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "/usr/local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 199, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord' has no attribute 'BadArgument'

This occurs when the bot fails to forward an reaction.

To fix: change discord.BadArgument to TypeError as that's the correct potential exception (src).

Code: https://github.com/kyb3r/modmail/blame/master/bot.py#L882

@Taaku18 Taaku18 added maybe: bug An unconfirmed bug bug This is a confirmed bug and removed maybe: bug An unconfirmed bug labels Oct 20, 2022
@Taaku18 Taaku18 changed the title [BUG]: your bug report title [BUG]: module 'discord' has no attribute 'BadArgument' when forwarding reaction fails Dec 8, 2022
@Taaku18 Taaku18 self-assigned this Jul 11, 2023
@Taaku18 Taaku18 closed this as completed Jul 17, 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
Projects
None yet
Development

No branches or pull requests

1 participant