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,17 +10,32 @@ 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) {
const repliedMessageId = message.reference.messageId; // Check if the message is just ".sb" or ".spongebob" (empty arguments)
message.channel.messages.fetch(repliedMessageId) if (commandData.args === "") {
.then(repliedMessage => { const repliedMessageId = message.reference.messageId;
repliedMessage.reply(fn.spongebob({ args: repliedMessage.content })).then(() => { message.channel.messages.fetch(repliedMessageId)
if (message.deletable) message.delete(); .then(repliedMessage => {
repliedMessage.reply(fn.spongebob({ args: repliedMessage.content })).then(() => {
if (message.deletable) message.delete();
});
})
.catch(err => {
console.error(err);
}); });
}) } else { // If there is content before the .sb, meaning the reply is just for reference...
.catch(err => { const repliedMessageId = message.reference.messageId;
console.error(err); 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();