@velliajs/discord 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/client/BaseClient.js +7 -28
- package/src/client/Client.js +116 -283
- package/src/client/WebhookClient.js +17 -59
- package/src/client/actions/Action.js +0 -10
- package/src/client/actions/ActionsManager.js +3 -3
- package/src/client/actions/ApplicationCommandPermissionsUpdate.js +2 -15
- package/src/client/actions/AutoModerationActionExecution.js +1 -6
- package/src/client/actions/AutoModerationRuleCreate.js +1 -6
- package/src/client/actions/AutoModerationRuleDelete.js +1 -6
- package/src/client/actions/AutoModerationRuleUpdate.js +1 -7
- package/src/client/actions/ChannelCreate.js +1 -5
- package/src/client/actions/ChannelDelete.js +1 -5
- package/src/client/actions/GuildAuditLogEntryCreate.js +1 -6
- package/src/client/actions/GuildBanAdd.js +1 -5
- package/src/client/actions/GuildBanRemove.js +1 -5
- package/src/client/actions/GuildDelete.js +6 -14
- package/src/client/actions/GuildEmojiCreate.js +1 -5
- package/src/client/actions/GuildEmojiDelete.js +1 -5
- package/src/client/actions/GuildEmojiUpdate.js +1 -6
- package/src/client/actions/GuildEmojisUpdate.js +4 -4
- package/src/client/actions/GuildIntegrationsUpdate.js +1 -5
- package/src/client/actions/GuildMemberRemove.js +1 -5
- package/src/client/actions/GuildMemberUpdate.js +2 -11
- package/src/client/actions/GuildRoleCreate.js +1 -5
- package/src/client/actions/GuildRoleDelete.js +1 -5
- package/src/client/actions/GuildRoleUpdate.js +1 -6
- package/src/client/actions/GuildScheduledEventCreate.js +1 -5
- package/src/client/actions/GuildScheduledEventDelete.js +1 -5
- package/src/client/actions/GuildScheduledEventUpdate.js +1 -6
- package/src/client/actions/GuildScheduledEventUserAdd.js +1 -6
- package/src/client/actions/GuildScheduledEventUserRemove.js +1 -6
- package/src/client/actions/GuildStickerCreate.js +1 -5
- package/src/client/actions/GuildStickerDelete.js +1 -5
- package/src/client/actions/GuildStickerUpdate.js +1 -6
- package/src/client/actions/GuildStickersUpdate.js +4 -4
- package/src/client/actions/GuildUpdate.js +1 -6
- package/src/client/actions/InteractionCreate.js +3 -7
- package/src/client/actions/InviteCreate.js +1 -7
- package/src/client/actions/InviteDelete.js +1 -7
- package/src/client/actions/MessageCreate.js +1 -5
- package/src/client/actions/MessageDelete.js +1 -5
- package/src/client/actions/MessageDeleteBulk.js +1 -6
- package/src/client/actions/MessageReactionAdd.js +5 -18
- package/src/client/actions/MessageReactionRemove.js +5 -16
- package/src/client/actions/MessageReactionRemoveAll.js +4 -9
- package/src/client/actions/MessageReactionRemoveEmoji.js +1 -5
- package/src/client/actions/PresenceUpdate.js +1 -6
- package/src/client/actions/StageInstanceCreate.js +1 -5
- package/src/client/actions/StageInstanceDelete.js +1 -5
- package/src/client/actions/StageInstanceUpdate.js +1 -6
- package/src/client/actions/ThreadCreate.js +1 -6
- package/src/client/actions/ThreadDelete.js +1 -5
- package/src/client/actions/ThreadListSync.js +2 -7
- package/src/client/actions/ThreadMemberUpdate.js +2 -7
- package/src/client/actions/ThreadMembersUpdate.js +2 -9
- package/src/client/actions/TypingStart.js +1 -5
- package/src/client/actions/UserUpdate.js +1 -8
- package/src/client/actions/VoiceStateUpdate.js +4 -9
- package/src/client/actions/WebhooksUpdate.js +1 -6
- package/src/client/voice/ClientVoiceManager.js +3 -13
- package/src/client/websocket/WebSocketManager.js +25 -117
- package/src/client/websocket/WebSocketShard.js +29 -116
- package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js +2 -8
- package/src/client/websocket/handlers/CHANNEL_UPDATE.js +1 -6
- package/src/client/websocket/handlers/GUILD_CREATE.js +3 -7
- package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js +2 -16
- package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +1 -5
- package/src/client/websocket/handlers/MESSAGE_UPDATE.js +1 -6
- package/src/client/websocket/handlers/RESUMED.js +1 -6
- package/src/client/websocket/handlers/THREAD_UPDATE.js +1 -6
- package/src/errors/DJSError.js +3 -14
- package/src/errors/ErrorCodes.js +2 -164
- package/src/index.js +6 -6
- package/src/managers/ApplicationCommandManager.js +14 -130
- package/src/managers/ApplicationCommandPermissionsManager.js +31 -202
- package/src/managers/AutoModerationRuleManager.js +17 -145
- package/src/managers/BaseGuildEmojiManager.js +7 -38
- package/src/managers/BaseManager.js +2 -10
- package/src/managers/CachedManager.js +3 -17
- package/src/managers/CategoryChannelChildManager.js +6 -48
- package/src/managers/ChannelManager.js +11 -52
- package/src/managers/DataManager.js +5 -27
- package/src/managers/GuildApplicationCommandManager.js +3 -12
- package/src/managers/GuildBanManager.js +16 -105
- package/src/managers/GuildChannelManager.js +31 -226
- package/src/managers/GuildEmojiManager.js +9 -65
- package/src/managers/GuildEmojiRoleManager.js +8 -47
- package/src/managers/GuildForumThreadManager.js +5 -39
- package/src/managers/GuildInviteManager.js +18 -117
- package/src/managers/GuildManager.js +14 -115
- package/src/managers/GuildMemberManager.js +38 -256
- package/src/managers/GuildMemberRoleManager.js +13 -76
- package/src/managers/GuildScheduledEventManager.js +25 -128
- package/src/managers/GuildStickerManager.js +16 -96
- package/src/managers/GuildTextThreadManager.js +4 -47
- package/src/managers/MessageManager.js +23 -137
- package/src/managers/PermissionOverwriteManager.js +10 -78
- package/src/managers/PresenceManager.js +6 -27
- package/src/managers/ReactionManager.js +7 -40
- package/src/managers/ReactionUserManager.js +6 -29
- package/src/managers/RoleManager.js +29 -177
- package/src/managers/StageInstanceManager.js +14 -77
- package/src/managers/ThreadManager.js +23 -113
- package/src/managers/ThreadMemberManager.js +20 -89
- package/src/managers/UserManager.js +13 -65
- package/src/managers/VoiceStateManager.js +3 -13
- package/src/sharding/Shard.js +42 -158
- package/src/sharding/ShardClientUtil.js +17 -101
- package/src/sharding/ShardingManager.js +34 -151
- package/src/structures/ActionRow.js +4 -21
- package/src/structures/ActionRowBuilder.js +3 -13
- package/src/structures/AnonymousGuild.js +10 -43
- package/src/structures/ApplicationCommand.js +54 -308
- package/src/structures/ApplicationRoleConnectionMetadata.js +7 -27
- package/src/structures/Attachment.js +16 -65
- package/src/structures/AttachmentBuilder.js +13 -58
- package/src/structures/AutoModerationActionExecution.js +16 -69
- package/src/structures/AutoModerationRule.js +32 -164
- package/src/structures/AutocompleteInteraction.js +10 -52
- package/src/structures/Base.js +2 -10
- package/src/structures/BaseChannel.js +16 -80
- package/src/structures/BaseGuild.js +13 -59
- package/src/structures/BaseGuildEmoji.js +5 -21
- package/src/structures/BaseGuildTextChannel.js +19 -100
- package/src/structures/BaseGuildVoiceChannel.js +21 -110
- package/src/structures/BaseInteraction.js +40 -196
- package/src/structures/BaseSelectMenuComponent.js +6 -29
- package/src/structures/ButtonBuilder.js +4 -18
- package/src/structures/ButtonComponent.js +7 -34
- package/src/structures/ButtonInteraction.js +1 -4
- package/src/structures/CategoryChannel.js +5 -30
- package/src/structures/ChannelSelectMenuBuilder.js +3 -13
- package/src/structures/ChannelSelectMenuComponent.js +2 -9
- package/src/structures/ChannelSelectMenuInteraction.js +3 -12
- package/src/structures/ChatInputCommandInteraction.js +3 -13
- package/src/structures/ClientApplication.js +20 -83
- package/src/structures/ClientPresence.js +5 -20
- package/src/structures/ClientUser.js +21 -118
- package/src/structures/CommandInteraction.js +21 -96
- package/src/structures/CommandInteractionOptionResolver.js +26 -147
- package/src/structures/Component.js +5 -21
- package/src/structures/ContextMenuCommandInteraction.js +4 -18
- package/src/structures/DMChannel.js +17 -52
- package/src/structures/DirectoryChannel.js +4 -16
- package/src/structures/Embed.js +21 -107
- package/src/structures/EmbedBuilder.js +4 -18
- package/src/structures/Emoji.js +12 -60
- package/src/structures/ForumChannel.js +30 -140
- package/src/structures/Guild.js +117 -697
- package/src/structures/GuildAuditLogs.js +7 -32
- package/src/structures/GuildAuditLogsEntry.js +27 -135
- package/src/structures/GuildBan.js +6 -26
- package/src/structures/GuildChannel.js +36 -188
- package/src/structures/GuildEmoji.js +13 -67
- package/src/structures/GuildMember.js +47 -270
- package/src/structures/GuildPreview.js +19 -84
- package/src/structures/GuildPreviewEmoji.js +3 -13
- package/src/structures/GuildScheduledEvent.js +46 -250
- package/src/structures/GuildTemplate.js +24 -108
- package/src/structures/Integration.js +25 -103
- package/src/structures/IntegrationApplication.js +8 -32
- package/src/structures/InteractionCollector.js +22 -113
- package/src/structures/InteractionResponse.js +11 -46
- package/src/structures/InteractionWebhook.js +8 -33
- package/src/structures/Invite.js +27 -131
- package/src/structures/InviteGuild.js +2 -8
- package/src/structures/InviteStageInstance.js +9 -39
- package/src/structures/MentionableSelectMenuBuilder.js +3 -14
- package/src/structures/MentionableSelectMenuComponent.js +1 -4
- package/src/structures/MentionableSelectMenuInteraction.js +5 -20
- package/src/structures/Message.js +85 -460
- package/src/structures/MessageCollector.js +14 -70
- package/src/structures/MessageComponentInteraction.js +14 -57
- package/src/structures/MessageContextMenuCommandInteraction.js +2 -9
- package/src/structures/MessageMentions.js +25 -136
- package/src/structures/MessagePayload.js +24 -94
- package/src/structures/MessageReaction.js +13 -51
- package/src/structures/ModalBuilder.js +3 -13
- package/src/structures/ModalSubmitFields.js +5 -22
- package/src/structures/ModalSubmitInteraction.js +17 -61
- package/src/structures/NewsChannel.js +2 -16
- package/src/structures/OAuth2Guild.js +3 -12
- package/src/structures/PartialGroupDMChannel.js +7 -27
- package/src/structures/PermissionOverwrites.js +20 -99
- package/src/structures/Presence.js +45 -190
- package/src/structures/ReactionCollector.js +20 -108
- package/src/structures/ReactionEmoji.js +2 -10
- package/src/structures/Role.js +39 -261
- package/src/structures/RoleSelectMenuBuilder.js +3 -13
- package/src/structures/RoleSelectMenuComponent.js +1 -4
- package/src/structures/RoleSelectMenuInteraction.js +3 -12
- package/src/structures/SelectMenuBuilder.js +1 -4
- package/src/structures/SelectMenuComponent.js +1 -4
- package/src/structures/SelectMenuInteraction.js +1 -4
- package/src/structures/SelectMenuOptionBuilder.js +1 -4
- package/src/structures/StageChannel.js +12 -84
- package/src/structures/StageInstance.js +16 -87
- package/src/structures/Sticker.js +25 -124
- package/src/structures/StickerPack.js +12 -52
- package/src/structures/StringSelectMenuBuilder.js +6 -29
- package/src/structures/StringSelectMenuComponent.js +2 -9
- package/src/structures/StringSelectMenuInteraction.js +2 -8
- package/src/structures/StringSelectMenuOptionBuilder.js +4 -18
- package/src/structures/Team.js +11 -52
- package/src/structures/TeamMember.js +7 -33
- package/src/structures/TextChannel.js +3 -14
- package/src/structures/TextInputBuilder.js +3 -13
- package/src/structures/TextInputComponent.js +3 -14
- package/src/structures/ThreadChannel.js +59 -305
- package/src/structures/ThreadMember.js +12 -55
- package/src/structures/Typing.js +8 -35
- package/src/structures/User.js +29 -151
- package/src/structures/UserContextMenuCommandInteraction.js +3 -14
- package/src/structures/UserSelectMenuBuilder.js +3 -13
- package/src/structures/UserSelectMenuComponent.js +1 -4
- package/src/structures/UserSelectMenuInteraction.js +4 -16
- package/src/structures/VoiceChannel.js +8 -67
- package/src/structures/VoiceRegion.js +6 -23
- package/src/structures/VoiceState.js +28 -140
- package/src/structures/Webhook.js +37 -227
- package/src/structures/WelcomeChannel.js +7 -29
- package/src/structures/WelcomeScreen.js +5 -20
- package/src/structures/Widget.js +9 -40
- package/src/structures/WidgetMember.js +15 -61
- package/src/structures/interfaces/Application.js +10 -49
- package/src/structures/interfaces/Collector.js +34 -155
- package/src/structures/interfaces/InteractionResponses.js +25 -164
- package/src/structures/interfaces/TextBasedChannel.js +37 -232
- package/src/util/APITypes.js +183 -456
- package/src/util/ActivityFlagsBitField.js +3 -15
- package/src/util/ApplicationFlagsBitField.js +3 -15
- package/src/util/BitField.js +17 -82
- package/src/util/ChannelFlagsBitField.js +7 -30
- package/src/util/Channels.js +5 -35
- package/src/util/Colors.js +3 -38
- package/src/util/Components.js +21 -75
- package/src/util/Constants.js +17 -144
- package/src/util/DataResolver.js +20 -77
- package/src/util/Events.js +3 -81
- package/src/util/Formatters.js +58 -305
- package/src/util/GuildMemberFlagsBitField.js +7 -30
- package/src/util/IntentsBitField.js +4 -23
- package/src/util/LimitedCollection.js +4 -21
- package/src/util/MessageFlagsBitField.js +5 -21
- package/src/util/Options.js +24 -137
- package/src/util/Partials.js +3 -30
- package/src/util/PermissionsBitField.js +12 -67
- package/src/util/ShardEvents.js +3 -15
- package/src/util/Status.js +3 -17
- package/src/util/Sweepers.js +35 -184
- package/src/util/SystemChannelFlagsBitField.js +7 -32
- package/src/util/ThreadMemberFlagsBitField.js +5 -21
- package/src/util/Transformers.js +2 -11
- package/src/util/UserFlagsBitField.js +5 -21
- package/src/util/Util.js +30 -169
- package/src/util/WebSocketShardEvents.js +3 -14
package/src/structures/Role.js
CHANGED
|
@@ -6,94 +6,58 @@ const Base = require('./Base');
|
|
|
6
6
|
const { DiscordjsError, ErrorCodes } = require('../errors');
|
|
7
7
|
const PermissionsBitField = require('../util/PermissionsBitField');
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
* Represents a role on Discord.
|
|
11
|
-
* @extends {Base}
|
|
12
|
-
*/
|
|
9
|
+
|
|
13
10
|
class Role extends Base {
|
|
14
11
|
constructor(client, data, guild) {
|
|
15
12
|
super(client);
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
* The guild that the role belongs to
|
|
19
|
-
* @type {Guild}
|
|
20
|
-
*/
|
|
14
|
+
|
|
21
15
|
this.guild = guild;
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
* The icon hash of the role
|
|
25
|
-
* @type {?string}
|
|
26
|
-
*/
|
|
17
|
+
|
|
27
18
|
this.icon = null;
|
|
28
19
|
|
|
29
|
-
|
|
30
|
-
* The unicode emoji for the role
|
|
31
|
-
* @type {?string}
|
|
32
|
-
*/
|
|
20
|
+
|
|
33
21
|
this.unicodeEmoji = null;
|
|
34
22
|
|
|
35
23
|
if (data) this._patch(data);
|
|
36
24
|
}
|
|
37
25
|
|
|
38
26
|
_patch(data) {
|
|
39
|
-
|
|
40
|
-
* The role's id (unique to the guild it is part of)
|
|
41
|
-
* @type {Snowflake}
|
|
42
|
-
*/
|
|
27
|
+
|
|
43
28
|
this.id = data.id;
|
|
44
29
|
if ('name' in data) {
|
|
45
|
-
|
|
46
|
-
* The name of the role
|
|
47
|
-
* @type {string}
|
|
48
|
-
*/
|
|
30
|
+
|
|
49
31
|
this.name = data.name;
|
|
50
32
|
}
|
|
51
33
|
|
|
52
34
|
if ('color' in data) {
|
|
53
|
-
|
|
54
|
-
* The base 10 color of the role
|
|
55
|
-
* @type {number}
|
|
56
|
-
*/
|
|
35
|
+
|
|
57
36
|
this.color = data.color;
|
|
58
37
|
}
|
|
59
38
|
|
|
60
39
|
if ('hoist' in data) {
|
|
61
|
-
|
|
62
|
-
* If true, users that are part of this role will appear in a separate category in the users list
|
|
63
|
-
* @type {boolean}
|
|
64
|
-
*/
|
|
40
|
+
|
|
65
41
|
this.hoist = data.hoist;
|
|
66
42
|
}
|
|
67
43
|
|
|
68
44
|
if ('position' in data) {
|
|
69
|
-
|
|
70
|
-
* The raw position of the role from the API
|
|
71
|
-
* @type {number}
|
|
72
|
-
*/
|
|
45
|
+
|
|
73
46
|
this.rawPosition = data.position;
|
|
74
47
|
}
|
|
75
48
|
|
|
76
49
|
if ('permissions' in data) {
|
|
77
|
-
|
|
78
|
-
* The permissions of the role
|
|
79
|
-
* @type {Readonly<PermissionsBitField>}
|
|
80
|
-
*/
|
|
50
|
+
|
|
81
51
|
this.permissions = new PermissionsBitField(BigInt(data.permissions)).freeze();
|
|
82
52
|
}
|
|
83
53
|
|
|
84
54
|
if ('managed' in data) {
|
|
85
|
-
|
|
86
|
-
* Whether or not the role is managed by an external service
|
|
87
|
-
* @type {boolean}
|
|
88
|
-
*/
|
|
55
|
+
|
|
89
56
|
this.managed = data.managed;
|
|
90
57
|
}
|
|
91
58
|
|
|
92
59
|
if ('mentionable' in data) {
|
|
93
|
-
|
|
94
|
-
* Whether or not the role can be mentioned by anyone
|
|
95
|
-
* @type {boolean}
|
|
96
|
-
*/
|
|
60
|
+
|
|
97
61
|
this.mentionable = data.mentionable;
|
|
98
62
|
}
|
|
99
63
|
|
|
@@ -101,16 +65,7 @@ class Role extends Base {
|
|
|
101
65
|
|
|
102
66
|
if ('unicode_emoji' in data) this.unicodeEmoji = data.unicode_emoji;
|
|
103
67
|
|
|
104
|
-
|
|
105
|
-
* The tags this role has
|
|
106
|
-
* @type {?Object}
|
|
107
|
-
* @property {Snowflake} [botId] The id of the bot this role belongs to
|
|
108
|
-
* @property {Snowflake|string} [integrationId] The id of the integration this role belongs to
|
|
109
|
-
* @property {true} [premiumSubscriberRole] Whether this is the guild's premium subscription role
|
|
110
|
-
* @property {Snowflake} [subscriptionListingId] The id of this role's subscription SKU and listing
|
|
111
|
-
* @property {true} [availableForPurchase] Whether this role is available for purchase
|
|
112
|
-
* @property {true} [guildConnections] Whether this role is a guild's linked role
|
|
113
|
-
*/
|
|
68
|
+
|
|
114
69
|
this.tags = data.tags ? {} : null;
|
|
115
70
|
if (data.tags) {
|
|
116
71
|
if ('bot_id' in data.tags) {
|
|
@@ -134,47 +89,27 @@ class Role extends Base {
|
|
|
134
89
|
}
|
|
135
90
|
}
|
|
136
91
|
|
|
137
|
-
|
|
138
|
-
* The timestamp the role was created at
|
|
139
|
-
* @type {number}
|
|
140
|
-
* @readonly
|
|
141
|
-
*/
|
|
92
|
+
|
|
142
93
|
get createdTimestamp() {
|
|
143
94
|
return DiscordSnowflake.timestampFrom(this.id);
|
|
144
95
|
}
|
|
145
96
|
|
|
146
|
-
|
|
147
|
-
* The time the role was created at
|
|
148
|
-
* @type {Date}
|
|
149
|
-
* @readonly
|
|
150
|
-
*/
|
|
97
|
+
|
|
151
98
|
get createdAt() {
|
|
152
99
|
return new Date(this.createdTimestamp);
|
|
153
100
|
}
|
|
154
101
|
|
|
155
|
-
|
|
156
|
-
* The hexadecimal version of the role color, with a leading hashtag
|
|
157
|
-
* @type {string}
|
|
158
|
-
* @readonly
|
|
159
|
-
*/
|
|
102
|
+
|
|
160
103
|
get hexColor() {
|
|
161
104
|
return `#${this.color.toString(16).padStart(6, '0')}`;
|
|
162
105
|
}
|
|
163
106
|
|
|
164
|
-
|
|
165
|
-
* The cached guild members that have this role
|
|
166
|
-
* @type {Collection<Snowflake, GuildMember>}
|
|
167
|
-
* @readonly
|
|
168
|
-
*/
|
|
107
|
+
|
|
169
108
|
get members() {
|
|
170
109
|
return this.guild.members.cache.filter(m => m.roles.cache.has(this.id));
|
|
171
110
|
}
|
|
172
111
|
|
|
173
|
-
|
|
174
|
-
* Whether the role is editable by the client user
|
|
175
|
-
* @type {boolean}
|
|
176
|
-
* @readonly
|
|
177
|
-
*/
|
|
112
|
+
|
|
178
113
|
get editable() {
|
|
179
114
|
if (this.managed) return false;
|
|
180
115
|
const clientMember = this.guild.members.resolve(this.client.user);
|
|
@@ -182,11 +117,7 @@ class Role extends Base {
|
|
|
182
117
|
return clientMember.roles.highest.comparePositionTo(this) > 0;
|
|
183
118
|
}
|
|
184
119
|
|
|
185
|
-
|
|
186
|
-
* The position of the role in the role manager
|
|
187
|
-
* @type {number}
|
|
188
|
-
* @readonly
|
|
189
|
-
*/
|
|
120
|
+
|
|
190
121
|
get position() {
|
|
191
122
|
return this.guild.roles.cache.reduce(
|
|
192
123
|
(acc, role) =>
|
|
@@ -198,223 +129,79 @@ class Role extends Base {
|
|
|
198
129
|
);
|
|
199
130
|
}
|
|
200
131
|
|
|
201
|
-
|
|
202
|
-
* Compares this role's position to another role's.
|
|
203
|
-
* @param {RoleResolvable} role Role to compare to this one
|
|
204
|
-
* @returns {number} Negative number if this role's position is lower (other role's is higher),
|
|
205
|
-
* positive number if this one is higher (other's is lower), 0 if equal
|
|
206
|
-
* @example
|
|
207
|
-
* // Compare the position of a role to another
|
|
208
|
-
* const roleCompare = role.comparePositionTo(otherRole);
|
|
209
|
-
* if (roleCompare >= 1) console.log(`${role.name} is higher than ${otherRole.name}`);
|
|
210
|
-
*/
|
|
132
|
+
|
|
211
133
|
comparePositionTo(role) {
|
|
212
134
|
return this.guild.roles.comparePositions(this, role);
|
|
213
135
|
}
|
|
214
136
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
* @property {string} [name] The name of the role
|
|
219
|
-
* @property {ColorResolvable} [color] The color of the role, either a hex string or a base 10 number
|
|
220
|
-
* @property {boolean} [hoist] Whether or not the role should be hoisted
|
|
221
|
-
* @property {number} [position] The position of the role
|
|
222
|
-
* @property {PermissionResolvable} [permissions] The permissions of the role
|
|
223
|
-
* @property {boolean} [mentionable] Whether or not the role should be mentionable
|
|
224
|
-
* @property {?(BufferResolvable|Base64Resolvable|EmojiResolvable)} [icon] The icon for the role
|
|
225
|
-
* <warn>The `EmojiResolvable` should belong to the same guild as the role.
|
|
226
|
-
* If not, pass the emoji's URL directly</warn>
|
|
227
|
-
* @property {?string} [unicodeEmoji] The unicode emoji for the role
|
|
228
|
-
*/
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Edits the role.
|
|
232
|
-
* @param {RoleEditOptions} options The options to provide
|
|
233
|
-
* @returns {Promise<Role>}
|
|
234
|
-
* @example
|
|
235
|
-
* // Edit a role
|
|
236
|
-
* role.edit({ name: 'new role' })
|
|
237
|
-
* .then(updated => console.log(`Edited role name to ${updated.name}`))
|
|
238
|
-
* .catch(console.error);
|
|
239
|
-
*/
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
240
140
|
edit(options) {
|
|
241
141
|
return this.guild.roles.edit(this, options);
|
|
242
142
|
}
|
|
243
143
|
|
|
244
|
-
|
|
245
|
-
* Returns `channel.permissionsFor(role)`. Returns permissions for a role in a guild channel,
|
|
246
|
-
* taking into account permission overwrites.
|
|
247
|
-
* @param {GuildChannel|Snowflake} channel The guild channel to use as context
|
|
248
|
-
* @param {boolean} [checkAdmin=true] Whether having the {@link PermissionFlagsBits.Administrator} permission
|
|
249
|
-
* will return all permissions
|
|
250
|
-
* @returns {Readonly<PermissionsBitField>}
|
|
251
|
-
*/
|
|
144
|
+
|
|
252
145
|
permissionsIn(channel, checkAdmin = true) {
|
|
253
146
|
channel = this.guild.channels.resolve(channel);
|
|
254
147
|
if (!channel) throw new DiscordjsError(ErrorCodes.GuildChannelResolve);
|
|
255
148
|
return channel.rolePermissions(this, checkAdmin);
|
|
256
149
|
}
|
|
257
150
|
|
|
258
|
-
|
|
259
|
-
* Sets a new name for the role.
|
|
260
|
-
* @param {string} name The new name of the role
|
|
261
|
-
* @param {string} [reason] Reason for changing the role's name
|
|
262
|
-
* @returns {Promise<Role>}
|
|
263
|
-
* @example
|
|
264
|
-
* // Set the name of the role
|
|
265
|
-
* role.setName('new role')
|
|
266
|
-
* .then(updated => console.log(`Updated role name to ${updated.name}`))
|
|
267
|
-
* .catch(console.error);
|
|
268
|
-
*/
|
|
151
|
+
|
|
269
152
|
setName(name, reason) {
|
|
270
153
|
return this.edit({ name, reason });
|
|
271
154
|
}
|
|
272
155
|
|
|
273
|
-
|
|
274
|
-
* Sets a new color for the role.
|
|
275
|
-
* @param {ColorResolvable} color The color of the role
|
|
276
|
-
* @param {string} [reason] Reason for changing the role's color
|
|
277
|
-
* @returns {Promise<Role>}
|
|
278
|
-
* @example
|
|
279
|
-
* // Set the color of a role
|
|
280
|
-
* role.setColor('#FF0000')
|
|
281
|
-
* .then(updated => console.log(`Set color of role to ${updated.color}`))
|
|
282
|
-
* .catch(console.error);
|
|
283
|
-
*/
|
|
156
|
+
|
|
284
157
|
setColor(color, reason) {
|
|
285
158
|
return this.edit({ color, reason });
|
|
286
159
|
}
|
|
287
160
|
|
|
288
|
-
|
|
289
|
-
* Sets whether or not the role should be hoisted.
|
|
290
|
-
* @param {boolean} [hoist=true] Whether or not to hoist the role
|
|
291
|
-
* @param {string} [reason] Reason for setting whether or not the role should be hoisted
|
|
292
|
-
* @returns {Promise<Role>}
|
|
293
|
-
* @example
|
|
294
|
-
* // Set the hoist of the role
|
|
295
|
-
* role.setHoist(true)
|
|
296
|
-
* .then(updated => console.log(`Role hoisted: ${updated.hoist}`))
|
|
297
|
-
* .catch(console.error);
|
|
298
|
-
*/
|
|
161
|
+
|
|
299
162
|
setHoist(hoist = true, reason) {
|
|
300
163
|
return this.edit({ hoist, reason });
|
|
301
164
|
}
|
|
302
165
|
|
|
303
|
-
|
|
304
|
-
* Sets the permissions of the role.
|
|
305
|
-
* @param {PermissionResolvable} permissions The permissions of the role
|
|
306
|
-
* @param {string} [reason] Reason for changing the role's permissions
|
|
307
|
-
* @returns {Promise<Role>}
|
|
308
|
-
* @example
|
|
309
|
-
* // Set the permissions of the role
|
|
310
|
-
* role.setPermissions([PermissionFlagsBits.KickMembers, PermissionFlagsBits.BanMembers])
|
|
311
|
-
* .then(updated => console.log(`Updated permissions to ${updated.permissions.bitfield}`))
|
|
312
|
-
* .catch(console.error);
|
|
313
|
-
* @example
|
|
314
|
-
* // Remove all permissions from a role
|
|
315
|
-
* role.setPermissions(0n)
|
|
316
|
-
* .then(updated => console.log(`Updated permissions to ${updated.permissions.bitfield}`))
|
|
317
|
-
* .catch(console.error);
|
|
318
|
-
*/
|
|
166
|
+
|
|
319
167
|
setPermissions(permissions, reason) {
|
|
320
168
|
return this.edit({ permissions, reason });
|
|
321
169
|
}
|
|
322
170
|
|
|
323
|
-
|
|
324
|
-
* Sets whether this role is mentionable.
|
|
325
|
-
* @param {boolean} [mentionable=true] Whether this role should be mentionable
|
|
326
|
-
* @param {string} [reason] Reason for setting whether or not this role should be mentionable
|
|
327
|
-
* @returns {Promise<Role>}
|
|
328
|
-
* @example
|
|
329
|
-
* // Make the role mentionable
|
|
330
|
-
* role.setMentionable(true)
|
|
331
|
-
* .then(updated => console.log(`Role updated ${updated.name}`))
|
|
332
|
-
* .catch(console.error);
|
|
333
|
-
*/
|
|
171
|
+
|
|
334
172
|
setMentionable(mentionable = true, reason) {
|
|
335
173
|
return this.edit({ mentionable, reason });
|
|
336
174
|
}
|
|
337
175
|
|
|
338
|
-
|
|
339
|
-
* Sets a new icon for the role.
|
|
340
|
-
* @param {?(BufferResolvable|Base64Resolvable|EmojiResolvable)} icon The icon for the role
|
|
341
|
-
* <warn>The `EmojiResolvable` should belong to the same guild as the role.
|
|
342
|
-
* If not, pass the emoji's URL directly</warn>
|
|
343
|
-
* @param {string} [reason] Reason for changing the role's icon
|
|
344
|
-
* @returns {Promise<Role>}
|
|
345
|
-
*/
|
|
176
|
+
|
|
346
177
|
setIcon(icon, reason) {
|
|
347
178
|
return this.edit({ icon, reason });
|
|
348
179
|
}
|
|
349
180
|
|
|
350
|
-
|
|
351
|
-
* Sets a new unicode emoji for the role.
|
|
352
|
-
* @param {?string} unicodeEmoji The new unicode emoji for the role
|
|
353
|
-
* @param {string} [reason] Reason for changing the role's unicode emoji
|
|
354
|
-
* @returns {Promise<Role>}
|
|
355
|
-
* @example
|
|
356
|
-
* // Set a new unicode emoji for the role
|
|
357
|
-
* role.setUnicodeEmoji('🤖')
|
|
358
|
-
* .then(updated => console.log(`Set unicode emoji for the role to ${updated.unicodeEmoji}`))
|
|
359
|
-
* .catch(console.error);
|
|
360
|
-
*/
|
|
181
|
+
|
|
361
182
|
setUnicodeEmoji(unicodeEmoji, reason) {
|
|
362
183
|
return this.edit({ unicodeEmoji, reason });
|
|
363
184
|
}
|
|
364
185
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
* @property {boolean} [relative=false] Whether to change the position relative to its current value or not
|
|
369
|
-
* @property {string} [reason] The reason for changing the position
|
|
370
|
-
*/
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* Sets the new position of the role.
|
|
374
|
-
* @param {number} position The new position for the role
|
|
375
|
-
* @param {SetRolePositionOptions} [options] Options for setting the position
|
|
376
|
-
* @returns {Promise<Role>}
|
|
377
|
-
* @example
|
|
378
|
-
* // Set the position of the role
|
|
379
|
-
* role.setPosition(1)
|
|
380
|
-
* .then(updated => console.log(`Role position: ${updated.position}`))
|
|
381
|
-
* .catch(console.error);
|
|
382
|
-
*/
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
383
189
|
setPosition(position, options = {}) {
|
|
384
190
|
return this.guild.roles.setPosition(this, position, options);
|
|
385
191
|
}
|
|
386
192
|
|
|
387
|
-
|
|
388
|
-
* Deletes the role.
|
|
389
|
-
* @param {string} [reason] Reason for deleting this role
|
|
390
|
-
* @returns {Promise<Role>}
|
|
391
|
-
* @example
|
|
392
|
-
* // Delete a role
|
|
393
|
-
* role.delete('The role needed to go')
|
|
394
|
-
* .then(deleted => console.log(`Deleted role ${deleted.name}`))
|
|
395
|
-
* .catch(console.error);
|
|
396
|
-
*/
|
|
193
|
+
|
|
397
194
|
async delete(reason) {
|
|
398
195
|
await this.guild.roles.delete(this.id, reason);
|
|
399
196
|
return this;
|
|
400
197
|
}
|
|
401
198
|
|
|
402
|
-
|
|
403
|
-
* A link to the role's icon
|
|
404
|
-
* @param {ImageURLOptions} [options={}] Options for the image URL
|
|
405
|
-
* @returns {?string}
|
|
406
|
-
*/
|
|
199
|
+
|
|
407
200
|
iconURL(options = {}) {
|
|
408
201
|
return this.icon && this.client.rest.cdn.roleIcon(this.id, this.icon, options);
|
|
409
202
|
}
|
|
410
203
|
|
|
411
|
-
|
|
412
|
-
* Whether this role equals another role. It compares all properties, so for most operations
|
|
413
|
-
* it is advisable to just compare `role.id === role2.id` as it is much faster and is often
|
|
414
|
-
* what most users need.
|
|
415
|
-
* @param {Role} role Role to compare with
|
|
416
|
-
* @returns {boolean}
|
|
417
|
-
*/
|
|
204
|
+
|
|
418
205
|
equals(role) {
|
|
419
206
|
return (
|
|
420
207
|
role &&
|
|
@@ -430,13 +217,7 @@ class Role extends Base {
|
|
|
430
217
|
);
|
|
431
218
|
}
|
|
432
219
|
|
|
433
|
-
|
|
434
|
-
* When concatenated with a string, this automatically returns the role's mention instead of the Role object.
|
|
435
|
-
* @returns {string}
|
|
436
|
-
* @example
|
|
437
|
-
* // Logs: Role: <@&123456789012345678>
|
|
438
|
-
* console.log(`Role: ${role}`);
|
|
439
|
-
*/
|
|
220
|
+
|
|
440
221
|
toString() {
|
|
441
222
|
if (this.id === this.guild.id) return '@everyone';
|
|
442
223
|
return `<@&${this.id}>`;
|
|
@@ -452,7 +233,4 @@ class Role extends Base {
|
|
|
452
233
|
|
|
453
234
|
exports.Role = Role;
|
|
454
235
|
|
|
455
|
-
|
|
456
|
-
* @external APIRole
|
|
457
|
-
* @see {@link https://discord.com/developers/docs/topics/permissions#role-object}
|
|
458
|
-
*/
|
|
236
|
+
|
|
@@ -4,20 +4,13 @@ const { RoleSelectMenuBuilder: BuildersRoleSelectMenu } = require('@discordjs/bu
|
|
|
4
4
|
const { isJSONEncodable } = require('@discordjs/util');
|
|
5
5
|
const { toSnakeCase } = require('../util/Transformers');
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
* Class used to build select menu components to be sent through the API
|
|
9
|
-
* @extends {BuildersRoleSelectMenu}
|
|
10
|
-
*/
|
|
7
|
+
|
|
11
8
|
class RoleSelectMenuBuilder extends BuildersRoleSelectMenu {
|
|
12
9
|
constructor(data = {}) {
|
|
13
10
|
super(toSnakeCase(data));
|
|
14
11
|
}
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
* Creates a new select menu builder from JSON data
|
|
18
|
-
* @param {RoleSelectMenuBuilder|RoleSelectMenuComponent|APIRoleSelectComponent} other The other data
|
|
19
|
-
* @returns {RoleSelectMenuBuilder}
|
|
20
|
-
*/
|
|
13
|
+
|
|
21
14
|
static from(other) {
|
|
22
15
|
return new this(isJSONEncodable(other) ? other.toJSON() : other);
|
|
23
16
|
}
|
|
@@ -25,7 +18,4 @@ class RoleSelectMenuBuilder extends BuildersRoleSelectMenu {
|
|
|
25
18
|
|
|
26
19
|
module.exports = RoleSelectMenuBuilder;
|
|
27
20
|
|
|
28
|
-
|
|
29
|
-
* @external BuildersRoleSelectMenu
|
|
30
|
-
* @see {@link https://discord.js.org/docs/packages/builders/stable/RoleSelectMenuBuilder:Class}
|
|
31
|
-
*/
|
|
21
|
+
|
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const BaseSelectMenuComponent = require('./BaseSelectMenuComponent');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
* Represents a role select menu component
|
|
7
|
-
* @extends {BaseSelectMenuComponent}
|
|
8
|
-
*/
|
|
5
|
+
|
|
9
6
|
class RoleSelectMenuComponent extends BaseSelectMenuComponent {}
|
|
10
7
|
|
|
11
8
|
module.exports = RoleSelectMenuComponent;
|
|
@@ -3,25 +3,16 @@
|
|
|
3
3
|
const { Collection } = require('@discordjs/collection');
|
|
4
4
|
const MessageComponentInteraction = require('./MessageComponentInteraction');
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
* Represents a {@link ComponentType.RoleSelect} select menu interaction.
|
|
8
|
-
* @extends {MessageComponentInteraction}
|
|
9
|
-
*/
|
|
6
|
+
|
|
10
7
|
class RoleSelectMenuInteraction extends MessageComponentInteraction {
|
|
11
8
|
constructor(client, data) {
|
|
12
9
|
super(client, data);
|
|
13
10
|
const { resolved, values } = data.data;
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
* An array of the selected role ids
|
|
17
|
-
* @type {Snowflake[]}
|
|
18
|
-
*/
|
|
12
|
+
|
|
19
13
|
this.values = values ?? [];
|
|
20
14
|
|
|
21
|
-
|
|
22
|
-
* Collection of the selected roles
|
|
23
|
-
* @type {Collection<Snowflake, Role|APIRole>}
|
|
24
|
-
*/
|
|
15
|
+
|
|
25
16
|
this.roles = new Collection();
|
|
26
17
|
|
|
27
18
|
for (const role of Object.values(resolved?.roles ?? {})) {
|
|
@@ -5,10 +5,7 @@ const StringSelectMenuBuilder = require('./StringSelectMenuBuilder');
|
|
|
5
5
|
|
|
6
6
|
let deprecationEmitted = false;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
* @deprecated Use {@link StringSelectMenuBuilder} instead.
|
|
10
|
-
* @extends {StringSelectMenuBuilder}
|
|
11
|
-
*/
|
|
8
|
+
|
|
12
9
|
class SelectMenuBuilder extends StringSelectMenuBuilder {
|
|
13
10
|
constructor(...params) {
|
|
14
11
|
super(...params);
|
|
@@ -5,10 +5,7 @@ const StringSelectMenuComponent = require('./StringSelectMenuComponent');
|
|
|
5
5
|
|
|
6
6
|
let deprecationEmitted = false;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
* @deprecated Use {@link StringSelectMenuComponent} instead.
|
|
10
|
-
* @extends {StringSelectMenuComponent}
|
|
11
|
-
*/
|
|
8
|
+
|
|
12
9
|
class SelectMenuComponent extends StringSelectMenuComponent {
|
|
13
10
|
constructor(...params) {
|
|
14
11
|
super(...params);
|
|
@@ -5,10 +5,7 @@ const StringSelectMenuInteraction = require('./StringSelectMenuInteraction');
|
|
|
5
5
|
|
|
6
6
|
let deprecationEmitted = false;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
* @deprecated Use {@link StringSelectMenuInteraction} instead.
|
|
10
|
-
* @extends {StringSelectMenuInteraction}
|
|
11
|
-
*/
|
|
8
|
+
|
|
12
9
|
class SelectMenuInteraction extends StringSelectMenuInteraction {
|
|
13
10
|
constructor(...params) {
|
|
14
11
|
super(...params);
|
|
@@ -5,10 +5,7 @@ const StringSelectMenuOptionBuilder = require('./StringSelectMenuOptionBuilder')
|
|
|
5
5
|
|
|
6
6
|
let deprecationEmitted = false;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
* @deprecated Use {@link StringSelectMenuOptionBuilder} instead.
|
|
10
|
-
* @extends {StringSelectMenuOptionBuilder}
|
|
11
|
-
*/
|
|
8
|
+
|
|
12
9
|
class SelectMenuOptionBuilder extends StringSelectMenuOptionBuilder {
|
|
13
10
|
constructor(...params) {
|
|
14
11
|
super(...params);
|