-
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 regionbyid command which changes the voice channel region…
… by an id input
- Loading branch information
Showing
2 changed files
with
80 additions
and
1 deletion.
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,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!` | ||
), | ||
], | ||
}); | ||
} | ||
}, | ||
}; |
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