Skip to content

Fixed DM Channels being null on API requests

Created by: DWaffles

Summary

As @cmsteffey brought up in #lib-discussion, any API request for messages within a DM returns messages with null channels. This fixes that.

Details

Modified PrepareMessage() in DiscordApiClient to check if the prepared message channel is null and construct channel objects from there.

The code is largely stolen based off UpdateMessage() in DiscordClient. I'm not sure why GuildId isn't set either for the base channel in the original code, but if it isn't broke don't fix it. https://github.com/DSharpPlus/DSharpPlus/blob/4281c5911997008400522111287e0b661a000d41/DSharpPlus/Clients/DiscordClient.cs#L776-L791

Notes

I've done light testing and nothing is broken, at least with, GetMessagesAsync(), GetMessageAsync(), creating messages via builder or content, GetPinnedMessagesAsync(), and ModifyAsync().

Merge request reports

Loading