Bot giving me "disallowed intents" error when trying to run through node.js
Code:
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
],
});
const roles = ['Whale', 'Melon']; // placeholder names
const usedUsers = new Set();
client.once('ready', () => {
console.log(
Logged in as ${client.user.tag}!
);
});
client.on('messageCreate', (message) => {
if (message.author.bot || !message.guild) return;
const args = message.content.split(' ');
const command = args[0].toLowerCase();
if (command === '!assignrole' && args.length === 1 && !usedUsers.has(message.author.id)) {
const randomRole = roles[Math.floor(Math.random() * roles.length)];
const role = message.guild.roles.cache.find((r) => r.name === randomRole);
if (role) {
message.member.roles.add(role);
message.reply(You've been assigned the "${randomRole}" role.
);
usedUsers.add(message.author.id);
} else {
message.reply('Error: Could not find the specified role.');
}
}
});
client.login('token thats left out for this posts sake');
the bot serves as a random role picker for my friends server, but with no coding experience i went to CGPT. I have done the basic troubleshooting (attempting to update discord.js, giving the bot the right perms for its use, but still giving me the error shown in image.6 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!-
Error [DisallowedIntents]: Privileged intent provided is not enabled or whitelisted.
- Error: Used disallowed intents
If you are using the GuildMembers
, GuildPresences
, or MessageContent
intents, you need to enable them via Developer Portal > Your app > Bot > Privileged Gateway Intentsthanks lol
bump because its not applying roles
it sends the "you have been given x role" and then the bot breaks
@Qjuh it stops responding after one command
I'll get a pic of it when I get home
okay i think its cuz the bot role is below the roles it needs to assign