𝐒𝐑_𝐑𝐁𝐚𝐛
𝐒𝐑_𝐑𝐁𝐚𝐛
DIAdiscord.js - Imagine an app
Created by 𝐒𝐑_𝐑𝐁𝐚𝐛 on 11/15/2023 in #djs-questions
Simple code assistance!
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] });
12 replies
DIAdiscord.js - Imagine an app
Created by 𝐒𝐑_𝐑𝐁𝐚𝐛 on 11/15/2023 in #djs-questions
Simple code assistance!
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);
12 replies