@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,229 @@
|
|
|
1
|
+
import { RouteBases, Routes } from 'discord-api-types/v10';
|
|
2
|
+
import { Base } from './Base.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Represents the template for a guild.
|
|
6
|
+
*
|
|
7
|
+
* @extends {Base}
|
|
8
|
+
*/
|
|
9
|
+
export class GuildTemplate extends Base {
|
|
10
|
+
public client: any;
|
|
11
|
+
public code: any;
|
|
12
|
+
public name: any;
|
|
13
|
+
public description: any;
|
|
14
|
+
public usageCount: any;
|
|
15
|
+
public creatorId: any;
|
|
16
|
+
public creator: any;
|
|
17
|
+
public createdTimestamp: any;
|
|
18
|
+
public updatedTimestamp: any;
|
|
19
|
+
public guildId: any;
|
|
20
|
+
public serializedGuild: any;
|
|
21
|
+
public unSynced: any;
|
|
22
|
+
/**
|
|
23
|
+
* A regular expression that matches guild template links.
|
|
24
|
+
* The `code` group property is present on the `exec()` result of this expression.
|
|
25
|
+
*
|
|
26
|
+
* @type {RegExp}
|
|
27
|
+
* @memberof GuildTemplate
|
|
28
|
+
*/
|
|
29
|
+
static GuildTemplatesPattern = /discord(?:app)?\.(?:com\/template|new)\/(?<code>[\w-]{2,255})/i;
|
|
30
|
+
|
|
31
|
+
constructor(client, data) {
|
|
32
|
+
super(client);
|
|
33
|
+
this._patch(data);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
_patch(data) {
|
|
37
|
+
if ('code' in data) {
|
|
38
|
+
/**
|
|
39
|
+
* The unique code of this template
|
|
40
|
+
*
|
|
41
|
+
* @type {string}
|
|
42
|
+
*/
|
|
43
|
+
this.code = data.code;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if ('name' in data) {
|
|
47
|
+
/**
|
|
48
|
+
* The name of this template
|
|
49
|
+
*
|
|
50
|
+
* @type {string}
|
|
51
|
+
*/
|
|
52
|
+
this.name = data.name;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if ('description' in data) {
|
|
56
|
+
/**
|
|
57
|
+
* The description of this template
|
|
58
|
+
*
|
|
59
|
+
* @type {?string}
|
|
60
|
+
*/
|
|
61
|
+
this.description = data.description;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if ('usage_count' in data) {
|
|
65
|
+
/**
|
|
66
|
+
* The amount of times this template has been used
|
|
67
|
+
*
|
|
68
|
+
* @type {number}
|
|
69
|
+
*/
|
|
70
|
+
this.usageCount = data.usage_count;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if ('creator_id' in data) {
|
|
74
|
+
/**
|
|
75
|
+
* The id of the user that created this template
|
|
76
|
+
*
|
|
77
|
+
* @type {Snowflake}
|
|
78
|
+
*/
|
|
79
|
+
this.creatorId = data.creator_id;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if ('creator' in data) {
|
|
83
|
+
/**
|
|
84
|
+
* The user that created this template
|
|
85
|
+
*
|
|
86
|
+
* @type {User}
|
|
87
|
+
*/
|
|
88
|
+
this.creator = this.client.users._add(data.creator);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if ('created_at' in data) {
|
|
92
|
+
/**
|
|
93
|
+
* The timestamp of when this template was created at
|
|
94
|
+
*
|
|
95
|
+
* @type {number}
|
|
96
|
+
*/
|
|
97
|
+
this.createdTimestamp = Date.parse(data.created_at);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if ('updated_at' in data) {
|
|
101
|
+
/**
|
|
102
|
+
* The timestamp of when this template was last synced to the guild
|
|
103
|
+
*
|
|
104
|
+
* @type {number}
|
|
105
|
+
*/
|
|
106
|
+
this.updatedTimestamp = Date.parse(data.updated_at);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if ('source_guild_id' in data) {
|
|
110
|
+
/**
|
|
111
|
+
* The id of the guild that this template belongs to
|
|
112
|
+
*
|
|
113
|
+
* @type {Snowflake}
|
|
114
|
+
*/
|
|
115
|
+
this.guildId = data.source_guild_id;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if ('serialized_source_guild' in data) {
|
|
119
|
+
/**
|
|
120
|
+
* The data of the guild that this template would create
|
|
121
|
+
*
|
|
122
|
+
* @type {APIGuild}
|
|
123
|
+
*/
|
|
124
|
+
this.serializedGuild = data.serialized_source_guild;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Whether this template has unsynced changes
|
|
129
|
+
*
|
|
130
|
+
* @type {?boolean}
|
|
131
|
+
*/
|
|
132
|
+
this.unSynced = 'is_dirty' in data ? Boolean(data.is_dirty) : null;
|
|
133
|
+
|
|
134
|
+
return this;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Options used to edit a guild template.
|
|
139
|
+
*
|
|
140
|
+
* @typedef {Object} GuildTemplateEditOptions
|
|
141
|
+
* @property {string} [name] The name of this template
|
|
142
|
+
* @property {string} [description] The description of this template
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Updates the metadata of this template.
|
|
147
|
+
*
|
|
148
|
+
* @param {GuildTemplateEditOptions} [options] Options for editing the template
|
|
149
|
+
* @returns {Promise<GuildTemplate>}
|
|
150
|
+
*/
|
|
151
|
+
async edit({ name, description } = {}) {
|
|
152
|
+
const data = await this.client.rest.patch(Routes.guildTemplate(this.guildId, this.code), {
|
|
153
|
+
body: { name, description },
|
|
154
|
+
});
|
|
155
|
+
return this._patch(data);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Deletes this template.
|
|
160
|
+
*
|
|
161
|
+
* @returns {Promise<GuildTemplate>}
|
|
162
|
+
*/
|
|
163
|
+
async delete() {
|
|
164
|
+
await this.client.rest.delete(Routes.guildTemplate(this.guildId, this.code));
|
|
165
|
+
return this;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Syncs this template to the current state of the guild.
|
|
170
|
+
*
|
|
171
|
+
* @returns {Promise<GuildTemplate>}
|
|
172
|
+
*/
|
|
173
|
+
async sync() {
|
|
174
|
+
const data = await this.client.rest.put(Routes.guildTemplate(this.guildId, this.code));
|
|
175
|
+
return this._patch(data);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* The time when this template was created at
|
|
180
|
+
*
|
|
181
|
+
* @type {Date}
|
|
182
|
+
* @readonly
|
|
183
|
+
*/
|
|
184
|
+
get createdAt() {
|
|
185
|
+
return new Date(this.createdTimestamp);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* The time when this template was last synced to the guild
|
|
190
|
+
*
|
|
191
|
+
* @type {Date}
|
|
192
|
+
* @readonly
|
|
193
|
+
*/
|
|
194
|
+
get updatedAt() {
|
|
195
|
+
return new Date(this.updatedTimestamp);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* The guild that this template belongs to
|
|
200
|
+
*
|
|
201
|
+
* @type {?Guild}
|
|
202
|
+
* @readonly
|
|
203
|
+
*/
|
|
204
|
+
get guild() {
|
|
205
|
+
return this.client.guilds.resolve(this.guildId);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* The URL of this template
|
|
210
|
+
*
|
|
211
|
+
* @type {string}
|
|
212
|
+
* @readonly
|
|
213
|
+
*/
|
|
214
|
+
get url() {
|
|
215
|
+
return `${RouteBases.template}/${this.code}`;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* When concatenated with a string, this automatically returns the template's code instead of the template object.
|
|
220
|
+
*
|
|
221
|
+
* @returns {string}
|
|
222
|
+
* @example
|
|
223
|
+
* // Logs: Template: FKvmczH2HyUf
|
|
224
|
+
* console.log(`Template: ${guildTemplate}!`);
|
|
225
|
+
*/
|
|
226
|
+
toString() {
|
|
227
|
+
return this.code;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { Routes } from 'discord-api-types/v10';
|
|
2
|
+
import { Base } from './Base.js';
|
|
3
|
+
import { IntegrationApplication } from './IntegrationApplication.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The information account for an integration
|
|
7
|
+
*
|
|
8
|
+
* @typedef {Object} IntegrationAccount
|
|
9
|
+
* @property {Snowflake|string} id The id of the account
|
|
10
|
+
* @property {string} name The name of the account
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The type of an {@link Integration}. This can be:
|
|
15
|
+
* - `twitch`
|
|
16
|
+
* - `youtube`
|
|
17
|
+
* - `discord`
|
|
18
|
+
* - `guild_subscription`
|
|
19
|
+
*
|
|
20
|
+
* @typedef {string} IntegrationType
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Represents a guild integration.
|
|
25
|
+
*
|
|
26
|
+
* @extends {Base}
|
|
27
|
+
*/
|
|
28
|
+
export class Integration extends Base {
|
|
29
|
+
public client: any;
|
|
30
|
+
public guild: any;
|
|
31
|
+
public id: any;
|
|
32
|
+
public name: any;
|
|
33
|
+
public type: any;
|
|
34
|
+
public enabled: any;
|
|
35
|
+
public syncing: any;
|
|
36
|
+
public role: any;
|
|
37
|
+
public enableEmoticons: any;
|
|
38
|
+
public user: any;
|
|
39
|
+
public account: any;
|
|
40
|
+
public syncedTimestamp: any;
|
|
41
|
+
public subscriberCount: any;
|
|
42
|
+
public revoked: any;
|
|
43
|
+
public expireBehavior: any;
|
|
44
|
+
public expireGracePeriod: any;
|
|
45
|
+
public application: any;
|
|
46
|
+
public scopes: any;
|
|
47
|
+
constructor(client, data, guild) {
|
|
48
|
+
super(client);
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The guild this integration belongs to
|
|
52
|
+
*
|
|
53
|
+
* @type {Guild}
|
|
54
|
+
*/
|
|
55
|
+
this.guild = guild;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The integration id
|
|
59
|
+
*
|
|
60
|
+
* @type {Snowflake|string}
|
|
61
|
+
*/
|
|
62
|
+
this.id = data.id;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The integration name
|
|
66
|
+
*
|
|
67
|
+
* @type {string}
|
|
68
|
+
*/
|
|
69
|
+
this.name = data.name;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The integration type
|
|
73
|
+
*
|
|
74
|
+
* @type {IntegrationType}
|
|
75
|
+
*/
|
|
76
|
+
this.type = data.type;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Whether this integration is enabled
|
|
80
|
+
*
|
|
81
|
+
* @type {?boolean}
|
|
82
|
+
*/
|
|
83
|
+
this.enabled = data.enabled ?? null;
|
|
84
|
+
|
|
85
|
+
if ('syncing' in data) {
|
|
86
|
+
/**
|
|
87
|
+
* Whether this integration is syncing
|
|
88
|
+
*
|
|
89
|
+
* @type {?boolean}
|
|
90
|
+
*/
|
|
91
|
+
this.syncing = data.syncing;
|
|
92
|
+
} else {
|
|
93
|
+
this.syncing ??= null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The role that this integration uses for subscribers
|
|
98
|
+
*
|
|
99
|
+
* @type {?Role}
|
|
100
|
+
*/
|
|
101
|
+
this.role = this.guild.roles.resolve(data.role_id);
|
|
102
|
+
|
|
103
|
+
if ('enable_emoticons' in data) {
|
|
104
|
+
/**
|
|
105
|
+
* Whether emoticons should be synced for this integration (twitch only currently)
|
|
106
|
+
*
|
|
107
|
+
* @type {?boolean}
|
|
108
|
+
*/
|
|
109
|
+
this.enableEmoticons = data.enable_emoticons;
|
|
110
|
+
} else {
|
|
111
|
+
this.enableEmoticons ??= null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (data.user) {
|
|
115
|
+
/**
|
|
116
|
+
* The user for this integration
|
|
117
|
+
*
|
|
118
|
+
* @type {?User}
|
|
119
|
+
*/
|
|
120
|
+
this.user = this.client.users._add(data.user);
|
|
121
|
+
} else {
|
|
122
|
+
this.user ??= null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The account integration information
|
|
127
|
+
*
|
|
128
|
+
* @type {IntegrationAccount}
|
|
129
|
+
*/
|
|
130
|
+
this.account = data.account;
|
|
131
|
+
|
|
132
|
+
if ('synced_at' in data) {
|
|
133
|
+
/**
|
|
134
|
+
* The timestamp at which this integration was last synced at
|
|
135
|
+
*
|
|
136
|
+
* @type {?number}
|
|
137
|
+
*/
|
|
138
|
+
this.syncedTimestamp = Date.parse(data.synced_at);
|
|
139
|
+
} else {
|
|
140
|
+
this.syncedTimestamp ??= null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if ('subscriber_count' in data) {
|
|
144
|
+
/**
|
|
145
|
+
* How many subscribers this integration has
|
|
146
|
+
*
|
|
147
|
+
* @type {?number}
|
|
148
|
+
*/
|
|
149
|
+
this.subscriberCount = data.subscriber_count;
|
|
150
|
+
} else {
|
|
151
|
+
this.subscriberCount ??= null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if ('revoked' in data) {
|
|
155
|
+
/**
|
|
156
|
+
* Whether this integration has been revoked
|
|
157
|
+
*
|
|
158
|
+
* @type {?boolean}
|
|
159
|
+
*/
|
|
160
|
+
this.revoked = data.revoked;
|
|
161
|
+
} else {
|
|
162
|
+
this.revoked ??= null;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
this._patch(data);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* The date at which this integration was last synced at
|
|
170
|
+
*
|
|
171
|
+
* @type {?Date}
|
|
172
|
+
* @readonly
|
|
173
|
+
*/
|
|
174
|
+
get syncedAt() {
|
|
175
|
+
return this.syncedTimestamp && new Date(this.syncedTimestamp);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* All roles that are managed by this integration
|
|
180
|
+
*
|
|
181
|
+
* @type {Collection<Snowflake, Role>}
|
|
182
|
+
* @readonly
|
|
183
|
+
*/
|
|
184
|
+
get roles() {
|
|
185
|
+
const roles = this.guild.roles.cache;
|
|
186
|
+
return roles.filter(role => role.tags?.integrationId === this.id);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
_patch(data) {
|
|
190
|
+
if ('expire_behavior' in data) {
|
|
191
|
+
/**
|
|
192
|
+
* The behavior of expiring subscribers
|
|
193
|
+
*
|
|
194
|
+
* @type {?IntegrationExpireBehavior}
|
|
195
|
+
*/
|
|
196
|
+
this.expireBehavior = data.expire_behavior;
|
|
197
|
+
} else {
|
|
198
|
+
this.expireBehavior ??= null;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if ('expire_grace_period' in data) {
|
|
202
|
+
/**
|
|
203
|
+
* The grace period (in days) before expiring subscribers
|
|
204
|
+
*
|
|
205
|
+
* @type {?number}
|
|
206
|
+
*/
|
|
207
|
+
this.expireGracePeriod = data.expire_grace_period;
|
|
208
|
+
} else {
|
|
209
|
+
this.expireGracePeriod ??= null;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if ('application' in data) {
|
|
213
|
+
if (this.application) {
|
|
214
|
+
this.application._patch(data.application);
|
|
215
|
+
} else {
|
|
216
|
+
/**
|
|
217
|
+
* The application for this integration
|
|
218
|
+
*
|
|
219
|
+
* @type {?IntegrationApplication}
|
|
220
|
+
*/
|
|
221
|
+
this.application = new IntegrationApplication(this.client, data.application);
|
|
222
|
+
}
|
|
223
|
+
} else {
|
|
224
|
+
this.application ??= null;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if ('scopes' in data) {
|
|
228
|
+
/**
|
|
229
|
+
* The scopes this application has been authorized for
|
|
230
|
+
*
|
|
231
|
+
* @type {OAuth2Scopes[]}
|
|
232
|
+
*/
|
|
233
|
+
this.scopes = data.scopes;
|
|
234
|
+
} else {
|
|
235
|
+
this.scopes ??= [];
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Deletes this integration.
|
|
241
|
+
*
|
|
242
|
+
* @returns {Promise<Integration>}
|
|
243
|
+
* @param {string} [reason] Reason for deleting this integration
|
|
244
|
+
*/
|
|
245
|
+
async delete(reason) {
|
|
246
|
+
await this.client.rest.delete(Routes.guildIntegration(this.guild.id, this.id), { reason });
|
|
247
|
+
return this;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
toJSON() {
|
|
251
|
+
return super.toJSON({
|
|
252
|
+
role: 'roleId',
|
|
253
|
+
guild: 'guildId',
|
|
254
|
+
user: 'userId',
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Application } from './interfaces/Application.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents an Integration's OAuth2 Application.
|
|
5
|
+
*
|
|
6
|
+
* @extends {Application}
|
|
7
|
+
*/
|
|
8
|
+
export class IntegrationApplication extends Application {
|
|
9
|
+
public bot: any;
|
|
10
|
+
public termsOfServiceURL: any;
|
|
11
|
+
public privacyPolicyURL: any;
|
|
12
|
+
public rpcOrigins: any;
|
|
13
|
+
public cover: any;
|
|
14
|
+
public verifyKey: any;
|
|
15
|
+
_patch(data) {
|
|
16
|
+
super._patch(data);
|
|
17
|
+
|
|
18
|
+
if ('bot' in data) {
|
|
19
|
+
/**
|
|
20
|
+
* The bot user for this application
|
|
21
|
+
*
|
|
22
|
+
* @type {?User}
|
|
23
|
+
*/
|
|
24
|
+
this.bot = this.client.users._add(data.bot);
|
|
25
|
+
} else {
|
|
26
|
+
this.bot ??= null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if ('terms_of_service_url' in data) {
|
|
30
|
+
/**
|
|
31
|
+
* The URL of the application's terms of service
|
|
32
|
+
*
|
|
33
|
+
* @type {?string}
|
|
34
|
+
*/
|
|
35
|
+
this.termsOfServiceURL = data.terms_of_service_url;
|
|
36
|
+
} else {
|
|
37
|
+
this.termsOfServiceURL ??= null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if ('privacy_policy_url' in data) {
|
|
41
|
+
/**
|
|
42
|
+
* The URL of the application's privacy policy
|
|
43
|
+
*
|
|
44
|
+
* @type {?string}
|
|
45
|
+
*/
|
|
46
|
+
this.privacyPolicyURL = data.privacy_policy_url;
|
|
47
|
+
} else {
|
|
48
|
+
this.privacyPolicyURL ??= null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if ('rpc_origins' in data) {
|
|
52
|
+
/**
|
|
53
|
+
* The Array of RPC origin URLs
|
|
54
|
+
*
|
|
55
|
+
* @type {string[]}
|
|
56
|
+
*/
|
|
57
|
+
this.rpcOrigins = data.rpc_origins;
|
|
58
|
+
} else {
|
|
59
|
+
this.rpcOrigins ??= [];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if ('cover_image' in data) {
|
|
63
|
+
/**
|
|
64
|
+
* The hash of the application's cover image
|
|
65
|
+
*
|
|
66
|
+
* @type {?string}
|
|
67
|
+
*/
|
|
68
|
+
this.cover = data.cover_image;
|
|
69
|
+
} else {
|
|
70
|
+
this.cover ??= null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if ('verify_key' in data) {
|
|
74
|
+
/**
|
|
75
|
+
* The hex-encoded key for verification in interactions and the GameSDK's GetTicket
|
|
76
|
+
*
|
|
77
|
+
* @type {?string}
|
|
78
|
+
*/
|
|
79
|
+
this.verifyKey = data.verify_key;
|
|
80
|
+
} else {
|
|
81
|
+
this.verifyKey ??= null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { DiscordSnowflake } from '@sapphire/snowflake';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents an interaction callback response from Discord
|
|
5
|
+
*/
|
|
6
|
+
export class InteractionCallback {
|
|
7
|
+
public client: any;
|
|
8
|
+
public id: any;
|
|
9
|
+
public type: any;
|
|
10
|
+
public activityInstanceId: any;
|
|
11
|
+
public responseMessageId: any;
|
|
12
|
+
public responseMessageLoading: any;
|
|
13
|
+
public responseMessageEphemeral: any;
|
|
14
|
+
constructor(client, data) {
|
|
15
|
+
/**
|
|
16
|
+
* The client that instantiated this.
|
|
17
|
+
*
|
|
18
|
+
* @name InteractionCallback#client
|
|
19
|
+
* @type {Client}
|
|
20
|
+
* @readonly
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(this, 'client', { value: client });
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The id of the original interaction response
|
|
26
|
+
*
|
|
27
|
+
* @type {Snowflake}
|
|
28
|
+
*/
|
|
29
|
+
this.id = data.id;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The type of the original interaction
|
|
33
|
+
*
|
|
34
|
+
* @type {InteractionType}
|
|
35
|
+
*/
|
|
36
|
+
this.type = data.type;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The instance id of the Activity if one was launched or joined
|
|
40
|
+
*
|
|
41
|
+
* @type {?string}
|
|
42
|
+
*/
|
|
43
|
+
this.activityInstanceId = data.activity_instance_id ?? null;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The id of the message that was created by the interaction
|
|
47
|
+
*
|
|
48
|
+
* @type {?Snowflake}
|
|
49
|
+
*/
|
|
50
|
+
this.responseMessageId = data.response_message_id ?? null;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Whether the message is in a loading state
|
|
54
|
+
*
|
|
55
|
+
* @type {?boolean}
|
|
56
|
+
*/
|
|
57
|
+
this.responseMessageLoading = data.response_message_loading ?? null;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Whether the response message was ephemeral
|
|
61
|
+
*
|
|
62
|
+
* @type {?boolean}
|
|
63
|
+
*/
|
|
64
|
+
this.responseMessageEphemeral = data.response_message_ephemeral ?? null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The timestamp the original interaction was created at
|
|
69
|
+
*
|
|
70
|
+
* @type {number}
|
|
71
|
+
* @readonly
|
|
72
|
+
*/
|
|
73
|
+
get createdTimestamp() {
|
|
74
|
+
return DiscordSnowflake.timestampFrom(this.id);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The time the original interaction was created at
|
|
79
|
+
*
|
|
80
|
+
* @type {Date}
|
|
81
|
+
* @readonly
|
|
82
|
+
*/
|
|
83
|
+
get createdAt() {
|
|
84
|
+
return new Date(this.createdTimestamp);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { lazy } from '@ovencord/util';
|
|
2
|
+
|
|
3
|
+
const getMessage = lazy(() => require('./Message.js').Message);
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents the resource that was created by the interaction response.
|
|
7
|
+
*/
|
|
8
|
+
export class InteractionCallbackResource {
|
|
9
|
+
public client: any;
|
|
10
|
+
public type: any;
|
|
11
|
+
public activityInstance: any;
|
|
12
|
+
public message: any;
|
|
13
|
+
constructor(client, data) {
|
|
14
|
+
/**
|
|
15
|
+
* The client that instantiated this
|
|
16
|
+
*
|
|
17
|
+
* @name InteractionCallbackResource#client
|
|
18
|
+
* @type {Client}
|
|
19
|
+
* @readonly
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(this, 'client', { value: client });
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The interaction callback type
|
|
25
|
+
*
|
|
26
|
+
* @type {InteractionResponseType}
|
|
27
|
+
*/
|
|
28
|
+
this.type = data.type;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The Activity launched by an interaction
|
|
32
|
+
*
|
|
33
|
+
* @typedef {Object} ActivityInstance
|
|
34
|
+
* @property {string} id The instance id of the Activity
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Represents the Activity launched by this interaction
|
|
39
|
+
*
|
|
40
|
+
* @type {?ActivityInstance}
|
|
41
|
+
*/
|
|
42
|
+
this.activityInstance = data.activity_instance ?? null;
|
|
43
|
+
|
|
44
|
+
if ('message' in data) {
|
|
45
|
+
/**
|
|
46
|
+
* The message created by the interaction
|
|
47
|
+
*
|
|
48
|
+
* @type {?Message}
|
|
49
|
+
*/
|
|
50
|
+
this.message =
|
|
51
|
+
this.client.channels.cache.get(data.message.channel_id)?.messages._add(data.message) ??
|
|
52
|
+
new (getMessage())(client, data.message);
|
|
53
|
+
} else {
|
|
54
|
+
this.message = null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|