The other day, some quirck made the discord bot I made for my personal server several years ago, stop working. So now I have to build it from the ground up. Even following the setup from the Discord tutorial, I can't get basic functions to work anymore. Here's what I'm struggling with right now:
// Require the necessary discord.js classes
const { Client, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');
// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
// When the client is ready, run this code (only once)
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
// Reply to a user who mentions the bot
client.on('messageCreate', message => {
console.log(`I see a message!`);
if (message.mentions.has(client.user)) {
console.log(`I see a mention!`);
message.channel.send(`Working on it!`);
}
});
// Login to Discord with your client's token
client.login(token);
Neither of the console.log commands within the messageCreate event trigger, so it seems that for some reason, my bot isn't even watching for that event, but I cannot find anywhere online that will tell me why, especially since this exact method used to work for my old bot. (The console.log that triggers when the bot logs in works just fine.)