basic chanel creation
This commit is contained in:
parent
a0eb75e4ee
commit
1a3e7ac96b
@ -1,16 +1,28 @@
|
|||||||
import { Events } from 'discord.js';
|
import { PermissionsBitField } from 'discord.js';
|
||||||
|
import { ChannelType, Events } from 'discord.js';
|
||||||
|
|
||||||
export const name = Events.VoiceStateUpdate;
|
export const name = Events.VoiceStateUpdate;
|
||||||
export async function execute(oldState, newState) {
|
export async function execute(_, state) {
|
||||||
console.debug('[DEBUG] Voice State Update');
|
if (!state.channel) return;
|
||||||
|
|
||||||
const change = !!oldState.channel ^ !!newState.channel;
|
const member = state.member;
|
||||||
if (!change) return;
|
const name = member.user.username;
|
||||||
|
|
||||||
const guild = newState.guild.name;
|
const channels = state.guild.channels;
|
||||||
const member = newState.member.user.username;
|
const privCh = await channels.create({
|
||||||
const state = newState.channel ? 'joined' : 'left';
|
name: `${name}${name.endsWith('s') ? "'" : "'s"} channel`,
|
||||||
const channel = (oldState.channel ?? newState.channel).name;
|
type: ChannelType.GuildVoice,
|
||||||
|
permissionOverwrites: [
|
||||||
console.debug(`[DEBUG] User '${member}' ${state} channel '${channel}' in guild '${guild}'.`);
|
{
|
||||||
|
id: member.id,
|
||||||
|
allow: [
|
||||||
|
PermissionsBitField.All
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
await state.setChannel(privCh);
|
||||||
|
|
||||||
|
console.debug(`[DEBUG] User '${member}' created private channel!`);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user