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); +}