@velliajs/discord 1.0.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/LICENSE +191 -0
- package/README.md +133 -0
- package/package.json +82 -0
- package/src/client/BaseClient.js +83 -0
- package/src/client/Client.js +591 -0
- package/src/client/WebhookClient.js +103 -0
- package/src/client/actions/Action.js +119 -0
- package/src/client/actions/ActionsManager.js +79 -0
- 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 +23 -0
- package/src/client/actions/ChannelDelete.js +23 -0
- package/src/client/actions/ChannelUpdate.js +33 -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 +21 -0
- package/src/client/actions/GuildDelete.js +44 -0
- package/src/client/actions/GuildEmojiCreate.js +20 -0
- package/src/client/actions/GuildEmojiDelete.js +19 -0
- package/src/client/actions/GuildEmojiUpdate.js +20 -0
- package/src/client/actions/GuildEmojisUpdate.js +34 -0
- package/src/client/actions/GuildIntegrationsUpdate.js +19 -0
- package/src/client/actions/GuildMemberRemove.js +31 -0
- package/src/client/actions/GuildMemberUpdate.js +44 -0
- package/src/client/actions/GuildRoleCreate.js +25 -0
- package/src/client/actions/GuildRoleDelete.js +29 -0
- package/src/client/actions/GuildRoleUpdate.js +39 -0
- package/src/client/actions/GuildRolesPositionUpdate.js +21 -0
- package/src/client/actions/GuildScheduledEventCreate.js +27 -0
- package/src/client/actions/GuildScheduledEventDelete.js +31 -0
- package/src/client/actions/GuildScheduledEventUpdate.js +30 -0
- package/src/client/actions/GuildScheduledEventUserAdd.js +32 -0
- package/src/client/actions/GuildScheduledEventUserRemove.js +32 -0
- package/src/client/actions/GuildStickerCreate.js +20 -0
- package/src/client/actions/GuildStickerDelete.js +19 -0
- package/src/client/actions/GuildStickerUpdate.js +20 -0
- package/src/client/actions/GuildStickersUpdate.js +34 -0
- package/src/client/actions/GuildUpdate.js +33 -0
- package/src/client/actions/InteractionCreate.js +101 -0
- package/src/client/actions/InviteCreate.js +28 -0
- package/src/client/actions/InviteDelete.js +30 -0
- package/src/client/actions/MessageCreate.js +37 -0
- package/src/client/actions/MessageDelete.js +32 -0
- package/src/client/actions/MessageDeleteBulk.js +47 -0
- package/src/client/actions/MessageReactionAdd.js +55 -0
- package/src/client/actions/MessageReactionRemove.js +45 -0
- package/src/client/actions/MessageReactionRemoveAll.js +33 -0
- package/src/client/actions/MessageReactionRemoveEmoji.js +28 -0
- package/src/client/actions/MessageUpdate.js +26 -0
- package/src/client/actions/PresenceUpdate.js +42 -0
- package/src/client/actions/StageInstanceCreate.js +28 -0
- package/src/client/actions/StageInstanceDelete.js +31 -0
- package/src/client/actions/StageInstanceUpdate.js +30 -0
- package/src/client/actions/ThreadCreate.js +24 -0
- 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 +47 -0
- package/src/client/actions/TypingStart.js +29 -0
- package/src/client/actions/UserUpdate.js +36 -0
- package/src/client/actions/VoiceStateUpdate.js +43 -0
- package/src/client/actions/WebhooksUpdate.js +20 -0
- package/src/client/voice/ClientVoiceManager.js +44 -0
- package/src/client/websocket/WebSocketManager.js +393 -0
- package/src/client/websocket/WebSocketShard.js +231 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_PERMISSIONS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_ACTION_EXECUTION.js +5 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_CREATE.js +5 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_DELETE.js +5 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/CHANNEL_CREATE.js +5 -0
- package/src/client/websocket/handlers/CHANNEL_DELETE.js +5 -0
- package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js +22 -0
- package/src/client/websocket/handlers/CHANNEL_UPDATE.js +16 -0
- package/src/client/websocket/handlers/GUILD_AUDIT_LOG_ENTRY_CREATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_BAN_ADD.js +5 -0
- package/src/client/websocket/handlers/GUILD_BAN_REMOVE.js +5 -0
- package/src/client/websocket/handlers/GUILD_CREATE.js +26 -0
- package/src/client/websocket/handlers/GUILD_DELETE.js +5 -0
- package/src/client/websocket/handlers/GUILD_EMOJIS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_INTEGRATIONS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js +39 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +20 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_REMOVE.js +5 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_ROLE_CREATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_ROLE_DELETE.js +5 -0
- package/src/client/websocket/handlers/GUILD_ROLE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_CREATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_DELETE.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_ADD.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_REMOVE.js +5 -0
- package/src/client/websocket/handlers/GUILD_STICKERS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_UPDATE.js +5 -0
- package/src/client/websocket/handlers/INTERACTION_CREATE.js +5 -0
- package/src/client/websocket/handlers/INVITE_CREATE.js +5 -0
- package/src/client/websocket/handlers/INVITE_DELETE.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_CREATE.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE_BULK.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_ADD.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_ALL.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_EMOJI.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_UPDATE.js +16 -0
- package/src/client/websocket/handlers/PRESENCE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/READY.js +27 -0
- package/src/client/websocket/handlers/RESUMED.js +14 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_CREATE.js +5 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_DELETE.js +5 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/THREAD_CREATE.js +5 -0
- package/src/client/websocket/handlers/THREAD_DELETE.js +5 -0
- package/src/client/websocket/handlers/THREAD_LIST_SYNC.js +5 -0
- package/src/client/websocket/handlers/THREAD_MEMBERS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/THREAD_MEMBER_UPDATE.js +5 -0
- package/src/client/websocket/handlers/THREAD_UPDATE.js +16 -0
- package/src/client/websocket/handlers/TYPING_START.js +5 -0
- package/src/client/websocket/handlers/USER_UPDATE.js +5 -0
- package/src/client/websocket/handlers/VOICE_SERVER_UPDATE.js +6 -0
- package/src/client/websocket/handlers/VOICE_STATE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/WEBHOOKS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/index.js +64 -0
- package/src/errors/DJSError.js +48 -0
- package/src/errors/ErrorCodes.js +319 -0
- package/src/errors/Messages.js +170 -0
- package/src/errors/index.js +5 -0
- package/src/index.js +213 -0
- package/src/managers/ApplicationCommandManager.js +263 -0
- package/src/managers/ApplicationCommandPermissionsManager.js +434 -0
- package/src/managers/AutoModerationRuleManager.js +288 -0
- package/src/managers/BaseGuildEmojiManager.js +80 -0
- package/src/managers/BaseManager.js +19 -0
- package/src/managers/CachedManager.js +57 -0
- package/src/managers/CategoryChannelChildManager.js +77 -0
- package/src/managers/ChannelManager.js +128 -0
- package/src/managers/DataManager.js +61 -0
- package/src/managers/GuildApplicationCommandManager.js +28 -0
- package/src/managers/GuildBanManager.js +204 -0
- package/src/managers/GuildChannelManager.js +494 -0
- package/src/managers/GuildEmojiManager.js +174 -0
- package/src/managers/GuildEmojiRoleManager.js +118 -0
- package/src/managers/GuildForumThreadManager.js +83 -0
- package/src/managers/GuildInviteManager.js +213 -0
- package/src/managers/GuildManager.js +283 -0
- package/src/managers/GuildMemberManager.js +540 -0
- package/src/managers/GuildMemberRoleManager.js +204 -0
- package/src/managers/GuildScheduledEventManager.js +297 -0
- package/src/managers/GuildStickerManager.js +182 -0
- package/src/managers/GuildTextThreadManager.js +91 -0
- package/src/managers/MessageManager.js +259 -0
- package/src/managers/PermissionOverwriteManager.js +168 -0
- package/src/managers/PresenceManager.js +58 -0
- package/src/managers/ReactionManager.js +68 -0
- package/src/managers/ReactionUserManager.js +77 -0
- package/src/managers/RoleManager.js +360 -0
- package/src/managers/StageInstanceManager.js +154 -0
- package/src/managers/ThreadManager.js +204 -0
- package/src/managers/ThreadMemberManager.js +182 -0
- package/src/managers/UserManager.js +139 -0
- package/src/managers/VoiceStateManager.js +37 -0
- package/src/sharding/Shard.js +457 -0
- package/src/sharding/ShardClientUtil.js +285 -0
- package/src/sharding/ShardingManager.js +326 -0
- package/src/structures/ActionRow.js +46 -0
- package/src/structures/ActionRowBuilder.js +35 -0
- package/src/structures/AnonymousGuild.js +97 -0
- package/src/structures/ApplicationCommand.js +606 -0
- package/src/structures/ApplicationRoleConnectionMetadata.js +46 -0
- package/src/structures/Attachment.js +140 -0
- package/src/structures/AttachmentBuilder.js +116 -0
- package/src/structures/AutoModerationActionExecution.js +116 -0
- package/src/structures/AutoModerationRule.js +284 -0
- package/src/structures/AutocompleteInteraction.js +97 -0
- package/src/structures/Base.js +43 -0
- package/src/structures/BaseChannel.js +160 -0
- package/src/structures/BaseGuild.js +119 -0
- package/src/structures/BaseGuildEmoji.js +56 -0
- package/src/structures/BaseGuildTextChannel.js +186 -0
- package/src/structures/BaseGuildVoiceChannel.js +234 -0
- package/src/structures/BaseInteraction.js +344 -0
- package/src/structures/BaseSelectMenuComponent.js +56 -0
- package/src/structures/ButtonBuilder.js +44 -0
- package/src/structures/ButtonComponent.js +65 -0
- package/src/structures/ButtonInteraction.js +11 -0
- package/src/structures/CategoryChannel.js +45 -0
- package/src/structures/ChannelSelectMenuBuilder.js +31 -0
- package/src/structures/ChannelSelectMenuComponent.js +20 -0
- package/src/structures/ChannelSelectMenuInteraction.js +33 -0
- package/src/structures/ChatInputCommandInteraction.js +41 -0
- package/src/structures/ClientApplication.js +193 -0
- package/src/structures/ClientPresence.js +82 -0
- package/src/structures/ClientUser.js +185 -0
- package/src/structures/CommandInteraction.js +224 -0
- package/src/structures/CommandInteractionOptionResolver.js +308 -0
- package/src/structures/Component.js +47 -0
- package/src/structures/ContextMenuCommandInteraction.js +64 -0
- package/src/structures/DMChannel.js +129 -0
- package/src/structures/DirectoryChannel.js +36 -0
- package/src/structures/Embed.js +220 -0
- package/src/structures/EmbedBuilder.js +41 -0
- package/src/structures/Emoji.js +108 -0
- package/src/structures/ForumChannel.js +264 -0
- package/src/structures/Guild.js +1361 -0
- package/src/structures/GuildAuditLogs.js +91 -0
- package/src/structures/GuildAuditLogsEntry.js +527 -0
- package/src/structures/GuildBan.js +59 -0
- package/src/structures/GuildChannel.js +457 -0
- package/src/structures/GuildEmoji.js +148 -0
- package/src/structures/GuildMember.js +518 -0
- package/src/structures/GuildPreview.js +193 -0
- package/src/structures/GuildPreviewEmoji.js +27 -0
- package/src/structures/GuildScheduledEvent.js +439 -0
- package/src/structures/GuildTemplate.js +241 -0
- package/src/structures/Integration.js +220 -0
- package/src/structures/IntegrationApplication.js +85 -0
- package/src/structures/InteractionCollector.js +263 -0
- package/src/structures/InteractionResponse.js +102 -0
- package/src/structures/InteractionWebhook.js +59 -0
- package/src/structures/Invite.js +322 -0
- package/src/structures/InviteGuild.js +22 -0
- package/src/structures/InviteStageInstance.js +87 -0
- package/src/structures/MentionableSelectMenuBuilder.js +32 -0
- package/src/structures/MentionableSelectMenuComponent.js +11 -0
- package/src/structures/MentionableSelectMenuInteraction.js +71 -0
- package/src/structures/Message.js +997 -0
- package/src/structures/MessageCollector.js +146 -0
- package/src/structures/MessageComponentInteraction.js +107 -0
- package/src/structures/MessageContextMenuCommandInteraction.js +20 -0
- package/src/structures/MessageMentions.js +297 -0
- package/src/structures/MessagePayload.js +299 -0
- package/src/structures/MessageReaction.js +142 -0
- package/src/structures/ModalBuilder.js +34 -0
- package/src/structures/ModalSubmitFields.js +55 -0
- package/src/structures/ModalSubmitInteraction.js +121 -0
- package/src/structures/NewsChannel.js +32 -0
- package/src/structures/OAuth2Guild.js +28 -0
- package/src/structures/PartialGroupDMChannel.js +60 -0
- package/src/structures/PermissionOverwrites.js +196 -0
- package/src/structures/Presence.js +372 -0
- package/src/structures/ReactionCollector.js +229 -0
- package/src/structures/ReactionEmoji.js +31 -0
- package/src/structures/Role.js +458 -0
- package/src/structures/RoleSelectMenuBuilder.js +31 -0
- package/src/structures/RoleSelectMenuComponent.js +11 -0
- package/src/structures/RoleSelectMenuInteraction.js +33 -0
- 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/StageChannel.js +112 -0
- package/src/structures/StageInstance.js +167 -0
- package/src/structures/Sticker.js +272 -0
- package/src/structures/StickerPack.js +95 -0
- package/src/structures/StringSelectMenuBuilder.js +79 -0
- package/src/structures/StringSelectMenuComponent.js +20 -0
- package/src/structures/StringSelectMenuInteraction.js +21 -0
- package/src/structures/StringSelectMenuOptionBuilder.js +49 -0
- package/src/structures/Team.js +117 -0
- package/src/structures/TeamMember.js +70 -0
- package/src/structures/TextChannel.js +33 -0
- package/src/structures/TextInputBuilder.js +31 -0
- package/src/structures/TextInputComponent.js +29 -0
- package/src/structures/ThreadChannel.js +606 -0
- package/src/structures/ThreadMember.js +113 -0
- package/src/structures/Typing.js +74 -0
- package/src/structures/User.js +331 -0
- package/src/structures/UserContextMenuCommandInteraction.js +29 -0
- package/src/structures/UserSelectMenuBuilder.js +31 -0
- package/src/structures/UserSelectMenuComponent.js +11 -0
- package/src/structures/UserSelectMenuInteraction.js +51 -0
- package/src/structures/VoiceChannel.js +96 -0
- package/src/structures/VoiceRegion.js +46 -0
- package/src/structures/VoiceState.js +303 -0
- package/src/structures/Webhook.js +481 -0
- package/src/structures/WelcomeChannel.js +60 -0
- package/src/structures/WelcomeScreen.js +49 -0
- package/src/structures/Widget.js +88 -0
- package/src/structures/WidgetMember.js +99 -0
- package/src/structures/interfaces/Application.js +108 -0
- package/src/structures/interfaces/Collector.js +335 -0
- package/src/structures/interfaces/InteractionResponses.js +320 -0
- package/src/structures/interfaces/TextBasedChannel.js +413 -0
- package/src/util/APITypes.js +456 -0
- package/src/util/ActivityFlagsBitField.js +26 -0
- package/src/util/ApplicationFlagsBitField.js +26 -0
- package/src/util/BitField.js +176 -0
- package/src/util/ChannelFlagsBitField.js +41 -0
- package/src/util/Channels.js +150 -0
- package/src/util/Colors.js +73 -0
- package/src/util/Components.js +152 -0
- package/src/util/Constants.js +230 -0
- package/src/util/DataResolver.js +140 -0
- package/src/util/Enums.js +13 -0
- package/src/util/Events.js +160 -0
- package/src/util/Formatters.js +413 -0
- package/src/util/GuildMemberFlagsBitField.js +41 -0
- package/src/util/IntentsBitField.js +34 -0
- package/src/util/LimitedCollection.js +68 -0
- package/src/util/MessageFlagsBitField.js +32 -0
- package/src/util/Options.js +216 -0
- package/src/util/Partials.js +44 -0
- package/src/util/PermissionsBitField.js +104 -0
- package/src/util/ShardEvents.js +27 -0
- package/src/util/Status.js +33 -0
- package/src/util/Sweepers.js +467 -0
- package/src/util/SystemChannelFlagsBitField.js +43 -0
- package/src/util/ThreadMemberFlagsBitField.js +31 -0
- package/src/util/Transformers.js +36 -0
- package/src/util/UserFlagsBitField.js +32 -0
- package/src/util/Util.js +394 -0
- package/src/util/WebSocketShardEvents.js +25 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Role connection metadata object for an application.
|
|
5
|
+
*/
|
|
6
|
+
class ApplicationRoleConnectionMetadata {
|
|
7
|
+
constructor(data) {
|
|
8
|
+
/**
|
|
9
|
+
* The name of this metadata field
|
|
10
|
+
* @type {string}
|
|
11
|
+
*/
|
|
12
|
+
this.name = data.name;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The name localizations for this metadata field
|
|
16
|
+
* @type {?Object<Locale, string>}
|
|
17
|
+
*/
|
|
18
|
+
this.nameLocalizations = data.name_localizations ?? null;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The description of this metadata field
|
|
22
|
+
* @type {string}
|
|
23
|
+
*/
|
|
24
|
+
this.description = data.description;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The description localizations for this metadata field
|
|
28
|
+
* @type {?Object<Locale, string>}
|
|
29
|
+
*/
|
|
30
|
+
this.descriptionLocalizations = data.description_localizations ?? null;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The dictionary key for this metadata field
|
|
34
|
+
* @type {string}
|
|
35
|
+
*/
|
|
36
|
+
this.key = data.key;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The type of this metadata field
|
|
40
|
+
* @type {ApplicationRoleConnectionMetadataType}
|
|
41
|
+
*/
|
|
42
|
+
this.type = data.type;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
exports.ApplicationRoleConnectionMetadata = ApplicationRoleConnectionMetadata;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { basename, flatten } = require('../util/Util');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Object} AttachmentPayload
|
|
7
|
+
* @property {?string} name The name of the attachment
|
|
8
|
+
* @property {Stream|BufferResolvable} attachment The attachment in this payload
|
|
9
|
+
* @property {?string} description The description of the attachment
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Represents an attachment
|
|
14
|
+
*/
|
|
15
|
+
class Attachment {
|
|
16
|
+
constructor(data) {
|
|
17
|
+
this.attachment = data.url;
|
|
18
|
+
/**
|
|
19
|
+
* The name of this attachment
|
|
20
|
+
* @type {string}
|
|
21
|
+
*/
|
|
22
|
+
this.name = data.filename;
|
|
23
|
+
this._patch(data);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
_patch(data) {
|
|
27
|
+
/**
|
|
28
|
+
* The attachment's id
|
|
29
|
+
* @type {Snowflake}
|
|
30
|
+
*/
|
|
31
|
+
this.id = data.id;
|
|
32
|
+
|
|
33
|
+
if ('size' in data) {
|
|
34
|
+
/**
|
|
35
|
+
* The size of this attachment in bytes
|
|
36
|
+
* @type {number}
|
|
37
|
+
*/
|
|
38
|
+
this.size = data.size;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if ('url' in data) {
|
|
42
|
+
/**
|
|
43
|
+
* The URL to this attachment
|
|
44
|
+
* @type {string}
|
|
45
|
+
*/
|
|
46
|
+
this.url = data.url;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if ('proxy_url' in data) {
|
|
50
|
+
/**
|
|
51
|
+
* The Proxy URL to this attachment
|
|
52
|
+
* @type {string}
|
|
53
|
+
*/
|
|
54
|
+
this.proxyURL = data.proxy_url;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if ('height' in data) {
|
|
58
|
+
/**
|
|
59
|
+
* The height of this attachment (if an image or video)
|
|
60
|
+
* @type {?number}
|
|
61
|
+
*/
|
|
62
|
+
this.height = data.height;
|
|
63
|
+
} else {
|
|
64
|
+
this.height ??= null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if ('width' in data) {
|
|
68
|
+
/**
|
|
69
|
+
* The width of this attachment (if an image or video)
|
|
70
|
+
* @type {?number}
|
|
71
|
+
*/
|
|
72
|
+
this.width = data.width;
|
|
73
|
+
} else {
|
|
74
|
+
this.width ??= null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if ('content_type' in data) {
|
|
78
|
+
/**
|
|
79
|
+
* The media type of this attachment
|
|
80
|
+
* @type {?string}
|
|
81
|
+
*/
|
|
82
|
+
this.contentType = data.content_type;
|
|
83
|
+
} else {
|
|
84
|
+
this.contentType ??= null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if ('description' in data) {
|
|
88
|
+
/**
|
|
89
|
+
* The description (alt text) of this attachment
|
|
90
|
+
* @type {?string}
|
|
91
|
+
*/
|
|
92
|
+
this.description = data.description;
|
|
93
|
+
} else {
|
|
94
|
+
this.description ??= null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Whether this attachment is ephemeral
|
|
99
|
+
* @type {boolean}
|
|
100
|
+
*/
|
|
101
|
+
this.ephemeral = data.ephemeral ?? false;
|
|
102
|
+
|
|
103
|
+
if ('duration_secs' in data) {
|
|
104
|
+
/**
|
|
105
|
+
* The duration of this attachment in seconds
|
|
106
|
+
* <info>This will only be available if the attachment is an audio file.</info>
|
|
107
|
+
* @type {?number}
|
|
108
|
+
*/
|
|
109
|
+
this.duration = data.duration_secs;
|
|
110
|
+
} else {
|
|
111
|
+
this.duration ??= null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if ('waveform' in data) {
|
|
115
|
+
/**
|
|
116
|
+
* The base64 encoded byte array representing a sampled waveform
|
|
117
|
+
* <info>This will only be available if the attachment is an audio file.</info>
|
|
118
|
+
* @type {?string}
|
|
119
|
+
*/
|
|
120
|
+
this.waveform = data.waveform;
|
|
121
|
+
} else {
|
|
122
|
+
this.waveform ??= null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Whether or not this attachment has been marked as a spoiler
|
|
128
|
+
* @type {boolean}
|
|
129
|
+
* @readonly
|
|
130
|
+
*/
|
|
131
|
+
get spoiler() {
|
|
132
|
+
return basename(this.url ?? this.name).startsWith('SPOILER_');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
toJSON() {
|
|
136
|
+
return flatten(this);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
module.exports = Attachment;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { basename, flatten } = require('../util/Util');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents an attachment builder
|
|
7
|
+
*/
|
|
8
|
+
class AttachmentBuilder {
|
|
9
|
+
/**
|
|
10
|
+
* @param {BufferResolvable|Stream} attachment The file
|
|
11
|
+
* @param {AttachmentData} [data] Extra data
|
|
12
|
+
*/
|
|
13
|
+
constructor(attachment, data = {}) {
|
|
14
|
+
/**
|
|
15
|
+
* The file associated with this attachment.
|
|
16
|
+
* @type {BufferResolvable|Stream}
|
|
17
|
+
*/
|
|
18
|
+
this.attachment = attachment;
|
|
19
|
+
/**
|
|
20
|
+
* The name of this attachment
|
|
21
|
+
* @type {?string}
|
|
22
|
+
*/
|
|
23
|
+
this.name = data.name;
|
|
24
|
+
/**
|
|
25
|
+
* The description of the attachment
|
|
26
|
+
* @type {?string}
|
|
27
|
+
*/
|
|
28
|
+
this.description = data.description;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Sets the description of this attachment.
|
|
33
|
+
* @param {string} description The description of the file
|
|
34
|
+
* @returns {AttachmentBuilder} This attachment
|
|
35
|
+
*/
|
|
36
|
+
setDescription(description) {
|
|
37
|
+
this.description = description;
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Sets the file of this attachment.
|
|
43
|
+
* @param {BufferResolvable|Stream} attachment The file
|
|
44
|
+
* @returns {AttachmentBuilder} This attachment
|
|
45
|
+
*/
|
|
46
|
+
setFile(attachment) {
|
|
47
|
+
this.attachment = attachment;
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Sets the name of this attachment.
|
|
53
|
+
* @param {string} name The name of the file
|
|
54
|
+
* @returns {AttachmentBuilder} This attachment
|
|
55
|
+
*/
|
|
56
|
+
setName(name) {
|
|
57
|
+
this.name = name;
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Sets whether this attachment is a spoiler
|
|
63
|
+
* @param {boolean} [spoiler=true] Whether the attachment should be marked as a spoiler
|
|
64
|
+
* @returns {AttachmentBuilder} This attachment
|
|
65
|
+
*/
|
|
66
|
+
setSpoiler(spoiler = true) {
|
|
67
|
+
if (spoiler === this.spoiler) return this;
|
|
68
|
+
|
|
69
|
+
if (!spoiler) {
|
|
70
|
+
while (this.spoiler) {
|
|
71
|
+
this.name = this.name.slice('SPOILER_'.length);
|
|
72
|
+
}
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
this.name = `SPOILER_${this.name}`;
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Whether or not this attachment has been marked as a spoiler
|
|
81
|
+
* @type {boolean}
|
|
82
|
+
* @readonly
|
|
83
|
+
*/
|
|
84
|
+
get spoiler() {
|
|
85
|
+
return basename(this.name).startsWith('SPOILER_');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
toJSON() {
|
|
89
|
+
return flatten(this);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Makes a new builder instance from a preexisting attachment structure.
|
|
94
|
+
* @param {AttachmentBuilder|Attachment|AttachmentPayload} other The builder to construct a new instance from
|
|
95
|
+
* @returns {AttachmentBuilder}
|
|
96
|
+
*/
|
|
97
|
+
static from(other) {
|
|
98
|
+
return new AttachmentBuilder(other.attachment, {
|
|
99
|
+
name: other.name,
|
|
100
|
+
description: other.description,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
module.exports = AttachmentBuilder;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @external APIAttachment
|
|
109
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#attachment-object}
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @typedef {Object} AttachmentData
|
|
114
|
+
* @property {string} [name] The name of the attachment
|
|
115
|
+
* @property {string} [description] The description of the attachment
|
|
116
|
+
*/
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { _transformAPIAutoModerationAction } = require('../util/Transformers');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents the structure of an executed action when an {@link AutoModerationRule} is triggered.
|
|
7
|
+
*/
|
|
8
|
+
class AutoModerationActionExecution {
|
|
9
|
+
constructor(data, guild) {
|
|
10
|
+
/**
|
|
11
|
+
* The guild where this action was executed from.
|
|
12
|
+
* @type {Guild}
|
|
13
|
+
*/
|
|
14
|
+
this.guild = guild;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The action that was executed.
|
|
18
|
+
* @type {AutoModerationAction}
|
|
19
|
+
*/
|
|
20
|
+
this.action = _transformAPIAutoModerationAction(data.action);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The id of the auto moderation rule this action belongs to.
|
|
24
|
+
* @type {Snowflake}
|
|
25
|
+
*/
|
|
26
|
+
this.ruleId = data.rule_id;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The trigger type of the auto moderation rule which was triggered.
|
|
30
|
+
* @type {AutoModerationRuleTriggerType}
|
|
31
|
+
*/
|
|
32
|
+
this.ruleTriggerType = data.rule_trigger_type;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The id of the user that triggered this action.
|
|
36
|
+
* @type {Snowflake}
|
|
37
|
+
*/
|
|
38
|
+
this.userId = data.user_id;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The id of the channel where this action was triggered from.
|
|
42
|
+
* @type {?Snowflake}
|
|
43
|
+
*/
|
|
44
|
+
this.channelId = data.channel_id ?? null;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The id of the message that triggered this action.
|
|
48
|
+
* <info>This will not be present if the message was blocked or the content was not part of any message.</info>
|
|
49
|
+
* @type {?Snowflake}
|
|
50
|
+
*/
|
|
51
|
+
this.messageId = data.message_id ?? null;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The id of any system auto moderation messages posted as a result of this action.
|
|
55
|
+
* @type {?Snowflake}
|
|
56
|
+
*/
|
|
57
|
+
this.alertSystemMessageId = data.alert_system_message_id ?? null;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The content that triggered this action.
|
|
61
|
+
* <info>This property requires the {@link GatewayIntentBits.MessageContent} privileged gateway intent.</info>
|
|
62
|
+
* @type {string}
|
|
63
|
+
*/
|
|
64
|
+
this.content = data.content;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The word or phrase configured in the rule that triggered this action.
|
|
68
|
+
* @type {?string}
|
|
69
|
+
*/
|
|
70
|
+
this.matchedKeyword = data.matched_keyword ?? null;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The substring in content that triggered this action.
|
|
74
|
+
* @type {?string}
|
|
75
|
+
*/
|
|
76
|
+
this.matchedContent = data.matched_content ?? null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The auto moderation rule this action belongs to.
|
|
81
|
+
* @type {?AutoModerationRule}
|
|
82
|
+
* @readonly
|
|
83
|
+
*/
|
|
84
|
+
get autoModerationRule() {
|
|
85
|
+
return this.guild.autoModerationRules.cache.get(this.ruleId) ?? null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The channel where this action was triggered from.
|
|
90
|
+
* @type {?TextBasedChannel}
|
|
91
|
+
* @readonly
|
|
92
|
+
*/
|
|
93
|
+
get channel() {
|
|
94
|
+
return this.guild.channels.cache.get(this.channelId) ?? null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The user that triggered this action.
|
|
99
|
+
* @type {?User}
|
|
100
|
+
* @readonly
|
|
101
|
+
*/
|
|
102
|
+
get user() {
|
|
103
|
+
return this.guild.client.users.cache.get(this.userId) ?? null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The guild member that triggered this action.
|
|
108
|
+
* @type {?GuildMember}
|
|
109
|
+
* @readonly
|
|
110
|
+
*/
|
|
111
|
+
get member() {
|
|
112
|
+
return this.guild.members.cache.get(this.userId) ?? null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
module.exports = AutoModerationActionExecution;
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { Collection } = require('@discordjs/collection');
|
|
4
|
+
const Base = require('./Base');
|
|
5
|
+
const { _transformAPIAutoModerationAction } = require('../util/Transformers');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents an auto moderation rule.
|
|
9
|
+
* @extends {Base}
|
|
10
|
+
*/
|
|
11
|
+
class AutoModerationRule extends Base {
|
|
12
|
+
constructor(client, data, guild) {
|
|
13
|
+
super(client);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The id of this auto moderation rule.
|
|
17
|
+
* @type {Snowflake}
|
|
18
|
+
*/
|
|
19
|
+
this.id = data.id;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The guild this auto moderation rule is for.
|
|
23
|
+
* @type {Guild}
|
|
24
|
+
*/
|
|
25
|
+
this.guild = guild;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The user that created this auto moderation rule.
|
|
29
|
+
* @type {Snowflake}
|
|
30
|
+
*/
|
|
31
|
+
this.creatorId = data.creator_id;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The trigger type of this auto moderation rule.
|
|
35
|
+
* @type {AutoModerationRuleTriggerType}
|
|
36
|
+
*/
|
|
37
|
+
this.triggerType = data.trigger_type;
|
|
38
|
+
|
|
39
|
+
this._patch(data);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
_patch(data) {
|
|
43
|
+
if ('name' in data) {
|
|
44
|
+
/**
|
|
45
|
+
* The name of this auto moderation rule.
|
|
46
|
+
* @type {string}
|
|
47
|
+
*/
|
|
48
|
+
this.name = data.name;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if ('event_type' in data) {
|
|
52
|
+
/**
|
|
53
|
+
* The event type of this auto moderation rule.
|
|
54
|
+
* @type {AutoModerationRuleEventType}
|
|
55
|
+
*/
|
|
56
|
+
this.eventType = data.event_type;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if ('trigger_metadata' in data) {
|
|
60
|
+
/**
|
|
61
|
+
* Additional data used to determine whether an auto moderation rule should be triggered.
|
|
62
|
+
* @typedef {Object} AutoModerationTriggerMetadata
|
|
63
|
+
* @property {string[]} keywordFilter The substrings that will be searched for in the content
|
|
64
|
+
* @property {string[]} regexPatterns The regular expression patterns which will be matched against the content
|
|
65
|
+
* <info>Only Rust-flavored regular expressions are supported.</info>
|
|
66
|
+
* @property {AutoModerationRuleKeywordPresetType[]} presets
|
|
67
|
+
* The internally pre-defined wordsets which will be searched for in the content
|
|
68
|
+
* @property {string[]} allowList The substrings that will be exempt from triggering
|
|
69
|
+
* {@link AutoModerationRuleTriggerType.Keyword} and {@link AutoModerationRuleTriggerType.KeywordPreset}
|
|
70
|
+
* @property {?number} mentionTotalLimit The total number of role & user mentions allowed per message
|
|
71
|
+
* @property {boolean} mentionRaidProtectionEnabled Whether mention raid protection is enabled
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The trigger metadata of the rule.
|
|
76
|
+
* @type {AutoModerationTriggerMetadata}
|
|
77
|
+
*/
|
|
78
|
+
this.triggerMetadata = {
|
|
79
|
+
keywordFilter: data.trigger_metadata.keyword_filter ?? [],
|
|
80
|
+
regexPatterns: data.trigger_metadata.regex_patterns ?? [],
|
|
81
|
+
presets: data.trigger_metadata.presets ?? [],
|
|
82
|
+
allowList: data.trigger_metadata.allow_list ?? [],
|
|
83
|
+
mentionTotalLimit: data.trigger_metadata.mention_total_limit ?? null,
|
|
84
|
+
mentionRaidProtectionEnabled: data.trigger_metadata.mention_raid_protection_enabled ?? false,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if ('actions' in data) {
|
|
89
|
+
/**
|
|
90
|
+
* An object containing information about an auto moderation rule action.
|
|
91
|
+
* @typedef {Object} AutoModerationAction
|
|
92
|
+
* @property {AutoModerationActionType} type The type of this auto moderation rule action
|
|
93
|
+
* @property {AutoModerationActionMetadata} metadata Additional metadata needed during execution
|
|
94
|
+
*/
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Additional data used when an auto moderation rule is executed.
|
|
98
|
+
* @typedef {Object} AutoModerationActionMetadata
|
|
99
|
+
* @property {?Snowflake} channelId The id of the channel to which content will be logged
|
|
100
|
+
* @property {?number} durationSeconds The timeout duration in seconds
|
|
101
|
+
* @property {?string} customMessage The custom message that is shown whenever a message is blocked
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The actions of this auto moderation rule.
|
|
106
|
+
* @type {AutoModerationAction[]}
|
|
107
|
+
*/
|
|
108
|
+
this.actions = data.actions.map(action => _transformAPIAutoModerationAction(action));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if ('enabled' in data) {
|
|
112
|
+
/**
|
|
113
|
+
* Whether this auto moderation rule is enabled.
|
|
114
|
+
* @type {boolean}
|
|
115
|
+
*/
|
|
116
|
+
this.enabled = data.enabled;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if ('exempt_roles' in data) {
|
|
120
|
+
/**
|
|
121
|
+
* The roles exempt by this auto moderation rule.
|
|
122
|
+
* @type {Collection<Snowflake, Role>}
|
|
123
|
+
*/
|
|
124
|
+
this.exemptRoles = new Collection(
|
|
125
|
+
data.exempt_roles.map(exemptRole => [exemptRole, this.guild.roles.cache.get(exemptRole)]),
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if ('exempt_channels' in data) {
|
|
130
|
+
/**
|
|
131
|
+
* The channels exempt by this auto moderation rule.
|
|
132
|
+
* @type {Collection<Snowflake, GuildChannel|ThreadChannel>}
|
|
133
|
+
*/
|
|
134
|
+
this.exemptChannels = new Collection(
|
|
135
|
+
data.exempt_channels.map(exemptChannel => [exemptChannel, this.guild.channels.cache.get(exemptChannel)]),
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Edits this auto moderation rule.
|
|
142
|
+
* @param {AutoModerationRuleEditOptions} options Options for editing this auto moderation rule
|
|
143
|
+
* @returns {Promise<AutoModerationRule>}
|
|
144
|
+
*/
|
|
145
|
+
edit(options) {
|
|
146
|
+
return this.guild.autoModerationRules.edit(this.id, options);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Deletes this auto moderation rule.
|
|
151
|
+
* @param {string} [reason] The reason for deleting this auto moderation rule
|
|
152
|
+
* @returns {Promise<void>}
|
|
153
|
+
*/
|
|
154
|
+
delete(reason) {
|
|
155
|
+
return this.guild.autoModerationRules.delete(this.id, reason);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Sets the name for this auto moderation rule.
|
|
160
|
+
* @param {string} name The name of this auto moderation rule
|
|
161
|
+
* @param {string} [reason] The reason for changing the name of this auto moderation rule
|
|
162
|
+
* @returns {Promise<AutoModerationRule>}
|
|
163
|
+
*/
|
|
164
|
+
setName(name, reason) {
|
|
165
|
+
return this.edit({ name, reason });
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Sets the event type for this auto moderation rule.
|
|
170
|
+
* @param {AutoModerationRuleEventType} eventType The event type of this auto moderation rule
|
|
171
|
+
* @param {string} [reason] The reason for changing the event type of this auto moderation rule
|
|
172
|
+
* @returns {Promise<AutoModerationRule>}
|
|
173
|
+
*/
|
|
174
|
+
setEventType(eventType, reason) {
|
|
175
|
+
return this.edit({ eventType, reason });
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Sets the keyword filter for this auto moderation rule.
|
|
180
|
+
* @param {string[]} keywordFilter The keyword filter of this auto moderation rule
|
|
181
|
+
* @param {string} [reason] The reason for changing the keyword filter of this auto moderation rule
|
|
182
|
+
* @returns {Promise<AutoModerationRule>}
|
|
183
|
+
*/
|
|
184
|
+
setKeywordFilter(keywordFilter, reason) {
|
|
185
|
+
return this.edit({ triggerMetadata: { ...this.triggerMetadata, keywordFilter }, reason });
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Sets the regular expression patterns for this auto moderation rule.
|
|
190
|
+
* @param {string[]} regexPatterns The regular expression patterns of this auto moderation rule
|
|
191
|
+
* <info>Only Rust-flavored regular expressions are supported.</info>
|
|
192
|
+
* @param {string} [reason] The reason for changing the regular expression patterns of this auto moderation rule
|
|
193
|
+
* @returns {Promise<AutoModerationRule>}
|
|
194
|
+
*/
|
|
195
|
+
setRegexPatterns(regexPatterns, reason) {
|
|
196
|
+
return this.edit({ triggerMetadata: { ...this.triggerMetadata, regexPatterns }, reason });
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Sets the presets for this auto moderation rule.
|
|
201
|
+
* @param {AutoModerationRuleKeywordPresetType[]} presets The presets of this auto moderation rule
|
|
202
|
+
* @param {string} [reason] The reason for changing the presets of this auto moderation rule
|
|
203
|
+
* @returns {Promise<AutoModerationRule>}
|
|
204
|
+
*/
|
|
205
|
+
setPresets(presets, reason) {
|
|
206
|
+
return this.edit({ triggerMetadata: { ...this.triggerMetadata, presets }, reason });
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Sets the allow list for this auto moderation rule.
|
|
211
|
+
* @param {string[]} allowList The substrings that will be exempt from triggering
|
|
212
|
+
* {@link AutoModerationRuleTriggerType.Keyword} and {@link AutoModerationRuleTriggerType.KeywordPreset}
|
|
213
|
+
* @param {string} [reason] The reason for changing the allow list of this auto moderation rule
|
|
214
|
+
* @returns {Promise<AutoModerationRule>}
|
|
215
|
+
*/
|
|
216
|
+
setAllowList(allowList, reason) {
|
|
217
|
+
return this.edit({ triggerMetadata: { ...this.triggerMetadata, allowList }, reason });
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Sets the mention total limit for this auto moderation rule.
|
|
222
|
+
* @param {number} mentionTotalLimit The total number of unique role and user mentions allowed per message
|
|
223
|
+
* @param {string} [reason] The reason for changing the mention total limit of this auto moderation rule
|
|
224
|
+
* @returns {Promise<AutoModerationRule>}
|
|
225
|
+
*/
|
|
226
|
+
setMentionTotalLimit(mentionTotalLimit, reason) {
|
|
227
|
+
return this.edit({ triggerMetadata: { ...this.triggerMetadata, mentionTotalLimit }, reason });
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Sets whether to enable mention raid protection for this auto moderation rule.
|
|
232
|
+
* @param {boolean} mentionRaidProtectionEnabled
|
|
233
|
+
* Whether to enable mention raid protection for this auto moderation rule
|
|
234
|
+
* @param {string} [reason] The reason for changing the mention raid protection of this auto moderation rule
|
|
235
|
+
* @returns {Promise<AutoModerationRule>}
|
|
236
|
+
*/
|
|
237
|
+
setMentionRaidProtectionEnabled(mentionRaidProtectionEnabled, reason) {
|
|
238
|
+
return this.edit({ triggerMetadata: { ...this.triggerMetadata, mentionRaidProtectionEnabled }, reason });
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Sets the actions for this auto moderation rule.
|
|
243
|
+
* @param {AutoModerationActionOptions[]} actions The actions of this auto moderation rule
|
|
244
|
+
* @param {string} [reason] The reason for changing the actions of this auto moderation rule
|
|
245
|
+
* @returns {Promise<AutoModerationRule>}
|
|
246
|
+
*/
|
|
247
|
+
setActions(actions, reason) {
|
|
248
|
+
return this.edit({ actions, reason });
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Sets whether this auto moderation rule should be enabled.
|
|
253
|
+
* @param {boolean} [enabled=true] Whether to enable this auto moderation rule
|
|
254
|
+
* @param {string} [reason] The reason for enabling or disabling this auto moderation rule
|
|
255
|
+
* @returns {Promise<AutoModerationRule>}
|
|
256
|
+
*/
|
|
257
|
+
setEnabled(enabled = true, reason) {
|
|
258
|
+
return this.edit({ enabled, reason });
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Sets the exempt roles for this auto moderation rule.
|
|
263
|
+
* @param {Collection<Snowflake, Role>|RoleResolvable[]} [exemptRoles]
|
|
264
|
+
* The roles that should not be affected by the auto moderation rule
|
|
265
|
+
* @param {string} [reason] The reason for changing the exempt roles of this auto moderation rule
|
|
266
|
+
* @returns {Promise<AutoModerationRule>}
|
|
267
|
+
*/
|
|
268
|
+
setExemptRoles(exemptRoles, reason) {
|
|
269
|
+
return this.edit({ exemptRoles, reason });
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Sets the exempt channels for this auto moderation rule.
|
|
274
|
+
* @param {Collection<Snowflake, GuildChannel|ThreadChannel>|GuildChannelResolvable[]} [exemptChannels]
|
|
275
|
+
* The channels that should not be affected by the auto moderation rule
|
|
276
|
+
* @param {string} [reason] The reason for changing the exempt channels of this auto moderation rule
|
|
277
|
+
* @returns {Promise<AutoModerationRule>}
|
|
278
|
+
*/
|
|
279
|
+
setExemptChannels(exemptChannels, reason) {
|
|
280
|
+
return this.edit({ exemptChannels, reason });
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
module.exports = AutoModerationRule;
|