@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,526 @@
|
|
|
1
|
+
import { makeURLSearchParams } from '@ovencord/rest';
|
|
2
|
+
import { lazy } from '@ovencord/util';
|
|
3
|
+
import { DiscordSnowflake } from '@sapphire/snowflake';
|
|
4
|
+
import { Routes, WebhookType } from 'discord-api-types/v10';
|
|
5
|
+
import { DiscordjsError, ErrorCodes } from '../errors/index.js';
|
|
6
|
+
import { resolveImage } from '../util/DataResolver.js';
|
|
7
|
+
import { MessagePayload } from './MessagePayload.js';
|
|
8
|
+
|
|
9
|
+
const getMessage = lazy(() => require('./Message.js').Message);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Represents a webhook.
|
|
13
|
+
*/
|
|
14
|
+
export class Webhook {
|
|
15
|
+
public client: any;
|
|
16
|
+
public name: any;
|
|
17
|
+
public id: any;
|
|
18
|
+
public type: any;
|
|
19
|
+
public guildId: any;
|
|
20
|
+
public channelId: any;
|
|
21
|
+
public owner: any;
|
|
22
|
+
public applicationId: any;
|
|
23
|
+
public sourceGuild: any;
|
|
24
|
+
public sourceChannel: any;
|
|
25
|
+
constructor(client, data) {
|
|
26
|
+
/**
|
|
27
|
+
* The client that instantiated the webhook
|
|
28
|
+
*
|
|
29
|
+
* @name Webhook#client
|
|
30
|
+
* @type {Client}
|
|
31
|
+
* @readonly
|
|
32
|
+
*/
|
|
33
|
+
Object.defineProperty(this, 'client', { value: client });
|
|
34
|
+
this._patch(data);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
_patch(data) {
|
|
38
|
+
if ('name' in data) {
|
|
39
|
+
/**
|
|
40
|
+
* The name of the webhook
|
|
41
|
+
*
|
|
42
|
+
* @type {string}
|
|
43
|
+
*/
|
|
44
|
+
this.name = data.name;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The token for the webhook, unavailable for follower webhooks and webhooks owned by another application.
|
|
49
|
+
*
|
|
50
|
+
* @name Webhook#token
|
|
51
|
+
* @type {?string}
|
|
52
|
+
*/
|
|
53
|
+
Object.defineProperty(this, 'token', {
|
|
54
|
+
value: data.token ?? null,
|
|
55
|
+
writable: true,
|
|
56
|
+
configurable: true,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
if ('avatar' in data) {
|
|
60
|
+
/**
|
|
61
|
+
* The avatar for the webhook
|
|
62
|
+
*
|
|
63
|
+
* @type {?string}
|
|
64
|
+
*/
|
|
65
|
+
this.avatar = data.avatar;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The webhook's id
|
|
70
|
+
*
|
|
71
|
+
* @type {Snowflake}
|
|
72
|
+
*/
|
|
73
|
+
this.id = data.id;
|
|
74
|
+
|
|
75
|
+
if ('type' in data) {
|
|
76
|
+
/**
|
|
77
|
+
* The type of the webhook
|
|
78
|
+
*
|
|
79
|
+
* @type {WebhookType}
|
|
80
|
+
*/
|
|
81
|
+
this.type = data.type;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if ('guild_id' in data) {
|
|
85
|
+
/**
|
|
86
|
+
* The guild the webhook belongs to
|
|
87
|
+
*
|
|
88
|
+
* @type {Snowflake}
|
|
89
|
+
*/
|
|
90
|
+
this.guildId = data.guild_id;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if ('channel_id' in data) {
|
|
94
|
+
/**
|
|
95
|
+
* The id of the channel the webhook belongs to
|
|
96
|
+
*
|
|
97
|
+
* @type {Snowflake}
|
|
98
|
+
*/
|
|
99
|
+
this.channelId = data.channel_id;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if ('user' in data) {
|
|
103
|
+
/**
|
|
104
|
+
* The owner of the webhook
|
|
105
|
+
*
|
|
106
|
+
* @type {?User}
|
|
107
|
+
*/
|
|
108
|
+
this.owner = this.client.users._add(data.user);
|
|
109
|
+
} else {
|
|
110
|
+
this.owner ??= null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if ('application_id' in data) {
|
|
114
|
+
/**
|
|
115
|
+
* The application that created this webhook
|
|
116
|
+
*
|
|
117
|
+
* @type {?Snowflake}
|
|
118
|
+
*/
|
|
119
|
+
this.applicationId = data.application_id;
|
|
120
|
+
} else {
|
|
121
|
+
this.applicationId ??= null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if ('source_guild' in data) {
|
|
125
|
+
/**
|
|
126
|
+
* The source guild of the webhook
|
|
127
|
+
*
|
|
128
|
+
* @type {?(Guild|APIGuild)}
|
|
129
|
+
*/
|
|
130
|
+
this.sourceGuild = this.client.guilds.cache.get(data.source_guild.id) ?? data.source_guild;
|
|
131
|
+
} else {
|
|
132
|
+
this.sourceGuild ??= null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if ('source_channel' in data) {
|
|
136
|
+
/**
|
|
137
|
+
* The source channel of the webhook
|
|
138
|
+
*
|
|
139
|
+
* @type {?(AnnouncementChannel|APIChannel)}
|
|
140
|
+
*/
|
|
141
|
+
this.sourceChannel = this.client.channels.cache.get(data.source_channel?.id) ?? data.source_channel;
|
|
142
|
+
} else {
|
|
143
|
+
this.sourceChannel ??= null;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Options that can be passed into send.
|
|
149
|
+
*
|
|
150
|
+
* @typedef {BaseMessageOptionsWithPoll} WebhookMessageCreateOptions
|
|
151
|
+
* @property {boolean} [tts=false] Whether the message should be spoken aloud
|
|
152
|
+
* @property {MessageFlags} [flags] Which flags to set for the message.
|
|
153
|
+
* <info>Only {@link MessageFlags.SuppressEmbeds} and {@link MessageFlags.IsVoiceMessage} can be set.</info>
|
|
154
|
+
* @property {string} [username=this.name] Username override for the message
|
|
155
|
+
* @property {string} [avatarURL] Avatar URL override for the message
|
|
156
|
+
* @property {Snowflake} [threadId] The id of the thread in the channel to send to.
|
|
157
|
+
* <info>For interaction webhooks, this property is ignored</info>
|
|
158
|
+
* @property {string} [threadName] Name of the thread to create (only available if the webhook is in a forum channel)
|
|
159
|
+
* @property {Snowflake[]} [appliedTags]
|
|
160
|
+
* The tags to apply to the created thread (only available if the webhook is in a forum channel)
|
|
161
|
+
* @property {boolean} [withComponents] Whether to allow sending non-interactive components in the message.
|
|
162
|
+
* <info>For application-owned webhooks, this property is ignored</info>
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Options that can be passed into editMessage.
|
|
167
|
+
*
|
|
168
|
+
* @typedef {MessageEditOptions} WebhookMessageEditOptions
|
|
169
|
+
* @property {Snowflake} [threadId] The id of the thread this message belongs to
|
|
170
|
+
* <info>For interaction webhooks, this property is ignored</info>
|
|
171
|
+
* @property {boolean} [withComponents] Whether to allow sending non-interactive components in the message.
|
|
172
|
+
* <info>For application-owned webhooks, this property is ignored</info>
|
|
173
|
+
*/
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* The channel the webhook belongs to
|
|
177
|
+
*
|
|
178
|
+
* @type {?(TextChannel|VoiceChannel|StageChannel|AnnouncementChannel|ForumChannel|MediaChannel)}
|
|
179
|
+
* @readonly
|
|
180
|
+
*/
|
|
181
|
+
get channel() {
|
|
182
|
+
return this.client.channels.resolve(this.channelId);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Sends a message with this webhook.
|
|
187
|
+
*
|
|
188
|
+
* @param {string|MessagePayload|WebhookMessageCreateOptions} options The options to provide
|
|
189
|
+
* @returns {Promise<Message>}
|
|
190
|
+
* @example
|
|
191
|
+
* // Send a basic message
|
|
192
|
+
* webhook.send('hello!')
|
|
193
|
+
* .then(message => console.log(`Sent message: ${message.content}`))
|
|
194
|
+
* .catch(console.error);
|
|
195
|
+
* @example
|
|
196
|
+
* // Send a basic message in a thread
|
|
197
|
+
* webhook.send({ content: 'hello!', threadId: '836856309672348295' })
|
|
198
|
+
* .then(message => console.log(`Sent message: ${message.content}`))
|
|
199
|
+
* .catch(console.error);
|
|
200
|
+
* @example
|
|
201
|
+
* // Send a remote file
|
|
202
|
+
* webhook.send({
|
|
203
|
+
* files: ['https://github.com/discordjs.png']
|
|
204
|
+
* })
|
|
205
|
+
* .then(console.log)
|
|
206
|
+
* .catch(console.error);
|
|
207
|
+
* @example
|
|
208
|
+
* // Send a local file
|
|
209
|
+
* webhook.send({
|
|
210
|
+
* files: [{
|
|
211
|
+
* attachment: 'entire/path/to/file.jpg',
|
|
212
|
+
* name: 'file.jpg'
|
|
213
|
+
* }]
|
|
214
|
+
* })
|
|
215
|
+
* .then(console.log)
|
|
216
|
+
* .catch(console.error);
|
|
217
|
+
* @example
|
|
218
|
+
* // Send an embed with a local image inside
|
|
219
|
+
* webhook.send({
|
|
220
|
+
* content: 'This is an embed',
|
|
221
|
+
* embeds: [{
|
|
222
|
+
* thumbnail: {
|
|
223
|
+
* url: 'attachment://file.jpg'
|
|
224
|
+
* }
|
|
225
|
+
* }],
|
|
226
|
+
* files: [{
|
|
227
|
+
* attachment: 'entire/path/to/file.jpg',
|
|
228
|
+
* name: 'file.jpg'
|
|
229
|
+
* }]
|
|
230
|
+
* })
|
|
231
|
+
* .then(console.log)
|
|
232
|
+
* .catch(console.error);
|
|
233
|
+
*/
|
|
234
|
+
async send(options) {
|
|
235
|
+
if (!this.token) throw new DiscordjsError(ErrorCodes.WebhookTokenUnavailable);
|
|
236
|
+
|
|
237
|
+
let messagePayload;
|
|
238
|
+
|
|
239
|
+
if (options instanceof MessagePayload) {
|
|
240
|
+
messagePayload = options.resolveBody();
|
|
241
|
+
} else {
|
|
242
|
+
messagePayload = MessagePayload.create(this, options).resolveBody();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const query = makeURLSearchParams({
|
|
246
|
+
wait: true,
|
|
247
|
+
thread_id: messagePayload.options.threadId,
|
|
248
|
+
with_components: messagePayload.options.withComponents,
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
const { body, files } = await messagePayload.resolveFiles();
|
|
252
|
+
const data = await this.client.rest.post(Routes.webhook(this.id, this.token), {
|
|
253
|
+
body,
|
|
254
|
+
files,
|
|
255
|
+
query,
|
|
256
|
+
auth: false,
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
return (
|
|
260
|
+
this.client.channels.cache.get(data.channel_id)?.messages._add(data, false) ??
|
|
261
|
+
new (getMessage())(this.client, data)
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Sends a raw slack message with this webhook.
|
|
267
|
+
*
|
|
268
|
+
* @param {Object} body The raw body to send
|
|
269
|
+
* @returns {Promise<boolean>}
|
|
270
|
+
* @example
|
|
271
|
+
* // Send a slack message
|
|
272
|
+
* webhook.sendSlackMessage({
|
|
273
|
+
* 'username': 'Wumpus',
|
|
274
|
+
* 'attachments': [{
|
|
275
|
+
* 'pretext': 'this looks pretty cool',
|
|
276
|
+
* 'color': '#F0F',
|
|
277
|
+
* 'footer_icon': 'http://snek.s3.amazonaws.com/topSnek.png',
|
|
278
|
+
* 'footer': 'Powered by sneks',
|
|
279
|
+
* 'ts': Date.now() / 1_000
|
|
280
|
+
* }]
|
|
281
|
+
* }).catch(console.error);
|
|
282
|
+
* @see {@link https://api.slack.com/messaging/webhooks}
|
|
283
|
+
*/
|
|
284
|
+
async sendSlackMessage(body) {
|
|
285
|
+
if (!this.token) throw new DiscordjsError(ErrorCodes.WebhookTokenUnavailable);
|
|
286
|
+
|
|
287
|
+
const data = await this.client.rest.post(Routes.webhookPlatform(this.id, this.token, 'slack'), {
|
|
288
|
+
query: makeURLSearchParams({ wait: true }),
|
|
289
|
+
auth: false,
|
|
290
|
+
body,
|
|
291
|
+
});
|
|
292
|
+
return data.toString() === 'ok';
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Options used to edit a {@link Webhook}.
|
|
297
|
+
*
|
|
298
|
+
* @typedef {Object} WebhookEditOptions
|
|
299
|
+
* @property {string} [name=this.name] The new name for the webhook
|
|
300
|
+
* @property {?(BufferResolvable)} [avatar] The new avatar for the webhook
|
|
301
|
+
* @property {GuildTextChannelResolvable|VoiceChannel|StageChannel|ForumChannel|MediaChannel} [channel]
|
|
302
|
+
* The new channel for the webhook
|
|
303
|
+
* @property {string} [reason] Reason for editing the webhook
|
|
304
|
+
*/
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Edits this webhook.
|
|
308
|
+
*
|
|
309
|
+
* @param {WebhookEditOptions} options Options for editing the webhook
|
|
310
|
+
* @returns {Promise<Webhook>}
|
|
311
|
+
*/
|
|
312
|
+
async edit({ name = this.name, avatar: newAvatar, channel: newChannel, reason }) {
|
|
313
|
+
let avatar = newAvatar;
|
|
314
|
+
if (avatar && !(typeof avatar === 'string' && avatar.startsWith('data:'))) {
|
|
315
|
+
avatar = await resolveImage(avatar);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const channel = newChannel?.id ?? newChannel;
|
|
319
|
+
const data = await this.client.rest.patch(Routes.webhook(this.id, channel ? undefined : this.token), {
|
|
320
|
+
body: { name, avatar, channel_id: channel },
|
|
321
|
+
reason,
|
|
322
|
+
auth: !this.token || Boolean(channel),
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
this.name = data.name;
|
|
326
|
+
this.avatar = data.avatar;
|
|
327
|
+
this.channelId = data.channel_id;
|
|
328
|
+
return this;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Options that can be passed into fetchMessage.
|
|
333
|
+
*
|
|
334
|
+
* @typedef {options} WebhookFetchMessageOptions
|
|
335
|
+
* @property {boolean} [cache=true] Whether to cache the message.
|
|
336
|
+
* @property {Snowflake} [threadId] The id of the thread this message belongs to.
|
|
337
|
+
* <info>For interaction webhooks, this property is ignored</info>
|
|
338
|
+
*/
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Gets a message that was sent by this webhook.
|
|
342
|
+
*
|
|
343
|
+
* @param {Snowflake|'@original'} message The id of the message to fetch
|
|
344
|
+
* @param {WebhookFetchMessageOptions} [options={}] The options to provide to fetch the message.
|
|
345
|
+
* @returns {Promise<Message>} Returns the message sent by this webhook
|
|
346
|
+
*/
|
|
347
|
+
async fetchMessage(message, { threadId } = {}) {
|
|
348
|
+
if (!this.token) throw new DiscordjsError(ErrorCodes.WebhookTokenUnavailable);
|
|
349
|
+
|
|
350
|
+
const data = await this.client.rest.get(Routes.webhookMessage(this.id, this.token, message), {
|
|
351
|
+
query: threadId ? makeURLSearchParams({ thread_id: threadId }) : undefined,
|
|
352
|
+
auth: false,
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
return (
|
|
356
|
+
this.client.channels.cache.get(data.channel_id)?.messages._add(data, false) ??
|
|
357
|
+
new (getMessage())(this.client, data)
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Edits a message that was sent by this webhook.
|
|
363
|
+
*
|
|
364
|
+
* @param {MessageResolvable|'@original'} message The message to edit
|
|
365
|
+
* @param {string|MessagePayload|WebhookMessageEditOptions} options The options to provide
|
|
366
|
+
* @returns {Promise<Message>} Returns the message edited by this webhook
|
|
367
|
+
*/
|
|
368
|
+
async editMessage(message, options) {
|
|
369
|
+
if (!this.token) throw new DiscordjsError(ErrorCodes.WebhookTokenUnavailable);
|
|
370
|
+
|
|
371
|
+
let messagePayload;
|
|
372
|
+
|
|
373
|
+
if (options instanceof MessagePayload) messagePayload = options;
|
|
374
|
+
else messagePayload = MessagePayload.create(this, options);
|
|
375
|
+
|
|
376
|
+
const { body, files } = await messagePayload.resolveBody().resolveFiles();
|
|
377
|
+
|
|
378
|
+
const query = makeURLSearchParams({
|
|
379
|
+
thread_id: messagePayload.options.threadId,
|
|
380
|
+
with_components: messagePayload.options.withComponents,
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
const data = await this.client.rest.patch(
|
|
384
|
+
Routes.webhookMessage(this.id, this.token, typeof message === 'string' ? message : message.id),
|
|
385
|
+
{
|
|
386
|
+
body,
|
|
387
|
+
files,
|
|
388
|
+
query,
|
|
389
|
+
auth: false,
|
|
390
|
+
},
|
|
391
|
+
);
|
|
392
|
+
|
|
393
|
+
const messageManager = this.client.channels.cache.get(data.channel_id)?.messages;
|
|
394
|
+
if (!messageManager) return new (getMessage())(this.client, data);
|
|
395
|
+
|
|
396
|
+
const existing = messageManager.cache.get(data.id);
|
|
397
|
+
if (!existing) return messageManager._add(data);
|
|
398
|
+
|
|
399
|
+
const clone = existing._clone();
|
|
400
|
+
clone._patch(data);
|
|
401
|
+
return clone;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Deletes the webhook.
|
|
406
|
+
*
|
|
407
|
+
* @param {string} [reason] Reason for deleting this webhook
|
|
408
|
+
* @returns {Promise<void>}
|
|
409
|
+
*/
|
|
410
|
+
async delete(reason) {
|
|
411
|
+
return this.client.deleteWebhook(this.id, { token: this.token, reason });
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Delete a message that was sent by this webhook.
|
|
416
|
+
*
|
|
417
|
+
* @param {MessageResolvable|'@original'} message The message to delete
|
|
418
|
+
* @param {Snowflake} [threadId] The id of the thread this message belongs to
|
|
419
|
+
* @returns {Promise<void>}
|
|
420
|
+
*/
|
|
421
|
+
async deleteMessage(message, threadId) {
|
|
422
|
+
if (!this.token) throw new DiscordjsError(ErrorCodes.WebhookTokenUnavailable);
|
|
423
|
+
|
|
424
|
+
await this.client.rest.delete(
|
|
425
|
+
Routes.webhookMessage(this.id, this.token, typeof message === 'string' ? message : message.id),
|
|
426
|
+
{
|
|
427
|
+
query: threadId ? makeURLSearchParams({ thread_id: threadId }) : undefined,
|
|
428
|
+
auth: false,
|
|
429
|
+
},
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* The timestamp the webhook was created at
|
|
435
|
+
*
|
|
436
|
+
* @type {number}
|
|
437
|
+
* @readonly
|
|
438
|
+
*/
|
|
439
|
+
get createdTimestamp() {
|
|
440
|
+
return DiscordSnowflake.timestampFrom(this.id);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* The time the webhook was created at
|
|
445
|
+
*
|
|
446
|
+
* @type {Date}
|
|
447
|
+
* @readonly
|
|
448
|
+
*/
|
|
449
|
+
get createdAt() {
|
|
450
|
+
return new Date(this.createdTimestamp);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* The URL of this webhook
|
|
455
|
+
*
|
|
456
|
+
* @type {string}
|
|
457
|
+
* @readonly
|
|
458
|
+
*/
|
|
459
|
+
get url() {
|
|
460
|
+
return this.client.options.rest.api + Routes.webhook(this.id, this.token);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* A link to the webhook's avatar.
|
|
465
|
+
*
|
|
466
|
+
* @param {ImageURLOptions} [options={}] Options for the image URL
|
|
467
|
+
* @returns {?string}
|
|
468
|
+
*/
|
|
469
|
+
avatarURL(options = {}) {
|
|
470
|
+
return this.avatar && this.client.rest.cdn.avatar(this.id, this.avatar, options);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Whether this webhook is created by a user.
|
|
475
|
+
*
|
|
476
|
+
* @returns {boolean}
|
|
477
|
+
*/
|
|
478
|
+
isUserCreated() {
|
|
479
|
+
return Boolean(this.type === WebhookType.Incoming && this.owner && !this.owner.bot);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Whether this webhook is created by an application.
|
|
484
|
+
*
|
|
485
|
+
* @returns {boolean}
|
|
486
|
+
*/
|
|
487
|
+
isApplicationCreated() {
|
|
488
|
+
return this.type === WebhookType.Application;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Whether or not this webhook is a channel follower webhook.
|
|
493
|
+
*
|
|
494
|
+
* @returns {boolean}
|
|
495
|
+
*/
|
|
496
|
+
isChannelFollower() {
|
|
497
|
+
return this.type === WebhookType.ChannelFollower;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Whether or not this webhook is an incoming webhook.
|
|
502
|
+
*
|
|
503
|
+
* @returns {boolean}
|
|
504
|
+
*/
|
|
505
|
+
isIncoming() {
|
|
506
|
+
return this.type === WebhookType.Incoming;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
static applyToClass(structure, ignore = []) {
|
|
510
|
+
for (const prop of [
|
|
511
|
+
'send',
|
|
512
|
+
'sendSlackMessage',
|
|
513
|
+
'fetchMessage',
|
|
514
|
+
'edit',
|
|
515
|
+
'editMessage',
|
|
516
|
+
'delete',
|
|
517
|
+
'deleteMessage',
|
|
518
|
+
'createdTimestamp',
|
|
519
|
+
'createdAt',
|
|
520
|
+
'url',
|
|
521
|
+
]) {
|
|
522
|
+
if (ignore.includes(prop)) continue;
|
|
523
|
+
Object.defineProperty(structure.prototype, prop, Object.getOwnPropertyDescriptor(Webhook.prototype, prop));
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Base } from './Base.js';
|
|
2
|
+
import { Emoji } from './Emoji.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Represents a channel link in a guild's welcome screen.
|
|
6
|
+
*
|
|
7
|
+
* @extends {Base}
|
|
8
|
+
*/
|
|
9
|
+
export class WelcomeChannel extends Base {
|
|
10
|
+
public guild: any;
|
|
11
|
+
public description: any;
|
|
12
|
+
public _emoji: any;
|
|
13
|
+
public channelId: any;
|
|
14
|
+
constructor(guild, data) {
|
|
15
|
+
super(guild.client);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The guild for this welcome channel
|
|
19
|
+
*
|
|
20
|
+
* @type {Guild|InviteGuild}
|
|
21
|
+
*/
|
|
22
|
+
this.guild = guild;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The description of this welcome channel
|
|
26
|
+
*
|
|
27
|
+
* @type {string}
|
|
28
|
+
*/
|
|
29
|
+
this.description = data.description;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The raw emoji data
|
|
33
|
+
*
|
|
34
|
+
* @type {Object}
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
this._emoji = {
|
|
38
|
+
name: data.emoji_name,
|
|
39
|
+
id: data.emoji_id,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The id of this welcome channel
|
|
44
|
+
*
|
|
45
|
+
* @type {Snowflake}
|
|
46
|
+
*/
|
|
47
|
+
this.channelId = data.channel_id;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The channel of this welcome channel
|
|
52
|
+
*
|
|
53
|
+
* @type {?(TextChannel|AnnouncementChannel|ForumChannel|MediaChannel)}
|
|
54
|
+
*/
|
|
55
|
+
get channel() {
|
|
56
|
+
return this.client.channels.resolve(this.channelId);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The emoji of this welcome channel
|
|
61
|
+
*
|
|
62
|
+
* @type {GuildEmoji|Emoji}
|
|
63
|
+
*/
|
|
64
|
+
get emoji() {
|
|
65
|
+
return this.guild.emojis.cache.get(this._emoji.id) ?? new Emoji(this.client, this._emoji);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Collection } from '@ovencord/collection';
|
|
2
|
+
import { GuildFeature } from 'discord-api-types/v10';
|
|
3
|
+
import { Base } from './Base.js';
|
|
4
|
+
import { WelcomeChannel } from './WelcomeChannel.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents a welcome screen.
|
|
8
|
+
*
|
|
9
|
+
* @extends {Base}
|
|
10
|
+
*/
|
|
11
|
+
export class WelcomeScreen extends Base {
|
|
12
|
+
public guild: any;
|
|
13
|
+
public description: any;
|
|
14
|
+
public welcomeChannels: any;
|
|
15
|
+
constructor(guild, data) {
|
|
16
|
+
super(guild.client);
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The guild for this welcome screen
|
|
20
|
+
*
|
|
21
|
+
* @type {Guild}
|
|
22
|
+
*/
|
|
23
|
+
this.guild = guild;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The description of this welcome screen
|
|
27
|
+
*
|
|
28
|
+
* @type {?string}
|
|
29
|
+
*/
|
|
30
|
+
this.description = data.description ?? null;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Collection of welcome channels belonging to this welcome screen
|
|
34
|
+
*
|
|
35
|
+
* @type {Collection<Snowflake, WelcomeChannel>}
|
|
36
|
+
*/
|
|
37
|
+
this.welcomeChannels = new Collection();
|
|
38
|
+
|
|
39
|
+
for (const channel of data.welcome_channels) {
|
|
40
|
+
const welcomeChannel = new WelcomeChannel(this.guild, channel);
|
|
41
|
+
this.welcomeChannels.set(welcomeChannel.channelId, welcomeChannel);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Whether the welcome screen is enabled on the guild
|
|
47
|
+
*
|
|
48
|
+
* @type {boolean}
|
|
49
|
+
*/
|
|
50
|
+
get enabled() {
|
|
51
|
+
return this.guild.features.includes(GuildFeature.WelcomeScreenEnabled);
|
|
52
|
+
}
|
|
53
|
+
}
|