Skip to content

Commit

Permalink
[New] Added regionbyid command which changes the voice channel region…
Browse files Browse the repository at this point in the history
… by an id input
  • Loading branch information
naseif committed Sep 1, 2021
1 parent 0162fe5 commit 852b34b
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 1 deletion.
79 changes: 79 additions & 0 deletions commands/admin/regionById.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { Permissions } = require("discord.js");
const { embedMessage } = require("../../modules/embedSimple");

module.exports = {
data: new SlashCommandBuilder()
.setName("regionbyid")
.setDescription("changes a voice channel region by channel id")
.addStringOption((option) =>
option
.setName("id")
.setDescription("provide the voice channel id")
.setRequired(true)
)
.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 vcId = interaction.options.getString("id");
const region = interaction.options.getString("region");
const voiceChannel = await interaction.guild.channels.cache.get(vcId);
let currentRtc = voiceChannel.rtcRegion;

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 from ${currentRtc} to ${
voiceChannel.rtcRegion
}`
),
],
});
} catch (err) {
console.error(err);
await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
`Could not change the region of this channel!`
),
],
});
}
},
};
2 changes: 1 addition & 1 deletion commands/misc/nickname.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = {
user &&
!interaction.member.permissions.has(Permissions.FLAGS.MANAGE_NICKNAMES)
) {
await interaction.followUp({
return await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
Expand Down

0 comments on commit 852b34b

Please sign in to comment.