@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,47 +5,25 @@ const { ApplicationCommandPermissionType, RESTJSONErrorCodes, Routes } = require
|
|
|
5
5
|
const BaseManager = require('./BaseManager');
|
|
6
6
|
const { DiscordjsError, DiscordjsTypeError, ErrorCodes } = require('../errors');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
* Manages API methods for permissions of Application Commands.
|
|
10
|
-
* @extends {BaseManager}
|
|
11
|
-
*/
|
|
8
|
+
|
|
12
9
|
class ApplicationCommandPermissionsManager extends BaseManager {
|
|
13
10
|
constructor(manager) {
|
|
14
11
|
super(manager.client);
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
* The manager or command that this manager belongs to
|
|
18
|
-
* @type {ApplicationCommandManager|ApplicationCommand}
|
|
19
|
-
* @private
|
|
20
|
-
*/
|
|
13
|
+
|
|
21
14
|
this.manager = manager;
|
|
22
15
|
|
|
23
|
-
|
|
24
|
-
* The guild that this manager acts on
|
|
25
|
-
* @type {?Guild}
|
|
26
|
-
*/
|
|
16
|
+
|
|
27
17
|
this.guild = manager.guild ?? null;
|
|
28
18
|
|
|
29
|
-
|
|
30
|
-
* The id of the guild that this manager acts on
|
|
31
|
-
* @type {?Snowflake}
|
|
32
|
-
*/
|
|
19
|
+
|
|
33
20
|
this.guildId = manager.guildId ?? manager.guild?.id ?? null;
|
|
34
21
|
|
|
35
|
-
|
|
36
|
-
* The id of the command this manager acts on
|
|
37
|
-
* @type {?Snowflake}
|
|
38
|
-
*/
|
|
22
|
+
|
|
39
23
|
this.commandId = manager.id ?? null;
|
|
40
24
|
}
|
|
41
25
|
|
|
42
|
-
|
|
43
|
-
* The APIRouter path to the commands
|
|
44
|
-
* @param {Snowflake} guildId The guild's id to use in the path,
|
|
45
|
-
* @param {Snowflake} [commandId] The application command's id
|
|
46
|
-
* @returns {string}
|
|
47
|
-
* @private
|
|
48
|
-
*/
|
|
26
|
+
|
|
49
27
|
permissionsPath(guildId, commandId) {
|
|
50
28
|
if (commandId) {
|
|
51
29
|
return Routes.applicationCommandPermissions(this.client.application.id, guildId, commandId);
|
|
@@ -54,49 +32,13 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
|
|
54
32
|
return Routes.guildApplicationCommandsPermissions(this.client.application.id, guildId);
|
|
55
33
|
}
|
|
56
34
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
* @property {boolean} permission Whether the role or user has the permission to use this command
|
|
65
|
-
*/
|
|
66
|
-
/* eslint-enable max-len */
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Options for managing permissions for one or more Application Commands
|
|
70
|
-
* <warn>When passing these options to a manager where `guildId` is `null`,
|
|
71
|
-
* `guild` is a required parameter</warn>
|
|
72
|
-
* @typedef {Object} BaseApplicationCommandPermissionsOptions
|
|
73
|
-
* @property {GuildResolvable} [guild] The guild to modify / check permissions for
|
|
74
|
-
* <warn>Ignored when the manager has a non-null `guildId` property</warn>
|
|
75
|
-
* @property {ApplicationCommandResolvable} [command] The command to modify / check permissions for
|
|
76
|
-
* <warn>Ignored when the manager has a non-null `commandId` property</warn>
|
|
77
|
-
*/
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Fetches the permissions for one or multiple commands. Providing the client's id as the "command id" will fetch
|
|
81
|
-
* *only* the guild level permissions
|
|
82
|
-
* @param {BaseApplicationCommandPermissionsOptions} [options] Options used to fetch permissions
|
|
83
|
-
* @returns {Promise<ApplicationCommandPermissions[]|Collection<Snowflake, ApplicationCommandPermissions[]>>}
|
|
84
|
-
* @example
|
|
85
|
-
* // Fetch permissions for one command
|
|
86
|
-
* guild.commands.permissions.fetch({ command: '123456789012345678' })
|
|
87
|
-
* .then(perms => console.log(`Fetched ${perms.length} overwrites`))
|
|
88
|
-
* .catch(console.error);
|
|
89
|
-
* @example
|
|
90
|
-
* // Fetch permissions for all commands in a guild
|
|
91
|
-
* client.application.commands.permissions.fetch({ guild: '123456789012345678' })
|
|
92
|
-
* .then(perms => console.log(`Fetched permissions for ${perms.size} commands`))
|
|
93
|
-
* .catch(console.error);
|
|
94
|
-
* @example
|
|
95
|
-
* // Fetch guild level permissions
|
|
96
|
-
* guild.commands.permissions.fetch({ command: client.user.id })
|
|
97
|
-
* .then(perms => console.log(`Fetched ${perms.length} guild level permissions`))
|
|
98
|
-
* .catch(console.error);
|
|
99
|
-
*/
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
100
42
|
async fetch({ guild, command } = {}) {
|
|
101
43
|
const { guildId, commandId } = this._validateOptions(guild, command);
|
|
102
44
|
if (commandId) {
|
|
@@ -108,49 +50,9 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
|
|
108
50
|
return data.reduce((coll, perm) => coll.set(perm.id, perm.permissions), new Collection());
|
|
109
51
|
}
|
|
110
52
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
* when the manager's `commandId` is `null`</warn>
|
|
115
|
-
* @typedef {BaseApplicationCommandPermissionsOptions} ApplicationCommandPermissionsEditOptions
|
|
116
|
-
* @property {ApplicationCommandPermissions[]} permissions The new permissions for the guild or overwrite
|
|
117
|
-
* @property {string} token The bearer token to use that authorizes the permission edit
|
|
118
|
-
*/
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Sets the permissions for the guild or a command overwrite.
|
|
122
|
-
* @param {ApplicationCommandPermissionsEditOptions} options Options used to set permissions
|
|
123
|
-
* @returns {Promise<ApplicationCommandPermissions[]|Collection<Snowflake, ApplicationCommandPermissions[]>>}
|
|
124
|
-
* @example
|
|
125
|
-
* // Set a permission overwrite for a command
|
|
126
|
-
* client.application.commands.permissions.set({
|
|
127
|
-
* guild: '892455839386304532',
|
|
128
|
-
* command: '123456789012345678',
|
|
129
|
-
* token: 'TotallyRealToken',
|
|
130
|
-
* permissions: [
|
|
131
|
-
* {
|
|
132
|
-
* id: '876543210987654321',
|
|
133
|
-
* type: ApplicationCommandPermissionType.User,
|
|
134
|
-
* permission: false,
|
|
135
|
-
* },
|
|
136
|
-
* ]})
|
|
137
|
-
* .then(console.log)
|
|
138
|
-
* .catch(console.error);
|
|
139
|
-
* @example
|
|
140
|
-
* // Set the permissions used for the guild (commands without overwrites)
|
|
141
|
-
* guild.commands.permissions.set({ token: 'TotallyRealToken', permissions: [
|
|
142
|
-
* {
|
|
143
|
-
* id: '123456789012345678',
|
|
144
|
-
* permissions: [{
|
|
145
|
-
* id: '876543210987654321',
|
|
146
|
-
* type: ApplicationCommandPermissionType.User,
|
|
147
|
-
* permission: false,
|
|
148
|
-
* }],
|
|
149
|
-
* },
|
|
150
|
-
* ]})
|
|
151
|
-
* .then(console.log)
|
|
152
|
-
* .catch(console.error);
|
|
153
|
-
*/
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
154
56
|
async set({ guild, command, permissions, token } = {}) {
|
|
155
57
|
if (!token) {
|
|
156
58
|
throw new DiscordjsError(ErrorCodes.ApplicationCommandPermissionsTokenMissing);
|
|
@@ -177,22 +79,7 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
|
|
177
79
|
return data.permissions;
|
|
178
80
|
}
|
|
179
81
|
|
|
180
|
-
|
|
181
|
-
* Add permissions to a command.
|
|
182
|
-
* @param {ApplicationCommandPermissionsEditOptions} options Options used to add permissions
|
|
183
|
-
* @returns {Promise<ApplicationCommandPermissions[]>}
|
|
184
|
-
* @example
|
|
185
|
-
* // Add a rule to block a role from using a command
|
|
186
|
-
* guild.commands.permissions.add({ command: '123456789012345678', token: 'TotallyRealToken', permissions: [
|
|
187
|
-
* {
|
|
188
|
-
* id: '876543211234567890',
|
|
189
|
-
* type: ApplicationCommandPermissionType.Role,
|
|
190
|
-
* permission: false
|
|
191
|
-
* },
|
|
192
|
-
* ]})
|
|
193
|
-
* .then(console.log)
|
|
194
|
-
* .catch(console.error);
|
|
195
|
-
*/
|
|
82
|
+
|
|
196
83
|
async add({ guild, command, permissions, token } = {}) {
|
|
197
84
|
if (!token) {
|
|
198
85
|
throw new DiscordjsError(ErrorCodes.ApplicationCommandPermissionsTokenMissing);
|
|
@@ -227,49 +114,13 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
|
|
227
114
|
return this.set({ guild: guildId, command: commandId, permissions: newPermissions, token });
|
|
228
115
|
}
|
|
229
116
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
* A static snowflake that identifies the "all channels" entity for application command permissions.
|
|
238
|
-
* It will be the result of the calculation `guildId - 1`
|
|
239
|
-
* @typedef {Snowflake} ChannelPermissionConstant
|
|
240
|
-
*/
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Options used to remove permissions from a command
|
|
244
|
-
* <warn>Omitting the `command` parameter removes from the guild wide permissions
|
|
245
|
-
* when the managers `commandId` is `null`</warn>
|
|
246
|
-
* <warn>At least one of `users`, `roles`, and `channels` is required</warn>
|
|
247
|
-
* @typedef {BaseApplicationCommandPermissionsOptions} RemoveApplicationCommandPermissionsOptions
|
|
248
|
-
* @property {string} token The bearer token to use that authorizes the permission removal
|
|
249
|
-
* @property {UserResolvable[]} [users] The user(s) to remove
|
|
250
|
-
* @property {Array<RoleResolvable|RolePermissionConstant>} [roles] The role(s) to remove
|
|
251
|
-
* @property {Array<GuildChannelResolvable|ChannelPermissionConstant>} [channels] The channel(s) to remove
|
|
252
|
-
*/
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Remove permissions from a command.
|
|
256
|
-
* @param {RemoveApplicationCommandPermissionsOptions} options Options used to remove permissions
|
|
257
|
-
* @returns {Promise<ApplicationCommandPermissions[]>}
|
|
258
|
-
* @example
|
|
259
|
-
* // Remove a user permission from this command
|
|
260
|
-
* guild.commands.permissions.remove({
|
|
261
|
-
* command: '123456789012345678', users: '876543210123456789', token: 'TotallyRealToken',
|
|
262
|
-
* })
|
|
263
|
-
* .then(console.log)
|
|
264
|
-
* .catch(console.error);
|
|
265
|
-
* @example
|
|
266
|
-
* // Remove multiple roles from this command
|
|
267
|
-
* guild.commands.permissions.remove({
|
|
268
|
-
* command: '123456789012345678', roles: ['876543210123456789', '765432101234567890'], token: 'TotallyRealToken',
|
|
269
|
-
* })
|
|
270
|
-
* .then(console.log)
|
|
271
|
-
* .catch(console.error);
|
|
272
|
-
*/
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
273
124
|
async remove({ guild, command, users, roles, channels, token } = {}) {
|
|
274
125
|
if (!token) {
|
|
275
126
|
throw new DiscordjsError(ErrorCodes.ApplicationCommandPermissionsTokenMissing);
|
|
@@ -342,25 +193,9 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
|
|
342
193
|
return this.set({ guild: guildId, command: commandId, permissions, token });
|
|
343
194
|
}
|
|
344
195
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
* @typedef {BaseApplicationCommandPermissionsOptions} HasApplicationCommandPermissionsOptions
|
|
349
|
-
* @property {ApplicationCommandPermissionIdResolvable} permissionId The entity to check if a permission exists for
|
|
350
|
-
* on this command.
|
|
351
|
-
* @property {ApplicationCommandPermissionType} [permissionType] Check for a specific type of permission
|
|
352
|
-
*/
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* Check whether a permission exists for a user, role, or channel
|
|
356
|
-
* @param {HasApplicationCommandPermissionsOptions} options Options used to check permissions
|
|
357
|
-
* @returns {Promise<boolean>}
|
|
358
|
-
* @example
|
|
359
|
-
* // Check whether a user has permission to use a command
|
|
360
|
-
* guild.commands.permissions.has({ command: '123456789012345678', permissionId: '876543210123456789' })
|
|
361
|
-
* .then(console.log)
|
|
362
|
-
* .catch(console.error);
|
|
363
|
-
*/
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
364
199
|
async has({ guild, command, permissionId, permissionType }) {
|
|
365
200
|
const { guildId, commandId } = this._validateOptions(guild, command);
|
|
366
201
|
if (!commandId) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'command', 'ApplicationCommandResolvable');
|
|
@@ -398,7 +233,7 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
|
|
398
233
|
if (error.code !== RESTJSONErrorCodes.UnknownApplicationCommandPermissions) throw error;
|
|
399
234
|
}
|
|
400
235
|
|
|
401
|
-
|
|
236
|
+
|
|
402
237
|
return existing.some(perm => perm.id === resolvedId && (permissionType ?? perm.type) === perm.type);
|
|
403
238
|
}
|
|
404
239
|
|
|
@@ -422,13 +257,7 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
|
|
422
257
|
|
|
423
258
|
module.exports = ApplicationCommandPermissionsManager;
|
|
424
259
|
|
|
425
|
-
/* eslint-disable max-len */
|
|
426
|
-
/**
|
|
427
|
-
* @external APIApplicationCommandPermissions
|
|
428
|
-
* @see {@link https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-structure}
|
|
429
|
-
*/
|
|
430
260
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
*/
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
@@ -5,105 +5,34 @@ const { Routes } = require('discord-api-types/v10');
|
|
|
5
5
|
const CachedManager = require('./CachedManager');
|
|
6
6
|
const AutoModerationRule = require('../structures/AutoModerationRule');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
* Manages API methods for auto moderation rules and stores their cache.
|
|
10
|
-
* @extends {CachedManager}
|
|
11
|
-
*/
|
|
8
|
+
|
|
12
9
|
class AutoModerationRuleManager extends CachedManager {
|
|
13
10
|
constructor(guild, iterable) {
|
|
14
11
|
super(guild.client, AutoModerationRule, iterable);
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
* The guild this manager belongs to.
|
|
18
|
-
* @type {Guild}
|
|
19
|
-
*/
|
|
13
|
+
|
|
20
14
|
this.guild = guild;
|
|
21
15
|
}
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
* The cache of this manager
|
|
25
|
-
* @type {Collection<Snowflake, AutoModerationRule>}
|
|
26
|
-
* @name AutoModerationRuleManager#cache
|
|
27
|
-
*/
|
|
17
|
+
|
|
28
18
|
|
|
29
|
-
|
|
30
|
-
* Resolves an {@link AutoModerationRuleResolvable} to an {@link AutoModerationRule} object.
|
|
31
|
-
* @method resolve
|
|
32
|
-
* @memberof AutoModerationRuleManager
|
|
33
|
-
* @instance
|
|
34
|
-
* @param {AutoModerationRuleResolvable} autoModerationRule The AutoModerationRule resolvable to resolve
|
|
35
|
-
* @returns {?AutoModerationRule}
|
|
36
|
-
*/
|
|
19
|
+
|
|
37
20
|
|
|
38
|
-
|
|
39
|
-
* Resolves an {@link AutoModerationRuleResolvable} to a {@link AutoModerationRule} id.
|
|
40
|
-
* @method resolveId
|
|
41
|
-
* @memberof AutoModerationRuleManager
|
|
42
|
-
* @instance
|
|
43
|
-
* @param {AutoModerationRuleResolvable} autoModerationRule The AutoModerationRule resolvable to resolve
|
|
44
|
-
* @returns {?Snowflake}
|
|
45
|
-
*/
|
|
21
|
+
|
|
46
22
|
|
|
47
23
|
_add(data, cache) {
|
|
48
24
|
return super._add(data, cache, { extras: [this.guild] });
|
|
49
25
|
}
|
|
50
26
|
|
|
51
|
-
|
|
52
|
-
* Options used to set the trigger metadata of an auto moderation rule.
|
|
53
|
-
* @typedef {Object} AutoModerationTriggerMetadataOptions
|
|
54
|
-
* @property {string[]} [keywordFilter] The substrings that will be searched for in the content
|
|
55
|
-
* @property {string[]} [regexPatterns] The regular expression patterns which will be matched against the content
|
|
56
|
-
* <info>Only Rust-flavored regular expressions are supported.</info>
|
|
57
|
-
* @property {AutoModerationRuleKeywordPresetType[]} [presets]
|
|
58
|
-
* The internally pre-defined wordsets which will be searched for in the content
|
|
59
|
-
* @property {string[]} [allowList] The substrings that will be exempt from triggering
|
|
60
|
-
* {@link AutoModerationRuleTriggerType.Keyword} and {@link AutoModerationRuleTriggerType.KeywordPreset}
|
|
61
|
-
* @property {?number} [mentionTotalLimit] The total number of role & user mentions allowed per message
|
|
62
|
-
* @property {boolean} [mentionRaidProtectionEnabled] Whether to automatically detect mention raids
|
|
63
|
-
*/
|
|
27
|
+
|
|
64
28
|
|
|
65
|
-
|
|
66
|
-
* Options used to set the actions of an auto moderation rule.
|
|
67
|
-
* @typedef {Object} AutoModerationActionOptions
|
|
68
|
-
* @property {AutoModerationActionType} type The type of this auto moderation rule action
|
|
69
|
-
* @property {AutoModerationActionMetadataOptions} [metadata] Additional metadata needed during execution
|
|
70
|
-
* <info>This property is required if using a `type` of
|
|
71
|
-
* {@link AutoModerationActionType.SendAlertMessage} or {@link AutoModerationActionType.Timeout}.</info>
|
|
72
|
-
*/
|
|
29
|
+
|
|
73
30
|
|
|
74
|
-
|
|
75
|
-
* Options used to set the metadata of an auto moderation rule action.
|
|
76
|
-
* @typedef {Object} AutoModerationActionMetadataOptions
|
|
77
|
-
* @property {GuildTextChannelResolvable|ThreadChannel} [channel] The channel to which content will be logged
|
|
78
|
-
* @property {number} [durationSeconds] The timeout duration in seconds
|
|
79
|
-
* @property {string} [customMessage] The custom message that is shown whenever a message is blocked
|
|
80
|
-
*/
|
|
31
|
+
|
|
81
32
|
|
|
82
|
-
|
|
83
|
-
* Options used to create an auto moderation rule.
|
|
84
|
-
* @typedef {Object} AutoModerationRuleCreateOptions
|
|
85
|
-
* @property {string} name The name of the auto moderation rule
|
|
86
|
-
* @property {AutoModerationRuleEventType} eventType The event type of the auto moderation rule
|
|
87
|
-
* @property {AutoModerationRuleTriggerType} triggerType The trigger type of the auto moderation rule
|
|
88
|
-
* @property {AutoModerationTriggerMetadataOptions} [triggerMetadata] The trigger metadata of the auto moderation rule
|
|
89
|
-
* <info>This property is required if using a `triggerType` of
|
|
90
|
-
* {@link AutoModerationRuleTriggerType.Keyword}, {@link AutoModerationRuleTriggerType.KeywordPreset},
|
|
91
|
-
* or {@link AutoModerationRuleTriggerType.MentionSpam}.</info>
|
|
92
|
-
* @property {AutoModerationActionOptions[]} actions
|
|
93
|
-
* The actions that will execute when the auto moderation rule is triggered
|
|
94
|
-
* @property {boolean} [enabled] Whether the auto moderation rule should be enabled
|
|
95
|
-
* @property {Collection<Snowflake, Role>|RoleResolvable[]} [exemptRoles]
|
|
96
|
-
* The roles that should not be affected by the auto moderation rule
|
|
97
|
-
* @property {Collection<Snowflake, GuildChannel|ThreadChannel>|GuildChannelResolvable[]} [exemptChannels]
|
|
98
|
-
* The channels that should not be affected by the auto moderation rule
|
|
99
|
-
* @property {string} [reason] The reason for creating the auto moderation rule
|
|
100
|
-
*/
|
|
33
|
+
|
|
101
34
|
|
|
102
|
-
|
|
103
|
-
* Creates a new auto moderation rule.
|
|
104
|
-
* @param {AutoModerationRuleCreateOptions} options Options for creating the auto moderation rule
|
|
105
|
-
* @returns {Promise<AutoModerationRule>}
|
|
106
|
-
*/
|
|
35
|
+
|
|
107
36
|
async create({
|
|
108
37
|
name,
|
|
109
38
|
eventType,
|
|
@@ -146,28 +75,9 @@ class AutoModerationRuleManager extends CachedManager {
|
|
|
146
75
|
return this._add(data);
|
|
147
76
|
}
|
|
148
77
|
|
|
149
|
-
|
|
150
|
-
* Options used to edit an auto moderation rule.
|
|
151
|
-
* @typedef {Object} AutoModerationRuleEditOptions
|
|
152
|
-
* @property {string} [name] The name of the auto moderation rule
|
|
153
|
-
* @property {AutoModerationRuleEventType} [eventType] The event type of the auto moderation rule
|
|
154
|
-
* @property {AutoModerationTriggerMetadataOptions} [triggerMetadata] The trigger metadata of the auto moderation rule
|
|
155
|
-
* @property {AutoModerationActionOptions[]} [actions]
|
|
156
|
-
* The actions that will execute when the auto moderation rule is triggered
|
|
157
|
-
* @property {boolean} [enabled] Whether the auto moderation rule should be enabled
|
|
158
|
-
* @property {Collection<Snowflake, Role>|RoleResolvable[]} [exemptRoles]
|
|
159
|
-
* The roles that should not be affected by the auto moderation rule
|
|
160
|
-
* @property {Collection<Snowflake, GuildChannel|ThreadChannel>|GuildChannelResolvable[]} [exemptChannels]
|
|
161
|
-
* The channels that should not be affected by the auto moderation rule
|
|
162
|
-
* @property {string} [reason] The reason for creating the auto moderation rule
|
|
163
|
-
*/
|
|
78
|
+
|
|
164
79
|
|
|
165
|
-
|
|
166
|
-
* Edits an auto moderation rule.
|
|
167
|
-
* @param {AutoModerationRuleResolvable} autoModerationRule The auto moderation rule to edit
|
|
168
|
-
* @param {AutoModerationRuleEditOptions} options Options for editing the auto moderation rule
|
|
169
|
-
* @returns {Promise<AutoModerationRule>}
|
|
170
|
-
*/
|
|
80
|
+
|
|
171
81
|
async edit(
|
|
172
82
|
autoModerationRule,
|
|
173
83
|
{ name, eventType, triggerMetadata, actions, enabled, exemptRoles, exemptChannels, reason },
|
|
@@ -204,46 +114,13 @@ class AutoModerationRuleManager extends CachedManager {
|
|
|
204
114
|
return this._add(data);
|
|
205
115
|
}
|
|
206
116
|
|
|
207
|
-
|
|
208
|
-
* Data that can be resolved to give an AutoModerationRule object. This can be:
|
|
209
|
-
* * An AutoModerationRule
|
|
210
|
-
* * A Snowflake
|
|
211
|
-
* @typedef {AutoModerationRule|Snowflake} AutoModerationRuleResolvable
|
|
212
|
-
*/
|
|
117
|
+
|
|
213
118
|
|
|
214
|
-
|
|
215
|
-
* Options used to fetch a single auto moderation rule from a guild.
|
|
216
|
-
* @typedef {BaseFetchOptions} FetchAutoModerationRuleOptions
|
|
217
|
-
* @property {AutoModerationRuleResolvable} autoModerationRule The auto moderation rule to fetch
|
|
218
|
-
*/
|
|
119
|
+
|
|
219
120
|
|
|
220
|
-
|
|
221
|
-
* Options used to fetch all auto moderation rules from a guild.
|
|
222
|
-
* @typedef {Object} FetchAutoModerationRulesOptions
|
|
223
|
-
* @property {boolean} [cache] Whether to cache the fetched auto moderation rules
|
|
224
|
-
*/
|
|
121
|
+
|
|
225
122
|
|
|
226
|
-
|
|
227
|
-
* Fetches auto moderation rules from Discord.
|
|
228
|
-
* @param {AutoModerationRuleResolvable|FetchAutoModerationRuleOptions|FetchAutoModerationRulesOptions} [options]
|
|
229
|
-
* Options for fetching auto moderation rule(s)
|
|
230
|
-
* @returns {Promise<AutoModerationRule|Collection<Snowflake, AutoModerationRule>>}
|
|
231
|
-
* @example
|
|
232
|
-
* // Fetch all auto moderation rules from a guild without caching
|
|
233
|
-
* guild.autoModerationRules.fetch({ cache: false })
|
|
234
|
-
* .then(console.log)
|
|
235
|
-
* .catch(console.error);
|
|
236
|
-
* @example
|
|
237
|
-
* // Fetch a single auto moderation rule
|
|
238
|
-
* guild.autoModerationRules.fetch('979083472868098119')
|
|
239
|
-
* .then(console.log)
|
|
240
|
-
* .catch(console.error);
|
|
241
|
-
* @example
|
|
242
|
-
* // Fetch a single auto moderation rule without checking cache and without caching
|
|
243
|
-
* guild.autoModerationRules.fetch({ autoModerationRule: '979083472868098119', cache: false, force: true })
|
|
244
|
-
* .then(console.log)
|
|
245
|
-
* .catch(console.error)
|
|
246
|
-
*/
|
|
123
|
+
|
|
247
124
|
fetch(options) {
|
|
248
125
|
if (!options) return this._fetchMany();
|
|
249
126
|
const { autoModerationRule, cache, force } = options;
|
|
@@ -273,12 +150,7 @@ class AutoModerationRuleManager extends CachedManager {
|
|
|
273
150
|
);
|
|
274
151
|
}
|
|
275
152
|
|
|
276
|
-
|
|
277
|
-
* Deletes an auto moderation rule.
|
|
278
|
-
* @param {AutoModerationRuleResolvable} autoModerationRule The auto moderation rule to delete
|
|
279
|
-
* @param {string} [reason] The reason for deleting the auto moderation rule
|
|
280
|
-
* @returns {Promise<void>}
|
|
281
|
-
*/
|
|
153
|
+
|
|
282
154
|
async delete(autoModerationRule, reason) {
|
|
283
155
|
const autoModerationRuleId = this.resolveId(autoModerationRule);
|
|
284
156
|
await this.client.rest.delete(Routes.guildAutoModerationRule(this.guild.id, autoModerationRuleId), { reason });
|
|
@@ -5,62 +5,31 @@ const GuildEmoji = require('../structures/GuildEmoji');
|
|
|
5
5
|
const ReactionEmoji = require('../structures/ReactionEmoji');
|
|
6
6
|
const { parseEmoji } = require('../util/Util');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
* Holds methods to resolve GuildEmojis and stores their cache.
|
|
10
|
-
* @extends {CachedManager}
|
|
11
|
-
*/
|
|
8
|
+
|
|
12
9
|
class BaseGuildEmojiManager extends CachedManager {
|
|
13
10
|
constructor(client, iterable) {
|
|
14
11
|
super(client, GuildEmoji, iterable);
|
|
15
12
|
}
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
* The cache of GuildEmojis
|
|
19
|
-
* @type {Collection<Snowflake, GuildEmoji>}
|
|
20
|
-
* @name BaseGuildEmojiManager#cache
|
|
21
|
-
*/
|
|
14
|
+
|
|
22
15
|
|
|
23
|
-
|
|
24
|
-
* Data that can be resolved into a GuildEmoji object. This can be:
|
|
25
|
-
* * A Snowflake
|
|
26
|
-
* * A GuildEmoji object
|
|
27
|
-
* * A ReactionEmoji object
|
|
28
|
-
* @typedef {Snowflake|GuildEmoji|ReactionEmoji} EmojiResolvable
|
|
29
|
-
*/
|
|
16
|
+
|
|
30
17
|
|
|
31
|
-
|
|
32
|
-
* Resolves an EmojiResolvable to an Emoji object.
|
|
33
|
-
* @param {EmojiResolvable} emoji The Emoji resolvable to identify
|
|
34
|
-
* @returns {?GuildEmoji}
|
|
35
|
-
*/
|
|
18
|
+
|
|
36
19
|
resolve(emoji) {
|
|
37
20
|
if (emoji instanceof ReactionEmoji) return super.resolve(emoji.id);
|
|
38
21
|
return super.resolve(emoji);
|
|
39
22
|
}
|
|
40
23
|
|
|
41
|
-
|
|
42
|
-
* Resolves an EmojiResolvable to an Emoji id string.
|
|
43
|
-
* @param {EmojiResolvable} emoji The Emoji resolvable to identify
|
|
44
|
-
* @returns {?Snowflake}
|
|
45
|
-
*/
|
|
24
|
+
|
|
46
25
|
resolveId(emoji) {
|
|
47
26
|
if (emoji instanceof ReactionEmoji) return emoji.id;
|
|
48
27
|
return super.resolveId(emoji);
|
|
49
28
|
}
|
|
50
29
|
|
|
51
|
-
|
|
52
|
-
* Data that can be resolved to give an emoji identifier. This can be:
|
|
53
|
-
* * An EmojiResolvable
|
|
54
|
-
* * The `<a:name:id>`, `<:name:id>`, `a:name:id` or `name:id` emoji identifier string of an emoji
|
|
55
|
-
* * The Unicode representation of an emoji
|
|
56
|
-
* @typedef {string|EmojiResolvable} EmojiIdentifierResolvable
|
|
57
|
-
*/
|
|
30
|
+
|
|
58
31
|
|
|
59
|
-
|
|
60
|
-
* Resolves an EmojiResolvable to an emoji identifier.
|
|
61
|
-
* @param {EmojiIdentifierResolvable} emoji The emoji resolvable to resolve
|
|
62
|
-
* @returns {?string}
|
|
63
|
-
*/
|
|
32
|
+
|
|
64
33
|
resolveIdentifier(emoji) {
|
|
65
34
|
const emojiResolvable = this.resolve(emoji);
|
|
66
35
|
if (emojiResolvable) return emojiResolvable.identifier;
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
* Manages the API methods of a data model.
|
|
5
|
-
* @abstract
|
|
6
|
-
*/
|
|
3
|
+
|
|
7
4
|
class BaseManager {
|
|
8
5
|
constructor(client) {
|
|
9
|
-
|
|
10
|
-
* The client that instantiated this Manager
|
|
11
|
-
* @name BaseManager#client
|
|
12
|
-
* @type {Client}
|
|
13
|
-
* @readonly
|
|
14
|
-
*/
|
|
6
|
+
|
|
15
7
|
Object.defineProperty(this, 'client', { value: client });
|
|
16
8
|
}
|
|
17
9
|
}
|
|
@@ -2,22 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
const DataManager = require('./DataManager');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
* Manages the API methods of a data model with a mutable cache of instances.
|
|
7
|
-
* @extends {DataManager}
|
|
8
|
-
* @abstract
|
|
9
|
-
*/
|
|
5
|
+
|
|
10
6
|
class CachedManager extends DataManager {
|
|
11
7
|
constructor(client, holds, iterable) {
|
|
12
8
|
super(client, holds);
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
* The private cache of items for this manager.
|
|
16
|
-
* @type {Collection}
|
|
17
|
-
* @private
|
|
18
|
-
* @readonly
|
|
19
|
-
* @name CachedManager#_cache
|
|
20
|
-
*/
|
|
10
|
+
|
|
21
11
|
Object.defineProperty(this, '_cache', { value: this.client.options.makeCache(this.constructor, this.holds) });
|
|
22
12
|
|
|
23
13
|
if (iterable) {
|
|
@@ -27,11 +17,7 @@ class CachedManager extends DataManager {
|
|
|
27
17
|
}
|
|
28
18
|
}
|
|
29
19
|
|
|
30
|
-
|
|
31
|
-
* The cache of items for this manager.
|
|
32
|
-
* @type {Collection}
|
|
33
|
-
* @abstract
|
|
34
|
-
*/
|
|
20
|
+
|
|
35
21
|
get cache() {
|
|
36
22
|
return this._cache;
|
|
37
23
|
}
|