From b25877f1bb26cf44ed5527f2f21af5734aa99052 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 8 Apr 2025 01:07:35 +0400 Subject: feat: remove previous command if it exists --- bot/src/commands/command.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'bot/src') diff --git a/bot/src/commands/command.cpp b/bot/src/commands/command.cpp index 4544810..6d3010e 100644 --- a/bot/src/commands/command.cpp +++ b/bot/src/commands/command.cpp @@ -84,6 +84,13 @@ namespace bot { } void CommandLoader::add_command(std::unique_ptr command) { + auto it = std::find_if(this->commands.begin(), this->commands.end(), + [&command](const auto &x) { + return command->get_name() == x->get_name(); + }); + if (it != this->commands.end()) { + this->commands.erase(it); + } this->commands.push_back(std::move(command)); } -- cgit v1.2.3