discord-selfbot-v13.js 0.0.1-security → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of discord-selfbot-v13.js might be problematic. Click here for more details.
- package/LICENSE +674 -0
- package/README.md +119 -5
- package/package.json +101 -6
- package/src/WebSocket.js +39 -0
- package/src/client/BaseClient.js +87 -0
- package/src/client/Client.js +1154 -0
- package/src/client/WebhookClient.js +61 -0
- package/src/client/actions/Action.js +115 -0
- package/src/client/actions/ActionsManager.js +72 -0
- package/src/client/actions/ApplicationCommandPermissionsUpdate.js +34 -0
- package/src/client/actions/AutoModerationActionExecution.js +26 -0
- package/src/client/actions/AutoModerationRuleCreate.js +27 -0
- package/src/client/actions/AutoModerationRuleDelete.js +31 -0
- package/src/client/actions/AutoModerationRuleUpdate.js +29 -0
- package/src/client/actions/ChannelCreate.js +23 -0
- package/src/client/actions/ChannelDelete.js +39 -0
- package/src/client/actions/ChannelUpdate.js +34 -0
- package/src/client/actions/GuildAuditLogEntryCreate.js +29 -0
- package/src/client/actions/GuildBanAdd.js +20 -0
- package/src/client/actions/GuildBanRemove.js +25 -0
- package/src/client/actions/GuildChannelsPositionUpdate.js +21 -0
- package/src/client/actions/GuildDelete.js +65 -0
- package/src/client/actions/GuildEmojiCreate.js +20 -0
- package/src/client/actions/GuildEmojiDelete.js +21 -0
- package/src/client/actions/GuildEmojiUpdate.js +20 -0
- package/src/client/actions/GuildEmojisUpdate.js +34 -0
- package/src/client/actions/GuildIntegrationsUpdate.js +19 -0
- package/src/client/actions/GuildMemberRemove.js +33 -0
- package/src/client/actions/GuildMemberUpdate.js +44 -0
- package/src/client/actions/GuildRoleCreate.js +25 -0
- package/src/client/actions/GuildRoleDelete.js +31 -0
- package/src/client/actions/GuildRoleUpdate.js +39 -0
- package/src/client/actions/GuildRolesPositionUpdate.js +21 -0
- package/src/client/actions/GuildScheduledEventCreate.js +27 -0
- package/src/client/actions/GuildScheduledEventDelete.js +31 -0
- package/src/client/actions/GuildScheduledEventUpdate.js +30 -0
- package/src/client/actions/GuildScheduledEventUserAdd.js +32 -0
- package/src/client/actions/GuildScheduledEventUserRemove.js +32 -0
- package/src/client/actions/GuildStickerCreate.js +20 -0
- package/src/client/actions/GuildStickerDelete.js +21 -0
- package/src/client/actions/GuildStickerUpdate.js +20 -0
- package/src/client/actions/GuildStickersUpdate.js +34 -0
- package/src/client/actions/GuildUpdate.js +33 -0
- package/src/client/actions/InteractionCreate.js +115 -0
- package/src/client/actions/InviteCreate.js +28 -0
- package/src/client/actions/InviteDelete.js +30 -0
- package/src/client/actions/MessageCreate.js +50 -0
- package/src/client/actions/MessageDelete.js +32 -0
- package/src/client/actions/MessageDeleteBulk.js +46 -0
- package/src/client/actions/MessageReactionAdd.js +56 -0
- package/src/client/actions/MessageReactionRemove.js +45 -0
- package/src/client/actions/MessageReactionRemoveAll.js +33 -0
- package/src/client/actions/MessageReactionRemoveEmoji.js +28 -0
- package/src/client/actions/MessageUpdate.js +26 -0
- package/src/client/actions/PresenceUpdate.js +45 -0
- package/src/client/actions/StageInstanceCreate.js +28 -0
- package/src/client/actions/StageInstanceDelete.js +33 -0
- package/src/client/actions/StageInstanceUpdate.js +30 -0
- package/src/client/actions/ThreadCreate.js +24 -0
- package/src/client/actions/ThreadDelete.js +32 -0
- package/src/client/actions/ThreadListSync.js +59 -0
- package/src/client/actions/ThreadMemberUpdate.js +30 -0
- package/src/client/actions/ThreadMembersUpdate.js +34 -0
- package/src/client/actions/TypingStart.js +29 -0
- package/src/client/actions/UserUpdate.js +35 -0
- package/src/client/actions/VoiceStateUpdate.js +57 -0
- package/src/client/actions/WebhooksUpdate.js +20 -0
- package/src/client/voice/ClientVoiceManager.js +51 -0
- package/src/client/websocket/WebSocketManager.js +412 -0
- package/src/client/websocket/WebSocketShard.js +908 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE.js +23 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_CREATE.js +18 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_DELETE.js +20 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_PERMISSIONS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_UPDATE.js +20 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_ACTION_EXECUTION.js +5 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_CREATE.js +5 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_DELETE.js +5 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/CALL_CREATE.js +14 -0
- package/src/client/websocket/handlers/CALL_DELETE.js +11 -0
- package/src/client/websocket/handlers/CALL_UPDATE.js +11 -0
- package/src/client/websocket/handlers/CHANNEL_CREATE.js +5 -0
- package/src/client/websocket/handlers/CHANNEL_DELETE.js +5 -0
- package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js +22 -0
- package/src/client/websocket/handlers/CHANNEL_RECIPIENT_ADD.js +16 -0
- package/src/client/websocket/handlers/CHANNEL_RECIPIENT_REMOVE.js +16 -0
- package/src/client/websocket/handlers/CHANNEL_UPDATE.js +16 -0
- package/src/client/websocket/handlers/GUILD_APPLICATION_COMMANDS_UPDATE.js +11 -0
- package/src/client/websocket/handlers/GUILD_AUDIT_LOG_ENTRY_CREATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_BAN_ADD.js +5 -0
- package/src/client/websocket/handlers/GUILD_BAN_REMOVE.js +5 -0
- package/src/client/websocket/handlers/GUILD_CREATE.js +46 -0
- package/src/client/websocket/handlers/GUILD_DELETE.js +5 -0
- package/src/client/websocket/handlers/GUILD_EMOJIS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_INTEGRATIONS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js +39 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +20 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_LIST_UPDATE.js +55 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_REMOVE.js +5 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_ROLE_CREATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_ROLE_DELETE.js +5 -0
- package/src/client/websocket/handlers/GUILD_ROLE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_CREATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_DELETE.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_ADD.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_REMOVE.js +5 -0
- package/src/client/websocket/handlers/GUILD_STICKERS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_UPDATE.js +5 -0
- package/src/client/websocket/handlers/INTERACTION_CREATE.js +16 -0
- package/src/client/websocket/handlers/INTERACTION_FAILURE.js +18 -0
- package/src/client/websocket/handlers/INTERACTION_MODAL_CREATE.js +11 -0
- package/src/client/websocket/handlers/INTERACTION_SUCCESS.js +30 -0
- package/src/client/websocket/handlers/INVITE_CREATE.js +5 -0
- package/src/client/websocket/handlers/INVITE_DELETE.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_ACK.js +16 -0
- package/src/client/websocket/handlers/MESSAGE_CREATE.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE_BULK.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_ADD.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_ALL.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_EMOJI.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_UPDATE.js +16 -0
- package/src/client/websocket/handlers/PRESENCE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/READY.js +172 -0
- package/src/client/websocket/handlers/RELATIONSHIP_ADD.js +17 -0
- package/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js +15 -0
- package/src/client/websocket/handlers/RELATIONSHIP_UPDATE.js +18 -0
- package/src/client/websocket/handlers/RESUMED.js +14 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_CREATE.js +5 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_DELETE.js +5 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/THREAD_CREATE.js +5 -0
- package/src/client/websocket/handlers/THREAD_DELETE.js +5 -0
- package/src/client/websocket/handlers/THREAD_LIST_SYNC.js +5 -0
- package/src/client/websocket/handlers/THREAD_MEMBERS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/THREAD_MEMBER_UPDATE.js +5 -0
- package/src/client/websocket/handlers/THREAD_UPDATE.js +16 -0
- package/src/client/websocket/handlers/TYPING_START.js +5 -0
- package/src/client/websocket/handlers/USER_GUILD_SETTINGS_UPDATE.js +12 -0
- package/src/client/websocket/handlers/USER_NOTE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/USER_SETTINGS_UPDATE.js +9 -0
- package/src/client/websocket/handlers/USER_UPDATE.js +5 -0
- package/src/client/websocket/handlers/VOICE_SERVER_UPDATE.js +6 -0
- package/src/client/websocket/handlers/VOICE_STATE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/WEBHOOKS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/index.js +86 -0
- package/src/errors/DJSError.js +61 -0
- package/src/errors/Messages.js +227 -0
- package/src/errors/index.js +4 -0
- package/src/index.js +190 -0
- package/src/main.js +42 -0
- package/src/managers/ApplicationCommandManager.js +267 -0
- package/src/managers/ApplicationCommandPermissionsManager.js +425 -0
- package/src/managers/AutoModerationRuleManager.js +296 -0
- package/src/managers/BaseGuildEmojiManager.js +80 -0
- package/src/managers/BaseManager.js +19 -0
- package/src/managers/BillingManager.js +66 -0
- package/src/managers/CachedManager.js +71 -0
- package/src/managers/ChannelManager.js +139 -0
- package/src/managers/ClientUserSettingManager.js +490 -0
- package/src/managers/DataManager.js +61 -0
- package/src/managers/DeveloperPortalManager.js +104 -0
- package/src/managers/GuildApplicationCommandManager.js +28 -0
- package/src/managers/GuildBanManager.js +204 -0
- package/src/managers/GuildChannelManager.js +502 -0
- package/src/managers/GuildEmojiManager.js +171 -0
- package/src/managers/GuildEmojiRoleManager.js +118 -0
- package/src/managers/GuildFolderManager.js +24 -0
- package/src/managers/GuildForumThreadManager.js +114 -0
- package/src/managers/GuildInviteManager.js +213 -0
- package/src/managers/GuildManager.js +304 -0
- package/src/managers/GuildMemberManager.js +724 -0
- package/src/managers/GuildMemberRoleManager.js +191 -0
- package/src/managers/GuildScheduledEventManager.js +296 -0
- package/src/managers/GuildSettingManager.js +148 -0
- package/src/managers/GuildStickerManager.js +179 -0
- package/src/managers/GuildTextThreadManager.js +98 -0
- package/src/managers/InteractionManager.js +39 -0
- package/src/managers/MessageManager.js +393 -0
- package/src/managers/PermissionOverwriteManager.js +166 -0
- package/src/managers/PresenceManager.js +58 -0
- package/src/managers/ReactionManager.js +67 -0
- package/src/managers/ReactionUserManager.js +71 -0
- package/src/managers/RelationshipManager.js +258 -0
- package/src/managers/RoleManager.js +352 -0
- package/src/managers/SessionManager.js +57 -0
- package/src/managers/StageInstanceManager.js +162 -0
- package/src/managers/ThreadManager.js +207 -0
- package/src/managers/ThreadMemberManager.js +186 -0
- package/src/managers/UserManager.js +150 -0
- package/src/managers/VoiceStateManager.js +37 -0
- package/src/rest/APIRequest.js +136 -0
- package/src/rest/APIRouter.js +53 -0
- package/src/rest/CaptchaSolver.js +78 -0
- package/src/rest/DiscordAPIError.js +103 -0
- package/src/rest/HTTPError.js +62 -0
- package/src/rest/RESTManager.js +81 -0
- package/src/rest/RateLimitError.js +55 -0
- package/src/rest/RequestHandler.js +446 -0
- package/src/sharding/Shard.js +443 -0
- package/src/sharding/ShardClientUtil.js +275 -0
- package/src/sharding/ShardingManager.js +318 -0
- package/src/structures/AnonymousGuild.js +98 -0
- package/src/structures/ApplicationCommand.js +1028 -0
- package/src/structures/ApplicationRoleConnectionMetadata.js +45 -0
- package/src/structures/AutoModerationActionExecution.js +89 -0
- package/src/structures/AutoModerationRule.js +294 -0
- package/src/structures/AutocompleteInteraction.js +106 -0
- package/src/structures/Base.js +43 -0
- package/src/structures/BaseCommandInteraction.js +211 -0
- package/src/structures/BaseGuild.js +116 -0
- package/src/structures/BaseGuildEmoji.js +56 -0
- package/src/structures/BaseGuildTextChannel.js +193 -0
- package/src/structures/BaseGuildVoiceChannel.js +243 -0
- package/src/structures/BaseMessageComponent.js +114 -0
- package/src/structures/ButtonInteraction.js +11 -0
- package/src/structures/Call.js +58 -0
- package/src/structures/CategoryChannel.js +83 -0
- package/src/structures/Channel.js +271 -0
- package/src/structures/ClientApplication.js +204 -0
- package/src/structures/ClientPresence.js +84 -0
- package/src/structures/ClientUser.js +624 -0
- package/src/structures/CommandInteraction.js +41 -0
- package/src/structures/CommandInteractionOptionResolver.js +276 -0
- package/src/structures/ContextMenuInteraction.js +65 -0
- package/src/structures/DMChannel.js +280 -0
- package/src/structures/DeveloperPortalApplication.js +520 -0
- package/src/structures/DirectoryChannel.js +20 -0
- package/src/structures/Emoji.js +148 -0
- package/src/structures/ForumChannel.js +271 -0
- package/src/structures/Guild.js +1744 -0
- package/src/structures/GuildAuditLogs.js +734 -0
- package/src/structures/GuildBan.js +59 -0
- package/src/structures/GuildBoost.js +108 -0
- package/src/structures/GuildChannel.js +454 -0
- package/src/structures/GuildEmoji.js +161 -0
- package/src/structures/GuildFolder.js +75 -0
- package/src/structures/GuildMember.js +686 -0
- package/src/structures/GuildPreview.js +191 -0
- package/src/structures/GuildPreviewEmoji.js +27 -0
- package/src/structures/GuildScheduledEvent.js +441 -0
- package/src/structures/GuildTemplate.js +236 -0
- package/src/structures/Integration.js +188 -0
- package/src/structures/IntegrationApplication.js +96 -0
- package/src/structures/Interaction.js +351 -0
- package/src/structures/InteractionCollector.js +248 -0
- package/src/structures/InteractionResponse.js +114 -0
- package/src/structures/InteractionWebhook.js +43 -0
- package/src/structures/Invite.js +375 -0
- package/src/structures/InviteGuild.js +23 -0
- package/src/structures/InviteStageInstance.js +86 -0
- package/src/structures/Message.js +1188 -0
- package/src/structures/MessageActionRow.js +103 -0
- package/src/structures/MessageAttachment.js +193 -0
- package/src/structures/MessageButton.js +231 -0
- package/src/structures/MessageCollector.js +146 -0
- package/src/structures/MessageComponentInteraction.js +120 -0
- package/src/structures/MessageContextMenuInteraction.js +20 -0
- package/src/structures/MessageEmbed.js +586 -0
- package/src/structures/MessageMentions.js +272 -0
- package/src/structures/MessagePayload.js +358 -0
- package/src/structures/MessageReaction.js +171 -0
- package/src/structures/MessageSelectMenu.js +391 -0
- package/src/structures/Modal.js +279 -0
- package/src/structures/ModalSubmitFieldsResolver.js +53 -0
- package/src/structures/ModalSubmitInteraction.js +119 -0
- package/src/structures/NewsChannel.js +32 -0
- package/src/structures/OAuth2Guild.js +28 -0
- package/src/structures/PartialGroupDMChannel.js +430 -0
- package/src/structures/PermissionOverwrites.js +196 -0
- package/src/structures/Presence.js +441 -0
- package/src/structures/ReactionCollector.js +229 -0
- package/src/structures/ReactionEmoji.js +31 -0
- package/src/structures/RichPresence.js +722 -0
- package/src/structures/Role.js +515 -0
- package/src/structures/SelectMenuInteraction.js +170 -0
- package/src/structures/Session.js +81 -0
- package/src/structures/StageChannel.js +104 -0
- package/src/structures/StageInstance.js +208 -0
- package/src/structures/Sticker.js +310 -0
- package/src/structures/StickerPack.js +95 -0
- package/src/structures/StoreChannel.js +56 -0
- package/src/structures/Team.js +167 -0
- package/src/structures/TeamMember.js +71 -0
- package/src/structures/TextChannel.js +33 -0
- package/src/structures/TextInputComponent.js +201 -0
- package/src/structures/ThreadChannel.js +626 -0
- package/src/structures/ThreadMember.js +105 -0
- package/src/structures/Typing.js +74 -0
- package/src/structures/User.js +697 -0
- package/src/structures/UserContextMenuInteraction.js +29 -0
- package/src/structures/VoiceChannel.js +110 -0
- package/src/structures/VoiceRegion.js +53 -0
- package/src/structures/VoiceState.js +306 -0
- package/src/structures/WebEmbed.js +401 -0
- package/src/structures/Webhook.js +461 -0
- package/src/structures/WelcomeChannel.js +60 -0
- package/src/structures/WelcomeScreen.js +48 -0
- package/src/structures/Widget.js +87 -0
- package/src/structures/WidgetMember.js +99 -0
- package/src/structures/interfaces/Application.js +190 -0
- package/src/structures/interfaces/Collector.js +300 -0
- package/src/structures/interfaces/InteractionResponses.js +313 -0
- package/src/structures/interfaces/TextBasedChannel.js +566 -0
- package/src/util/ActivityFlags.js +44 -0
- package/src/util/ApplicationFlags.js +74 -0
- package/src/util/BitField.js +170 -0
- package/src/util/ChannelFlags.js +45 -0
- package/src/util/Constants.js +1917 -0
- package/src/util/DataResolver.js +145 -0
- package/src/util/Formatters.js +214 -0
- package/src/util/GuildMemberFlags.js +43 -0
- package/src/util/Intents.js +74 -0
- package/src/util/LimitedCollection.js +131 -0
- package/src/util/MessageFlags.js +54 -0
- package/src/util/Options.js +360 -0
- package/src/util/Permissions.js +187 -0
- package/src/util/PremiumUsageFlags.js +31 -0
- package/src/util/PurchasedFlags.js +31 -0
- package/src/util/RemoteAuth.js +522 -0
- package/src/util/SnowflakeUtil.js +92 -0
- package/src/util/Sweepers.js +466 -0
- package/src/util/SystemChannelFlags.js +55 -0
- package/src/util/ThreadMemberFlags.js +30 -0
- package/src/util/UserFlags.js +104 -0
- package/src/util/Util.js +741 -0
- package/src/util/Voice.js +1456 -0
- package/src/util/arRPC/index.js +229 -0
- package/src/util/arRPC/process/detectable.json +1 -0
- package/src/util/arRPC/process/index.js +102 -0
- package/src/util/arRPC/process/native/index.js +5 -0
- package/src/util/arRPC/process/native/linux.js +37 -0
- package/src/util/arRPC/process/native/win32.js +25 -0
- package/src/util/arRPC/transports/ipc.js +281 -0
- package/src/util/arRPC/transports/websocket.js +128 -0
- package/typings/enums.d.ts +346 -0
- package/typings/index.d.ts +7725 -0
- package/typings/index.test-d.ts +0 -0
- package/typings/rawDataTypes.d.ts +283 -0
@@ -0,0 +1,515 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const process = require('node:process');
|
4
|
+
const Base = require('./Base');
|
5
|
+
const { Error } = require('../errors');
|
6
|
+
const Permissions = require('../util/Permissions');
|
7
|
+
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
8
|
+
|
9
|
+
let deprecationEmittedForComparePositions = false;
|
10
|
+
|
11
|
+
/**
|
12
|
+
* @type {WeakSet<Role>}
|
13
|
+
* @private
|
14
|
+
* @internal
|
15
|
+
*/
|
16
|
+
const deletedRoles = new WeakSet();
|
17
|
+
let deprecationEmittedForDeleted = false;
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Represents a role on Discord.
|
21
|
+
* @extends {Base}
|
22
|
+
*/
|
23
|
+
class Role extends Base {
|
24
|
+
constructor(client, data, guild) {
|
25
|
+
super(client);
|
26
|
+
|
27
|
+
/**
|
28
|
+
* The guild that the role belongs to
|
29
|
+
* @type {Guild}
|
30
|
+
*/
|
31
|
+
this.guild = guild;
|
32
|
+
|
33
|
+
/**
|
34
|
+
* The icon hash of the role
|
35
|
+
* @type {?string}
|
36
|
+
*/
|
37
|
+
this.icon = null;
|
38
|
+
|
39
|
+
/**
|
40
|
+
* The unicode emoji for the role
|
41
|
+
* @type {?string}
|
42
|
+
*/
|
43
|
+
this.unicodeEmoji = null;
|
44
|
+
|
45
|
+
if (data) this._patch(data);
|
46
|
+
}
|
47
|
+
|
48
|
+
_patch(data) {
|
49
|
+
/**
|
50
|
+
* The role's id (unique to the guild it is part of)
|
51
|
+
* @type {Snowflake}
|
52
|
+
*/
|
53
|
+
this.id = data.id;
|
54
|
+
if ('name' in data) {
|
55
|
+
/**
|
56
|
+
* The name of the role
|
57
|
+
* @type {string}
|
58
|
+
*/
|
59
|
+
this.name = data.name;
|
60
|
+
}
|
61
|
+
|
62
|
+
if ('color' in data) {
|
63
|
+
/**
|
64
|
+
* The base 10 color of the role
|
65
|
+
* @type {number}
|
66
|
+
*/
|
67
|
+
this.color = data.color;
|
68
|
+
}
|
69
|
+
|
70
|
+
if ('hoist' in data) {
|
71
|
+
/**
|
72
|
+
* If true, users that are part of this role will appear in a separate category in the users list
|
73
|
+
* @type {boolean}
|
74
|
+
*/
|
75
|
+
this.hoist = data.hoist;
|
76
|
+
}
|
77
|
+
|
78
|
+
if ('position' in data) {
|
79
|
+
/**
|
80
|
+
* The raw position of the role from the API
|
81
|
+
* @type {number}
|
82
|
+
*/
|
83
|
+
this.rawPosition = data.position;
|
84
|
+
}
|
85
|
+
|
86
|
+
if ('permissions' in data) {
|
87
|
+
/**
|
88
|
+
* The permissions of the role
|
89
|
+
* @type {Readonly<Permissions>}
|
90
|
+
*/
|
91
|
+
this.permissions = new Permissions(BigInt(data.permissions)).freeze();
|
92
|
+
}
|
93
|
+
|
94
|
+
if ('managed' in data) {
|
95
|
+
/**
|
96
|
+
* Whether or not the role is managed by an external service
|
97
|
+
* @type {boolean}
|
98
|
+
*/
|
99
|
+
this.managed = data.managed;
|
100
|
+
}
|
101
|
+
|
102
|
+
if ('mentionable' in data) {
|
103
|
+
/**
|
104
|
+
* Whether or not the role can be mentioned by anyone
|
105
|
+
* @type {boolean}
|
106
|
+
*/
|
107
|
+
this.mentionable = data.mentionable;
|
108
|
+
}
|
109
|
+
|
110
|
+
if ('icon' in data) this.icon = data.icon;
|
111
|
+
|
112
|
+
if ('unicode_emoji' in data) this.unicodeEmoji = data.unicode_emoji;
|
113
|
+
|
114
|
+
/**
|
115
|
+
* The tags this role has
|
116
|
+
* @type {?Object}
|
117
|
+
* @property {Snowflake} [botId] The id of the bot this role belongs to
|
118
|
+
* @property {Snowflake|string} [integrationId] The id of the integration this role belongs to
|
119
|
+
* @property {true} [premiumSubscriberRole] Whether this is the guild's premium subscription role
|
120
|
+
* @property {Snowflake} [subscriptionListingId] The id of this role's subscription SKU and listing
|
121
|
+
* @property {true} [availableForPurchase] Whether this role is available for purchase
|
122
|
+
* @property {true} [guildConnections] Whether this role is a guild's linked role
|
123
|
+
*/
|
124
|
+
this.tags = data.tags ? {} : null;
|
125
|
+
if (data.tags) {
|
126
|
+
if ('bot_id' in data.tags) {
|
127
|
+
this.tags.botId = data.tags.bot_id;
|
128
|
+
}
|
129
|
+
if ('integration_id' in data.tags) {
|
130
|
+
this.tags.integrationId = data.tags.integration_id;
|
131
|
+
}
|
132
|
+
if ('premium_subscriber' in data.tags) {
|
133
|
+
this.tags.premiumSubscriberRole = true;
|
134
|
+
}
|
135
|
+
if ('subscription_listing_id' in data.tags) {
|
136
|
+
this.tags.subscriptionListingId = data.tags.subscription_listing_id;
|
137
|
+
}
|
138
|
+
if ('available_for_purchase' in data.tags) {
|
139
|
+
this.tags.availableForPurchase = true;
|
140
|
+
}
|
141
|
+
if ('guild_connections' in data.tags) {
|
142
|
+
this.tags.guildConnections = true;
|
143
|
+
}
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
/**
|
148
|
+
* The timestamp the role was created at
|
149
|
+
* @type {number}
|
150
|
+
* @readonly
|
151
|
+
*/
|
152
|
+
get createdTimestamp() {
|
153
|
+
return SnowflakeUtil.timestampFrom(this.id);
|
154
|
+
}
|
155
|
+
|
156
|
+
/**
|
157
|
+
* The time the role was created at
|
158
|
+
* @type {Date}
|
159
|
+
* @readonly
|
160
|
+
*/
|
161
|
+
get createdAt() {
|
162
|
+
return new Date(this.createdTimestamp);
|
163
|
+
}
|
164
|
+
|
165
|
+
/**
|
166
|
+
* Whether or not the role has been deleted
|
167
|
+
* @type {boolean}
|
168
|
+
* @deprecated This will be removed in the next major version, see https://github.com/discordjs/discord.js/issues/7091
|
169
|
+
*/
|
170
|
+
get deleted() {
|
171
|
+
if (!deprecationEmittedForDeleted) {
|
172
|
+
deprecationEmittedForDeleted = true;
|
173
|
+
process.emitWarning(
|
174
|
+
'Role#deleted is deprecated, see https://github.com/discordjs/discord.js/issues/7091.',
|
175
|
+
'DeprecationWarning',
|
176
|
+
);
|
177
|
+
}
|
178
|
+
|
179
|
+
return deletedRoles.has(this);
|
180
|
+
}
|
181
|
+
|
182
|
+
set deleted(value) {
|
183
|
+
if (!deprecationEmittedForDeleted) {
|
184
|
+
deprecationEmittedForDeleted = true;
|
185
|
+
process.emitWarning(
|
186
|
+
'Role#deleted is deprecated, see https://github.com/discordjs/discord.js/issues/7091.',
|
187
|
+
'DeprecationWarning',
|
188
|
+
);
|
189
|
+
}
|
190
|
+
|
191
|
+
if (value) deletedRoles.add(this);
|
192
|
+
else deletedRoles.delete(this);
|
193
|
+
}
|
194
|
+
|
195
|
+
/**
|
196
|
+
* The hexadecimal version of the role color, with a leading hashtag
|
197
|
+
* @type {string}
|
198
|
+
* @readonly
|
199
|
+
*/
|
200
|
+
get hexColor() {
|
201
|
+
return `#${this.color.toString(16).padStart(6, '0')}`;
|
202
|
+
}
|
203
|
+
|
204
|
+
/**
|
205
|
+
* The cached guild members that have this role
|
206
|
+
* @type {Collection<Snowflake, GuildMember>}
|
207
|
+
* @readonly
|
208
|
+
*/
|
209
|
+
get members() {
|
210
|
+
return this.guild.members.cache.filter(m => m.roles.cache.has(this.id));
|
211
|
+
}
|
212
|
+
|
213
|
+
/**
|
214
|
+
* Whether the role is editable by the client user
|
215
|
+
* @type {boolean}
|
216
|
+
* @readonly
|
217
|
+
*/
|
218
|
+
get editable() {
|
219
|
+
if (this.managed) return false;
|
220
|
+
const clientMember = this.guild.members.resolve(this.client.user);
|
221
|
+
if (!clientMember.permissions.has(Permissions.FLAGS.MANAGE_ROLES)) return false;
|
222
|
+
return clientMember.roles.highest.comparePositionTo(this) > 0;
|
223
|
+
}
|
224
|
+
|
225
|
+
/**
|
226
|
+
* The position of the role in the role manager
|
227
|
+
* @type {number}
|
228
|
+
* @readonly
|
229
|
+
*/
|
230
|
+
get position() {
|
231
|
+
const sorted = this.guild._sortedRoles();
|
232
|
+
return [...sorted.values()].indexOf(sorted.get(this.id));
|
233
|
+
}
|
234
|
+
|
235
|
+
/**
|
236
|
+
* Compares this role's position to another role's.
|
237
|
+
* @param {RoleResolvable} role Role to compare to this one
|
238
|
+
* @returns {number} Negative number if this role's position is lower (other role's is higher),
|
239
|
+
* positive number if this one is higher (other's is lower), 0 if equal
|
240
|
+
* @example
|
241
|
+
* // Compare the position of a role to another
|
242
|
+
* const roleCompare = role.comparePositionTo(otherRole);
|
243
|
+
* if (roleCompare >= 1) console.log(`${role.name} is higher than ${otherRole.name}`);
|
244
|
+
*/
|
245
|
+
comparePositionTo(role) {
|
246
|
+
return this.guild.roles.comparePositions(this, role);
|
247
|
+
}
|
248
|
+
|
249
|
+
/**
|
250
|
+
* The data for a role.
|
251
|
+
* @typedef {Object} RoleData
|
252
|
+
* @property {string} [name] The name of the role
|
253
|
+
* @property {ColorResolvable} [color] The color of the role, either a hex string or a base 10 number
|
254
|
+
* @property {boolean} [hoist] Whether or not the role should be hoisted
|
255
|
+
* @property {number} [position] The position of the role
|
256
|
+
* @property {PermissionResolvable} [permissions] The permissions of the role
|
257
|
+
* @property {boolean} [mentionable] Whether or not the role should be mentionable
|
258
|
+
* @property {?(BufferResolvable|Base64Resolvable|EmojiResolvable)} [icon] The icon for the role
|
259
|
+
* <warn>The `EmojiResolvable` should belong to the same guild as the role.
|
260
|
+
* If not, pass the emoji's URL directly</warn>
|
261
|
+
* @property {?string} [unicodeEmoji] The unicode emoji for the role
|
262
|
+
*/
|
263
|
+
|
264
|
+
/**
|
265
|
+
* Edits the role.
|
266
|
+
* @param {RoleData} data The new data for the role
|
267
|
+
* @param {string} [reason] Reason for editing this role
|
268
|
+
* @returns {Promise<Role>}
|
269
|
+
* @example
|
270
|
+
* // Edit a role
|
271
|
+
* role.edit({ name: 'new role' })
|
272
|
+
* .then(updated => console.log(`Edited role name to ${updated.name}`))
|
273
|
+
* .catch(console.error);
|
274
|
+
*/
|
275
|
+
edit(data, reason) {
|
276
|
+
return this.guild.roles.edit(this, data, reason);
|
277
|
+
}
|
278
|
+
|
279
|
+
/**
|
280
|
+
* Returns `channel.permissionsFor(role)`. Returns permissions for a role in a guild channel,
|
281
|
+
* taking into account permission overwrites.
|
282
|
+
* @param {GuildChannel|Snowflake} channel The guild channel to use as context
|
283
|
+
* @param {boolean} [checkAdmin=true] Whether having `ADMINISTRATOR` will return all permissions
|
284
|
+
* @returns {Readonly<Permissions>}
|
285
|
+
*/
|
286
|
+
permissionsIn(channel, checkAdmin = true) {
|
287
|
+
channel = this.guild.channels.resolve(channel);
|
288
|
+
if (!channel) throw new Error('GUILD_CHANNEL_RESOLVE');
|
289
|
+
return channel.rolePermissions(this, checkAdmin);
|
290
|
+
}
|
291
|
+
|
292
|
+
/**
|
293
|
+
* Sets a new name for the role.
|
294
|
+
* @param {string} name The new name of the role
|
295
|
+
* @param {string} [reason] Reason for changing the role's name
|
296
|
+
* @returns {Promise<Role>}
|
297
|
+
* @example
|
298
|
+
* // Set the name of the role
|
299
|
+
* role.setName('new role')
|
300
|
+
* .then(updated => console.log(`Updated role name to ${updated.name}`))
|
301
|
+
* .catch(console.error);
|
302
|
+
*/
|
303
|
+
setName(name, reason) {
|
304
|
+
return this.edit({ name }, reason);
|
305
|
+
}
|
306
|
+
|
307
|
+
/**
|
308
|
+
* Sets a new color for the role.
|
309
|
+
* @param {ColorResolvable} color The color of the role
|
310
|
+
* @param {string} [reason] Reason for changing the role's color
|
311
|
+
* @returns {Promise<Role>}
|
312
|
+
* @example
|
313
|
+
* // Set the color of a role
|
314
|
+
* role.setColor('#FF0000')
|
315
|
+
* .then(updated => console.log(`Set color of role to ${updated.color}`))
|
316
|
+
* .catch(console.error);
|
317
|
+
*/
|
318
|
+
setColor(color, reason) {
|
319
|
+
return this.edit({ color }, reason);
|
320
|
+
}
|
321
|
+
|
322
|
+
/**
|
323
|
+
* Sets whether or not the role should be hoisted.
|
324
|
+
* @param {boolean} [hoist=true] Whether or not to hoist the role
|
325
|
+
* @param {string} [reason] Reason for setting whether or not the role should be hoisted
|
326
|
+
* @returns {Promise<Role>}
|
327
|
+
* @example
|
328
|
+
* // Set the hoist of the role
|
329
|
+
* role.setHoist(true)
|
330
|
+
* .then(updated => console.log(`Role hoisted: ${updated.hoist}`))
|
331
|
+
* .catch(console.error);
|
332
|
+
*/
|
333
|
+
setHoist(hoist = true, reason) {
|
334
|
+
return this.edit({ hoist }, reason);
|
335
|
+
}
|
336
|
+
|
337
|
+
/**
|
338
|
+
* Sets the permissions of the role.
|
339
|
+
* @param {PermissionResolvable} permissions The permissions of the role
|
340
|
+
* @param {string} [reason] Reason for changing the role's permissions
|
341
|
+
* @returns {Promise<Role>}
|
342
|
+
* @example
|
343
|
+
* // Set the permissions of the role
|
344
|
+
* role.setPermissions([Permissions.FLAGS.KICK_MEMBERS, Permissions.FLAGS.BAN_MEMBERS])
|
345
|
+
* .then(updated => console.log(`Updated permissions to ${updated.permissions.bitfield}`))
|
346
|
+
* .catch(console.error);
|
347
|
+
* @example
|
348
|
+
* // Remove all permissions from a role
|
349
|
+
* role.setPermissions(0n)
|
350
|
+
* .then(updated => console.log(`Updated permissions to ${updated.permissions.bitfield}`))
|
351
|
+
* .catch(console.error);
|
352
|
+
*/
|
353
|
+
setPermissions(permissions, reason) {
|
354
|
+
return this.edit({ permissions }, reason);
|
355
|
+
}
|
356
|
+
|
357
|
+
/**
|
358
|
+
* Sets whether this role is mentionable.
|
359
|
+
* @param {boolean} [mentionable=true] Whether this role should be mentionable
|
360
|
+
* @param {string} [reason] Reason for setting whether or not this role should be mentionable
|
361
|
+
* @returns {Promise<Role>}
|
362
|
+
* @example
|
363
|
+
* // Make the role mentionable
|
364
|
+
* role.setMentionable(true)
|
365
|
+
* .then(updated => console.log(`Role updated ${updated.name}`))
|
366
|
+
* .catch(console.error);
|
367
|
+
*/
|
368
|
+
setMentionable(mentionable = true, reason) {
|
369
|
+
return this.edit({ mentionable }, reason);
|
370
|
+
}
|
371
|
+
|
372
|
+
/**
|
373
|
+
* Sets a new icon for the role.
|
374
|
+
* @param {?(BufferResolvable|Base64Resolvable|EmojiResolvable)} icon The icon for the role
|
375
|
+
* <warn>The `EmojiResolvable` should belong to the same guild as the role.
|
376
|
+
* If not, pass the emoji's URL directly</warn>
|
377
|
+
* @param {string} [reason] Reason for changing the role's icon
|
378
|
+
* @returns {Promise<Role>}
|
379
|
+
*/
|
380
|
+
setIcon(icon, reason) {
|
381
|
+
return this.edit({ icon }, reason);
|
382
|
+
}
|
383
|
+
|
384
|
+
/**
|
385
|
+
* Sets a new unicode emoji for the role.
|
386
|
+
* @param {?string} unicodeEmoji The new unicode emoji for the role
|
387
|
+
* @param {string} [reason] Reason for changing the role's unicode emoji
|
388
|
+
* @returns {Promise<Role>}
|
389
|
+
* @example
|
390
|
+
* // Set a new unicode emoji for the role
|
391
|
+
* role.setUnicodeEmoji('🤖')
|
392
|
+
* .then(updated => console.log(`Set unicode emoji for the role to ${updated.unicodeEmoji}`))
|
393
|
+
* .catch(console.error);
|
394
|
+
*/
|
395
|
+
setUnicodeEmoji(unicodeEmoji, reason) {
|
396
|
+
return this.edit({ unicodeEmoji }, reason);
|
397
|
+
}
|
398
|
+
|
399
|
+
/**
|
400
|
+
* Options used to set the position of a role.
|
401
|
+
* @typedef {Object} SetRolePositionOptions
|
402
|
+
* @property {boolean} [relative=false] Whether to change the position relative to its current value or not
|
403
|
+
* @property {string} [reason] The reason for changing the position
|
404
|
+
*/
|
405
|
+
|
406
|
+
/**
|
407
|
+
* Sets the new position of the role.
|
408
|
+
* @param {number} position The new position for the role
|
409
|
+
* @param {SetRolePositionOptions} [options] Options for setting the position
|
410
|
+
* @returns {Promise<Role>}
|
411
|
+
* @example
|
412
|
+
* // Set the position of the role
|
413
|
+
* role.setPosition(1)
|
414
|
+
* .then(updated => console.log(`Role position: ${updated.position}`))
|
415
|
+
* .catch(console.error);
|
416
|
+
*/
|
417
|
+
setPosition(position, options = {}) {
|
418
|
+
return this.guild.roles.setPosition(this, position, options);
|
419
|
+
}
|
420
|
+
|
421
|
+
/**
|
422
|
+
* Deletes the role.
|
423
|
+
* @param {string} [reason] Reason for deleting this role
|
424
|
+
* @returns {Promise<Role>}
|
425
|
+
* @example
|
426
|
+
* // Delete a role
|
427
|
+
* role.delete('The role needed to go')
|
428
|
+
* .then(deleted => console.log(`Deleted role ${deleted.name}`))
|
429
|
+
* .catch(console.error);
|
430
|
+
*/
|
431
|
+
async delete(reason) {
|
432
|
+
await this.guild.roles.delete(this.id, reason);
|
433
|
+
return this;
|
434
|
+
}
|
435
|
+
|
436
|
+
/**
|
437
|
+
* A link to the role's icon
|
438
|
+
* @param {StaticImageURLOptions} [options={}] Options for the image URL
|
439
|
+
* @returns {?string}
|
440
|
+
*/
|
441
|
+
iconURL({ format, size } = {}) {
|
442
|
+
if (!this.icon) return null;
|
443
|
+
return this.client.rest.cdn.RoleIcon(this.id, this.icon, format, size);
|
444
|
+
}
|
445
|
+
|
446
|
+
/**
|
447
|
+
* Whether this role equals another role. It compares all properties, so for most operations
|
448
|
+
* it is advisable to just compare `role.id === role2.id` as it is much faster and is often
|
449
|
+
* what most users need.
|
450
|
+
* @param {Role} role Role to compare with
|
451
|
+
* @returns {boolean}
|
452
|
+
*/
|
453
|
+
equals(role) {
|
454
|
+
return (
|
455
|
+
role &&
|
456
|
+
this.id === role.id &&
|
457
|
+
this.name === role.name &&
|
458
|
+
this.color === role.color &&
|
459
|
+
this.hoist === role.hoist &&
|
460
|
+
this.position === role.position &&
|
461
|
+
this.permissions.bitfield === role.permissions.bitfield &&
|
462
|
+
this.managed === role.managed &&
|
463
|
+
this.icon === role.icon &&
|
464
|
+
this.unicodeEmoji === role.unicodeEmoji
|
465
|
+
);
|
466
|
+
}
|
467
|
+
|
468
|
+
/**
|
469
|
+
* When concatenated with a string, this automatically returns the role's mention instead of the Role object.
|
470
|
+
* @returns {string}
|
471
|
+
* @example
|
472
|
+
* // Logs: Role: <@&123456789012345678>
|
473
|
+
* console.log(`Role: ${role}`);
|
474
|
+
*/
|
475
|
+
toString() {
|
476
|
+
if (this.id === this.guild.id) return '@everyone';
|
477
|
+
return `<@&${this.id}>`;
|
478
|
+
}
|
479
|
+
|
480
|
+
toJSON() {
|
481
|
+
return {
|
482
|
+
...super.toJSON({ createdTimestamp: true }),
|
483
|
+
permissions: this.permissions.toJSON(),
|
484
|
+
};
|
485
|
+
}
|
486
|
+
|
487
|
+
/**
|
488
|
+
* Compares the positions of two roles.
|
489
|
+
* @param {Role} role1 First role to compare
|
490
|
+
* @param {Role} role2 Second role to compare
|
491
|
+
* @returns {number} Negative number if the first role's position is lower (second role's is higher),
|
492
|
+
* positive number if the first's is higher (second's is lower), 0 if equal
|
493
|
+
* @deprecated Use {@link RoleManager#comparePositions} instead.
|
494
|
+
*/
|
495
|
+
static comparePositions(role1, role2) {
|
496
|
+
if (!deprecationEmittedForComparePositions) {
|
497
|
+
process.emitWarning(
|
498
|
+
'The Role.comparePositions method is deprecated. Use RoleManager#comparePositions instead.',
|
499
|
+
'DeprecationWarning',
|
500
|
+
);
|
501
|
+
|
502
|
+
deprecationEmittedForComparePositions = true;
|
503
|
+
}
|
504
|
+
|
505
|
+
return role1.guild.roles.comparePositions(role1, role2);
|
506
|
+
}
|
507
|
+
}
|
508
|
+
|
509
|
+
exports.Role = Role;
|
510
|
+
exports.deletedRoles = deletedRoles;
|
511
|
+
|
512
|
+
/**
|
513
|
+
* @external APIRole
|
514
|
+
* @see {@link https://discord.com/developers/docs/topics/permissions#role-object}
|
515
|
+
*/
|
@@ -0,0 +1,170 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const { Collection } = require('@discordjs/collection');
|
4
|
+
const MessageComponentInteraction = require('./MessageComponentInteraction');
|
5
|
+
const { Events } = require('../util/Constants');
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Represents any select menu interaction.
|
9
|
+
* @extends {MessageComponentInteraction}
|
10
|
+
*/
|
11
|
+
class SelectMenuInteraction extends MessageComponentInteraction {
|
12
|
+
constructor(client, data) {
|
13
|
+
super(client, data);
|
14
|
+
|
15
|
+
/**
|
16
|
+
* The values selected, if the component which was interacted with was a select menu
|
17
|
+
* @type {string[]}
|
18
|
+
*/
|
19
|
+
this.values = data.data.values ?? [];
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
module.exports.SelectMenuInteraction = SelectMenuInteraction;
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Represents a CHANNEL_SELECT interaction.
|
27
|
+
* @extends {SelectMenuInteraction}
|
28
|
+
*/
|
29
|
+
class ChannelSelectInteraction extends SelectMenuInteraction {
|
30
|
+
constructor(client, data) {
|
31
|
+
super(client, data);
|
32
|
+
|
33
|
+
const { channels } = data.data.resolved ?? {};
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Collection of the selected channels
|
37
|
+
* @type {Collection<Snowflake, Channel|APIChannel>}
|
38
|
+
*/
|
39
|
+
this.channels = new Collection();
|
40
|
+
for (const channel of Object.values(channels)) {
|
41
|
+
this.channel.set(channel.id, this.client.channels._add(channel));
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
module.exports.ChannelSelectInteraction = ChannelSelectInteraction;
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Represents a ROLE_SELECT interaction.
|
50
|
+
* @extends {SelectMenuInteraction}
|
51
|
+
*/
|
52
|
+
class RoleSelectInteraction extends SelectMenuInteraction {
|
53
|
+
constructor(client, data) {
|
54
|
+
super(client, data);
|
55
|
+
|
56
|
+
const { roles } = data.data.resolved ?? {};
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Collection of the selected roles
|
60
|
+
* @type {Collection<Snowflake, Role|APIRole>}
|
61
|
+
*/
|
62
|
+
this.roles = new Collection();
|
63
|
+
for (const role of Object.values(roles)) {
|
64
|
+
this.roles.set(role.id, this.guild?.roles._add(role) ?? role);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
module.exports.RoleSelectInteraction = RoleSelectInteraction;
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Represents a USER_SELECT interaction.
|
73
|
+
* @extends {SelectMenuInteraction}
|
74
|
+
*/
|
75
|
+
class UserSelectInteraction extends SelectMenuInteraction {
|
76
|
+
constructor(client, data) {
|
77
|
+
super(client, data);
|
78
|
+
|
79
|
+
const { members, users } = data.data.resolved ?? {};
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Collection of the selected users
|
83
|
+
* @type {Collection<Snowflake, User>}
|
84
|
+
*/
|
85
|
+
this.users = new Collection();
|
86
|
+
for (const user of Object.values(users)) {
|
87
|
+
this.users.set(user.id, this.client.users._add(user));
|
88
|
+
}
|
89
|
+
|
90
|
+
if (members) {
|
91
|
+
/**
|
92
|
+
* Collection of the selected members
|
93
|
+
* @type {Collection<Snowflake, GuildMember|APIGuildMember>}
|
94
|
+
*/
|
95
|
+
this.members = new Collection();
|
96
|
+
for (const [id, member] of Object.entries(members)) {
|
97
|
+
const user = users[id];
|
98
|
+
if (!user) {
|
99
|
+
this.client.emit(Events.DEBUG, `[SelectMenuInteraction] Received a member without a user, skipping ${id}`);
|
100
|
+
continue;
|
101
|
+
}
|
102
|
+
this.members.set(id, this.guild?.members._add({ user, ...member }) ?? { user, ...member });
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
module.exports.UserSelectInteraction = UserSelectInteraction;
|
109
|
+
|
110
|
+
/**
|
111
|
+
* Represents a MENTIONABLE_SELECT interaction.
|
112
|
+
* @extends {SelectMenuInteraction}
|
113
|
+
*/
|
114
|
+
class MentionableSelectInteraction extends SelectMenuInteraction {
|
115
|
+
constructor(client, data) {
|
116
|
+
super(client, data);
|
117
|
+
|
118
|
+
const { members, users, roles, channels } = data.data.resolved ?? {};
|
119
|
+
|
120
|
+
if (channels) {
|
121
|
+
/**
|
122
|
+
* Collection of the selected channels
|
123
|
+
* @type {Collection<Snowflake, Channel|APIChannel>}
|
124
|
+
*/
|
125
|
+
this.channels = new Collection();
|
126
|
+
for (const channel of Object.values(channels)) {
|
127
|
+
this.channels.set(channel.id, this.client?.channels._add(channel) ?? channel);
|
128
|
+
}
|
129
|
+
}
|
130
|
+
|
131
|
+
if (members) {
|
132
|
+
/**
|
133
|
+
* Collection of the selected members
|
134
|
+
* @type {Collection<Snowflake, GuildMember|APIGuildMember>}
|
135
|
+
*/
|
136
|
+
this.members = new Collection();
|
137
|
+
for (const [id, member] of Object.entries(members)) {
|
138
|
+
const user = users[id];
|
139
|
+
if (!user) {
|
140
|
+
this.client.emit(Events.DEBUG, `[SelectMenuInteraction] Received a member without a user, skipping ${id}`);
|
141
|
+
continue;
|
142
|
+
}
|
143
|
+
this.members.set(id, this.guild?.members._add({ user, ...member }) ?? { user, ...member });
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
if (roles) {
|
148
|
+
/**
|
149
|
+
* Collection of the selected roles
|
150
|
+
* @type {Collection<Snowflake, Role|APIRole>}
|
151
|
+
*/
|
152
|
+
this.roles = new Collection();
|
153
|
+
for (const role of Object.values(roles)) {
|
154
|
+
this.roles.set(role.id, this.guild?.roles._add(role) ?? role);
|
155
|
+
}
|
156
|
+
}
|
157
|
+
|
158
|
+
if (users) {
|
159
|
+
/**
|
160
|
+
* Collection of the selected users
|
161
|
+
* @type {Collection<Snowflake, User>}
|
162
|
+
*/
|
163
|
+
this.users = new Collection();
|
164
|
+
for (const user of Object.values(users)) {
|
165
|
+
this.users.set(user.id, this.client.users._add(user));
|
166
|
+
}
|
167
|
+
}
|
168
|
+
}
|
169
|
+
}
|
170
|
+
module.exports.MentionableSelectInteraction = MentionableSelectInteraction;
|