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
| Parameter | Type | Required | Description |
|---|---|---|---|
| client | Client | ✅ | The Discord client. |
| guildId | string | ✅ | The guild ID of the role setup. |
| options | LevelAddOptions | ✅ | 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| guildId | string | ✅ | The guild ID of the role setup. |
| level | number | ✅ | 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| client | Client | ✅ | The Discord client. |
| guildId | string | ✅ | 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| client | Client | ✅ | The Discord client. |
| guildId | string | ✅ | The guild ID of the role setup. |
| options | LevelRemoveOptions | ✅ | 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
| Options | Type | Required | Description |
|---|---|---|---|
| level | number | ✅ | Level to add the role to. |
| role | Role ID | ✅ | ID of the role to add. |
LevelRemoveOptions
| Options | Type | Required | Description |
|---|---|---|---|
| level | number | ✅ | Level to remove the roles from. |