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!
This commit is contained in:
committed by
Christopher F
parent
f6413bac59
commit
91e0f03bfd
@@ -1218,16 +1218,22 @@ namespace Discord.WebSocket
|
|||||||
cachedMsg.Update(State, data);
|
cachedMsg.Update(State, data);
|
||||||
after = cachedMsg;
|
after = cachedMsg;
|
||||||
}
|
}
|
||||||
else if (data.Author.IsSpecified)
|
else
|
||||||
{
|
{
|
||||||
//Edited message isnt in cache, create a detached one
|
//Edited message isnt in cache, create a detached one
|
||||||
SocketUser author;
|
SocketUser author;
|
||||||
if (guild != null)
|
if (data.Author.IsSpecified)
|
||||||
author = guild.GetUser(data.Author.Value.Id);
|
{
|
||||||
|
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
|
else
|
||||||
author = (channel as SocketChannel).GetUser(data.Author.Value.Id);
|
// Message author wasn't specified in the payload, so create a completely anonymous unknown user
|
||||||
if (author == null)
|
author = new SocketUnknownUser(this, id: 0);
|
||||||
author = SocketUnknownUser.Create(this, State, data.Author.Value);
|
|
||||||
|
|
||||||
after = SocketMessage.Create(this, State, author, channel, data);
|
after = SocketMessage.Create(this, State, author, channel, data);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user