-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[New] Added region command which changes the region for the voice cha…
…nnel the member is currently connected to!
- Loading branch information
Showing
1 changed file
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
const { SlashCommandBuilder } = require("@discordjs/builders"); | ||
const { Permissions } = require("discord.js"); | ||
const { embedMessage } = require("../../modules/embedSimple"); | ||
|
||
module.exports = { | ||
data: new SlashCommandBuilder() | ||
.setName("region") | ||
.setDescription( | ||
"changes the region of the voice channel the user is connected to" | ||
) | ||
.addStringOption((option) => | ||
option | ||
.setName("region") | ||
.setDescription("select the region you wish to set") | ||
.setRequired(true) | ||
.addChoice("Brazil", "brazil") | ||
.addChoice("Europe", "europe") | ||
.addChoice("Hong Kong", "hongkong") | ||
.addChoice("India", "india") | ||
.addChoice("Japan", "japan") | ||
.addChoice("Russia", "russia") | ||
.addChoice("Singapore", "singapore") | ||
.addChoice("Sydney", "sydney") | ||
.addChoice("South Africa", "southafrica") | ||
.addChoice("US Central", "us-central") | ||
.addChoice("US East", "us-east") | ||
.addChoice("US South", "us-south") | ||
.addChoice("US West", "us-west") | ||
), | ||
async execute(interaction, client) { | ||
await interaction.deferReply(); | ||
const voiceChannel = interaction.member.voice.channel; | ||
const region = interaction.options.getString("region"); | ||
|
||
if (!voiceChannel) { | ||
return await interaction.followUp({ | ||
embeds: [ | ||
embedMessage( | ||
"#9dcc37", | ||
`You have to be connected to the voice channel to use this commnad\n see /regionbyid instead!` | ||
), | ||
], | ||
}); | ||
} | ||
|
||
if ( | ||
!interaction.member.permissions.has([Permissions.FLAGS.ADMINISTRATOR]) || | ||
!interaction.member.permissions.has([Permissions.FLAGS.MANAGE_CHANNELS]) | ||
) { | ||
return await interaction.followUp({ | ||
embeds: [ | ||
embedMessage( | ||
"#9dcc37", | ||
`${interaction.member.toString()} You do not have permssion to edit the region of channels!` | ||
), | ||
], | ||
}); | ||
} | ||
|
||
try { | ||
await voiceChannel.setRTCRegion(region); | ||
await interaction.followUp({ | ||
embeds: [ | ||
embedMessage( | ||
"#9dcc37", | ||
`Region of ${voiceChannel.toString()} has been changed to ${ | ||
voiceChannel.rtcRegion | ||
}` | ||
), | ||
], | ||
}); | ||
} catch (err) { | ||
console.error(err); | ||
await interaction.followUp({ | ||
embeds: [ | ||
embedMessage( | ||
"#9dcc37", | ||
`Could not change the region of this channel!` | ||
), | ||
], | ||
}); | ||
} | ||
}, | ||
}; |