Permission Overwrites on Voice Channels

I set permission overwrites for a voice channel and they do apply, yet they dont seem to take effect at all.
import { Listener } from '@sapphire/framework';
import { ApplyOptions } from '@sapphire/decorators';
import { ChannelType, OverwriteType, Snowflake, VoiceState } from 'discord.js';

@ApplyOptions<Listener.Options>({
name: 'voiceStateUpdate',
})
export class VoiceStateUpdate extends Listener {
channels: Set<Snowflake> = new Set<Snowflake>();
async run(old_state: VoiceState, new_state: VoiceState) {
const channel_id = '1201376611786817566';
const category_id = '1201376440332079124';

if (new_state.channelId === channel_id) {
try {
const new_channel = await old_state.guild.channels.create({
name: `${old_state.member?.user.username} | private`,
type: ChannelType.GuildVoice,
parent: category_id,
userLimit: 2,
permissionOverwrites: [
{
allow: ['ManageChannels', 'ManageRoles', 'Connect'],
type: OverwriteType.Member,
id: old_state.member?.id!,
},
],
});

await old_state.setChannel(
new_channel,
'voice channel was created by them',
);

console.log(
`Here is the channel permissions:\n`,
new_channel.permissionOverwrites.cache.toJSON(),
);

this.channels.add(new_channel.id);
} catch (err) {
this.container.logger.error(err);
}
}

if (
old_state.channel &&
this.channels.has(old_state.channelId!) &&
old_state.channel?.members.size! <= 0
) {
await old_state.channel!.delete('Everyone left the voice channel');
}

return;
}
}
import { Listener } from '@sapphire/framework';
import { ApplyOptions } from '@sapphire/decorators';
import { ChannelType, OverwriteType, Snowflake, VoiceState } from 'discord.js';

@ApplyOptions<Listener.Options>({
name: 'voiceStateUpdate',
})
export class VoiceStateUpdate extends Listener {
channels: Set<Snowflake> = new Set<Snowflake>();
async run(old_state: VoiceState, new_state: VoiceState) {
const channel_id = '1201376611786817566';
const category_id = '1201376440332079124';

if (new_state.channelId === channel_id) {
try {
const new_channel = await old_state.guild.channels.create({
name: `${old_state.member?.user.username} | private`,
type: ChannelType.GuildVoice,
parent: category_id,
userLimit: 2,
permissionOverwrites: [
{
allow: ['ManageChannels', 'ManageRoles', 'Connect'],
type: OverwriteType.Member,
id: old_state.member?.id!,
},
],
});

await old_state.setChannel(
new_channel,
'voice channel was created by them',
);

console.log(
`Here is the channel permissions:\n`,
new_channel.permissionOverwrites.cache.toJSON(),
);

this.channels.add(new_channel.id);
} catch (err) {
this.container.logger.error(err);
}
}

if (
old_state.channel &&
this.channels.has(old_state.channelId!) &&
old_state.channel?.members.size! <= 0
) {
await old_state.channel!.delete('Everyone left the voice channel');
}

return;
}
}
Here is my current code of me making the channel and setting the permissions.
4 Replies
d.js toolkit
d.js toolkit10mo 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!
Aaron
AaronOP10mo ago
oh and the Connect perm also has a green check mark
ThePedroo
ThePedroo10mo ago
This help is for @discordjs/voice And could you define "apply"?
Want results from more Discord servers?
Add your server