Fix possible loophole

This commit is contained in:
Christopher Cookman 2024-06-18 14:15:20 -06:00
parent 185c357220
commit cb9e49dd2c
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42

View file

@ -85,6 +85,13 @@ client.on('interactionCreate', async interaction => {
switch (interaction.commandName) { switch (interaction.commandName) {
case "moveall": case "moveall":
toChannel = interaction.options.getChannel("to"); 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) { if (toChannel?.type == Discord.ChannelType.GuildVoice) {
interaction.guild.channels.cache.forEach(channel => { interaction.guild.channels.cache.forEach(channel => {
if (channel?.type == Discord.ChannelType.GuildVoice) { if (channel?.type == Discord.ChannelType.GuildVoice) {
@ -107,6 +114,12 @@ client.on('interactionCreate', async interaction => {
case "move": case "move":
fromChannel = interaction.options.getChannel("from"); fromChannel = interaction.options.getChannel("from");
toChannel = interaction.options.getChannel("to"); 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) { if (fromChannel?.type == Discord.ChannelType.GuildVoice || toChannel?.type == Discord.ChannelType.GuildVoice) {
fromChannel?.members?.forEach(member => { fromChannel?.members?.forEach(member => {
member.voice?.setChannel(toChannel); member.voice?.setChannel(toChannel);
@ -142,6 +155,12 @@ client.on('interactionCreate', async interaction => {
break; break;
case "disconnect": case "disconnect":
channel = interaction.options.getChannel("channel"); 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) { if (channel?.type == Discord.ChannelType.GuildVoice) {
channel?.members?.forEach(member => { channel?.members?.forEach(member => {
member.voice?.setChannel(null); member.voice?.setChannel(null);