From d58cc216c0b5e0514d42e4e5a08c599b6084aa95 Mon Sep 17 00:00:00 2001 From: spiral Date: Fri, 14 Jan 2022 15:05:46 -0500 Subject: [PATCH] fix: unbreak error reporting for @mention prefix --- PluralKit.Bot/Bot.cs | 3 ++- PluralKit.Bot/Handlers/IEventHandler.cs | 2 +- PluralKit.Bot/Handlers/MessageCreated.cs | 6 ++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/PluralKit.Bot/Bot.cs b/PluralKit.Bot/Bot.cs index aed1abac..cd86a0e8 100644 --- a/PluralKit.Bot/Bot.cs +++ b/PluralKit.Bot/Bot.cs @@ -220,7 +220,8 @@ public class Bot return; // Once we've sent it to Sentry, report it to the user (if we have permission to) - var reportChannel = handler.ErrorChannelFor(evt); + var ourUserId = await _cache.GetOwnUser(); + var reportChannel = handler.ErrorChannelFor(evt, ourUserId); if (reportChannel == null) return; diff --git a/PluralKit.Bot/Handlers/IEventHandler.cs b/PluralKit.Bot/Handlers/IEventHandler.cs index 8cdac7c2..64cc3cc7 100644 --- a/PluralKit.Bot/Handlers/IEventHandler.cs +++ b/PluralKit.Bot/Handlers/IEventHandler.cs @@ -6,5 +6,5 @@ public interface IEventHandler where T : IGatewayEvent { Task Handle(Shard shard, T evt); - ulong? ErrorChannelFor(T evt) => null; + ulong? ErrorChannelFor(T evt, ulong userId) => null; } \ No newline at end of file diff --git a/PluralKit.Bot/Handlers/MessageCreated.cs b/PluralKit.Bot/Handlers/MessageCreated.cs index d1a5c022..7a0bf0ff 100644 --- a/PluralKit.Bot/Handlers/MessageCreated.cs +++ b/PluralKit.Bot/Handlers/MessageCreated.cs @@ -51,11 +51,9 @@ public class MessageCreated: IEventHandler } // for now, only return error messages for explicit commands - public ulong? ErrorChannelFor(MessageCreateEvent evt) + public ulong? ErrorChannelFor(MessageCreateEvent evt, ulong userId) { - // todo: fix @mention prefix - // it only breaks error reporting so I'm not *too* worried about it, but should be fixed eventually - if (!HasCommandPrefix(evt.Content, default, out var cmdStart) || cmdStart == evt.Content.Length) + if (!HasCommandPrefix(evt.Content, userId, out var cmdStart) || cmdStart == evt.Content.Length) return null; return evt.ChannelId;