Birthday cog : Console flooding with the same errors
Closed this issue · 3 comments
What cog is this bug report for?
Birthday
What versions are you running?
Versions
╷ ╷ ╷
│ Current │ Latest │ Up to date?
╶───────────────┼─────────┼─────────┼─────────────╴
This Cog │ 1.2.0 │ 1.2.0 │ 🟢
Bundled Utils │ b980728 │ b980728 │ 🟢
Red │ 3.4.18 │ 3.4.18 │ 🟢
╵ ╵ ╵
Describe the bug
When launching the bot, it keeps floodinfg the shell with the following errors, even if using simple commands like "bdset msgwithoutyear Happy birthday {mention}!"
If there's an error, paste it here
NotFound: 404 Not Found (error code: 10011): Unknown Role
WARNING [red.vex.birthday.loop] A queued coro failed to run.
╭──────────────────────────── Traceback (most recent call last) ─────────────────────────────╮
│ /home/alfred/.local/share/Red-DiscordBot/data/monenv/cogs/CogManager/cogs/birthday/loop.py │
│ :32 in birthday_role_manager │
│ ❱ 32 await coro │
│ /home/alfred/redenv/lib/python3.9/site-packages/discord/member.py:822 in remove_roles │
│ ❱ 822 await req(guild_id, user_id, role.id, reason=reason) │
│ /home/alfred/redenv/lib/python3.9/site-packages/discord/http.py:250 in request │
│ ❱ 250 raise NotFound(r, data) │
╰────────────────────────────────────────────────────────────────────────────────────────────╯
NotFound: 404 Not Found (error code: 10011): Unknown Role
WARNING [red.vex.birthday.loop] A queued coro failed to run.
╭──────────────────────────── Traceback (most recent call last) ─────────────────────────────╮
│ /home/alfred/.local/share/Red-DiscordBot/data/monenv/cogs/CogManager/cogs/birthday/loop.py │
│ :32 in birthday_role_manager │
│ ❱ 32 await coro │
│ /home/alfred/redenv/lib/python3.9/site-packages/discord/member.py:822 in remove_roles │
│ ❱ 822 await req(guild_id, user_id, role.id, reason=reason) │
│ /home/alfred/redenv/lib/python3.9/site-packages/discord/http.py:250 in request │
│ ❱ 250 raise NotFound(r, data) │
╰────────────────────────────────────────────────────────────────────────────────────────────╯
NotFound: 404 Not Found (error code: 10011): Unknown Role
[07:15:35] WARNING [red.vex.birthday.loop] A queued coro failed to run.
╭──────────────────────────── Traceback (most recent call last) ─────────────────────────────╮
│ /home/alfred/.local/share/Red-DiscordBot/data/monenv/cogs/CogManager/cogs/birthday/loop.py │
│ :32 in birthday_role_manager │
│ ❱ 32 await coro │
│ /home/alfred/redenv/lib/python3.9/site-packages/discord/member.py:822 in remove_roles │
│ ❱ 822 await req(guild_id, user_id, role.id, reason=reason) │
│ /home/alfred/redenv/lib/python3.9/site-packages/discord/http.py:250 in request │
│ ❱ 250 raise NotFound(r, data) │
╰────────────────────────────────────────────────────────────────────────────────────────────╯
NotFound: 404 Not Found (error code: 10011): Unknown Role
WARNING [red.vex.birthday.loop] A queued coro failed to run.
╭──────────────────────────── Traceback (most recent call last) ─────────────────────────────╮
│ /home/alfred/.local/share/Red-DiscordBot/data/monenv/cogs/CogManager/cogs/birthday/loop.py │
│ :32 in birthday_role_manager │
│ ❱ 32 await coro │
│ /home/alfred/redenv/lib/python3.9/site-packages/discord/member.py:822 in remove_roles │
│ ❱ 822 await req(guild_id, user_id, role.id, reason=reason) │
│ /home/alfred/redenv/lib/python3.9/site-packages/discord/http.py:250 in request │
│ ❱ 250 raise NotFound(r, data) │
╰────────────────────────────────────────────────────────────────────────────────────────────╯
NotFound: 404 Not Found (error code: 10011): Unknown Role
Thanks for sharing the error. While this isn't directly caused by my cog, I should include user-friendly error handling for scenarios like this when Discord responds with errors. It appears the birthday role was deleted in the server, so you could temporarily fix this by making a new one and setting the cog to use it, or unloading the cog. I'll send another message here when I release an update to handle this better.
Thanks!
Actually I can't read the error properly! That's a warning from here so there is an element of handling by my own code.
This is unlikely to happen. There is already a check that the role exists, however this uses a cached guild object. I guess you were just unlucky. I will consider fetching an updated guild object from Discord but this won't necessarily scale well. I'll have to take a look at rate limits but unfortunately, I think this is highly unlikely and does not justify fetching the guild object from Discord. Core Red and nearly all cogs are coded to trust the cache. The cached guild object should by updated automatically by discord.py.