File tree Expand file tree Collapse file tree 5 files changed +52
-0
lines changed Expand file tree Collapse file tree 5 files changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ exports.MessageFlagsBitField = require('./util/MessageFlagsBitField');
36
36
exports . Options = require ( './util/Options' ) ;
37
37
exports . Partials = require ( './util/Partials' ) ;
38
38
exports . PermissionsBitField = require ( './util/PermissionsBitField' ) ;
39
+ exports . RoleFlagsBitField = require ( './util/RoleFlagsBitField' ) ;
39
40
exports . ShardEvents = require ( './util/ShardEvents' ) ;
40
41
exports . Status = require ( './util/Status' ) ;
41
42
exports . SnowflakeUtil = require ( '@sapphire/snowflake' ) . DiscordSnowflake ;
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ const { PermissionFlagsBits } = require('discord-api-types/v10');
5
5
const Base = require ( './Base' ) ;
6
6
const { DiscordjsError, ErrorCodes } = require ( '../errors' ) ;
7
7
const PermissionsBitField = require ( '../util/PermissionsBitField' ) ;
8
+ const RoleFlagsBitField = require ( '../util/RoleFlagsBitField' ) ;
8
9
9
10
/**
10
11
* Represents a role on Discord.
@@ -101,6 +102,16 @@ class Role extends Base {
101
102
102
103
if ( 'unicode_emoji' in data ) this . unicodeEmoji = data . unicode_emoji ;
103
104
105
+ if ( 'flags' in data ) {
106
+ /**
107
+ * The flags of this role
108
+ * @type {Readonly<RoleFlagsBitField> }
109
+ */
110
+ this . flags = new RoleFlagsBitField ( data . flags ) . freeze ( ) ;
111
+ } else {
112
+ this . flags ??= new RoleFlagsBitField ( ) . freeze ( ) ;
113
+ }
114
+
104
115
/**
105
116
* The tags this role has
106
117
* @type {?Object }
Original file line number Diff line number Diff line change 410
410
* @see {@link https://discord-api-types.dev/api/discord-api-types-payloads/common#PermissionFlagsBits }
411
411
*/
412
412
413
+ /**
414
+ * @external RoleFlags
415
+ * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/RoleFlags }
416
+ */
417
+
413
418
/**
414
419
* @external RESTGetAPIGuildThreadsResult
415
420
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10#RESTGetAPIGuildThreadsResult }
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const { RoleFlags } = require ( 'discord-api-types/v10' ) ;
4
+ const BitField = require ( './BitField' ) ;
5
+
6
+ /**
7
+ * Data structure that makes it easy to interact with a {@link Role#flags} bitfield.
8
+ * @extends {BitField }
9
+ */
10
+ class RoleFlagsBitField extends BitField {
11
+ /**
12
+ * Numeric role flags.
13
+ * @type {RoleFlags }
14
+ * @memberof RoleFlagsBitField
15
+ */
16
+ static Flags = RoleFlags ;
17
+ }
18
+
19
+ /**
20
+ * @name RoleFlagsBitField
21
+ * @kind constructor
22
+ * @memberof RoleFlagsBitField
23
+ * @param {BitFieldResolvable } [bits=0] Bit(s) to read from
24
+ */
25
+
26
+ module . exports = RoleFlagsBitField ;
Original file line number Diff line number Diff line change @@ -167,6 +167,7 @@ import {
167
167
APIGuildOnboardingPromptOption ,
168
168
GuildOnboardingPromptType ,
169
169
AttachmentFlags ,
170
+ RoleFlags ,
170
171
} from 'discord-api-types/v10' ;
171
172
import { ChildProcess } from 'node:child_process' ;
172
173
import { EventEmitter } from 'node:events' ;
@@ -2524,6 +2525,7 @@ export class Role extends Base {
2524
2525
public get createdAt ( ) : Date ;
2525
2526
public get createdTimestamp ( ) : number ;
2526
2527
public get editable ( ) : boolean ;
2528
+ public flags : RoleFlagsBitField ;
2527
2529
public guild : Guild ;
2528
2530
public get hexColor ( ) : HexColorString ;
2529
2531
public hoist : boolean ;
@@ -2559,6 +2561,13 @@ export class Role extends Base {
2559
2561
public toString ( ) : RoleMention ;
2560
2562
}
2561
2563
2564
+ export type RoleFlagsString = keyof typeof RoleFlags ;
2565
+
2566
+ export class RoleFlagsBitField extends BitField < RoleFlagsString > {
2567
+ public static Flags : typeof RoleFlags ;
2568
+ public static resolve ( bit ?: BitFieldResolvable < RoleFlagsString , number > ) : number ;
2569
+ }
2570
+
2562
2571
export class StringSelectMenuInteraction <
2563
2572
Cached extends CacheType = CacheType ,
2564
2573
> extends MessageComponentInteraction < Cached > {
You can’t perform that action at this time.
0 commit comments