Constructor
new User(manager, provider, data)
The data used to instantiate this user.
Parameters:
| Name | Type | Description |
|---|---|---|
manager |
XpManager | The manager used to instantiate this class. |
provider |
Provider | The provider used to instantiate this class. |
data |
object | The database entry data for this user. |
- Source:
Members
dynamicNextLevelXp
The amount of xp that user needs to earn from last level up to the next level up.
- Source:
dynamicXp
The amount of xp earned since the last level up.
- Source:
guildID :string
User's guild id.
Type:
- string
- Source:
id :string
User's discord id.
Type:
- string
- Source:
lastUpdatedAt :Date
Last updated at.
Type:
- Date
- Source:
lastUpdatedTimestamp :number
Last updated timestamp.
Type:
- number
- Source:
level
- Source:
manager :XpManager
The xp manager used to instantiate this.
Type:
- Source:
nextLevelXp
- Source:
Example
console.log(user.nextLevelXp); // 400
provider :Provider
The provider whose data was used to instantiate this user.
Type:
- Source:
rank :number
The user's rank in the leaderboard.
Type:
- number
- Source:
xp :number
User's xp.
Type:
- number
- Source:
Methods
(async) appendLevel(xp) → {Promise.<object>}
Increases the user's xp by a certain amount.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
xp |
number | 1 | The amount of xp to add to the user. |
- Source:
Returns:
An object containing oldLevel and newLevel properties.
- Type
- Promise.<object>
(async) appendXp(xp) → {Promise.<object>}
Increases the user's xp by a certain amount.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
xp |
number | 1 | The amount of xp to add to the user. |
- Source:
Returns:
An object containing oldLevel and newLevel properties.
- Type
- Promise.<object>
(async) fetchRank() → {Promise.<number>}
Fetches the rank of this user.
- Source:
Returns:
The rank of this user.
- Type
- Promise.<number>
(async) refetch() → {Promise.<void>}
Refetches the properties of the user.
- Source:
Returns:
It returns nothing.
- Type
- Promise.<void>
(async) setLevel(level) → {Promise.<object>}
Sets user's level to a specified number.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
level |
number | 0 | The level to set the user. |
- Source:
Returns:
An object containing oldXp and newXp properties.
- Type
- Promise.<object>
(async) setXp(xp) → {Promise.<object>}
Sets the user xp to a specified number.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
xp |
number | 0 | The amount of xp to set. |
- Source:
Returns:
An object containing oldLevel and newLevel properties.
- Type
- Promise.<object>