@ovencord/discord.js 14.16.3
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 +148 -0
- package/package.json +73 -0
- package/src/client/Client.ts +967 -0
- package/src/client/actions/Action.ts +141 -0
- package/src/client/actions/ActionsManager.ts +138 -0
- package/src/client/actions/ChannelCreate.ts +21 -0
- package/src/client/actions/ChannelDelete.ts +20 -0
- package/src/client/actions/ChannelUpdate.ts +38 -0
- package/src/client/actions/GuildChannelsPositionUpdate.ts +17 -0
- package/src/client/actions/GuildEmojiCreate.ts +17 -0
- package/src/client/actions/GuildEmojiDelete.ts +16 -0
- package/src/client/actions/GuildEmojiUpdate.ts +17 -0
- package/src/client/actions/GuildEmojisUpdate.ts +30 -0
- package/src/client/actions/GuildMemberRemove.ts +29 -0
- package/src/client/actions/GuildMemberUpdate.ts +41 -0
- package/src/client/actions/GuildRoleCreate.ts +23 -0
- package/src/client/actions/GuildRoleDelete.ts +26 -0
- package/src/client/actions/GuildRolesPositionUpdate.ts +17 -0
- package/src/client/actions/GuildScheduledEventDelete.ts +28 -0
- package/src/client/actions/GuildScheduledEventUserAdd.ts +29 -0
- package/src/client/actions/GuildScheduledEventUserRemove.ts +29 -0
- package/src/client/actions/GuildSoundboardSoundDelete.ts +26 -0
- package/src/client/actions/GuildStickerCreate.ts +17 -0
- package/src/client/actions/GuildStickerDelete.ts +16 -0
- package/src/client/actions/GuildStickerUpdate.ts +17 -0
- package/src/client/actions/GuildStickersUpdate.ts +30 -0
- package/src/client/actions/GuildUpdate.ts +30 -0
- package/src/client/actions/InteractionCreate.ts +104 -0
- package/src/client/actions/MessageCreate.ts +38 -0
- package/src/client/actions/MessageDelete.ts +29 -0
- package/src/client/actions/MessageDeleteBulk.ts +45 -0
- package/src/client/actions/MessagePollVoteAdd.ts +37 -0
- package/src/client/actions/MessagePollVoteRemove.ts +35 -0
- package/src/client/actions/MessageReactionAdd.ts +68 -0
- package/src/client/actions/MessageReactionRemove.ts +47 -0
- package/src/client/actions/MessageReactionRemoveAll.ts +30 -0
- package/src/client/actions/MessageReactionRemoveEmoji.ts +25 -0
- package/src/client/actions/MessageUpdate.ts +22 -0
- package/src/client/actions/StageInstanceCreate.ts +25 -0
- package/src/client/actions/StageInstanceDelete.ts +28 -0
- package/src/client/actions/StageInstanceUpdate.ts +27 -0
- package/src/client/actions/ThreadCreate.ts +22 -0
- package/src/client/actions/ThreadMembersUpdate.ts +45 -0
- package/src/client/actions/TypingStart.ts +26 -0
- package/src/client/actions/UserUpdate.ts +33 -0
- package/src/client/voice/ClientVoiceManager.ts +46 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_PERMISSIONS_UPDATE.ts +19 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_ACTION_EXECUTION.ts +17 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_CREATE.ts +18 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_DELETE.ts +21 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_UPDATE.ts +20 -0
- package/src/client/websocket/handlers/CHANNEL_CREATE.ts +4 -0
- package/src/client/websocket/handlers/CHANNEL_DELETE.ts +4 -0
- package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.ts +22 -0
- package/src/client/websocket/handlers/CHANNEL_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/ENTITLEMENT_CREATE.ts +14 -0
- package/src/client/websocket/handlers/ENTITLEMENT_DELETE.ts +18 -0
- package/src/client/websocket/handlers/ENTITLEMENT_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/GUILD_AUDIT_LOG_ENTRY_CREATE.ts +19 -0
- package/src/client/websocket/handlers/GUILD_BAN_ADD.ts +15 -0
- package/src/client/websocket/handlers/GUILD_BAN_REMOVE.ts +20 -0
- package/src/client/websocket/handlers/GUILD_CREATE.ts +34 -0
- package/src/client/websocket/handlers/GUILD_DELETE.ts +36 -0
- package/src/client/websocket/handlers/GUILD_EMOJIS_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_INTEGRATIONS_UPDATE.ts +15 -0
- package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.ts +40 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_ADD.ts +17 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_ROLE_CREATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_ROLE_DELETE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_ROLE_UPDATE.ts +21 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_CREATE.ts +17 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_DELETE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_UPDATE.ts +19 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_ADD.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.ts +24 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.ts +18 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_DELETE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.ts +20 -0
- package/src/client/websocket/handlers/GUILD_STICKERS_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/INTERACTION_CREATE.ts +4 -0
- package/src/client/websocket/handlers/INVITE_CREATE.ts +20 -0
- package/src/client/websocket/handlers/INVITE_DELETE.ts +23 -0
- package/src/client/websocket/handlers/MESSAGE_CREATE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE_BULK.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_ADD.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_ADD.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_ALL.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_EMOJI.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/PRESENCE_UPDATE.ts +42 -0
- package/src/client/websocket/handlers/RATE_LIMITED.ts +23 -0
- package/src/client/websocket/handlers/READY.ts +29 -0
- package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.ts +24 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_CREATE.ts +4 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_DELETE.ts +4 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/SUBSCRIPTION_CREATE.ts +14 -0
- package/src/client/websocket/handlers/SUBSCRIPTION_DELETE.ts +16 -0
- package/src/client/websocket/handlers/SUBSCRIPTION_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/THREAD_CREATE.ts +4 -0
- package/src/client/websocket/handlers/THREAD_DELETE.ts +17 -0
- package/src/client/websocket/handlers/THREAD_LIST_SYNC.ts +50 -0
- package/src/client/websocket/handlers/THREAD_MEMBERS_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/THREAD_MEMBER_UPDATE.ts +25 -0
- package/src/client/websocket/handlers/THREAD_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/TYPING_START.ts +4 -0
- package/src/client/websocket/handlers/USER_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.ts +16 -0
- package/src/client/websocket/handlers/VOICE_SERVER_UPDATE.ts +5 -0
- package/src/client/websocket/handlers/VOICE_STATE_UPDATE.ts +37 -0
- package/src/client/websocket/handlers/WEBHOOKS_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/index.ts +74 -0
- package/src/errors/DJSError.ts +50 -0
- package/src/errors/ErrorCodes.ts +277 -0
- package/src/errors/Messages.ts +155 -0
- package/src/errors/index.ts +6 -0
- package/src/index.ts +241 -0
- package/src/managers/ApplicationCommandManager.ts +303 -0
- package/src/managers/ApplicationCommandPermissionsManager.ts +453 -0
- package/src/managers/ApplicationEmojiManager.ts +149 -0
- package/src/managers/AutoModerationRuleManager.ts +307 -0
- package/src/managers/BaseManager.ts +13 -0
- package/src/managers/CachedManager.ts +56 -0
- package/src/managers/CategoryChannelChildManager.ts +81 -0
- package/src/managers/ChannelManager.ts +194 -0
- package/src/managers/DMMessageManager.ts +15 -0
- package/src/managers/DataManager.ts +38 -0
- package/src/managers/EntitlementManager.ts +182 -0
- package/src/managers/GuildApplicationCommandManager.ts +29 -0
- package/src/managers/GuildBanManager.ts +221 -0
- package/src/managers/GuildChannelManager.ts +552 -0
- package/src/managers/GuildEmojiManager.ts +262 -0
- package/src/managers/GuildEmojiRoleManager.ts +134 -0
- package/src/managers/GuildForumThreadManager.ts +84 -0
- package/src/managers/GuildInviteManager.ts +236 -0
- package/src/managers/GuildManager.ts +265 -0
- package/src/managers/GuildMemberManager.ts +619 -0
- package/src/managers/GuildMemberRoleManager.ts +230 -0
- package/src/managers/GuildMessageManager.ts +31 -0
- package/src/managers/GuildScheduledEventManager.ts +330 -0
- package/src/managers/GuildSoundboardSoundManager.ts +157 -0
- package/src/managers/GuildStickerManager.ts +192 -0
- package/src/managers/GuildTextThreadManager.ts +91 -0
- package/src/managers/MessageManager.ts +352 -0
- package/src/managers/PartialGroupDMMessageManager.ts +15 -0
- package/src/managers/PermissionOverwriteManager.ts +174 -0
- package/src/managers/PollAnswerVoterManager.ts +59 -0
- package/src/managers/PresenceManager.ts +60 -0
- package/src/managers/ReactionManager.ts +72 -0
- package/src/managers/ReactionUserManager.ts +82 -0
- package/src/managers/RoleManager.ts +432 -0
- package/src/managers/StageInstanceManager.ts +166 -0
- package/src/managers/SubscriptionManager.ts +83 -0
- package/src/managers/ThreadManager.ts +210 -0
- package/src/managers/ThreadMemberManager.ts +194 -0
- package/src/managers/UserManager.ts +139 -0
- package/src/managers/VoiceStateManager.ts +61 -0
- package/src/sharding/Shard.ts +513 -0
- package/src/sharding/ShardClientUtil.ts +293 -0
- package/src/sharding/ShardingManager.ts +374 -0
- package/src/structures/ActionRow.ts +31 -0
- package/src/structures/AnnouncementChannel.ts +25 -0
- package/src/structures/AnonymousGuild.ts +110 -0
- package/src/structures/ApplicationCommand.ts +675 -0
- package/src/structures/ApplicationEmoji.ts +189 -0
- package/src/structures/ApplicationRoleConnectionMetadata.ts +54 -0
- package/src/structures/Attachment.ts +189 -0
- package/src/structures/AuthorizingIntegrationOwners.ts +63 -0
- package/src/structures/AutoModerationActionExecution.ts +138 -0
- package/src/structures/AutoModerationRule.ts +325 -0
- package/src/structures/AutocompleteInteraction.ts +115 -0
- package/src/structures/Base.ts +37 -0
- package/src/structures/BaseChannel.ts +188 -0
- package/src/structures/BaseGuild.ts +134 -0
- package/src/structures/BaseGuildEmoji.ts +113 -0
- package/src/structures/BaseGuildTextChannel.ts +230 -0
- package/src/structures/BaseGuildVoiceChannel.ts +270 -0
- package/src/structures/BaseInteraction.ts +393 -0
- package/src/structures/BaseInvite.ts +192 -0
- package/src/structures/BaseSelectMenuComponent.ts +58 -0
- package/src/structures/ButtonComponent.ts +68 -0
- package/src/structures/ButtonInteraction.ts +8 -0
- package/src/structures/CategoryChannel.ts +46 -0
- package/src/structures/ChannelSelectMenuComponent.ts +18 -0
- package/src/structures/ChannelSelectMenuInteraction.ts +34 -0
- package/src/structures/ChatInputCommandInteraction.ts +43 -0
- package/src/structures/ClientApplication.ts +470 -0
- package/src/structures/ClientPresence.ts +87 -0
- package/src/structures/ClientUser.ts +219 -0
- package/src/structures/CommandInteraction.ts +193 -0
- package/src/structures/CommandInteractionOptionResolver.ts +336 -0
- package/src/structures/Component.ts +59 -0
- package/src/structures/ContainerComponent.ts +63 -0
- package/src/structures/ContextMenuCommandInteraction.ts +68 -0
- package/src/structures/DMChannel.ts +148 -0
- package/src/structures/DirectoryChannel.ts +40 -0
- package/src/structures/Embed.ts +251 -0
- package/src/structures/Emoji.ts +61 -0
- package/src/structures/Entitlement.ts +206 -0
- package/src/structures/FileComponent.ts +41 -0
- package/src/structures/ForumChannel.ts +31 -0
- package/src/structures/GroupDMInvite.ts +34 -0
- package/src/structures/Guild.ts +1605 -0
- package/src/structures/GuildAuditLogs.ts +99 -0
- package/src/structures/GuildAuditLogsEntry.ts +557 -0
- package/src/structures/GuildBan.ts +65 -0
- package/src/structures/GuildChannel.ts +515 -0
- package/src/structures/GuildEmoji.ts +159 -0
- package/src/structures/GuildInvite.ts +233 -0
- package/src/structures/GuildMember.ts +643 -0
- package/src/structures/GuildOnboarding.ts +73 -0
- package/src/structures/GuildOnboardingPrompt.ts +93 -0
- package/src/structures/GuildOnboardingPromptOption.ts +100 -0
- package/src/structures/GuildPreview.ts +218 -0
- package/src/structures/GuildPreviewEmoji.ts +28 -0
- package/src/structures/GuildScheduledEvent.ts +593 -0
- package/src/structures/GuildTemplate.ts +229 -0
- package/src/structures/Integration.ts +257 -0
- package/src/structures/IntegrationApplication.ts +84 -0
- package/src/structures/InteractionCallback.ts +86 -0
- package/src/structures/InteractionCallbackResource.ts +57 -0
- package/src/structures/InteractionCallbackResponse.ts +35 -0
- package/src/structures/InteractionCollector.ts +260 -0
- package/src/structures/InteractionWebhook.ts +65 -0
- package/src/structures/InviteGuild.ts +22 -0
- package/src/structures/LabelComponent.ts +51 -0
- package/src/structures/MediaChannel.ts +8 -0
- package/src/structures/MediaGalleryComponent.ts +31 -0
- package/src/structures/MediaGalleryItem.ts +54 -0
- package/src/structures/MentionableSelectMenuComponent.ts +8 -0
- package/src/structures/MentionableSelectMenuInteraction.ts +76 -0
- package/src/structures/Message.ts +1202 -0
- package/src/structures/MessageCollector.ts +155 -0
- package/src/structures/MessageComponentInteraction.ts +132 -0
- package/src/structures/MessageContextMenuCommandInteraction.ts +18 -0
- package/src/structures/MessageMentions.ts +327 -0
- package/src/structures/MessagePayload.ts +325 -0
- package/src/structures/MessageReaction.ts +219 -0
- package/src/structures/ModalComponentResolver.ts +237 -0
- package/src/structures/ModalSubmitInteraction.ts +260 -0
- package/src/structures/OAuth2Guild.ts +30 -0
- package/src/structures/PartialGroupDMChannel.ts +151 -0
- package/src/structures/PermissionOverwrites.ts +222 -0
- package/src/structures/Poll.ts +195 -0
- package/src/structures/PollAnswer.ts +100 -0
- package/src/structures/Presence.ts +448 -0
- package/src/structures/PrimaryEntryPointCommandInteraction.ts +8 -0
- package/src/structures/ReactionCollector.ts +245 -0
- package/src/structures/ReactionEmoji.ts +30 -0
- package/src/structures/Role.ts +543 -0
- package/src/structures/RoleSelectMenuComponent.ts +8 -0
- package/src/structures/RoleSelectMenuInteraction.ts +34 -0
- package/src/structures/SKU.ts +62 -0
- package/src/structures/SectionComponent.ts +44 -0
- package/src/structures/SeparatorComponent.ts +29 -0
- package/src/structures/SoundboardSound.ts +176 -0
- package/src/structures/StageChannel.ts +118 -0
- package/src/structures/StageInstance.ts +173 -0
- package/src/structures/Sticker.ts +300 -0
- package/src/structures/StickerPack.ts +111 -0
- package/src/structures/StringSelectMenuComponent.ts +18 -0
- package/src/structures/StringSelectMenuInteraction.ts +21 -0
- package/src/structures/Subscription.ts +138 -0
- package/src/structures/Team.ts +131 -0
- package/src/structures/TeamMember.ts +77 -0
- package/src/structures/TextChannel.ts +33 -0
- package/src/structures/TextDisplayComponent.ts +18 -0
- package/src/structures/TextInputComponent.ts +28 -0
- package/src/structures/ThreadChannel.ts +680 -0
- package/src/structures/ThreadMember.ts +125 -0
- package/src/structures/ThreadOnlyChannel.ts +276 -0
- package/src/structures/ThumbnailComponent.ts +51 -0
- package/src/structures/Typing.ts +81 -0
- package/src/structures/UnfurledMediaItem.ts +33 -0
- package/src/structures/User.ts +511 -0
- package/src/structures/UserContextMenuCommandInteraction.ts +28 -0
- package/src/structures/UserSelectMenuComponent.ts +8 -0
- package/src/structures/UserSelectMenuInteraction.ts +54 -0
- package/src/structures/VoiceChannel.ts +119 -0
- package/src/structures/VoiceChannelEffect.ts +92 -0
- package/src/structures/VoiceRegion.ts +52 -0
- package/src/structures/VoiceState.ts +346 -0
- package/src/structures/Webhook.ts +526 -0
- package/src/structures/WelcomeChannel.ts +67 -0
- package/src/structures/WelcomeScreen.ts +53 -0
- package/src/structures/Widget.ts +110 -0
- package/src/structures/WidgetMember.ts +124 -0
- package/src/structures/interfaces/Application.ts +179 -0
- package/src/structures/interfaces/Collector.ts +372 -0
- package/src/structures/interfaces/InteractionResponses.ts +384 -0
- package/src/structures/interfaces/TextBasedChannel.ts +430 -0
- package/src/util/APITypes.ts +690 -0
- package/src/util/ActivityFlagsBitField.ts +26 -0
- package/src/util/ApplicationFlagsBitField.ts +43 -0
- package/src/util/AttachmentFlagsBitField.ts +26 -0
- package/src/util/BitField.ts +178 -0
- package/src/util/ChannelFlagsBitField.ts +43 -0
- package/src/util/Channels.ts +165 -0
- package/src/util/Colors.ts +72 -0
- package/src/util/Components.ts +285 -0
- package/src/util/Constants.ts +251 -0
- package/src/util/DataResolver.ts +146 -0
- package/src/util/Enums.ts +10 -0
- package/src/util/Events.ts +178 -0
- package/src/util/GuildMemberFlagsBitField.ts +43 -0
- package/src/util/IntentsBitField.ts +35 -0
- package/src/util/InviteFlagsBitField.ts +26 -0
- package/src/util/Invites.ts +27 -0
- package/src/util/LimitedCollection.ts +73 -0
- package/src/util/MessageFlagsBitField.ts +43 -0
- package/src/util/Options.ts +215 -0
- package/src/util/Partials.ts +50 -0
- package/src/util/PermissionsBitField.ts +113 -0
- package/src/util/RoleFlagsBitField.ts +26 -0
- package/src/util/SKUFlagsBitField.ts +26 -0
- package/src/util/ShardEvents.ts +26 -0
- package/src/util/Status.ts +16 -0
- package/src/util/Sweepers.ts +532 -0
- package/src/util/Symbols.ts +1 -0
- package/src/util/SystemChannelFlagsBitField.ts +45 -0
- package/src/util/ThreadMemberFlagsBitField.ts +33 -0
- package/src/util/Transformers.ts +123 -0
- package/src/util/UserFlagsBitField.ts +33 -0
- package/src/util/Util.ts +519 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { Collection } from '@ovencord/collection';
|
|
2
|
+
import { _transformAPIAutoModerationAction } from '../util/Transformers.js';
|
|
3
|
+
import { Base } from './Base.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents an auto moderation rule.
|
|
7
|
+
*
|
|
8
|
+
* @extends {Base}
|
|
9
|
+
*/
|
|
10
|
+
export class AutoModerationRule extends Base {
|
|
11
|
+
public client: any;
|
|
12
|
+
public id: any;
|
|
13
|
+
public guild: any;
|
|
14
|
+
public creatorId: any;
|
|
15
|
+
public triggerType: any;
|
|
16
|
+
public name: any;
|
|
17
|
+
public eventType: any;
|
|
18
|
+
public triggerMetadata: any;
|
|
19
|
+
public actions: any;
|
|
20
|
+
public enabled: any;
|
|
21
|
+
public exemptRoles: any;
|
|
22
|
+
public exemptChannels: any;
|
|
23
|
+
constructor(client, data, guild) {
|
|
24
|
+
super(client);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The id of this auto moderation rule.
|
|
28
|
+
*
|
|
29
|
+
* @type {Snowflake}
|
|
30
|
+
*/
|
|
31
|
+
this.id = data.id;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The guild this auto moderation rule is for.
|
|
35
|
+
*
|
|
36
|
+
* @type {Guild}
|
|
37
|
+
*/
|
|
38
|
+
this.guild = guild;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The user that created this auto moderation rule.
|
|
42
|
+
*
|
|
43
|
+
* @type {Snowflake}
|
|
44
|
+
*/
|
|
45
|
+
this.creatorId = data.creator_id;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The trigger type of this auto moderation rule.
|
|
49
|
+
*
|
|
50
|
+
* @type {AutoModerationRuleTriggerType}
|
|
51
|
+
*/
|
|
52
|
+
this.triggerType = data.trigger_type;
|
|
53
|
+
|
|
54
|
+
this._patch(data);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
_patch(data) {
|
|
58
|
+
if ('name' in data) {
|
|
59
|
+
/**
|
|
60
|
+
* The name of this auto moderation rule.
|
|
61
|
+
*
|
|
62
|
+
* @type {string}
|
|
63
|
+
*/
|
|
64
|
+
this.name = data.name;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if ('event_type' in data) {
|
|
68
|
+
/**
|
|
69
|
+
* The event type of this auto moderation rule.
|
|
70
|
+
*
|
|
71
|
+
* @type {AutoModerationRuleEventType}
|
|
72
|
+
*/
|
|
73
|
+
this.eventType = data.event_type;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if ('trigger_metadata' in data) {
|
|
77
|
+
/**
|
|
78
|
+
* Additional data used to determine whether an auto moderation rule should be triggered.
|
|
79
|
+
*
|
|
80
|
+
* @typedef {Object} AutoModerationTriggerMetadata
|
|
81
|
+
* @property {string[]} keywordFilter The substrings that will be searched for in the content
|
|
82
|
+
* @property {string[]} regexPatterns The regular expression patterns which will be matched against the content
|
|
83
|
+
* <info>Only Rust-flavored regular expressions are supported.</info>
|
|
84
|
+
* @property {AutoModerationRuleKeywordPresetType[]} presets
|
|
85
|
+
* The internally pre-defined wordsets which will be searched for in the content
|
|
86
|
+
* @property {string[]} allowList The substrings that will be exempt from triggering
|
|
87
|
+
* {@link AutoModerationRuleTriggerType.Keyword},
|
|
88
|
+
* {@link AutoModerationRuleTriggerType.KeywordPreset},
|
|
89
|
+
* and {@link AutoModerationRuleTriggerType.MemberProfile}
|
|
90
|
+
* @property {?number} mentionTotalLimit The total number of role & user mentions allowed per message
|
|
91
|
+
* @property {boolean} mentionRaidProtectionEnabled Whether mention raid protection is enabled
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The trigger metadata of the rule.
|
|
96
|
+
*
|
|
97
|
+
* @type {AutoModerationTriggerMetadata}
|
|
98
|
+
*/
|
|
99
|
+
this.triggerMetadata = {
|
|
100
|
+
keywordFilter: data.trigger_metadata.keyword_filter ?? [],
|
|
101
|
+
regexPatterns: data.trigger_metadata.regex_patterns ?? [],
|
|
102
|
+
presets: data.trigger_metadata.presets ?? [],
|
|
103
|
+
allowList: data.trigger_metadata.allow_list ?? [],
|
|
104
|
+
mentionTotalLimit: data.trigger_metadata.mention_total_limit ?? null,
|
|
105
|
+
mentionRaidProtectionEnabled: data.trigger_metadata.mention_raid_protection_enabled ?? false,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if ('actions' in data) {
|
|
110
|
+
/**
|
|
111
|
+
* An object containing information about an auto moderation rule action.
|
|
112
|
+
*
|
|
113
|
+
* @typedef {Object} AutoModerationAction
|
|
114
|
+
* @property {AutoModerationActionType} type The type of this auto moderation rule action
|
|
115
|
+
* @property {AutoModerationActionMetadata} metadata Additional metadata needed during execution
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Additional data used when an auto moderation rule is executed.
|
|
120
|
+
*
|
|
121
|
+
* @typedef {Object} AutoModerationActionMetadata
|
|
122
|
+
* @property {?Snowflake} channelId The id of the channel to which content will be logged
|
|
123
|
+
* @property {?number} durationSeconds The timeout duration in seconds
|
|
124
|
+
* @property {?string} customMessage The custom message that is shown whenever a message is blocked
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The actions of this auto moderation rule.
|
|
129
|
+
*
|
|
130
|
+
* @type {AutoModerationAction[]}
|
|
131
|
+
*/
|
|
132
|
+
this.actions = data.actions.map(action => _transformAPIAutoModerationAction(action));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if ('enabled' in data) {
|
|
136
|
+
/**
|
|
137
|
+
* Whether this auto moderation rule is enabled.
|
|
138
|
+
*
|
|
139
|
+
* @type {boolean}
|
|
140
|
+
*/
|
|
141
|
+
this.enabled = data.enabled;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if ('exempt_roles' in data) {
|
|
145
|
+
/**
|
|
146
|
+
* The roles exempt by this auto moderation rule.
|
|
147
|
+
*
|
|
148
|
+
* @type {Collection<Snowflake, Role>}
|
|
149
|
+
*/
|
|
150
|
+
this.exemptRoles = new Collection(
|
|
151
|
+
data.exempt_roles.map(exemptRole => [exemptRole, this.guild.roles.cache.get(exemptRole)]),
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if ('exempt_channels' in data) {
|
|
156
|
+
/**
|
|
157
|
+
* The channels exempt by this auto moderation rule.
|
|
158
|
+
*
|
|
159
|
+
* @type {Collection<Snowflake, GuildChannel|ThreadChannel>}
|
|
160
|
+
*/
|
|
161
|
+
this.exemptChannels = new Collection(
|
|
162
|
+
data.exempt_channels.map(exemptChannel => [exemptChannel, this.guild.channels.cache.get(exemptChannel)]),
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Edits this auto moderation rule.
|
|
169
|
+
*
|
|
170
|
+
* @param {AutoModerationRuleEditOptions} options Options for editing this auto moderation rule
|
|
171
|
+
* @returns {Promise<AutoModerationRule>}
|
|
172
|
+
*/
|
|
173
|
+
async edit(options) {
|
|
174
|
+
return this.guild.autoModerationRules.edit(this.id, options);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Deletes this auto moderation rule.
|
|
179
|
+
*
|
|
180
|
+
* @param {string} [reason] The reason for deleting this auto moderation rule
|
|
181
|
+
* @returns {Promise<void>}
|
|
182
|
+
*/
|
|
183
|
+
async delete(reason) {
|
|
184
|
+
return this.guild.autoModerationRules.delete(this.id, reason);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Sets the name for this auto moderation rule.
|
|
189
|
+
*
|
|
190
|
+
* @param {string} name The name of this auto moderation rule
|
|
191
|
+
* @param {string} [reason] The reason for changing the name of this auto moderation rule
|
|
192
|
+
* @returns {Promise<AutoModerationRule>}
|
|
193
|
+
*/
|
|
194
|
+
async setName(name, reason) {
|
|
195
|
+
return this.edit({ name, reason });
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Sets the event type for this auto moderation rule.
|
|
200
|
+
*
|
|
201
|
+
* @param {AutoModerationRuleEventType} eventType The event type of this auto moderation rule
|
|
202
|
+
* @param {string} [reason] The reason for changing the event type of this auto moderation rule
|
|
203
|
+
* @returns {Promise<AutoModerationRule>}
|
|
204
|
+
*/
|
|
205
|
+
async setEventType(eventType, reason) {
|
|
206
|
+
return this.edit({ eventType, reason });
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Sets the keyword filter for this auto moderation rule.
|
|
211
|
+
*
|
|
212
|
+
* @param {string[]} keywordFilter The keyword filter of this auto moderation rule
|
|
213
|
+
* @param {string} [reason] The reason for changing the keyword filter of this auto moderation rule
|
|
214
|
+
* @returns {Promise<AutoModerationRule>}
|
|
215
|
+
*/
|
|
216
|
+
async setKeywordFilter(keywordFilter, reason) {
|
|
217
|
+
return this.edit({ triggerMetadata: { ...this.triggerMetadata, keywordFilter }, reason });
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Sets the regular expression patterns for this auto moderation rule.
|
|
222
|
+
*
|
|
223
|
+
* @param {string[]} regexPatterns The regular expression patterns of this auto moderation rule
|
|
224
|
+
* <info>Only Rust-flavored regular expressions are supported.</info>
|
|
225
|
+
* @param {string} [reason] The reason for changing the regular expression patterns of this auto moderation rule
|
|
226
|
+
* @returns {Promise<AutoModerationRule>}
|
|
227
|
+
*/
|
|
228
|
+
async setRegexPatterns(regexPatterns, reason) {
|
|
229
|
+
return this.edit({ triggerMetadata: { ...this.triggerMetadata, regexPatterns }, reason });
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Sets the presets for this auto moderation rule.
|
|
234
|
+
*
|
|
235
|
+
* @param {AutoModerationRuleKeywordPresetType[]} presets The presets of this auto moderation rule
|
|
236
|
+
* @param {string} [reason] The reason for changing the presets of this auto moderation rule
|
|
237
|
+
* @returns {Promise<AutoModerationRule>}
|
|
238
|
+
*/
|
|
239
|
+
async setPresets(presets, reason) {
|
|
240
|
+
return this.edit({ triggerMetadata: { ...this.triggerMetadata, presets }, reason });
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Sets the allow list for this auto moderation rule.
|
|
245
|
+
*
|
|
246
|
+
* @param {string[]} allowList The substrings that will be exempt from triggering
|
|
247
|
+
* {@link AutoModerationRuleTriggerType.Keyword},
|
|
248
|
+
* {@link AutoModerationRuleTriggerType.KeywordPreset},
|
|
249
|
+
* and {@link AutoModerationRuleTriggerType.MemberProfile}
|
|
250
|
+
* @param {string} [reason] The reason for changing the allow list of this auto moderation rule
|
|
251
|
+
* @returns {Promise<AutoModerationRule>}
|
|
252
|
+
*/
|
|
253
|
+
async setAllowList(allowList, reason) {
|
|
254
|
+
return this.edit({ triggerMetadata: { ...this.triggerMetadata, allowList }, reason });
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Sets the mention total limit for this auto moderation rule.
|
|
259
|
+
*
|
|
260
|
+
* @param {number} mentionTotalLimit The total number of unique role and user mentions allowed per message
|
|
261
|
+
* @param {string} [reason] The reason for changing the mention total limit of this auto moderation rule
|
|
262
|
+
* @returns {Promise<AutoModerationRule>}
|
|
263
|
+
*/
|
|
264
|
+
async setMentionTotalLimit(mentionTotalLimit, reason) {
|
|
265
|
+
return this.edit({ triggerMetadata: { ...this.triggerMetadata, mentionTotalLimit }, reason });
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Sets whether to enable mention raid protection for this auto moderation rule.
|
|
270
|
+
*
|
|
271
|
+
* @param {boolean} mentionRaidProtectionEnabled
|
|
272
|
+
* Whether to enable mention raid protection for this auto moderation rule
|
|
273
|
+
* @param {string} [reason] The reason for changing the mention raid protection of this auto moderation rule
|
|
274
|
+
* @returns {Promise<AutoModerationRule>}
|
|
275
|
+
*/
|
|
276
|
+
async setMentionRaidProtectionEnabled(mentionRaidProtectionEnabled, reason) {
|
|
277
|
+
return this.edit({ triggerMetadata: { ...this.triggerMetadata, mentionRaidProtectionEnabled }, reason });
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Sets the actions for this auto moderation rule.
|
|
282
|
+
*
|
|
283
|
+
* @param {AutoModerationActionOptions[]} actions The actions of this auto moderation rule
|
|
284
|
+
* @param {string} [reason] The reason for changing the actions of this auto moderation rule
|
|
285
|
+
* @returns {Promise<AutoModerationRule>}
|
|
286
|
+
*/
|
|
287
|
+
async setActions(actions, reason) {
|
|
288
|
+
return this.edit({ actions, reason });
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Sets whether this auto moderation rule should be enabled.
|
|
293
|
+
*
|
|
294
|
+
* @param {boolean} [enabled=true] Whether to enable this auto moderation rule
|
|
295
|
+
* @param {string} [reason] The reason for enabling or disabling this auto moderation rule
|
|
296
|
+
* @returns {Promise<AutoModerationRule>}
|
|
297
|
+
*/
|
|
298
|
+
async setEnabled(enabled = true, reason = undefined) {
|
|
299
|
+
return this.edit({ enabled, reason });
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Sets the exempt roles for this auto moderation rule.
|
|
304
|
+
*
|
|
305
|
+
* @param {Collection<Snowflake, Role>|RoleResolvable[]} [exemptRoles]
|
|
306
|
+
* The roles that should not be affected by the auto moderation rule
|
|
307
|
+
* @param {string} [reason] The reason for changing the exempt roles of this auto moderation rule
|
|
308
|
+
* @returns {Promise<AutoModerationRule>}
|
|
309
|
+
*/
|
|
310
|
+
async setExemptRoles(exemptRoles, reason) {
|
|
311
|
+
return this.edit({ exemptRoles, reason });
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Sets the exempt channels for this auto moderation rule.
|
|
316
|
+
*
|
|
317
|
+
* @param {Collection<Snowflake, GuildChannel|ThreadChannel>|GuildChannelResolvable[]} [exemptChannels]
|
|
318
|
+
* The channels that should not be affected by the auto moderation rule
|
|
319
|
+
* @param {string} [reason] The reason for changing the exempt channels of this auto moderation rule
|
|
320
|
+
* @returns {Promise<AutoModerationRule>}
|
|
321
|
+
*/
|
|
322
|
+
async setExemptChannels(exemptChannels, reason) {
|
|
323
|
+
return this.edit({ exemptChannels, reason });
|
|
324
|
+
}
|
|
325
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { InteractionResponseType, Routes } from 'discord-api-types/v10';
|
|
2
|
+
import { DiscordjsError, ErrorCodes } from '../errors/index.js';
|
|
3
|
+
import { BaseInteraction } from './BaseInteraction.js';
|
|
4
|
+
import { CommandInteractionOptionResolver } from './CommandInteractionOptionResolver.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents an autocomplete interaction.
|
|
8
|
+
*
|
|
9
|
+
* @extends {BaseInteraction}
|
|
10
|
+
*/
|
|
11
|
+
export class AutocompleteInteraction extends BaseInteraction {
|
|
12
|
+
public client: any;
|
|
13
|
+
public commandId: any;
|
|
14
|
+
public commandName: any;
|
|
15
|
+
public commandType: any;
|
|
16
|
+
public commandGuildId: any;
|
|
17
|
+
public responded: any;
|
|
18
|
+
public options: any;
|
|
19
|
+
constructor(client, data) {
|
|
20
|
+
super(client, data);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The id of the channel this interaction was sent in
|
|
24
|
+
*
|
|
25
|
+
* @type {Snowflake}
|
|
26
|
+
* @name AutocompleteInteraction#channelId
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The invoked application command's id
|
|
31
|
+
*
|
|
32
|
+
* @type {Snowflake}
|
|
33
|
+
*/
|
|
34
|
+
this.commandId = data.data.id;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The invoked application command's name
|
|
38
|
+
*
|
|
39
|
+
* @type {string}
|
|
40
|
+
*/
|
|
41
|
+
this.commandName = data.data.name;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The invoked application command's type
|
|
45
|
+
*
|
|
46
|
+
* @type {ApplicationCommandType}
|
|
47
|
+
*/
|
|
48
|
+
this.commandType = data.data.type;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The id of the guild the invoked application command is registered to
|
|
52
|
+
*
|
|
53
|
+
* @type {?Snowflake}
|
|
54
|
+
*/
|
|
55
|
+
this.commandGuildId = data.data.guild_id ?? null;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Whether this interaction has already received a response
|
|
59
|
+
*
|
|
60
|
+
* @type {boolean}
|
|
61
|
+
*/
|
|
62
|
+
this.responded = false;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The options passed to the command
|
|
66
|
+
*
|
|
67
|
+
* @type {CommandInteractionOptionResolver}
|
|
68
|
+
*/
|
|
69
|
+
this.options = new CommandInteractionOptionResolver(this.client, data.data.options ?? []);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The invoked application command, if it was fetched before
|
|
74
|
+
*
|
|
75
|
+
* @type {?ApplicationCommand}
|
|
76
|
+
*/
|
|
77
|
+
get command() {
|
|
78
|
+
const id = this.commandId;
|
|
79
|
+
return this.guild?.commands.cache.get(id) ?? this.client.application.commands.cache.get(id) ?? null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Sends results for the autocomplete of this interaction.
|
|
84
|
+
*
|
|
85
|
+
* @param {ApplicationCommandOptionChoiceData[]} options The options for the autocomplete
|
|
86
|
+
* @returns {Promise<void>}
|
|
87
|
+
* @example
|
|
88
|
+
* // respond to autocomplete interaction
|
|
89
|
+
* interaction.respond([
|
|
90
|
+
* {
|
|
91
|
+
* name: 'Option 1',
|
|
92
|
+
* value: 'option1',
|
|
93
|
+
* },
|
|
94
|
+
* ])
|
|
95
|
+
* .then(() => console.log('Successfully responded to the autocomplete interaction'))
|
|
96
|
+
* .catch(console.error);
|
|
97
|
+
*/
|
|
98
|
+
async respond(options) {
|
|
99
|
+
if (this.responded) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
|
100
|
+
|
|
101
|
+
await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
|
|
102
|
+
body: {
|
|
103
|
+
type: InteractionResponseType.ApplicationCommandAutocompleteResult,
|
|
104
|
+
data: {
|
|
105
|
+
choices: options.map(({ nameLocalizations, ...option }) => ({
|
|
106
|
+
...this.client.options.jsonTransformer(option),
|
|
107
|
+
name_localizations: nameLocalizations,
|
|
108
|
+
})),
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
auth: false,
|
|
112
|
+
});
|
|
113
|
+
this.responded = true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
import { flatten } from '../util/Util.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Represents a data model that is identifiable by a Snowflake (i.e. Discord API data models).
|
|
6
|
+
*
|
|
7
|
+
* @abstract
|
|
8
|
+
*/
|
|
9
|
+
export abstract class Base {
|
|
10
|
+
public client: any;
|
|
11
|
+
|
|
12
|
+
constructor(client: any) {
|
|
13
|
+
this.client = client;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
_clone(): any {
|
|
17
|
+
return Object.assign(Object.create(this), this);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
_patch(data: any): any {
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
_update(data: any): any {
|
|
25
|
+
const clone = this._clone();
|
|
26
|
+
this._patch(data);
|
|
27
|
+
return clone;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
toJSON(...props: any[]): any {
|
|
31
|
+
return flatten(this, ...props);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
valueOf(): any {
|
|
35
|
+
return (this as any).id;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { channelLink, channelMention } from '@ovencord/formatters';
|
|
2
|
+
import { DiscordSnowflake } from '@sapphire/snowflake';
|
|
3
|
+
import { ChannelType, Routes } from 'discord-api-types/v10';
|
|
4
|
+
import { ChannelFlagsBitField } from '../util/ChannelFlagsBitField.js';
|
|
5
|
+
import { ThreadChannelTypes } from '../util/Constants.js';
|
|
6
|
+
import { Base } from './Base.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Represents any channel on Discord.
|
|
10
|
+
*
|
|
11
|
+
* @extends {Base}
|
|
12
|
+
* @abstract
|
|
13
|
+
*/
|
|
14
|
+
export class BaseChannel extends Base {
|
|
15
|
+
public client: any;
|
|
16
|
+
public type: any;
|
|
17
|
+
public flags: any;
|
|
18
|
+
public id: any;
|
|
19
|
+
constructor(client, data, immediatePatch = true) {
|
|
20
|
+
super(client);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The type of the channel
|
|
24
|
+
*
|
|
25
|
+
* @type {ChannelType}
|
|
26
|
+
*/
|
|
27
|
+
this.type = data.type;
|
|
28
|
+
|
|
29
|
+
if (data && immediatePatch) this._patch(data);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
_patch(data) {
|
|
33
|
+
if ('flags' in data) {
|
|
34
|
+
/**
|
|
35
|
+
* The flags that are applied to the channel.
|
|
36
|
+
* <info>This is only `null` in a {@link PartialGroupDMChannel}. In all other cases, it is not `null`.</info>
|
|
37
|
+
*
|
|
38
|
+
* @type {?Readonly<ChannelFlagsBitField>}
|
|
39
|
+
*/
|
|
40
|
+
this.flags = new ChannelFlagsBitField(data.flags).freeze();
|
|
41
|
+
} else {
|
|
42
|
+
this.flags ??= new ChannelFlagsBitField().freeze();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The channel's id
|
|
47
|
+
*
|
|
48
|
+
* @type {Snowflake}
|
|
49
|
+
*/
|
|
50
|
+
this.id = data.id;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The timestamp the channel was created at
|
|
55
|
+
*
|
|
56
|
+
* @type {number}
|
|
57
|
+
* @readonly
|
|
58
|
+
*/
|
|
59
|
+
get createdTimestamp() {
|
|
60
|
+
return DiscordSnowflake.timestampFrom(this.id);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The time the channel was created at
|
|
65
|
+
*
|
|
66
|
+
* @type {Date}
|
|
67
|
+
* @readonly
|
|
68
|
+
*/
|
|
69
|
+
get createdAt() {
|
|
70
|
+
return new Date(this.createdTimestamp);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The URL to the channel
|
|
75
|
+
*
|
|
76
|
+
* @type {string}
|
|
77
|
+
* @readonly
|
|
78
|
+
*/
|
|
79
|
+
get url() {
|
|
80
|
+
return this.isDMBased() ? channelLink(this.id) : channelLink(this.id, this.guildId);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Whether this Channel is a partial
|
|
85
|
+
* <info>This is always false outside of DM channels.</info>
|
|
86
|
+
*
|
|
87
|
+
* @type {boolean}
|
|
88
|
+
* @readonly
|
|
89
|
+
*/
|
|
90
|
+
get partial() {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* When concatenated with a string, this automatically returns the channel's mention instead of the Channel object.
|
|
96
|
+
*
|
|
97
|
+
* @returns {string}
|
|
98
|
+
* @example
|
|
99
|
+
* // Logs: Hello from <#123456789012345678>!
|
|
100
|
+
* console.log(`Hello from ${channel}!`);
|
|
101
|
+
*/
|
|
102
|
+
toString() {
|
|
103
|
+
return channelMention(this.id);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Deletes this channel.
|
|
108
|
+
*
|
|
109
|
+
* @returns {Promise<BaseChannel>}
|
|
110
|
+
* @example
|
|
111
|
+
* // Delete the channel
|
|
112
|
+
* channel.delete()
|
|
113
|
+
* .then(console.log)
|
|
114
|
+
* .catch(console.error);
|
|
115
|
+
*/
|
|
116
|
+
async delete() {
|
|
117
|
+
await this.client.rest.delete(Routes.channel(this.id));
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Fetches this channel.
|
|
123
|
+
*
|
|
124
|
+
* @param {boolean} [force=true] Whether to skip the cache check and request the API
|
|
125
|
+
* @returns {Promise<BaseChannel>}
|
|
126
|
+
*/
|
|
127
|
+
async fetch(force = true) {
|
|
128
|
+
return this.client.channels.fetch(this.id, { force });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Indicates whether this channel is a {@link ThreadChannel}.
|
|
133
|
+
*
|
|
134
|
+
* @returns {boolean}
|
|
135
|
+
*/
|
|
136
|
+
isThread() {
|
|
137
|
+
return ThreadChannelTypes.includes(this.type);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Indicates whether this channel is {@link TextBasedChannels text-based}.
|
|
142
|
+
*
|
|
143
|
+
* @returns {boolean}
|
|
144
|
+
*/
|
|
145
|
+
isTextBased() {
|
|
146
|
+
return 'messages' in this;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Indicates whether this channel is DM-based (either a {@link DMChannel} or a {@link PartialGroupDMChannel}).
|
|
151
|
+
*
|
|
152
|
+
* @returns {boolean}
|
|
153
|
+
*/
|
|
154
|
+
isDMBased() {
|
|
155
|
+
return [ChannelType.DM, ChannelType.GroupDM].includes(this.type);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Indicates whether this channel is {@link BaseGuildVoiceChannel voice-based}.
|
|
160
|
+
*
|
|
161
|
+
* @returns {boolean}
|
|
162
|
+
*/
|
|
163
|
+
isVoiceBased() {
|
|
164
|
+
return 'bitrate' in this;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Indicates whether this channel is {@link ThreadOnlyChannel thread-only}.
|
|
169
|
+
*
|
|
170
|
+
* @returns {boolean}
|
|
171
|
+
*/
|
|
172
|
+
isThreadOnly() {
|
|
173
|
+
return 'availableTags' in this;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Indicates whether this channel is sendable.
|
|
178
|
+
*
|
|
179
|
+
* @returns {boolean}
|
|
180
|
+
*/
|
|
181
|
+
isSendable() {
|
|
182
|
+
return 'send' in this;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
toJSON(...props) {
|
|
186
|
+
return super.toJSON({ createdTimestamp: true }, ...props);
|
|
187
|
+
}
|
|
188
|
+
}
|