fix(arabot): fix verification vc being removed/not created

This commit is contained in:
smyalygames 2022-10-21 04:14:19 +01:00
parent a545a52ba7
commit c0e5bae1e7
2 changed files with 12 additions and 4 deletions

View File

@ -125,7 +125,7 @@ class VerificationLeaveVCListener extends Listener {
} }
// If there are no VCs left in verification after having the channel deleted // If there are no VCs left in verification after having the channel deleted
if (listVoiceChannels.size === 0) { if (listVoiceChannels.size - 1 === 0) {
// Create a verification channel // Create a verification channel
await guild.channels.create('Verification', { await guild.channels.create('Verification', {
type: 'GUILD_VOICE', type: 'GUILD_VOICE',

View File

@ -47,7 +47,8 @@ class VerificationReady extends Listener {
} }
// Check how many voice channels there are // Check how many voice channels there are
let voiceChannels = category.children.filter((c) => c.type === 'GUILD_VOICE'); const voiceChannels = category.children.filter((c) => c.type === 'GUILD_VOICE');
const currentVCs: VoiceChannel[] = [];
const emptyVC: string[] = []; const emptyVC: string[] = [];
// Delete voice channels // Delete voice channels
voiceChannels.forEach((c) => { voiceChannels.forEach((c) => {
@ -55,6 +56,8 @@ class VerificationReady extends Listener {
if (voiceChannel.members.size === 0) { if (voiceChannel.members.size === 0) {
emptyVC.push(voiceChannel.id); emptyVC.push(voiceChannel.id);
voiceChannel.delete(); voiceChannel.delete();
} else {
currentVCs.push(voiceChannel);
} }
}); });
@ -71,8 +74,13 @@ class VerificationReady extends Listener {
}); });
// Check if there is no voice channels, create verification // Check if there is no voice channels, create verification
voiceChannels = category.children.filter((c) => c.type === 'GUILD_VOICE'); let verification = false;
if (voiceChannels.size === emptyVC.length) { currentVCs.forEach((c) => {
if (c.name === 'Verification') {
verification = true;
}
});
if (currentVCs.length === emptyVC.length || !verification) {
await category.guild.channels.create('Verification', { await category.guild.channels.create('Verification', {
type: 'GUILD_VOICE', type: 'GUILD_VOICE',
parent: IDs.categories.verification, parent: IDs.categories.verification,