summaryrefslogtreecommitdiff
path: root/bot
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-04-08 01:07:35 +0400
committerilotterytea <iltsu@alright.party>2025-04-08 01:07:35 +0400
commitb25877f1bb26cf44ed5527f2f21af5734aa99052 (patch)
tree6dcf9cf85063594cce5ccbcbc50bd7d781f3738d /bot
parent112136c184bcb226fa84e9b5a39c2d1dc557c4d3 (diff)
feat: remove previous command if it exists
Diffstat (limited to 'bot')
-rw-r--r--bot/src/commands/command.cpp7
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));
}