Home > front end >  Only reply in dms discord.js
Only reply in dms discord.js

Time:03-01

So I was working on this project where people will DM the BOT and run command and it replies test. But it doesn't reply.

client.on("messageCreate", async message => {
    if (message.content.startsWith(prefix)) {
        const args = message.content.slice(prefix.length).trim().split(/  /g);

        const command = args.shift().toLowerCase();

        if (message.channel.type === 'dm') {
            message.reply("test");
        }
    }
});

CodePudding user response:

try replacing message.reply("test"); with message.author.send("test"); maybe it will help

CodePudding user response:

here is a way:

1.Create a file named ** 'privateMessage.js'** and in the main file add:

const privateMessage = require('./privateMessage')

client.on('ready' ,() =>{
console.log('I am online')
client.user.setActivity('YouTube Music            
  • Related