@velliajs/discord 1.0.2 → 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/README.md +4 -11
- package/package.json +3 -3
- 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
|
@@ -5,100 +5,53 @@ const { Emoji } = require('./Emoji');
|
|
|
5
5
|
const ActivityFlagsBitField = require('../util/ActivityFlagsBitField');
|
|
6
6
|
const { flatten } = require('../util/Util');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The status of this presence:
|
|
17
|
-
* * **`online`** - user is online
|
|
18
|
-
* * **`idle`** - user is AFK
|
|
19
|
-
* * **`offline`** - user is offline or invisible
|
|
20
|
-
* * **`dnd`** - user is in Do Not Disturb
|
|
21
|
-
* @typedef {string} PresenceStatus
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The status of this presence:
|
|
26
|
-
* * **`online`** - user is online
|
|
27
|
-
* * **`idle`** - user is AFK
|
|
28
|
-
* * **`dnd`** - user is in Do Not Disturb
|
|
29
|
-
* @typedef {string} ClientPresenceStatus
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Represents a user's presence.
|
|
34
|
-
* @extends {Base}
|
|
35
|
-
*/
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
36
15
|
class Presence extends Base {
|
|
37
16
|
constructor(client, data = {}) {
|
|
38
17
|
super(client);
|
|
39
18
|
|
|
40
|
-
|
|
41
|
-
* The presence's user id
|
|
42
|
-
* @type {Snowflake}
|
|
43
|
-
*/
|
|
19
|
+
|
|
44
20
|
this.userId = data.user.id;
|
|
45
21
|
|
|
46
|
-
|
|
47
|
-
* The guild this presence is in
|
|
48
|
-
* @type {?Guild}
|
|
49
|
-
*/
|
|
22
|
+
|
|
50
23
|
this.guild = data.guild ?? null;
|
|
51
24
|
|
|
52
25
|
this._patch(data);
|
|
53
26
|
}
|
|
54
27
|
|
|
55
|
-
|
|
56
|
-
* The user of this presence
|
|
57
|
-
* @type {?User}
|
|
58
|
-
* @readonly
|
|
59
|
-
*/
|
|
28
|
+
|
|
60
29
|
get user() {
|
|
61
30
|
return this.client.users.resolve(this.userId);
|
|
62
31
|
}
|
|
63
32
|
|
|
64
|
-
|
|
65
|
-
* The member of this presence
|
|
66
|
-
* @type {?GuildMember}
|
|
67
|
-
* @readonly
|
|
68
|
-
*/
|
|
33
|
+
|
|
69
34
|
get member() {
|
|
70
35
|
return this.guild.members.resolve(this.userId);
|
|
71
36
|
}
|
|
72
37
|
|
|
73
38
|
_patch(data) {
|
|
74
39
|
if ('status' in data) {
|
|
75
|
-
|
|
76
|
-
* The status of this presence
|
|
77
|
-
* @type {PresenceStatus}
|
|
78
|
-
*/
|
|
40
|
+
|
|
79
41
|
this.status = data.status;
|
|
80
42
|
} else {
|
|
81
43
|
this.status ??= 'offline';
|
|
82
44
|
}
|
|
83
45
|
|
|
84
46
|
if ('activities' in data) {
|
|
85
|
-
|
|
86
|
-
* The activities of this presence
|
|
87
|
-
* @type {Activity[]}
|
|
88
|
-
*/
|
|
47
|
+
|
|
89
48
|
this.activities = data.activities.map(activity => new Activity(this, activity));
|
|
90
49
|
} else {
|
|
91
50
|
this.activities ??= [];
|
|
92
51
|
}
|
|
93
52
|
|
|
94
53
|
if ('client_status' in data) {
|
|
95
|
-
|
|
96
|
-
* The devices this presence is on
|
|
97
|
-
* @type {?Object}
|
|
98
|
-
* @property {?ClientPresenceStatus} web The current presence in the web application
|
|
99
|
-
* @property {?ClientPresenceStatus} mobile The current presence in the mobile application
|
|
100
|
-
* @property {?ClientPresenceStatus} desktop The current presence in the desktop application
|
|
101
|
-
*/
|
|
54
|
+
|
|
102
55
|
this.clientStatus = data.client_status;
|
|
103
56
|
} else {
|
|
104
57
|
this.clientStatus ??= null;
|
|
@@ -113,11 +66,7 @@ class Presence extends Base {
|
|
|
113
66
|
return clone;
|
|
114
67
|
}
|
|
115
68
|
|
|
116
|
-
|
|
117
|
-
* Whether this presence is equal to another.
|
|
118
|
-
* @param {Presence} presence The presence to compare with
|
|
119
|
-
* @returns {boolean}
|
|
120
|
-
*/
|
|
69
|
+
|
|
121
70
|
equals(presence) {
|
|
122
71
|
return (
|
|
123
72
|
this === presence ||
|
|
@@ -136,66 +85,33 @@ class Presence extends Base {
|
|
|
136
85
|
}
|
|
137
86
|
}
|
|
138
87
|
|
|
139
|
-
|
|
140
|
-
* Represents an activity that is part of a user's presence.
|
|
141
|
-
*/
|
|
88
|
+
|
|
142
89
|
class Activity {
|
|
143
90
|
constructor(presence, data) {
|
|
144
|
-
|
|
145
|
-
* The presence of the Activity
|
|
146
|
-
* @type {Presence}
|
|
147
|
-
* @readonly
|
|
148
|
-
* @name Activity#presence
|
|
149
|
-
*/
|
|
91
|
+
|
|
150
92
|
Object.defineProperty(this, 'presence', { value: presence });
|
|
151
93
|
|
|
152
|
-
|
|
153
|
-
* The activity's name
|
|
154
|
-
* @type {string}
|
|
155
|
-
*/
|
|
94
|
+
|
|
156
95
|
this.name = data.name;
|
|
157
96
|
|
|
158
|
-
|
|
159
|
-
* The activity status's type
|
|
160
|
-
* @type {ActivityType}
|
|
161
|
-
*/
|
|
97
|
+
|
|
162
98
|
this.type = data.type;
|
|
163
99
|
|
|
164
|
-
|
|
165
|
-
* If the activity is being streamed, a link to the stream
|
|
166
|
-
* @type {?string}
|
|
167
|
-
*/
|
|
100
|
+
|
|
168
101
|
this.url = data.url ?? null;
|
|
169
102
|
|
|
170
|
-
|
|
171
|
-
* Details about the activity
|
|
172
|
-
* @type {?string}
|
|
173
|
-
*/
|
|
103
|
+
|
|
174
104
|
this.details = data.details ?? null;
|
|
175
105
|
|
|
176
|
-
|
|
177
|
-
* State of the activity
|
|
178
|
-
* @type {?string}
|
|
179
|
-
*/
|
|
106
|
+
|
|
180
107
|
this.state = data.state ?? null;
|
|
181
108
|
|
|
182
|
-
|
|
183
|
-
* The id of the application associated with this activity
|
|
184
|
-
* @type {?Snowflake}
|
|
185
|
-
*/
|
|
109
|
+
|
|
186
110
|
this.applicationId = data.application_id ?? null;
|
|
187
111
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
* @property {?Date} start When the activity started
|
|
192
|
-
* @property {?Date} end When the activity will end
|
|
193
|
-
*/
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Timestamps for the activity
|
|
197
|
-
* @type {?ActivityTimestamps}
|
|
198
|
-
*/
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
199
115
|
this.timestamps = data.timestamps
|
|
200
116
|
? {
|
|
201
117
|
start: data.timestamps.start ? new Date(Number(data.timestamps.start)) : null,
|
|
@@ -203,55 +119,28 @@ class Activity {
|
|
|
203
119
|
}
|
|
204
120
|
: null;
|
|
205
121
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
* @property {?string} id The party's id
|
|
210
|
-
* @property {number[]} size Size of the party as `[current, max]`
|
|
211
|
-
*/
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Party of the activity
|
|
215
|
-
* @type {?ActivityParty}
|
|
216
|
-
*/
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
217
125
|
this.party = data.party ?? null;
|
|
218
126
|
|
|
219
|
-
|
|
220
|
-
* Assets for rich presence
|
|
221
|
-
* @type {?RichPresenceAssets}
|
|
222
|
-
*/
|
|
127
|
+
|
|
223
128
|
this.assets = data.assets ? new RichPresenceAssets(this, data.assets) : null;
|
|
224
129
|
|
|
225
|
-
|
|
226
|
-
* Flags that describe the activity
|
|
227
|
-
* @type {Readonly<ActivityFlagsBitField>}
|
|
228
|
-
*/
|
|
130
|
+
|
|
229
131
|
this.flags = new ActivityFlagsBitField(data.flags).freeze();
|
|
230
132
|
|
|
231
|
-
|
|
232
|
-
* Emoji for a custom activity
|
|
233
|
-
* @type {?Emoji}
|
|
234
|
-
*/
|
|
133
|
+
|
|
235
134
|
this.emoji = data.emoji ? new Emoji(presence.client, data.emoji) : null;
|
|
236
135
|
|
|
237
|
-
|
|
238
|
-
* The labels of the buttons of this rich presence
|
|
239
|
-
* @type {string[]}
|
|
240
|
-
*/
|
|
136
|
+
|
|
241
137
|
this.buttons = data.buttons ?? [];
|
|
242
138
|
|
|
243
|
-
|
|
244
|
-
* Creation date of the activity
|
|
245
|
-
* @type {number}
|
|
246
|
-
*/
|
|
139
|
+
|
|
247
140
|
this.createdTimestamp = data.created_at;
|
|
248
141
|
}
|
|
249
142
|
|
|
250
|
-
|
|
251
|
-
* Whether this activity is equal to another activity.
|
|
252
|
-
* @param {Activity} activity The activity to compare with
|
|
253
|
-
* @returns {boolean}
|
|
254
|
-
*/
|
|
143
|
+
|
|
255
144
|
equals(activity) {
|
|
256
145
|
return (
|
|
257
146
|
this === activity ||
|
|
@@ -266,19 +155,12 @@ class Activity {
|
|
|
266
155
|
);
|
|
267
156
|
}
|
|
268
157
|
|
|
269
|
-
|
|
270
|
-
* The time the activity was created at
|
|
271
|
-
* @type {Date}
|
|
272
|
-
* @readonly
|
|
273
|
-
*/
|
|
158
|
+
|
|
274
159
|
get createdAt() {
|
|
275
160
|
return new Date(this.createdTimestamp);
|
|
276
161
|
}
|
|
277
162
|
|
|
278
|
-
|
|
279
|
-
* When concatenated with a string, this automatically returns the activity's name instead of the Activity object.
|
|
280
|
-
* @returns {string}
|
|
281
|
-
*/
|
|
163
|
+
|
|
282
164
|
toString() {
|
|
283
165
|
return this.name;
|
|
284
166
|
}
|
|
@@ -288,49 +170,26 @@ class Activity {
|
|
|
288
170
|
}
|
|
289
171
|
}
|
|
290
172
|
|
|
291
|
-
|
|
292
|
-
* Assets for a rich presence
|
|
293
|
-
*/
|
|
173
|
+
|
|
294
174
|
class RichPresenceAssets {
|
|
295
175
|
constructor(activity, assets) {
|
|
296
|
-
|
|
297
|
-
* The activity of the RichPresenceAssets
|
|
298
|
-
* @type {Activity}
|
|
299
|
-
* @readonly
|
|
300
|
-
* @name RichPresenceAssets#activity
|
|
301
|
-
*/
|
|
176
|
+
|
|
302
177
|
Object.defineProperty(this, 'activity', { value: activity });
|
|
303
178
|
|
|
304
|
-
|
|
305
|
-
* Hover text for the large image
|
|
306
|
-
* @type {?string}
|
|
307
|
-
*/
|
|
179
|
+
|
|
308
180
|
this.largeText = assets.large_text ?? null;
|
|
309
181
|
|
|
310
|
-
|
|
311
|
-
* Hover text for the small image
|
|
312
|
-
* @type {?string}
|
|
313
|
-
*/
|
|
182
|
+
|
|
314
183
|
this.smallText = assets.small_text ?? null;
|
|
315
184
|
|
|
316
|
-
|
|
317
|
-
* The large image asset's id
|
|
318
|
-
* @type {?Snowflake}
|
|
319
|
-
*/
|
|
185
|
+
|
|
320
186
|
this.largeImage = assets.large_image ?? null;
|
|
321
187
|
|
|
322
|
-
|
|
323
|
-
* The small image asset's id
|
|
324
|
-
* @type {?Snowflake}
|
|
325
|
-
*/
|
|
188
|
+
|
|
326
189
|
this.smallImage = assets.small_image ?? null;
|
|
327
190
|
}
|
|
328
191
|
|
|
329
|
-
|
|
330
|
-
* Gets the URL of the small image asset
|
|
331
|
-
* @param {ImageURLOptions} [options={}] Options for the image URL
|
|
332
|
-
* @returns {?string}
|
|
333
|
-
*/
|
|
192
|
+
|
|
334
193
|
smallImageURL(options = {}) {
|
|
335
194
|
if (!this.smallImage) return null;
|
|
336
195
|
if (this.smallImage.includes(':')) {
|
|
@@ -346,11 +205,7 @@ class RichPresenceAssets {
|
|
|
346
205
|
return this.activity.presence.client.rest.cdn.appAsset(this.activity.applicationId, this.smallImage, options);
|
|
347
206
|
}
|
|
348
207
|
|
|
349
|
-
|
|
350
|
-
* Gets the URL of the large image asset
|
|
351
|
-
* @param {ImageURLOptions} [options={}] Options for the image URL
|
|
352
|
-
* @returns {?string}
|
|
353
|
-
*/
|
|
208
|
+
|
|
354
209
|
largeImageURL(options = {}) {
|
|
355
210
|
if (!this.largeImage) return null;
|
|
356
211
|
if (this.largeImage.includes(':')) {
|
|
@@ -4,46 +4,21 @@ const { Collection } = require('@discordjs/collection');
|
|
|
4
4
|
const Collector = require('./interfaces/Collector');
|
|
5
5
|
const Events = require('../util/Events');
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* @property {number} maxEmojis The maximum number of emojis to collect
|
|
11
|
-
* @property {number} maxUsers The maximum number of users to react
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Collects reactions on messages.
|
|
16
|
-
* Will automatically stop if the message ({@link Client#event:messageDelete messageDelete} or
|
|
17
|
-
* {@link Client#event:messageDeleteBulk messageDeleteBulk}),
|
|
18
|
-
* channel ({@link Client#event:channelDelete channelDelete}),
|
|
19
|
-
* thread ({@link Client#event:threadDelete threadDelete}), or
|
|
20
|
-
* guild ({@link Client#event:guildDelete guildDelete}) is deleted.
|
|
21
|
-
* @extends {Collector}
|
|
22
|
-
*/
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
23
10
|
class ReactionCollector extends Collector {
|
|
24
|
-
|
|
25
|
-
* @param {Message} message The message upon which to collect reactions
|
|
26
|
-
* @param {ReactionCollectorOptions} [options={}] The options to apply to this collector
|
|
27
|
-
*/
|
|
11
|
+
|
|
28
12
|
constructor(message, options = {}) {
|
|
29
13
|
super(message.client, options);
|
|
30
14
|
|
|
31
|
-
|
|
32
|
-
* The message upon which to collect reactions
|
|
33
|
-
* @type {Message}
|
|
34
|
-
*/
|
|
15
|
+
|
|
35
16
|
this.message = message;
|
|
36
17
|
|
|
37
|
-
|
|
38
|
-
* The users that have reacted to this message
|
|
39
|
-
* @type {Collection}
|
|
40
|
-
*/
|
|
18
|
+
|
|
41
19
|
this.users = new Collection();
|
|
42
20
|
|
|
43
|
-
|
|
44
|
-
* The total number of reactions collected
|
|
45
|
-
* @type {number}
|
|
46
|
-
*/
|
|
21
|
+
|
|
47
22
|
this.total = 0;
|
|
48
23
|
|
|
49
24
|
this.empty = this.empty.bind(this);
|
|
@@ -79,14 +54,7 @@ class ReactionCollector extends Collector {
|
|
|
79
54
|
});
|
|
80
55
|
|
|
81
56
|
this.on('collect', (reaction, user) => {
|
|
82
|
-
|
|
83
|
-
* Emitted whenever a reaction is newly created on a message. Will emit only when a new reaction is
|
|
84
|
-
* added to the message, as opposed to {@link Collector#collect} which will
|
|
85
|
-
* be emitted even when a reaction has already been added to the message.
|
|
86
|
-
* @event ReactionCollector#create
|
|
87
|
-
* @param {MessageReaction} reaction The reaction that was added
|
|
88
|
-
* @param {User} user The user that added the reaction
|
|
89
|
-
*/
|
|
57
|
+
|
|
90
58
|
if (reaction.count === 1) {
|
|
91
59
|
this.emit('create', reaction, user);
|
|
92
60
|
}
|
|
@@ -100,55 +68,27 @@ class ReactionCollector extends Collector {
|
|
|
100
68
|
});
|
|
101
69
|
}
|
|
102
70
|
|
|
103
|
-
|
|
104
|
-
* Handles an incoming reaction for possible collection.
|
|
105
|
-
* @param {MessageReaction} reaction The reaction to possibly collect
|
|
106
|
-
* @param {User} user The user that added the reaction
|
|
107
|
-
* @returns {?(Snowflake|string)}
|
|
108
|
-
* @private
|
|
109
|
-
*/
|
|
71
|
+
|
|
110
72
|
collect(reaction) {
|
|
111
|
-
|
|
112
|
-
* Emitted whenever a reaction is collected.
|
|
113
|
-
* @event ReactionCollector#collect
|
|
114
|
-
* @param {MessageReaction} reaction The reaction that was collected
|
|
115
|
-
* @param {User} user The user that added the reaction
|
|
116
|
-
*/
|
|
73
|
+
|
|
117
74
|
if (reaction.message.id !== this.message.id) return null;
|
|
118
75
|
|
|
119
76
|
return ReactionCollector.key(reaction);
|
|
120
77
|
}
|
|
121
78
|
|
|
122
|
-
|
|
123
|
-
* Handles a reaction deletion for possible disposal.
|
|
124
|
-
* @param {MessageReaction} reaction The reaction to possibly dispose of
|
|
125
|
-
* @param {User} user The user that removed the reaction
|
|
126
|
-
* @returns {?(Snowflake|string)}
|
|
127
|
-
*/
|
|
79
|
+
|
|
128
80
|
dispose(reaction, user) {
|
|
129
|
-
|
|
130
|
-
* Emitted when the reaction had all the users removed and the `dispose` option is set to true.
|
|
131
|
-
* @event ReactionCollector#dispose
|
|
132
|
-
* @param {MessageReaction} reaction The reaction that was disposed of
|
|
133
|
-
* @param {User} user The user that removed the reaction
|
|
134
|
-
*/
|
|
81
|
+
|
|
135
82
|
if (reaction.message.id !== this.message.id) return null;
|
|
136
83
|
|
|
137
|
-
|
|
138
|
-
* Emitted when the reaction had one user removed and the `dispose` option is set to true.
|
|
139
|
-
* @event ReactionCollector#remove
|
|
140
|
-
* @param {MessageReaction} reaction The reaction that was removed
|
|
141
|
-
* @param {User} user The user that removed the reaction
|
|
142
|
-
*/
|
|
84
|
+
|
|
143
85
|
if (this.collected.has(ReactionCollector.key(reaction)) && this.users.has(user.id)) {
|
|
144
86
|
this.emit('remove', reaction, user);
|
|
145
87
|
}
|
|
146
88
|
return reaction.count ? null : ReactionCollector.key(reaction);
|
|
147
89
|
}
|
|
148
90
|
|
|
149
|
-
|
|
150
|
-
* Empties this reaction collector.
|
|
151
|
-
*/
|
|
91
|
+
|
|
152
92
|
empty() {
|
|
153
93
|
this.total = 0;
|
|
154
94
|
this.collected.clear();
|
|
@@ -156,11 +96,7 @@ class ReactionCollector extends Collector {
|
|
|
156
96
|
this.checkEnd();
|
|
157
97
|
}
|
|
158
98
|
|
|
159
|
-
|
|
160
|
-
* The reason this collector has ended with, or null if it hasn't ended yet
|
|
161
|
-
* @type {?string}
|
|
162
|
-
* @readonly
|
|
163
|
-
*/
|
|
99
|
+
|
|
164
100
|
get endReason() {
|
|
165
101
|
if (this.options.max && this.total >= this.options.max) return 'limit';
|
|
166
102
|
if (this.options.maxEmojis && this.collected.size >= this.options.maxEmojis) return 'emojiLimit';
|
|
@@ -168,59 +104,35 @@ class ReactionCollector extends Collector {
|
|
|
168
104
|
return super.endReason;
|
|
169
105
|
}
|
|
170
106
|
|
|
171
|
-
|
|
172
|
-
* Handles checking if the message has been deleted, and if so, stops the collector with the reason 'messageDelete'.
|
|
173
|
-
* @private
|
|
174
|
-
* @param {Message} message The message that was deleted
|
|
175
|
-
* @returns {void}
|
|
176
|
-
*/
|
|
107
|
+
|
|
177
108
|
_handleMessageDeletion(message) {
|
|
178
109
|
if (message.id === this.message.id) {
|
|
179
110
|
this.stop('messageDelete');
|
|
180
111
|
}
|
|
181
112
|
}
|
|
182
113
|
|
|
183
|
-
|
|
184
|
-
* Handles checking if the channel has been deleted, and if so, stops the collector with the reason 'channelDelete'.
|
|
185
|
-
* @private
|
|
186
|
-
* @param {GuildChannel} channel The channel that was deleted
|
|
187
|
-
* @returns {void}
|
|
188
|
-
*/
|
|
114
|
+
|
|
189
115
|
_handleChannelDeletion(channel) {
|
|
190
116
|
if (channel.id === this.message.channelId || channel.threads?.cache.has(this.message.channelId)) {
|
|
191
117
|
this.stop('channelDelete');
|
|
192
118
|
}
|
|
193
119
|
}
|
|
194
120
|
|
|
195
|
-
|
|
196
|
-
* Handles checking if the thread has been deleted, and if so, stops the collector with the reason 'threadDelete'.
|
|
197
|
-
* @private
|
|
198
|
-
* @param {ThreadChannel} thread The thread that was deleted
|
|
199
|
-
* @returns {void}
|
|
200
|
-
*/
|
|
121
|
+
|
|
201
122
|
_handleThreadDeletion(thread) {
|
|
202
123
|
if (thread.id === this.message.channelId) {
|
|
203
124
|
this.stop('threadDelete');
|
|
204
125
|
}
|
|
205
126
|
}
|
|
206
127
|
|
|
207
|
-
|
|
208
|
-
* Handles checking if the guild has been deleted, and if so, stops the collector with the reason 'guildDelete'.
|
|
209
|
-
* @private
|
|
210
|
-
* @param {Guild} guild The guild that was deleted
|
|
211
|
-
* @returns {void}
|
|
212
|
-
*/
|
|
128
|
+
|
|
213
129
|
_handleGuildDeletion(guild) {
|
|
214
130
|
if (guild.id === this.message.guild?.id) {
|
|
215
131
|
this.stop('guildDelete');
|
|
216
132
|
}
|
|
217
133
|
}
|
|
218
134
|
|
|
219
|
-
|
|
220
|
-
* Gets the collector key for a reaction.
|
|
221
|
-
* @param {MessageReaction} reaction The message reaction to get the key for
|
|
222
|
-
* @returns {Snowflake|string}
|
|
223
|
-
*/
|
|
135
|
+
|
|
224
136
|
static key(reaction) {
|
|
225
137
|
return reaction.emoji.id ?? reaction.emoji.name;
|
|
226
138
|
}
|
|
@@ -3,19 +3,11 @@
|
|
|
3
3
|
const { Emoji } = require('./Emoji');
|
|
4
4
|
const { flatten } = require('../util/Util');
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
* Represents a limited emoji set used for both custom and unicode emojis. Custom emojis
|
|
8
|
-
* will use this class opposed to the Emoji class when the client doesn't know enough
|
|
9
|
-
* information about them.
|
|
10
|
-
* @extends {Emoji}
|
|
11
|
-
*/
|
|
6
|
+
|
|
12
7
|
class ReactionEmoji extends Emoji {
|
|
13
8
|
constructor(reaction, emoji) {
|
|
14
9
|
super(reaction.message.client, emoji);
|
|
15
|
-
|
|
16
|
-
* The message reaction this emoji refers to
|
|
17
|
-
* @type {MessageReaction}
|
|
18
|
-
*/
|
|
10
|
+
|
|
19
11
|
this.reaction = reaction;
|
|
20
12
|
}
|
|
21
13
|
|