@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
|
@@ -6,17 +6,9 @@ const Base = require('./Base');
|
|
|
6
6
|
const DataResolver = require('../util/DataResolver');
|
|
7
7
|
const Events = require('../util/Events');
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
* Represents the template for a guild.
|
|
11
|
-
* @extends {Base}
|
|
12
|
-
*/
|
|
9
|
+
|
|
13
10
|
class GuildTemplate extends Base {
|
|
14
|
-
|
|
15
|
-
* A regular expression that matches guild template links.
|
|
16
|
-
* The `code` group property is present on the `exec()` result of this expression.
|
|
17
|
-
* @type {RegExp}
|
|
18
|
-
* @memberof GuildTemplate
|
|
19
|
-
*/
|
|
11
|
+
|
|
20
12
|
static GuildTemplatesPattern = /discord(?:app)?\.(?:com\/template|new)\/(?<code>[\w-]{2,255})/i;
|
|
21
13
|
|
|
22
14
|
constructor(client, data) {
|
|
@@ -26,101 +18,62 @@ class GuildTemplate extends Base {
|
|
|
26
18
|
|
|
27
19
|
_patch(data) {
|
|
28
20
|
if ('code' in data) {
|
|
29
|
-
|
|
30
|
-
* The unique code of this template
|
|
31
|
-
* @type {string}
|
|
32
|
-
*/
|
|
21
|
+
|
|
33
22
|
this.code = data.code;
|
|
34
23
|
}
|
|
35
24
|
|
|
36
25
|
if ('name' in data) {
|
|
37
|
-
|
|
38
|
-
* The name of this template
|
|
39
|
-
* @type {string}
|
|
40
|
-
*/
|
|
26
|
+
|
|
41
27
|
this.name = data.name;
|
|
42
28
|
}
|
|
43
29
|
|
|
44
30
|
if ('description' in data) {
|
|
45
|
-
|
|
46
|
-
* The description of this template
|
|
47
|
-
* @type {?string}
|
|
48
|
-
*/
|
|
31
|
+
|
|
49
32
|
this.description = data.description;
|
|
50
33
|
}
|
|
51
34
|
|
|
52
35
|
if ('usage_count' in data) {
|
|
53
|
-
|
|
54
|
-
* The amount of times this template has been used
|
|
55
|
-
* @type {number}
|
|
56
|
-
*/
|
|
36
|
+
|
|
57
37
|
this.usageCount = data.usage_count;
|
|
58
38
|
}
|
|
59
39
|
|
|
60
40
|
if ('creator_id' in data) {
|
|
61
|
-
|
|
62
|
-
* The id of the user that created this template
|
|
63
|
-
* @type {Snowflake}
|
|
64
|
-
*/
|
|
41
|
+
|
|
65
42
|
this.creatorId = data.creator_id;
|
|
66
43
|
}
|
|
67
44
|
|
|
68
45
|
if ('creator' in data) {
|
|
69
|
-
|
|
70
|
-
* The user that created this template
|
|
71
|
-
* @type {User}
|
|
72
|
-
*/
|
|
46
|
+
|
|
73
47
|
this.creator = this.client.users._add(data.creator);
|
|
74
48
|
}
|
|
75
49
|
|
|
76
50
|
if ('created_at' in data) {
|
|
77
|
-
|
|
78
|
-
* The timestamp of when this template was created at
|
|
79
|
-
* @type {number}
|
|
80
|
-
*/
|
|
51
|
+
|
|
81
52
|
this.createdTimestamp = Date.parse(data.created_at);
|
|
82
53
|
}
|
|
83
54
|
|
|
84
55
|
if ('updated_at' in data) {
|
|
85
|
-
|
|
86
|
-
* The timestamp of when this template was last synced to the guild
|
|
87
|
-
* @type {number}
|
|
88
|
-
*/
|
|
56
|
+
|
|
89
57
|
this.updatedTimestamp = Date.parse(data.updated_at);
|
|
90
58
|
}
|
|
91
59
|
|
|
92
60
|
if ('source_guild_id' in data) {
|
|
93
|
-
|
|
94
|
-
* The id of the guild that this template belongs to
|
|
95
|
-
* @type {Snowflake}
|
|
96
|
-
*/
|
|
61
|
+
|
|
97
62
|
this.guildId = data.source_guild_id;
|
|
98
63
|
}
|
|
99
64
|
|
|
100
65
|
if ('serialized_source_guild' in data) {
|
|
101
|
-
|
|
102
|
-
* The data of the guild that this template would create
|
|
103
|
-
* @type {APIGuild}
|
|
104
|
-
*/
|
|
66
|
+
|
|
105
67
|
this.serializedGuild = data.serialized_source_guild;
|
|
106
68
|
}
|
|
107
69
|
|
|
108
|
-
|
|
109
|
-
* Whether this template has unsynced changes
|
|
110
|
-
* @type {?boolean}
|
|
111
|
-
*/
|
|
70
|
+
|
|
112
71
|
this.unSynced = 'is_dirty' in data ? Boolean(data.is_dirty) : null;
|
|
113
72
|
|
|
114
73
|
return this;
|
|
115
74
|
}
|
|
116
75
|
|
|
117
|
-
|
|
118
|
-
* Creates a guild based on this template.
|
|
119
|
-
* <warn>This is only available to bots in fewer than 10 guilds.</warn>
|
|
120
|
-
* @param {string} name The name of the guild
|
|
121
|
-
* @param {BufferResolvable|Base64Resolvable} [icon] The icon for the guild
|
|
122
|
-
* @returns {Promise<Guild>}
|
|
123
|
-
*/
|
|
76
|
+
|
|
124
77
|
async createGuild(name, icon) {
|
|
125
78
|
const { client } = this;
|
|
126
79
|
const data = await client.rest.post(Routes.template(this.code), {
|
|
@@ -153,18 +106,9 @@ class GuildTemplate extends Base {
|
|
|
153
106
|
});
|
|
154
107
|
}
|
|
155
108
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
* @property {string} [name] The name of this template
|
|
160
|
-
* @property {string} [description] The description of this template
|
|
161
|
-
*/
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Updates the metadata of this template.
|
|
165
|
-
* @param {GuildTemplateEditOptions} [options] Options for editing the template
|
|
166
|
-
* @returns {Promise<GuildTemplate>}
|
|
167
|
-
*/
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
168
112
|
async edit({ name, description } = {}) {
|
|
169
113
|
const data = await this.client.rest.patch(Routes.guildTemplate(this.guildId, this.code), {
|
|
170
114
|
body: { name, description },
|
|
@@ -172,67 +116,39 @@ class GuildTemplate extends Base {
|
|
|
172
116
|
return this._patch(data);
|
|
173
117
|
}
|
|
174
118
|
|
|
175
|
-
|
|
176
|
-
* Deletes this template.
|
|
177
|
-
* @returns {Promise<GuildTemplate>}
|
|
178
|
-
*/
|
|
119
|
+
|
|
179
120
|
async delete() {
|
|
180
121
|
await this.client.rest.delete(Routes.guildTemplate(this.guildId, this.code));
|
|
181
122
|
return this;
|
|
182
123
|
}
|
|
183
124
|
|
|
184
|
-
|
|
185
|
-
* Syncs this template to the current state of the guild.
|
|
186
|
-
* @returns {Promise<GuildTemplate>}
|
|
187
|
-
*/
|
|
125
|
+
|
|
188
126
|
async sync() {
|
|
189
127
|
const data = await this.client.rest.put(Routes.guildTemplate(this.guildId, this.code));
|
|
190
128
|
return this._patch(data);
|
|
191
129
|
}
|
|
192
130
|
|
|
193
|
-
|
|
194
|
-
* The time when this template was created at
|
|
195
|
-
* @type {Date}
|
|
196
|
-
* @readonly
|
|
197
|
-
*/
|
|
131
|
+
|
|
198
132
|
get createdAt() {
|
|
199
133
|
return new Date(this.createdTimestamp);
|
|
200
134
|
}
|
|
201
135
|
|
|
202
|
-
|
|
203
|
-
* The time when this template was last synced to the guild
|
|
204
|
-
* @type {Date}
|
|
205
|
-
* @readonly
|
|
206
|
-
*/
|
|
136
|
+
|
|
207
137
|
get updatedAt() {
|
|
208
138
|
return new Date(this.updatedTimestamp);
|
|
209
139
|
}
|
|
210
140
|
|
|
211
|
-
|
|
212
|
-
* The guild that this template belongs to
|
|
213
|
-
* @type {?Guild}
|
|
214
|
-
* @readonly
|
|
215
|
-
*/
|
|
141
|
+
|
|
216
142
|
get guild() {
|
|
217
143
|
return this.client.guilds.resolve(this.guildId);
|
|
218
144
|
}
|
|
219
145
|
|
|
220
|
-
|
|
221
|
-
* The URL of this template
|
|
222
|
-
* @type {string}
|
|
223
|
-
* @readonly
|
|
224
|
-
*/
|
|
146
|
+
|
|
225
147
|
get url() {
|
|
226
148
|
return `${RouteBases.template}/${this.code}`;
|
|
227
149
|
}
|
|
228
150
|
|
|
229
|
-
|
|
230
|
-
* When concatenated with a string, this automatically returns the template's code instead of the template object.
|
|
231
|
-
* @returns {string}
|
|
232
|
-
* @example
|
|
233
|
-
* // Logs: Template: FKvmczH2HyUf
|
|
234
|
-
* console.log(`Template: ${guildTemplate}!`);
|
|
235
|
-
*/
|
|
151
|
+
|
|
236
152
|
toString() {
|
|
237
153
|
return this.code;
|
|
238
154
|
}
|
|
@@ -4,127 +4,73 @@ const { Routes } = require('discord-api-types/v10');
|
|
|
4
4
|
const Base = require('./Base');
|
|
5
5
|
const IntegrationApplication = require('./IntegrationApplication');
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The type of an {@link Integration}. This can be:
|
|
16
|
-
* * `twitch`
|
|
17
|
-
* * `youtube`
|
|
18
|
-
* * `discord`
|
|
19
|
-
* * `guild_subscription`
|
|
20
|
-
* @typedef {string} IntegrationType
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Represents a guild integration.
|
|
25
|
-
* @extends {Base}
|
|
26
|
-
*/
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
27
12
|
class Integration extends Base {
|
|
28
13
|
constructor(client, data, guild) {
|
|
29
14
|
super(client);
|
|
30
15
|
|
|
31
|
-
|
|
32
|
-
* The guild this integration belongs to
|
|
33
|
-
* @type {Guild}
|
|
34
|
-
*/
|
|
16
|
+
|
|
35
17
|
this.guild = guild;
|
|
36
18
|
|
|
37
|
-
|
|
38
|
-
* The integration id
|
|
39
|
-
* @type {Snowflake|string}
|
|
40
|
-
*/
|
|
19
|
+
|
|
41
20
|
this.id = data.id;
|
|
42
21
|
|
|
43
|
-
|
|
44
|
-
* The integration name
|
|
45
|
-
* @type {string}
|
|
46
|
-
*/
|
|
22
|
+
|
|
47
23
|
this.name = data.name;
|
|
48
24
|
|
|
49
|
-
|
|
50
|
-
* The integration type
|
|
51
|
-
* @type {IntegrationType}
|
|
52
|
-
*/
|
|
25
|
+
|
|
53
26
|
this.type = data.type;
|
|
54
27
|
|
|
55
|
-
|
|
56
|
-
* Whether this integration is enabled
|
|
57
|
-
* @type {?boolean}
|
|
58
|
-
*/
|
|
28
|
+
|
|
59
29
|
this.enabled = data.enabled ?? null;
|
|
60
30
|
|
|
61
31
|
if ('syncing' in data) {
|
|
62
|
-
|
|
63
|
-
* Whether this integration is syncing
|
|
64
|
-
* @type {?boolean}
|
|
65
|
-
*/
|
|
32
|
+
|
|
66
33
|
this.syncing = data.syncing;
|
|
67
34
|
} else {
|
|
68
35
|
this.syncing ??= null;
|
|
69
36
|
}
|
|
70
37
|
|
|
71
|
-
|
|
72
|
-
* The role that this integration uses for subscribers
|
|
73
|
-
* @type {?Role}
|
|
74
|
-
*/
|
|
38
|
+
|
|
75
39
|
this.role = this.guild.roles.resolve(data.role_id);
|
|
76
40
|
|
|
77
41
|
if ('enable_emoticons' in data) {
|
|
78
|
-
|
|
79
|
-
* Whether emoticons should be synced for this integration (twitch only currently)
|
|
80
|
-
* @type {?boolean}
|
|
81
|
-
*/
|
|
42
|
+
|
|
82
43
|
this.enableEmoticons = data.enable_emoticons;
|
|
83
44
|
} else {
|
|
84
45
|
this.enableEmoticons ??= null;
|
|
85
46
|
}
|
|
86
47
|
|
|
87
48
|
if (data.user) {
|
|
88
|
-
|
|
89
|
-
* The user for this integration
|
|
90
|
-
* @type {?User}
|
|
91
|
-
*/
|
|
49
|
+
|
|
92
50
|
this.user = this.client.users._add(data.user);
|
|
93
51
|
} else {
|
|
94
52
|
this.user ??= null;
|
|
95
53
|
}
|
|
96
54
|
|
|
97
|
-
|
|
98
|
-
* The account integration information
|
|
99
|
-
* @type {IntegrationAccount}
|
|
100
|
-
*/
|
|
55
|
+
|
|
101
56
|
this.account = data.account;
|
|
102
57
|
|
|
103
58
|
if ('synced_at' in data) {
|
|
104
|
-
|
|
105
|
-
* The timestamp at which this integration was last synced at
|
|
106
|
-
* @type {?number}
|
|
107
|
-
*/
|
|
59
|
+
|
|
108
60
|
this.syncedTimestamp = Date.parse(data.synced_at);
|
|
109
61
|
} else {
|
|
110
62
|
this.syncedTimestamp ??= null;
|
|
111
63
|
}
|
|
112
64
|
|
|
113
65
|
if ('subscriber_count' in data) {
|
|
114
|
-
|
|
115
|
-
* How many subscribers this integration has
|
|
116
|
-
* @type {?number}
|
|
117
|
-
*/
|
|
66
|
+
|
|
118
67
|
this.subscriberCount = data.subscriber_count;
|
|
119
68
|
} else {
|
|
120
69
|
this.subscriberCount ??= null;
|
|
121
70
|
}
|
|
122
71
|
|
|
123
72
|
if ('revoked' in data) {
|
|
124
|
-
|
|
125
|
-
* Whether this integration has been revoked
|
|
126
|
-
* @type {?boolean}
|
|
127
|
-
*/
|
|
73
|
+
|
|
128
74
|
this.revoked = data.revoked;
|
|
129
75
|
} else {
|
|
130
76
|
this.revoked ??= null;
|
|
@@ -133,20 +79,12 @@ class Integration extends Base {
|
|
|
133
79
|
this._patch(data);
|
|
134
80
|
}
|
|
135
81
|
|
|
136
|
-
|
|
137
|
-
* The date at which this integration was last synced at
|
|
138
|
-
* @type {?Date}
|
|
139
|
-
* @readonly
|
|
140
|
-
*/
|
|
82
|
+
|
|
141
83
|
get syncedAt() {
|
|
142
84
|
return this.syncedTimestamp && new Date(this.syncedTimestamp);
|
|
143
85
|
}
|
|
144
86
|
|
|
145
|
-
|
|
146
|
-
* All roles that are managed by this integration
|
|
147
|
-
* @type {Collection<Snowflake, Role>}
|
|
148
|
-
* @readonly
|
|
149
|
-
*/
|
|
87
|
+
|
|
150
88
|
get roles() {
|
|
151
89
|
const roles = this.guild.roles.cache;
|
|
152
90
|
return roles.filter(role => role.tags?.integrationId === this.id);
|
|
@@ -154,20 +92,14 @@ class Integration extends Base {
|
|
|
154
92
|
|
|
155
93
|
_patch(data) {
|
|
156
94
|
if ('expire_behavior' in data) {
|
|
157
|
-
|
|
158
|
-
* The behavior of expiring subscribers
|
|
159
|
-
* @type {?IntegrationExpireBehavior}
|
|
160
|
-
*/
|
|
95
|
+
|
|
161
96
|
this.expireBehavior = data.expire_behavior;
|
|
162
97
|
} else {
|
|
163
98
|
this.expireBehavior ??= null;
|
|
164
99
|
}
|
|
165
100
|
|
|
166
101
|
if ('expire_grace_period' in data) {
|
|
167
|
-
|
|
168
|
-
* The grace period (in days) before expiring subscribers
|
|
169
|
-
* @type {?number}
|
|
170
|
-
*/
|
|
102
|
+
|
|
171
103
|
this.expireGracePeriod = data.expire_grace_period;
|
|
172
104
|
} else {
|
|
173
105
|
this.expireGracePeriod ??= null;
|
|
@@ -177,10 +109,7 @@ class Integration extends Base {
|
|
|
177
109
|
if (this.application) {
|
|
178
110
|
this.application._patch(data.application);
|
|
179
111
|
} else {
|
|
180
|
-
|
|
181
|
-
* The application for this integration
|
|
182
|
-
* @type {?IntegrationApplication}
|
|
183
|
-
*/
|
|
112
|
+
|
|
184
113
|
this.application = new IntegrationApplication(this.client, data.application);
|
|
185
114
|
}
|
|
186
115
|
} else {
|
|
@@ -188,21 +117,14 @@ class Integration extends Base {
|
|
|
188
117
|
}
|
|
189
118
|
|
|
190
119
|
if ('scopes' in data) {
|
|
191
|
-
|
|
192
|
-
* The scopes this application has been authorized for
|
|
193
|
-
* @type {OAuth2Scopes[]}
|
|
194
|
-
*/
|
|
120
|
+
|
|
195
121
|
this.scopes = data.scopes;
|
|
196
122
|
} else {
|
|
197
123
|
this.scopes ??= [];
|
|
198
124
|
}
|
|
199
125
|
}
|
|
200
126
|
|
|
201
|
-
|
|
202
|
-
* Deletes this integration.
|
|
203
|
-
* @returns {Promise<Integration>}
|
|
204
|
-
* @param {string} [reason] Reason for deleting this integration
|
|
205
|
-
*/
|
|
127
|
+
|
|
206
128
|
async delete(reason) {
|
|
207
129
|
await this.client.rest.delete(Routes.guildIntegration(this.guild.id, this.id), { reason });
|
|
208
130
|
return this;
|
|
@@ -2,79 +2,55 @@
|
|
|
2
2
|
|
|
3
3
|
const Application = require('./interfaces/Application');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
* Represents an Integration's OAuth2 Application.
|
|
7
|
-
* @extends {Application}
|
|
8
|
-
*/
|
|
5
|
+
|
|
9
6
|
class IntegrationApplication extends Application {
|
|
10
7
|
_patch(data) {
|
|
11
8
|
super._patch(data);
|
|
12
9
|
|
|
13
10
|
if ('bot' in data) {
|
|
14
|
-
|
|
15
|
-
* The bot user for this application
|
|
16
|
-
* @type {?User}
|
|
17
|
-
*/
|
|
11
|
+
|
|
18
12
|
this.bot = this.client.users._add(data.bot);
|
|
19
13
|
} else {
|
|
20
14
|
this.bot ??= null;
|
|
21
15
|
}
|
|
22
16
|
|
|
23
17
|
if ('terms_of_service_url' in data) {
|
|
24
|
-
|
|
25
|
-
* The URL of the application's terms of service
|
|
26
|
-
* @type {?string}
|
|
27
|
-
*/
|
|
18
|
+
|
|
28
19
|
this.termsOfServiceURL = data.terms_of_service_url;
|
|
29
20
|
} else {
|
|
30
21
|
this.termsOfServiceURL ??= null;
|
|
31
22
|
}
|
|
32
23
|
|
|
33
24
|
if ('privacy_policy_url' in data) {
|
|
34
|
-
|
|
35
|
-
* The URL of the application's privacy policy
|
|
36
|
-
* @type {?string}
|
|
37
|
-
*/
|
|
25
|
+
|
|
38
26
|
this.privacyPolicyURL = data.privacy_policy_url;
|
|
39
27
|
} else {
|
|
40
28
|
this.privacyPolicyURL ??= null;
|
|
41
29
|
}
|
|
42
30
|
|
|
43
31
|
if ('rpc_origins' in data) {
|
|
44
|
-
|
|
45
|
-
* The Array of RPC origin URLs
|
|
46
|
-
* @type {string[]}
|
|
47
|
-
*/
|
|
32
|
+
|
|
48
33
|
this.rpcOrigins = data.rpc_origins;
|
|
49
34
|
} else {
|
|
50
35
|
this.rpcOrigins ??= [];
|
|
51
36
|
}
|
|
52
37
|
|
|
53
38
|
if ('hook' in data) {
|
|
54
|
-
|
|
55
|
-
* Whether the application can be default hooked by the client
|
|
56
|
-
* @type {?boolean}
|
|
57
|
-
*/
|
|
39
|
+
|
|
58
40
|
this.hook = data.hook;
|
|
59
41
|
} else {
|
|
60
42
|
this.hook ??= null;
|
|
61
43
|
}
|
|
62
44
|
|
|
63
45
|
if ('cover_image' in data) {
|
|
64
|
-
|
|
65
|
-
* The hash of the application's cover image
|
|
66
|
-
* @type {?string}
|
|
67
|
-
*/
|
|
46
|
+
|
|
68
47
|
this.cover = data.cover_image;
|
|
69
48
|
} else {
|
|
70
49
|
this.cover ??= null;
|
|
71
50
|
}
|
|
72
51
|
|
|
73
52
|
if ('verify_key' in data) {
|
|
74
|
-
|
|
75
|
-
* The hex-encoded key for verification in interactions and the GameSDK's GetTicket
|
|
76
|
-
* @type {?string}
|
|
77
|
-
*/
|
|
53
|
+
|
|
78
54
|
this.verifyKey = data.verify_key;
|
|
79
55
|
} else {
|
|
80
56
|
this.verifyKey ??= null;
|