Home > Net >  How do I make the bot dm me with a command
How do I make the bot dm me with a command

Time:06-28

So I have an easter egg command. If someone says founder, my bot replies that the user found an easter egg. But I want the bot to dm me if anyone runs the command.

Here's my code :

module.exports = {
    name: 'founder',
    description: "easter egg",
    execute(message, args){
        message.channel.send('You found a easter egg!! Don\'t tell anyone else.....');
    }
}

And here's what in main.js

if (command === 'founder') {
    client.commands.get('founder').execute(message, args);
} 

CodePudding user response:

You'll need to grab yourself as a User/GuildMember and use send to send a message:

module.exports = {
    name: 'founder',
    description: 'easter egg',
    async execute(message, args) {
        message.channel.send('You found an easter egg!! Don\'t tell anyone else.....');
        const me = await message.guild.members.fetch('YOUR ID HERE');
        me.send(`${message.author} found an easter egg!`);
    }
}
  • Related