fix: MessageUpdated without author (#1858)
This commit is contained in:
@@ -1359,36 +1359,42 @@ namespace Discord.WebSocket
|
|||||||
{
|
{
|
||||||
//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)
|
||||||
{
|
|
||||||
if (data.WebhookId.IsSpecified)
|
|
||||||
author = SocketWebhookUser.Create(guild, State, data.Author.Value, data.WebhookId.Value);
|
|
||||||
else
|
|
||||||
author = guild.GetUser(data.Author.Value.Id);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
author = (channel as SocketChannel).GetUser(data.Author.Value.Id);
|
|
||||||
|
|
||||||
if (author == null)
|
|
||||||
{
|
{
|
||||||
if (guild != null)
|
if (guild != null)
|
||||||
{
|
{
|
||||||
if (data.Member.IsSpecified) // member isn't always included, but use it when we can
|
if (data.WebhookId.IsSpecified)
|
||||||
{
|
author = SocketWebhookUser.Create(guild, State, data.Author.Value, data.WebhookId.Value);
|
||||||
data.Member.Value.User = data.Author.Value;
|
|
||||||
author = guild.AddOrUpdateUser(data.Member.Value);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
author = guild.AddOrUpdateUser(data.Author.Value); // user has no guild-specific data
|
author = guild.GetUser(data.Author.Value.Id);
|
||||||
}
|
}
|
||||||
else if (channel is SocketGroupChannel groupChannel)
|
|
||||||
author = groupChannel.GetOrAddUser(data.Author.Value);
|
|
||||||
else
|
else
|
||||||
|
author = (channel as SocketChannel).GetUser(data.Author.Value.Id);
|
||||||
|
|
||||||
|
if (author == null)
|
||||||
{
|
{
|
||||||
await UnknownChannelUserAsync(type, data.Author.Value.Id, channel.Id).ConfigureAwait(false);
|
if (guild != null)
|
||||||
return;
|
{
|
||||||
|
if (data.Member.IsSpecified) // member isn't always included, but use it when we can
|
||||||
|
{
|
||||||
|
data.Member.Value.User = data.Author.Value;
|
||||||
|
author = guild.AddOrUpdateUser(data.Member.Value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
author = guild.AddOrUpdateUser(data.Author.Value); // user has no guild-specific data
|
||||||
|
}
|
||||||
|
else if (channel is SocketGroupChannel groupChannel)
|
||||||
|
author = groupChannel.GetOrAddUser(data.Author.Value);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await UnknownChannelUserAsync(type, data.Author.Value.Id, channel.Id).ConfigureAwait(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
// 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);
|
after = SocketMessage.Create(this, State, author, channel, data);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user