Skip to main content

LevelRoles

This class manages level-based role setups. It supports adding, removing, listing and querying level roles and works with both MongoDB and SQLite backends via the shared db API.

Methods​

LevelRoles.add()​

Adds roles to a level. If the level already exists the provided roles are merged (duplicates removed).

Parameters​

ParameterTypeRequiredDescription
guildIdstringβœ…The guild ID.
optionsLevelRoleβœ…The level and roles to add.

Returns​

  • Promise<boolean> - true if the operation succeeded.

Throws​

  • XpFatal - If invalid parameters are provided.

LevelRoles.delete()​

Deletes some or all roles from a level. When options.roles is omitted all roles for the level are removed.

Parameters​

ParameterTypeRequiredDescription
guildIdstringβœ…The guild ID.
optionsLevelRoleβœ…The level and roles to remove.

Returns​

  • Promise<boolean> - true if the operation succeeded.

LevelRoles.deleteAll()​

Deletes all level-role entries for a guild.

Parameters​

ParameterTypeRequiredDescription
guildIdstringβœ…The guild ID.

Returns​

  • Promise<boolean> - true if the operation succeeded.

LevelRoles.getGuildRoles()​

Fetches all level-role entries for a guild.

Parameters​

ParameterTypeRequiredDescription
guildIdstringβœ…The guild ID.

Returns​


LevelRoles.getUserRoles()​

Returns role IDs applicable to a user's level. Options control whether roles for the current, next or previous levels are included. By default only the current level is included.

Parameters​

ParameterTypeRequiredDescription
userIdstringβœ…The user ID.
guildIdstringβœ…The guild ID.
optionsGetRolesOptions❌Options to include next/prev.

Returns​

  • Promise<string[]> - Array of role IDs (or empty array).

LevelRoles.set()​

Sets (overwrites) the roles for a specific level.

Parameters​

ParameterTypeRequiredDescription
guildIdstringβœ…The guild ID.
optionsLevelRoleβœ…The level and roles to set.

Returns​

  • Promise<boolean> - true if the operation succeeded.