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
fix(state): hard crash when user_id is None #1014
Conversation
Co-authored-by: toolifelesstocode <toolifelesstocode@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm if it's been tested
In the future I would recommend using a separate branch in your fork other than |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't tested, but looks good to me. This properly reflects ddocs listing user_id
as a nullable field.
* Fix hard crash when user_id is None Reflect https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object * Change to literal key word Co-authored-by: toolifelesstocode <toolifelesstocode@gmail.com> * refactor(state): use data.get("user_id") for cheaner checks * fix(state): ignore if user is None in audit log entry --------- Co-authored-by: toolifelesstocode <toolifelesstocode@gmail.com> Co-authored-by: Oliver Wilkes <oliverwilkes2006@icloud.com>
After this there is a new error Traceback (most recent call last):
File "/myBot/bot.py", line 214, in <module>
bot.run(os.environ["TOKEN"])
File "/myBot/venv/lib/python3.8/site-packages/nextcord/client.py", line 871, in run
return future.result()
File "/myBot/venv/lib/python3.8/site-packages/nextcord/client.py", line 850, in runner
await self.start(*args, **kwargs)
File "/myBot/venv/lib/python3.8/site-packages/nextcord/client.py", line 814, in start
await self.connect(reconnect=reconnect)
File "/myBot/venv/lib/python3.8/site-packages/nextcord/shard.py", line 511, in connect
raise item.error
File "/myBot/venv/lib/python3.8/site-packages/nextcord/shard.py", line 152, in worker
await self.ws.poll_event()
File "/myBot/venv/lib/python3.8/site-packages/nextcord/gateway.py", line 603, in poll_event
await self.received_message(msg.data)
File "/myBot/venv/lib/python3.8/site-packages/nextcord/gateway.py", line 553, in received_message
func(data)
File "/myBot/venv/lib/python3.8/site-packages/nextcord/state.py", line 2318, in parse_guild_audit_log_entry_create
entry = AuditLogEntry(auto_moderation_rules={}, users=users, data=data, guild=guild)
File "/myBot/venv/lib/python3.8/site-packages/nextcord/audit_logs.py", line 457, in __init__
self._from_data(data)
File "/myBot/venv/lib/python3.8/site-packages/nextcord/audit_logs.py", line 519, in _from_data
channel_id = int(self.extra["channel_id"])
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType' |
Reflect https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object
Summary
Fix issue like detailed in https://discord.com/channels/881118111967883295/1084474550345023638
Checklist
task pyright
and fixed the relevant issues.