#where i can find a example for a bot
1 messages · Page 1 of 1 (latest)
const { Client, GatewayIntentBits } = require('discord.js'); const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, ], }); client.on('ready', () => { console.log(Logged in as ${client.user.tag}!`);
});
client.on("messageCreate", (message) => {
console.log(message.content);
if (message.content.startsWith("ping")) {
message.channel.send("pong!");
}
});
client.login("key");
`
youre missing messageContent intent
it fail when i put it
what do you mean fail
i give admin to the bot
what do you mean fail
`node_modules/discord.js/src/client/websocket/WebSocketManager.js:250
throw new DiscordjsError(unrecoverableErrorCodeMap[error.code]);
^
Error [DisallowedIntents]: Privileged intent provided is not enabled or whitelisted.
at WebSocketManager.createShards (/mnt/c/xampp/htdocs/RuedaFortuna/node_modules/discord.js/src/client/websocket/WebSocketManager.js:250:15)
at async Client.login (/mnt/c/xampp/htdocs/RuedaFortuna/node_modules/discord.js/src/client/Client.js:226:7) {
code: 'DisallowedIntents'
}
Node.js v20.0.0`
enable it on your bots dashboard
Error [DisallowedIntents]: Privileged intent provided is not enabled or whitelisted.
If you are using the GuildMembers, GuildPresences, or MessageContent intents, you need to enable them in the developer portal:
• Developer Portal > Your app > Bot > Privileged Gateway Intents