Skip to content

Commit

Permalink
change format and add additional examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Starman3787 committed Sep 16, 2024
1 parent ea10059 commit fffb85f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
13 changes: 12 additions & 1 deletion example.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,15 @@ import languages from "./get.js";

const language = "en_pr";

console.log(await languages[language].slash_commands.ping.name);
// 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);
}
11 changes: 3 additions & 8 deletions get.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ const languageProxy = (language) => {
);
};

export default new Proxy(
{},
{
get(target, prop) {
return languageProxy(prop);
},
}
);
export default function (lang) {
return languageProxy(lang);
}

0 comments on commit fffb85f

Please sign in to comment.