Simple code assistance!

Anyone knows what the issue is with this node.js code?
8 Replies
d.js toolkit
d.js toolkit13mo ago
- 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! - Marked as resolved by staff
𝐒𝐑_𝐑𝐁𝐚𝐛
const { Client, Intents, IntentsBitField } = require('discord.js'); const client = new Client({ Intentsntents: [IntentsBitField.Flags.Guilds, IntentsBitField.Flags.GuildMembers, IntentsBitField.Flags.GuildMessages] }); client.once('ready', () => { console.log('Ready!'); }); client.on('interactionCreate', async interaction => { if (!interaction.isCommand()) return; const { commandName, options } = interaction; if (commandName === 'giverole') { const targetUser = options.getUser('target'); const roleName = options.getString('role'); const role = interaction.guild.roles.cache.find(r => r.name === roleName); const member = interaction.guild.members.cache.get(targetUser.id); if (!role) { await interaction.reply(Role ${roleName} does not exist.); return; } if (!member) { await interaction.reply(User not found.); return; } if (interaction.member.roles.cache.some(r => r.name === 'SpecificRole')) { await member.roles.add(role); await interaction.reply(Role ${roleName} has been given to ${targetUser.username}.); } else { await interaction.reply('You do not have permission to use this command.'); } } }); const token = 'my token i use, hiding for now'; client.login(token);
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs13mo ago
Codeblocks: ```js const Discord = require("discord.js"); // further code ``` becomes
const Discord = require("discord.js");
// further code
const Discord = require("discord.js");
// further code
Inline Code: `console.log('inline!');` becomes console.log('inline!');
𝐒𝐑_𝐑𝐁𝐚𝐛
Oh yeah. So, basically this is a code for a simple discord bot written in node.js. When I try run the code, the terminal simply says that the clients is not valid for the client. This is the terminal: TypeError [ClientMissingIntents]: Valid intents must be provided for the Client. This is my attempt to identify all the intents: const client = new Client({ Intentsntents: [IntentsBitField.Flags.Guilds, IntentsBitField.Flags.GuildMembers, IntentsBitField.Flags.GuildMessages] });
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
treble/luna
treble/luna13mo ago
i dont see what this is supposed to be https://bork.treble-is-fluffy.gay/floof7d3ecca8.png
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server