-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created deletequeue command. Created help message in helpmessages.jso…
…n and updated help docs.
- Loading branch information
1 parent
cbf8db1
commit ed5f740
Showing
6 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const Discord = require("discord.js"); | ||
const queueFunctions = require("./functions/queueFunctions"); | ||
const helpMessages = require("./functions/helpMessages.json"); | ||
|
||
module.exports.run = async (client,message,args,prefix,con_database) => { | ||
const helpMessage = helpMessages.deletequeue.replace(/\$prefix/g, `${prefix}`); | ||
if(args[0] === "help"){ | ||
return message.reply(helpMessage); | ||
} | ||
else if(!args[0]){ | ||
return message.reply(`Please input a queue name to delete. Use ${prefix}delete help for help using the deletequeue command.`); | ||
} | ||
else if(args[1]){ | ||
return message.reply(`Invalid use of the deletequeue command. Use ${prefix}deletequeue help for help.`); | ||
} | ||
else{ | ||
var queue = await queueFunctions.getQueue(args[0], message, con_database); | ||
if(queue.length < 1){ | ||
message.reply("This queue is empty or does not exist."); | ||
}//end if | ||
else if(queue.length >= 1){ | ||
try{ | ||
message.channel.send(`Are you sure you want to delete ${args[0]}? Please reply yes or no.`);//end message.send | ||
try{ | ||
var response = await message.channel.awaitMessages(message2 => (message2.content.toLowerCase() === "yes" || message2.content.toLowerCase() === "no"), { | ||
maxMatches: 1, | ||
time: 5000, | ||
errors: ['time'] | ||
}); | ||
}//end try | ||
catch(err){ | ||
//console.error(err); | ||
return message.channel.send("Invalid value entered, cancelling operation"); | ||
}//end catch | ||
if(response.first().content == "yes"){ | ||
let var2 = await queueFunctions.deleteQueue(args[0], message, con_database); | ||
return message.reply(`${args[0]} was deleted.`); | ||
} | ||
else if(response.first().content == "no"){ | ||
return message.reply("Alright, I won't delete that queue"); | ||
} | ||
|
||
}//end try | ||
catch(err){ | ||
console.error(err); | ||
return message.channel.send("An error occured."); | ||
}//end catch | ||
}//end else if | ||
}//end else | ||
}//end module | ||
|
||
module.exports.help = { | ||
name: "deletequeue" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const Discord = require("discord.js"); | ||
const fs = require("fs"); //includes the file system package | ||
|
||
module.exports.run = async (client,message,args,prefix,con_database) => { | ||
//const generalHelpString = fs.readFileSync("./HELP.md","utf8").replace(/```/g, "").replace(/# /g, "").replace(/#/g, ""); | ||
//let generalHelpArray = generalHelpString.split("\r\n"); | ||
//console.log(generalHelpArray); | ||
return message.reply("Please see the help documentation here https://github.com/markbmullins/CordTrax-Discord-Bot/blob/master/HELP.md"); | ||
|
||
|
||
} | ||
|
||
module.exports.help = { | ||
name: "help" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters