From fffb85fa0d50d6d58c8f8a5a36eb79e36ceab9bf Mon Sep 17 00:00:00 2001 From: Starman <30315137+Starman3787@users.noreply.github.com> Date: Mon, 16 Sep 2024 12:14:18 +0100 Subject: [PATCH] change format and add additional examples --- example.js | 13 ++++++++++++- get.js | 11 +++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/example.js b/example.js index 2b2f60e..b82880d 100644 --- a/example.js +++ b/example.js @@ -2,4 +2,15 @@ import languages from "./get.js"; const language = "en_pr"; -console.log(await languages[language].slash_commands.ping.name); \ No newline at end of file +// non existent, should fallback to en_us +console.log(await languages(language).slash_commands.ping.name); + +// existent, should use en_pr +console.log(await languages(language).standard.textEvents.messageDeleted); + +// non existent in either selected language or fallback language +try { + await languages(language).doesNotExist.abc; +} catch (error) { + console.error(error); +} \ No newline at end of file diff --git a/get.js b/get.js index a7a1d7b..a1538ea 100644 --- a/get.js +++ b/get.js @@ -47,11 +47,6 @@ const languageProxy = (language) => { ); }; -export default new Proxy( - {}, - { - get(target, prop) { - return languageProxy(prop); - }, - } -); +export default function (lang) { + return languageProxy(lang); +}