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β
| Parameter | Type | Required | Description |
|---|---|---|---|
| guildId | string | β | The guild ID. |
| options | LevelRole | β | The level and roles to add. |
Returnsβ
- Promise<
boolean> -trueif 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β
| Parameter | Type | Required | Description |
|---|---|---|---|
| guildId | string | β | The guild ID. |
| options | LevelRole | β | The level and roles to remove. |
Returnsβ
- Promise<
boolean> -trueif the operation succeeded.
LevelRoles.deleteAll()β
Deletes all level-role entries for a guild.
Parametersβ
| Parameter | Type | Required | Description |
|---|---|---|---|
| guildId | string | β | The guild ID. |
Returnsβ
- Promise<
boolean> -trueif the operation succeeded.
LevelRoles.getGuildRoles()β
Fetches all level-role entries for a guild.
Parametersβ
| Parameter | Type | Required | Description |
|---|---|---|---|
| guildId | string | β | The guild ID. |
Returnsβ
- Promise<
LevelRoleResult[]> - Array of level-role objects.
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β
| Parameter | Type | Required | Description |
|---|---|---|---|
| userId | string | β | The user ID. |
| guildId | string | β | The guild ID. |
| options | GetRolesOptions | β | 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β
| Parameter | Type | Required | Description |
|---|---|---|---|
| guildId | string | β | The guild ID. |
| options | LevelRole | β | The level and roles to set. |
Returnsβ
- Promise<
boolean> -trueif the operation succeeded.