@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,300 @@
|
|
|
1
|
+
import { DiscordSnowflake } from '@sapphire/snowflake';
|
|
2
|
+
import { Routes } from 'discord-api-types/v10';
|
|
3
|
+
import { DiscordjsError, ErrorCodes } from '../errors/index.js';
|
|
4
|
+
import { StickerFormatExtensionMap } from '../util/Constants.js';
|
|
5
|
+
import { Base } from './Base.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents a Sticker.
|
|
9
|
+
*
|
|
10
|
+
* @extends {Base}
|
|
11
|
+
*/
|
|
12
|
+
export class Sticker extends Base {
|
|
13
|
+
public client: any;
|
|
14
|
+
public id: any;
|
|
15
|
+
public description: any;
|
|
16
|
+
public type: any;
|
|
17
|
+
public format: any;
|
|
18
|
+
public name: any;
|
|
19
|
+
public packId: any;
|
|
20
|
+
public tags: any;
|
|
21
|
+
public available: any;
|
|
22
|
+
public guildId: any;
|
|
23
|
+
public user: any;
|
|
24
|
+
public sortValue: any;
|
|
25
|
+
constructor(client, sticker) {
|
|
26
|
+
super(client);
|
|
27
|
+
|
|
28
|
+
this._patch(sticker);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
_patch(sticker) {
|
|
32
|
+
/**
|
|
33
|
+
* The sticker's id
|
|
34
|
+
*
|
|
35
|
+
* @type {Snowflake}
|
|
36
|
+
*/
|
|
37
|
+
this.id = sticker.id;
|
|
38
|
+
|
|
39
|
+
if ('description' in sticker) {
|
|
40
|
+
/**
|
|
41
|
+
* The description of the sticker
|
|
42
|
+
*
|
|
43
|
+
* @type {?string}
|
|
44
|
+
*/
|
|
45
|
+
this.description = sticker.description;
|
|
46
|
+
} else {
|
|
47
|
+
this.description ??= null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if ('type' in sticker) {
|
|
51
|
+
/**
|
|
52
|
+
* The type of the sticker
|
|
53
|
+
*
|
|
54
|
+
* @type {?StickerType}
|
|
55
|
+
*/
|
|
56
|
+
this.type = sticker.type;
|
|
57
|
+
} else {
|
|
58
|
+
this.type ??= null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if ('format_type' in sticker) {
|
|
62
|
+
/**
|
|
63
|
+
* The format of the sticker
|
|
64
|
+
*
|
|
65
|
+
* @type {StickerFormatType}
|
|
66
|
+
*/
|
|
67
|
+
this.format = sticker.format_type;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if ('name' in sticker) {
|
|
71
|
+
/**
|
|
72
|
+
* The name of the sticker
|
|
73
|
+
*
|
|
74
|
+
* @type {string}
|
|
75
|
+
*/
|
|
76
|
+
this.name = sticker.name;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if ('pack_id' in sticker) {
|
|
80
|
+
/**
|
|
81
|
+
* The id of the pack the sticker is from, for standard stickers
|
|
82
|
+
*
|
|
83
|
+
* @type {?Snowflake}
|
|
84
|
+
*/
|
|
85
|
+
this.packId = sticker.pack_id;
|
|
86
|
+
} else {
|
|
87
|
+
this.packId ??= null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if ('tags' in sticker) {
|
|
91
|
+
/**
|
|
92
|
+
* Autocomplete/suggestions for the sticker
|
|
93
|
+
*
|
|
94
|
+
* @type {?string}
|
|
95
|
+
*/
|
|
96
|
+
this.tags = sticker.tags;
|
|
97
|
+
} else {
|
|
98
|
+
this.tags ??= null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if ('available' in sticker) {
|
|
102
|
+
/**
|
|
103
|
+
* Whether or not the guild sticker is available
|
|
104
|
+
*
|
|
105
|
+
* @type {?boolean}
|
|
106
|
+
*/
|
|
107
|
+
this.available = sticker.available;
|
|
108
|
+
} else {
|
|
109
|
+
this.available ??= null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if ('guild_id' in sticker) {
|
|
113
|
+
/**
|
|
114
|
+
* The id of the guild that owns this sticker
|
|
115
|
+
*
|
|
116
|
+
* @type {?Snowflake}
|
|
117
|
+
*/
|
|
118
|
+
this.guildId = sticker.guild_id;
|
|
119
|
+
} else {
|
|
120
|
+
this.guildId ??= null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if ('user' in sticker) {
|
|
124
|
+
/**
|
|
125
|
+
* The user that uploaded the guild sticker
|
|
126
|
+
*
|
|
127
|
+
* @type {?User}
|
|
128
|
+
*/
|
|
129
|
+
this.user = this.client.users._add(sticker.user);
|
|
130
|
+
} else {
|
|
131
|
+
this.user ??= null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if ('sort_value' in sticker) {
|
|
135
|
+
/**
|
|
136
|
+
* The standard sticker's sort order within its pack
|
|
137
|
+
*
|
|
138
|
+
* @type {?number}
|
|
139
|
+
*/
|
|
140
|
+
this.sortValue = sticker.sort_value;
|
|
141
|
+
} else {
|
|
142
|
+
this.sortValue ??= null;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The timestamp the sticker was created at
|
|
148
|
+
*
|
|
149
|
+
* @type {number}
|
|
150
|
+
* @readonly
|
|
151
|
+
*/
|
|
152
|
+
get createdTimestamp() {
|
|
153
|
+
return DiscordSnowflake.timestampFrom(this.id);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The time the sticker was created at
|
|
158
|
+
*
|
|
159
|
+
* @type {Date}
|
|
160
|
+
* @readonly
|
|
161
|
+
*/
|
|
162
|
+
get createdAt() {
|
|
163
|
+
return new Date(this.createdTimestamp);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Whether this sticker is partial
|
|
168
|
+
*
|
|
169
|
+
* @type {boolean}
|
|
170
|
+
* @readonly
|
|
171
|
+
*/
|
|
172
|
+
get partial() {
|
|
173
|
+
return !this.type;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* The guild that owns this sticker
|
|
178
|
+
*
|
|
179
|
+
* @type {?Guild}
|
|
180
|
+
* @readonly
|
|
181
|
+
*/
|
|
182
|
+
get guild() {
|
|
183
|
+
return this.client.guilds.resolve(this.guildId);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* A link to the sticker
|
|
188
|
+
* <info>If the sticker's format is {@link StickerFormatType.Lottie}, it returns
|
|
189
|
+
* the URL of the Lottie JSON file.</info>
|
|
190
|
+
*
|
|
191
|
+
* @type {string}
|
|
192
|
+
* @readonly
|
|
193
|
+
*/
|
|
194
|
+
get url() {
|
|
195
|
+
return this.client.rest.cdn.sticker(this.id, StickerFormatExtensionMap[this.format]);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Fetches this sticker.
|
|
200
|
+
*
|
|
201
|
+
* @returns {Promise<Sticker>}
|
|
202
|
+
*/
|
|
203
|
+
async fetch() {
|
|
204
|
+
const data = await this.client.rest.get(Routes.sticker(this.id));
|
|
205
|
+
this._patch(data);
|
|
206
|
+
return this;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Fetches the pack that contains this sticker.
|
|
211
|
+
*
|
|
212
|
+
* @returns {Promise<?StickerPack>} The sticker pack or `null` if this sticker does not belong to one.
|
|
213
|
+
*/
|
|
214
|
+
async fetchPack() {
|
|
215
|
+
if (!this.packId) return null;
|
|
216
|
+
return this.client.fetchStickerPacks({ packId: this.packId });
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Fetches the user who uploaded this sticker, if this is a guild sticker.
|
|
221
|
+
*
|
|
222
|
+
* @returns {Promise<?User>}
|
|
223
|
+
*/
|
|
224
|
+
async fetchUser() {
|
|
225
|
+
if (this.partial) await this.fetch();
|
|
226
|
+
if (!this.guildId) throw new DiscordjsError(ErrorCodes.NotGuildSticker);
|
|
227
|
+
return this.guild.stickers.fetchUser(this);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Data for editing a sticker.
|
|
232
|
+
*
|
|
233
|
+
* @typedef {Object} GuildStickerEditOptions
|
|
234
|
+
* @property {string} [name] The name of the sticker
|
|
235
|
+
* @property {?string} [description] The description of the sticker
|
|
236
|
+
* @property {string} [tags] The Discord name of a unicode emoji representing the sticker's expression
|
|
237
|
+
* @property {string} [reason] Reason for editing this sticker
|
|
238
|
+
*/
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Edits the sticker.
|
|
242
|
+
*
|
|
243
|
+
* @param {GuildStickerEditOptions} options The options to provide
|
|
244
|
+
* @returns {Promise<Sticker>}
|
|
245
|
+
* @example
|
|
246
|
+
* // Update the name of a sticker
|
|
247
|
+
* sticker.edit({ name: 'new name' })
|
|
248
|
+
* .then(sticker => console.log(`Updated the name of the sticker to ${sticker.name}`))
|
|
249
|
+
* .catch(console.error);
|
|
250
|
+
*/
|
|
251
|
+
async edit(options) {
|
|
252
|
+
return this.guild.stickers.edit(this, options);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Deletes the sticker.
|
|
257
|
+
*
|
|
258
|
+
* @returns {Promise<Sticker>}
|
|
259
|
+
* @param {string} [reason] Reason for deleting this sticker
|
|
260
|
+
* @example
|
|
261
|
+
* // Delete a sticker
|
|
262
|
+
* sticker.delete()
|
|
263
|
+
* .then(sticker => console.log(`Deleted sticker ${sticker.name}`))
|
|
264
|
+
* .catch(console.error);
|
|
265
|
+
*/
|
|
266
|
+
async delete(reason) {
|
|
267
|
+
await this.guild.stickers.delete(this, reason);
|
|
268
|
+
return this;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Whether this sticker is the same as another one.
|
|
273
|
+
*
|
|
274
|
+
* @param {Sticker|APISticker} other The sticker to compare it to
|
|
275
|
+
* @returns {boolean}
|
|
276
|
+
*/
|
|
277
|
+
equals(other) {
|
|
278
|
+
if (other instanceof Sticker) {
|
|
279
|
+
return (
|
|
280
|
+
other.id === this.id &&
|
|
281
|
+
other.description === this.description &&
|
|
282
|
+
other.type === this.type &&
|
|
283
|
+
other.format === this.format &&
|
|
284
|
+
other.name === this.name &&
|
|
285
|
+
other.packId === this.packId &&
|
|
286
|
+
other.tags === this.tags &&
|
|
287
|
+
other.available === this.available &&
|
|
288
|
+
other.guildId === this.guildId &&
|
|
289
|
+
other.sortValue === this.sortValue
|
|
290
|
+
);
|
|
291
|
+
} else {
|
|
292
|
+
return (
|
|
293
|
+
other.id === this.id &&
|
|
294
|
+
other.description === this.description &&
|
|
295
|
+
other.name === this.name &&
|
|
296
|
+
other.tags === this.tags
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Collection } from '@ovencord/collection';
|
|
2
|
+
import { DiscordSnowflake } from '@sapphire/snowflake';
|
|
3
|
+
import { Base } from './Base.js';
|
|
4
|
+
import { Sticker } from './Sticker.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents a pack of standard stickers.
|
|
8
|
+
*
|
|
9
|
+
* @extends {Base}
|
|
10
|
+
*/
|
|
11
|
+
export class StickerPack extends Base {
|
|
12
|
+
public client: any;
|
|
13
|
+
public id: any;
|
|
14
|
+
public stickers: any;
|
|
15
|
+
public name: any;
|
|
16
|
+
public skuId: any;
|
|
17
|
+
public coverStickerId: any;
|
|
18
|
+
public description: any;
|
|
19
|
+
public bannerId: any;
|
|
20
|
+
constructor(client, pack) {
|
|
21
|
+
super(client);
|
|
22
|
+
/**
|
|
23
|
+
* The Sticker pack's id
|
|
24
|
+
*
|
|
25
|
+
* @type {Snowflake}
|
|
26
|
+
*/
|
|
27
|
+
this.id = pack.id;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The stickers in the pack
|
|
31
|
+
*
|
|
32
|
+
* @type {Collection<Snowflake, Sticker>}
|
|
33
|
+
*/
|
|
34
|
+
this.stickers = new Collection(pack.stickers.map(sticker => [sticker.id, new Sticker(client, sticker)]));
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The name of the sticker pack
|
|
38
|
+
*
|
|
39
|
+
* @type {string}
|
|
40
|
+
*/
|
|
41
|
+
this.name = pack.name;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The id of the pack's SKU
|
|
45
|
+
*
|
|
46
|
+
* @type {Snowflake}
|
|
47
|
+
*/
|
|
48
|
+
this.skuId = pack.sku_id;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The id of a sticker in the pack which is shown as the pack's icon
|
|
52
|
+
*
|
|
53
|
+
* @type {?Snowflake}
|
|
54
|
+
*/
|
|
55
|
+
this.coverStickerId = pack.cover_sticker_id ?? null;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The description of the sticker pack
|
|
59
|
+
*
|
|
60
|
+
* @type {string}
|
|
61
|
+
*/
|
|
62
|
+
this.description = pack.description;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The id of the sticker pack's banner image
|
|
66
|
+
*
|
|
67
|
+
* @type {?Snowflake}
|
|
68
|
+
*/
|
|
69
|
+
this.bannerId = pack.banner_asset_id ?? null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The timestamp the sticker was created at
|
|
74
|
+
*
|
|
75
|
+
* @type {number}
|
|
76
|
+
* @readonly
|
|
77
|
+
*/
|
|
78
|
+
get createdTimestamp() {
|
|
79
|
+
return DiscordSnowflake.timestampFrom(this.id);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The time the sticker was created at
|
|
84
|
+
*
|
|
85
|
+
* @type {Date}
|
|
86
|
+
* @readonly
|
|
87
|
+
*/
|
|
88
|
+
get createdAt() {
|
|
89
|
+
return new Date(this.createdTimestamp);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The sticker which is shown as the pack's icon
|
|
94
|
+
*
|
|
95
|
+
* @type {?Sticker}
|
|
96
|
+
* @readonly
|
|
97
|
+
*/
|
|
98
|
+
get coverSticker() {
|
|
99
|
+
return this.coverStickerId && this.stickers.get(this.coverStickerId);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The URL to this sticker pack's banner.
|
|
104
|
+
*
|
|
105
|
+
* @param {ImageURLOptions} [options={}] Options for the image URL
|
|
106
|
+
* @returns {?string}
|
|
107
|
+
*/
|
|
108
|
+
bannerURL(options = {}) {
|
|
109
|
+
return this.bannerId && this.client.rest.cdn.stickerPackBanner(this.bannerId, options);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseSelectMenuComponent } from './BaseSelectMenuComponent.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents a string select menu component
|
|
5
|
+
*
|
|
6
|
+
* @extends {BaseSelectMenuComponent}
|
|
7
|
+
*/
|
|
8
|
+
export class StringSelectMenuComponent extends BaseSelectMenuComponent {
|
|
9
|
+
/**
|
|
10
|
+
* The options in this select menu
|
|
11
|
+
*
|
|
12
|
+
* @type {APISelectMenuOption[]}
|
|
13
|
+
* @readonly
|
|
14
|
+
*/
|
|
15
|
+
get options() {
|
|
16
|
+
return this.data.options;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { MessageComponentInteraction } from './MessageComponentInteraction.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents a {@link ComponentType.StringSelect} select menu interaction.
|
|
5
|
+
*
|
|
6
|
+
* @extends {MessageComponentInteraction}
|
|
7
|
+
*/
|
|
8
|
+
export class StringSelectMenuInteraction extends MessageComponentInteraction {
|
|
9
|
+
public client: any;
|
|
10
|
+
public values: any;
|
|
11
|
+
constructor(client, data) {
|
|
12
|
+
super(client, data);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The values selected
|
|
16
|
+
*
|
|
17
|
+
* @type {string[]}
|
|
18
|
+
*/
|
|
19
|
+
this.values = data.data.values ?? [];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { Base } from './Base.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents a Subscription
|
|
5
|
+
*
|
|
6
|
+
* @extends {Base}
|
|
7
|
+
*/
|
|
8
|
+
export class Subscription extends Base {
|
|
9
|
+
public client: any;
|
|
10
|
+
public id: any;
|
|
11
|
+
public userId: any;
|
|
12
|
+
public skuIds: any;
|
|
13
|
+
public entitlementIds: any;
|
|
14
|
+
public currentPeriodStartTimestamp: any;
|
|
15
|
+
public currentPeriodEndTimestamp: any;
|
|
16
|
+
public status: any;
|
|
17
|
+
public renewalSkuIds: any;
|
|
18
|
+
public canceledTimestamp: any;
|
|
19
|
+
public country: any;
|
|
20
|
+
constructor(client, data) {
|
|
21
|
+
super(client);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The id of the subscription
|
|
25
|
+
*
|
|
26
|
+
* @type {Snowflake}
|
|
27
|
+
*/
|
|
28
|
+
this.id = data.id;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The id of the user who subscribed
|
|
32
|
+
*
|
|
33
|
+
* @type {Snowflake}
|
|
34
|
+
*/
|
|
35
|
+
this.userId = data.user_id;
|
|
36
|
+
|
|
37
|
+
this._patch(data);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
_patch(data) {
|
|
41
|
+
/**
|
|
42
|
+
* The SKU ids subscribed to
|
|
43
|
+
*
|
|
44
|
+
* @type {Snowflake[]}
|
|
45
|
+
*/
|
|
46
|
+
this.skuIds = data.sku_ids;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The entitlement ids granted for this subscription
|
|
50
|
+
*
|
|
51
|
+
* @type {Snowflake[]}
|
|
52
|
+
*/
|
|
53
|
+
this.entitlementIds = data.entitlement_ids;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The timestamp the current subscription period will start at
|
|
57
|
+
*
|
|
58
|
+
* @type {number}
|
|
59
|
+
*/
|
|
60
|
+
this.currentPeriodStartTimestamp = Date.parse(data.current_period_start);
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The timestamp the current subscription period will end at
|
|
64
|
+
*
|
|
65
|
+
* @type {number}
|
|
66
|
+
*/
|
|
67
|
+
this.currentPeriodEndTimestamp = Date.parse(data.current_period_end);
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The current status of the subscription
|
|
71
|
+
*
|
|
72
|
+
* @type {SubscriptionStatus}
|
|
73
|
+
*/
|
|
74
|
+
this.status = data.status;
|
|
75
|
+
|
|
76
|
+
if ('renewal_sku_ids' in data) {
|
|
77
|
+
/**
|
|
78
|
+
* The SKU ids that this user will be subscribed to at renewal
|
|
79
|
+
*
|
|
80
|
+
* @type {?Snowflake[]}
|
|
81
|
+
*/
|
|
82
|
+
this.renewalSkuIds = data.renewal_sku_ids;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if ('canceled_at' in data) {
|
|
86
|
+
/**
|
|
87
|
+
* The timestamp of when the subscription was canceled
|
|
88
|
+
*
|
|
89
|
+
* @type {?number}
|
|
90
|
+
*/
|
|
91
|
+
this.canceledTimestamp = data.canceled_at ? Date.parse(data.canceled_at) : null;
|
|
92
|
+
} else {
|
|
93
|
+
this.canceledTimestamp ??= null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if ('country' in data) {
|
|
97
|
+
/**
|
|
98
|
+
* ISO 3166-1 alpha-2 country code of the payment source used to purchase the subscription.
|
|
99
|
+
* Missing unless queried with a private OAuth scope.
|
|
100
|
+
*
|
|
101
|
+
* @type {?string}
|
|
102
|
+
*/
|
|
103
|
+
this.country = data.country;
|
|
104
|
+
} else {
|
|
105
|
+
this.country ??= null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The time the subscription was canceled
|
|
111
|
+
*
|
|
112
|
+
* @type {?Date}
|
|
113
|
+
* @readonly
|
|
114
|
+
*/
|
|
115
|
+
get canceledAt() {
|
|
116
|
+
return this.canceledTimestamp && new Date(this.canceledTimestamp);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The time the current subscription period will start at
|
|
121
|
+
*
|
|
122
|
+
* @type {Date}
|
|
123
|
+
* @readonly
|
|
124
|
+
*/
|
|
125
|
+
get currentPeriodStartAt() {
|
|
126
|
+
return new Date(this.currentPeriodStartTimestamp);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The time the current subscription period will end at
|
|
131
|
+
*
|
|
132
|
+
* @type {Date}
|
|
133
|
+
* @readonly
|
|
134
|
+
*/
|
|
135
|
+
get currentPeriodEndAt() {
|
|
136
|
+
return new Date(this.currentPeriodEndTimestamp);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Collection } from '@ovencord/collection';
|
|
2
|
+
import { DiscordSnowflake } from '@sapphire/snowflake';
|
|
3
|
+
import { Base } from './Base.js';
|
|
4
|
+
import { TeamMember } from './TeamMember.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents a Client OAuth2 Application Team.
|
|
8
|
+
*
|
|
9
|
+
* @extends {Base}
|
|
10
|
+
*/
|
|
11
|
+
export class Team extends Base {
|
|
12
|
+
public client: any;
|
|
13
|
+
public id: any;
|
|
14
|
+
public name: any;
|
|
15
|
+
public icon: any;
|
|
16
|
+
public ownerId: any;
|
|
17
|
+
public members: any;
|
|
18
|
+
constructor(client, data) {
|
|
19
|
+
super(client);
|
|
20
|
+
this._patch(data);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
_patch(data) {
|
|
24
|
+
/**
|
|
25
|
+
* The Team's id
|
|
26
|
+
*
|
|
27
|
+
* @type {Snowflake}
|
|
28
|
+
*/
|
|
29
|
+
this.id = data.id;
|
|
30
|
+
|
|
31
|
+
if ('name' in data) {
|
|
32
|
+
/**
|
|
33
|
+
* The name of the Team
|
|
34
|
+
*
|
|
35
|
+
* @type {string}
|
|
36
|
+
*/
|
|
37
|
+
this.name = data.name;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if ('icon' in data) {
|
|
41
|
+
/**
|
|
42
|
+
* The Team's icon hash
|
|
43
|
+
*
|
|
44
|
+
* @type {?string}
|
|
45
|
+
*/
|
|
46
|
+
this.icon = data.icon;
|
|
47
|
+
} else {
|
|
48
|
+
this.icon ??= null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if ('owner_user_id' in data) {
|
|
52
|
+
/**
|
|
53
|
+
* The Team's owner id
|
|
54
|
+
*
|
|
55
|
+
* @type {?Snowflake}
|
|
56
|
+
*/
|
|
57
|
+
this.ownerId = data.owner_user_id;
|
|
58
|
+
} else {
|
|
59
|
+
this.ownerId ??= null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The Team's members
|
|
64
|
+
*
|
|
65
|
+
* @type {Collection<Snowflake, TeamMember>}
|
|
66
|
+
*/
|
|
67
|
+
this.members = new Collection();
|
|
68
|
+
|
|
69
|
+
for (const memberData of data.members) {
|
|
70
|
+
const member = new TeamMember(this, memberData);
|
|
71
|
+
this.members.set(member.id, member);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The owner of this team
|
|
77
|
+
*
|
|
78
|
+
* @type {?TeamMember}
|
|
79
|
+
* @readonly
|
|
80
|
+
*/
|
|
81
|
+
get owner() {
|
|
82
|
+
return this.members.get(this.ownerId) ?? null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The timestamp the team was created at
|
|
87
|
+
*
|
|
88
|
+
* @type {number}
|
|
89
|
+
* @readonly
|
|
90
|
+
*/
|
|
91
|
+
get createdTimestamp() {
|
|
92
|
+
return DiscordSnowflake.timestampFrom(this.id);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The time the team was created at
|
|
97
|
+
*
|
|
98
|
+
* @type {Date}
|
|
99
|
+
* @readonly
|
|
100
|
+
*/
|
|
101
|
+
get createdAt() {
|
|
102
|
+
return new Date(this.createdTimestamp);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* A link to the team's icon.
|
|
107
|
+
*
|
|
108
|
+
* @param {ImageURLOptions} [options={}] Options for the image URL
|
|
109
|
+
* @returns {?string}
|
|
110
|
+
*/
|
|
111
|
+
iconURL(options = {}) {
|
|
112
|
+
return this.icon && this.client.rest.cdn.teamIcon(this.id, this.icon, options);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* When concatenated with a string, this automatically returns the Team's name instead of the
|
|
117
|
+
* Team object.
|
|
118
|
+
*
|
|
119
|
+
* @returns {string}
|
|
120
|
+
* @example
|
|
121
|
+
* // Logs: Team name: My Team
|
|
122
|
+
* console.log(`Team name: ${team}`);
|
|
123
|
+
*/
|
|
124
|
+
toString() {
|
|
125
|
+
return this.name;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
toJSON() {
|
|
129
|
+
return super.toJSON({ createdTimestamp: true });
|
|
130
|
+
}
|
|
131
|
+
}
|