Home > Software engineering >  Is there a way to remove permissions from a role on creation with Discord?
Is there a way to remove permissions from a role on creation with Discord?

Time:11-11

I'm trying to remove all the permissions from a role that my bot has made on the server, I've looked on Discord JS guide and other websites but there's nothing about it on there, Im basically stuck here's my code:

if (!message.guild.roles.cache.find(i => i.name == 'Muted')) {
    message.channel.send('Adding \`Muted\` Role...')
    await message.guild.roles.create({
        data: {
            name: 'Muted',
            color: '#ff4939',
            permissions: ["ALL", false]
        },
        reason: 'Mute role automaticly added.',
    })
}

CodePudding user response:

To remove all permissions from a role on creation, provide an empty array.

await message.guild.roles.create({
    data: {
        name: 'Muted',
        color: '#ff4939',
        permissions: [] //should have no permissions
    },
    reason: 'Mute role automaticly added.',
})

CodePudding user response:

permissions: new Discord.Permissions() should give no permissions, since it works the same as the permissions calculator. Permissions can be either a string, number, array or made by the Permissions constructor using bits.

PermissionResolvable - v12

  • Related