I need help creating a new command for my bot that simulates "killing" people. I want the bot to respond with the message "Ha! You thought! @Author died!" if someone pings the bot. (How can I make the Bot detect when it is pinged?) This answer has been updated and is now fully functional.
const Discord = require('discord.js');
const bot = new Discord.Client();
module.exports = {
name: 'kill',
description: 'kills',
execute(message, args, bot) {
message.delete({ timeout: 30000 });
if (message.content.startsWith('-kill')) {
const target = message.mentions.users.first();
const memberTarget = message.guild.members.cache.get(target.id);
if (message.mentions.has(bot.user)) {
return message.channel.send(`HA! SIKE! <@${message.author.id}> died.`);
}
message.channel.send(`<@${memberTarget.user.id}> has died!`);
console.log(`<@${memberTarget.user.id} died.`);
}
},
};