nodbot/dot-commands/spongebob.js

43 lines
1.9 KiB
JavaScript
Raw Permalink Normal View History

2021-09-24 00:08:29 +00:00
const fn = require('../functions.js');
2021-09-22 17:15:31 +00:00
const config = require('../config.json');
module.exports = {
name: 'spongebob',
2022-06-11 14:55:25 +00:00
alias: 'sb',
2021-09-22 17:15:31 +00:00
description: 'SpOnGeBoB-iFy AnYtHiNg AuToMaTiCaLly',
usage: '<text to convert>.spongebob',
execute(message, commandData) {
2022-12-16 19:56:00 +00:00
// message.reply(fn.spongebob(commandData)).then(() => {
// message.delete();
// });
2024-06-15 01:38:36 +00:00
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);
2023-01-08 01:22:06 +00:00
});
2024-06-15 01:38:36 +00:00
} 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
2023-01-08 01:22:06 +00:00
message.channel.send(fn.spongebob(commandData)).then(() => {
2024-06-15 01:38:36 +00:00
if (message.deletable) message.delete(); // If the initiating message is deletable, delete it.
2023-01-08 01:22:06 +00:00
});
}
2021-09-22 17:15:31 +00:00
}
}