refactor(bot): remove saving own user ID from ready event, rely on ID in config

This commit is contained in:
spiral
2022-09-06 09:52:37 +00:00
parent aeb6411b6c
commit 9303dbb91e
17 changed files with 51 additions and 69 deletions

View File

@@ -18,6 +18,7 @@ namespace PluralKit.Bot;
public class ReactionAdded: IEventHandler<MessageReactionAddEvent>
{
private readonly Bot _bot;
private readonly BotConfig _config;
private readonly IDiscordCache _cache;
private readonly Cluster _cluster;
private readonly CommandMessageService _commandMessageService;
@@ -30,13 +31,14 @@ public class ReactionAdded: IEventHandler<MessageReactionAddEvent>
public ReactionAdded(ILogger logger, IDatabase db, ModelRepository repo,
CommandMessageService commandMessageService, IDiscordCache cache, Bot bot, Cluster cluster,
DiscordApiClient rest, EmbedService embeds, PrivateChannelService dmCache)
BotConfig config, DiscordApiClient rest, EmbedService embeds, PrivateChannelService dmCache)
{
_db = db;
_repo = repo;
_commandMessageService = commandMessageService;
_cache = cache;
_bot = bot;
_config = config;
_cluster = cluster;
_rest = rest;
_embeds = embeds;
@@ -52,7 +54,7 @@ public class ReactionAdded: IEventHandler<MessageReactionAddEvent>
private async ValueTask TryHandleProxyMessageReactions(MessageReactionAddEvent evt)
{
// ignore any reactions added by *us*
if (evt.UserId == await _cache.GetOwnUser())
if (evt.UserId == _config.ClientId)
return;
// Ignore reactions from bots (we can't DM them anyway)