Merge remote-tracking branch 'upstream/main' into rust-command-parser

This commit is contained in:
dusk 2025-08-09 17:38:44 +03:00
commit f721b850d4
No known key found for this signature in database
183 changed files with 5121 additions and 1909 deletions

View file

@ -55,7 +55,9 @@ public class MessageCreated: IEventHandler<MessageCreateEvent>
public (ulong?, ulong?) ErrorChannelFor(MessageCreateEvent evt, ulong userId) => (evt.GuildId, evt.ChannelId);
private bool IsDuplicateMessage(Message msg) =>
// We consider a message duplicate if it has the same ID as the previous message that hit the gateway
_lastMessageCache.GetLastMessage(msg.ChannelId)?.Current.Id == msg.Id;
// use only the local cache here
// http gateway sets last message before forwarding the message here, so this will always return true
_lastMessageCache._GetLastMessage(msg.ChannelId)?.Current.Id == msg.Id;
public async Task Handle(int shardId, MessageCreateEvent evt)
{

View file

@ -65,7 +65,7 @@ public class MessageEdited: IEventHandler<MessageUpdateEvent>
var guild = await _cache.TryGetGuild(channel.GuildId!.Value);
if (guild == null)
throw new Exception("could not find self guild in MessageEdited event");
var lastMessage = _lastMessageCache.GetLastMessage(evt.ChannelId)?.Current;
var lastMessage = (await _lastMessageCache.GetLastMessage(evt.GuildId.HasValue ? evt.GuildId.Value ?? 0 : 0, evt.ChannelId))?.Current;
// Only react to the last message in the channel
if (lastMessage?.Id != evt.Id)
@ -107,10 +107,6 @@ public class MessageEdited: IEventHandler<MessageUpdateEvent>
? new Message.Reference(channel.GuildId, evt.ChannelId, lastMessage.ReferencedMessage.Value)
: null;
var messageType = lastMessage.ReferencedMessage != null
? Message.MessageType.Reply
: Message.MessageType.Default;
// TODO: is this missing anything?
var equivalentEvt = new MessageCreateEvent
{
@ -123,7 +119,7 @@ public class MessageEdited: IEventHandler<MessageUpdateEvent>
Attachments = evt.Attachments.Value ?? Array.Empty<Message.Attachment>(),
MessageReference = messageReference,
ReferencedMessage = referencedMessage,
Type = messageType,
Type = evt.Type,
};
return equivalentEvt;
}

View file

@ -111,6 +111,7 @@ public class ReactionAdded: IEventHandler<MessageReactionAddEvent>
case "\U0001F514": // Bell
case "\U0001F6CE": // Bellhop bell
case "\U0001F3D3": // Ping pong paddle (lol)
case "\U0001FAD1": // Bell pepper
case "\u23F0": // Alarm clock
case "\u2757": // Exclamation mark
{