Skip to content

Latest commit

 

History

History
30 lines (18 loc) · 1.8 KB

miscellaneous.md

File metadata and controls

30 lines (18 loc) · 1.8 KB

Miscellaneous

There are many useful functions that can be used in many places to avoid duplicating code, you can see a list here :

Errors

Arguments

  • getThing : Get easily arguments of a given type.

JSON Utilities

  • saveJSON : Saves a JSON safely, returning a boolean meaning if it worked.
  • readJSON : Reads a JSON, prefer using import or require.

Permissions

  • isOwner : Returns true if the given ID is included in the owners set in CommandHandler.create.
  • isPermission : Returns true if the given string is a valid permission. It's also a type guard for PermissionString type for TypeScript users.

Other

  • cutIfTooLong : Cut a text at a given length (if too long).
  • getKeyByValue : Get a key from a value in an object.
  • random : Returns a random value from an array.