@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,219 @@
|
|
|
1
|
+
import { Routes } from 'discord-api-types/v10';
|
|
2
|
+
import { resolveImage } from '../util/DataResolver.js';
|
|
3
|
+
import { User } from './User.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents the logged in client's Discord user.
|
|
7
|
+
*
|
|
8
|
+
* @extends {User}
|
|
9
|
+
*/
|
|
10
|
+
export class ClientUser extends User {
|
|
11
|
+
public verified: any;
|
|
12
|
+
public mfaEnabled: any;
|
|
13
|
+
_patch(data) {
|
|
14
|
+
super._patch(data);
|
|
15
|
+
|
|
16
|
+
if ('verified' in data) {
|
|
17
|
+
/**
|
|
18
|
+
* Whether or not this account has been verified
|
|
19
|
+
*
|
|
20
|
+
* @type {boolean}
|
|
21
|
+
*/
|
|
22
|
+
this.verified = data.verified;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if ('mfa_enabled' in data) {
|
|
26
|
+
/**
|
|
27
|
+
* If the bot's {@link ClientApplication#owner Owner} has MFA enabled on their account
|
|
28
|
+
*
|
|
29
|
+
* @type {?boolean}
|
|
30
|
+
*/
|
|
31
|
+
this.mfaEnabled = typeof data.mfa_enabled === 'boolean' ? data.mfa_enabled : null;
|
|
32
|
+
} else {
|
|
33
|
+
this.mfaEnabled ??= null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if ('token' in data) this.client.token = data.token;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Represents the client user's presence
|
|
41
|
+
*
|
|
42
|
+
* @type {ClientPresence}
|
|
43
|
+
* @readonly
|
|
44
|
+
*/
|
|
45
|
+
get presence() {
|
|
46
|
+
return this.client.presence;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Data used to edit the logged in client
|
|
51
|
+
*
|
|
52
|
+
* @typedef {Object} ClientUserEditOptions
|
|
53
|
+
* @property {string} [username] The new username
|
|
54
|
+
* @property {?(BufferResolvable|Base64Resolvable)} [avatar] The new avatar
|
|
55
|
+
* @property {?(BufferResolvable|Base64Resolvable)} [banner] The new banner
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Edits the logged in client.
|
|
60
|
+
*
|
|
61
|
+
* @param {ClientUserEditOptions} options The options to provide
|
|
62
|
+
* @returns {Promise<ClientUser>}
|
|
63
|
+
*/
|
|
64
|
+
async edit({ username, avatar, banner }) {
|
|
65
|
+
const data = await this.client.rest.patch(Routes.user(), {
|
|
66
|
+
body: {
|
|
67
|
+
username,
|
|
68
|
+
avatar: avatar && (await resolveImage(avatar)),
|
|
69
|
+
banner: banner && (await resolveImage(banner)),
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const { updated } = this.client.actions.UserUpdate.handle(data);
|
|
74
|
+
return updated ?? this;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Sets the username of the logged in client.
|
|
79
|
+
* <info>Changing usernames in Discord is heavily rate limited, with only 2 requests
|
|
80
|
+
* every hour. Use this sparingly!</info>
|
|
81
|
+
*
|
|
82
|
+
* @param {string} username The new username
|
|
83
|
+
* @returns {Promise<ClientUser>}
|
|
84
|
+
* @example
|
|
85
|
+
* // Set username
|
|
86
|
+
* client.user.setUsername('discordjs')
|
|
87
|
+
* .then(user => console.log(`My new username is ${user.username}`))
|
|
88
|
+
* .catch(console.error);
|
|
89
|
+
*/
|
|
90
|
+
async setUsername(username) {
|
|
91
|
+
return this.edit({ username });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Sets the avatar of the logged in client.
|
|
96
|
+
*
|
|
97
|
+
* @param {?(BufferResolvable|Base64Resolvable)} avatar The new avatar
|
|
98
|
+
* @returns {Promise<ClientUser>}
|
|
99
|
+
* @example
|
|
100
|
+
* // Set avatar
|
|
101
|
+
* client.user.setAvatar('./avatar.png')
|
|
102
|
+
* .then(user => console.log(`New avatar set!`))
|
|
103
|
+
* .catch(console.error);
|
|
104
|
+
*/
|
|
105
|
+
async setAvatar(avatar) {
|
|
106
|
+
return this.edit({ avatar });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Sets the banner of the logged in client.
|
|
111
|
+
*
|
|
112
|
+
* @param {?(BufferResolvable|Base64Resolvable)} banner The new banner
|
|
113
|
+
* @returns {Promise<ClientUser>}
|
|
114
|
+
* @example
|
|
115
|
+
* // Set banner
|
|
116
|
+
* client.user.setBanner('./banner.png')
|
|
117
|
+
* .then(user => console.log(`New banner set!`))
|
|
118
|
+
* .catch(console.error);
|
|
119
|
+
*/
|
|
120
|
+
async setBanner(banner) {
|
|
121
|
+
return this.edit({ banner });
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Options for setting activities
|
|
126
|
+
*
|
|
127
|
+
* @typedef {Object} ActivitiesOptions
|
|
128
|
+
* @property {string} name Name of the activity
|
|
129
|
+
* @property {string} [state] State of the activity
|
|
130
|
+
* @property {ActivityType} [type] Type of the activity
|
|
131
|
+
* @property {string} [url] Twitch / YouTube stream URL
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Data resembling a raw Discord presence.
|
|
136
|
+
*
|
|
137
|
+
* @typedef {Object} PresenceData
|
|
138
|
+
* @property {PresenceStatusData} [status] Status of the user
|
|
139
|
+
* @property {boolean} [afk] Whether the user is AFK
|
|
140
|
+
* @property {ActivitiesOptions[]} [activities] Activity the user is playing
|
|
141
|
+
* @property {number|number[]} [shardId] Shard id(s) to have the activity set on
|
|
142
|
+
*/
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Sets the full presence of the client user.
|
|
146
|
+
*
|
|
147
|
+
* @param {PresenceData} data Data for the presence
|
|
148
|
+
* @returns {Promise<ClientPresence>}
|
|
149
|
+
* @example
|
|
150
|
+
* // Set the client user's presence
|
|
151
|
+
* client.user.setPresence({ activities: [{ name: 'with discord.js' }], status: 'idle' });
|
|
152
|
+
*/
|
|
153
|
+
async setPresence(data) {
|
|
154
|
+
return this.client.presence.set(data);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* A user's status. Must be one of:
|
|
159
|
+
* - `online`
|
|
160
|
+
* - `idle`
|
|
161
|
+
* - `invisible`
|
|
162
|
+
* - `dnd` (do not disturb)
|
|
163
|
+
*
|
|
164
|
+
* @typedef {string} PresenceStatusData
|
|
165
|
+
*/
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Sets the status of the client user.
|
|
169
|
+
*
|
|
170
|
+
* @param {PresenceStatusData} status Status to change to
|
|
171
|
+
* @param {number|number[]} [shardId] Shard id(s) to have the activity set on
|
|
172
|
+
* @returns {Promise<ClientPresence>}
|
|
173
|
+
* @example
|
|
174
|
+
* // Set the client user's status
|
|
175
|
+
* client.user.setStatus('idle');
|
|
176
|
+
*/
|
|
177
|
+
async setStatus(status, shardId) {
|
|
178
|
+
return this.setPresence({ status, shardId });
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Options for setting an activity.
|
|
183
|
+
*
|
|
184
|
+
* @typedef {Object} ActivityOptions
|
|
185
|
+
* @property {string} name Name of the activity
|
|
186
|
+
* @property {string} [state] State of the activity
|
|
187
|
+
* @property {string} [url] Twitch / YouTube stream URL
|
|
188
|
+
* @property {ActivityType} [type] Type of the activity
|
|
189
|
+
* @property {number|number[]} [shardId] Shard Id(s) to have the activity set on
|
|
190
|
+
*/
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Sets the activity the client user is playing.
|
|
194
|
+
*
|
|
195
|
+
* @param {string|ActivityOptions} name Activity being played, or options for setting the activity
|
|
196
|
+
* @param {ActivityOptions} [options] Options for setting the activity
|
|
197
|
+
* @returns {Promise<ClientPresence>}
|
|
198
|
+
* @example
|
|
199
|
+
* // Set the client user's activity
|
|
200
|
+
* client.user.setActivity('discord.js', { type: ActivityType.Watching });
|
|
201
|
+
*/
|
|
202
|
+
async setActivity(name, options = {}) {
|
|
203
|
+
if (!name) return this.setPresence({ activities: [], shardId: options.shardId });
|
|
204
|
+
|
|
205
|
+
const activity = { ...options, ...(typeof name === 'object' ? name : { name }) };
|
|
206
|
+
return this.setPresence({ activities: [activity], shardId: activity.shardId });
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Sets/removes the AFK flag for the client user.
|
|
211
|
+
*
|
|
212
|
+
* @param {boolean} [afk=true] Whether or not the user is AFK
|
|
213
|
+
* @param {number|number[]} [shardId] Shard Id(s) to have the AFK flag set on
|
|
214
|
+
* @returns {Promise<ClientPresence>}
|
|
215
|
+
*/
|
|
216
|
+
async setAFK(afk = true, shardId = undefined) {
|
|
217
|
+
return this.setPresence({ afk, shardId });
|
|
218
|
+
}
|
|
219
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { Attachment } from './Attachment.js';
|
|
2
|
+
import { BaseInteraction } from './BaseInteraction.js';
|
|
3
|
+
import { InteractionWebhook } from './InteractionWebhook.js';
|
|
4
|
+
import { InteractionResponses } from './interfaces/InteractionResponses.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents a command interaction.
|
|
8
|
+
*
|
|
9
|
+
* @extends {BaseInteraction}
|
|
10
|
+
* @implements {InteractionResponses}
|
|
11
|
+
* @abstract
|
|
12
|
+
*/
|
|
13
|
+
export class CommandInteraction extends BaseInteraction {
|
|
14
|
+
public client: any;
|
|
15
|
+
public commandId: any;
|
|
16
|
+
public commandName: any;
|
|
17
|
+
public commandType: any;
|
|
18
|
+
public commandGuildId: any;
|
|
19
|
+
public deferred: any;
|
|
20
|
+
public replied: any;
|
|
21
|
+
public ephemeral: any;
|
|
22
|
+
public webhook: any;
|
|
23
|
+
constructor(client, data) {
|
|
24
|
+
super(client, data);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The id of the channel this interaction was sent in
|
|
28
|
+
*
|
|
29
|
+
* @type {Snowflake}
|
|
30
|
+
* @name CommandInteraction#channelId
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The invoked application command's id
|
|
35
|
+
*
|
|
36
|
+
* @type {Snowflake}
|
|
37
|
+
*/
|
|
38
|
+
this.commandId = data.data.id;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The invoked application command's name
|
|
42
|
+
*
|
|
43
|
+
* @type {string}
|
|
44
|
+
*/
|
|
45
|
+
this.commandName = data.data.name;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The invoked application command's type
|
|
49
|
+
*
|
|
50
|
+
* @type {ApplicationCommandType}
|
|
51
|
+
*/
|
|
52
|
+
this.commandType = data.data.type;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The id of the guild the invoked application command is registered to
|
|
56
|
+
*
|
|
57
|
+
* @type {?Snowflake}
|
|
58
|
+
*/
|
|
59
|
+
this.commandGuildId = data.data.guild_id ?? null;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Whether the reply to this interaction has been deferred
|
|
63
|
+
*
|
|
64
|
+
* @type {boolean}
|
|
65
|
+
*/
|
|
66
|
+
this.deferred = false;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Whether this interaction has already been replied to
|
|
70
|
+
*
|
|
71
|
+
* @type {boolean}
|
|
72
|
+
*/
|
|
73
|
+
this.replied = false;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Whether the reply to this interaction is ephemeral
|
|
77
|
+
*
|
|
78
|
+
* @type {?boolean}
|
|
79
|
+
*/
|
|
80
|
+
this.ephemeral = null;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* An associated interaction webhook, can be used to further interact with this interaction
|
|
84
|
+
*
|
|
85
|
+
* @type {InteractionWebhook}
|
|
86
|
+
*/
|
|
87
|
+
this.webhook = new InteractionWebhook(this.client, this.applicationId, this.token);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The invoked application command, if it was fetched before
|
|
92
|
+
*
|
|
93
|
+
* @type {?ApplicationCommand}
|
|
94
|
+
*/
|
|
95
|
+
get command() {
|
|
96
|
+
const id = this.commandId;
|
|
97
|
+
return this.guild?.commands.cache.get(id) ?? this.client.application.commands.cache.get(id) ?? null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @typedef {Object} BaseInteractionResolvedData
|
|
102
|
+
* @property {Collection<Snowflake, User>} [users] The resolved users
|
|
103
|
+
* @property {Collection<Snowflake, GuildMember|APIGuildMember>} [members] The resolved guild members
|
|
104
|
+
* @property {Collection<Snowflake, Role|APIRole>} [roles] The resolved roles
|
|
105
|
+
* @property {Collection<Snowflake, BaseChannel|APIChannel>} [channels] The resolved channels
|
|
106
|
+
* @property {Collection<Snowflake, Attachment>} [attachments] The resolved attachments
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Represents the resolved data of a received command interaction.
|
|
111
|
+
*
|
|
112
|
+
* @typedef {BaseInteractionResolvedData} CommandInteractionResolvedData
|
|
113
|
+
* @property {Collection<Snowflake, Message|APIMessage>} [messages] The resolved messages
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Represents an option of a received command interaction.
|
|
118
|
+
*
|
|
119
|
+
* @typedef {Object} CommandInteractionOption
|
|
120
|
+
* @property {string} name The name of the option
|
|
121
|
+
* @property {ApplicationCommandOptionType} type The type of the option
|
|
122
|
+
* @property {boolean} [autocomplete] Whether the autocomplete interaction is enabled for a
|
|
123
|
+
* {@link ApplicationCommandOptionType.String}, {@link ApplicationCommandOptionType.Integer} or
|
|
124
|
+
* {@link ApplicationCommandOptionType.Number} option
|
|
125
|
+
* @property {string|number|boolean} [value] The value of the option
|
|
126
|
+
* @property {CommandInteractionOption[]} [options] Additional options if this option is a
|
|
127
|
+
* subcommand (group)
|
|
128
|
+
* @property {User} [user] The resolved user
|
|
129
|
+
* @property {GuildMember|APIGuildMember} [member] The resolved member
|
|
130
|
+
* @property {GuildChannel|ThreadChannel|APIChannel} [channel] The resolved channel
|
|
131
|
+
* @property {Role|APIRole} [role] The resolved role
|
|
132
|
+
* @property {Attachment} [attachment] The resolved attachment
|
|
133
|
+
*/
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Transforms an option received from the API.
|
|
137
|
+
*
|
|
138
|
+
* @param {APIApplicationCommandOption} option The received option
|
|
139
|
+
* @param {APIInteractionDataResolved} resolved The resolved interaction data
|
|
140
|
+
* @returns {CommandInteractionOption}
|
|
141
|
+
* @private
|
|
142
|
+
*/
|
|
143
|
+
transformOption(option, resolved) {
|
|
144
|
+
const result = {
|
|
145
|
+
name: option.name,
|
|
146
|
+
type: option.type,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
if ('value' in option) result.value = option.value;
|
|
150
|
+
if ('options' in option) result.options = option.options.map(opt => this.transformOption(opt, resolved));
|
|
151
|
+
|
|
152
|
+
if (resolved) {
|
|
153
|
+
const user = resolved.users?.[option.value];
|
|
154
|
+
if (user) result.user = this.client.users._add(user);
|
|
155
|
+
|
|
156
|
+
const member = resolved.members?.[option.value];
|
|
157
|
+
if (member) result.member = this.guild?.members._add({ user, ...member }) ?? member;
|
|
158
|
+
|
|
159
|
+
const channel = resolved.channels?.[option.value];
|
|
160
|
+
if (channel) result.channel = this.client.channels._add(channel, this.guild) ?? channel;
|
|
161
|
+
|
|
162
|
+
const role = resolved.roles?.[option.value];
|
|
163
|
+
if (role) result.role = this.guild?.roles._add(role) ?? role;
|
|
164
|
+
|
|
165
|
+
const attachment = resolved.attachments?.[option.value];
|
|
166
|
+
if (attachment) result.attachment = new Attachment(attachment);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// These are here only for documentation purposes - they are implemented by InteractionResponses
|
|
173
|
+
|
|
174
|
+
deferReply() {}
|
|
175
|
+
|
|
176
|
+
reply() {}
|
|
177
|
+
|
|
178
|
+
fetchReply() {}
|
|
179
|
+
|
|
180
|
+
editReply() {}
|
|
181
|
+
|
|
182
|
+
deleteReply() {}
|
|
183
|
+
|
|
184
|
+
followUp() {}
|
|
185
|
+
|
|
186
|
+
launchActivity() {}
|
|
187
|
+
|
|
188
|
+
showModal() {}
|
|
189
|
+
|
|
190
|
+
awaitModalSubmit() {}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
InteractionResponses.applyToClass(CommandInteraction, ['deferUpdate', 'update']);
|