Fix possible loophole
This commit is contained in:
parent
185c357220
commit
cb9e49dd2c
19
index.js
19
index.js
|
@ -85,6 +85,13 @@ client.on('interactionCreate', async interaction => {
|
|||
switch (interaction.commandName) {
|
||||
case "moveall":
|
||||
toChannel = interaction.options.getChannel("to");
|
||||
// Check that toChannel is in same guild as interaction
|
||||
if (toChannel?.guild != interaction.guild) {
|
||||
return interaction.reply({
|
||||
content: "You must specify a voice channel in this server",
|
||||
ephemeral: true
|
||||
});
|
||||
}
|
||||
if (toChannel?.type == Discord.ChannelType.GuildVoice) {
|
||||
interaction.guild.channels.cache.forEach(channel => {
|
||||
if (channel?.type == Discord.ChannelType.GuildVoice) {
|
||||
|
@ -107,6 +114,12 @@ client.on('interactionCreate', async interaction => {
|
|||
case "move":
|
||||
fromChannel = interaction.options.getChannel("from");
|
||||
toChannel = interaction.options.getChannel("to");
|
||||
if (toChannel?.guild != interaction.guild || fromChannel?.guild != interaction.guild) {
|
||||
return interaction.reply({
|
||||
content: "You must specify a voice channel in this server",
|
||||
ephemeral: true
|
||||
});
|
||||
}
|
||||
if (fromChannel?.type == Discord.ChannelType.GuildVoice || toChannel?.type == Discord.ChannelType.GuildVoice) {
|
||||
fromChannel?.members?.forEach(member => {
|
||||
member.voice?.setChannel(toChannel);
|
||||
|
@ -142,6 +155,12 @@ client.on('interactionCreate', async interaction => {
|
|||
break;
|
||||
case "disconnect":
|
||||
channel = interaction.options.getChannel("channel");
|
||||
if (channel?.guild != interaction.guild) {
|
||||
return interaction.reply({
|
||||
content: "You must specify a voice channel in this server",
|
||||
ephemeral: true
|
||||
});
|
||||
}
|
||||
if (channel?.type == Discord.ChannelType.GuildVoice) {
|
||||
channel?.members?.forEach(member => {
|
||||
member.voice?.setChannel(null);
|
||||
|
|
Loading…
Reference in a new issue