0
const Discord = require("discord.js")
const client = new Discord.Client({
    intents: [
        Discord.GatewayIntentBits.Guilds,
        Discord.GatewayIntentBits.GuildMessages
    ]
});


client.on("ready", () => {
  console.log(`Logged in as ${client.user.tag}!`)
})

client.on("messageCreator", (msg) => {
  if (msg.content === "ping") {
      msg.reply("pong");
  }
})
client.on("message", Message => {
  if (msg.content === "hi") {
      msg.reply("hello");
  }
})

client.login(process.env.TOKEN)

Hi, im tryng learn how to make a discord bot for my server and i dont know much of js. I've been reading some tutorials but isnt working.

1 Answers1

0

Seems like you're trying to listen to 2 message events, messageCreator and message.

The event messageCreator doesn't exist. You need to replace it with messageCreate.

The event message has been deprecated. (Also, you've named your message instance Message but you're referring to it as msg.)

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

client.on("ready", () => {
    console.log(`Logged in as ${client.user.tag}!`);
});

client.on("messageCreate", (msg) => {
    if (msg.content === "ping") {
        msg.reply("pong");
    }
});

client.login(process.env.TOKEN);
Jakye
  • 6,440
  • 3
  • 19
  • 38