Fix SB Replies
All checks were successful
NodBot Production Dockerization / build (pull_request) Successful in 17s

This commit is contained in:
Skylar Grant 2023-08-24 18:53:46 -04:00
parent 0c03b4b2d4
commit a8519af9cc

View File

@ -10,7 +10,10 @@ module.exports = {
// message.reply(fn.spongebob(commandData)).then(() => { // message.reply(fn.spongebob(commandData)).then(() => {
// message.delete(); // message.delete();
// }); // });
// Check if the message is replying to another message
if (message.reference != undefined) { if (message.reference != undefined) {
// Check if the message is just ".sb" or ".spongebob" (empty arguments)
if (commandData.args === "") {
const repliedMessageId = message.reference.messageId; const repliedMessageId = message.reference.messageId;
message.channel.messages.fetch(repliedMessageId) message.channel.messages.fetch(repliedMessageId)
.then(repliedMessage => { .then(repliedMessage => {
@ -21,6 +24,18 @@ module.exports = {
.catch(err => { .catch(err => {
console.error(err); console.error(err);
}); });
} else { // If there is content before the .sb, meaning the reply is just for reference...
const repliedMessageId = message.reference.messageId;
message.channel.messages.fetch(repliedMessageId)
.then(repliedMessage => {
repliedMessage.reply(fn.spongebob({ args: commandData.args })).then(() => {
if (message.deletable) message.delete();
});
})
.catch(err => {
console.error(err);
});
}
} else { } else {
message.channel.send(fn.spongebob(commandData)).then(() => { message.channel.send(fn.spongebob(commandData)).then(() => {
if (message.deletable) message.delete(); if (message.deletable) message.delete();