ignore reactions added by the bot itself
This commit is contained in:
parent
8aa448c475
commit
d49b9f9bb7
@ -25,15 +25,17 @@ namespace PluralKit.Bot
|
|||||||
private readonly IDiscordCache _cache;
|
private readonly IDiscordCache _cache;
|
||||||
private readonly EmbedService _embeds;
|
private readonly EmbedService _embeds;
|
||||||
private readonly Bot _bot;
|
private readonly Bot _bot;
|
||||||
|
private readonly Cluster _cluster;
|
||||||
private readonly DiscordApiClient _rest;
|
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;
|
_db = db;
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_commandMessageService = commandMessageService;
|
_commandMessageService = commandMessageService;
|
||||||
_cache = cache;
|
_cache = cache;
|
||||||
_bot = bot;
|
_bot = bot;
|
||||||
|
_cluster = cluster;
|
||||||
_rest = rest;
|
_rest = rest;
|
||||||
_embeds = embeds;
|
_embeds = embeds;
|
||||||
_logger = logger.ForContext<ReactionAdded>();
|
_logger = logger.ForContext<ReactionAdded>();
|
||||||
@ -51,6 +53,13 @@ namespace PluralKit.Bot
|
|||||||
if (!_cache.TryGetUser(evt.UserId, out var user))
|
if (!_cache.TryGetUser(evt.UserId, out var user))
|
||||||
return;
|
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);
|
var channel = _cache.GetChannel(evt.ChannelId);
|
||||||
|
|
||||||
// check if it's a command message first
|
// 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
|
// Proxied messages only exist in guild text channels, so skip checking if we're elsewhere
|
||||||
if (!DiscordUtils.IsValidGuildChannel(channel)) return;
|
if (!DiscordUtils.IsValidGuildChannel(channel)) return;
|
||||||
|
|
||||||
// Ignore reactions from bots (we can't DM them anyway)
|
|
||||||
if (user.Bot) return;
|
|
||||||
|
|
||||||
switch (evt.Emoji.Name)
|
switch (evt.Emoji.Name)
|
||||||
{
|
{
|
||||||
// Message deletion
|
// Message deletion
|
||||||
|
Loading…
x
Reference in New Issue
Block a user