Skip to content

Commit

Permalink
added exeption for adding "commands" command
Browse files Browse the repository at this point in the history
  • Loading branch information
thearturca committed Jan 22, 2021
1 parent cbf67c2 commit 94f456f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 94f456f

Please sign in to comment.