Home > Mobile >  discordjs how to add all intents/permissions
discordjs how to add all intents/permissions

Time:07-11

I'm trying to add a role when members join the server, but it says I don't have that permission. How do I add all intents/permissions for the bot?

I'll just leave the beginning of the code.

// Require the necessary discord.js classes
const { Client, Intents, Message } = require('discord.js');
const { Player } = require("discord-player");
const { token, prefix } = require("./config.json");

// Create a new client instance
const client = new Client(
    { 
        restTimeOffset: 0,
        shards: "auto",
        intents: [
            Intents.FLAGS.DIRECT_MESSAGES,
            Intents.FLAGS.DIRECT_MESSAGE_REACTIONS,
            Intents.FLAGS.DIRECT_MESSAGE_TYPING,
            Intents.FLAGS.GUILDS,
            Intents.FLAGS.GUILD_BANS,
            Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS,
            Intents.FLAGS.GUILD_INTEGRATIONS,
            Intents.FLAGS.GUILD_INVITES,
            Intents.FLAGS.GUILD_MEMBERS,
            Intents.FLAGS.GUILD_MESSAGES,
            Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
            Intents.FLAGS.GUILD_MESSAGE_TYPING,
            Intents.FLAGS.GUILD_PRESENCES,
            Intents.FLAGS.GUILD_SCHEDULED_EVENTS,
            Intents.FLAGS.GUILD_VOICE_STATES,
            Intents.FLAGS.GUILD_WEBHOOKS,
        ] 
});

CodePudding user response:

The error could be coming because of other reasons as well. One explanation behind the error might be that the bot was trying to add a role to a member with a role higher than its own. In that case, you would have to manually rearrange the role hierarchy and put the bot's role on the top.

About the intents: It's not advisable to just add all the intents you want. The whole point of intents was that developers could choose what type of data they wanted their bot to receive. This whole concept is trashed if we just selected all the intents. If you still want to enable all the intents, you can just check for intents calculator in Google, and then copy the intent value given there and paste it like this:

const { Intents, Client } = require("discord.js")
const client = new Client({
    intents: new Intents(value) // Insert the value here
})
  • Related