default element

This commit is contained in:
Mylloon 2024-10-14 21:23:29 +02:00
parent 937627b879
commit a8a0c36e51
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 6 additions and 2 deletions

View file

@ -96,7 +96,7 @@ export default async (message: Message, client: Client) => {
// Remove undefined elements // Remove undefined elements
.filter(Boolean); .filter(Boolean);
const loc = getLocale(client, client.config.default_lang); const loc = getLocale(client);
// Remove duplicates then map the quoted posts // Remove duplicates then map the quoted posts
[...new Set(messages)] [...new Set(messages)]

View file

@ -81,9 +81,13 @@ export const getLocalizations = (client: Client, text: string, lowercase = false
* @param lang Lang to fetch * @param lang Lang to fetch
* @returns the map with the desired languaged clogged with the default one * @returns the map with the desired languaged clogged with the default one
*/ */
export const getLocale = (client: Client, lang: string) => { export const getLocale = (client: Client, lang: string | undefined = undefined) => {
// Load default lang // Load default lang
const default_locales = client.locales.get(client.config.default_lang); const default_locales = client.locales.get(client.config.default_lang);
if (!lang) {
return default_locales!;
}
// Load desired lang // Load desired lang
const desired_locales = client.locales.get(lang); const desired_locales = client.locales.get(lang);