2024-02-07 16:36:00 +00:00
|
|
|
import { PermissionsBitField } from 'discord.js';
|
|
|
|
import { ChannelType, Events } from 'discord.js';
|
2024-01-28 17:33:22 +00:00
|
|
|
|
|
|
|
export const name = Events.VoiceStateUpdate;
|
2024-02-07 16:36:00 +00:00
|
|
|
export async function execute(_, state) {
|
|
|
|
if (!state.channel) return;
|
2024-01-28 17:33:22 +00:00
|
|
|
|
2024-02-07 16:36:00 +00:00
|
|
|
const member = state.member;
|
|
|
|
const name = member.user.username;
|
2024-01-28 17:33:22 +00:00
|
|
|
|
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-01-28 17:33:22 +00:00
|
|
|
|
2024-02-07 16:36:00 +00:00
|
|
|
await state.setChannel(privCh);
|
|
|
|
|
|
|
|
console.debug(`[DEBUG] User '${member}' created private channel!`);
|
2024-01-28 17:33:22 +00:00
|
|
|
}
|