@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
|
@@ -3,69 +3,27 @@
|
|
|
3
3
|
const DataManager = require('./DataManager');
|
|
4
4
|
const GuildChannel = require('../structures/GuildChannel');
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
* Manages API methods for CategoryChannels' children.
|
|
8
|
-
* @extends {DataManager}
|
|
9
|
-
*/
|
|
6
|
+
|
|
10
7
|
class CategoryChannelChildManager extends DataManager {
|
|
11
8
|
constructor(channel) {
|
|
12
9
|
super(channel.client, GuildChannel);
|
|
13
|
-
|
|
14
|
-
* The category channel this manager belongs to
|
|
15
|
-
* @type {CategoryChannel}
|
|
16
|
-
*/
|
|
10
|
+
|
|
17
11
|
this.channel = channel;
|
|
18
12
|
}
|
|
19
13
|
|
|
20
|
-
|
|
21
|
-
* The channels that are a part of this category
|
|
22
|
-
* @type {Collection<Snowflake, GuildChannel>}
|
|
23
|
-
* @readonly
|
|
24
|
-
*/
|
|
14
|
+
|
|
25
15
|
get cache() {
|
|
26
16
|
return this.guild.channels.cache.filter(c => c.parentId === this.channel.id);
|
|
27
17
|
}
|
|
28
18
|
|
|
29
|
-
|
|
30
|
-
* The guild this manager belongs to
|
|
31
|
-
* @type {Guild}
|
|
32
|
-
* @readonly
|
|
33
|
-
*/
|
|
19
|
+
|
|
34
20
|
get guild() {
|
|
35
21
|
return this.channel.guild;
|
|
36
22
|
}
|
|
37
23
|
|
|
38
|
-
|
|
39
|
-
* Options for creating a channel using {@link CategoryChannel#createChannel}.
|
|
40
|
-
* @typedef {Object} CategoryCreateChannelOptions
|
|
41
|
-
* @property {string} name The name for the new channel
|
|
42
|
-
* @property {ChannelType} [type=ChannelType.GuildText] The type of the new channel.
|
|
43
|
-
* @property {string} [topic] The topic for the new channel
|
|
44
|
-
* @property {boolean} [nsfw] Whether the new channel is NSFW
|
|
45
|
-
* @property {number} [bitrate] Bitrate of the new channel in bits (only voice)
|
|
46
|
-
* @property {number} [userLimit] Maximum amount of users allowed in the new channel (only voice)
|
|
47
|
-
* @property {OverwriteResolvable[]|Collection<Snowflake, OverwriteResolvable>} [permissionOverwrites]
|
|
48
|
-
* Permission overwrites of the new channel
|
|
49
|
-
* @property {number} [position] Position of the new channel
|
|
50
|
-
* @property {number} [rateLimitPerUser] The rate limit per user (slowmode) for the new channel in seconds
|
|
51
|
-
* @property {string} [rtcRegion] The specific region of the new channel.
|
|
52
|
-
* @property {VideoQualityMode} [videoQualityMode] The camera video quality mode of the voice channel
|
|
53
|
-
* @property {GuildForumTagData[]} [availableTags] The tags that can be used in this channel (forum only).
|
|
54
|
-
* @property {DefaultReactionEmoji} [defaultReactionEmoji]
|
|
55
|
-
* The emoji to show in the add reaction button on a thread in a guild forum channel.
|
|
56
|
-
* @property {ThreadAutoArchiveDuration} [defaultAutoArchiveDuration]
|
|
57
|
-
* The default auto archive duration for all new threads in this channel
|
|
58
|
-
* @property {SortOrderType} [defaultSortOrder] The default sort order mode used to order posts (forum only).
|
|
59
|
-
* @property {ForumLayoutType} [defaultForumLayout] The default layout used to display posts (forum only).
|
|
60
|
-
* @property {string} [reason] Reason for creating the new channel
|
|
61
|
-
*/
|
|
24
|
+
|
|
62
25
|
|
|
63
|
-
|
|
64
|
-
* Creates a new channel within this category.
|
|
65
|
-
* <info>You cannot create a channel of type {@link ChannelType.GuildCategory} inside a CategoryChannel.</info>
|
|
66
|
-
* @param {CategoryCreateChannelOptions} options Options for creating the new channel
|
|
67
|
-
* @returns {Promise<GuildChannel>}
|
|
68
|
-
*/
|
|
26
|
+
|
|
69
27
|
create(options) {
|
|
70
28
|
return this.guild.channels.create({
|
|
71
29
|
...options,
|
|
@@ -10,10 +10,7 @@ const Events = require('../util/Events');
|
|
|
10
10
|
|
|
11
11
|
let cacheWarningEmitted = false;
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
* A manager of channels belonging to a client
|
|
15
|
-
* @extends {CachedManager}
|
|
16
|
-
*/
|
|
13
|
+
|
|
17
14
|
class ChannelManager extends CachedManager {
|
|
18
15
|
constructor(client, iterable) {
|
|
19
16
|
super(client, BaseChannel, iterable);
|
|
@@ -30,11 +27,7 @@ class ChannelManager extends CachedManager {
|
|
|
30
27
|
}
|
|
31
28
|
}
|
|
32
29
|
|
|
33
|
-
|
|
34
|
-
* The cache of Channels
|
|
35
|
-
* @type {Collection<Snowflake, BaseChannel>}
|
|
36
|
-
* @name ChannelManager#cache
|
|
37
|
-
*/
|
|
30
|
+
|
|
38
31
|
|
|
39
32
|
_add(data, guild, { cache = true, allowUnknownGuild = false } = {}) {
|
|
40
33
|
const existing = this.cache.get(data.id);
|
|
@@ -71,49 +64,15 @@ class ChannelManager extends CachedManager {
|
|
|
71
64
|
this.cache.delete(id);
|
|
72
65
|
}
|
|
73
66
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
* @method resolve
|
|
84
|
-
* @memberof ChannelManager
|
|
85
|
-
* @instance
|
|
86
|
-
* @param {ChannelResolvable} channel The channel resolvable to resolve
|
|
87
|
-
* @returns {?BaseChannel}
|
|
88
|
-
*/
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Resolves a ChannelResolvable to a channel id string.
|
|
92
|
-
* @method resolveId
|
|
93
|
-
* @memberof ChannelManager
|
|
94
|
-
* @instance
|
|
95
|
-
* @param {ChannelResolvable} channel The channel resolvable to resolve
|
|
96
|
-
* @returns {?Snowflake}
|
|
97
|
-
*/
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Options for fetching a channel from Discord
|
|
101
|
-
* @typedef {BaseFetchOptions} FetchChannelOptions
|
|
102
|
-
* @property {boolean} [allowUnknownGuild=false] Allows the channel to be returned even if the guild is not in cache,
|
|
103
|
-
* it will not be cached. <warn>Many of the properties and methods on the returned channel will throw errors</warn>
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Obtains a channel from Discord, or the channel cache if it's already available.
|
|
108
|
-
* @param {Snowflake} id The channel's id
|
|
109
|
-
* @param {FetchChannelOptions} [options] Additional options for this fetch
|
|
110
|
-
* @returns {Promise<?BaseChannel>}
|
|
111
|
-
* @example
|
|
112
|
-
* // Fetch a channel by its id
|
|
113
|
-
* client.channels.fetch('222109930545610754')
|
|
114
|
-
* .then(channel => console.log(channel.name))
|
|
115
|
-
* .catch(console.error);
|
|
116
|
-
*/
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
117
76
|
async fetch(id, { allowUnknownGuild = false, cache = true, force = false } = {}) {
|
|
118
77
|
if (!force) {
|
|
119
78
|
const existing = this.cache.get(id);
|
|
@@ -3,50 +3,28 @@
|
|
|
3
3
|
const BaseManager = require('./BaseManager');
|
|
4
4
|
const { DiscordjsError, ErrorCodes } = require('../errors');
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
* Manages the API methods of a data model along with a collection of instances.
|
|
8
|
-
* @extends {BaseManager}
|
|
9
|
-
* @abstract
|
|
10
|
-
*/
|
|
6
|
+
|
|
11
7
|
class DataManager extends BaseManager {
|
|
12
8
|
constructor(client, holds) {
|
|
13
9
|
super(client);
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
* The data structure belonging to this manager.
|
|
17
|
-
* @name DataManager#holds
|
|
18
|
-
* @type {Function}
|
|
19
|
-
* @private
|
|
20
|
-
* @readonly
|
|
21
|
-
*/
|
|
11
|
+
|
|
22
12
|
Object.defineProperty(this, 'holds', { value: holds });
|
|
23
13
|
}
|
|
24
14
|
|
|
25
|
-
|
|
26
|
-
* The cache of items for this manager.
|
|
27
|
-
* @type {Collection}
|
|
28
|
-
* @abstract
|
|
29
|
-
*/
|
|
15
|
+
|
|
30
16
|
get cache() {
|
|
31
17
|
throw new DiscordjsError(ErrorCodes.NotImplemented, 'get cache', this.constructor.name);
|
|
32
18
|
}
|
|
33
19
|
|
|
34
|
-
|
|
35
|
-
* Resolves a data entry to a data Object.
|
|
36
|
-
* @param {string|Object} idOrInstance The id or instance of something in this Manager
|
|
37
|
-
* @returns {?Object} An instance from this Manager
|
|
38
|
-
*/
|
|
20
|
+
|
|
39
21
|
resolve(idOrInstance) {
|
|
40
22
|
if (idOrInstance instanceof this.holds) return idOrInstance;
|
|
41
23
|
if (typeof idOrInstance === 'string') return this.cache.get(idOrInstance) ?? null;
|
|
42
24
|
return null;
|
|
43
25
|
}
|
|
44
26
|
|
|
45
|
-
|
|
46
|
-
* Resolves a data entry to an instance id.
|
|
47
|
-
* @param {string|Object} idOrInstance The id or instance of something in this Manager
|
|
48
|
-
* @returns {?Snowflake}
|
|
49
|
-
*/
|
|
27
|
+
|
|
50
28
|
resolveId(idOrInstance) {
|
|
51
29
|
if (idOrInstance instanceof this.holds) return idOrInstance.id;
|
|
52
30
|
if (typeof idOrInstance === 'string') return idOrInstance;
|
|
@@ -3,24 +3,15 @@
|
|
|
3
3
|
const ApplicationCommandManager = require('./ApplicationCommandManager');
|
|
4
4
|
const ApplicationCommandPermissionsManager = require('./ApplicationCommandPermissionsManager');
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
* An extension for guild-specific application commands.
|
|
8
|
-
* @extends {ApplicationCommandManager}
|
|
9
|
-
*/
|
|
6
|
+
|
|
10
7
|
class GuildApplicationCommandManager extends ApplicationCommandManager {
|
|
11
8
|
constructor(guild, iterable) {
|
|
12
9
|
super(guild.client, iterable);
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
* The guild that this manager belongs to
|
|
16
|
-
* @type {Guild}
|
|
17
|
-
*/
|
|
11
|
+
|
|
18
12
|
this.guild = guild;
|
|
19
13
|
|
|
20
|
-
|
|
21
|
-
* The manager for permissions of arbitrary commands on this guild
|
|
22
|
-
* @type {ApplicationCommandPermissionsManager}
|
|
23
|
-
*/
|
|
14
|
+
|
|
24
15
|
this.permissions = new ApplicationCommandPermissionsManager(this);
|
|
25
16
|
}
|
|
26
17
|
}
|
|
@@ -11,92 +11,33 @@ const { GuildMember } = require('../structures/GuildMember');
|
|
|
11
11
|
|
|
12
12
|
let deprecationEmittedForDeleteMessageDays = false;
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
* Manages API methods for guild bans and stores their cache.
|
|
16
|
-
* @extends {CachedManager}
|
|
17
|
-
*/
|
|
14
|
+
|
|
18
15
|
class GuildBanManager extends CachedManager {
|
|
19
16
|
constructor(guild, iterable) {
|
|
20
17
|
super(guild.client, GuildBan, iterable);
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
* The guild this Manager belongs to
|
|
24
|
-
* @type {Guild}
|
|
25
|
-
*/
|
|
19
|
+
|
|
26
20
|
this.guild = guild;
|
|
27
21
|
}
|
|
28
22
|
|
|
29
|
-
|
|
30
|
-
* The cache of this Manager
|
|
31
|
-
* @type {Collection<Snowflake, GuildBan>}
|
|
32
|
-
* @name GuildBanManager#cache
|
|
33
|
-
*/
|
|
23
|
+
|
|
34
24
|
|
|
35
25
|
_add(data, cache) {
|
|
36
26
|
return super._add(data, cache, { id: data.user.id, extras: [this.guild] });
|
|
37
27
|
}
|
|
38
28
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
* * A User resolvable
|
|
43
|
-
* @typedef {GuildBan|UserResolvable} GuildBanResolvable
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Resolves a GuildBanResolvable to a GuildBan object.
|
|
48
|
-
* @param {GuildBanResolvable} ban The ban that is in the guild
|
|
49
|
-
* @returns {?GuildBan}
|
|
50
|
-
*/
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
51
32
|
resolve(ban) {
|
|
52
33
|
return super.resolve(ban) ?? super.resolve(this.client.users.resolveId(ban));
|
|
53
34
|
}
|
|
54
35
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Options used to fetch multiple bans from a guild.
|
|
63
|
-
* @typedef {Object} FetchBansOptions
|
|
64
|
-
* @property {number} [limit] The maximum number of bans to return
|
|
65
|
-
* @property {Snowflake} [before] Consider only bans before this id
|
|
66
|
-
* @property {Snowflake} [after] Consider only bans after this id
|
|
67
|
-
* @property {boolean} [cache] Whether to cache the fetched bans
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Fetches ban(s) from Discord.
|
|
72
|
-
* @param {UserResolvable|FetchBanOptions|FetchBansOptions} [options] Options for fetching guild ban(s)
|
|
73
|
-
* @returns {Promise<GuildBan|Collection<Snowflake, GuildBan>>}
|
|
74
|
-
* @example
|
|
75
|
-
* // Fetch multiple bans from a guild
|
|
76
|
-
* guild.bans.fetch()
|
|
77
|
-
* .then(console.log)
|
|
78
|
-
* .catch(console.error);
|
|
79
|
-
* @example
|
|
80
|
-
* // Fetch a maximum of 5 bans from a guild without caching
|
|
81
|
-
* guild.bans.fetch({ limit: 5, cache: false })
|
|
82
|
-
* .then(console.log)
|
|
83
|
-
* .catch(console.error);
|
|
84
|
-
* @example
|
|
85
|
-
* // Fetch a single ban
|
|
86
|
-
* guild.bans.fetch('351871113346809860')
|
|
87
|
-
* .then(console.log)
|
|
88
|
-
* .catch(console.error);
|
|
89
|
-
* @example
|
|
90
|
-
* // Fetch a single ban without checking cache
|
|
91
|
-
* guild.bans.fetch({ user, force: true })
|
|
92
|
-
* .then(console.log)
|
|
93
|
-
* .catch(console.error)
|
|
94
|
-
* @example
|
|
95
|
-
* // Fetch a single ban without caching
|
|
96
|
-
* guild.bans.fetch({ user, cache: false })
|
|
97
|
-
* .then(console.log)
|
|
98
|
-
* .catch(console.error);
|
|
99
|
-
*/
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
100
41
|
fetch(options) {
|
|
101
42
|
if (!options) return this._fetchMany();
|
|
102
43
|
const { user, cache, force, limit, before, after } = options;
|
|
@@ -128,29 +69,9 @@ class GuildBanManager extends CachedManager {
|
|
|
128
69
|
return data.reduce((col, ban) => col.set(ban.user.id, this._add(ban, options.cache)), new Collection());
|
|
129
70
|
}
|
|
130
71
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
* @property {number} [deleteMessageDays] Number of days of messages to delete, must be between 0 and 7, inclusive
|
|
135
|
-
* <warn>This property is deprecated. Use `deleteMessageSeconds` instead.</warn>
|
|
136
|
-
* @property {number} [deleteMessageSeconds] Number of seconds of messages to delete,
|
|
137
|
-
* must be between 0 and 604800 (7 days), inclusive
|
|
138
|
-
* @property {string} [reason] The reason for the ban
|
|
139
|
-
*/
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Bans a user from the guild.
|
|
143
|
-
* @param {UserResolvable} user The user to ban
|
|
144
|
-
* @param {BanOptions} [options] Options for the ban
|
|
145
|
-
* @returns {Promise<GuildMember|User|Snowflake>} Result object will be resolved as specifically as possible.
|
|
146
|
-
* If the GuildMember cannot be resolved, the User will instead be attempted to be resolved. If that also cannot
|
|
147
|
-
* be resolved, the user id will be the result.
|
|
148
|
-
* @example
|
|
149
|
-
* // Ban a user by id (or with a user/guild member object)
|
|
150
|
-
* guild.bans.create('84484653687267328')
|
|
151
|
-
* .then(banInfo => console.log(`Banned ${banInfo.user?.tag ?? banInfo.tag ?? banInfo}`))
|
|
152
|
-
* .catch(console.error);
|
|
153
|
-
*/
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
154
75
|
async create(user, options = {}) {
|
|
155
76
|
if (typeof options !== 'object') throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'options', 'object', true);
|
|
156
77
|
const id = this.client.users.resolveId(user);
|
|
@@ -158,7 +79,7 @@ class GuildBanManager extends CachedManager {
|
|
|
158
79
|
|
|
159
80
|
if (options.deleteMessageDays !== undefined && !deprecationEmittedForDeleteMessageDays) {
|
|
160
81
|
process.emitWarning(
|
|
161
|
-
|
|
82
|
+
|
|
162
83
|
'The deleteMessageDays option for GuildBanManager#create() is deprecated. Use the deleteMessageSeconds option instead.',
|
|
163
84
|
'DeprecationWarning',
|
|
164
85
|
);
|
|
@@ -182,17 +103,7 @@ class GuildBanManager extends CachedManager {
|
|
|
182
103
|
return id;
|
|
183
104
|
}
|
|
184
105
|
|
|
185
|
-
|
|
186
|
-
* Unbans a user from the guild.
|
|
187
|
-
* @param {UserResolvable} user The user to unban
|
|
188
|
-
* @param {string} [reason] Reason for unbanning user
|
|
189
|
-
* @returns {Promise<?User>}
|
|
190
|
-
* @example
|
|
191
|
-
* // Unban a user by id (or with a user/guild member object)
|
|
192
|
-
* guild.bans.remove('84484653687267328')
|
|
193
|
-
* .then(user => console.log(`Unbanned ${user.username} from ${guild.name}`))
|
|
194
|
-
* .catch(console.error);
|
|
195
|
-
*/
|
|
106
|
+
|
|
196
107
|
async remove(user, reason) {
|
|
197
108
|
const id = this.client.users.resolveId(user);
|
|
198
109
|
if (!id) throw new DiscordjsError(ErrorCodes.BanResolveId);
|