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

698
Visualizações
Discord bot not reading message.content

My bot is not reading the Discord chat. I want it to read the chat and if it finds certain words it will give a certain response. This is my current message event code. This is my first JavaScript project and I have just started learning it so please rip it apart so I can learn quicker :)

At the moment I can get the bot to load into discord. I can turn it on with .node but I can not get it to read a message using message.content.

const Discord = require("discord.js");
const client = new Discord.Client({ intents: ["GUILD_MESSAGES", "DIRECT_MESSAGES"] }); 


var name = "Poker Bot";
var usersHand
let firstCardValue  
let secondCardValue
let firstCardSuit
let secondCardSuit 


//starts the bot and sets activity to a funny quote. it also will give a command prompt notification that the
// bot is online

client.on("ready", () => {
    console.log(`Bot is online: ${name} !`);
    client.user.setActivity('Burning The Fucking Casino Down');
});
    //check discord chat to see if a user has posted.
client.on("messageCreate", message => {
   //console.log is there to test user input. If it works the message in the discord channel will appear in console
    console.log(`The user has said: ${message} `);

//look for poker hand ~~~ position ~~~~ event (ex: AA CO PF )     (PF= PreFlop)


if (message.content.toLowerCase == 'AK' || message.content.toLowerCase == 'AA' || message.content.toLowerCase == 'KK'){

    message.reply("RECOMMENDED PLAY SHOVE: ALL IN")
}
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

.content is not a method, it's a property, you must now also enable the Message Content intent on your bot page as well as in your code.

const Discord = require("discord.js");
const client = new Discord.Client({ intents: ["GUILD_MESSAGES", "DIRECT_MESSAGES"] }); 

client.on("messageCreate", message => {
    // || "String" like you did before would return "true" in every single instance, 
    // this is case sensitive, if you wanna make it case insensitive 
    // use `message.content.toLowerCase() == "lowercasestring"`
    if (message.content == "AK" || message.content = "AA" || message.content == "KK") {     
        message.channel.send("Recommend Play is to shove all in" + message.author);
    }
})

client.login(token);
about 4 years ago · Juan Pablo Isaza Relatório

0

Judging by your information, you dont just want to send a response if the message contains only those strings, but may just contain then. To check for that, I would suggest to use regex#test

Still as @iiRealistic_Dev rightfully mentioned: message.content is not a function, so removing the brackets is the way to go.

client.on("messageCreate", (message) => {

  if (/AK|AA|KK/.test(message.content)) {
    message.channel.send("Recommend Play is to shove all in" + message.author);
    console.log('it got to here');
  }
});
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