locales in interactions?

so i have a command that handles locales, it has buttons and those are handled in a different event handling file. but I cannot figure out how to extract locale from interactions.
client.on(Events.InteractionCreate, async interaction => {
let userLocale = interaction.member ? interaction.member.locale : (interaction.user.locale || 'en');

console.log('User's Discord Locale: ${userLocale}');

// code

// Set the locale for i18n
i18n.setLocale(userLocale);
console.log('bot.js Current i18n locale: ${i18n.getLocale()}');
});
client.on(Events.InteractionCreate, async interaction => {
let userLocale = interaction.member ? interaction.member.locale : (interaction.user.locale || 'en');

console.log('User's Discord Locale: ${userLocale}');

// code

// Set the locale for i18n
i18n.setLocale(userLocale);
console.log('bot.js Current i18n locale: ${i18n.getLocale()}');
});
Prior to that initial let, i had: let userLocale = interaction.user.locale || 'en'; which also didn't achieve the results either
2 Replies
d.js toolkit
d.js toolkit2y 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!
d.js docs
d.js docs2y ago
property ButtonInteraction#locale The locale of the user who invoked this interaction
Want results from more Discord servers?
Add your server