feat(interaction): send member locale from interaction#99
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a framework-level locale abstraction (StelliaLocale) and wires Discord interaction user locale through interaction execution hooks, enabling command/button/etc handlers to receive the member’s locale directly.
Changes:
- Add
StelliaLocaleenum and export it via@typescript/index.js. - Update interaction structure
execute(...)signatures to include amemberLocale: StelliaLocaleparameter. - Update guild configuration/translation typing to use
StelliaLocale, and adjustgetGuildConfigurationto returnnull(instead ofundefined).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/translation.ts | Switches translation locale typing from Discord Locale to StelliaLocale. |
| src/typescript/types.ts | Updates configuration typing to use StelliaLocale; changes GuildConfigurationType to null-based absence. |
| src/typescript/locale.ts | Adds the StelliaLocale enum defining supported base language codes. |
| src/typescript/index.ts | Re-exports the new locale module. |
| src/structures/Interaction.ts | Extends all interaction execute(...) signatures to include memberLocale. |
| src/client/StelliaUtils.ts | Converts Discord locale to StelliaLocale and passes it into handlers; updates guild config retrieval to return null. |
| src/client/StelliaClient.ts | Updates getGuildConfiguration return type to null-based absence. |
Comments suppressed due to low confidence (1)
src/client/StelliaUtils.ts:91
getGuildConfigurationcan return an object whoseguildfield isundefinedwhenguilds[guildId]has no entry. That breaks theGuildConfigurationcontract and can lead to runtime errors in handlers expectingguild.locale, etc. Consider returningnull(or throwing) whenguildConfigurationis missing, or changing theGuildsConfiguration.guildstype to explicitly allow missing keys and handle that case here.
const { guilds, general } = this.guildsConfiguration;
const guildConfiguration = guilds[guildId];
return {
general: general,
guild: guildConfiguration
} as CustomGuildConfiguration;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+276
to
+278
| } else { | ||
| const modalWithoutGuildConfiguration = selectMenu as SelectMenuStructureWithoutGuildConfiguration; | ||
| await modalWithoutGuildConfiguration.execute(this.client, selectMenuInteraction); | ||
| await modalWithoutGuildConfiguration.execute(this.client, memberLocale, selectMenuInteraction); |
Comment on lines
+2
to
+30
| Indonesian = "id", | ||
| English = "en", | ||
| Bulgarian = "bg", | ||
| Chinese = "zh", | ||
| Croatian = "hr", | ||
| Czech = "cs", | ||
| Danish = "da", | ||
| Dutch = "nl", | ||
| Finnish = "fi", | ||
| French = "fr", | ||
| German = "de", | ||
| Greek = "el", | ||
| Hindi = "hi", | ||
| Hungarian = "hu", | ||
| Italian = "it", | ||
| Japanese = "ja", | ||
| Korean = "ko", | ||
| Lithuanian = "lt", | ||
| Norwegian = "no", | ||
| Polish = "pl", | ||
| Portuguese = "pt", | ||
| Romanian = "ro", | ||
| Russian = "ru", | ||
| Spanish = "es", | ||
| Swedish = "sv", | ||
| Thai = "th", | ||
| Turkish = "tr", | ||
| Ukrainian = "uk", | ||
| Vietnamese = "vi" |
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



No description provided.