This snippet will delete a message using command prefix. You have to click "Reply" to a message and enter the prefix. This will delete that referenced message along with the command.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const REF_MESSAGE = context.params.event.referenced_message; //This is the message that you have replied to with the !delete-message command
//If you have replied to a message, this will delete that message, and your message with the command prefix
if (REF_MESSAGE) {
await lib.discord.channels['@0.3.2'].messages.destroy({
message_id: `${REF_MESSAGE.id}`,
channel_id: `${context.params.event.channel_id}`,
});
await lib.discord.channels['@0.3.2'].messages.destroy({
message_id: `${context.params.event.id}`,
channel_id: `${context.params.event.channel_id}`,
});
} else {
await lib.discord.channels['@0.3.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `Hey <@!${context.params.event.author.id}>, reply to a message!`,
});
}