Browse Source

fix: Fix after message remaining in MessageUpdated if message author wasn't in the payload (#1209)

* Fix leaving updated message as null when Discords doesn't include a message author in MESSAGE_UPDATE

* Name! That! Parameter!
tags/2.0
Alex Gravely Christopher F 6 years ago
parent
commit
91e0f03bfd
1 changed files with 12 additions and 6 deletions
  1. +12
    -6
      src/Discord.Net.WebSocket/DiscordSocketClient.cs

+ 12
- 6
src/Discord.Net.WebSocket/DiscordSocketClient.cs View File

@@ -1218,16 +1218,22 @@ namespace Discord.WebSocket
cachedMsg.Update(State, data);
after = cachedMsg;
}
else if (data.Author.IsSpecified)
else
{
//Edited message isnt in cache, create a detached one
SocketUser author;
if (guild != null)
author = guild.GetUser(data.Author.Value.Id);
if (data.Author.IsSpecified)
{
if (guild != null)
author = guild.GetUser(data.Author.Value.Id);
else
author = (channel as SocketChannel).GetUser(data.Author.Value.Id);
if (author == null)
author = SocketUnknownUser.Create(this, State, data.Author.Value);
}
else
author = (channel as SocketChannel).GetUser(data.Author.Value.Id);
if (author == null)
author = SocketUnknownUser.Create(this, State, data.Author.Value);
// Message author wasn't specified in the payload, so create a completely anonymous unknown user
author = new SocketUnknownUser(this, id: 0);

after = SocketMessage.Create(this, State, author, channel, data);
}


Loading…
Cancel
Save