From 8aa448c475011361c22830380ac972db120a207c Mon Sep 17 00:00:00 2001 From: Ske Date: Sat, 25 Sep 2021 20:24:16 +0200 Subject: [PATCH] Fix executing some commands without defs --- PluralKit.Bot/CommandSystem/Context.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PluralKit.Bot/CommandSystem/Context.cs b/PluralKit.Bot/CommandSystem/Context.cs index cc5ff89f..ec790b16 100644 --- a/PluralKit.Bot/CommandSystem/Context.cs +++ b/PluralKit.Bot/CommandSystem/Context.cs @@ -37,7 +37,7 @@ namespace PluralKit.Bot private readonly CommandMessageService _commandMessageService; private readonly IDiscordCache _cache; - private Command _currentCommand; + private Command? _currentCommand; public Context(ILifetimeScope provider, Shard shard, Guild? guild, Channel channel, MessageCreateEvent message, int commandParseOffset, PKSystem senderSystem, MessageContext messageContext) @@ -110,20 +110,20 @@ namespace PluralKit.Bot return msg; } - public async Task Execute(Command commandDef, Func handler) + public async Task Execute(Command? commandDef, Func handler) { _currentCommand = commandDef; try { - using (_metrics.Measure.Timer.Time(BotMetrics.CommandTime, new MetricTags("Command", commandDef.Key))) + using (_metrics.Measure.Timer.Time(BotMetrics.CommandTime, new MetricTags("Command", commandDef?.Key ?? "null"))) await handler(_provider.Resolve()); _metrics.Measure.Meter.Mark(BotMetrics.CommandsRun); } catch (PKSyntaxError e) { - await Reply($"{Emojis.Error} {e.Message}\n**Command usage:**\n> pk;{commandDef.Usage}"); + await Reply($"{Emojis.Error} {e.Message}\n**Command usage:**\n> pk;{commandDef?.Usage}"); } catch (PKError e) {