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

108
Visualizações
I am trying do deploy discord bot in javascript on replit but its just replying only when i mention bot instead of any normal message

I have developed a discord bot in python but getting problems in javascript one.

I have tried a few solutions from StackOverflow itself but I can't figure out how to make it work. And much confusion due to solutions available online about discord bot and whenever you try to deploy it as it shows many version/deprecation errors of nodejs and discord.

Problem is that my bot code as follows replying only when I mention them but I want it to reply on any message like for example I take "boomer" as my message but the bot doesn't respond to it at all.

const Discord = require("discord.js");
const { Client } = require('discord.js');

const client = new Discord.Client({
  intents: [
    32509
  ]
})
client.on("ready", () => {
  console.log(`Logged in as ${client.user.tag}!`);
  client.user.setActivity('Running a test, hopefully.');
})

client.on("messageCreate", (message) => {
  if (message.content.toLowerCase().includes("boomer")) {
    message.channel.send("how are you there!");
  }

  if (message.author.bot) return false;

  if (message.content.includes("@here") || message.content.includes("@everyone") || message.type == "REPLY") return false;

  if (message.mentions.has(client.user.id)) {
    message.channel.send("Hello there!");
  }

});

client.login(process.env.TOKEN)
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

With your current intent 32509 the following ones are enabled:

  • GUILDS (1 << 0)
  • GUILD_BANS (1 << 2)
  • GUILD_EMOJIS_AND_STICKERS (1 << 3)
  • GUILD_INTEGRATIONS (1 << 4)
  • GUILD_WEBHOOKS (1 << 5)
  • GUILD_INVITES (1 << 6)
  • GUILD_VOICE_STATES (1 << 7)
  • GUILD_MESSAGES (1 << 9)
  • GUILD_MESSAGE_REACTIONS (1 << 10)
  • GUILD_MESSAGE_TYPING (1 << 11)
  • DIRECT_MESSAGES (1 << 12)
  • DIRECT_MESSAGE_REACTIONS (1 << 13)
  • DIRECT_MESSAGE_TYPING (1 << 14)

The problem is you've added lots of unnecessary ones but missing the MESSAGE_CONTENT intent. It means message.content doesn't have any value, but message.mentions has. That's why it works when you mention the bot and doesn't work when you check if the message.content includes the string "boomer".

To solve this, you can add 32768 (1 << 15) to the current number:

const client = new Client({
  intents: [65277],
});

or even better, just use the ones you actually need:

const { Client, GatewayIntentBits } = require('discord.js');

const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent,
  ],
});
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