Permission needed for permissionOverwrite method

Hi, I'm developing a bot for my server, so I let it have Admin permission. However I want my friend test my bot as well, but he doesn't want a bot with Admin, so I'm figuring out what permission I need for my bot to operate. I tried checking all the permission but admin, and I got this error:
./node_modules/@discordjs/rest/dist/index.js:722
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[50001]: Missing Access
at handleErrors (./node_modules/@discordjs/rest/dist/index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (./node_modules/@discordjs/rest/dist/index.js:1120:23)
at async SequentialHandler.queueRequest (./node_modules/@discordjs/rest/dist/index.js:953:14)
at async _REST.request (./node_modules/@discordjs/rest/dist/index.js:1266:22)
at async PermissionOverwriteManager.upsert (./node_modules/discord.js/src/managers/PermissionOverwriteManager.js:107:5)
at async ./commands/mute.js:134:13 {
requestBody: {
files: undefined,
json: {
id: '767335568647782441',
type: 1,
allow: PermissionsBitField { bitfield: 0n },
deny: PermissionsBitField { bitfield: 70643622086656n }
}
},
rawError: { message: 'Missing Access', code: 50001 },
code: 50001,
status: 403,
method: 'PUT',
url: 'https://discord.com/api/v10/channels/1203231726688538635/permissions/767335568647782441'
}

Node.js v18.16.0
./node_modules/@discordjs/rest/dist/index.js:722
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[50001]: Missing Access
at handleErrors (./node_modules/@discordjs/rest/dist/index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (./node_modules/@discordjs/rest/dist/index.js:1120:23)
at async SequentialHandler.queueRequest (./node_modules/@discordjs/rest/dist/index.js:953:14)
at async _REST.request (./node_modules/@discordjs/rest/dist/index.js:1266:22)
at async PermissionOverwriteManager.upsert (./node_modules/discord.js/src/managers/PermissionOverwriteManager.js:107:5)
at async ./commands/mute.js:134:13 {
requestBody: {
files: undefined,
json: {
id: '767335568647782441',
type: 1,
allow: PermissionsBitField { bitfield: 0n },
deny: PermissionsBitField { bitfield: 70643622086656n }
}
},
rawError: { message: 'Missing Access', code: 50001 },
code: 50001,
status: 403,
method: 'PUT',
url: 'https://discord.com/api/v10/channels/1203231726688538635/permissions/767335568647782441'
}

Node.js v18.16.0
In my code, I have a custom mute command that changes the user's permission so they just cannot send messages, which I used "channel.permissionOverwrites.create(...)", but then this line caused the error. But it didn't have this error when I gave it admin permission. Is there any way to prevent this without granting it admin perm? P/s: In my OAuth2, I set the scope to application.commands & bot, and all permissions except admin.
12 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!
rubii
rubiiOP5mo ago
The full code that causes the error is
await channel.permissionOverwrites.create(user.id,
{ 'SendMessages': false,
'SendMessagesInThreads': false,
'SendVoiceMessages': false,
});
await channel.permissionOverwrites.create(user.id,
{ 'SendMessages': false,
'SendMessagesInThreads': false,
'SendVoiceMessages': false,
});
treble/luna
treble/luna5mo ago
the bot does not have access to the channel, or the bot is not in the guild also why not use timeouts
rubii
rubiiOP5mo ago
it's for some personal reason, specifically i want the user to not be able to send message but able to click some buttons so that's why i customize this "mute" also this happens after i issued the slash command
treble/luna
treble/luna5mo ago
does the bot have access to the channel and is the bot in the guild
rubii
rubiiOP5mo ago
yes it is. when i see the channel, i see the bot is online
treble/luna
treble/luna5mo ago
does the bot have manage channel permissions
rubii
rubiiOP5mo ago
yes I checked all the permission but admin :,,,,,,,( i tried checking only needed permission at first but it just doesn't work, so i'm so desperate to the point that i checked everything but admin and it still doesnt work T T
treble/luna
treble/luna5mo ago
log <Interaction>.channel.permissionsFor(<Guild>.members.me)
rubii
rubiiOP5mo ago
when i logged this (
channel.permissionsFor(guild.members.me).toArray()
channel.permissionsFor(guild.members.me).toArray()
), it's giving all the permission i think:
CreateInstantInvite,KickMembers,BanMembers,ManageChannels,ManageGuild,AddReactions,ViewAuditLog,PrioritySpeaker,Stream,SendMessages,SendTTSMessages,ManageMessages,EmbedLinks,AttachFiles,ReadMessageHistory,MentionEveryone,UseExternalEmojis,ViewGuildInsights,Connect,Speak,MuteMembers,DeafenMembers,MoveMembers,UseVAD,ChangeNickname,ManageNicknames,ManageRoles,ManageWebhooks,ManageEmojisAndStickers,ManageGuildExpressions,UseApplicationCommands,RequestToSpeak,ManageEvents,ManageThreads,CreatePublicThreads,CreatePrivateThreads,UseExternalStickers,SendMessagesInThreads,UseEmbeddedActivities,ModerateMembers,ViewCreatorMonetizationAnalytics,UseSoundboard,UseExternalSounds,SendVoiceMessages
CreateInstantInvite,KickMembers,BanMembers,ManageChannels,ManageGuild,AddReactions,ViewAuditLog,PrioritySpeaker,Stream,SendMessages,SendTTSMessages,ManageMessages,EmbedLinks,AttachFiles,ReadMessageHistory,MentionEveryone,UseExternalEmojis,ViewGuildInsights,Connect,Speak,MuteMembers,DeafenMembers,MoveMembers,UseVAD,ChangeNickname,ManageNicknames,ManageRoles,ManageWebhooks,ManageEmojisAndStickers,ManageGuildExpressions,UseApplicationCommands,RequestToSpeak,ManageEvents,ManageThreads,CreatePublicThreads,CreatePrivateThreads,UseExternalStickers,SendMessagesInThreads,UseEmbeddedActivities,ModerateMembers,ViewCreatorMonetizationAnalytics,UseSoundboard,UseExternalSounds,SendVoiceMessages
rubii
rubiiOP5mo ago
That's true though... But in the bot's role in the server, I saw that this is already checked. What might be the reason it's not there?
No description
rubii
rubiiOP5mo ago
I just figured out the issue! Turns out the bot cannot access private channels, and I think it's because it doesn't have admin permission. Is it not possible for a bot without admin permission to view private channel?
Want results from more Discord servers?
Add your server