don't cache the full message
This commit is contained in:
parent
a7189fab8c
commit
0acadee803
@ -64,6 +64,8 @@ namespace PluralKit.Bot
|
|||||||
using (_metrics.Measure.Timer.Time(BotMetrics.MessageContextQueryTime))
|
using (_metrics.Measure.Timer.Time(BotMetrics.MessageContextQueryTime))
|
||||||
ctx = await _repo.GetMessageContext(conn, evt.Author.Value!.Id, channel.GuildId!.Value, evt.ChannelId);
|
ctx = await _repo.GetMessageContext(conn, evt.Author.Value!.Id, channel.GuildId!.Value, evt.ChannelId);
|
||||||
|
|
||||||
|
Message referencedMessage = (lastMessage.referenced_message != null) ? await _rest.GetMessage(evt.ChannelId, lastMessage.referenced_message.Value) : null;
|
||||||
|
|
||||||
// TODO: is this missing anything?
|
// TODO: is this missing anything?
|
||||||
var equivalentEvt = new MessageCreateEvent
|
var equivalentEvt = new MessageCreateEvent
|
||||||
{
|
{
|
||||||
@ -74,9 +76,9 @@ namespace PluralKit.Bot
|
|||||||
Member = evt.Member.Value,
|
Member = evt.Member.Value,
|
||||||
Content = evt.Content.Value,
|
Content = evt.Content.Value,
|
||||||
Attachments = evt.Attachments.Value ?? Array.Empty<Message.Attachment>(),
|
Attachments = evt.Attachments.Value ?? Array.Empty<Message.Attachment>(),
|
||||||
MessageReference = (lastMessage.referenced_message.HasValue) ? new (channel.GuildId, evt.ChannelId, lastMessage.referenced_message.Value.Id) : null,
|
MessageReference = (lastMessage.referenced_message != null) ? new (channel.GuildId, evt.ChannelId, lastMessage.referenced_message.Value) : null,
|
||||||
ReferencedMessage = (lastMessage.referenced_message.HasValue) ? lastMessage.referenced_message : null,
|
ReferencedMessage = referencedMessage,
|
||||||
Type = (lastMessage.referenced_message.HasValue) ? Message.MessageType.Reply : Message.MessageType.Default,
|
Type = (lastMessage.referenced_message != null) ? Message.MessageType.Reply : Message.MessageType.Default,
|
||||||
};
|
};
|
||||||
var botPermissions = _bot.PermissionsIn(channel.Id);
|
var botPermissions = _bot.PermissionsIn(channel.Id);
|
||||||
await _proxy.HandleIncomingMessage(shard, equivalentEvt, ctx, allowAutoproxy: false, guild: guild, channel: channel, botPermissions: botPermissions);
|
await _proxy.HandleIncomingMessage(shard, equivalentEvt, ctx, allowAutoproxy: false, guild: guild, channel: channel, botPermissions: botPermissions);
|
||||||
|
@ -29,12 +29,13 @@ namespace PluralKit.Bot
|
|||||||
public class CachedMessage
|
public class CachedMessage
|
||||||
{
|
{
|
||||||
public ulong mid;
|
public ulong mid;
|
||||||
public Myriad.Utils.Optional<Message> referenced_message;
|
public ulong? referenced_message;
|
||||||
|
|
||||||
public CachedMessage(Message msg)
|
public CachedMessage(Message msg)
|
||||||
{
|
{
|
||||||
mid = msg.Id;
|
mid = msg.Id;
|
||||||
referenced_message = msg.ReferencedMessage;
|
if (msg.ReferencedMessage.HasValue)
|
||||||
|
referenced_message = msg.ReferencedMessage.Value.Id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user