don't cache the full message

This commit is contained in:
spiral 2021-03-22 07:17:10 +00:00
parent a7189fab8c
commit 0acadee803
No known key found for this signature in database
GPG Key ID: A6059F0CA0E1BD31
2 changed files with 8 additions and 5 deletions

View File

@ -64,6 +64,8 @@ namespace PluralKit.Bot
using (_metrics.Measure.Timer.Time(BotMetrics.MessageContextQueryTime))
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?
var equivalentEvt = new MessageCreateEvent
{
@ -74,9 +76,9 @@ namespace PluralKit.Bot
Member = evt.Member.Value,
Content = evt.Content.Value,
Attachments = evt.Attachments.Value ?? Array.Empty<Message.Attachment>(),
MessageReference = (lastMessage.referenced_message.HasValue) ? new (channel.GuildId, evt.ChannelId, lastMessage.referenced_message.Value.Id) : null,
ReferencedMessage = (lastMessage.referenced_message.HasValue) ? lastMessage.referenced_message : null,
Type = (lastMessage.referenced_message.HasValue) ? Message.MessageType.Reply : Message.MessageType.Default,
MessageReference = (lastMessage.referenced_message != null) ? new (channel.GuildId, evt.ChannelId, lastMessage.referenced_message.Value) : null,
ReferencedMessage = referencedMessage,
Type = (lastMessage.referenced_message != null) ? Message.MessageType.Reply : Message.MessageType.Default,
};
var botPermissions = _bot.PermissionsIn(channel.Id);
await _proxy.HandleIncomingMessage(shard, equivalentEvt, ctx, allowAutoproxy: false, guild: guild, channel: channel, botPermissions: botPermissions);

View File

@ -29,12 +29,13 @@ namespace PluralKit.Bot
public class CachedMessage
{
public ulong mid;
public Myriad.Utils.Optional<Message> referenced_message;
public ulong? referenced_message;
public CachedMessage(Message msg)
{
mid = msg.Id;
referenced_message = msg.ReferencedMessage;
if (msg.ReferencedMessage.HasValue)
referenced_message = msg.ReferencedMessage.Value.Id;
}
}
}