From 928f12fe019cfa41c283c6cadb5a797a464e8647 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 14 Jun 2024 20:30:34 -0400 Subject: [PATCH 1/3] Versioning --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 55b30c9..3b73fb7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodbot", - "version": "3.2.1", + "version": "3.2.2", "description": "Nods and Nod Accessories, now with ChatGPT!", "main": "main.js", "dependencies": { From caefe0e228317fb87c1500a0056b3e6fedf4367f Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 14 Jun 2024 20:34:51 -0400 Subject: [PATCH 2/3] Fix silly replace method for getting command --- functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions.js b/functions.js index 6b53169..0d87691 100644 --- a/functions.js +++ b/functions.js @@ -189,7 +189,7 @@ const functions = { // Get the first part of the message, everything leading up to the final period commandData.args = message.content.slice(0,finalPeriod).toLowerCase(); // Get the last part of the message, everything after the final period - commandData.command = message.content.slice(finalPeriod).replace('.','').toLowerCase(); + commandData.command = message.content.slice(finalPeriod + 1).toLowerCase(); commandData.author = `${message.author.username}`; return this.checkCommand(commandData); }, From 0106983a5f122bd488cf68df270f16fdd2d5d143 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 14 Jun 2024 21:38:36 -0400 Subject: [PATCH 3/3] Fixed how replies work with .sb --- dot-commands/spongebob.js | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/dot-commands/spongebob.js b/dot-commands/spongebob.js index f886a27..38f5bc0 100644 --- a/dot-commands/spongebob.js +++ b/dot-commands/spongebob.js @@ -10,20 +10,33 @@ module.exports = { // message.reply(fn.spongebob(commandData)).then(() => { // message.delete(); // }); - if (message.reference != undefined) { - const repliedMessageId = message.reference.messageId; - message.channel.messages.fetch(repliedMessageId) - .then(repliedMessage => { - repliedMessage.reply(fn.spongebob({ args: repliedMessage.content })).then(() => { - if (message.deletable) message.delete(); + if (message.reference != undefined) { // message.reference is undefined if the message isn't a reply to another message + if (commandData.args !== "") { // If the replying message isn't just .sb + const repliedMessageId = message.reference.messageId; // grab the message Id of the replied-to msg + message.channel.messages.fetch(repliedMessageId) // Fetch the message because with our luck it isn't in the cache + .then(repliedMessage => { + repliedMessage.reply(fn.spongebob({ args: commandData.args })).then(() => { // Use the pre-command text of the replying message to sb-ify + if (message.deletable) message.delete(); // If the initiating message is deletable, delete it. + }); + }) + .catch(err => { + console.error(err); }); - }) - .catch(err => { - console.error(err); - }); - } else { + } else { // We're working with a basic ".sb" and can proceed as we did before... + const repliedMessageId = message.reference.messageId; // grab the message Id of the replied-to msg + message.channel.messages.fetch(repliedMessageId) // Fetch the message because with our luck it isn't in the cache + .then(repliedMessage => { + repliedMessage.reply(fn.spongebob({ args: repliedMessage.content })).then(() => { + if (message.deletable) message.delete(); + }); + }) + .catch(err => { + console.error(err); + }); + } + } else { // The message isn't a reply, so just sb it like we did from the very beginning message.channel.send(fn.spongebob(commandData)).then(() => { - if (message.deletable) message.delete(); + if (message.deletable) message.delete(); // If the initiating message is deletable, delete it. }); } }