diff --git a/index.js b/index.js index 6f449be..3824e47 100644 --- a/index.js +++ b/index.js @@ -92,26 +92,19 @@ client.on('interactionCreate', async interaction => { ephemeral: true }); } - if (toChannel?.type == Discord.ChannelType.GuildVoice) { - interaction.guild.channels.cache.forEach(channel => { - if (channel?.type == Discord.ChannelType.GuildVoice) { - channel.members.forEach(member => { - member.voice.setChannel(toChannel).catch(err => { - // Do nothing, 99% missing permissions - });; - }); - } - }); - interaction.reply({ - content: "Moved all users to " + toChannel.name, - ephemeral: true - }); - } else { - return interaction.reply({ - content: "You must specify a voice channel", - ephemeral: true - }); - } + interaction.guild.channels.cache.forEach(channel => { + if (channel?.type == Discord.ChannelType.GuildVoice) { + channel.members.forEach(member => { + member.voice.setChannel(toChannel).catch(err => { + // Do nothing, 99% missing permissions + });; + }); + } + }); + interaction.reply({ + content: "Moved all users to " + toChannel.name, + ephemeral: true + }); break; case "move": fromChannel = interaction.options.getChannel("from"); @@ -122,41 +115,27 @@ client.on('interactionCreate', async interaction => { ephemeral: true }); } - if (fromChannel?.type == Discord.ChannelType.GuildVoice || toChannel?.type == Discord.ChannelType.GuildVoice) { - fromChannel?.members?.forEach(member => { - member.voice?.setChannel(toChannel).catch(err => { + fromChannel?.members?.forEach(member => { + member.voice?.setChannel(toChannel).catch(err => { + // Do nothing, 99% missing permissions + });; + }); + interaction.reply({ + content: "Moved all users from " + fromChannel.name + " to " + toChannel.name, + ephemeral: true + }); + break; + case "disconnectall": + interaction.guild.channels.cache.forEach(channel => { + channel.members?.forEach(member => { + member.voice.setChannel(null).catch(err => { // Do nothing, 99% missing permissions });; }); interaction.reply({ - content: "Moved all users from " + fromChannel.name + " to " + toChannel.name, + content: "Disconnected all users", ephemeral: true }); - } else { - return interaction.reply({ - content: "You must specify a voice channel", - ephemeral: true - }); - } - break; - case "disconnectall": - interaction.guild.channels.cache.forEach(channel => { - if (channel?.type == Discord.ChannelType.GuildVoice) { - channel.members?.forEach(member => { - member.voice.setChannel(null).catch(err => { - // Do nothing, 99% missing permissions - });; - }); - interaction.reply({ - content: "Disconnected all users", - ephemeral: true - }); - } else { - return interaction.reply({ - content: "You must specify a voice channel", - ephemeral: true - }); - } }); break; case "disconnect": @@ -167,22 +146,15 @@ client.on('interactionCreate', async interaction => { ephemeral: true }); } - if (channel?.type == Discord.ChannelType.GuildVoice) { - channel?.members?.forEach(member => { - member.voice?.setChannel(null).catch(err => { - // Do nothing, 99% missing permissions - }); + channel?.members?.forEach(member => { + member.voice?.setChannel(null).catch(err => { + // Do nothing, 99% missing permissions }); - interaction.reply({ - content: "Disconnected all users from " + channel.name, - ephemeral: true - }); - } else { - return interaction.reply({ - content: "You must specify a voice channel", - ephemeral: true - }); - } + }); + interaction.reply({ + content: "Disconnected all users from " + channel.name, + ephemeral: true + }); break; } });