From 689ee529e26ced9b9de944f8ffca1e0af245f159 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Mon, 20 Jun 2022 19:00:42 -0400 Subject: [PATCH] Add .joint back in addition to /joint --- dot-commands/joint.js | 16 ++++++++++++++++ functions.js | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 dot-commands/joint.js 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; }