Skip to content

fix: Prevent potential nullrefs on channel update event.

Mateusz Brawański requested to merge patch/null-ref-channel-update-event into master

Created by: Neuheit

Summary

Ensures null reference exceptions aren't encountered in the channel update event and also updates the channel type state.

Details

There were a few stack traces provided that showed a null reference exception occurring in this event, this PR attempts to prevent potential null refs from throwing.

Example stack trace:

Socket handler suppressed an exception - System.NullReferenceException: Object reference not set to an instance of an object.
   at DSharpPlus.DiscordClient.OnChannelUpdateEventAsync(DiscordChannel channel)
   at DSharpPlus.DiscordClient.HandleDispatchAsync(GatewayPayload payload)
   at DSharpPlus.DiscordClient.HandleSocketMessageAsync(String data)
   at DSharpPlus.DiscordClient.<InternalConnectAsync>g__SocketOnMessage|330_1(IWebSocketClient sender, SocketMessageEventArgs e)

I also made the channel type update with this event since this can be changed during the bot's uptime.

Changes proposed

  • Add null ref checks to channel update
  • Add ability for channel type to be updated.

Merge request reports

Loading