Skip to content

fix: channel id might be null #2078

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

Merged
merged 10 commits into from
May 23, 2023
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2048](https://github.com/Pycord-Development/pycord/pull/2048))
- Fixed the Slash command syncronization method `indiviual`.
([#1925](https://github.com/Pycord-Development/pycord/pull/1925))
- Fixed an issue that occurred when `webhooks_update` event payload channel ID was
`None`. ([#2078](https://github.com/Pycord-Development/pycord/pull/2078))
- Fixed major TypeError when an AuditLogEntry has no user.
([#2079](https://github.com/Pycord-Development/pycord/pull/2079))

Expand Down
17 changes: 12 additions & 5 deletions discord/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -1637,13 +1637,20 @@ def parse_webhooks_update(self, data) -> None:
)
return

channel = guild.get_channel(int(data["channel_id"]))
if channel is not None:
self.dispatch("webhooks_update", channel)
channel_id = data["channel_id"]
if channel_id is not None:
channel = guild.get_channel(int(channel_id))
if channel is not None:
self.dispatch("webhooks_update", channel)
else:
_log.debug(
"WEBHOOKS_UPDATE referencing an unknown channel ID: %s. Discarding.",
data["channel_id"],
)
else:
_log.debug(
"WEBHOOKS_UPDATE referencing an unknown channel ID: %s. Discarding.",
data["channel_id"],
"WEBHOOKS_UPDATE channel ID was null for guild: %s. Discarding.",
data["guild_id"],
)

def parse_stage_instance_create(self, data) -> None:
Expand Down