So, I made a bot a while ago that was working perfectly fine. I haven't used it in a couple of months and now I tried starting again because I needed it, and its literally not doing anything. It always worked, didn't change anything, It's not even showing any errors. Can anyone help?
const Discord = require('discord.js');
const { Intents } = Discord;
const client = new Discord.Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]
})
require('dotenv').config();
var token = process.env.TOKEN;
const prefix = ';';
const fs = require('fs');
const { ClientRequest } = require('http');
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles){
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
client.once('ready', () => {
console.log('Bot is aan het opstarten...!');
client.user.setActivity("Bot testing", {
type: "PLAYING",
});
});
//-------------
//Commands
//-------------
client.on('messageCreate', message =>{
if(message.content != '')
{
client.commands.get('suggest').execute(message, Discord)
}
if(message.content != '')
{
client.commands.get('nieuws').execute(message, Discord)
}
if(message.content != '')
{
client.commands.get('sollicitaties').execute(message, Discord)
}
if(message.content != '')
{
client.commands.get('regels').execute(message, Discord)
}
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ /);
const command = args.shift().toLowerCase();
});
client.login(token);
CodePudding user response:
Discord recently started privileged intents. make sure you have enabled message content intent
in your application's bot section. This will allow your bot to have access to reading message and its content. More info