Issue while creating a category with permission overrides

Context here to here
24 Replies
d.js toolkit
d.js toolkit2w 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! - Marked as resolved by OP
Mark
Mark2w ago
the bot also needs the permission it's allowing or denying
materwelon
materwelonOP2w ago
It has all permissions it’s allowing/denying :yescat: I have a permission check middleware that runs before this handler that makes sure it has them on its role I’ll check once again once I’m back home and send a screenshot here :thumbsup:
Inky
Inky2w ago
Use PermissionsBitField to read off the permissions, not BitField. Huge blunder by me
materwelon
materwelonOP2w ago
Ahhh. Okay lemmi check that All good :heartWumpus:
materwelon
materwelonOP2w ago
No description
materwelon
materwelonOP2w ago
These are all the permissions I am making sure the bot has. Second image has all the permissions I'm assigning/denying
No description
No description
materwelon
materwelonOP2w ago
yeah the bot has all the perms as well
materwelon
materwelonOP2w ago
Perms it has in the discord server
No description
materwelon
materwelonOP2w ago
^ guild does not require 2FA, I do have 2FA. But if that was the issue it wouldn't work with Admin perms. I should note, the bot is able to create roles. It only breaks when it tries to create a category I'll drop the full code just in case.
materwelon
materwelonOP2w ago
ooooooo breh so the bot most definitely needs admin while setup because bot needs to set Manage Permissions as allowed in the category it creates for itself I don't want the bot to rely on role based perms in case someone in the server removes it. The bot creates its category and after that it will only ever do stuff in that category hmm, if you put it like that :Thonk: anyway, it does need Manage Roles to give players the player role anyway so it would break regardless if that perm is removed. let me quickly test this out and update here ticket tool also requires manage permissions as a category permission in the ticket category. I wouldn't call that shady business though depends on the use case of the bot that didn't fix it :pain:
private botPermissions(): OverwriteData {
const botPermissions =
PermissionFlagsBits.ManageChannels |
PermissionFlagsBits.ManageWebhooks |
PermissionFlagsBits.UseExternalEmojis |
PermissionFlagsBits.ManageMessages |
this.commonPermissions();

return {
id: this.event.client.user.id,
allow: botPermissions,
type: OverwriteType.Member
};
}

private managerRolePermissions(allowSend: boolean = true): OverwriteData {
const managerPermissions = PermissionFlagsBits.ManageMessages | this.commonPermissions(allowSend);

return {
id: this.managerRole.id,
allow: managerPermissions,
type: OverwriteType.Role
};
}
private botPermissions(): OverwriteData {
const botPermissions =
PermissionFlagsBits.ManageChannels |
PermissionFlagsBits.ManageWebhooks |
PermissionFlagsBits.UseExternalEmojis |
PermissionFlagsBits.ManageMessages |
this.commonPermissions();

return {
id: this.event.client.user.id,
allow: botPermissions,
type: OverwriteType.Member
};
}

