Cannot create permissionOverwrites for users with server booster

Hi, I implement some manual "mute" action for my bot (so that the user can see the channels, can't message but can interact with the bot), and for that I used permissionOverwrites like this:
await channel.permissionOverwrites.create(offender.id,
{ 'SendMessages': false,
'SendMessagesInThreads': false,
'SendVoiceMessages': false,
'CreatePublicThreads': false,
'CreatePrivateThreads': false,
});
await channel.permissionOverwrites.create(offender.id,
{ 'SendMessages': false,
'SendMessagesInThreads': false,
'SendVoiceMessages': false,
'CreatePublicThreads': false,
'CreatePrivateThreads': false,
});
But this doesn't work for users with "server booster" role because as I understand, this role is handled by Discord. So this code would give DiscordAPIError[50013]: Missing Permissions. But still, I just want to "mute" them. I searched on Google but I can only find the problem, not the solution. Is there actually any possible solution? Thank you so much!
9 Replies
d.js toolkit
d.js toolkit5mo 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!
d.js docs
d.js docs5mo ago
- Bots cannot moderate (kick/ban/nickname/...) a target with a higher or equally high highest role or the guild owner. - Bots cannot modify (edit/add/remove) roles that are higher or equally high compared to the bot's highest role. - The Administrator permission does not skip these checks.
rubii
rubiiOP5mo ago
Oh and for context, I have checked all of the conditions (bot should be of higher role than target user, bot has permission to kick, bot cannot kick guild owner and etc) It works well for normal members but just not those with "server booster" role
monbrey
monbrey5mo ago
Yeah because you can't remove that role So... dont
rubii
rubiiOP5mo ago
Is it not possible to still keep that role but mute them? D:
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[50013]: Missing Permissions
at handleErrors (/app/node_modules/@discordjs/rest/dist/index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (/app/node_modules/@discordjs/rest/dist/index.js:1120:23)
at async SequentialHandler.queueRequest (/app/node_modules/@discordjs/rest/dist/index.js:953:14)
at async _REST.request (/app/node_modules/@discordjs/rest/dist/index.js:1266:22)
at async PermissionOverwriteManager.upsert (/app/node_modules/discord.js/src/managers/PermissionOverwriteManager.js:107:5)
at async /app/commands/apolomute.js:175:15 {
requestBody: {
files: undefined,
json: {
id: '548655063615275027',
type: 1,
allow: PermissionsBitField { bitfield: 0n },
deny: PermissionsBitField { bitfield: 70746701301760n }
}
},
rawError: { message: 'Missing Permissions', code: 50013 },
code: 50013,
status: 403,
method: 'PUT',
url: 'https://discord.com/api/v10/channels/780526772231077922/permissions/548655063615275027'
}
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[50013]: Missing Permissions
at handleErrors (/app/node_modules/@discordjs/rest/dist/index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (/app/node_modules/@discordjs/rest/dist/index.js:1120:23)
at async SequentialHandler.queueRequest (/app/node_modules/@discordjs/rest/dist/index.js:953:14)
at async _REST.request (/app/node_modules/@discordjs/rest/dist/index.js:1266:22)
at async PermissionOverwriteManager.upsert (/app/node_modules/discord.js/src/managers/PermissionOverwriteManager.js:107:5)
at async /app/commands/apolomute.js:175:15 {
requestBody: {
files: undefined,
json: {
id: '548655063615275027',
type: 1,
allow: PermissionsBitField { bitfield: 0n },
deny: PermissionsBitField { bitfield: 70746701301760n }
}
},
rawError: { message: 'Missing Permissions', code: 50013 },
code: 50013,
status: 403,
method: 'PUT',
url: 'https://discord.com/api/v10/channels/780526772231077922/permissions/548655063615275027'
}
(Line 175 is the code I posted in the question!)
monbrey
monbrey5mo ago
Yeah, when you're calling set, include the booster role too if they had it So it doesn't try to remove it Wait actually now I'm not sure
rubii
rubiiOP5mo ago
But it's indeed line 175 of my code tho D:
No description
rubii
rubiiOP5mo ago
The bot currently has ManageChannels and ManageRoles. But also before that line of code, I have checked the bot's permission in that channel (line 174:
if (channel.permissionsFor(interaction.guild.member.me).has(PermissionsBitField.Flags.ViewChannel)) {
if (channel.permissionsFor(interaction.guild.member.me).has(PermissionsBitField.Flags.ViewChannel)) {
, shouldn't that prevent the bot to access channels that it can't view already? But what's strange is that it works for other members who don't have the Server Booster role, and only gives error to this one person (that have the Booster role)... So I supposed it should already have the other roles that it needs
rubii
rubiiOP5mo ago
These were all the conditions I've checked before executing the command... And the person is just a member and not a mod, so I felt like the Booster role was the only thing that I noticed was different...
No description
Want results from more Discord servers?
Add your server