From d49b9f9bb76ee484781cae6984b86a1bb5ff2f24 Mon Sep 17 00:00:00 2001 From: spiral Date: Sat, 25 Sep 2021 15:04:06 -0400 Subject: [PATCH] ignore reactions added by the bot itself --- PluralKit.Bot/Handlers/ReactionAdded.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/PluralKit.Bot/Handlers/ReactionAdded.cs b/PluralKit.Bot/Handlers/ReactionAdded.cs index be2ff94c..47f1f3b1 100644 --- a/PluralKit.Bot/Handlers/ReactionAdded.cs +++ b/PluralKit.Bot/Handlers/ReactionAdded.cs @@ -25,15 +25,17 @@ namespace PluralKit.Bot private readonly IDiscordCache _cache; private readonly EmbedService _embeds; private readonly Bot _bot; + private readonly Cluster _cluster; private readonly DiscordApiClient _rest; - public ReactionAdded(ILogger logger, IDatabase db, ModelRepository repo, CommandMessageService commandMessageService, IDiscordCache cache, Bot bot, DiscordApiClient rest, EmbedService embeds) + public ReactionAdded(ILogger logger, IDatabase db, ModelRepository repo, CommandMessageService commandMessageService, IDiscordCache cache, Bot bot, Cluster cluster, DiscordApiClient rest, EmbedService embeds) { _db = db; _repo = repo; _commandMessageService = commandMessageService; _cache = cache; _bot = bot; + _cluster = cluster; _rest = rest; _embeds = embeds; _logger = logger.ForContext(); @@ -51,6 +53,13 @@ namespace PluralKit.Bot if (!_cache.TryGetUser(evt.UserId, out var user)) return; + // ignore any reactions added by *us* + if (evt.UserId == _cluster.User?.Id) + return; + + // Ignore reactions from bots (we can't DM them anyway) + if (user.Bot) return; + var channel = _cache.GetChannel(evt.ChannelId); // check if it's a command message first @@ -75,9 +84,6 @@ namespace PluralKit.Bot // Proxied messages only exist in guild text channels, so skip checking if we're elsewhere if (!DiscordUtils.IsValidGuildChannel(channel)) return; - // Ignore reactions from bots (we can't DM them anyway) - if (user.Bot) return; - switch (evt.Emoji.Name) { // Message deletion