Browse Source

fix: don't assume the member will always be included on MESSAGE_CREATE (#1167)

* fix: don't assume the member will always be included on MESSAGE_CREATE

This resolves #1153.

Member objects are only included on a message when the user has
transitioned from an offline state to an online state (i think?), so
this change will fall back to the prior behavior, where we just create
an incomplete member object for these states.

* lint: use a ternary in place of an if/else block
tags/2.0
Christopher F GitHub 6 years ago
parent
commit
8df2c1a1fb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      src/Discord.Net.WebSocket/DiscordSocketClient.cs

+ 5
- 1
src/Discord.Net.WebSocket/DiscordSocketClient.cs View File

@@ -1158,7 +1158,11 @@ namespace Discord.WebSocket
if (author == null)
{
if (guild != null)
author = guild.AddOrUpdateUser(data.Member.Value); //per g250k, we can create an entire member now
{
author = data.Member.IsSpecified // member isn't always included, but use it when we can
? guild.AddOrUpdateUser(data.Member.Value)
: guild.AddOrUpdateUser(data.Author.Value); // user has no guild-specific data
}
else if (channel is SocketGroupChannel)
author = (channel as SocketGroupChannel).GetOrAddUser(data.Author.Value);
else


Loading…
Cancel
Save