Fixed handling of message updates when not in cache
This commit is contained in:
@@ -762,10 +762,23 @@ namespace Discord
|
|||||||
var channel = DataStore.GetChannel(data.ChannelId) as ICachedMessageChannel;
|
var channel = DataStore.GetChannel(data.ChannelId) as ICachedMessageChannel;
|
||||||
if (channel != null)
|
if (channel != null)
|
||||||
{
|
{
|
||||||
var msg = channel.GetMessage(data.Id);
|
IMessage before = null, after = null;
|
||||||
var before = _enablePreUpdateEvents ? msg.Clone() : null;
|
CachedMessage cachedMsg = channel.GetMessage(data.Id);
|
||||||
msg.Update(data, UpdateSource.WebSocket);
|
if (cachedMsg != null)
|
||||||
await MessageUpdated.RaiseAsync(before, msg).ConfigureAwait(false);
|
{
|
||||||
|
before = _enablePreUpdateEvents ? cachedMsg.Clone() : null;
|
||||||
|
cachedMsg.Update(data, UpdateSource.WebSocket);
|
||||||
|
after = cachedMsg;
|
||||||
|
}
|
||||||
|
else if (data.Author.IsSpecified)
|
||||||
|
{
|
||||||
|
//Edited message isnt in cache, create a detached one
|
||||||
|
var author = channel.GetUser(data.Author.Value.Id);
|
||||||
|
if (author != null)
|
||||||
|
after = new Message(channel, author, data);
|
||||||
|
}
|
||||||
|
if (after != null)
|
||||||
|
await MessageUpdated.RaiseAsync(before, after).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user