diff options
| author | ilotterytea <iltsu@alright.party> | 2025-04-08 01:07:35 +0400 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-04-08 01:07:35 +0400 |
| commit | b25877f1bb26cf44ed5527f2f21af5734aa99052 (patch) | |
| tree | 6dcf9cf85063594cce5ccbcbc50bd7d781f3738d /bot/src | |
| parent | 112136c184bcb226fa84e9b5a39c2d1dc557c4d3 (diff) | |
feat: remove previous command if it exists
Diffstat (limited to 'bot/src')
| -rw-r--r-- | bot/src/commands/command.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
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> 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)); } |
