Skip to content

Commit

Permalink
fix: channel id might be null (#2078)
Browse files Browse the repository at this point in the history
* fix: channel id might be null

* style(pre-commit): auto fixes from pre-commit.com hooks

* docs: changelog

* Update CHANGELOG.md

Co-authored-by: BobDotCom <71356958+BobDotCom@users.noreply.github.com>
Signed-off-by: Lala Sabathil <aiko@aitsys.dev>

* Update CHANGELOG.md

Signed-off-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>

* style(pre-commit): auto fixes from pre-commit.com hooks

---------

Signed-off-by: Lala Sabathil <aiko@aitsys.dev>
Signed-off-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
Signed-off-by: Lala Sabathil <lala@pycord.dev>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: BobDotCom <71356958+BobDotCom@users.noreply.github.com>
Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
  • Loading branch information
4 people committed May 23, 2023
1 parent ad7056d commit 8950c2e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
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
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

0 comments on commit 8950c2e

Please sign in to comment.