@biggy1337/discord-sbjs 1.3.11
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 +674 -0
- package/README.md +147 -0
- package/package.json +80 -0
- package/src/WebSocket.js +39 -0
- package/src/client/BaseClient.js +110 -0
- package/src/client/Client.js +1076 -0
- package/src/client/WebhookClient.js +61 -0
- package/src/client/actions/Action.js +133 -0
- package/src/client/actions/ActionsManager.js +80 -0
- package/src/client/actions/ApplicationCommandPermissionsUpdate.js +34 -0
- package/src/client/actions/AutoModerationActionExecution.js +27 -0
- package/src/client/actions/AutoModerationRuleCreate.js +28 -0
- package/src/client/actions/AutoModerationRuleDelete.js +32 -0
- package/src/client/actions/AutoModerationRuleUpdate.js +30 -0
- package/src/client/actions/ChannelCreate.js +23 -0
- package/src/client/actions/ChannelDelete.js +39 -0
- package/src/client/actions/ChannelUpdate.js +43 -0
- package/src/client/actions/GuildAuditLogEntryCreate.js +29 -0
- package/src/client/actions/GuildBanAdd.js +20 -0
- package/src/client/actions/GuildBanRemove.js +25 -0
- package/src/client/actions/GuildChannelsPositionUpdate.js +21 -0
- package/src/client/actions/GuildDelete.js +65 -0
- package/src/client/actions/GuildEmojiCreate.js +20 -0
- package/src/client/actions/GuildEmojiDelete.js +21 -0
- package/src/client/actions/GuildEmojiUpdate.js +20 -0
- package/src/client/actions/GuildEmojisUpdate.js +34 -0
- package/src/client/actions/GuildIntegrationsUpdate.js +19 -0
- package/src/client/actions/GuildMemberRemove.js +33 -0
- package/src/client/actions/GuildMemberUpdate.js +44 -0
- package/src/client/actions/GuildRoleCreate.js +25 -0
- package/src/client/actions/GuildRoleDelete.js +31 -0
- package/src/client/actions/GuildRoleUpdate.js +39 -0
- package/src/client/actions/GuildRolesPositionUpdate.js +21 -0
- package/src/client/actions/GuildScheduledEventCreate.js +27 -0
- package/src/client/actions/GuildScheduledEventDelete.js +31 -0
- package/src/client/actions/GuildScheduledEventUpdate.js +30 -0
- package/src/client/actions/GuildScheduledEventUserAdd.js +32 -0
- package/src/client/actions/GuildScheduledEventUserRemove.js +32 -0
- package/src/client/actions/GuildStickerCreate.js +20 -0
- package/src/client/actions/GuildStickerDelete.js +21 -0
- package/src/client/actions/GuildStickerUpdate.js +20 -0
- package/src/client/actions/GuildStickersUpdate.js +34 -0
- package/src/client/actions/GuildUpdate.js +33 -0
- package/src/client/actions/InviteCreate.js +28 -0
- package/src/client/actions/InviteDelete.js +30 -0
- package/src/client/actions/MessageCreate.js +50 -0
- package/src/client/actions/MessageDelete.js +34 -0
- package/src/client/actions/MessageDeleteBulk.js +43 -0
- package/src/client/actions/MessagePollVoteAdd.js +33 -0
- package/src/client/actions/MessagePollVoteRemove.js +33 -0
- package/src/client/actions/MessageReactionAdd.js +71 -0
- package/src/client/actions/MessageReactionRemove.js +39 -0
- package/src/client/actions/MessageReactionRemoveAll.js +36 -0
- package/src/client/actions/MessageReactionRemoveEmoji.js +30 -0
- package/src/client/actions/MessageUpdate.js +28 -0
- package/src/client/actions/PresenceUpdate.js +55 -0
- package/src/client/actions/StageInstanceCreate.js +28 -0
- package/src/client/actions/StageInstanceDelete.js +33 -0
- package/src/client/actions/StageInstanceUpdate.js +30 -0
- package/src/client/actions/ThreadCreate.js +24 -0
- package/src/client/actions/ThreadDelete.js +32 -0
- package/src/client/actions/ThreadListSync.js +60 -0
- package/src/client/actions/ThreadMemberUpdate.js +30 -0
- package/src/client/actions/ThreadMembersUpdate.js +38 -0
- package/src/client/actions/TypingStart.js +31 -0
- package/src/client/actions/UserUpdate.js +35 -0
- package/src/client/actions/VoiceStateUpdate.js +63 -0
- package/src/client/actions/WebhooksUpdate.js +20 -0
- package/src/client/voice/ClientVoiceManager.js +162 -0
- package/src/client/voice/StreamEventRouter.js +60 -0
- package/src/client/voice/VoiceConnection.js +1173 -0
- package/src/client/voice/dispatcher/AnnexBDispatcher.js +120 -0
- package/src/client/voice/dispatcher/AudioDispatcher.js +145 -0
- package/src/client/voice/dispatcher/BaseDispatcher.js +459 -0
- package/src/client/voice/dispatcher/VPxDispatcher.js +54 -0
- package/src/client/voice/dispatcher/VideoDispatcher.js +68 -0
- package/src/client/voice/networking/VoiceUDPClient.js +187 -0
- package/src/client/voice/networking/VoiceWebSocket.js +347 -0
- package/src/client/voice/player/MediaPlayer.js +321 -0
- package/src/client/voice/player/processing/AnnexBNalSplitter.js +244 -0
- package/src/client/voice/player/processing/IvfSplitter.js +106 -0
- package/src/client/voice/player/processing/PCMInsertSilence.js +37 -0
- package/src/client/voice/receiver/PacketHandler.js +260 -0
- package/src/client/voice/receiver/Receiver.js +96 -0
- package/src/client/voice/receiver/Recorder.js +191 -0
- package/src/client/voice/util/Function.js +116 -0
- package/src/client/voice/util/PlayInterface.js +122 -0
- package/src/client/voice/util/Secretbox.js +64 -0
- package/src/client/voice/util/Silence.js +16 -0
- package/src/client/voice/util/Socket.js +62 -0
- package/src/client/voice/util/VolumeInterface.js +104 -0
- package/src/client/websocket/DispatchTable.js +7 -0
- package/src/client/websocket/GatewaySendScheduler.js +122 -0
- package/src/client/websocket/WebSocketManager.js +439 -0
- package/src/client/websocket/WebSocketShard.js +1085 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_CREATE.js +18 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_DELETE.js +20 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_PERMISSIONS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_UPDATE.js +20 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_ACTION_EXECUTION.js +5 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_CREATE.js +5 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_DELETE.js +5 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/CALL_CREATE.js +14 -0
- package/src/client/websocket/handlers/CALL_DELETE.js +11 -0
- package/src/client/websocket/handlers/CALL_UPDATE.js +11 -0
- package/src/client/websocket/handlers/CHANNEL_CREATE.js +5 -0
- package/src/client/websocket/handlers/CHANNEL_DELETE.js +5 -0
- package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js +22 -0
- package/src/client/websocket/handlers/CHANNEL_RECIPIENT_ADD.js +19 -0
- package/src/client/websocket/handlers/CHANNEL_RECIPIENT_REMOVE.js +16 -0
- package/src/client/websocket/handlers/CHANNEL_UPDATE.js +16 -0
- package/src/client/websocket/handlers/GUILD_AUDIT_LOG_ENTRY_CREATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_BAN_ADD.js +5 -0
- package/src/client/websocket/handlers/GUILD_BAN_REMOVE.js +5 -0
- package/src/client/websocket/handlers/GUILD_CREATE.js +51 -0
- package/src/client/websocket/handlers/GUILD_DELETE.js +5 -0
- package/src/client/websocket/handlers/GUILD_EMOJIS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_INTEGRATIONS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js +45 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +20 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_REMOVE.js +5 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_ROLE_CREATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_ROLE_DELETE.js +5 -0
- package/src/client/websocket/handlers/GUILD_ROLE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_CREATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_DELETE.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_ADD.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_REMOVE.js +5 -0
- package/src/client/websocket/handlers/GUILD_STICKERS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_UPDATE.js +5 -0
- package/src/client/websocket/handlers/INTERACTION_MODAL_CREATE.js +12 -0
- package/src/client/websocket/handlers/INVITE_CREATE.js +5 -0
- package/src/client/websocket/handlers/INVITE_DELETE.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_CREATE.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE_BULK.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_ADD.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_REMOVE.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_ADD.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_ALL.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_EMOJI.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_UPDATE.js +16 -0
- package/src/client/websocket/handlers/PRESENCE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/READY.js +156 -0
- package/src/client/websocket/handlers/RELATIONSHIP_ADD.js +19 -0
- package/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js +17 -0
- package/src/client/websocket/handlers/RELATIONSHIP_UPDATE.js +41 -0
- package/src/client/websocket/handlers/RESUMED.js +14 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_CREATE.js +5 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_DELETE.js +5 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/THREAD_CREATE.js +5 -0
- package/src/client/websocket/handlers/THREAD_DELETE.js +5 -0
- package/src/client/websocket/handlers/THREAD_LIST_SYNC.js +5 -0
- package/src/client/websocket/handlers/THREAD_MEMBERS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/THREAD_MEMBER_UPDATE.js +5 -0
- package/src/client/websocket/handlers/THREAD_UPDATE.js +16 -0
- package/src/client/websocket/handlers/TYPING_START.js +5 -0
- package/src/client/websocket/handlers/USER_GUILD_SETTINGS_UPDATE.js +6 -0
- package/src/client/websocket/handlers/USER_NOTE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/USER_REQUIRED_ACTION_UPDATE.js +82 -0
- package/src/client/websocket/handlers/USER_SETTINGS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/USER_UPDATE.js +5 -0
- package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.js +16 -0
- package/src/client/websocket/handlers/VOICE_CHANNEL_STATUS_UPDATE.js +12 -0
- package/src/client/websocket/handlers/VOICE_SERVER_UPDATE.js +12 -0
- package/src/client/websocket/handlers/VOICE_STATE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/WEBHOOKS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/index.js +84 -0
- package/src/errors/DJSError.js +61 -0
- package/src/errors/Messages.js +218 -0
- package/src/errors/index.js +4 -0
- package/src/index.js +172 -0
- package/src/managers/ApplicationCommandManager.js +264 -0
- package/src/managers/ApplicationCommandPermissionsManager.js +417 -0
- package/src/managers/AutoModerationRuleManager.js +296 -0
- package/src/managers/BaseGuildEmojiManager.js +80 -0
- package/src/managers/BaseManager.js +19 -0
- package/src/managers/BillingManager.js +66 -0
- package/src/managers/CachedManager.js +72 -0
- package/src/managers/ChannelManager.js +148 -0
- package/src/managers/ClientUserSettingManager.js +372 -0
- package/src/managers/DataManager.js +61 -0
- package/src/managers/DeveloperManager.js +265 -0
- package/src/managers/GuildBanManager.js +252 -0
- package/src/managers/GuildChannelManager.js +488 -0
- package/src/managers/GuildEmojiManager.js +171 -0
- package/src/managers/GuildEmojiRoleManager.js +118 -0
- package/src/managers/GuildForumThreadManager.js +108 -0
- package/src/managers/GuildInviteManager.js +213 -0
- package/src/managers/GuildManager.js +401 -0
- package/src/managers/GuildMemberManager.js +608 -0
- package/src/managers/GuildMemberRoleManager.js +195 -0
- package/src/managers/GuildScheduledEventManager.js +314 -0
- package/src/managers/GuildSettingManager.js +155 -0
- package/src/managers/GuildStickerManager.js +179 -0
- package/src/managers/GuildTextThreadManager.js +98 -0
- package/src/managers/InteractionManager.js +39 -0
- package/src/managers/MessageManager.js +457 -0
- package/src/managers/PermissionOverwriteManager.js +169 -0
- package/src/managers/PresenceManager.js +71 -0
- package/src/managers/QuestManager.js +391 -0
- package/src/managers/ReactionManager.js +67 -0
- package/src/managers/ReactionUserManager.js +73 -0
- package/src/managers/RelationshipManager.js +341 -0
- package/src/managers/RoleManager.js +448 -0
- package/src/managers/SessionManager.js +66 -0
- package/src/managers/StageInstanceManager.js +162 -0
- package/src/managers/ThreadManager.js +175 -0
- package/src/managers/ThreadMemberManager.js +186 -0
- package/src/managers/UserManager.js +274 -0
- package/src/managers/UserNoteManager.js +53 -0
- package/src/managers/VoiceStateManager.js +59 -0
- package/src/rest/APIRequest.js +198 -0
- package/src/rest/APIRouter.js +94 -0
- package/src/rest/DiscordAPIError.js +120 -0
- package/src/rest/HTTPError.js +62 -0
- package/src/rest/RESTManager.js +203 -0
- package/src/rest/RateLimitCoordinator.js +156 -0
- package/src/rest/RateLimitError.js +55 -0
- package/src/rest/RequestHandler.js +552 -0
- package/src/sharding/Shard.js +444 -0
- package/src/sharding/ShardClientUtil.js +279 -0
- package/src/sharding/ShardingManager.js +319 -0
- package/src/structures/AnonymousGuild.js +98 -0
- package/src/structures/ApplicationCommand.js +593 -0
- package/src/structures/ApplicationRoleConnectionMetadata.js +48 -0
- package/src/structures/AutoModerationActionExecution.js +89 -0
- package/src/structures/AutoModerationRule.js +294 -0
- package/src/structures/AutocompleteInteraction.js +107 -0
- package/src/structures/Base.js +43 -0
- package/src/structures/BaseCommandInteraction.js +211 -0
- package/src/structures/BaseGuild.js +124 -0
- package/src/structures/BaseGuildEmoji.js +56 -0
- package/src/structures/BaseGuildTextChannel.js +191 -0
- package/src/structures/BaseGuildVoiceChannel.js +241 -0
- package/src/structures/BaseMessageComponent.js +181 -0
- package/src/structures/ButtonInteraction.js +11 -0
- package/src/structures/CallState.js +63 -0
- package/src/structures/CategoryChannel.js +85 -0
- package/src/structures/Channel.js +284 -0
- package/src/structures/ClientPresence.js +77 -0
- package/src/structures/ClientUser.js +706 -0
- package/src/structures/CommandInteraction.js +41 -0
- package/src/structures/CommandInteractionOptionResolver.js +276 -0
- package/src/structures/ContainerComponent.js +68 -0
- package/src/structures/ContextMenuInteraction.js +65 -0
- package/src/structures/DMChannel.js +222 -0
- package/src/structures/DirectoryChannel.js +20 -0
- package/src/structures/Emoji.js +148 -0
- package/src/structures/FileComponent.js +49 -0
- package/src/structures/ForumChannel.js +31 -0
- package/src/structures/GroupDMChannel.js +415 -0
- package/src/structures/Guild.js +1804 -0
- package/src/structures/GuildAuditLogs.js +746 -0
- package/src/structures/GuildBan.js +59 -0
- package/src/structures/GuildBoost.js +108 -0
- package/src/structures/GuildChannel.js +470 -0
- package/src/structures/GuildEmoji.js +161 -0
- package/src/structures/GuildMember.js +636 -0
- package/src/structures/GuildPreview.js +191 -0
- package/src/structures/GuildPreviewEmoji.js +27 -0
- package/src/structures/GuildScheduledEvent.js +536 -0
- package/src/structures/GuildTemplate.js +236 -0
- package/src/structures/Integration.js +188 -0
- package/src/structures/IntegrationApplication.js +96 -0
- package/src/structures/Interaction.js +290 -0
- package/src/structures/InteractionCollector.js +248 -0
- package/src/structures/InteractionWebhook.js +43 -0
- package/src/structures/Invite.js +358 -0
- package/src/structures/InviteGuild.js +23 -0
- package/src/structures/InviteStageInstance.js +86 -0
- package/src/structures/MediaChannel.js +11 -0
- package/src/structures/MediaGalleryComponent.js +41 -0
- package/src/structures/MediaGalleryItem.js +47 -0
- package/src/structures/Message.js +1272 -0
- package/src/structures/MessageActionRow.js +105 -0
- package/src/structures/MessageAttachment.js +216 -0
- package/src/structures/MessageButton.js +166 -0
- package/src/structures/MessageCollector.js +146 -0
- package/src/structures/MessageComponentInteraction.js +120 -0
- package/src/structures/MessageContextMenuInteraction.js +20 -0
- package/src/structures/MessageEmbed.js +596 -0
- package/src/structures/MessageMentions.js +273 -0
- package/src/structures/MessagePayload.js +354 -0
- package/src/structures/MessageReaction.js +181 -0
- package/src/structures/MessageSelectMenu.js +141 -0
- package/src/structures/Modal.js +161 -0
- package/src/structures/ModalSubmitFieldsResolver.js +53 -0
- package/src/structures/ModalSubmitInteraction.js +119 -0
- package/src/structures/NewsChannel.js +32 -0
- package/src/structures/OAuth2Guild.js +28 -0
- package/src/structures/PermissionOverwrites.js +198 -0
- package/src/structures/Poll.js +108 -0
- package/src/structures/PollAnswer.js +88 -0
- package/src/structures/Presence.js +1165 -0
- package/src/structures/ReactionCollector.js +229 -0
- package/src/structures/ReactionEmoji.js +31 -0
- package/src/structures/Role.js +590 -0
- package/src/structures/SectionComponent.js +48 -0
- package/src/structures/SelectMenuInteraction.js +21 -0
- package/src/structures/SeparatorComponent.js +48 -0
- package/src/structures/Session.js +81 -0
- package/src/structures/StageChannel.js +104 -0
- package/src/structures/StageInstance.js +208 -0
- package/src/structures/Sticker.js +310 -0
- package/src/structures/StickerPack.js +95 -0
- package/src/structures/StoreChannel.js +56 -0
- package/src/structures/Team.js +118 -0
- package/src/structures/TeamMember.js +80 -0
- package/src/structures/TextChannel.js +33 -0
- package/src/structures/TextDisplayComponent.js +40 -0
- package/src/structures/TextInputComponent.js +132 -0
- package/src/structures/ThreadChannel.js +605 -0
- package/src/structures/ThreadMember.js +105 -0
- package/src/structures/ThreadOnlyChannel.js +249 -0
- package/src/structures/ThumbnailComponent.js +57 -0
- package/src/structures/Typing.js +74 -0
- package/src/structures/UnfurledMediaItem.js +29 -0
- package/src/structures/User.js +992 -0
- package/src/structures/UserContextMenuInteraction.js +29 -0
- package/src/structures/VoiceChannel.js +110 -0
- package/src/structures/VoiceChannelEffect.js +69 -0
- package/src/structures/VoiceRegion.js +53 -0
- package/src/structures/VoiceState.js +354 -0
- package/src/structures/WebEmbed.js +373 -0
- package/src/structures/Webhook.js +478 -0
- package/src/structures/WelcomeChannel.js +60 -0
- package/src/structures/WelcomeScreen.js +48 -0
- package/src/structures/Widget.js +87 -0
- package/src/structures/WidgetMember.js +100 -0
- package/src/structures/interfaces/Application.js +953 -0
- package/src/structures/interfaces/Collector.js +301 -0
- package/src/structures/interfaces/InteractionResponses.js +313 -0
- package/src/structures/interfaces/TextBasedChannel.js +821 -0
- package/src/util/APITypes.js +59 -0
- package/src/util/ActivityFlags.js +44 -0
- package/src/util/ApplicationFlags.js +76 -0
- package/src/util/AttachmentFlags.js +38 -0
- package/src/util/BitField.js +170 -0
- package/src/util/ChannelFlags.js +45 -0
- package/src/util/Constants.js +1953 -0
- package/src/util/DataResolver.js +162 -0
- package/src/util/FastQueue.js +93 -0
- package/src/util/FetchUtil.js +77 -0
- package/src/util/Formatters.js +228 -0
- package/src/util/GuildMemberFlags.js +43 -0
- package/src/util/Intents.js +74 -0
- package/src/util/InviteFlags.js +34 -0
- package/src/util/LimitedCollection.js +131 -0
- package/src/util/ListenerUtil.js +12 -0
- package/src/util/MessageFlags.js +63 -0
- package/src/util/Options.js +431 -0
- package/src/util/Permissions.js +202 -0
- package/src/util/PremiumUsageFlags.js +31 -0
- package/src/util/PurchasedFlags.js +33 -0
- package/src/util/RemoteAuth.js +425 -0
- package/src/util/RoleFlags.js +37 -0
- package/src/util/SnowflakeUtil.js +92 -0
- package/src/util/Speaking.js +33 -0
- package/src/util/Sweepers.js +493 -0
- package/src/util/SystemChannelFlags.js +55 -0
- package/src/util/ThreadMemberFlags.js +30 -0
- package/src/util/UserFlags.js +104 -0
- package/src/util/Util.js +1144 -0
- package/typings/enums.d.ts +437 -0
- package/typings/index.d.ts +8857 -0
- package/typings/index.test-d.ts +0 -0
- package/typings/rawDataTypes.d.ts +403 -0
|
@@ -0,0 +1,992 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const Base = require('./Base');
|
|
4
|
+
const VoiceState = require('./VoiceState');
|
|
5
|
+
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
|
6
|
+
const { Error } = require('../errors');
|
|
7
|
+
const { RelationshipTypes } = require('../util/Constants');
|
|
8
|
+
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
|
9
|
+
const UserFlags = require('../util/UserFlags');
|
|
10
|
+
const Util = require('../util/Util');
|
|
11
|
+
|
|
12
|
+
const nousdeux = 24 * 60 * 60 * 1000;
|
|
13
|
+
const ondoitfaireunebalade = 30 * nousdeux;
|
|
14
|
+
const laluneestbelle = Object.freeze({
|
|
15
|
+
0: 'None',
|
|
16
|
+
1: 'Nitro Classic',
|
|
17
|
+
2: 'Nitro',
|
|
18
|
+
3: 'Nitro Basic',
|
|
19
|
+
});
|
|
20
|
+
const tumeplais = Object.freeze([
|
|
21
|
+
Object.freeze({ months: 1, badgeName: 'Bronze', assetId: 'premium_tenure_1_month' }),
|
|
22
|
+
Object.freeze({ months: 3, badgeName: 'Silver', assetId: 'premium_tenure_3_month' }),
|
|
23
|
+
Object.freeze({ months: 6, badgeName: 'Gold', assetId: 'premium_tenure_6_month' }),
|
|
24
|
+
Object.freeze({ months: 12, badgeName: 'Platinum', assetId: 'premium_tenure_12_month' }),
|
|
25
|
+
Object.freeze({ months: 24, badgeName: 'Diamond', assetId: 'premium_tenure_24_month' }),
|
|
26
|
+
Object.freeze({ months: 36, badgeName: 'Emerald', assetId: 'premium_tenure_36_month' }),
|
|
27
|
+
Object.freeze({ months: 60, badgeName: 'Ruby', assetId: 'premium_tenure_60_month' }),
|
|
28
|
+
Object.freeze({ months: 72, badgeName: 'Opal / Fire', assetId: 'premium_tenure_72_month' }),
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @typedef {'None'|'Nitro Classic'|'Nitro'|'Nitro Basic'} NitroTypeName
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @typedef {Object} PremiumBadge
|
|
37
|
+
* @property {'premium'} id Premium badge id from the profile endpoint
|
|
38
|
+
* @property {?string} asset Premium badge asset hash
|
|
39
|
+
* @property {?string} description Premium badge description from the profile endpoint
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {Object} NitroTenureMilestone
|
|
44
|
+
* @property {number} months Milestone month threshold
|
|
45
|
+
* @property {string} badgeName Human-readable badge tier name
|
|
46
|
+
* @property {string} assetId Asset reference id for the milestone
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @typedef {Object} NitroTenureInfo
|
|
51
|
+
* @property {?number} nitroType Raw premium type id
|
|
52
|
+
* @property {NitroTypeName} nitroName Nitro plan label
|
|
53
|
+
* @property {boolean} isEvolving Whether tenure progression is active
|
|
54
|
+
* @property {?number} currentTenureMonths Current elapsed tenure in 30-day months
|
|
55
|
+
* @property {?number} currentBadgeMilestone Current reached milestone in months
|
|
56
|
+
* @property {?NitroTenureMilestone} currentBadge Current reached milestone details
|
|
57
|
+
* @property {?number} nextBadgeMilestone Next milestone in months
|
|
58
|
+
* @property {?NitroTenureMilestone} nextBadge Next milestone details
|
|
59
|
+
* @property {?number} daysUntilNextBadge Days until next milestone
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
function revienssteplait(user, now = Date.now()) {
|
|
63
|
+
const rawPremiumType = user.premiumType;
|
|
64
|
+
const premiumType = rawPremiumType ?? 0;
|
|
65
|
+
const nitroName = laluneestbelle[premiumType] ?? 'None';
|
|
66
|
+
const hasValidPremiumSince = Number.isFinite(user.premiumSinceTimestamp);
|
|
67
|
+
const isEvolving = premiumType === 2 && hasValidPremiumSince;
|
|
68
|
+
|
|
69
|
+
const base = {
|
|
70
|
+
nitroType: rawPremiumType ?? null,
|
|
71
|
+
nitroName,
|
|
72
|
+
isEvolving,
|
|
73
|
+
currentTenureMonths: null,
|
|
74
|
+
currentBadgeMilestone: null,
|
|
75
|
+
currentBadge: null,
|
|
76
|
+
nextBadgeMilestone: null,
|
|
77
|
+
nextBadge: null,
|
|
78
|
+
daysUntilNextBadge: null,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
if (!isEvolving) return base;
|
|
82
|
+
|
|
83
|
+
const elapsedMs = now - user.premiumSinceTimestamp;
|
|
84
|
+
if (!Number.isFinite(elapsedMs) || elapsedMs < 0) return base;
|
|
85
|
+
|
|
86
|
+
const currentTenureMonths = Math.floor(elapsedMs / ondoitfaireunebalade);
|
|
87
|
+
const currentBadge = [...tumeplais].reverse().find(milestone => milestone.months <= currentTenureMonths) ?? null;
|
|
88
|
+
const nextBadge = tumeplais.find(milestone => milestone.months > currentTenureMonths) ?? null;
|
|
89
|
+
|
|
90
|
+
let daysUntilNextBadge = null;
|
|
91
|
+
if (nextBadge) {
|
|
92
|
+
const remainingMs = Math.max(0, nextBadge.months * ondoitfaireunebalade - elapsedMs);
|
|
93
|
+
daysUntilNextBadge = Math.ceil(remainingMs / nousdeux);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
base.currentTenureMonths = currentTenureMonths;
|
|
97
|
+
base.currentBadgeMilestone = currentBadge?.months ?? null;
|
|
98
|
+
base.currentBadge = currentBadge;
|
|
99
|
+
base.nextBadgeMilestone = nextBadge?.months ?? null;
|
|
100
|
+
base.nextBadge = nextBadge;
|
|
101
|
+
base.daysUntilNextBadge = daysUntilNextBadge;
|
|
102
|
+
|
|
103
|
+
return base;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Represents a user on Discord.
|
|
108
|
+
* @implements {TextBasedChannel}
|
|
109
|
+
* @extends {Base}
|
|
110
|
+
*/
|
|
111
|
+
class User extends Base {
|
|
112
|
+
constructor(client, data) {
|
|
113
|
+
super(client);
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The user's id
|
|
117
|
+
* @type {Snowflake}
|
|
118
|
+
*/
|
|
119
|
+
this.id = data.id;
|
|
120
|
+
|
|
121
|
+
this.bot = null;
|
|
122
|
+
|
|
123
|
+
this.system = null;
|
|
124
|
+
|
|
125
|
+
this.flags = null;
|
|
126
|
+
|
|
127
|
+
this.premiumSinceTimestamp = null;
|
|
128
|
+
|
|
129
|
+
this.premiumGuildSinceTimestamp = null;
|
|
130
|
+
|
|
131
|
+
this.premiumType = null;
|
|
132
|
+
|
|
133
|
+
this.premiumBadge = null;
|
|
134
|
+
|
|
135
|
+
this.legacyUsername = null;
|
|
136
|
+
|
|
137
|
+
this.connectedAccounts = null;
|
|
138
|
+
|
|
139
|
+
this.mutualGroups = null;
|
|
140
|
+
|
|
141
|
+
this.mutualGroupsCount = null;
|
|
142
|
+
|
|
143
|
+
this.mutualFriendsCount = null;
|
|
144
|
+
|
|
145
|
+
this.mutualGuilds = null;
|
|
146
|
+
|
|
147
|
+
this.mutualGuildsCount = null;
|
|
148
|
+
|
|
149
|
+
this._patch(data);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
_patch(data) {
|
|
153
|
+
if ('username' in data) {
|
|
154
|
+
/**
|
|
155
|
+
* The username of the user
|
|
156
|
+
* @type {?string}
|
|
157
|
+
*/
|
|
158
|
+
this.username = data.username;
|
|
159
|
+
} else {
|
|
160
|
+
this.username ??= null;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if ('global_name' in data) {
|
|
164
|
+
/**
|
|
165
|
+
* The global name of this user
|
|
166
|
+
* @type {?string}
|
|
167
|
+
*/
|
|
168
|
+
this.globalName = data.global_name;
|
|
169
|
+
} else {
|
|
170
|
+
this.globalName ??= null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if ('bot' in data) {
|
|
174
|
+
/**
|
|
175
|
+
* Whether or not the user is a bot
|
|
176
|
+
* @type {?boolean}
|
|
177
|
+
*/
|
|
178
|
+
this.bot = Boolean(data.bot);
|
|
179
|
+
} else if (!this.partial && typeof this.bot !== 'boolean') {
|
|
180
|
+
this.bot = false;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if ('discriminator' in data) {
|
|
184
|
+
/**
|
|
185
|
+
* The discriminator of this user
|
|
186
|
+
* <info>`'0'`, or a 4-digit stringified number if they're using the legacy username system</info>
|
|
187
|
+
* @type {?string}
|
|
188
|
+
* @deprecated The discriminator is no longer used by Discord. Use `username` or `displayName` instead.
|
|
189
|
+
*/
|
|
190
|
+
this.discriminator = data.discriminator;
|
|
191
|
+
} else {
|
|
192
|
+
this.discriminator ??= null;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if ('avatar' in data) {
|
|
196
|
+
/**
|
|
197
|
+
* The user avatar's hash
|
|
198
|
+
* @type {?string}
|
|
199
|
+
*/
|
|
200
|
+
this.avatar = data.avatar;
|
|
201
|
+
} else {
|
|
202
|
+
this.avatar ??= null;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if ('banner' in data) {
|
|
206
|
+
/**
|
|
207
|
+
* The user banner's hash
|
|
208
|
+
* <info>The user must be force fetched for this property to be present or be updated</info>
|
|
209
|
+
* @type {?string}
|
|
210
|
+
*/
|
|
211
|
+
this.banner = data.banner;
|
|
212
|
+
} else if (this.banner !== null) {
|
|
213
|
+
this.banner ??= undefined;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if ('banner_color' in data) {
|
|
217
|
+
/**
|
|
218
|
+
* The user banner's hex
|
|
219
|
+
* <info>The user must be force fetched for this property to be present or be updated</info>
|
|
220
|
+
* @type {?string}
|
|
221
|
+
*/
|
|
222
|
+
this.bannerColor = data.banner_color;
|
|
223
|
+
} else if (this.bannerColor !== null) {
|
|
224
|
+
this.bannerColor ??= undefined;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if ('accent_color' in data) {
|
|
228
|
+
/**
|
|
229
|
+
* The base 10 accent color of the user's banner
|
|
230
|
+
* <info>The user must be force fetched for this property to be present or be updated</info>
|
|
231
|
+
* @type {?number}
|
|
232
|
+
*/
|
|
233
|
+
this.accentColor = data.accent_color;
|
|
234
|
+
} else if (this.accentColor !== null) {
|
|
235
|
+
this.accentColor ??= undefined;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if ('bio' in data) {
|
|
239
|
+
/**
|
|
240
|
+
* The user's bio
|
|
241
|
+
* <info>The user must be force fetched for this property to be present or be updated</info>
|
|
242
|
+
* @type {?string}
|
|
243
|
+
*/
|
|
244
|
+
this.bio = data.bio;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if ('pronouns' in data) {
|
|
248
|
+
/**
|
|
249
|
+
* The user's pronouns
|
|
250
|
+
* <info>The user must be force fetched for this property to be present or be updated</info>
|
|
251
|
+
* @type {?string}
|
|
252
|
+
*/
|
|
253
|
+
this.pronouns = data.pronouns;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const premiumSince = 'premium_since' in data ? data.premium_since : data.premiumSince;
|
|
257
|
+
if (typeof premiumSince !== 'undefined') {
|
|
258
|
+
/**
|
|
259
|
+
* Timestamp the user started boosting Nitro
|
|
260
|
+
* @type {?number}
|
|
261
|
+
*/
|
|
262
|
+
this.premiumSinceTimestamp = premiumSince ? new Date(premiumSince).getTime() : null;
|
|
263
|
+
} else {
|
|
264
|
+
this.premiumSinceTimestamp ??= null;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const premiumGuildSince = 'premium_guild_since' in data ? data.premium_guild_since : data.premiumGuildSince;
|
|
268
|
+
if (typeof premiumGuildSince !== 'undefined') {
|
|
269
|
+
/**
|
|
270
|
+
* Timestamp the user started boosting the mutual guild (if provided)
|
|
271
|
+
* @type {?number}
|
|
272
|
+
*/
|
|
273
|
+
this.premiumGuildSinceTimestamp = premiumGuildSince ? new Date(premiumGuildSince).getTime() : null;
|
|
274
|
+
} else {
|
|
275
|
+
this.premiumGuildSinceTimestamp ??= null;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if ('premium_type' in data) {
|
|
279
|
+
/**
|
|
280
|
+
* Premium type level for this user
|
|
281
|
+
* @type {?number}
|
|
282
|
+
*/
|
|
283
|
+
this.premiumType = data.premium_type ?? null;
|
|
284
|
+
} else if ('premiumType' in data) {
|
|
285
|
+
this.premiumType = data.premiumType ?? null;
|
|
286
|
+
} else {
|
|
287
|
+
this.premiumType ??= null;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if ('premium_badge' in data) {
|
|
291
|
+
/**
|
|
292
|
+
* Premium badge metadata from profile badges
|
|
293
|
+
* @type {?PremiumBadge}
|
|
294
|
+
*/
|
|
295
|
+
this.premiumBadge = data.premium_badge ?? null;
|
|
296
|
+
} else if ('premiumBadge' in data) {
|
|
297
|
+
this.premiumBadge = data.premiumBadge ?? null;
|
|
298
|
+
} else {
|
|
299
|
+
this.premiumBadge ??= null;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if ('legacy_username' in data) {
|
|
303
|
+
/**
|
|
304
|
+
* Legacy username (pre-unique username migration)
|
|
305
|
+
* @type {?string}
|
|
306
|
+
*/
|
|
307
|
+
this.legacyUsername = data.legacy_username ?? null;
|
|
308
|
+
} else if ('legacyUsername' in data) {
|
|
309
|
+
this.legacyUsername = data.legacyUsername ?? null;
|
|
310
|
+
} else {
|
|
311
|
+
this.legacyUsername ??= null;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* @typedef {Object} ConnectedAccount
|
|
316
|
+
* @property {string} id The id of the connected account
|
|
317
|
+
* @property {string} name The name of the connected account
|
|
318
|
+
* @property {string} type The type of the connected account (ex: spotify, twitter, ...)
|
|
319
|
+
* @property {?boolean} [verified] Whether the connection is verified
|
|
320
|
+
* @property {?number} [visibility] Visibility of the connection
|
|
321
|
+
*/
|
|
322
|
+
|
|
323
|
+
if ('connected_accounts' in data) {
|
|
324
|
+
/**
|
|
325
|
+
* Connected accounts for this user
|
|
326
|
+
* @type {?ConnectedAccount[]}
|
|
327
|
+
*/
|
|
328
|
+
this.connectedAccounts = data.connected_accounts ?? null;
|
|
329
|
+
} else if ('connectedAccounts' in data) {
|
|
330
|
+
this.connectedAccounts = data.connectedAccounts ?? null;
|
|
331
|
+
} else {
|
|
332
|
+
this.connectedAccounts ??= null;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* @typedef {Object} MutualGuild
|
|
337
|
+
* @property {Snowflake} id The id of the mutual guild
|
|
338
|
+
* @property {?string} nick The nickname of the user in the mutual guild
|
|
339
|
+
*/
|
|
340
|
+
|
|
341
|
+
if ('mutualGuilds' in data) {
|
|
342
|
+
/**
|
|
343
|
+
* The guilds that this user shares with the client user
|
|
344
|
+
* @type {?MutualGuild[]}
|
|
345
|
+
*/
|
|
346
|
+
this.mutualGuilds = data.mutualGuilds ?? null;
|
|
347
|
+
} else {
|
|
348
|
+
this.mutualGuilds ??= null;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if ('mutualGuildsCount' in data) {
|
|
352
|
+
/**
|
|
353
|
+
* The number of guilds that this user shares with the client user
|
|
354
|
+
* @type {?number}
|
|
355
|
+
*/
|
|
356
|
+
this.mutualGuildsCount = data.mutualGuildsCount;
|
|
357
|
+
} else if (this.mutualGuildsCount == null && Array.isArray(this.mutualGuilds)) {
|
|
358
|
+
this.mutualGuildsCount = this.mutualGuilds.length;
|
|
359
|
+
} else {
|
|
360
|
+
this.mutualGuildsCount ??= null;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if ('mutualGroups' in data) {
|
|
364
|
+
/**
|
|
365
|
+
* The group DMs this user shares with the client user
|
|
366
|
+
* @type {?GroupDMChannel[]}
|
|
367
|
+
*/
|
|
368
|
+
this.mutualGroups = data.mutualGroups ?? null;
|
|
369
|
+
} else {
|
|
370
|
+
this.mutualGroups ??= null;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if ('mutualGroupsCount' in data) {
|
|
374
|
+
/**
|
|
375
|
+
* The number of group DMs this user shares with the client user
|
|
376
|
+
* @type {?number}
|
|
377
|
+
*/
|
|
378
|
+
this.mutualGroupsCount = data.mutualGroupsCount;
|
|
379
|
+
} else {
|
|
380
|
+
this.mutualGroupsCount ??= null;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if ('mutualFriendsCount' in data) {
|
|
384
|
+
/**
|
|
385
|
+
* The number of friends that this user shares with the client user
|
|
386
|
+
* @type {?number}
|
|
387
|
+
*/
|
|
388
|
+
this.mutualFriendsCount = data.mutualFriendsCount;
|
|
389
|
+
} else {
|
|
390
|
+
this.mutualFriendsCount ??= null;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
if ('system' in data) {
|
|
394
|
+
/**
|
|
395
|
+
* Whether the user is an Official Discord System user (part of the urgent message system)
|
|
396
|
+
* @type {?boolean}
|
|
397
|
+
*/
|
|
398
|
+
this.system = Boolean(data.system);
|
|
399
|
+
} else if (!this.partial && typeof this.system !== 'boolean') {
|
|
400
|
+
this.system = false;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
if ('public_flags' in data) {
|
|
404
|
+
/**
|
|
405
|
+
* The flags for this user
|
|
406
|
+
* @type {?UserFlags}
|
|
407
|
+
*/
|
|
408
|
+
this.flags = new UserFlags(data.public_flags);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
if (data.display_name_styles) {
|
|
412
|
+
if (data.display_name_styles) {
|
|
413
|
+
/**
|
|
414
|
+
* The user avatar decoration's data
|
|
415
|
+
* @type {?AvatarDecorationData}
|
|
416
|
+
*/
|
|
417
|
+
this.displayNameStyles = {
|
|
418
|
+
fontId: data.display_name_styles.fontId,
|
|
419
|
+
effectId: data.display_name_styles.effectId,
|
|
420
|
+
colors: data.display_name_styles.colors,
|
|
421
|
+
};
|
|
422
|
+
} else {
|
|
423
|
+
this.displayNameStyles = null;
|
|
424
|
+
}
|
|
425
|
+
} else {
|
|
426
|
+
this.displayNameStyles ??= null;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* @typedef {Object} AvatarDecorationData
|
|
431
|
+
* @property {string} asset The avatar decoration hash
|
|
432
|
+
* @property {Snowflake} skuId The id of the avatar decoration's SKU
|
|
433
|
+
*/
|
|
434
|
+
|
|
435
|
+
if (data.avatar_decoration_data) {
|
|
436
|
+
if (data.avatar_decoration_data) {
|
|
437
|
+
/**
|
|
438
|
+
* The user avatar decoration's data
|
|
439
|
+
* @type {?AvatarDecorationData}
|
|
440
|
+
*/
|
|
441
|
+
this.avatarDecorationData = {
|
|
442
|
+
asset: data.avatar_decoration_data.asset,
|
|
443
|
+
skuId: data.avatar_decoration_data.sku_id,
|
|
444
|
+
};
|
|
445
|
+
} else {
|
|
446
|
+
this.avatarDecorationData = null;
|
|
447
|
+
}
|
|
448
|
+
} else {
|
|
449
|
+
this.avatarDecorationData ??= null;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* @typedef {Object} UserPrimaryGuild
|
|
454
|
+
* @property {?Snowflake} identityGuildId The id of the user's primary guild
|
|
455
|
+
* @property {?boolean} identityEnabled Whether the user is displaying the primary guild's tag
|
|
456
|
+
* @property {?string} tag The user's guild tag. Limited to 4 characters
|
|
457
|
+
* @property {?string} badge The guild tag badge hash
|
|
458
|
+
*/
|
|
459
|
+
|
|
460
|
+
if ('primary_guild' in data) {
|
|
461
|
+
if (data.primary_guild) {
|
|
462
|
+
/**
|
|
463
|
+
* The primary guild of the user
|
|
464
|
+
* @type {?UserPrimaryGuild}
|
|
465
|
+
*/
|
|
466
|
+
this.primaryGuild = {
|
|
467
|
+
identityGuildId: data.primary_guild.identity_guild_id,
|
|
468
|
+
identityEnabled: data.primary_guild.identity_enabled,
|
|
469
|
+
tag: data.primary_guild.tag,
|
|
470
|
+
badge: data.primary_guild.badge,
|
|
471
|
+
};
|
|
472
|
+
} else {
|
|
473
|
+
this.primaryGuild = null;
|
|
474
|
+
}
|
|
475
|
+
} else {
|
|
476
|
+
this.primaryGuild ??= null;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* @typedef {Object} NameplateData
|
|
481
|
+
* @property {Snowflake} skuId The id of the nameplate's SKU
|
|
482
|
+
* @property {string} asset The nameplate's asset path
|
|
483
|
+
* @property {string} label The nameplate's label
|
|
484
|
+
* @property {NameplatePalette} palette Background color of the nameplate
|
|
485
|
+
*/
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* @typedef {Object} Collectibles
|
|
489
|
+
* @property {?NameplateData} nameplate The user's nameplate data
|
|
490
|
+
*/
|
|
491
|
+
|
|
492
|
+
if (data.collectibles) {
|
|
493
|
+
if (data.collectibles.nameplate) {
|
|
494
|
+
/**
|
|
495
|
+
* The user's collectibles
|
|
496
|
+
* @type {?Collectibles}
|
|
497
|
+
*/
|
|
498
|
+
this.collectibles = {
|
|
499
|
+
nameplate: {
|
|
500
|
+
skuId: data.collectibles.nameplate.sku_id,
|
|
501
|
+
asset: data.collectibles.nameplate.asset,
|
|
502
|
+
label: data.collectibles.nameplate.label,
|
|
503
|
+
palette: data.collectibles.nameplate.palette,
|
|
504
|
+
},
|
|
505
|
+
};
|
|
506
|
+
} else {
|
|
507
|
+
this.collectibles = { nameplate: null };
|
|
508
|
+
}
|
|
509
|
+
} else {
|
|
510
|
+
this.collectibles ??= null;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* The primary clan the user is in
|
|
516
|
+
* @type {?PrimaryGuild}
|
|
517
|
+
* @deprecated Use `primaryGuild` instead
|
|
518
|
+
*/
|
|
519
|
+
get clan() {
|
|
520
|
+
return this.primaryGuild;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* The user avatar decoration's hash
|
|
525
|
+
* @type {?string}
|
|
526
|
+
* @deprecated Use `avatarDecorationData` instead
|
|
527
|
+
* Removed in v4
|
|
528
|
+
*/
|
|
529
|
+
get avatarDecoration() {
|
|
530
|
+
return this.avatarDecorationData?.asset || null;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Whether this User is a partial
|
|
535
|
+
* @type {boolean}
|
|
536
|
+
* @readonly
|
|
537
|
+
*/
|
|
538
|
+
get partial() {
|
|
539
|
+
return typeof this.username !== 'string';
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* The timestamp the user was created at
|
|
544
|
+
* @type {number}
|
|
545
|
+
* @readonly
|
|
546
|
+
*/
|
|
547
|
+
get createdTimestamp() {
|
|
548
|
+
return SnowflakeUtil.timestampFrom(this.id);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* The time the user was created at
|
|
553
|
+
* @type {Date}
|
|
554
|
+
* @readonly
|
|
555
|
+
*/
|
|
556
|
+
get createdAt() {
|
|
557
|
+
return new Date(this.createdTimestamp);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* The time the user started Nitro
|
|
562
|
+
* @type {?Date}
|
|
563
|
+
* @readonly
|
|
564
|
+
*/
|
|
565
|
+
get premiumSince() {
|
|
566
|
+
return this.premiumSinceTimestamp ? new Date(this.premiumSinceTimestamp) : null;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* The time the user started boosting the mutual guild (if provided)
|
|
571
|
+
* @type {?Date}
|
|
572
|
+
* @readonly
|
|
573
|
+
*/
|
|
574
|
+
get premiumGuildSince() {
|
|
575
|
+
return this.premiumGuildSinceTimestamp ? new Date(this.premiumGuildSinceTimestamp) : null;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Readable Nitro plan name from {@link User#premiumType}.
|
|
580
|
+
* @type {NitroTypeName}
|
|
581
|
+
* @readonly
|
|
582
|
+
*/
|
|
583
|
+
get nitroName() {
|
|
584
|
+
return laluneestbelle[this.premiumType ?? 0] ?? 'None';
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Current Nitro tenure in 30-day months. Returns null if tenure is not evolving.
|
|
589
|
+
* @type {?number}
|
|
590
|
+
* @readonly
|
|
591
|
+
*/
|
|
592
|
+
get currentTenureMonths() {
|
|
593
|
+
return this.nitroTenure.currentTenureMonths;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* The next Nitro tenure milestone in months. Returns null if max milestone reached or tenure not evolving.
|
|
598
|
+
* @type {?number}
|
|
599
|
+
* @readonly
|
|
600
|
+
*/
|
|
601
|
+
get nextBadgeMilestone() {
|
|
602
|
+
return this.nitroTenure.nextBadgeMilestone;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Days remaining before the next Nitro tenure badge milestone.
|
|
607
|
+
* @type {?number}
|
|
608
|
+
* @readonly
|
|
609
|
+
*/
|
|
610
|
+
get daysUntilNextBadge() {
|
|
611
|
+
return this.nitroTenure.daysUntilNextBadge;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Nitro tenure snapshot with current and next badge details.
|
|
616
|
+
* @type {NitroTenureInfo}
|
|
617
|
+
* @readonly
|
|
618
|
+
*/
|
|
619
|
+
get nitroTenure() {
|
|
620
|
+
return revienssteplait(this);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* A link to the user's avatar.
|
|
625
|
+
* @param {ImageURLOptions} [options={}] Options for the Image URL
|
|
626
|
+
* @returns {?string}
|
|
627
|
+
*/
|
|
628
|
+
avatarURL({ format, size, dynamic } = {}) {
|
|
629
|
+
if (!this.avatar) return null;
|
|
630
|
+
return this.client.rest.cdn.Avatar(this.id, this.avatar, format, size, dynamic);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* A link to the user's avatar decoration.
|
|
635
|
+
* @returns {?string}
|
|
636
|
+
*/
|
|
637
|
+
avatarDecorationURL() {
|
|
638
|
+
if (!this.avatarDecorationData) return null;
|
|
639
|
+
return this.client.rest.cdn.AvatarDecoration(this.avatarDecorationData.asset);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* A link to the user's guild tag badge.
|
|
644
|
+
* @returns {?string}
|
|
645
|
+
* @deprecated
|
|
646
|
+
*/
|
|
647
|
+
clanBadgeURL() {
|
|
648
|
+
return this.guildTagBadgeURL();
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* A link to the user's guild tag badge.
|
|
653
|
+
* @returns {?string}
|
|
654
|
+
*/
|
|
655
|
+
guildTagBadgeURL() {
|
|
656
|
+
if (!this.primaryGuild || !this.primaryGuild.identityGuildId || !this.primaryGuild.badge) return null;
|
|
657
|
+
return this.client.rest.cdn.GuildTagBadge(this.primaryGuild.identityGuildId, this.primaryGuild.badge);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* A link to the user's default avatar
|
|
662
|
+
* @type {string}
|
|
663
|
+
* @readonly
|
|
664
|
+
*/
|
|
665
|
+
get defaultAvatarURL() {
|
|
666
|
+
const index =
|
|
667
|
+
this.discriminator === '0' || this.discriminator === '0000'
|
|
668
|
+
? Util.calculateUserDefaultAvatarIndex(this.id)
|
|
669
|
+
: this.discriminator % 5;
|
|
670
|
+
return this.client.rest.cdn.DefaultAvatar(index);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* A link to the user's avatar if they have one.
|
|
675
|
+
* Otherwise a link to their default avatar will be returned.
|
|
676
|
+
* @param {ImageURLOptions} [options={}] Options for the Image URL
|
|
677
|
+
* @returns {string}
|
|
678
|
+
*/
|
|
679
|
+
displayAvatarURL(options) {
|
|
680
|
+
return this.avatarURL(options) ?? this.defaultAvatarURL;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* The hexadecimal version of the user accent color, with a leading hash
|
|
685
|
+
* <info>The user must be force fetched for this property to be present</info>
|
|
686
|
+
* @type {?string}
|
|
687
|
+
* @readonly
|
|
688
|
+
*/
|
|
689
|
+
get hexAccentColor() {
|
|
690
|
+
if (typeof this.accentColor !== 'number') return this.accentColor;
|
|
691
|
+
return `#${this.accentColor.toString(16).padStart(6, '0')}`;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* A link to the user's banner.
|
|
696
|
+
* <info>This method will throw an error if called before the user is force fetched.
|
|
697
|
+
* See {@link User#banner} for more info</info>
|
|
698
|
+
* @param {ImageURLOptions} [options={}] Options for the Image URL
|
|
699
|
+
* @returns {?string}
|
|
700
|
+
*/
|
|
701
|
+
bannerURL({ format, size, dynamic } = {}) {
|
|
702
|
+
if (typeof this.banner === 'undefined') throw new Error('USER_BANNER_NOT_FETCHED');
|
|
703
|
+
if (!this.banner) return null;
|
|
704
|
+
return this.client.rest.cdn.Banner(this.id, this.banner, format, size, dynamic);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* The tag of this user
|
|
709
|
+
* <info>This user's username, or their legacy tag (e.g. `hydrabolt#0001`)
|
|
710
|
+
* if they're using the legacy username system</info>
|
|
711
|
+
* @type {?string}
|
|
712
|
+
* @readonly
|
|
713
|
+
* @deprecated Legacy discriminator tags are deprecated by Discord. Use `displayName` or `username` instead.
|
|
714
|
+
*/
|
|
715
|
+
get tag() {
|
|
716
|
+
return typeof this.username === 'string'
|
|
717
|
+
? this.discriminator === '0' || this.discriminator === '0000'
|
|
718
|
+
? this.username
|
|
719
|
+
: `${this.username}#${this.discriminator}`
|
|
720
|
+
: null;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* The global name of this user, or their username if they don't have one
|
|
725
|
+
* @type {?string}
|
|
726
|
+
* @readonly
|
|
727
|
+
*/
|
|
728
|
+
get displayName() {
|
|
729
|
+
return this.globalName ?? this.username;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* The DM between the client's user and this user
|
|
734
|
+
* @type {?DMChannel}
|
|
735
|
+
* @readonly
|
|
736
|
+
*/
|
|
737
|
+
get dmChannel() {
|
|
738
|
+
return this.client.users.dmChannel(this.id);
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* Creates a DM channel between the client and the user.
|
|
743
|
+
* @param {boolean} [force=false] Whether to skip the cache check and request the API
|
|
744
|
+
* @returns {Promise<DMChannel>}
|
|
745
|
+
*/
|
|
746
|
+
createDM(force = false) {
|
|
747
|
+
return this.client.users.createDM(this.id, force);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* Deletes a DM channel (if one exists) between the client and the user. Resolves with the channel if successful.
|
|
752
|
+
* @returns {Promise<DMChannel>}
|
|
753
|
+
*/
|
|
754
|
+
deleteDM() {
|
|
755
|
+
return this.client.users.deleteDM(this.id);
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* Checks if the user is equal to another.
|
|
760
|
+
* It compares id, username, legacy discriminator, avatar, banner, accent color, and bot flags.
|
|
761
|
+
* It is recommended to compare equality by using `user.id === user2.id` unless you want to compare all properties.
|
|
762
|
+
* @param {User} user User to compare with
|
|
763
|
+
* @returns {boolean}
|
|
764
|
+
*/
|
|
765
|
+
equals(user) {
|
|
766
|
+
return (
|
|
767
|
+
user &&
|
|
768
|
+
this.id === user.id &&
|
|
769
|
+
this.username === user.username &&
|
|
770
|
+
this.discriminator === user.discriminator &&
|
|
771
|
+
this.globalName === user.globalName &&
|
|
772
|
+
this.avatar === user.avatar &&
|
|
773
|
+
this.flags?.bitfield === user.flags?.bitfield &&
|
|
774
|
+
this.banner === user.banner &&
|
|
775
|
+
this.accentColor === user.accentColor &&
|
|
776
|
+
this.bio === user.bio &&
|
|
777
|
+
this.pronouns === user.pronouns &&
|
|
778
|
+
this.premiumSinceTimestamp === user.premiumSinceTimestamp &&
|
|
779
|
+
this.premiumGuildSinceTimestamp === user.premiumGuildSinceTimestamp &&
|
|
780
|
+
this.premiumType === user.premiumType &&
|
|
781
|
+
this.premiumBadge?.id === user.premiumBadge?.id &&
|
|
782
|
+
this.premiumBadge?.asset === user.premiumBadge?.asset &&
|
|
783
|
+
this.premiumBadge?.description === user.premiumBadge?.description &&
|
|
784
|
+
this.legacyUsername === user.legacyUsername &&
|
|
785
|
+
this.avatarDecorationData?.asset === user.avatarDecorationData?.asset &&
|
|
786
|
+
this.avatarDecorationData?.skuId === user.avatarDecorationData?.skuId &&
|
|
787
|
+
this.collectibles?.nameplate?.skuId === user.collectibles?.nameplate?.skuId &&
|
|
788
|
+
this.collectibles?.nameplate?.asset === user.collectibles?.nameplate?.asset &&
|
|
789
|
+
this.collectibles?.nameplate?.label === user.collectibles?.nameplate?.label &&
|
|
790
|
+
this.collectibles?.nameplate?.palette === user.collectibles?.nameplate?.palette &&
|
|
791
|
+
this.primaryGuild?.identityGuildId === user.primaryGuild?.identityGuildId &&
|
|
792
|
+
this.primaryGuild?.identityEnabled === user.primaryGuild?.identityEnabled &&
|
|
793
|
+
this.primaryGuild?.tag === user.primaryGuild?.tag &&
|
|
794
|
+
this.primaryGuild?.badge === user.primaryGuild?.badge &&
|
|
795
|
+
this.mutualGroupsCount === user.mutualGroupsCount
|
|
796
|
+
);
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* Compares the user with an API user object
|
|
801
|
+
* Includes legacy discriminator comparison for compatibility with older payloads.
|
|
802
|
+
* @param {APIUser} user The API user object to compare
|
|
803
|
+
* @returns {boolean}
|
|
804
|
+
* @private
|
|
805
|
+
*/
|
|
806
|
+
_equals(user) {
|
|
807
|
+
return (
|
|
808
|
+
user &&
|
|
809
|
+
this.id === user.id &&
|
|
810
|
+
this.username === user.username &&
|
|
811
|
+
this.discriminator === user.discriminator &&
|
|
812
|
+
this.globalName === user.global_name &&
|
|
813
|
+
this.avatar === user.avatar &&
|
|
814
|
+
this.flags?.bitfield === user.public_flags &&
|
|
815
|
+
('banner' in user ? this.banner === user.banner : true) &&
|
|
816
|
+
('accent_color' in user ? this.accentColor === user.accent_color : true) &&
|
|
817
|
+
('avatar_decoration_data' in user
|
|
818
|
+
? this.avatarDecorationData?.asset === user.avatar_decoration_data?.asset &&
|
|
819
|
+
this.avatarDecorationData?.skuId === user.avatar_decoration_data?.sku_id
|
|
820
|
+
: true) &&
|
|
821
|
+
('collectibles' in user
|
|
822
|
+
? this.collectibles?.nameplate?.skuId === user.collectibles?.nameplate?.sku_id &&
|
|
823
|
+
this.collectibles?.nameplate?.asset === user.collectibles?.nameplate?.asset &&
|
|
824
|
+
this.collectibles?.nameplate?.label === user.collectibles?.nameplate?.label &&
|
|
825
|
+
this.collectibles?.nameplate?.palette === user.collectibles?.nameplate?.palette
|
|
826
|
+
: true) &&
|
|
827
|
+
('primary_guild' in user
|
|
828
|
+
? this.primaryGuild?.identityGuildId === user.primary_guild?.identity_guild_id &&
|
|
829
|
+
this.primaryGuild?.identityEnabled === user.primary_guild?.identity_enabled &&
|
|
830
|
+
this.primaryGuild?.tag === user.primary_guild?.tag &&
|
|
831
|
+
this.primaryGuild?.badge === user.primary_guild?.badge
|
|
832
|
+
: true)
|
|
833
|
+
);
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* Fetches this user.
|
|
838
|
+
* @param {boolean} [force=true] Whether to skip the cache check and request the API
|
|
839
|
+
* @returns {Promise<User>}
|
|
840
|
+
*/
|
|
841
|
+
fetch(force = true) {
|
|
842
|
+
return this.client.users.fetch(this.id, { force });
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* Returns a user profile object for a given user ID.
|
|
847
|
+
* <info>This endpoint requires one of the following:
|
|
848
|
+
* - The user is a bot
|
|
849
|
+
* - The user shares a mutual guild with the current user
|
|
850
|
+
* - The user is a friend of the current user
|
|
851
|
+
* - The user is a friend suggestion of the current user
|
|
852
|
+
* - The user has an outgoing friend request to the current user</info>
|
|
853
|
+
* @param {Snowflake} [guildId] The guild ID to get the user's member profile in
|
|
854
|
+
* @returns {Promise<Object>}
|
|
855
|
+
* @see {@link https://discord-userdoccers.vercel.app/resources/user#response-body}
|
|
856
|
+
*/
|
|
857
|
+
getProfile(guildId) {
|
|
858
|
+
return this.client.api.users(this.id).profile.get({
|
|
859
|
+
query: {
|
|
860
|
+
with_mutual_guilds: true,
|
|
861
|
+
with_mutual_friends: true,
|
|
862
|
+
with_mutual_friends_count: true,
|
|
863
|
+
guild_id: guildId,
|
|
864
|
+
},
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
/**
|
|
869
|
+
* When concatenated with a string, this automatically returns the user's mention instead of the User object.
|
|
870
|
+
* @returns {string}
|
|
871
|
+
* @example
|
|
872
|
+
* // Logs: Hello from <@123456789012345678>!
|
|
873
|
+
* console.log(`Hello from ${user}!`);
|
|
874
|
+
*/
|
|
875
|
+
toString() {
|
|
876
|
+
return `<@${this.id}>`;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
toJSON(...props) {
|
|
880
|
+
const json = super.toJSON(
|
|
881
|
+
{
|
|
882
|
+
createdTimestamp: true,
|
|
883
|
+
defaultAvatarURL: true,
|
|
884
|
+
hexAccentColor: true,
|
|
885
|
+
tag: true,
|
|
886
|
+
},
|
|
887
|
+
...props,
|
|
888
|
+
);
|
|
889
|
+
json.avatarURL = this.avatarURL();
|
|
890
|
+
json.displayAvatarURL = this.displayAvatarURL();
|
|
891
|
+
json.bannerURL = this.banner ? this.bannerURL() : this.banner;
|
|
892
|
+
json.guildTagBadgeURL = this.guildTagBadgeURL();
|
|
893
|
+
json.nitroName = this.nitroName;
|
|
894
|
+
json.currentTenureMonths = this.currentTenureMonths;
|
|
895
|
+
json.nextBadgeMilestone = this.nextBadgeMilestone;
|
|
896
|
+
json.daysUntilNextBadge = this.daysUntilNextBadge;
|
|
897
|
+
json.nitroTenure = this.nitroTenure;
|
|
898
|
+
return json;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* The function updates the note of a user and returns the updated user.
|
|
903
|
+
* @param {string|null|undefined} [note=null] - The `note` parameter is the new value that you want to set for the note of the
|
|
904
|
+
* user. It is an optional parameter and its default value is `null`.
|
|
905
|
+
* @returns {Promise<User>} The `setNote` method is returning the `User` object.
|
|
906
|
+
*/
|
|
907
|
+
async setNote(note = null) {
|
|
908
|
+
await this.client.notes.updateNote(this.id, note);
|
|
909
|
+
return this;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
/**
|
|
913
|
+
* The function returns the note associated with a specific client ID from a cache.
|
|
914
|
+
* @type {?string} The note that corresponds to the given id.
|
|
915
|
+
*/
|
|
916
|
+
get note() {
|
|
917
|
+
return this.client.notes.cache.get(this.id);
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* The voice state of this member
|
|
922
|
+
* @type {VoiceState}
|
|
923
|
+
* @readonly
|
|
924
|
+
*/
|
|
925
|
+
get voice() {
|
|
926
|
+
return (
|
|
927
|
+
this.client.voiceStates.cache.get(this.id) ??
|
|
928
|
+
this.client.guilds.cache.find(g => g?.voiceStates?.cache?.get(this.id))?.voiceStates?.cache?.get(this.id) ??
|
|
929
|
+
new VoiceState({ client: this.client }, { user_id: this.id })
|
|
930
|
+
);
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
/**
|
|
934
|
+
* Send Friend Request to the user
|
|
935
|
+
* @type {boolean}
|
|
936
|
+
* @returns {Promise<boolean>}
|
|
937
|
+
*/
|
|
938
|
+
sendFriendRequest() {
|
|
939
|
+
return this.client.relationships.sendFriendRequest(this);
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* Unblock / Unfriend / Cancels a friend request
|
|
944
|
+
* @type {boolean}
|
|
945
|
+
* @returns {Promise<boolean>}
|
|
946
|
+
*/
|
|
947
|
+
deleteRelationship() {
|
|
948
|
+
return this.client.relationships.deleteRelationship(this);
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
/**
|
|
952
|
+
* Check relationship status (Client -> User)
|
|
953
|
+
* @type {RelationshipType}
|
|
954
|
+
* @readonly
|
|
955
|
+
*/
|
|
956
|
+
get relationship() {
|
|
957
|
+
const i = this.client.relationships.cache.get(this.id) ?? 0;
|
|
958
|
+
return RelationshipTypes[parseInt(i)];
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Get friend nickname
|
|
963
|
+
* @type {?string}
|
|
964
|
+
* @readonly
|
|
965
|
+
*/
|
|
966
|
+
get friendNickname() {
|
|
967
|
+
return this.client.relationships.friendNicknames.get(this.id);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* Sends a message to this user.
|
|
973
|
+
* @method send
|
|
974
|
+
* @memberof User
|
|
975
|
+
* @instance
|
|
976
|
+
* @param {string|MessagePayload|MessageOptions} options The options to provide
|
|
977
|
+
* @returns {Promise<Message>}
|
|
978
|
+
* @example
|
|
979
|
+
* // Send a direct message
|
|
980
|
+
* user.send('Hello!')
|
|
981
|
+
* .then(message => console.log(`Sent message: ${message.content} to ${user.displayName}`))
|
|
982
|
+
* .catch(console.error);
|
|
983
|
+
*/
|
|
984
|
+
|
|
985
|
+
TextBasedChannel.applyToClass(User);
|
|
986
|
+
|
|
987
|
+
module.exports = User;
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* @external APIUser
|
|
991
|
+
* @see {@link https://discord.com/developers/docs/resources/user#user-object}
|
|
992
|
+
*/
|