What is the difference between a User and a GuildMember in discord.js?

From Official Discord.js Guide – Common Questions: A lot of users get confused as to what the difference between Users and GuildMembers is. The simple answer is that a User represents a global Discord user and a GuildMember represents a Discord user on a specific server. That means only GuildMembers can have permissions, roles, and … Read more

How do I fix CLIENT_MISSING_INTENTS error?

You need to specify the events which you want your bot to receive using gateway intents. Instead of const client = new Discord.Client(); Use const client = new Discord.Client({ intents: [Enter intents here] }) For example const client = new Discord.Client({ intents: [“GUILDS”, “GUILD_MESSAGES”] }) Here’s another useful link: https://discord.com/developers/docs/topics/gateway

SyntaxError: Unexpected token ‘{‘ Discord.js

You forgot the Arrow Function (=>) exports.run(message) => { const serverQueue = message.client.queue.get(message.guild.id); if (serverQueue && serverQueue.playing) { serverQueue.playing = false; serverQueue.connection.dispatcher.pause(); return message.channel.send(“⏸ La musique est en pause !”) } return message.channel.send( “Il n’y a aucune musique qui est en train de jouer !” ); } module.exports = Pause; Please consider learning JavaScript and … Read more

Need help for assigning a variable with discord bot command

You can split your the message into an array of words: const args = message.content.slice(config.prefix.length).split(/ +/).slice(1) // example: `.boosting hello people of the world` // returns: [‘hello’, ‘people’, ‘of’, ‘the’, ‘world’] So, if you’d like to get the first argument (word), you can use args[0]. For the second, args[1], and so on. You updated code: … Read more

Discord bot simple editing its own message gives me error

The “message” variable has the exact same name ad the “message” variable in the client.on(‘message’) so change it to ‘msg’ and everything should work fine : module.exports = { name: ‘hack’, execute: function(message, args) { const user = message.mentions.users.first() || args[0]; const member = message.guild.member(user); if (member) { message.channel .send(‘Scrambling Through Database’) .then((msg) => { … Read more

im new to making discord bots with node.js, i am having trouble with an error, it says that message is not defined in line 14 and 18

here,try this: client.on(‘message’, message =>{ if(message.content.startsWith(prefix) ||message.author.bot) return; const args = message.content.slice(prefix.lenght).split(/+/); const command = args.shift().toLowerCase(); if(command === ‘blackhumour’){ message.channel.send(‘What is the difference between a kid and a bowling ball? when you put your fingers in one it doesnt scream’); } else if(command === ‘sex’){ message.channel.send(‘no you fucking pervert’); } });