Skip to content

Commit fc4189c

Browse files
committed
feat: stuff
1 parent cd9fba9 commit fc4189c

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/commands/Config.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,22 @@ import k from "kleur";
1515

1616
//#region constants
1717

18-
const localesReformatted = [...localesJson]
19-
.sort((a, b) => a.nativeName.localeCompare(b.nativeName))
20-
.map((loc) => ({
21-
value: loc.code,
22-
name: `${loc.emoji} ${/\(.+\)/.test(loc.name)
23-
? loc.name
24-
: `${loc.name} (${loc.nativeName})`
25-
} ${getRegisteredTranslations().has(loc.code) ? "✅" : "⚠️"}`,
26-
loc,
27-
}));
18+
let localesReformatted: { value: string; name: string; loc: typeof localesJson[0] }[];
19+
20+
const getLocalesReformatted = () => {
21+
if(!localesReformatted)
22+
localesReformatted = [...localesJson]
23+
.sort((a, b) => a.nativeName.localeCompare(b.nativeName))
24+
.map((loc) => ({
25+
value: loc.code,
26+
name: `${loc.emoji} ${/\(.+\)/.test(loc.name)
27+
? loc.name
28+
: `${loc.name} (${loc.nativeName})`
29+
} ${getRegisteredTranslations().has(loc.code) ? "✅" : "⚠️"}`,
30+
loc,
31+
}));
32+
return localesReformatted;
33+
};
2834

2935
/** Configuration setting name mapping - value has to adhere to Discord slash command naming rules (lowercase and underscores only!) */
3036
const getSCNames = () => ({
@@ -275,7 +281,7 @@ export class ConfigCmd extends SlashCommand {
275281

276282
switch(int.options.getSubcommand(true)) {
277283
case "locale": {
278-
const res = localesReformatted
284+
const res = getLocalesReformatted()
279285
.filter(({ loc: { code, name, nativeName } }) =>
280286
code.toLowerCase().includes(searchVal)
281287
|| name.toLowerCase().includes(searchVal)

0 commit comments

Comments
 (0)