@velliajs/discord 1.0.0
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 +133 -0
- package/package.json +82 -0
- package/src/client/BaseClient.js +83 -0
- package/src/client/Client.js +591 -0
- package/src/client/WebhookClient.js +103 -0
- package/src/client/actions/Action.js +119 -0
- package/src/client/actions/ActionsManager.js +79 -0
- package/src/client/actions/ApplicationCommandPermissionsUpdate.js +34 -0
- package/src/client/actions/AutoModerationActionExecution.js +26 -0
- package/src/client/actions/AutoModerationRuleCreate.js +27 -0
- package/src/client/actions/AutoModerationRuleDelete.js +31 -0
- package/src/client/actions/AutoModerationRuleUpdate.js +29 -0
- package/src/client/actions/ChannelCreate.js +23 -0
- package/src/client/actions/ChannelDelete.js +23 -0
- package/src/client/actions/ChannelUpdate.js +33 -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 +44 -0
- package/src/client/actions/GuildEmojiCreate.js +20 -0
- package/src/client/actions/GuildEmojiDelete.js +19 -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 +31 -0
- package/src/client/actions/GuildMemberUpdate.js +44 -0
- package/src/client/actions/GuildRoleCreate.js +25 -0
- package/src/client/actions/GuildRoleDelete.js +29 -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 +19 -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/InteractionCreate.js +101 -0
- package/src/client/actions/InviteCreate.js +28 -0
- package/src/client/actions/InviteDelete.js +30 -0
- package/src/client/actions/MessageCreate.js +37 -0
- package/src/client/actions/MessageDelete.js +32 -0
- package/src/client/actions/MessageDeleteBulk.js +47 -0
- package/src/client/actions/MessageReactionAdd.js +55 -0
- package/src/client/actions/MessageReactionRemove.js +45 -0
- package/src/client/actions/MessageReactionRemoveAll.js +33 -0
- package/src/client/actions/MessageReactionRemoveEmoji.js +28 -0
- package/src/client/actions/MessageUpdate.js +26 -0
- package/src/client/actions/PresenceUpdate.js +42 -0
- package/src/client/actions/StageInstanceCreate.js +28 -0
- package/src/client/actions/StageInstanceDelete.js +31 -0
- package/src/client/actions/StageInstanceUpdate.js +30 -0
- package/src/client/actions/ThreadCreate.js +24 -0
- package/src/client/actions/ThreadDelete.js +26 -0
- package/src/client/actions/ThreadListSync.js +60 -0
- package/src/client/actions/ThreadMemberUpdate.js +30 -0
- package/src/client/actions/ThreadMembersUpdate.js +47 -0
- package/src/client/actions/TypingStart.js +29 -0
- package/src/client/actions/UserUpdate.js +36 -0
- package/src/client/actions/VoiceStateUpdate.js +43 -0
- package/src/client/actions/WebhooksUpdate.js +20 -0
- package/src/client/voice/ClientVoiceManager.js +44 -0
- package/src/client/websocket/WebSocketManager.js +393 -0
- package/src/client/websocket/WebSocketShard.js +231 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_PERMISSIONS_UPDATE.js +5 -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/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_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 +26 -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 +39 -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_CREATE.js +5 -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_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 +27 -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_UPDATE.js +5 -0
- package/src/client/websocket/handlers/VOICE_SERVER_UPDATE.js +6 -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 +64 -0
- package/src/errors/DJSError.js +48 -0
- package/src/errors/ErrorCodes.js +319 -0
- package/src/errors/Messages.js +170 -0
- package/src/errors/index.js +5 -0
- package/src/index.js +213 -0
- package/src/managers/ApplicationCommandManager.js +263 -0
- package/src/managers/ApplicationCommandPermissionsManager.js +434 -0
- package/src/managers/AutoModerationRuleManager.js +288 -0
- package/src/managers/BaseGuildEmojiManager.js +80 -0
- package/src/managers/BaseManager.js +19 -0
- package/src/managers/CachedManager.js +57 -0
- package/src/managers/CategoryChannelChildManager.js +77 -0
- package/src/managers/ChannelManager.js +128 -0
- package/src/managers/DataManager.js +61 -0
- package/src/managers/GuildApplicationCommandManager.js +28 -0
- package/src/managers/GuildBanManager.js +204 -0
- package/src/managers/GuildChannelManager.js +494 -0
- package/src/managers/GuildEmojiManager.js +174 -0
- package/src/managers/GuildEmojiRoleManager.js +118 -0
- package/src/managers/GuildForumThreadManager.js +83 -0
- package/src/managers/GuildInviteManager.js +213 -0
- package/src/managers/GuildManager.js +283 -0
- package/src/managers/GuildMemberManager.js +540 -0
- package/src/managers/GuildMemberRoleManager.js +204 -0
- package/src/managers/GuildScheduledEventManager.js +297 -0
- package/src/managers/GuildStickerManager.js +182 -0
- package/src/managers/GuildTextThreadManager.js +91 -0
- package/src/managers/MessageManager.js +259 -0
- package/src/managers/PermissionOverwriteManager.js +168 -0
- package/src/managers/PresenceManager.js +58 -0
- package/src/managers/ReactionManager.js +68 -0
- package/src/managers/ReactionUserManager.js +77 -0
- package/src/managers/RoleManager.js +360 -0
- package/src/managers/StageInstanceManager.js +154 -0
- package/src/managers/ThreadManager.js +204 -0
- package/src/managers/ThreadMemberManager.js +182 -0
- package/src/managers/UserManager.js +139 -0
- package/src/managers/VoiceStateManager.js +37 -0
- package/src/sharding/Shard.js +457 -0
- package/src/sharding/ShardClientUtil.js +285 -0
- package/src/sharding/ShardingManager.js +326 -0
- package/src/structures/ActionRow.js +46 -0
- package/src/structures/ActionRowBuilder.js +35 -0
- package/src/structures/AnonymousGuild.js +97 -0
- package/src/structures/ApplicationCommand.js +606 -0
- package/src/structures/ApplicationRoleConnectionMetadata.js +46 -0
- package/src/structures/Attachment.js +140 -0
- package/src/structures/AttachmentBuilder.js +116 -0
- package/src/structures/AutoModerationActionExecution.js +116 -0
- package/src/structures/AutoModerationRule.js +284 -0
- package/src/structures/AutocompleteInteraction.js +97 -0
- package/src/structures/Base.js +43 -0
- package/src/structures/BaseChannel.js +160 -0
- package/src/structures/BaseGuild.js +119 -0
- package/src/structures/BaseGuildEmoji.js +56 -0
- package/src/structures/BaseGuildTextChannel.js +186 -0
- package/src/structures/BaseGuildVoiceChannel.js +234 -0
- package/src/structures/BaseInteraction.js +344 -0
- package/src/structures/BaseSelectMenuComponent.js +56 -0
- package/src/structures/ButtonBuilder.js +44 -0
- package/src/structures/ButtonComponent.js +65 -0
- package/src/structures/ButtonInteraction.js +11 -0
- package/src/structures/CategoryChannel.js +45 -0
- package/src/structures/ChannelSelectMenuBuilder.js +31 -0
- package/src/structures/ChannelSelectMenuComponent.js +20 -0
- package/src/structures/ChannelSelectMenuInteraction.js +33 -0
- package/src/structures/ChatInputCommandInteraction.js +41 -0
- package/src/structures/ClientApplication.js +193 -0
- package/src/structures/ClientPresence.js +82 -0
- package/src/structures/ClientUser.js +185 -0
- package/src/structures/CommandInteraction.js +224 -0
- package/src/structures/CommandInteractionOptionResolver.js +308 -0
- package/src/structures/Component.js +47 -0
- package/src/structures/ContextMenuCommandInteraction.js +64 -0
- package/src/structures/DMChannel.js +129 -0
- package/src/structures/DirectoryChannel.js +36 -0
- package/src/structures/Embed.js +220 -0
- package/src/structures/EmbedBuilder.js +41 -0
- package/src/structures/Emoji.js +108 -0
- package/src/structures/ForumChannel.js +264 -0
- package/src/structures/Guild.js +1361 -0
- package/src/structures/GuildAuditLogs.js +91 -0
- package/src/structures/GuildAuditLogsEntry.js +527 -0
- package/src/structures/GuildBan.js +59 -0
- package/src/structures/GuildChannel.js +457 -0
- package/src/structures/GuildEmoji.js +148 -0
- package/src/structures/GuildMember.js +518 -0
- package/src/structures/GuildPreview.js +193 -0
- package/src/structures/GuildPreviewEmoji.js +27 -0
- package/src/structures/GuildScheduledEvent.js +439 -0
- package/src/structures/GuildTemplate.js +241 -0
- package/src/structures/Integration.js +220 -0
- package/src/structures/IntegrationApplication.js +85 -0
- package/src/structures/InteractionCollector.js +263 -0
- package/src/structures/InteractionResponse.js +102 -0
- package/src/structures/InteractionWebhook.js +59 -0
- package/src/structures/Invite.js +322 -0
- package/src/structures/InviteGuild.js +22 -0
- package/src/structures/InviteStageInstance.js +87 -0
- package/src/structures/MentionableSelectMenuBuilder.js +32 -0
- package/src/structures/MentionableSelectMenuComponent.js +11 -0
- package/src/structures/MentionableSelectMenuInteraction.js +71 -0
- package/src/structures/Message.js +997 -0
- package/src/structures/MessageCollector.js +146 -0
- package/src/structures/MessageComponentInteraction.js +107 -0
- package/src/structures/MessageContextMenuCommandInteraction.js +20 -0
- package/src/structures/MessageMentions.js +297 -0
- package/src/structures/MessagePayload.js +299 -0
- package/src/structures/MessageReaction.js +142 -0
- package/src/structures/ModalBuilder.js +34 -0
- package/src/structures/ModalSubmitFields.js +55 -0
- package/src/structures/ModalSubmitInteraction.js +121 -0
- package/src/structures/NewsChannel.js +32 -0
- package/src/structures/OAuth2Guild.js +28 -0
- package/src/structures/PartialGroupDMChannel.js +60 -0
- package/src/structures/PermissionOverwrites.js +196 -0
- package/src/structures/Presence.js +372 -0
- package/src/structures/ReactionCollector.js +229 -0
- package/src/structures/ReactionEmoji.js +31 -0
- package/src/structures/Role.js +458 -0
- package/src/structures/RoleSelectMenuBuilder.js +31 -0
- package/src/structures/RoleSelectMenuComponent.js +11 -0
- package/src/structures/RoleSelectMenuInteraction.js +33 -0
- package/src/structures/SelectMenuBuilder.js +26 -0
- package/src/structures/SelectMenuComponent.js +26 -0
- package/src/structures/SelectMenuInteraction.js +26 -0
- package/src/structures/SelectMenuOptionBuilder.js +26 -0
- package/src/structures/StageChannel.js +112 -0
- package/src/structures/StageInstance.js +167 -0
- package/src/structures/Sticker.js +272 -0
- package/src/structures/StickerPack.js +95 -0
- package/src/structures/StringSelectMenuBuilder.js +79 -0
- package/src/structures/StringSelectMenuComponent.js +20 -0
- package/src/structures/StringSelectMenuInteraction.js +21 -0
- package/src/structures/StringSelectMenuOptionBuilder.js +49 -0
- package/src/structures/Team.js +117 -0
- package/src/structures/TeamMember.js +70 -0
- package/src/structures/TextChannel.js +33 -0
- package/src/structures/TextInputBuilder.js +31 -0
- package/src/structures/TextInputComponent.js +29 -0
- package/src/structures/ThreadChannel.js +606 -0
- package/src/structures/ThreadMember.js +113 -0
- package/src/structures/Typing.js +74 -0
- package/src/structures/User.js +331 -0
- package/src/structures/UserContextMenuCommandInteraction.js +29 -0
- package/src/structures/UserSelectMenuBuilder.js +31 -0
- package/src/structures/UserSelectMenuComponent.js +11 -0
- package/src/structures/UserSelectMenuInteraction.js +51 -0
- package/src/structures/VoiceChannel.js +96 -0
- package/src/structures/VoiceRegion.js +46 -0
- package/src/structures/VoiceState.js +303 -0
- package/src/structures/Webhook.js +481 -0
- package/src/structures/WelcomeChannel.js +60 -0
- package/src/structures/WelcomeScreen.js +49 -0
- package/src/structures/Widget.js +88 -0
- package/src/structures/WidgetMember.js +99 -0
- package/src/structures/interfaces/Application.js +108 -0
- package/src/structures/interfaces/Collector.js +335 -0
- package/src/structures/interfaces/InteractionResponses.js +320 -0
- package/src/structures/interfaces/TextBasedChannel.js +413 -0
- package/src/util/APITypes.js +456 -0
- package/src/util/ActivityFlagsBitField.js +26 -0
- package/src/util/ApplicationFlagsBitField.js +26 -0
- package/src/util/BitField.js +176 -0
- package/src/util/ChannelFlagsBitField.js +41 -0
- package/src/util/Channels.js +150 -0
- package/src/util/Colors.js +73 -0
- package/src/util/Components.js +152 -0
- package/src/util/Constants.js +230 -0
- package/src/util/DataResolver.js +140 -0
- package/src/util/Enums.js +13 -0
- package/src/util/Events.js +160 -0
- package/src/util/Formatters.js +413 -0
- package/src/util/GuildMemberFlagsBitField.js +41 -0
- package/src/util/IntentsBitField.js +34 -0
- package/src/util/LimitedCollection.js +68 -0
- package/src/util/MessageFlagsBitField.js +32 -0
- package/src/util/Options.js +216 -0
- package/src/util/Partials.js +44 -0
- package/src/util/PermissionsBitField.js +104 -0
- package/src/util/ShardEvents.js +27 -0
- package/src/util/Status.js +33 -0
- package/src/util/Sweepers.js +467 -0
- package/src/util/SystemChannelFlagsBitField.js +43 -0
- package/src/util/ThreadMemberFlagsBitField.js +31 -0
- package/src/util/Transformers.js +36 -0
- package/src/util/UserFlagsBitField.js +32 -0
- package/src/util/Util.js +394 -0
- package/src/util/WebSocketShardEvents.js +25 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const BaseGuild = require('./BaseGuild');
|
|
4
|
+
const PermissionsBitField = require('../util/PermissionsBitField');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A partial guild received when using {@link GuildManager#fetch} to fetch multiple guilds.
|
|
8
|
+
* @extends {BaseGuild}
|
|
9
|
+
*/
|
|
10
|
+
class OAuth2Guild extends BaseGuild {
|
|
11
|
+
constructor(client, data) {
|
|
12
|
+
super(client, data);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Whether the client user is the owner of the guild
|
|
16
|
+
* @type {boolean}
|
|
17
|
+
*/
|
|
18
|
+
this.owner = data.owner;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The permissions that the client user has in this guild
|
|
22
|
+
* @type {Readonly<PermissionsBitField>}
|
|
23
|
+
*/
|
|
24
|
+
this.permissions = new PermissionsBitField(BigInt(data.permissions)).freeze();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = OAuth2Guild;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { BaseChannel } = require('./BaseChannel');
|
|
4
|
+
const { DiscordjsError, ErrorCodes } = require('../errors');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents a Partial Group DM Channel on Discord.
|
|
8
|
+
* @extends {BaseChannel}
|
|
9
|
+
*/
|
|
10
|
+
class PartialGroupDMChannel extends BaseChannel {
|
|
11
|
+
constructor(client, data) {
|
|
12
|
+
super(client, data);
|
|
13
|
+
|
|
14
|
+
// No flags are present when fetching partial group DM channels.
|
|
15
|
+
this.flags = null;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The name of this Group DM Channel
|
|
19
|
+
* @type {?string}
|
|
20
|
+
*/
|
|
21
|
+
this.name = data.name;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The hash of the channel icon
|
|
25
|
+
* @type {?string}
|
|
26
|
+
*/
|
|
27
|
+
this.icon = data.icon;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Recipient data received in a {@link PartialGroupDMChannel}.
|
|
31
|
+
* @typedef {Object} PartialRecipient
|
|
32
|
+
* @property {string} username The username of the recipient
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The recipients of this Group DM Channel.
|
|
37
|
+
* @type {PartialRecipient[]}
|
|
38
|
+
*/
|
|
39
|
+
this.recipients = data.recipients;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The URL to this channel's icon.
|
|
44
|
+
* @param {ImageURLOptions} [options={}] Options for the image URL
|
|
45
|
+
* @returns {?string}
|
|
46
|
+
*/
|
|
47
|
+
iconURL(options = {}) {
|
|
48
|
+
return this.icon && this.client.rest.cdn.channelIcon(this.id, this.icon, options);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
delete() {
|
|
52
|
+
return Promise.reject(new DiscordjsError(ErrorCodes.DeleteGroupDMChannel));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
fetch() {
|
|
56
|
+
return Promise.reject(new DiscordjsError(ErrorCodes.FetchGroupDMChannel));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
module.exports = PartialGroupDMChannel;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { OverwriteType } = require('discord-api-types/v10');
|
|
4
|
+
const Base = require('./Base');
|
|
5
|
+
const { Role } = require('./Role');
|
|
6
|
+
const { DiscordjsTypeError, ErrorCodes } = require('../errors');
|
|
7
|
+
const PermissionsBitField = require('../util/PermissionsBitField');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Represents a permission overwrite for a role or member in a guild channel.
|
|
11
|
+
* @extends {Base}
|
|
12
|
+
*/
|
|
13
|
+
class PermissionOverwrites extends Base {
|
|
14
|
+
constructor(client, data, channel) {
|
|
15
|
+
super(client);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The GuildChannel this overwrite is for
|
|
19
|
+
* @name PermissionOverwrites#channel
|
|
20
|
+
* @type {GuildChannel}
|
|
21
|
+
* @readonly
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(this, 'channel', { value: channel });
|
|
24
|
+
|
|
25
|
+
if (data) this._patch(data);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
_patch(data) {
|
|
29
|
+
/**
|
|
30
|
+
* The overwrite's id, either a {@link User} or a {@link Role} id
|
|
31
|
+
* @type {Snowflake}
|
|
32
|
+
*/
|
|
33
|
+
this.id = data.id;
|
|
34
|
+
|
|
35
|
+
if ('type' in data) {
|
|
36
|
+
/**
|
|
37
|
+
* The type of this overwrite
|
|
38
|
+
* @type {OverwriteType}
|
|
39
|
+
*/
|
|
40
|
+
this.type = data.type;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if ('deny' in data) {
|
|
44
|
+
/**
|
|
45
|
+
* The permissions that are denied for the user or role.
|
|
46
|
+
* @type {Readonly<PermissionsBitField>}
|
|
47
|
+
*/
|
|
48
|
+
this.deny = new PermissionsBitField(BigInt(data.deny)).freeze();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if ('allow' in data) {
|
|
52
|
+
/**
|
|
53
|
+
* The permissions that are allowed for the user or role.
|
|
54
|
+
* @type {Readonly<PermissionsBitField>}
|
|
55
|
+
*/
|
|
56
|
+
this.allow = new PermissionsBitField(BigInt(data.allow)).freeze();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Edits this Permission Overwrite.
|
|
62
|
+
* @param {PermissionOverwriteOptions} options The options for the update
|
|
63
|
+
* @param {string} [reason] Reason for creating/editing this overwrite
|
|
64
|
+
* @returns {Promise<PermissionOverwrites>}
|
|
65
|
+
* @example
|
|
66
|
+
* // Update permission overwrites
|
|
67
|
+
* permissionOverwrites.edit({
|
|
68
|
+
* SendMessages: false
|
|
69
|
+
* })
|
|
70
|
+
* .then(channel => console.log(channel.permissionOverwrites.get(message.author.id)))
|
|
71
|
+
* .catch(console.error);
|
|
72
|
+
*/
|
|
73
|
+
async edit(options, reason) {
|
|
74
|
+
await this.channel.permissionOverwrites.upsert(this.id, options, { type: this.type, reason }, this);
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Deletes this Permission Overwrite.
|
|
80
|
+
* @param {string} [reason] Reason for deleting this overwrite
|
|
81
|
+
* @returns {Promise<PermissionOverwrites>}
|
|
82
|
+
*/
|
|
83
|
+
async delete(reason) {
|
|
84
|
+
await this.channel.permissionOverwrites.delete(this.id, reason);
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
toJSON() {
|
|
89
|
+
return {
|
|
90
|
+
id: this.id,
|
|
91
|
+
type: this.type,
|
|
92
|
+
allow: this.allow,
|
|
93
|
+
deny: this.deny,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* An object mapping permission flags to `true` (enabled), `null` (unset) or `false` (disabled).
|
|
99
|
+
* ```js
|
|
100
|
+
* {
|
|
101
|
+
* 'SendMessages': true,
|
|
102
|
+
* 'EmbedLinks': null,
|
|
103
|
+
* 'AttachFiles': false,
|
|
104
|
+
* }
|
|
105
|
+
* ```
|
|
106
|
+
* @typedef {Object} PermissionOverwriteOptions
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @typedef {Object} ResolvedOverwriteOptions
|
|
111
|
+
* @property {PermissionsBitField} allow The allowed permissions
|
|
112
|
+
* @property {PermissionsBitField} deny The denied permissions
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Resolves bitfield permissions overwrites from an object.
|
|
117
|
+
* @param {PermissionOverwriteOptions} options The options for the update
|
|
118
|
+
* @param {ResolvedOverwriteOptions} initialPermissions The initial permissions
|
|
119
|
+
* @returns {ResolvedOverwriteOptions}
|
|
120
|
+
*/
|
|
121
|
+
static resolveOverwriteOptions(options, { allow, deny } = {}) {
|
|
122
|
+
allow = new PermissionsBitField(allow);
|
|
123
|
+
deny = new PermissionsBitField(deny);
|
|
124
|
+
|
|
125
|
+
for (const [perm, value] of Object.entries(options)) {
|
|
126
|
+
if (value === true) {
|
|
127
|
+
allow.add(perm);
|
|
128
|
+
deny.remove(perm);
|
|
129
|
+
} else if (value === false) {
|
|
130
|
+
allow.remove(perm);
|
|
131
|
+
deny.add(perm);
|
|
132
|
+
} else if (value === null) {
|
|
133
|
+
allow.remove(perm);
|
|
134
|
+
deny.remove(perm);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return { allow, deny };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The raw data for a permission overwrite
|
|
143
|
+
* @typedef {Object} RawOverwriteData
|
|
144
|
+
* @property {Snowflake} id The id of the {@link Role} or {@link User} this overwrite belongs to
|
|
145
|
+
* @property {string} allow The permissions to allow
|
|
146
|
+
* @property {string} deny The permissions to deny
|
|
147
|
+
* @property {number} type The type of this OverwriteData
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Data that can be resolved into {@link RawOverwriteData}. This can be:
|
|
152
|
+
* * PermissionOverwrites
|
|
153
|
+
* * OverwriteData
|
|
154
|
+
* @typedef {PermissionOverwrites|OverwriteData} OverwriteResolvable
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Data that can be used for a permission overwrite
|
|
159
|
+
* @typedef {Object} OverwriteData
|
|
160
|
+
* @property {GuildMemberResolvable|RoleResolvable} id Member or role this overwrite is for
|
|
161
|
+
* @property {PermissionResolvable} [allow] The permissions to allow
|
|
162
|
+
* @property {PermissionResolvable} [deny] The permissions to deny
|
|
163
|
+
* @property {OverwriteType} [type] The type of this OverwriteData
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Resolves an overwrite into {@link RawOverwriteData}.
|
|
168
|
+
* @param {OverwriteResolvable} overwrite The overwrite-like data to resolve
|
|
169
|
+
* @param {Guild} [guild] The guild to resolve from
|
|
170
|
+
* @returns {RawOverwriteData}
|
|
171
|
+
*/
|
|
172
|
+
static resolve(overwrite, guild) {
|
|
173
|
+
if (overwrite instanceof this) return overwrite.toJSON();
|
|
174
|
+
if (typeof overwrite.id === 'string' && overwrite.type in OverwriteType) {
|
|
175
|
+
return {
|
|
176
|
+
id: overwrite.id,
|
|
177
|
+
type: overwrite.type,
|
|
178
|
+
allow: PermissionsBitField.resolve(overwrite.allow ?? PermissionsBitField.DefaultBit).toString(),
|
|
179
|
+
deny: PermissionsBitField.resolve(overwrite.deny ?? PermissionsBitField.DefaultBit).toString(),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const userOrRole = guild.roles.resolve(overwrite.id) ?? guild.client.users.resolve(overwrite.id);
|
|
184
|
+
if (!userOrRole) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'parameter', 'User nor a Role');
|
|
185
|
+
const type = userOrRole instanceof Role ? OverwriteType.Role : OverwriteType.Member;
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
id: userOrRole.id,
|
|
189
|
+
type,
|
|
190
|
+
allow: PermissionsBitField.resolve(overwrite.allow ?? PermissionsBitField.DefaultBit).toString(),
|
|
191
|
+
deny: PermissionsBitField.resolve(overwrite.deny ?? PermissionsBitField.DefaultBit).toString(),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
module.exports = PermissionOverwrites;
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const Base = require('./Base');
|
|
4
|
+
const { Emoji } = require('./Emoji');
|
|
5
|
+
const ActivityFlagsBitField = require('../util/ActivityFlagsBitField');
|
|
6
|
+
const { flatten } = require('../util/Util');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Activity sent in a message.
|
|
10
|
+
* @typedef {Object} MessageActivity
|
|
11
|
+
* @property {string} [partyId] Id of the party represented in activity
|
|
12
|
+
* @property {MessageActivityType} type Type of activity sent
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The status of this presence:
|
|
17
|
+
* * **`online`** - user is online
|
|
18
|
+
* * **`idle`** - user is AFK
|
|
19
|
+
* * **`offline`** - user is offline or invisible
|
|
20
|
+
* * **`dnd`** - user is in Do Not Disturb
|
|
21
|
+
* @typedef {string} PresenceStatus
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The status of this presence:
|
|
26
|
+
* * **`online`** - user is online
|
|
27
|
+
* * **`idle`** - user is AFK
|
|
28
|
+
* * **`dnd`** - user is in Do Not Disturb
|
|
29
|
+
* @typedef {string} ClientPresenceStatus
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Represents a user's presence.
|
|
34
|
+
* @extends {Base}
|
|
35
|
+
*/
|
|
36
|
+
class Presence extends Base {
|
|
37
|
+
constructor(client, data = {}) {
|
|
38
|
+
super(client);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The presence's user id
|
|
42
|
+
* @type {Snowflake}
|
|
43
|
+
*/
|
|
44
|
+
this.userId = data.user.id;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The guild this presence is in
|
|
48
|
+
* @type {?Guild}
|
|
49
|
+
*/
|
|
50
|
+
this.guild = data.guild ?? null;
|
|
51
|
+
|
|
52
|
+
this._patch(data);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The user of this presence
|
|
57
|
+
* @type {?User}
|
|
58
|
+
* @readonly
|
|
59
|
+
*/
|
|
60
|
+
get user() {
|
|
61
|
+
return this.client.users.resolve(this.userId);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The member of this presence
|
|
66
|
+
* @type {?GuildMember}
|
|
67
|
+
* @readonly
|
|
68
|
+
*/
|
|
69
|
+
get member() {
|
|
70
|
+
return this.guild.members.resolve(this.userId);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
_patch(data) {
|
|
74
|
+
if ('status' in data) {
|
|
75
|
+
/**
|
|
76
|
+
* The status of this presence
|
|
77
|
+
* @type {PresenceStatus}
|
|
78
|
+
*/
|
|
79
|
+
this.status = data.status;
|
|
80
|
+
} else {
|
|
81
|
+
this.status ??= 'offline';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if ('activities' in data) {
|
|
85
|
+
/**
|
|
86
|
+
* The activities of this presence
|
|
87
|
+
* @type {Activity[]}
|
|
88
|
+
*/
|
|
89
|
+
this.activities = data.activities.map(activity => new Activity(this, activity));
|
|
90
|
+
} else {
|
|
91
|
+
this.activities ??= [];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if ('client_status' in data) {
|
|
95
|
+
/**
|
|
96
|
+
* The devices this presence is on
|
|
97
|
+
* @type {?Object}
|
|
98
|
+
* @property {?ClientPresenceStatus} web The current presence in the web application
|
|
99
|
+
* @property {?ClientPresenceStatus} mobile The current presence in the mobile application
|
|
100
|
+
* @property {?ClientPresenceStatus} desktop The current presence in the desktop application
|
|
101
|
+
*/
|
|
102
|
+
this.clientStatus = data.client_status;
|
|
103
|
+
} else {
|
|
104
|
+
this.clientStatus ??= null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
_clone() {
|
|
111
|
+
const clone = Object.assign(Object.create(this), this);
|
|
112
|
+
clone.activities = this.activities.map(activity => activity._clone());
|
|
113
|
+
return clone;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Whether this presence is equal to another.
|
|
118
|
+
* @param {Presence} presence The presence to compare with
|
|
119
|
+
* @returns {boolean}
|
|
120
|
+
*/
|
|
121
|
+
equals(presence) {
|
|
122
|
+
return (
|
|
123
|
+
this === presence ||
|
|
124
|
+
(presence &&
|
|
125
|
+
this.status === presence.status &&
|
|
126
|
+
this.activities.length === presence.activities.length &&
|
|
127
|
+
this.activities.every((activity, index) => activity.equals(presence.activities[index])) &&
|
|
128
|
+
this.clientStatus?.web === presence.clientStatus?.web &&
|
|
129
|
+
this.clientStatus?.mobile === presence.clientStatus?.mobile &&
|
|
130
|
+
this.clientStatus?.desktop === presence.clientStatus?.desktop)
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
toJSON() {
|
|
135
|
+
return flatten(this);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Represents an activity that is part of a user's presence.
|
|
141
|
+
*/
|
|
142
|
+
class Activity {
|
|
143
|
+
constructor(presence, data) {
|
|
144
|
+
/**
|
|
145
|
+
* The presence of the Activity
|
|
146
|
+
* @type {Presence}
|
|
147
|
+
* @readonly
|
|
148
|
+
* @name Activity#presence
|
|
149
|
+
*/
|
|
150
|
+
Object.defineProperty(this, 'presence', { value: presence });
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The activity's name
|
|
154
|
+
* @type {string}
|
|
155
|
+
*/
|
|
156
|
+
this.name = data.name;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* The activity status's type
|
|
160
|
+
* @type {ActivityType}
|
|
161
|
+
*/
|
|
162
|
+
this.type = data.type;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* If the activity is being streamed, a link to the stream
|
|
166
|
+
* @type {?string}
|
|
167
|
+
*/
|
|
168
|
+
this.url = data.url ?? null;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Details about the activity
|
|
172
|
+
* @type {?string}
|
|
173
|
+
*/
|
|
174
|
+
this.details = data.details ?? null;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* State of the activity
|
|
178
|
+
* @type {?string}
|
|
179
|
+
*/
|
|
180
|
+
this.state = data.state ?? null;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* The id of the application associated with this activity
|
|
184
|
+
* @type {?Snowflake}
|
|
185
|
+
*/
|
|
186
|
+
this.applicationId = data.application_id ?? null;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Represents timestamps of an activity
|
|
190
|
+
* @typedef {Object} ActivityTimestamps
|
|
191
|
+
* @property {?Date} start When the activity started
|
|
192
|
+
* @property {?Date} end When the activity will end
|
|
193
|
+
*/
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Timestamps for the activity
|
|
197
|
+
* @type {?ActivityTimestamps}
|
|
198
|
+
*/
|
|
199
|
+
this.timestamps = data.timestamps
|
|
200
|
+
? {
|
|
201
|
+
start: data.timestamps.start ? new Date(Number(data.timestamps.start)) : null,
|
|
202
|
+
end: data.timestamps.end ? new Date(Number(data.timestamps.end)) : null,
|
|
203
|
+
}
|
|
204
|
+
: null;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Represents a party of an activity
|
|
208
|
+
* @typedef {Object} ActivityParty
|
|
209
|
+
* @property {?string} id The party's id
|
|
210
|
+
* @property {number[]} size Size of the party as `[current, max]`
|
|
211
|
+
*/
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Party of the activity
|
|
215
|
+
* @type {?ActivityParty}
|
|
216
|
+
*/
|
|
217
|
+
this.party = data.party ?? null;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Assets for rich presence
|
|
221
|
+
* @type {?RichPresenceAssets}
|
|
222
|
+
*/
|
|
223
|
+
this.assets = data.assets ? new RichPresenceAssets(this, data.assets) : null;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Flags that describe the activity
|
|
227
|
+
* @type {Readonly<ActivityFlagsBitField>}
|
|
228
|
+
*/
|
|
229
|
+
this.flags = new ActivityFlagsBitField(data.flags).freeze();
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Emoji for a custom activity
|
|
233
|
+
* @type {?Emoji}
|
|
234
|
+
*/
|
|
235
|
+
this.emoji = data.emoji ? new Emoji(presence.client, data.emoji) : null;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* The labels of the buttons of this rich presence
|
|
239
|
+
* @type {string[]}
|
|
240
|
+
*/
|
|
241
|
+
this.buttons = data.buttons ?? [];
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Creation date of the activity
|
|
245
|
+
* @type {number}
|
|
246
|
+
*/
|
|
247
|
+
this.createdTimestamp = data.created_at;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Whether this activity is equal to another activity.
|
|
252
|
+
* @param {Activity} activity The activity to compare with
|
|
253
|
+
* @returns {boolean}
|
|
254
|
+
*/
|
|
255
|
+
equals(activity) {
|
|
256
|
+
return (
|
|
257
|
+
this === activity ||
|
|
258
|
+
(activity &&
|
|
259
|
+
this.name === activity.name &&
|
|
260
|
+
this.type === activity.type &&
|
|
261
|
+
this.url === activity.url &&
|
|
262
|
+
this.state === activity.state &&
|
|
263
|
+
this.details === activity.details &&
|
|
264
|
+
this.emoji?.id === activity.emoji?.id &&
|
|
265
|
+
this.emoji?.name === activity.emoji?.name)
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* The time the activity was created at
|
|
271
|
+
* @type {Date}
|
|
272
|
+
* @readonly
|
|
273
|
+
*/
|
|
274
|
+
get createdAt() {
|
|
275
|
+
return new Date(this.createdTimestamp);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* When concatenated with a string, this automatically returns the activity's name instead of the Activity object.
|
|
280
|
+
* @returns {string}
|
|
281
|
+
*/
|
|
282
|
+
toString() {
|
|
283
|
+
return this.name;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
_clone() {
|
|
287
|
+
return Object.assign(Object.create(this), this);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Assets for a rich presence
|
|
293
|
+
*/
|
|
294
|
+
class RichPresenceAssets {
|
|
295
|
+
constructor(activity, assets) {
|
|
296
|
+
/**
|
|
297
|
+
* The activity of the RichPresenceAssets
|
|
298
|
+
* @type {Activity}
|
|
299
|
+
* @readonly
|
|
300
|
+
* @name RichPresenceAssets#activity
|
|
301
|
+
*/
|
|
302
|
+
Object.defineProperty(this, 'activity', { value: activity });
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Hover text for the large image
|
|
306
|
+
* @type {?string}
|
|
307
|
+
*/
|
|
308
|
+
this.largeText = assets.large_text ?? null;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Hover text for the small image
|
|
312
|
+
* @type {?string}
|
|
313
|
+
*/
|
|
314
|
+
this.smallText = assets.small_text ?? null;
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* The large image asset's id
|
|
318
|
+
* @type {?Snowflake}
|
|
319
|
+
*/
|
|
320
|
+
this.largeImage = assets.large_image ?? null;
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* The small image asset's id
|
|
324
|
+
* @type {?Snowflake}
|
|
325
|
+
*/
|
|
326
|
+
this.smallImage = assets.small_image ?? null;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Gets the URL of the small image asset
|
|
331
|
+
* @param {ImageURLOptions} [options={}] Options for the image URL
|
|
332
|
+
* @returns {?string}
|
|
333
|
+
*/
|
|
334
|
+
smallImageURL(options = {}) {
|
|
335
|
+
if (!this.smallImage) return null;
|
|
336
|
+
if (this.smallImage.includes(':')) {
|
|
337
|
+
const [platform, id] = this.smallImage.split(':');
|
|
338
|
+
switch (platform) {
|
|
339
|
+
case 'mp':
|
|
340
|
+
return `https://media.discordapp.net/${id}`;
|
|
341
|
+
default:
|
|
342
|
+
return null;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
return this.activity.presence.client.rest.cdn.appAsset(this.activity.applicationId, this.smallImage, options);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Gets the URL of the large image asset
|
|
351
|
+
* @param {ImageURLOptions} [options={}] Options for the image URL
|
|
352
|
+
* @returns {?string}
|
|
353
|
+
*/
|
|
354
|
+
largeImageURL(options = {}) {
|
|
355
|
+
if (!this.largeImage) return null;
|
|
356
|
+
if (this.largeImage.includes(':')) {
|
|
357
|
+
const [platform, id] = this.largeImage.split(':');
|
|
358
|
+
switch (platform) {
|
|
359
|
+
case 'mp':
|
|
360
|
+
return `https://media.discordapp.net/${id}`;
|
|
361
|
+
default:
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
return this.activity.presence.client.rest.cdn.appAsset(this.activity.applicationId, this.largeImage, options);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
exports.Presence = Presence;
|
|
371
|
+
exports.Activity = Activity;
|
|
372
|
+
exports.RichPresenceAssets = RichPresenceAssets;
|