Cog-Creators / Red-DiscordBot

A multi-function Discord bot
https://docs.discord.red
GNU General Public License v3.0
4.72k stars 2.3k forks source link

Command raises an unhandled error if an ID too large is provided #6431

Open Zephyrkul opened 4 weeks ago

Zephyrkul commented 4 weeks ago

What Red version are you using?

3.4.5

Cog name

Mod

Command name

ban

What did you expect to happen?

The bot to respond that the provided user ID is too large / not a user ID

What actually happened?

Unhandled error, traceback below:

Exception in command 'ban'
Traceback (most recent call last):
  File "/home/.../.local/lib/python3.11/site-packages/discord/ext/commands/core.py", line 235, in wrapped
    ret = await coro(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.../.local/lib/python3.11/site-packages/redbot/cogs/mod/kickban.py", line 398, in ban
    success_, message = await self.ban_user(
                        ^^^^^^^^^^^^^^^^^^^^
  File "/home/.../.local/lib/python3.11/site-packages/redbot/cogs/mod/kickban.py", line 160, in ban_user
    await guild.fetch_ban(user)
  File "/home/.../.local/lib/python3.11/site-packages/discord/guild.py", line 2394, in fetch_ban
    data: BanPayload = await self._state.http.get_ban(user.id, self.id)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.../.local/lib/python3.11/site-packages/discord/http.py", line 758, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In user_id: snowflake value should be less than or equal to 9223372036854775807.

How can we reproduce this error?

Use [p]ban with an ID larger than 2^63-1

Anything else?

Other commands that take in a user ID and make an API request might also have to be double-checked