1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
use bitflags::bitflags;
use serde::{Deserialize, Serialize};
/**
* Types extracted from https://discord.com/developers/docs/topics/permissions
*/
/**
* @see {@link https://discord.com/developers/docs/topics/permissions#role-object}
*/
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIRole {
/**
* Role id
*/
pub id: String,
/**
* Role name
*/
pub name: String,
/**
* Integer representation of hexadecimal color code
*
* @remarks `color` will still be returned by the API, but using the `colors` field is recommended when doing requests.
*/
pub color: u32,
/**
* The role's colors
*/
pub colors: Option<APIRoleColors>,
/**
* If this role is pinned in the user listing
*/
pub hoist: bool,
/**
* The role icon hash
*/
pub icon: Option<String>,
/**
* The role unicode emoji as a standard emoji
*/
pub unicode_emoji: Option<String>,
/**
* Position of this role
*/
pub position: i32,
/**
* Permission bit set
*
* @see {@link https://en.wikipedia.org/wiki/Bit_field}
*/
pub permissions: String,
/**
* Whether this role is managed by an integration
*/
pub managed: bool,
/**
* Whether this role is mentionable
*/
pub mentionable: bool,
/**
* The tags this role has
*/
pub tags: Option<APIRoleTags>,
/**
* Role flags
*/
pub flags: RoleFlags,
}
/**
* @see {@link https://discord.com/developers/docs/topics/permissions#role-object-role-tags-structure}
*/
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIRoleTags {
/**
* The id of the bot this role belongs to
*/
pub bot_id: Option<String>,
/**
* Whether this is the guild's premium subscriber role
*/
pub premium_subscriber: Option<()>,
/**
* The id of the integration this role belongs to
*/
pub integration_id: Option<String>,
/**
* The id of this role's subscription sku and listing
*/
pub subscription_listing_id: Option<String>,
/**
* Whether this role is available for purchase
*/
pub available_for_purchase: Option<()>,
/**
* Whether this role is a guild's linked role
*/
pub guild_connections: Option<()>,
}
bitflags! {
/**
* @see {@link https://discord.com/developers/docs/topics/permissions#role-object-role-flags}
*/
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(transparent)]
pub struct RoleFlags: u32 {
/**
* Role can be selected by members in an onboarding prompt
*/
const InPrompt = 1 << 0;
}
}
/**
* @see {@link https://discord.com/developers/docs/topics/permissions#role-colors-object}
*/
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIRoleColors {
/**
* The primary color for the role
*/
pub primary_color: u32,
/**
* The secondary color for the role, this will make the role a gradient between the other provided colors
*/
pub secondary_color: Option<u32>,
/**
* The tertiary color for the role, this will turn the gradient into a holographic style
*
* @remarks When sending `tertiary_color` the API enforces the role color to be a holographic style with values of `primary_color = 11127295`, `secondary_color = 16759788`, and `tertiary_color = 16761760`.
*/
pub tertiary_color: Option<u32>,
}