Skip to main content
Version: v1

roleSetup

This class provides methods to interact with the database. Used for performing operations like creating, updating, deleting, and querying documents.

info

V2 added Role Arrays.

Because of this, we recommend handling both arrays and string for find and fetch methods, especially if you have used V2 before.

Methods​

roleSetup.add()​

Adds a role to the role setup.

Parameters​

ParameterTypeRequiredDescription
clientClientβœ…The Discord client.
guildIdstringβœ…The guild ID of the role setup.
optionsLevelAddOptionsβœ…The options for the role setup.

Returns​

  • Promise<boolean> - If the role was added successfully.

Throws​

  • new Error() - If an invalid type or value is provided.

roleSetup.find()​

Finds a role in the role setup.

Parameters​

ParameterTypeRequiredDescription
guildIdstringβœ…The guild ID of the role setup.
levelnumberβœ…The level number of the role setup.

Returns​

  • Promise<{ lvl: number, role: string || string[] }> - The role setup object.

Throws​

  • new Error() - If an invalid type or value is provided.

roleSetup.fetch()​

Lists all level roles in a guild.

Parameters​

ParameterTypeRequiredDescription
clientClientβœ…The Discord client.
guildIdstringβœ…The guild ID of the role setup.

Returns​

  • Promise<Array<{ lvl: number, role: string || string[] }>> - The role setup object.

Throws​

  • XpFatal - If there are no level roles in the guild.

roleSetup.remove()​

Removes a role from the role setup.

Parameters​

ParameterTypeRequiredDescription
clientClientβœ…The Discord client.
guildIdstringβœ…The guild ID of the role setup.
optionsLevelRemoveOptionsβœ…The options for the role setup.

Returns​

  • Promise<boolean> - If the role was removed successfully.

Throws​

  • new Error() - If an invalid type or value is provided.

LevelAddOptions​

OptionsTypeRequiredDescription
levelnumberβœ…Level to add the role to.
roleRole IDβœ…ID of the role to add.

LevelRemoveOptions​

OptionsTypeRequiredDescription
levelnumberβœ…Level to remove the roles from.