0

I've been having trouble with my code for a simple ping command that gets the bot to reply to !ping I've copied so many different techniques from loads of different videos, websites etc. that "supposedly" work but when I type !ping my bot does nothing.

My bot is online but I feel there's something stupidly obvious I'm forgetting. I searched the web and I think there's something wrong with the intents. I looked at versions that both used MessageCreate and Message, too, and I'm not sure which is correct. I tried this tutorial as well: https://www.youtube.com/watch?v=nTGtiCC3iQM&t=185s

Here is my code:

//constants
const Discord = require("discord.js");
const { ActivityType } = require("discord.js");
const prefix = '!';
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });

client.once('ready', () => {
    console.log('CARI is online');
    client.user.setActivity('paint dry.', { type: ActivityType.Watching });
}); 

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

client.login('TOKEN');
Tyler2P
  • 2,324
  • 26
  • 22
  • 31

0 Answers0