careless
careless
DIAdiscord.js - Imagine an app
Created by careless on 12/1/2023 in #djs-questions
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.
11 replies