On this page
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
Section titled “Methods”LevelRoles.add()
Section titled “LevelRoles.add()”Adds roles to a level. If the level already exists the provided roles are merged (duplicates removed).
Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
| guildId | string | ✅ | The guild ID. |
| options | LevelRole | ✅ | The level and roles to add. |
Returns
Section titled “Returns”- Promise<
boolean> -trueif the operation succeeded.
Throws
Section titled “Throws”XpFatal- If invalid parameters are provided.
LevelRoles.delete()
Section titled “LevelRoles.delete()”Deletes some or all roles from a level. When options.roles is omitted all roles for the level are removed.
Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
| guildId | string | ✅ | The guild ID. |
| options | LevelRole | ✅ | The level and roles to remove. |
Returns
Section titled “Returns”- Promise<
boolean> -trueif the operation succeeded.
LevelRoles.deleteAll()
Section titled “LevelRoles.deleteAll()”Deletes all level-role entries for a guild.
Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
| guildId | string | ✅ | The guild ID. |
Returns
Section titled “Returns”- Promise<
boolean> -trueif the operation succeeded.
LevelRoles.getGuildRoles()
Section titled “LevelRoles.getGuildRoles()”Fetches all level-role entries for a guild.
Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
| guildId | string | ✅ | The guild ID. |
Returns
Section titled “Returns”- Promise<
LevelRoleResult[]> - Array of level-role objects.
LevelRoles.getUserRoles()
Section titled “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
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | The user ID. |
| guildId | string | ✅ | The guild ID. |
| options | GetRolesOptions | ❌ | Options to include next/prev. |
Returns
Section titled “Returns”- Promise<
string[]> - Array of role IDs (or empty array).
LevelRoles.set()
Section titled “LevelRoles.set()”Sets (overwrites) the roles for a specific level.
Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
| guildId | string | ✅ | The guild ID. |
| options | LevelRole | ✅ | The level and roles to set. |
Returns
Section titled “Returns”- Promise<
boolean> -trueif the operation succeeded.