From 94f456f4d721f76813fd545b75d4813f4735aba9 Mon Sep 17 00:00:00 2001 From: thearturca Date: Fri, 22 Jan 2021 10:12:17 +0500 Subject: [PATCH] added exeption for adding "commands" command --- src/bot.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bot.js b/src/bot.js index 300f4a2..d0ea91b 100644 --- a/src/bot.js +++ b/src/bot.js @@ -411,14 +411,16 @@ class Bot { addCommand(newCommandName, newCommandDescription){ return new Promise((resolve, reject) =>{ let commandMatch = false; + let commandMatchStr = ''; newCommandName.forEach(commandName => { const checkCommand = this._commandsDB.get('commands').find({command: [commandName]}).value(); - if (checkCommand !== undefined){ + if (checkCommand !== undefined || commandName === "commands"){ commandMatch = true; + commandMatchStr = commandName; } }); if (commandMatch){ - reject('Команда уже существует'); + reject(`Команда "${commandMatchStr}" уже существует`); }else{ this._commandsDB.get('commands').push({ command: newCommandName,