# /roles

{% hint style="info" %}
This endpoint supports the [Exclude](https://dadocs.rickyjs.xyz/exclude-header) header
{% endhint %}

### Endpoint Headers:

* bot-token - Token of the Bot <mark style="color:orange;">**\[String]**</mark> (<mark style="color:red;">**Required**</mark>)&#x20;
* apikey - Your Api Auth Key <mark style="color:orange;">**\[String]**</mark> (<mark style="color:red;">**Required**</mark>)
* guild-id - ID of the guild to be fetched <mark style="color:orange;">**\[Snowflake]**</mark> (<mark style="color:red;">**Required**</mark>)&#x20;
* role - ID of the role to be fetched <mark style="color:orange;">**\[Snowflake]**</mark> (<mark style="color:green;">**Optional**</mark>)&#x20;

### Endpoint URL Parameters

* simple - Retrieves a simpler set of data <mark style="color:orange;">**\[Boolean]**</mark> (<mark style="color:green;">**Optional**</mark>)

{% hint style="warning" %}
If no `role` was specified, it will grab all data and retrieve an **Array**, otherwise it will grab the one specified and retrieve an **Object**.&#x20;

<mark style="color:red;background-color:yellow;">**This will affect how to grab your data!**</mark>
{% endhint %}

### Examples:

{% hint style="info" %}
Data API version required. Must replace `<version>` with either **release** or **beta**.
{% endhint %}

<details>

<summary>Bot Designer for Discord</summary>

Example usage of `/guild/roles` endpoint using BDFD

```bash
$httpAddHeader[apikey;<YOUR-API-KEY>]
$httpAddHeader[bot-token;<YOUR-BOT-TOKEN>]
$httpAddHeader[guild-id;1064098700307218463] 
$httpAddHeader[role;1064098700307218463] $c[Optional Header]
$httpGet[https://bdfddata.rickyjs.xyz/<version>/guild/roles]


$httpResult OR $httpResult[details]
```

OR

```bash
$httpAddHeader[apikey;<YOUR-API-KEY>]
$httpAddHeader[bot-token;<YOUR-BOT-TOKEN>]
$httpAddHeader[guild-id;1064098700307218463] 
$c[Header 'role' cannot be used when simple = true!]
$httpGet[https://bdfddata.rickyjs.xyz/<version>/guild/roles?simple=true]


$httpResult OR $httpResult[details]
```

</details>

<details>

<summary>Discord.js</summary>

Example usage of `/guild/roles` endpoint using Discord.js

```javascript
const axios = require('axios');
(async () => {
return await axios.get('https://bdfddata.rickyjs.xyz/<version>/guild/roles', {
headers: {
"apikey": "<YOUR-API-KEY>",
"bot-token": "<YOUR-BOT-TOKEN>",
"guild-id": "1064098700307218463",
"role": "1076739010849947748" // Optional header
}
}).then(res=>res.data)
})()
```

OR

```javascript
const axios = require('axios');
(async () => {
return await axios.get('https://bdfddata.rickyjs.xyz/<version>/guild/roles?simple=true', {
headers: {
"apikey": "<YOUR-API-KEY>",
"bot-token": "<YOUR-BOT-TOKEN>",
"guild-id": "1064098700307218463"
}
}).then(res=>res.data)
})()
```

</details>

### Possible Responses (Codes)

<details>

<summary>Code 200 (Simple Not Used)</summary>

API succeeded and details were fetched.

```javascript
{
  status: 200,
  details: [
    {
      id: '1064101750463799326',
      name: 'Founders',
      description: null,
      permissions: [],
      position: 5,
      color: 3066993,
      hoist: true,
      managed: false,
      mentionable: false,
      icon: null,
      unicode_emoji: null,
      flags: 0
    }
  ]
}
```

</details>

<details>

<summary>Code 200 (Simple Used)</summary>

API succeeded and details were fetched.

```javascript
{
status: 200,
 "details": {
    "roles": { // returns role name and ids (This example is from the support server)
      "@everyone": "1064098700307218463",
      "*": "1064099060702781461",
      "MasterBot": "1064101589729693740",
      "Founders": "1064101750463799326",
      "iVerified": "1064410587293028413",
      "Ugly cousin": "1064443842222366805",
      "Bots": "1064443871595077705",
      "Ping.Updates()": "1065288502637510676",
      "Ping.Announcements()": "1065288515539177512",
      "Ping.Polls()": "1065288607352488017",
      "Status Notifier": "1066204188285091852",
      "AltDentifier": "1070747620831658096",
      "Top.gg": "1072809281646235703",
      "Support": "1076416601034862612",
      "Moderator": "1076417228603408475",
      "Staff": "1077976311240331344",
      "Server Booster": "1108799499104698418",
      "PassMan": "1135308478970331240",
      "PassMan BETA": "1153519405372817451"
    },
    "count": 19 // number of roles in the server
  }
```

</details>

<details>

<summary>Code 400</summary>

An error occurred that stopped execution.

```javascript
{
    status: 400
    error: 'Cannot read ...  (This can vary)'
}
```

</details>

<details>

<summary>Code 401</summary>

Invalid bot token was provided.

```javascript
{
  status: 401,
  details: { message: '401: Unauthorized', code: 0 }
}
```

</details>

<details>

<summary>Code 404</summary>

Guild was not found via DAPI

```javascript
{
  status: 404,
  details: { message: 'Unknown Guild', code: 10004 } (this can vary)
}
```

</details>
