DiscordJS-Template/events/channels/voiceStateUpdate.js

29 lines
676 B
JavaScript
Raw Normal View History

2024-02-07 16:36:00 +00:00
import { PermissionsBitField } from 'discord.js';
import { ChannelType, Events } from 'discord.js';
export const name = Events.VoiceStateUpdate;
2024-02-07 16:36:00 +00:00
export async function execute(_, state) {
if (!state.channel) return;
2024-02-07 16:36:00 +00:00
const member = state.member;
const name = member.user.username;
2024-02-07 16:36:00 +00:00
const channels = state.guild.channels;
const privCh = await channels.create({
name: `${name}${name.endsWith('s') ? "'" : "'s"} channel`,
type: ChannelType.GuildVoice,
permissionOverwrites: [
{
id: member.id,
allow: [
PermissionsBitField.All
]
}
]
});
2024-02-07 16:36:00 +00:00
await state.setChannel(privCh);
console.debug(`[DEBUG] User '${member}' created private channel!`);
}