Compare commits

...

3 Commits

Author SHA1 Message Date
0106983a5f Fixed how replies work with .sb
Some checks failed
NodBot Production Dockerization / build (pull_request) Has been cancelled
2024-06-14 21:38:36 -04:00
caefe0e228 Fix silly replace method for getting command 2024-06-14 20:34:51 -04:00
928f12fe01 Versioning 2024-06-14 20:30:34 -04:00
3 changed files with 27 additions and 14 deletions

View File

@ -10,20 +10,33 @@ module.exports = {
// message.reply(fn.spongebob(commandData)).then(() => { // message.reply(fn.spongebob(commandData)).then(() => {
// message.delete(); // message.delete();
// }); // });
if (message.reference != undefined) { if (message.reference != undefined) { // message.reference is undefined if the message isn't a reply to another message
const repliedMessageId = message.reference.messageId; if (commandData.args !== "") { // If the replying message isn't just .sb
message.channel.messages.fetch(repliedMessageId) const repliedMessageId = message.reference.messageId; // grab the message Id of the replied-to msg
.then(repliedMessage => { message.channel.messages.fetch(repliedMessageId) // Fetch the message because with our luck it isn't in the cache
repliedMessage.reply(fn.spongebob({ args: repliedMessage.content })).then(() => { .then(repliedMessage => {
if (message.deletable) message.delete(); 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);
}); });
}) } else { // We're working with a basic ".sb" and can proceed as we did before...
.catch(err => { const repliedMessageId = message.reference.messageId; // grab the message Id of the replied-to msg
console.error(err); message.channel.messages.fetch(repliedMessageId) // Fetch the message because with our luck it isn't in the cache
}); .then(repliedMessage => {
} else { 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(() => { 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.
}); });
} }
} }

View File

@ -189,7 +189,7 @@ const functions = {
// Get the first part of the message, everything leading up to the final period // Get the first part of the message, everything leading up to the final period
commandData.args = message.content.slice(0,finalPeriod).toLowerCase(); commandData.args = message.content.slice(0,finalPeriod).toLowerCase();
// Get the last part of the message, everything after the final period // 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}`; commandData.author = `${message.author.username}`;
return this.checkCommand(commandData); return this.checkCommand(commandData);
}, },

View File

@ -1,6 +1,6 @@
{ {
"name": "nodbot", "name": "nodbot",
"version": "3.2.1", "version": "3.2.2",
"description": "Nods and Nod Accessories, now with ChatGPT!", "description": "Nods and Nod Accessories, now with ChatGPT!",
"main": "main.js", "main": "main.js",
"dependencies": { "dependencies": {