Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

182
Visualizações
Only reply in dms discord.js

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");
        }
    }
});
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

That's because you didn't enable the intents for getting a dm message, try putting those two on your client declarations :

const client = new Discord.Client({
    intents : ['DIRECT_MESSAGES','GUILD_MESSAGES'],
    partials: ["CHANNEL","MESSAGE"]
})
about 4 years ago · Juan Pablo Isaza Relatório

0

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 🎧', {type:'PLAYING'})
privateMessage(client, 'ping', 'pong')

})

and in the file we just created privateMessage.js add:


module.exports=(client, triggerText, replyText)=>{
   client.on('message', message =>{
       if(message.content.toLowerCase()===triggerText.toLowerCase()){
           message.author.send(replyText)
       }
   })
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda