voice.setRTCRegion(null) not working

HI, I have this code to change the region and it works perfectly except the null option
const buildSelectMenu = (regions: Collection<string, VoiceRegion>) => {
return new StringSelectMenuBuilder()
.setCustomId('voiceSetRTCRegionMenu')
.setPlaceholder('Change la région de ton serveur')
.addOptions([
{
label: 'Auto',
value: 'null',
emoji: '🌍'
},
...regions.map((region: VoiceRegion) => ({
label: region.name,
value: region.id,
emoji: '🌍'
}))
]);
};

export const buildVoiceSetRTCRegionActionRow = (regions: Collection<string, VoiceRegion>) => {
return new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(buildSelectMenu(regions));
};

export default {
data: {
name: `voiceSetRTCRegionMenu`
},
async execute(interaction: UserSelectMenuInteraction) {
await interaction.deferUpdate();
const region: string = interaction.values[0];
const member = interaction.member as GuildMember;
const voiceChannel = member.voice.channel;

if (voiceChannel) {
if (region === 'null') {
console.log("it's null already");
await voiceChannel.setRTCRegion(null, 'Auto');
} else await voiceChannel.setRTCRegion(region);
}

const newEmbed = new EmbedBuilder()
.setTitle('La région a bien été changée')
.setColor(Colors.random);

return interaction.update({
embeds: [newEmbed],
components: []
});
}
};
const buildSelectMenu = (regions: Collection<string, VoiceRegion>) => {
return new StringSelectMenuBuilder()
.setCustomId('voiceSetRTCRegionMenu')
.setPlaceholder('Change la région de ton serveur')
.addOptions([
{
label: 'Auto',
value: 'null',
emoji: '🌍'
},
...regions.map((region: VoiceRegion) => ({
label: region.name,
value: region.id,
emoji: '🌍'
}))
]);
};

export const buildVoiceSetRTCRegionActionRow = (regions: Collection<string, VoiceRegion>) => {
return new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(buildSelectMenu(regions));
};

export default {
data: {
name: `voiceSetRTCRegionMenu`
},
async execute(interaction: UserSelectMenuInteraction) {
await interaction.deferUpdate();
const region: string = interaction.values[0];
const member = interaction.member as GuildMember;
const voiceChannel = member.voice.channel;

if (voiceChannel) {
if (region === 'null') {
console.log("it's null already");
await voiceChannel.setRTCRegion(null, 'Auto');
} else await voiceChannel.setRTCRegion(region);
}

const newEmbed = new EmbedBuilder()
.setTitle('La région a bien été changée')
.setColor(Colors.random);

return interaction.update({
embeds: [newEmbed],
components: []
});
}
};
3 Replies
d.js toolkit
d.js toolkit14mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
Adan_ea
Adan_eaOP14mo ago
It goes through the loop and console fine, i get this in the logs But i still stay in the wrong region for some reason
No description
Adan_ea
Adan_eaOP14mo ago
Ah wait it works... it's just discord not switching to a better server
Want results from more Discord servers?
Add your server