-1
const {Client, GatewayIntentBits } = require("discord.js");

const client = new Client({
    intents:[
      GatewayIntentBits.Guilds,
      GatewayIntentBits.GuildMessages,
      GatewayIntentBits.MessageContent,
      GatewayIntentBits.GuildMembers,
      GatewayIntentBits.DirectMessageTyping,
    ],
});

const prefix = "t!";

client.on('ready', () => {
  console.log(`${client.user.tag} je online :D`);
});

client.on('message ', message => {
  if (message.author.client) return;
  if (message.content.startsWith(settings.prefix)) return;

  if(message.content.startsWith(settings.prefix + "ping")){
    message.reply("Pong!")
  }
  
});

client.login(token);

Im trying to make discord bot but im having hard time making it replay to me. I tried everykind of ways but nothing works so if someone can help me i would be glad.

Tin
  • 3
  • 1
  • From the linked answer: _"And make sure to use the `messageCreate` event instead of `message`"_ There is no `message` event now. – Zsolt Meszaros May 27 '23 at 11:35

1 Answers1

-1

Here is the working code, just read the documentation and you can fix everything by yourself: https://discord.js.org/#/docs/discord.js/main/general/welcome

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

const client = new Client({
    intents:[
      GatewayIntentBits.Guilds,
      GatewayIntentBits.GuildMessages,
      GatewayIntentBits.MessageContent,
      GatewayIntentBits.GuildMembers
    ],
});

const settings = {
   prefix: 't!',
   token: 'Your bot token'
};

client.on('ready', () => {
  console.log(`${client.user.tag} je online :D`);
});

client.on('messageCreate', (message) => {
  if (message.author.bot) return;
  if (!message.content.startsWith(settings.prefix)) return;

  if(message.content.startsWith(settings.prefix + "ping")) {
    message.reply({ content: "Pong!" });
  };
  
});

client.login(settings.token);
T.F.A
  • 16
  • 1