# Rank

### Classes

[Rank](#Rank)

### Functions

[setAvatar(avatarUrl, AvatarDecorationData, squareAvatar)](#setAvatar) ⇒ [`Rank`](#Rank)

Set the user avatar

[setBanner(bannerUrl, moreBackgroundBlur, disableBackgroundBlur, backgroundBrightness)](#setBanner) ⇒ [`Rank`](#Rank)

Set the user banner

[setBadges(flags, bot, frame, customBadges)](#setBadges) ⇒ [`Rank`](#Rank)

Set the user badges and frame

[setBorder(color, allign)](#setBorder) ⇒ [`Rank`](#Rank)

Set the border of the card

[setUsername(name, \[discriminator\], \[color\], \[customUsername\], \[customTag\])](#setUsername) ⇒ [`Rank`](#Rank)

Set the username of the user

[setCurrentXP(data, \[color\])](#setCurrentXP) ⇒ [`Rank`](#Rank)

Set the current experience

[setRequiredXP(data, \[color\])](#setRequiredXP) ⇒ [`Rank`](#Rank)

Set the required experience

[setRank(data, \[text\], \[display\])](#setRank) ⇒ [`Rank`](#Rank)

Set the user rank

[setLevel(data, \[text\])](#setLevel) ⇒ [`Rank`](#Rank)

Establece el nivel del usuario

[setProgressBar(color, \[fillType\], \[rounded\])](#setProgressBar) ⇒ [`Rank`](#Rank)

Set the progress bar

[setStatus(presenceStatus)](#setStatus) ⇒ [`Rank`](#Rank)

Set the user presence status

[setCreatedTimestamp(timestamp, customDate)](#setCreatedTimestamp) ⇒ [`Rank`](#Rank)

Set the user created timestamp

[build(\[font\])](#build) ⇒ `Promise.<Buffer>`

Build the rank card

### Rank

**Kind**: global class<br>

#### new Rank(userId)

Rank card creator

<details>

<summary>PREVIEW</summary>

\
![Rank Card Preview 1](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/rank_1.png) ![Rank Card Preview 2](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/rank_2.png) ![Rank Card Preview 3](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/rank_3.png)

</details>

| Param  | Type     | Description |
| ------ | -------- | ----------- |
| userId | `string` | User ID     |

**Example**

```js
const rank = new canvacard.Rank(data.id)
  .setAvatar(data.avatarURL, data.avatar_decoration_data.asset)
  .setBanner(data.bannerURL, true)
  .setBadges(data.flags, data.bot, true)
  .setBorder(["#22274a", "#001eff"], "vertical")
  .setCurrentXP(userData.xp)
  .setRequiredXP(userData.requiredXP)
  .setRank(1, "RANK", true)
  .setLevel(20, "LEVEL", true)
  .setStatus("online")
  .setProgressBar(["#14C49E", "#FF0000"], "GRADIENT", true)
  .setUsername(data.global_name, data.discriminator)
  .setCreatedTimestamp(data.createdTimestamp);

const rankImage = await rank.build("Cascadia Code PL");
canvacard.write(rankImage, "./rank.png");
```

### setAvatar(avatarUrl, AvatarDecorationData, squareAvatar) ⇒ [`Rank`](#Rank)

Set the user avatar

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param                | Type      | Description             |
| -------------------- | --------- | ----------------------- |
| avatarUrl            | `string`  | Avatar URL              |
| AvatarDecorationData | `string`  | Avatar decoration asset |
| squareAvatar         | `boolean` | Square avatar           |

### setBanner(bannerUrl, moreBackgroundBlur, disableBackgroundBlur, backgroundBrightness) ⇒ [`Rank`](#Rank)

Set the user banner

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param                 | Type      | Description             |
| --------------------- | --------- | ----------------------- |
| bannerUrl             | `string`  | Banner URL              |
| moreBackgroundBlur    | `boolean` | More background blur    |
| disableBackgroundBlur | `boolean` | Disable background blur |
| backgroundBrightness  | `number`  | Background brightness   |

### setBadges(flags, bot, frame, customBadges) ⇒ [`Rank`](#Rank)

Set the user badges and frame

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param        | Type             | Description                      |
| ------------ | ---------------- | -------------------------------- |
| flags        | `number`         | User flags                       |
| bot          | `boolean`        | Whether the user is a bot or not |
| frame        | `boolean`        | Badge frame                      |
| customBadges | `Array.<string>` | Custom badges                    |

### setBorder(color, allign) ⇒ [`Rank`](#Rank)

Set the border of the card

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param  | Type                         | Description                                                   |
| ------ | ---------------------------- | ------------------------------------------------------------- |
| color  | `string` \| `Array.<string>` | HEX color of the border, can be gradient if 2 colors are used |
| allign | `string`                     | Gradient alignment if 2 colors are used                       |

### setUsername(name, \[discriminator], \[color], \[customUsername], \[customTag]) ⇒ [`Rank`](#Rank)

Set the username of the user

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param             | Type     | Default                 | Description               |
| ----------------- | -------- | ----------------------- | ------------------------- |
| name              | `string` |                         | Username of the user      |
| \[discriminator]  | `string` | `"&quot;0&quot;"`       | Discriminator of the user |
| \[color]          | `string` | `"&quot;#FFFFFF&quot;"` | Color of the username     |
| \[customUsername] | `string` | `null`                  | Custom username           |
| \[customTag]      | `string` | `null`                  | Custom tag                |

### setCurrentXP(data, \[color]) ⇒ [`Rank`](#Rank)

Set the current experience

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param    | Type     | Default                 | Description             |
| -------- | -------- | ----------------------- | ----------------------- |
| data     | `number` |                         | Current experience data |
| \[color] | `string` | `"&quot;#FFFFFF&quot;"` | Text color              |

### setRequiredXP(data, \[color]) ⇒ [`Rank`](#Rank)

Set the required experience

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param    | Type     | Default                 | Description              |
| -------- | -------- | ----------------------- | ------------------------ |
| data     | `number` |                         | Required experience data |
| \[color] | `string` | `"&quot;#FFFFFF&quot;"` | Text color               |

### setRank(data, \[text], \[display]) ⇒ [`Rank`](#Rank)

Set the user rank

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param      | Type      | Default              | Description                |
| ---------- | --------- | -------------------- | -------------------------- |
| data       | `number`  |                      | Rank data                  |
| \[text]    | `string`  | `"&quot;RANK&quot;"` | Display text               |
| \[display] | `boolean` | `false`              | Display system rank or not |

### setLevel(data, \[text]) ⇒ [`Rank`](#Rank)

Establece el nivel del usuario

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param   | Type     | Default               | Description  |
| ------- | -------- | --------------------- | ------------ |
| data    | `number` |                       | Level data   |
| \[text] | `string` | `"&quot;LEVEL&quot;"` | Display text |

### setProgressBar(color, \[fillType], \[rounded]) ⇒ [`Rank`](#Rank)

Set the progress bar

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param       | Type                         | Default               | Description                                                     |
| ----------- | ---------------------------- | --------------------- | --------------------------------------------------------------- |
| color       | `string` \| `Array.<string>` |                       | Color of the progress bar, can be gradient if 2 colors are used |
| \[fillType] | `string`                     | `"&quot;COLOR&quot;"` | Type of progress bar                                            |
| \[rounded]  | `boolean`                    | `true`                | Rounded corners of the progress bar                             |

### setStatus(presenceStatus) ⇒ [`Rank`](#Rank)

Set the user presence status

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param          | Type     | Description     |
| -------------- | -------- | --------------- |
| presenceStatus | `string` | Presence status |

### setCreatedTimestamp(timestamp, customDate) ⇒ [`Rank`](#Rank)

Set the user created timestamp

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param      | Type               | Description                               |
| ---------- | ------------------ | ----------------------------------------- |
| timestamp  | `number`           | Timestamp of when the user joined Discord |
| customDate | `string` \| `Date` | Custom date format for the timestamp      |

### build(\[font]) ⇒ `Promise.<Buffer>`

Build the rank card

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Card image in buffer format\
**Throws**:

* `APIError` Missing field: data

| Param   | Type     | Default               | Description             |
| ------- | -------- | --------------------- | ----------------------- |
| \[font] | `string` | `"&quot;Arial&quot;"` | Font to use in the card |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://canvacard.srgobi.com/classes/rank.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