private managerRolePermissions(allowSend: boolean = true): OverwriteData {
const managerPermissions = PermissionFlagsBits.ManageMessages | this.commonPermissions(allowSend);

return {
id: this.managerRole.id,
allow: managerPermissions,
type: OverwriteType.Role
};
}
I removed ManageRoles from both botPermissions and manageRolePermissions.
materwelon
materwelonOP2w ago
No description
materwelon
materwelonOP2w ago
wait. WAIT hm that's a new error actually. It created the category this time
private async registrationChannel(): Promise<TextChannel> {
const registrationChannel: CategoryCreateChannelOptions = {
name: '🎱・registration',
type: ChannelType.GuildText,
reason: 'Creating registration channel',
permissionOverwrites: [
this.botPermissions(),
this.everyonePermissions(true),
this.managerRolePermissions(false),
this.playerRolePermissions(false)
]
};

return await this.category.children.create(registrationChannel);
}
private async registrationChannel(): Promise<TextChannel> {
const registrationChannel: CategoryCreateChannelOptions = {
name: '🎱・registration',
type: ChannelType.GuildText,
reason: 'Creating registration channel',
permissionOverwrites: [
this.botPermissions(),
this.everyonePermissions(true),
this.managerRolePermissions(false),
this.playerRolePermissions(false)
]
};

return await this.category.children.create(registrationChannel);
}
i wish Missing Permissions gave more info about what is missing. I do. Check commonPermissions
materwelon
materwelonOP2w ago
I also tested with admin perms to see the channel perms the bot gets, it has it. In fact, for the registration channel, @ everyone has View Channel as well.
No description
materwelon
materwelonOP2w ago
alright. give me a min ye
{
name: '🎱・registration',
type: 0,
reason: 'Creating registration channel',
permissionOverwrites: [
{ id: '1290511879390887966', allow: 537259024n, type: 1 },
{ id: '1297469570625568789', deny: 2112n, allow: 1024n, type: 0 },
{ id: '1360594778827391106', allow: 9216n, type: 0 },
{ id: '1360594782153605200', allow: 1024n, type: 0 }
]
}
{
name: '🎱・registration',
type: 0,
reason: 'Creating registration channel',
permissionOverwrites: [
{ id: '1290511879390887966', allow: 537259024n, type: 1 },
{ id: '1297469570625568789', deny: 2112n, allow: 1024n, type: 0 },
{ id: '1360594778827391106', allow: 9216n, type: 0 },
{ id: '1360594782153605200', allow: 1024n, type: 0 }
]
}
[
'CreateInstantInvite',
'ManageChannels',
'ManageMessages',
'EmbedLinks',
'AttachFiles',
'ReadMessageHistory',
'UseExternalEmojis',
'ChangeNickname',
'ManageNicknames',
'ManageRoles',
'ManageWebhooks',
'UseApplicationCommands'
]
[
'CreateInstantInvite',
'ManageChannels',
'ManageMessages',
'EmbedLinks',
'AttachFiles',
'ReadMessageHistory',
'UseExternalEmojis',
'ChangeNickname',
'ManageNicknames',
'ManageRoles',
'ManageWebhooks',
'UseApplicationCommands'
]
wait hold on. permissionsFor is wrong. i did it for the role
[
'CreateInstantInvite', 'ManageChannels',
'Stream', 'ViewChannel',
'SendMessages', 'ManageMessages',
'EmbedLinks', 'AttachFiles',
'ReadMessageHistory', 'UseExternalEmojis',
'Connect', 'Speak',
'UseVAD', 'ChangeNickname',
'ManageNicknames', 'ManageRoles',
'ManageWebhooks', 'UseApplicationCommands',
'RequestToSpeak', 'CreatePublicThreads',
'CreatePrivateThreads', 'UseExternalStickers',
'SendMessagesInThreads', 'UseEmbeddedActivities',
'UseSoundboard', 'UseExternalSounds',
'SendVoiceMessages', 'SendPolls',
'UseExternalApps'
]
[
'CreateInstantInvite', 'ManageChannels',
'Stream', 'ViewChannel',
'SendMessages', 'ManageMessages',
'EmbedLinks', 'AttachFiles',
'ReadMessageHistory', 'UseExternalEmojis',
'Connect', 'Speak',
'UseVAD', 'ChangeNickname',
'ManageNicknames', 'ManageRoles',
'ManageWebhooks', 'UseApplicationCommands',
'RequestToSpeak', 'CreatePublicThreads',
'CreatePrivateThreads', 'UseExternalStickers',
'SendMessagesInThreads', 'UseEmbeddedActivities',
'UseSoundboard', 'UseExternalSounds',
'SendVoiceMessages', 'SendPolls',
'UseExternalApps'
]
console.dir(registrationChannel, { depth: null });
console.log(this.category.permissionsFor(this.event.client.user)!.toArray());
console.dir(registrationChannel, { depth: null });
console.log(this.category.permissionsFor(this.event.client.user)!.toArray());
from above
`{ id: '1290511879390887966', allow: 537259024n, type: 1 }`
`{ id: '1290511879390887966', allow: 537259024n, type: 1 }`
console.log(new PermissionsBitField(537259024n).toArray());
console.log(new PermissionsBitField(537259024n).toArray());
[
'ManageChannels',
'ViewChannel',
'SendMessages',
'ManageMessages',
'EmbedLinks',
'AttachFiles',
'ReadMessageHistory',
'UseExternalEmojis',
'ManageWebhooks'
]
[
'ManageChannels',
'ViewChannel',
'SendMessages',
'ManageMessages',
'EmbedLinks',
'AttachFiles',
'ReadMessageHistory',
'UseExternalEmojis',
'ManageWebhooks'
]
hmmmmmmmm think I found it. nop nevermind yeah I'm stumped. that's what I said nevermind for because the bot does have it ohh wait. So. I deny the perm on everyone but I don't allow it for the bot role and since channel perms override ah. okay
[
'CreateInstantInvite', 'ManageChannels',
'AddReactions', 'Stream',
'ManageMessages', 'EmbedLinks',
'AttachFiles', 'ReadMessageHistory',
'UseExternalEmojis', 'Connect',
'Speak', 'UseVAD',
'ChangeNickname', 'ManageNicknames',
'ManageRoles', 'ManageWebhooks',
'UseApplicationCommands', 'RequestToSpeak',
'CreatePublicThreads', 'CreatePrivateThreads',
'UseExternalStickers', 'SendMessagesInThreads',
'UseEmbeddedActivities', 'UseSoundboard',
'UseExternalSounds', 'SendVoiceMessages',
'SendPolls', 'UseExternalApps'
]
[
'CreateInstantInvite', 'ManageChannels',
'AddReactions', 'Stream',
'ManageMessages', 'EmbedLinks',
'AttachFiles', 'ReadMessageHistory',
'UseExternalEmojis', 'Connect',
'Speak', 'UseVAD',
'ChangeNickname', 'ManageNicknames',
'ManageRoles', 'ManageWebhooks',
'UseApplicationCommands', 'RequestToSpeak',
'CreatePublicThreads', 'CreatePrivateThreads',
'UseExternalStickers', 'SendMessagesInThreads',
'UseEmbeddedActivities', 'UseSoundboard',
'UseExternalSounds', 'SendVoiceMessages',
'SendPolls', 'UseExternalApps'
]
It has it now BUT.
materwelon
materwelonOP2w ago
No description
materwelon
materwelonOP2w ago
:HH_cryAqua: yea. It's the same.
materwelon
materwelonOP2w ago
No description
materwelon
materwelonOP2w ago
@Qjuh yes. I added it to botPermissions. It gets added in every channel.
private botPermissions(): OverwriteData {
const botPermissions =
PermissionFlagsBits.ManageChannels |
PermissionFlagsBits.ManageWebhooks |
PermissionFlagsBits.UseExternalEmojis |
PermissionFlagsBits.ManageMessages |
PermissionFlagsBits.AddReactions;
this.commonPermissions();

return {
id: this.event.client.user.id,
allow: botPermissions,
type: OverwriteType.Member
};
}
private botPermissions(): OverwriteData {
const botPermissions =
PermissionFlagsBits.ManageChannels |
PermissionFlagsBits.ManageWebhooks |
PermissionFlagsBits.UseExternalEmojis |
PermissionFlagsBits.ManageMessages |
PermissionFlagsBits.AddReactions;
this.commonPermissions();

return {
id: this.event.client.user.id,
allow: botPermissions,
type: OverwriteType.Member
};
}
wait lmfao. i see the issue. bro :HH_cryCat: this is just embarrasing atp
materwelon
materwelonOP2w ago
Would you look at that
No description
No description
materwelon
materwelonOP2w ago
glorious where can I find this information? So I know where to look next time
d.js docs
d.js docs2w ago
:discord: Guild Resource - Create Guild Channel read more
materwelon
materwelonOP2w ago
much appreciated. Thanks all!

Did you find this page helpful?