lolka.js 0.1.4 → 0.2.0
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 +6 -6
- package/package.json +21 -52
- package/src/client/BaseClient.js +120 -0
- package/src/client/Client.js +147 -446
- package/src/client/WebhookClient.js +103 -0
- package/src/client/actions/Action.js +3 -4
- package/src/client/actions/ActionsManager.js +65 -55
- package/src/client/actions/ApplicationCommandPermissionsUpdate.js +34 -0
- package/src/client/actions/AutoModerationActionExecution.js +26 -0
- package/src/client/actions/AutoModerationRuleCreate.js +27 -0
- package/src/client/actions/AutoModerationRuleDelete.js +31 -0
- package/src/client/actions/AutoModerationRuleUpdate.js +29 -0
- package/src/client/actions/ChannelCreate.js +3 -5
- package/src/client/actions/ChannelDelete.js +3 -4
- package/src/client/actions/ChannelUpdate.js +3 -3
- package/src/client/actions/EntitlementCreate.js +23 -0
- package/src/client/actions/EntitlementDelete.js +27 -0
- package/src/client/actions/EntitlementUpdate.js +25 -0
- package/src/client/actions/GuildAuditLogEntryCreate.js +29 -0
- package/src/client/actions/GuildBanAdd.js +20 -0
- package/src/client/actions/GuildBanRemove.js +25 -0
- package/src/client/actions/GuildChannelsPositionUpdate.js +3 -3
- package/src/client/actions/GuildDelete.js +44 -0
- package/src/client/actions/GuildEmojiCreate.js +3 -4
- package/src/client/actions/GuildEmojiDelete.js +3 -4
- package/src/client/actions/GuildEmojiUpdate.js +3 -4
- package/src/client/actions/GuildEmojisUpdate.js +2 -2
- package/src/client/actions/GuildIntegrationsUpdate.js +19 -0
- package/src/client/actions/GuildMemberRemove.js +6 -8
- package/src/client/actions/GuildMemberUpdate.js +6 -7
- package/src/client/actions/GuildRoleCreate.js +4 -6
- package/src/client/actions/GuildRoleDelete.js +3 -4
- package/src/client/actions/GuildRoleUpdate.js +39 -0
- package/src/client/actions/GuildRolesPositionUpdate.js +3 -3
- package/src/client/actions/GuildScheduledEventCreate.js +27 -0
- package/src/client/actions/GuildScheduledEventDelete.js +3 -4
- package/src/client/actions/GuildScheduledEventUpdate.js +30 -0
- package/src/client/actions/GuildScheduledEventUserAdd.js +3 -4
- package/src/client/actions/GuildScheduledEventUserRemove.js +3 -4
- package/src/client/actions/GuildSoundboardSoundDelete.js +3 -4
- package/src/client/actions/GuildStickerCreate.js +3 -4
- package/src/client/actions/GuildStickerDelete.js +3 -4
- package/src/client/actions/GuildStickerUpdate.js +3 -4
- package/src/client/actions/GuildStickersUpdate.js +2 -2
- package/src/client/actions/GuildUpdate.js +3 -4
- package/src/client/actions/InteractionCreate.js +15 -18
- package/src/client/actions/InviteCreate.js +27 -0
- package/src/client/actions/InviteDelete.js +29 -0
- package/src/client/actions/MessageCreate.js +3 -4
- package/src/client/actions/MessageDelete.js +3 -4
- package/src/client/actions/MessageDeleteBulk.js +3 -5
- package/src/client/actions/MessagePollVoteAdd.js +3 -4
- package/src/client/actions/MessagePollVoteRemove.js +3 -4
- package/src/client/actions/MessageReactionAdd.js +5 -7
- package/src/client/actions/MessageReactionRemove.js +4 -5
- package/src/client/actions/MessageReactionRemoveAll.js +4 -5
- package/src/client/actions/MessageReactionRemoveEmoji.js +4 -5
- package/src/client/actions/MessageUpdate.js +2 -2
- package/src/client/actions/PresenceUpdate.js +45 -0
- package/src/client/actions/StageInstanceCreate.js +3 -4
- package/src/client/actions/StageInstanceDelete.js +3 -4
- package/src/client/actions/StageInstanceUpdate.js +3 -4
- package/src/client/actions/ThreadCreate.js +3 -5
- package/src/client/actions/ThreadDelete.js +26 -0
- package/src/client/actions/ThreadListSync.js +60 -0
- package/src/client/actions/ThreadMemberUpdate.js +30 -0
- package/src/client/actions/ThreadMembersUpdate.js +3 -5
- package/src/client/actions/TypingStart.js +5 -6
- package/src/client/actions/UserUpdate.js +3 -4
- package/src/client/actions/VoiceStateUpdate.js +43 -0
- package/src/client/actions/WebhooksUpdate.js +37 -0
- package/src/client/voice/ClientVoiceManager.js +6 -10
- package/src/client/websocket/WebSocketManager.js +407 -0
- package/src/client/websocket/WebSocketShard.js +234 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_PERMISSIONS_UPDATE.js +2 -27
- package/src/client/websocket/handlers/AUTO_MODERATION_ACTION_EXECUTION.js +2 -15
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_CREATE.js +2 -16
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_DELETE.js +2 -19
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_UPDATE.js +2 -18
- package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js +1 -2
- package/src/client/websocket/handlers/CHANNEL_UPDATE.js +1 -2
- package/src/client/websocket/handlers/ENTITLEMENT_CREATE.js +2 -12
- package/src/client/websocket/handlers/ENTITLEMENT_DELETE.js +2 -16
- package/src/client/websocket/handlers/ENTITLEMENT_UPDATE.js +2 -14
- package/src/client/websocket/handlers/GUILD_AUDIT_LOG_ENTRY_CREATE.js +2 -17
- package/src/client/websocket/handlers/GUILD_BAN_ADD.js +2 -13
- package/src/client/websocket/handlers/GUILD_BAN_REMOVE.js +2 -18
- package/src/client/websocket/handlers/GUILD_CREATE.js +5 -7
- package/src/client/websocket/handlers/GUILD_DELETE.js +2 -34
- package/src/client/websocket/handlers/GUILD_INTEGRATIONS_UPDATE.js +2 -13
- package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js +1 -3
- package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +11 -9
- package/src/client/websocket/handlers/GUILD_MEMBER_REMOVE.js +2 -2
- package/src/client/websocket/handlers/GUILD_MEMBER_UPDATE.js +2 -2
- package/src/client/websocket/handlers/GUILD_ROLE_UPDATE.js +2 -19
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_CREATE.js +2 -15
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_UPDATE.js +2 -17
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.js +1 -2
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.js +1 -2
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.js +1 -2
- package/src/client/websocket/handlers/INVITE_CREATE.js +2 -18
- package/src/client/websocket/handlers/INVITE_DELETE.js +2 -21
- package/src/client/websocket/handlers/MESSAGE_UPDATE.js +1 -2
- package/src/client/websocket/handlers/PRESENCE_UPDATE.js +2 -40
- package/src/client/websocket/handlers/RATE_LIMITED.js +2 -1
- package/src/client/websocket/handlers/READY.js +5 -8
- package/src/client/websocket/handlers/RESUMED.js +14 -0
- package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.js +1 -2
- package/src/client/websocket/handlers/SUBSCRIPTION_CREATE.js +1 -2
- package/src/client/websocket/handlers/SUBSCRIPTION_DELETE.js +1 -2
- package/src/client/websocket/handlers/SUBSCRIPTION_UPDATE.js +1 -2
- package/src/client/websocket/handlers/THREAD_DELETE.js +2 -15
- package/src/client/websocket/handlers/THREAD_LIST_SYNC.js +2 -49
- package/src/client/websocket/handlers/THREAD_MEMBER_UPDATE.js +2 -23
- package/src/client/websocket/handlers/THREAD_UPDATE.js +1 -2
- package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.js +2 -3
- package/src/client/websocket/handlers/VOICE_SERVER_UPDATE.js +3 -30
- package/src/client/websocket/handlers/VOICE_STATE_UPDATE.js +2 -35
- package/src/client/websocket/handlers/WEBHOOKS_UPDATE.js +2 -14
- package/src/client/websocket/handlers/index.js +75 -74
- package/src/errors/DJSError.js +7 -7
- package/src/errors/ErrorCodes.js +134 -58
- package/src/errors/Messages.js +143 -115
- package/src/errors/index.js +3 -5
- package/src/index.js +226 -234
- package/src/managers/ApplicationCommandManager.js +24 -60
- package/src/managers/ApplicationCommandPermissionsManager.js +33 -57
- package/src/managers/ApplicationEmojiManager.js +8 -18
- package/src/managers/AutoModerationRuleManager.js +6 -24
- package/src/managers/BaseGuildEmojiManager.js +85 -0
- package/src/managers/BaseManager.js +1 -3
- package/src/managers/CachedManager.js +8 -12
- package/src/managers/CategoryChannelChildManager.js +4 -10
- package/src/managers/ChannelManager.js +8 -70
- package/src/managers/DMMessageManager.js +2 -4
- package/src/managers/DataManager.js +5 -10
- package/src/managers/EntitlementManager.js +8 -19
- package/src/managers/GuildApplicationCommandManager.js +3 -6
- package/src/managers/GuildBanManager.js +52 -27
- package/src/managers/GuildChannelManager.js +54 -91
- package/src/managers/GuildEmojiManager.js +18 -108
- package/src/managers/GuildEmojiRoleManager.js +14 -24
- package/src/managers/GuildForumThreadManager.js +5 -10
- package/src/managers/GuildInviteManager.js +27 -51
- package/src/managers/GuildManager.js +185 -45
- package/src/managers/GuildMemberManager.js +105 -89
- package/src/managers/GuildMemberRoleManager.js +14 -29
- package/src/managers/GuildMessageManager.js +2 -20
- package/src/managers/GuildScheduledEventManager.js +13 -31
- package/src/managers/GuildSoundboardSoundManager.js +5 -17
- package/src/managers/GuildStickerManager.js +21 -34
- package/src/managers/GuildTextThreadManager.js +5 -9
- package/src/managers/MessageManager.js +77 -64
- package/src/managers/PartialGroupDMMessageManager.js +2 -4
- package/src/managers/PermissionOverwriteManager.js +15 -26
- package/src/managers/PollAnswerVoterManager.js +2 -14
- package/src/managers/PresenceManager.js +6 -11
- package/src/managers/ReactionManager.js +6 -13
- package/src/managers/ReactionUserManager.js +4 -11
- package/src/managers/RoleManager.js +74 -76
- package/src/managers/StageInstanceManager.js +8 -18
- package/src/managers/SubscriptionManager.js +4 -9
- package/src/managers/ThreadManager.js +13 -33
- package/src/managers/ThreadMemberManager.js +34 -27
- package/src/managers/UserManager.js +34 -32
- package/src/managers/VoiceStateManager.js +4 -9
- package/src/sharding/Shard.js +40 -64
- package/src/sharding/ShardClientUtil.js +60 -60
- package/src/sharding/ShardingManager.js +30 -89
- package/src/structures/ActionRow.js +18 -6
- package/src/structures/ActionRowBuilder.js +35 -0
- package/src/structures/AnonymousGuild.js +10 -14
- package/src/structures/ApplicationCommand.js +49 -67
- package/src/structures/ApplicationEmoji.js +5 -22
- package/src/structures/ApplicationRoleConnectionMetadata.js +0 -6
- package/src/structures/Attachment.js +7 -25
- package/src/structures/AttachmentBuilder.js +111 -0
- package/src/structures/AutoModerationActionExecution.js +2 -17
- package/src/structures/AutoModerationRule.js +17 -46
- package/src/structures/AutocompleteInteraction.js +4 -14
- package/src/structures/Base.js +2 -4
- package/src/structures/BaseChannel.js +4 -21
- package/src/structures/BaseGuild.js +7 -19
- package/src/structures/BaseGuildEmoji.js +13 -13
- package/src/structures/BaseGuildTextChannel.js +16 -45
- package/src/structures/BaseGuildVoiceChannel.js +12 -43
- package/src/structures/BaseInteraction.js +25 -54
- package/src/structures/BaseSelectMenuComponent.js +2 -8
- package/src/structures/ButtonBuilder.js +44 -0
- package/src/structures/ButtonComponent.js +2 -9
- package/src/structures/ButtonInteraction.js +2 -3
- package/src/structures/CategoryChannel.js +3 -8
- package/src/structures/ChannelSelectMenuBuilder.js +31 -0
- package/src/structures/ChannelSelectMenuComponent.js +2 -4
- package/src/structures/ChannelSelectMenuInteraction.js +2 -5
- package/src/structures/ChatInputCommandInteraction.js +4 -7
- package/src/structures/ClientApplication.js +12 -60
- package/src/structures/ClientPresence.js +10 -15
- package/src/structures/ClientUser.js +19 -36
- package/src/structures/CommandInteraction.js +7 -27
- package/src/structures/CommandInteractionOptionResolver.js +8 -36
- package/src/structures/Component.js +1 -7
- package/src/structures/ContainerComponent.js +3 -9
- package/src/structures/ContextMenuCommandInteraction.js +5 -9
- package/src/structures/DMChannel.js +15 -34
- package/src/structures/DirectoryChannel.js +2 -6
- package/src/structures/Embed.js +2 -19
- package/src/structures/EmbedBuilder.js +50 -0
- package/src/structures/Emoji.js +19 -19
- package/src/structures/Entitlement.js +2 -22
- package/src/structures/FileComponent.js +3 -7
- package/src/structures/ForumChannel.js +3 -6
- package/src/structures/Guild.js +131 -187
- package/src/structures/GuildAuditLogs.js +6 -12
- package/src/structures/GuildAuditLogsEntry.js +63 -88
- package/src/structures/GuildBan.js +3 -9
- package/src/structures/GuildChannel.js +33 -68
- package/src/structures/GuildEmoji.js +7 -19
- package/src/structures/GuildMember.js +58 -107
- package/src/structures/GuildOnboarding.js +2 -9
- package/src/structures/GuildOnboardingPrompt.js +2 -12
- package/src/structures/GuildOnboardingPromptOption.js +2 -12
- package/src/structures/GuildPreview.js +21 -30
- package/src/structures/GuildPreviewEmoji.js +2 -5
- package/src/structures/GuildScheduledEvent.js +19 -59
- package/src/structures/GuildTemplate.js +45 -24
- package/src/structures/Integration.js +7 -30
- package/src/structures/IntegrationApplication.js +12 -9
- package/src/structures/InteractionCallback.js +1 -10
- package/src/structures/InteractionCallbackResource.js +2 -7
- package/src/structures/InteractionCallbackResponse.js +3 -6
- package/src/structures/InteractionCollector.js +36 -23
- package/src/structures/InteractionResponse.js +102 -0
- package/src/structures/InteractionWebhook.js +6 -14
- package/src/structures/Invite.js +341 -0
- package/src/structures/InviteGuild.js +4 -6
- package/src/structures/InviteStageInstance.js +87 -0
- package/src/structures/LabelComponent.js +3 -3
- package/src/structures/MediaChannel.js +2 -3
- package/src/structures/MediaGalleryComponent.js +3 -6
- package/src/structures/MediaGalleryItem.js +2 -7
- package/src/structures/MentionableSelectMenuBuilder.js +32 -0
- package/src/structures/MentionableSelectMenuComponent.js +2 -3
- package/src/structures/MentionableSelectMenuInteraction.js +3 -8
- package/src/structures/Message.js +100 -169
- package/src/structures/MessageCollector.js +5 -16
- package/src/structures/MessageComponentInteraction.js +14 -34
- package/src/structures/MessageContextMenuCommandInteraction.js +2 -4
- package/src/structures/MessageMentions.js +4 -30
- package/src/structures/MessagePayload.js +90 -92
- package/src/structures/MessageReaction.js +17 -31
- package/src/structures/ModalBuilder.js +36 -0
- package/src/structures/{ModalComponentResolver.js → ModalSubmitFields.js} +31 -37
- package/src/structures/ModalSubmitInteraction.js +55 -54
- package/src/structures/NewsChannel.js +32 -0
- package/src/structures/OAuth2Guild.js +3 -6
- package/src/structures/PartialGroupDMChannel.js +11 -23
- package/src/structures/PermissionOverwrites.js +25 -47
- package/src/structures/Poll.js +4 -19
- package/src/structures/PollAnswer.js +29 -13
- package/src/structures/Presence.js +13 -57
- package/src/structures/PrimaryEntryPointCommandInteraction.js +2 -3
- package/src/structures/ReactionCollector.js +4 -21
- package/src/structures/ReactionEmoji.js +3 -5
- package/src/structures/Role.js +48 -65
- package/src/structures/RoleSelectMenuBuilder.js +31 -0
- package/src/structures/RoleSelectMenuComponent.js +2 -3
- package/src/structures/RoleSelectMenuInteraction.js +2 -5
- package/src/structures/SKU.js +2 -9
- package/src/structures/SectionComponent.js +3 -7
- package/src/structures/SelectMenuBuilder.js +26 -0
- package/src/structures/SelectMenuComponent.js +26 -0
- package/src/structures/SelectMenuInteraction.js +26 -0
- package/src/structures/SelectMenuOptionBuilder.js +26 -0
- package/src/structures/SeparatorComponent.js +2 -5
- package/src/structures/SoundboardSound.js +2 -18
- package/src/structures/StageChannel.js +4 -13
- package/src/structures/StageInstance.js +16 -19
- package/src/structures/Sticker.js +4 -28
- package/src/structures/StickerPack.js +4 -16
- package/src/structures/StringSelectMenuBuilder.js +79 -0
- package/src/structures/StringSelectMenuComponent.js +2 -4
- package/src/structures/StringSelectMenuInteraction.js +2 -4
- package/src/structures/StringSelectMenuOptionBuilder.js +49 -0
- package/src/structures/Subscription.js +1 -15
- package/src/structures/Team.js +7 -16
- package/src/structures/TeamMember.js +15 -9
- package/src/structures/TextChannel.js +3 -6
- package/src/structures/TextDisplayComponent.js +2 -4
- package/src/structures/TextInputBuilder.js +31 -0
- package/src/structures/TextInputComponent.js +2 -5
- package/src/structures/ThreadChannel.js +35 -85
- package/src/structures/ThreadMember.js +12 -17
- package/src/structures/ThreadOnlyChannel.js +15 -36
- package/src/structures/ThumbnailComponent.js +3 -8
- package/src/structures/Typing.js +2 -10
- package/src/structures/UnfurledMediaItem.js +2 -5
- package/src/structures/User.js +68 -60
- package/src/structures/UserContextMenuCommandInteraction.js +2 -5
- package/src/structures/UserSelectMenuBuilder.js +31 -0
- package/src/structures/UserSelectMenuComponent.js +2 -3
- package/src/structures/UserSelectMenuInteraction.js +3 -7
- package/src/structures/VoiceChannel.js +4 -11
- package/src/structures/VoiceChannelEffect.js +2 -12
- package/src/structures/VoiceRegion.js +2 -7
- package/src/structures/VoiceState.js +10 -36
- package/src/structures/Webhook.js +37 -65
- package/src/structures/WelcomeChannel.js +5 -12
- package/src/structures/WelcomeScreen.js +3 -8
- package/src/structures/Widget.js +3 -13
- package/src/structures/WidgetMember.js +2 -17
- package/src/structures/interfaces/Application.js +10 -19
- package/src/structures/interfaces/Collector.js +12 -45
- package/src/structures/interfaces/InteractionResponses.js +152 -43
- package/src/structures/interfaces/TextBasedChannel.js +99 -83
- package/src/util/APITypes.js +16 -30
- package/src/util/ActivityFlagsBitField.js +2 -5
- package/src/util/ApplicationFlagsBitField.js +6 -11
- package/src/util/AttachmentFlagsBitField.js +2 -5
- package/src/util/BitField.js +8 -27
- package/src/util/ChannelFlagsBitField.js +6 -11
- package/src/util/Channels.js +61 -73
- package/src/util/Colors.js +43 -43
- package/src/util/Components.js +82 -61
- package/src/util/Constants.js +124 -94
- package/src/util/DataResolver.js +17 -36
- package/src/util/Enums.js +1 -2
- package/src/util/Events.js +14 -3
- package/src/util/Formatters.js +413 -0
- package/src/util/GuildMemberFlagsBitField.js +5 -9
- package/src/util/IntentsBitField.js +6 -10
- package/src/util/InviteFlagsBitField.js +1 -2
- package/src/util/LimitedCollection.js +6 -13
- package/src/util/LolkaSnowflake.js +14 -1
- package/src/util/MessageFlagsBitField.js +6 -11
- package/src/util/Options.js +57 -35
- package/src/util/Partials.js +4 -5
- package/src/util/PermissionsBitField.js +8 -21
- package/src/util/RoleFlagsBitField.js +2 -5
- package/src/util/SKUFlagsBitField.js +1 -4
- package/src/util/ShardEvents.js +3 -1
- package/src/util/Status.js +21 -5
- package/src/util/Sweepers.js +13 -59
- package/src/util/SystemChannelFlagsBitField.js +6 -11
- package/src/util/ThreadMemberFlagsBitField.js +2 -6
- package/src/util/Transformers.js +18 -17
- package/src/util/UserFlagsBitField.js +2 -6
- package/src/util/Util.js +97 -148
- package/src/util/WebSocketShardEvents.js +25 -0
- package/typings/index.d.mts +2394 -1771
- package/typings/index.d.ts +2394 -1771
- package/typings/rawDataTypes.d.ts +211 -0
- package/src/structures/ActivityInstance.js +0 -52
- package/src/structures/ActivityLocation.js +0 -65
- package/src/structures/AnnouncementChannel.js +0 -29
- package/src/structures/AuthorizingIntegrationOwners.js +0 -64
- package/src/structures/BaseInvite.js +0 -187
- package/src/structures/GroupDMInvite.js +0 -37
- package/src/structures/GuildInvite.js +0 -223
- package/src/util/Invites.js +0 -31
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
const { Collection } = require('@discordjs/collection');
|
|
4
4
|
const { Routes } = require('discord-api-types/v10');
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const CachedManager = require('./CachedManager');
|
|
6
|
+
const AutoModerationRule = require('../structures/AutoModerationRule');
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Manages API methods for auto moderation rules and stores their cache.
|
|
10
|
-
*
|
|
11
10
|
* @extends {CachedManager}
|
|
12
11
|
*/
|
|
13
12
|
class AutoModerationRuleManager extends CachedManager {
|
|
@@ -16,7 +15,6 @@ class AutoModerationRuleManager extends CachedManager {
|
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
17
|
* The guild this manager belongs to.
|
|
19
|
-
*
|
|
20
18
|
* @type {Guild}
|
|
21
19
|
*/
|
|
22
20
|
this.guild = guild;
|
|
@@ -24,14 +22,12 @@ class AutoModerationRuleManager extends CachedManager {
|
|
|
24
22
|
|
|
25
23
|
/**
|
|
26
24
|
* The cache of this manager
|
|
27
|
-
*
|
|
28
25
|
* @type {Collection<Snowflake, AutoModerationRule>}
|
|
29
26
|
* @name AutoModerationRuleManager#cache
|
|
30
27
|
*/
|
|
31
28
|
|
|
32
29
|
/**
|
|
33
30
|
* Resolves an {@link AutoModerationRuleResolvable} to an {@link AutoModerationRule} object.
|
|
34
|
-
*
|
|
35
31
|
* @method resolve
|
|
36
32
|
* @memberof AutoModerationRuleManager
|
|
37
33
|
* @instance
|
|
@@ -41,7 +37,6 @@ class AutoModerationRuleManager extends CachedManager {
|
|
|
41
37
|
|
|
42
38
|
/**
|
|
43
39
|
* Resolves an {@link AutoModerationRuleResolvable} to a {@link AutoModerationRule} id.
|
|
44
|
-
*
|
|
45
40
|
* @method resolveId
|
|
46
41
|
* @memberof AutoModerationRuleManager
|
|
47
42
|
* @instance
|
|
@@ -55,7 +50,6 @@ class AutoModerationRuleManager extends CachedManager {
|
|
|
55
50
|
|
|
56
51
|
/**
|
|
57
52
|
* Options used to set the trigger metadata of an auto moderation rule.
|
|
58
|
-
*
|
|
59
53
|
* @typedef {Object} AutoModerationTriggerMetadataOptions
|
|
60
54
|
* @property {string[]} [keywordFilter] The substrings that will be searched for in the content
|
|
61
55
|
* @property {string[]} [regexPatterns] The regular expression patterns which will be matched against the content
|
|
@@ -72,7 +66,6 @@ class AutoModerationRuleManager extends CachedManager {
|
|
|
72
66
|
|
|
73
67
|
/**
|
|
74
68
|
* Options used to set the actions of an auto moderation rule.
|
|
75
|
-
*
|
|
76
69
|
* @typedef {Object} AutoModerationActionOptions
|
|
77
70
|
* @property {AutoModerationActionType} type The type of this auto moderation rule action
|
|
78
71
|
* @property {AutoModerationActionMetadataOptions} [metadata] Additional metadata needed during execution
|
|
@@ -82,7 +75,6 @@ class AutoModerationRuleManager extends CachedManager {
|
|
|
82
75
|
|
|
83
76
|
/**
|
|
84
77
|
* Options used to set the metadata of an auto moderation rule action.
|
|
85
|
-
*
|
|
86
78
|
* @typedef {Object} AutoModerationActionMetadataOptions
|
|
87
79
|
* @property {GuildTextChannelResolvable|ThreadChannel} [channel] The channel to which content will be logged
|
|
88
80
|
* @property {number} [durationSeconds] The timeout duration in seconds
|
|
@@ -91,7 +83,6 @@ class AutoModerationRuleManager extends CachedManager {
|
|
|
91
83
|
|
|
92
84
|
/**
|
|
93
85
|
* Options used to create an auto moderation rule.
|
|
94
|
-
*
|
|
95
86
|
* @typedef {Object} AutoModerationRuleCreateOptions
|
|
96
87
|
* @property {string} name The name of the auto moderation rule
|
|
97
88
|
* @property {AutoModerationRuleEventType} eventType The event type of the auto moderation rule
|
|
@@ -114,7 +105,6 @@ class AutoModerationRuleManager extends CachedManager {
|
|
|
114
105
|
|
|
115
106
|
/**
|
|
116
107
|
* Creates a new auto moderation rule.
|
|
117
|
-
*
|
|
118
108
|
* @param {AutoModerationRuleCreateOptions} options Options for creating the auto moderation rule
|
|
119
109
|
* @returns {Promise<AutoModerationRule>}
|
|
120
110
|
*/
|
|
@@ -162,7 +152,6 @@ class AutoModerationRuleManager extends CachedManager {
|
|
|
162
152
|
|
|
163
153
|
/**
|
|
164
154
|
* Options used to edit an auto moderation rule.
|
|
165
|
-
*
|
|
166
155
|
* @typedef {Object} AutoModerationRuleEditOptions
|
|
167
156
|
* @property {string} [name] The name of the auto moderation rule
|
|
168
157
|
* @property {AutoModerationRuleEventType} [eventType] The event type of the auto moderation rule
|
|
@@ -179,7 +168,6 @@ class AutoModerationRuleManager extends CachedManager {
|
|
|
179
168
|
|
|
180
169
|
/**
|
|
181
170
|
* Edits an auto moderation rule.
|
|
182
|
-
*
|
|
183
171
|
* @param {AutoModerationRuleResolvable} autoModerationRule The auto moderation rule to edit
|
|
184
172
|
* @param {AutoModerationRuleEditOptions} options Options for editing the auto moderation rule
|
|
185
173
|
* @returns {Promise<AutoModerationRule>}
|
|
@@ -222,29 +210,25 @@ class AutoModerationRuleManager extends CachedManager {
|
|
|
222
210
|
|
|
223
211
|
/**
|
|
224
212
|
* Data that can be resolved to give an AutoModerationRule object. This can be:
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
213
|
+
* * An AutoModerationRule
|
|
214
|
+
* * A Snowflake
|
|
228
215
|
* @typedef {AutoModerationRule|Snowflake} AutoModerationRuleResolvable
|
|
229
216
|
*/
|
|
230
217
|
|
|
231
218
|
/**
|
|
232
219
|
* Options used to fetch a single auto moderation rule from a guild.
|
|
233
|
-
*
|
|
234
220
|
* @typedef {BaseFetchOptions} FetchAutoModerationRuleOptions
|
|
235
221
|
* @property {AutoModerationRuleResolvable} autoModerationRule The auto moderation rule to fetch
|
|
236
222
|
*/
|
|
237
223
|
|
|
238
224
|
/**
|
|
239
225
|
* Options used to fetch all auto moderation rules from a guild.
|
|
240
|
-
*
|
|
241
226
|
* @typedef {Object} FetchAutoModerationRulesOptions
|
|
242
227
|
* @property {boolean} [cache] Whether to cache the fetched auto moderation rules
|
|
243
228
|
*/
|
|
244
229
|
|
|
245
230
|
/**
|
|
246
231
|
* Fetches auto moderation rules from Discord.
|
|
247
|
-
*
|
|
248
232
|
* @param {AutoModerationRuleResolvable|FetchAutoModerationRuleOptions|FetchAutoModerationRulesOptions} [options]
|
|
249
233
|
* Options for fetching auto moderation rule(s)
|
|
250
234
|
* @returns {Promise<AutoModerationRule|Collection<Snowflake, AutoModerationRule>>}
|
|
@@ -264,14 +248,13 @@ class AutoModerationRuleManager extends CachedManager {
|
|
|
264
248
|
* .then(console.log)
|
|
265
249
|
* .catch(console.error)
|
|
266
250
|
*/
|
|
267
|
-
|
|
251
|
+
fetch(options) {
|
|
268
252
|
if (!options) return this._fetchMany();
|
|
269
253
|
const { autoModerationRule, cache, force } = options;
|
|
270
254
|
const resolvedAutoModerationRule = this.resolveId(autoModerationRule ?? options);
|
|
271
255
|
if (resolvedAutoModerationRule) {
|
|
272
256
|
return this._fetchSingle({ autoModerationRule: resolvedAutoModerationRule, cache, force });
|
|
273
257
|
}
|
|
274
|
-
|
|
275
258
|
return this._fetchMany(options);
|
|
276
259
|
}
|
|
277
260
|
|
|
@@ -296,7 +279,6 @@ class AutoModerationRuleManager extends CachedManager {
|
|
|
296
279
|
|
|
297
280
|
/**
|
|
298
281
|
* Deletes an auto moderation rule.
|
|
299
|
-
*
|
|
300
282
|
* @param {AutoModerationRuleResolvable} autoModerationRule The auto moderation rule to delete
|
|
301
283
|
* @param {string} [reason] The reason for deleting the auto moderation rule
|
|
302
284
|
* @returns {Promise<void>}
|
|
@@ -307,4 +289,4 @@ class AutoModerationRuleManager extends CachedManager {
|
|
|
307
289
|
}
|
|
308
290
|
}
|
|
309
291
|
|
|
310
|
-
exports
|
|
292
|
+
module.exports = AutoModerationRuleManager;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const CachedManager = require('./CachedManager');
|
|
4
|
+
const ApplicationEmoji = require('../structures/ApplicationEmoji');
|
|
5
|
+
const GuildEmoji = require('../structures/GuildEmoji');
|
|
6
|
+
const ReactionEmoji = require('../structures/ReactionEmoji');
|
|
7
|
+
const { parseEmoji } = require('../util/Util');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Holds methods to resolve GuildEmojis and stores their cache.
|
|
11
|
+
* @extends {CachedManager}
|
|
12
|
+
*/
|
|
13
|
+
class BaseGuildEmojiManager extends CachedManager {
|
|
14
|
+
constructor(client, iterable) {
|
|
15
|
+
super(client, GuildEmoji, iterable);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The cache of GuildEmojis
|
|
20
|
+
* @type {Collection<Snowflake, GuildEmoji>}
|
|
21
|
+
* @name BaseGuildEmojiManager#cache
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Data that can be resolved into a GuildEmoji object. This can be:
|
|
26
|
+
* * A Snowflake
|
|
27
|
+
* * A GuildEmoji object
|
|
28
|
+
* * A ReactionEmoji object
|
|
29
|
+
* * An ApplicationEmoji object
|
|
30
|
+
* @typedef {Snowflake|GuildEmoji|ReactionEmoji|ApplicationEmoji} EmojiResolvable
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Resolves an EmojiResolvable to an Emoji object.
|
|
35
|
+
* @param {EmojiResolvable} emoji The Emoji resolvable to identify
|
|
36
|
+
* @returns {?GuildEmoji}
|
|
37
|
+
*/
|
|
38
|
+
resolve(emoji) {
|
|
39
|
+
if (emoji instanceof ReactionEmoji) return this.cache.get(emoji.id) ?? null;
|
|
40
|
+
if (emoji instanceof ApplicationEmoji) return this.cache.get(emoji.id) ?? null;
|
|
41
|
+
return super.resolve(emoji);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Resolves an EmojiResolvable to an Emoji id string.
|
|
46
|
+
* @param {EmojiResolvable} emoji The Emoji resolvable to identify
|
|
47
|
+
* @returns {?Snowflake}
|
|
48
|
+
*/
|
|
49
|
+
resolveId(emoji) {
|
|
50
|
+
if (emoji instanceof ReactionEmoji) return emoji.id;
|
|
51
|
+
if (emoji instanceof ApplicationEmoji) return emoji.id;
|
|
52
|
+
return super.resolveId(emoji);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Data that can be resolved to give an emoji identifier. This can be:
|
|
57
|
+
* * An EmojiResolvable
|
|
58
|
+
* * The `<a:name:id>`, `<:name:id>`, `a:name:id` or `name:id` emoji identifier string of an emoji
|
|
59
|
+
* * The Unicode representation of an emoji
|
|
60
|
+
* @typedef {string|EmojiResolvable} EmojiIdentifierResolvable
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Resolves an EmojiResolvable to an emoji identifier.
|
|
65
|
+
* @param {EmojiIdentifierResolvable} emoji The emoji resolvable to resolve
|
|
66
|
+
* @returns {?string}
|
|
67
|
+
*/
|
|
68
|
+
resolveIdentifier(emoji) {
|
|
69
|
+
const emojiResolvable = this.resolve(emoji);
|
|
70
|
+
if (emojiResolvable) return emojiResolvable.identifier;
|
|
71
|
+
if (emoji instanceof ReactionEmoji) return emoji.identifier;
|
|
72
|
+
if (emoji instanceof ApplicationEmoji) return emoji.identifier;
|
|
73
|
+
if (typeof emoji === 'string') {
|
|
74
|
+
const res = parseEmoji(emoji);
|
|
75
|
+
if (res?.name.length) {
|
|
76
|
+
emoji = `${res.animated ? 'a:' : ''}${res.name}${res.id ? `:${res.id}` : ''}`;
|
|
77
|
+
}
|
|
78
|
+
if (!emoji.includes('%')) return encodeURIComponent(emoji);
|
|
79
|
+
return emoji;
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
module.exports = BaseGuildEmojiManager;
|
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Manages the API methods of a data model.
|
|
5
|
-
*
|
|
6
5
|
* @abstract
|
|
7
6
|
*/
|
|
8
7
|
class BaseManager {
|
|
9
8
|
constructor(client) {
|
|
10
9
|
/**
|
|
11
10
|
* The client that instantiated this Manager
|
|
12
|
-
*
|
|
13
11
|
* @name BaseManager#client
|
|
14
12
|
* @type {Client}
|
|
15
13
|
* @readonly
|
|
@@ -18,4 +16,4 @@ class BaseManager {
|
|
|
18
16
|
}
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
exports
|
|
19
|
+
module.exports = BaseManager;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const {
|
|
3
|
+
const DataManager = require('./DataManager');
|
|
4
|
+
const { MakeCacheOverrideSymbol } = require('../util/Symbols');
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Manages the API methods of a data model with a mutable cache of instances.
|
|
8
|
-
*
|
|
9
8
|
* @extends {DataManager}
|
|
10
9
|
* @abstract
|
|
11
10
|
*/
|
|
@@ -15,18 +14,17 @@ class CachedManager extends DataManager {
|
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* The private cache of items for this manager.
|
|
18
|
-
*
|
|
19
17
|
* @type {Collection}
|
|
20
18
|
* @private
|
|
21
19
|
* @readonly
|
|
22
20
|
* @name CachedManager#_cache
|
|
23
21
|
*/
|
|
24
22
|
Object.defineProperty(this, '_cache', {
|
|
25
|
-
value: this.client.options.makeCache(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
value: this.client.options.makeCache(
|
|
24
|
+
this.constructor[MakeCacheOverrideSymbol] ?? this.constructor,
|
|
25
|
+
this.holds,
|
|
26
|
+
this.constructor,
|
|
27
|
+
),
|
|
30
28
|
});
|
|
31
29
|
|
|
32
30
|
if (iterable) {
|
|
@@ -38,7 +36,6 @@ class CachedManager extends DataManager {
|
|
|
38
36
|
|
|
39
37
|
/**
|
|
40
38
|
* The cache of items for this manager.
|
|
41
|
-
*
|
|
42
39
|
* @type {Collection}
|
|
43
40
|
* @abstract
|
|
44
41
|
*/
|
|
@@ -53,7 +50,6 @@ class CachedManager extends DataManager {
|
|
|
53
50
|
existing._patch(data);
|
|
54
51
|
return existing;
|
|
55
52
|
}
|
|
56
|
-
|
|
57
53
|
const clone = existing._clone();
|
|
58
54
|
clone._patch(data);
|
|
59
55
|
return clone;
|
|
@@ -65,4 +61,4 @@ class CachedManager extends DataManager {
|
|
|
65
61
|
}
|
|
66
62
|
}
|
|
67
63
|
|
|
68
|
-
exports
|
|
64
|
+
module.exports = CachedManager;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const DataManager = require('./DataManager');
|
|
4
|
+
const GuildChannel = require('../structures/GuildChannel');
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Manages API methods for CategoryChannels' children.
|
|
8
|
-
*
|
|
9
8
|
* @extends {DataManager}
|
|
10
9
|
*/
|
|
11
10
|
class CategoryChannelChildManager extends DataManager {
|
|
@@ -13,7 +12,6 @@ class CategoryChannelChildManager extends DataManager {
|
|
|
13
12
|
super(channel.client, GuildChannel);
|
|
14
13
|
/**
|
|
15
14
|
* The category channel this manager belongs to
|
|
16
|
-
*
|
|
17
15
|
* @type {CategoryChannel}
|
|
18
16
|
*/
|
|
19
17
|
this.channel = channel;
|
|
@@ -21,7 +19,6 @@ class CategoryChannelChildManager extends DataManager {
|
|
|
21
19
|
|
|
22
20
|
/**
|
|
23
21
|
* The channels that are a part of this category
|
|
24
|
-
*
|
|
25
22
|
* @type {Collection<Snowflake, GuildChannel>}
|
|
26
23
|
* @readonly
|
|
27
24
|
*/
|
|
@@ -31,7 +28,6 @@ class CategoryChannelChildManager extends DataManager {
|
|
|
31
28
|
|
|
32
29
|
/**
|
|
33
30
|
* The guild this manager belongs to
|
|
34
|
-
*
|
|
35
31
|
* @type {Guild}
|
|
36
32
|
* @readonly
|
|
37
33
|
*/
|
|
@@ -41,7 +37,6 @@ class CategoryChannelChildManager extends DataManager {
|
|
|
41
37
|
|
|
42
38
|
/**
|
|
43
39
|
* Options for creating a channel using {@link CategoryChannelChildManager#create}.
|
|
44
|
-
*
|
|
45
40
|
* @typedef {Object} CategoryCreateChannelOptions
|
|
46
41
|
* @property {string} name The name for the new channel
|
|
47
42
|
* @property {ChannelType} [type=ChannelType.GuildText] The type of the new channel.
|
|
@@ -70,11 +65,10 @@ class CategoryChannelChildManager extends DataManager {
|
|
|
70
65
|
/**
|
|
71
66
|
* Creates a new channel within this category.
|
|
72
67
|
* <info>You cannot create a channel of type {@link ChannelType.GuildCategory} inside a CategoryChannel.</info>
|
|
73
|
-
*
|
|
74
68
|
* @param {CategoryCreateChannelOptions} options Options for creating the new channel
|
|
75
69
|
* @returns {Promise<GuildChannel>}
|
|
76
70
|
*/
|
|
77
|
-
|
|
71
|
+
create(options) {
|
|
78
72
|
return this.guild.channels.create({
|
|
79
73
|
...options,
|
|
80
74
|
parent: this.channel.id,
|
|
@@ -82,4 +76,4 @@ class CategoryChannelChildManager extends DataManager {
|
|
|
82
76
|
}
|
|
83
77
|
}
|
|
84
78
|
|
|
85
|
-
exports
|
|
79
|
+
module.exports = CategoryChannelChildManager;
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const process = require('node:process');
|
|
4
|
-
const { lazy, isFileBodyEncodable, isJSONEncodable } = require('@discordjs/util');
|
|
5
4
|
const { Routes } = require('discord-api-types/v10');
|
|
6
|
-
const
|
|
7
|
-
const {
|
|
8
|
-
const { createChannel } = require('../util/Channels
|
|
9
|
-
const { ThreadChannelTypes } = require('../util/Constants
|
|
10
|
-
const
|
|
11
|
-
const { CachedManager } = require('./CachedManager.js');
|
|
12
|
-
|
|
13
|
-
const getMessage = lazy(() => require('../structures/Message.js').Message);
|
|
5
|
+
const CachedManager = require('./CachedManager');
|
|
6
|
+
const { BaseChannel } = require('../structures/BaseChannel');
|
|
7
|
+
const { createChannel } = require('../util/Channels');
|
|
8
|
+
const { ThreadChannelTypes } = require('../util/Constants');
|
|
9
|
+
const Events = require('../util/Events');
|
|
14
10
|
|
|
15
11
|
let cacheWarningEmitted = false;
|
|
16
12
|
|
|
17
13
|
/**
|
|
18
14
|
* A manager of channels belonging to a client
|
|
19
|
-
*
|
|
20
15
|
* @extends {CachedManager}
|
|
21
16
|
*/
|
|
22
17
|
class ChannelManager extends CachedManager {
|
|
@@ -37,7 +32,6 @@ class ChannelManager extends CachedManager {
|
|
|
37
32
|
|
|
38
33
|
/**
|
|
39
34
|
* The cache of Channels
|
|
40
|
-
*
|
|
41
35
|
* @type {Collection<Snowflake, BaseChannel>}
|
|
42
36
|
* @name ChannelManager#cache
|
|
43
37
|
*/
|
|
@@ -50,7 +44,6 @@ class ChannelManager extends CachedManager {
|
|
|
50
44
|
if (ThreadChannelTypes.includes(existing.type)) {
|
|
51
45
|
existing.parent?.threads?._add(existing);
|
|
52
46
|
}
|
|
53
|
-
|
|
54
47
|
return existing;
|
|
55
48
|
}
|
|
56
49
|
|
|
@@ -87,15 +80,13 @@ class ChannelManager extends CachedManager {
|
|
|
87
80
|
|
|
88
81
|
/**
|
|
89
82
|
* Data that can be resolved to give a Channel object. This can be:
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
83
|
+
* * A Channel object
|
|
84
|
+
* * A Snowflake
|
|
93
85
|
* @typedef {BaseChannel|Snowflake} ChannelResolvable
|
|
94
86
|
*/
|
|
95
87
|
|
|
96
88
|
/**
|
|
97
89
|
* Resolves a ChannelResolvable to a Channel object.
|
|
98
|
-
*
|
|
99
90
|
* @method resolve
|
|
100
91
|
* @memberof ChannelManager
|
|
101
92
|
* @instance
|
|
@@ -105,7 +96,6 @@ class ChannelManager extends CachedManager {
|
|
|
105
96
|
|
|
106
97
|
/**
|
|
107
98
|
* Resolves a ChannelResolvable to a channel id string.
|
|
108
|
-
*
|
|
109
99
|
* @method resolveId
|
|
110
100
|
* @memberof ChannelManager
|
|
111
101
|
* @instance
|
|
@@ -115,7 +105,6 @@ class ChannelManager extends CachedManager {
|
|
|
115
105
|
|
|
116
106
|
/**
|
|
117
107
|
* Options for fetching a channel from Discord
|
|
118
|
-
*
|
|
119
108
|
* @typedef {BaseFetchOptions} FetchChannelOptions
|
|
120
109
|
* @property {boolean} [allowUnknownGuild=false] Allows the channel to be returned even if the guild is not in cache,
|
|
121
110
|
* it will not be cached. <warn>Many of the properties and methods on the returned channel will throw errors</warn>
|
|
@@ -123,7 +112,6 @@ class ChannelManager extends CachedManager {
|
|
|
123
112
|
|
|
124
113
|
/**
|
|
125
114
|
* Obtains a channel from Discord, or the channel cache if it's already available.
|
|
126
|
-
*
|
|
127
115
|
* @param {Snowflake} id The channel's id
|
|
128
116
|
* @param {FetchChannelOptions} [options] Additional options for this fetch
|
|
129
117
|
* @returns {Promise<?BaseChannel>}
|
|
@@ -142,56 +130,6 @@ class ChannelManager extends CachedManager {
|
|
|
142
130
|
const data = await this.client.rest.get(Routes.channel(id));
|
|
143
131
|
return this._add(data, null, { cache, allowUnknownGuild });
|
|
144
132
|
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Creates a message in a channel.
|
|
148
|
-
*
|
|
149
|
-
* @param {TextChannelResolvable} channel The channel to send the message to
|
|
150
|
-
* @param {string|MessagePayload|MessageCreateOptions|JSONEncodable<RESTPostAPIChannelMessageJSONBody>|FileBodyEncodable<RESTPostAPIChannelMessageJSONBody>} options The options to provide
|
|
151
|
-
* @returns {Promise<Message>}
|
|
152
|
-
* @example
|
|
153
|
-
* // Send a basic message
|
|
154
|
-
* client.channels.createMessage(channel, 'hello!')
|
|
155
|
-
* .then(message => console.log(`Sent message: ${message.content}`))
|
|
156
|
-
* .catch(console.error);
|
|
157
|
-
* @example
|
|
158
|
-
* // Send a remote file
|
|
159
|
-
* client.channels.createMessage(channel, {
|
|
160
|
-
* files: ['https://github.com/discordjs.png']
|
|
161
|
-
* })
|
|
162
|
-
* .then(console.log)
|
|
163
|
-
* .catch(console.error);
|
|
164
|
-
* @example
|
|
165
|
-
* // Send a local file
|
|
166
|
-
* client.channels.createMessage(channel, {
|
|
167
|
-
* files: [{
|
|
168
|
-
* attachment: 'entire/path/to/file.jpg',
|
|
169
|
-
* name: 'file.jpg',
|
|
170
|
-
* description: 'A description of the file'
|
|
171
|
-
* }]
|
|
172
|
-
* })
|
|
173
|
-
* .then(console.log)
|
|
174
|
-
* .catch(console.error);
|
|
175
|
-
*/
|
|
176
|
-
async createMessage(channel, options) {
|
|
177
|
-
let payload;
|
|
178
|
-
|
|
179
|
-
if (options instanceof MessagePayload) {
|
|
180
|
-
payload = await options.resolveBody().resolveFiles();
|
|
181
|
-
} else if (isFileBodyEncodable(options)) {
|
|
182
|
-
payload = options.toFileBody();
|
|
183
|
-
} else if (isJSONEncodable(options)) {
|
|
184
|
-
payload = { body: options.toJSON() };
|
|
185
|
-
} else {
|
|
186
|
-
payload = await MessagePayload.create(this, options).resolveBody().resolveFiles();
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const resolvedChannelId = this.resolveId(channel);
|
|
190
|
-
const resolvedChannel = this.resolve(channel);
|
|
191
|
-
const data = await this.client.rest.post(Routes.channelMessages(resolvedChannelId), payload);
|
|
192
|
-
|
|
193
|
-
return resolvedChannel?.messages._add(data) ?? new (getMessage())(this.client, data);
|
|
194
|
-
}
|
|
195
133
|
}
|
|
196
134
|
|
|
197
|
-
exports
|
|
135
|
+
module.exports = ChannelManager;
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const MessageManager = require('./MessageManager');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Manages API methods for messages in direct message channels and holds their cache.
|
|
7
|
-
*
|
|
8
7
|
* @extends {MessageManager}
|
|
9
8
|
*/
|
|
10
9
|
class DMMessageManager extends MessageManager {
|
|
11
10
|
/**
|
|
12
11
|
* The channel that the messages belong to
|
|
13
|
-
*
|
|
14
12
|
* @name DMMessageManager#channel
|
|
15
13
|
* @type {DMChannel}
|
|
16
14
|
*/
|
|
17
15
|
}
|
|
18
16
|
|
|
19
|
-
exports
|
|
17
|
+
module.exports = DMMessageManager;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const {
|
|
3
|
+
const BaseManager = require('./BaseManager');
|
|
4
|
+
const { DiscordjsError, ErrorCodes } = require('../errors');
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Manages the API methods of a data model along with a collection of instances.
|
|
8
|
-
*
|
|
9
8
|
* @extends {BaseManager}
|
|
10
9
|
* @abstract
|
|
11
10
|
*/
|
|
@@ -15,7 +14,6 @@ class DataManager extends BaseManager {
|
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* The data structure belonging to this manager.
|
|
18
|
-
*
|
|
19
17
|
* @name DataManager#holds
|
|
20
18
|
* @type {Function}
|
|
21
19
|
* @private
|
|
@@ -26,7 +24,6 @@ class DataManager extends BaseManager {
|
|
|
26
24
|
|
|
27
25
|
/**
|
|
28
26
|
* The cache of items for this manager.
|
|
29
|
-
*
|
|
30
27
|
* @type {Collection}
|
|
31
28
|
* @abstract
|
|
32
29
|
*/
|
|
@@ -36,8 +33,7 @@ class DataManager extends BaseManager {
|
|
|
36
33
|
|
|
37
34
|
/**
|
|
38
35
|
* Resolves a data entry to a data Object.
|
|
39
|
-
*
|
|
40
|
-
* @param {string | Object} idOrInstance The id or instance of something in this Manager
|
|
36
|
+
* @param {string|Object} idOrInstance The id or instance of something in this Manager
|
|
41
37
|
* @returns {?Object} An instance from this Manager
|
|
42
38
|
*/
|
|
43
39
|
resolve(idOrInstance) {
|
|
@@ -48,8 +44,7 @@ class DataManager extends BaseManager {
|
|
|
48
44
|
|
|
49
45
|
/**
|
|
50
46
|
* Resolves a data entry to an instance id.
|
|
51
|
-
*
|
|
52
|
-
* @param {string | Object} idOrInstance The id or instance of something in this Manager
|
|
47
|
+
* @param {string|Object} idOrInstance The id or instance of something in this Manager
|
|
53
48
|
* @returns {?Snowflake}
|
|
54
49
|
*/
|
|
55
50
|
resolveId(idOrInstance) {
|
|
@@ -63,4 +58,4 @@ class DataManager extends BaseManager {
|
|
|
63
58
|
}
|
|
64
59
|
}
|
|
65
60
|
|
|
66
|
-
exports
|
|
61
|
+
module.exports = DataManager;
|