vertyco / vrt-cogs

Utility and fun cogs for Red
MIT License
49 stars 29 forks source link

[NoNuke] Getting rate limited (429-ed) #164

Closed cool-aid-man closed 10 months ago

cool-aid-man commented 10 months ago

Hey Alex getting this on nonuke

#7963 [2023-12-18 17:20:24] ERROR [discord.client] Ignoring exception in on_guild_role_update.
Traceback (most recent call last):
File "{HOME}/redenv/lib/python3.11/site-packages/discord/client.py", line 441, in _run_event
await coro(*args, **kwargs)
File "{HOME}/.local/share/Red-DiscordBot/data/dusky/cogs/CogManager/cogs/nonuke/listen.py", line 286, in on_guild_role_update
user = await self.get_audit_log_reason(guild, before, discord.AuditLogAction.role_update)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "{HOME}/.local/share/Red-DiscordBot/data/dusky/cogs/CogManager/cogs/nonuke/listen.py", line 202, in get_audit_log_reason
async for entry in guild.audit_logs(limit=5, action=action):
File "{HOME}/redenv/lib/python3.11/site-packages/discord/guild.py", line 3922, in audit_logs
data, raw_entries, state, limit = await strategy(retrieve, state, limit)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "{HOME}/redenv/lib/python3.11/site-packages/discord/guild.py", line 3855, in _before_strategy
data = await self._state.http.get_audit_logs(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "{HOME}/redenv/lib/python3.11/site-packages/discord/http.py", line 760, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 429 Too Many Requests (error code: 0): You are being rate limited.

Spammed the whole console with 429-ed

NoNuke

Not a big bot, just ~6k users with one big & a few test servers.

vertyco commented 10 months ago

Cog has been updated to use the dpy listener for audit logs now and keeps a cache, so the 429s should no longer be an issue