Skip to content

Commit

Permalink
[Fix] Added error handling in case a channel with the given id does n…
Browse files Browse the repository at this point in the history
…ot exist, added automatic region option
  • Loading branch information
naseif committed Sep 1, 2021
1 parent c86ad65 commit 57887b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion commands/admin/region.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
.setName("region")
.setDescription("select the region you wish to set")
.setRequired(true)
.addChoice("Automatic", "null")
.addChoice("Brazil", "brazil")
.addChoice("Europe", "europe")
.addChoice("Hong Kong", "hongkong")
Expand Down Expand Up @@ -56,7 +57,7 @@ module.exports = {
],
});
}
let currentRtc = voiceChannel.rtcRegion;

try {
await voiceChannel.setRTCRegion(region);
await interaction.followUp({
Expand Down
14 changes: 13 additions & 1 deletion commands/admin/regionById.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
.setName("region")
.setDescription("select the region you wish to set")
.setRequired(true)
.addChoice("Automatic", "null")
.addChoice("Brazil", "brazil")
.addChoice("Europe", "europe")
.addChoice("Hong Kong", "hongkong")
Expand All @@ -36,7 +37,18 @@ module.exports = {
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;
let currentRtc = voiceChannel.rtcRegion || "Default";

if (!voiceChannel) {
return await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
`A voice channel with this id does not exist!`
),
],
});
}

if (
!interaction.member.permissions.has([Permissions.FLAGS.ADMINISTRATOR]) ||
Expand Down

0 comments on commit 57887b9

Please sign in to comment.