|
|
|
@ -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.
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|