From 31f12a41106f0fdb56d917ab3e9d22862e653b5a Mon Sep 17 00:00:00 2001 From: Daan Boerlage Date: Sat, 6 Nov 2021 18:20:16 +0100 Subject: [PATCH] Add command type level to interaction command dictionary --- src/Core/Interactions/InteractionCommandManager.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Core/Interactions/InteractionCommandManager.cs b/src/Core/Interactions/InteractionCommandManager.cs index dee25b5..ec40c00 100644 --- a/src/Core/Interactions/InteractionCommandManager.cs +++ b/src/Core/Interactions/InteractionCommandManager.cs @@ -19,7 +19,11 @@ namespace Geekbot.Core.Interactions private readonly IGuildSettingsManager _guildSettingsManager; - private readonly Dictionary _commands = new(); + private readonly Dictionary> _commands = new() { + { CommandType.Message, new Dictionary() }, + { CommandType.User, new Dictionary() }, + { CommandType.ChatInput, new Dictionary() }, + }; public Dictionary CommandsInfo { get; init; } @@ -38,14 +42,14 @@ namespace Geekbot.Core.Interactions { var instance = (InteractionBase)ActivatorUtilities.CreateInstance(provider, interactionType); var commandInfo = instance.GetCommandInfo(); - _commands.Add(commandInfo.Name, interactionType); - CommandsInfo.Add(commandInfo.Name, commandInfo); + _commands[commandInfo.Type].Add(commandInfo.Name, interactionType); + CommandsInfo.Add($"{commandInfo.Type}-{commandInfo.Name}", commandInfo); } } public async Task RunCommand(Interaction interaction) { - var type = _commands[interaction.Data.Name]; + var type = _commands[interaction.Data.Type][interaction.Data.Name]; var command = ActivatorUtilities.CreateInstance(_provider, type) as InteractionBase; if (command == null)