#private

9 messages · Page 1 of 1 (latest)

covert ether
#

Why channel.setParent may produce DiscordAPIError[50013]: Missing Permissions when the permissions are seemingly set?

Here's the deal: in a command interaction handler, I've successfully created a channel like this:

const channel = await interaction.guild.channels.create({
    name: 'new-channel',
    type: ChannelType.GuildText,
//     parent: categoryId,
})

if I uncomment setting parent, this also works. Now I'm trying to change the parent via

await channel.setParent(categoryId)

I'm getting the error [50013]: Missing Permissions (more details below). I was under an impression that it is ManageChannels permission that I need, so I've checked:

console.log('ManageChannels:',interaction.guild.members.me.permissions.has('ManageChannels'))
console.log('overwrites:',channel.permissionOverwrites.cache.get('ManageChannels'))
console.log('ManageChannels in role:',interaction.guild.members.me.roles.highest.permissions.has('ManageChannels'))

and got

ManageChannels: true
overwrites: undefined
ManageChannels in role: true

I've also check manually that there's no channel permissions overwrites anyway. So how comes I'm still getting this error? Due to Discord limit, I'll add error full text in comments.

vivid sonnet
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

covert ether
#

Full error text:

at SequentialHandler.runRequest (D:\data\based_here\code\business\blockchain\games-apis\node_modules\@discordjs\rest\src\lib\handlers\SequentialHandler.ts:497:11)
at processTicksAndRejections (node:internal/process/task_queues:96:5)    
at SequentialHandler.queueRequest (D:\data\based_here\code\business\blockchain\games-apis\node_modules\@discordjs\rest\src\lib\handlers\SequentialHandler.ts:198:11)
at REST.request (D:\data\based_here\code\business\blockchain\games-apis\node_modules\@discordjs\rest\src\lib\REST.ts:343:20)
at GuildChannelManager.edit (D:\data\based_here\code\business\blockchain\games-apis\node_modules\discord.js\src\managers\GuildChannelManager.js:278:21) {

requestBody: {
files: undefined,
json: {
name: 'new-channel',
type: undefined,
topic: undefined,
nsfw: undefined,
bitrate: undefined,
user_limit: undefined,
rtc_region: undefined,
video_quality_mode: undefined,
parent_id: '1041662999800332400',
lock_permissions: true,
rate_limit_per_user: undefined,
default_auto_archive_duration: undefined,
permission_overwrites: [],
available_tags: undefined,
default_reaction_emoji: undefined,
default_thread_rate_limit_per_user: undefined,
flags: undefined,
default_sort_order: undefined
}
},
rawError: { message: 'Missing Permissions', code: 50013 },
code: 50013,
status: 403,
method: 'PATCH',
url: 'https://discord.com/api/v10/channels/1058000940751400980'
}

#

the exact discord.js version is 14.6.0

spiral fjord
#

The helper method also locks permissions, so it is trying to set permissions on the channel it does not have itself

covert ether
# spiral fjord The helper method also locks permissions, so it is trying to set permissions on ...

sorry, I didn't really get you: what do you refer as "the helper method" here? For instance, what locks which permissions in this code?

const channel = await interaction.guild.channels.create({
    name: 'new-channel',
    type: ChannelType.GuildText,
})
await channel.setParent(categoryId)  // gives DiscordAPIError[50013]: Missing Permissions

it is trying to set permissions on the channel

again, I think I'm not following, what is trying to set permissions on the channel, the setParent method? What kind of permissions? Do you mean that moving a channel to another category would potentially change channel permissions, and that is the source of the problem? If so, what permissions do I have to give to the bot so that it doesn't fail?

dusky ibex
#

It needs the permissions that are allowed/denied for any role on the category you move it to… but why not just create it in the correct category from the get-go and not have that issue

covert ether
# dusky ibex It needs the permissions that are allowed/denied for any role on the category yo...

could you clarify, does this mean that if a role R1 has a permission to send images in that category and role R2 has a permission to, say, embed links in that category, then the bot has to have both those permissions just to move the channel into that category?

The idea is to create the channel in one category, and when the time comes, move it to another one, so yes, I do set the first category when I create the channel, but it's the second one which I have problems with.

dusky ibex