diff --git a/dot-commands/joint.js b/dot-commands/joint.js new file mode 100644 index 0000000..733dade --- /dev/null +++ b/dot-commands/joint.js @@ -0,0 +1,16 @@ +const fn = require('../functions.js'); +const { emoji } = require('../strings.json'); + +module.exports = { + name: 'joint', + description: 'Send a random weed-themed phrase.', + usage: '.joint', + execute(message, commandData) { + let joints = []; + for (const entry of message.client.joints.map(joint => joint.content)) { + joints.push(entry); + } + const randIndex = Math.floor(Math.random() * joints.length); + message.reply(`${joints[randIndex]} ${emoji.joint}`); + } +} \ No newline at end of file diff --git a/functions.js b/functions.js index 5aa0f74..39aad3e 100644 --- a/functions.js +++ b/functions.js @@ -146,7 +146,8 @@ const functions = { // Split the message content at the final instance of a period const finalPeriod = message.content.lastIndexOf('.'); // If the final period is the last character, or doesn't exist - if (finalPeriod <= 0) { + if (finalPeriod < 0) { + if (isDev) console.log(finalPeriod); commandData.isCommand = false; return commandData; }