@ovencord/discord.js 14.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +191 -0
- package/README.md +148 -0
- package/package.json +73 -0
- package/src/client/Client.ts +967 -0
- package/src/client/actions/Action.ts +141 -0
- package/src/client/actions/ActionsManager.ts +138 -0
- package/src/client/actions/ChannelCreate.ts +21 -0
- package/src/client/actions/ChannelDelete.ts +20 -0
- package/src/client/actions/ChannelUpdate.ts +38 -0
- package/src/client/actions/GuildChannelsPositionUpdate.ts +17 -0
- package/src/client/actions/GuildEmojiCreate.ts +17 -0
- package/src/client/actions/GuildEmojiDelete.ts +16 -0
- package/src/client/actions/GuildEmojiUpdate.ts +17 -0
- package/src/client/actions/GuildEmojisUpdate.ts +30 -0
- package/src/client/actions/GuildMemberRemove.ts +29 -0
- package/src/client/actions/GuildMemberUpdate.ts +41 -0
- package/src/client/actions/GuildRoleCreate.ts +23 -0
- package/src/client/actions/GuildRoleDelete.ts +26 -0
- package/src/client/actions/GuildRolesPositionUpdate.ts +17 -0
- package/src/client/actions/GuildScheduledEventDelete.ts +28 -0
- package/src/client/actions/GuildScheduledEventUserAdd.ts +29 -0
- package/src/client/actions/GuildScheduledEventUserRemove.ts +29 -0
- package/src/client/actions/GuildSoundboardSoundDelete.ts +26 -0
- package/src/client/actions/GuildStickerCreate.ts +17 -0
- package/src/client/actions/GuildStickerDelete.ts +16 -0
- package/src/client/actions/GuildStickerUpdate.ts +17 -0
- package/src/client/actions/GuildStickersUpdate.ts +30 -0
- package/src/client/actions/GuildUpdate.ts +30 -0
- package/src/client/actions/InteractionCreate.ts +104 -0
- package/src/client/actions/MessageCreate.ts +38 -0
- package/src/client/actions/MessageDelete.ts +29 -0
- package/src/client/actions/MessageDeleteBulk.ts +45 -0
- package/src/client/actions/MessagePollVoteAdd.ts +37 -0
- package/src/client/actions/MessagePollVoteRemove.ts +35 -0
- package/src/client/actions/MessageReactionAdd.ts +68 -0
- package/src/client/actions/MessageReactionRemove.ts +47 -0
- package/src/client/actions/MessageReactionRemoveAll.ts +30 -0
- package/src/client/actions/MessageReactionRemoveEmoji.ts +25 -0
- package/src/client/actions/MessageUpdate.ts +22 -0
- package/src/client/actions/StageInstanceCreate.ts +25 -0
- package/src/client/actions/StageInstanceDelete.ts +28 -0
- package/src/client/actions/StageInstanceUpdate.ts +27 -0
- package/src/client/actions/ThreadCreate.ts +22 -0
- package/src/client/actions/ThreadMembersUpdate.ts +45 -0
- package/src/client/actions/TypingStart.ts +26 -0
- package/src/client/actions/UserUpdate.ts +33 -0
- package/src/client/voice/ClientVoiceManager.ts +46 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_PERMISSIONS_UPDATE.ts +19 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_ACTION_EXECUTION.ts +17 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_CREATE.ts +18 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_DELETE.ts +21 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_UPDATE.ts +20 -0
- package/src/client/websocket/handlers/CHANNEL_CREATE.ts +4 -0
- package/src/client/websocket/handlers/CHANNEL_DELETE.ts +4 -0
- package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.ts +22 -0
- package/src/client/websocket/handlers/CHANNEL_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/ENTITLEMENT_CREATE.ts +14 -0
- package/src/client/websocket/handlers/ENTITLEMENT_DELETE.ts +18 -0
- package/src/client/websocket/handlers/ENTITLEMENT_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/GUILD_AUDIT_LOG_ENTRY_CREATE.ts +19 -0
- package/src/client/websocket/handlers/GUILD_BAN_ADD.ts +15 -0
- package/src/client/websocket/handlers/GUILD_BAN_REMOVE.ts +20 -0
- package/src/client/websocket/handlers/GUILD_CREATE.ts +34 -0
- package/src/client/websocket/handlers/GUILD_DELETE.ts +36 -0
- package/src/client/websocket/handlers/GUILD_EMOJIS_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_INTEGRATIONS_UPDATE.ts +15 -0
- package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.ts +40 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_ADD.ts +17 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_ROLE_CREATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_ROLE_DELETE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_ROLE_UPDATE.ts +21 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_CREATE.ts +17 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_DELETE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_UPDATE.ts +19 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_ADD.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.ts +24 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.ts +18 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_DELETE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.ts +20 -0
- package/src/client/websocket/handlers/GUILD_STICKERS_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/INTERACTION_CREATE.ts +4 -0
- package/src/client/websocket/handlers/INVITE_CREATE.ts +20 -0
- package/src/client/websocket/handlers/INVITE_DELETE.ts +23 -0
- package/src/client/websocket/handlers/MESSAGE_CREATE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE_BULK.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_ADD.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_ADD.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_ALL.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_EMOJI.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/PRESENCE_UPDATE.ts +42 -0
- package/src/client/websocket/handlers/RATE_LIMITED.ts +23 -0
- package/src/client/websocket/handlers/READY.ts +29 -0
- package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.ts +24 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_CREATE.ts +4 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_DELETE.ts +4 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/SUBSCRIPTION_CREATE.ts +14 -0
- package/src/client/websocket/handlers/SUBSCRIPTION_DELETE.ts +16 -0
- package/src/client/websocket/handlers/SUBSCRIPTION_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/THREAD_CREATE.ts +4 -0
- package/src/client/websocket/handlers/THREAD_DELETE.ts +17 -0
- package/src/client/websocket/handlers/THREAD_LIST_SYNC.ts +50 -0
- package/src/client/websocket/handlers/THREAD_MEMBERS_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/THREAD_MEMBER_UPDATE.ts +25 -0
- package/src/client/websocket/handlers/THREAD_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/TYPING_START.ts +4 -0
- package/src/client/websocket/handlers/USER_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.ts +16 -0
- package/src/client/websocket/handlers/VOICE_SERVER_UPDATE.ts +5 -0
- package/src/client/websocket/handlers/VOICE_STATE_UPDATE.ts +37 -0
- package/src/client/websocket/handlers/WEBHOOKS_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/index.ts +74 -0
- package/src/errors/DJSError.ts +50 -0
- package/src/errors/ErrorCodes.ts +277 -0
- package/src/errors/Messages.ts +155 -0
- package/src/errors/index.ts +6 -0
- package/src/index.ts +241 -0
- package/src/managers/ApplicationCommandManager.ts +303 -0
- package/src/managers/ApplicationCommandPermissionsManager.ts +453 -0
- package/src/managers/ApplicationEmojiManager.ts +149 -0
- package/src/managers/AutoModerationRuleManager.ts +307 -0
- package/src/managers/BaseManager.ts +13 -0
- package/src/managers/CachedManager.ts +56 -0
- package/src/managers/CategoryChannelChildManager.ts +81 -0
- package/src/managers/ChannelManager.ts +194 -0
- package/src/managers/DMMessageManager.ts +15 -0
- package/src/managers/DataManager.ts +38 -0
- package/src/managers/EntitlementManager.ts +182 -0
- package/src/managers/GuildApplicationCommandManager.ts +29 -0
- package/src/managers/GuildBanManager.ts +221 -0
- package/src/managers/GuildChannelManager.ts +552 -0
- package/src/managers/GuildEmojiManager.ts +262 -0
- package/src/managers/GuildEmojiRoleManager.ts +134 -0
- package/src/managers/GuildForumThreadManager.ts +84 -0
- package/src/managers/GuildInviteManager.ts +236 -0
- package/src/managers/GuildManager.ts +265 -0
- package/src/managers/GuildMemberManager.ts +619 -0
- package/src/managers/GuildMemberRoleManager.ts +230 -0
- package/src/managers/GuildMessageManager.ts +31 -0
- package/src/managers/GuildScheduledEventManager.ts +330 -0
- package/src/managers/GuildSoundboardSoundManager.ts +157 -0
- package/src/managers/GuildStickerManager.ts +192 -0
- package/src/managers/GuildTextThreadManager.ts +91 -0
- package/src/managers/MessageManager.ts +352 -0
- package/src/managers/PartialGroupDMMessageManager.ts +15 -0
- package/src/managers/PermissionOverwriteManager.ts +174 -0
- package/src/managers/PollAnswerVoterManager.ts +59 -0
- package/src/managers/PresenceManager.ts +60 -0
- package/src/managers/ReactionManager.ts +72 -0
- package/src/managers/ReactionUserManager.ts +82 -0
- package/src/managers/RoleManager.ts +432 -0
- package/src/managers/StageInstanceManager.ts +166 -0
- package/src/managers/SubscriptionManager.ts +83 -0
- package/src/managers/ThreadManager.ts +210 -0
- package/src/managers/ThreadMemberManager.ts +194 -0
- package/src/managers/UserManager.ts +139 -0
- package/src/managers/VoiceStateManager.ts +61 -0
- package/src/sharding/Shard.ts +513 -0
- package/src/sharding/ShardClientUtil.ts +293 -0
- package/src/sharding/ShardingManager.ts +374 -0
- package/src/structures/ActionRow.ts +31 -0
- package/src/structures/AnnouncementChannel.ts +25 -0
- package/src/structures/AnonymousGuild.ts +110 -0
- package/src/structures/ApplicationCommand.ts +675 -0
- package/src/structures/ApplicationEmoji.ts +189 -0
- package/src/structures/ApplicationRoleConnectionMetadata.ts +54 -0
- package/src/structures/Attachment.ts +189 -0
- package/src/structures/AuthorizingIntegrationOwners.ts +63 -0
- package/src/structures/AutoModerationActionExecution.ts +138 -0
- package/src/structures/AutoModerationRule.ts +325 -0
- package/src/structures/AutocompleteInteraction.ts +115 -0
- package/src/structures/Base.ts +37 -0
- package/src/structures/BaseChannel.ts +188 -0
- package/src/structures/BaseGuild.ts +134 -0
- package/src/structures/BaseGuildEmoji.ts +113 -0
- package/src/structures/BaseGuildTextChannel.ts +230 -0
- package/src/structures/BaseGuildVoiceChannel.ts +270 -0
- package/src/structures/BaseInteraction.ts +393 -0
- package/src/structures/BaseInvite.ts +192 -0
- package/src/structures/BaseSelectMenuComponent.ts +58 -0
- package/src/structures/ButtonComponent.ts +68 -0
- package/src/structures/ButtonInteraction.ts +8 -0
- package/src/structures/CategoryChannel.ts +46 -0
- package/src/structures/ChannelSelectMenuComponent.ts +18 -0
- package/src/structures/ChannelSelectMenuInteraction.ts +34 -0
- package/src/structures/ChatInputCommandInteraction.ts +43 -0
- package/src/structures/ClientApplication.ts +470 -0
- package/src/structures/ClientPresence.ts +87 -0
- package/src/structures/ClientUser.ts +219 -0
- package/src/structures/CommandInteraction.ts +193 -0
- package/src/structures/CommandInteractionOptionResolver.ts +336 -0
- package/src/structures/Component.ts +59 -0
- package/src/structures/ContainerComponent.ts +63 -0
- package/src/structures/ContextMenuCommandInteraction.ts +68 -0
- package/src/structures/DMChannel.ts +148 -0
- package/src/structures/DirectoryChannel.ts +40 -0
- package/src/structures/Embed.ts +251 -0
- package/src/structures/Emoji.ts +61 -0
- package/src/structures/Entitlement.ts +206 -0
- package/src/structures/FileComponent.ts +41 -0
- package/src/structures/ForumChannel.ts +31 -0
- package/src/structures/GroupDMInvite.ts +34 -0
- package/src/structures/Guild.ts +1605 -0
- package/src/structures/GuildAuditLogs.ts +99 -0
- package/src/structures/GuildAuditLogsEntry.ts +557 -0
- package/src/structures/GuildBan.ts +65 -0
- package/src/structures/GuildChannel.ts +515 -0
- package/src/structures/GuildEmoji.ts +159 -0
- package/src/structures/GuildInvite.ts +233 -0
- package/src/structures/GuildMember.ts +643 -0
- package/src/structures/GuildOnboarding.ts +73 -0
- package/src/structures/GuildOnboardingPrompt.ts +93 -0
- package/src/structures/GuildOnboardingPromptOption.ts +100 -0
- package/src/structures/GuildPreview.ts +218 -0
- package/src/structures/GuildPreviewEmoji.ts +28 -0
- package/src/structures/GuildScheduledEvent.ts +593 -0
- package/src/structures/GuildTemplate.ts +229 -0
- package/src/structures/Integration.ts +257 -0
- package/src/structures/IntegrationApplication.ts +84 -0
- package/src/structures/InteractionCallback.ts +86 -0
- package/src/structures/InteractionCallbackResource.ts +57 -0
- package/src/structures/InteractionCallbackResponse.ts +35 -0
- package/src/structures/InteractionCollector.ts +260 -0
- package/src/structures/InteractionWebhook.ts +65 -0
- package/src/structures/InviteGuild.ts +22 -0
- package/src/structures/LabelComponent.ts +51 -0
- package/src/structures/MediaChannel.ts +8 -0
- package/src/structures/MediaGalleryComponent.ts +31 -0
- package/src/structures/MediaGalleryItem.ts +54 -0
- package/src/structures/MentionableSelectMenuComponent.ts +8 -0
- package/src/structures/MentionableSelectMenuInteraction.ts +76 -0
- package/src/structures/Message.ts +1202 -0
- package/src/structures/MessageCollector.ts +155 -0
- package/src/structures/MessageComponentInteraction.ts +132 -0
- package/src/structures/MessageContextMenuCommandInteraction.ts +18 -0
- package/src/structures/MessageMentions.ts +327 -0
- package/src/structures/MessagePayload.ts +325 -0
- package/src/structures/MessageReaction.ts +219 -0
- package/src/structures/ModalComponentResolver.ts +237 -0
- package/src/structures/ModalSubmitInteraction.ts +260 -0
- package/src/structures/OAuth2Guild.ts +30 -0
- package/src/structures/PartialGroupDMChannel.ts +151 -0
- package/src/structures/PermissionOverwrites.ts +222 -0
- package/src/structures/Poll.ts +195 -0
- package/src/structures/PollAnswer.ts +100 -0
- package/src/structures/Presence.ts +448 -0
- package/src/structures/PrimaryEntryPointCommandInteraction.ts +8 -0
- package/src/structures/ReactionCollector.ts +245 -0
- package/src/structures/ReactionEmoji.ts +30 -0
- package/src/structures/Role.ts +543 -0
- package/src/structures/RoleSelectMenuComponent.ts +8 -0
- package/src/structures/RoleSelectMenuInteraction.ts +34 -0
- package/src/structures/SKU.ts +62 -0
- package/src/structures/SectionComponent.ts +44 -0
- package/src/structures/SeparatorComponent.ts +29 -0
- package/src/structures/SoundboardSound.ts +176 -0
- package/src/structures/StageChannel.ts +118 -0
- package/src/structures/StageInstance.ts +173 -0
- package/src/structures/Sticker.ts +300 -0
- package/src/structures/StickerPack.ts +111 -0
- package/src/structures/StringSelectMenuComponent.ts +18 -0
- package/src/structures/StringSelectMenuInteraction.ts +21 -0
- package/src/structures/Subscription.ts +138 -0
- package/src/structures/Team.ts +131 -0
- package/src/structures/TeamMember.ts +77 -0
- package/src/structures/TextChannel.ts +33 -0
- package/src/structures/TextDisplayComponent.ts +18 -0
- package/src/structures/TextInputComponent.ts +28 -0
- package/src/structures/ThreadChannel.ts +680 -0
- package/src/structures/ThreadMember.ts +125 -0
- package/src/structures/ThreadOnlyChannel.ts +276 -0
- package/src/structures/ThumbnailComponent.ts +51 -0
- package/src/structures/Typing.ts +81 -0
- package/src/structures/UnfurledMediaItem.ts +33 -0
- package/src/structures/User.ts +511 -0
- package/src/structures/UserContextMenuCommandInteraction.ts +28 -0
- package/src/structures/UserSelectMenuComponent.ts +8 -0
- package/src/structures/UserSelectMenuInteraction.ts +54 -0
- package/src/structures/VoiceChannel.ts +119 -0
- package/src/structures/VoiceChannelEffect.ts +92 -0
- package/src/structures/VoiceRegion.ts +52 -0
- package/src/structures/VoiceState.ts +346 -0
- package/src/structures/Webhook.ts +526 -0
- package/src/structures/WelcomeChannel.ts +67 -0
- package/src/structures/WelcomeScreen.ts +53 -0
- package/src/structures/Widget.ts +110 -0
- package/src/structures/WidgetMember.ts +124 -0
- package/src/structures/interfaces/Application.ts +179 -0
- package/src/structures/interfaces/Collector.ts +372 -0
- package/src/structures/interfaces/InteractionResponses.ts +384 -0
- package/src/structures/interfaces/TextBasedChannel.ts +430 -0
- package/src/util/APITypes.ts +690 -0
- package/src/util/ActivityFlagsBitField.ts +26 -0
- package/src/util/ApplicationFlagsBitField.ts +43 -0
- package/src/util/AttachmentFlagsBitField.ts +26 -0
- package/src/util/BitField.ts +178 -0
- package/src/util/ChannelFlagsBitField.ts +43 -0
- package/src/util/Channels.ts +165 -0
- package/src/util/Colors.ts +72 -0
- package/src/util/Components.ts +285 -0
- package/src/util/Constants.ts +251 -0
- package/src/util/DataResolver.ts +146 -0
- package/src/util/Enums.ts +10 -0
- package/src/util/Events.ts +178 -0
- package/src/util/GuildMemberFlagsBitField.ts +43 -0
- package/src/util/IntentsBitField.ts +35 -0
- package/src/util/InviteFlagsBitField.ts +26 -0
- package/src/util/Invites.ts +27 -0
- package/src/util/LimitedCollection.ts +73 -0
- package/src/util/MessageFlagsBitField.ts +43 -0
- package/src/util/Options.ts +215 -0
- package/src/util/Partials.ts +50 -0
- package/src/util/PermissionsBitField.ts +113 -0
- package/src/util/RoleFlagsBitField.ts +26 -0
- package/src/util/SKUFlagsBitField.ts +26 -0
- package/src/util/ShardEvents.ts +26 -0
- package/src/util/Status.ts +16 -0
- package/src/util/Sweepers.ts +532 -0
- package/src/util/Symbols.ts +1 -0
- package/src/util/SystemChannelFlagsBitField.ts +45 -0
- package/src/util/ThreadMemberFlagsBitField.ts +33 -0
- package/src/util/Transformers.ts +123 -0
- package/src/util/UserFlagsBitField.ts +33 -0
- package/src/util/Util.ts +519 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { Collection } from '@ovencord/collection';
|
|
2
|
+
import { Routes } from 'discord-api-types/v10';
|
|
3
|
+
import { DiscordjsError, ErrorCodes } from '../errors/index.js';
|
|
4
|
+
import { GuildInvite } from '../structures/GuildInvite.js';
|
|
5
|
+
import { resolveInviteCode } from '../util/DataResolver.js';
|
|
6
|
+
import { CachedManager } from './CachedManager.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Manages API methods for GuildInvites and stores their cache.
|
|
10
|
+
*
|
|
11
|
+
* @extends {CachedManager}
|
|
12
|
+
*/
|
|
13
|
+
export class GuildInviteManager extends CachedManager {
|
|
14
|
+
public guild: any;
|
|
15
|
+
constructor(guild, iterable) {
|
|
16
|
+
super(guild.client, GuildInvite, iterable);
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The guild this Manager belongs to
|
|
20
|
+
*
|
|
21
|
+
* @type {Guild}
|
|
22
|
+
*/
|
|
23
|
+
this.guild = guild;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The cache of this Manager
|
|
28
|
+
*
|
|
29
|
+
* @type {Collection<string, GuildInvite>}
|
|
30
|
+
* @name GuildInviteManager#cache
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
_add(data, cache) {
|
|
34
|
+
return super._add(data, cache, { id: data.code, extras: [this.guild] });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Data that resolves to give a `GuildInvite`. This can be:
|
|
39
|
+
*
|
|
40
|
+
* - An invite code
|
|
41
|
+
* - An invite URL
|
|
42
|
+
*
|
|
43
|
+
* @typedef {string} GuildInviteResolvable
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A guild channel where an invite may be created on. This can be:
|
|
48
|
+
* - TextChannel
|
|
49
|
+
* - VoiceChannel
|
|
50
|
+
* - AnnouncementChannel
|
|
51
|
+
* - StageChannel
|
|
52
|
+
* - ForumChannel
|
|
53
|
+
* - MediaChannel
|
|
54
|
+
*
|
|
55
|
+
* @typedef {TextChannel|VoiceChannel|AnnouncementChannel|StageChannel|ForumChannel|MediaChannel}
|
|
56
|
+
* GuildInvitableChannel
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Data that can be resolved to a guild channel where an invite may be created on. This can be:
|
|
61
|
+
* - GuildInvitableChannel
|
|
62
|
+
* - Snowflake
|
|
63
|
+
*
|
|
64
|
+
* @typedef {GuildInvitableChannel|Snowflake}
|
|
65
|
+
* GuildInvitableChannelResolvable
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Resolves an `GuildInviteResolvable` to a `GuildInvite` object.
|
|
70
|
+
*
|
|
71
|
+
* @method resolve
|
|
72
|
+
* @memberof GuildInviteManager
|
|
73
|
+
* @instance
|
|
74
|
+
* @param {GuildInviteResolvable} invite The invite resolvable to resolve
|
|
75
|
+
* @returns {?GuildInvite}
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Resolves an InviteResolvable to an invite code string.
|
|
80
|
+
*
|
|
81
|
+
* @method resolveId
|
|
82
|
+
* @memberof GuildInviteManager
|
|
83
|
+
* @instance
|
|
84
|
+
* @param {InviteResolvable} invite The invite resolvable to resolve
|
|
85
|
+
* @returns {?string}
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Options used to fetch a single invite from a guild.
|
|
90
|
+
*
|
|
91
|
+
* @typedef {Object} FetchInviteOptions
|
|
92
|
+
* @property {InviteResolvable} code The invite to fetch
|
|
93
|
+
* @property {boolean} [cache=true] Whether or not to cache the fetched invite
|
|
94
|
+
* @property {boolean} [force=false] Whether to skip the cache check and request the API
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Options used to fetch all invites from a guild.
|
|
99
|
+
*
|
|
100
|
+
* @typedef {Object} FetchInvitesOptions
|
|
101
|
+
* @property {GuildInvitableChannelResolvable} [channelId]
|
|
102
|
+
* The channel to fetch all invites from
|
|
103
|
+
* @property {boolean} [cache=true] Whether or not to cache the fetched invites
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Fetches invite(s) from Discord.
|
|
108
|
+
*
|
|
109
|
+
* @param {GuildInviteResolvable|FetchInviteOptions|FetchInvitesOptions} [options]
|
|
110
|
+
* Options for fetching guild invite(s)
|
|
111
|
+
* @returns {Promise<GuildInvite|Collection<string, GuildInvite>>}
|
|
112
|
+
* @example
|
|
113
|
+
* // Fetch all invites from a guild
|
|
114
|
+
* guild.invites.fetch()
|
|
115
|
+
* .then(console.log)
|
|
116
|
+
* .catch(console.error);
|
|
117
|
+
* @example
|
|
118
|
+
* // Fetch all invites from a guild without caching
|
|
119
|
+
* guild.invites.fetch({ cache: false })
|
|
120
|
+
* .then(console.log)
|
|
121
|
+
* .catch(console.error);
|
|
122
|
+
* @example
|
|
123
|
+
* // Fetch all invites from a channel
|
|
124
|
+
* guild.invites.fetch({ channelId: '222197033908436994' })
|
|
125
|
+
* .then(console.log)
|
|
126
|
+
* .catch(console.error);
|
|
127
|
+
* @example
|
|
128
|
+
* // Fetch a single invite
|
|
129
|
+
* guild.invites.fetch('bRCvFy9')
|
|
130
|
+
* .then(console.log)
|
|
131
|
+
* .catch(console.error);
|
|
132
|
+
* @example
|
|
133
|
+
* // Fetch a single invite without checking cache
|
|
134
|
+
* guild.invites.fetch({ code: 'bRCvFy9', force: true })
|
|
135
|
+
* .then(console.log)
|
|
136
|
+
* .catch(console.error)
|
|
137
|
+
* @example
|
|
138
|
+
* // Fetch a single invite without caching
|
|
139
|
+
* guild.invites.fetch({ code: 'bRCvFy9', cache: false })
|
|
140
|
+
* .then(console.log)
|
|
141
|
+
* .catch(console.error);
|
|
142
|
+
*/
|
|
143
|
+
async fetch(options) {
|
|
144
|
+
if (!options) return this._fetchMany();
|
|
145
|
+
if (typeof options === 'string') {
|
|
146
|
+
const code = resolveInviteCode(options);
|
|
147
|
+
if (!code) throw new DiscordjsError(ErrorCodes.InviteResolveCode);
|
|
148
|
+
return this._fetchSingle({ code, cache: true });
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (!options.code) {
|
|
152
|
+
if (options.channelId) {
|
|
153
|
+
const id = this.guild.channels.resolveId(options.channelId);
|
|
154
|
+
if (!id) throw new DiscordjsError(ErrorCodes.GuildChannelResolve);
|
|
155
|
+
return this._fetchChannelMany(id, options.cache);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if ('cache' in options) return this._fetchMany(options.cache);
|
|
159
|
+
throw new DiscordjsError(ErrorCodes.InviteResolveCode);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return this._fetchSingle({
|
|
163
|
+
...options,
|
|
164
|
+
code: resolveInviteCode(options.code),
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async _fetchSingle({ code, cache, force = false }) {
|
|
169
|
+
if (!force) {
|
|
170
|
+
const existing = this.cache.get(code);
|
|
171
|
+
if (existing) return existing;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const invites = await this._fetchMany(cache);
|
|
175
|
+
const invite = invites.get(code);
|
|
176
|
+
if (!invite) throw new DiscordjsError(ErrorCodes.InviteNotFound);
|
|
177
|
+
return invite;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
async _fetchMany(cache) {
|
|
181
|
+
const data = await this.client.rest.get(Routes.guildInvites(this.guild.id));
|
|
182
|
+
return data.reduce((col, invite) => col.set(invite.code, this._add(invite, cache)), new Collection());
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async _fetchChannelMany(channelId, cache) {
|
|
186
|
+
const data = await this.client.rest.get(Routes.channelInvites(channelId));
|
|
187
|
+
return data.reduce((col, invite) => col.set(invite.code, this._add(invite, cache)), new Collection());
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Create an invite to the guild from the provided channel.
|
|
192
|
+
*
|
|
193
|
+
* @param {GuildInvitableChannelResolvable} channel The options for creating the invite from a channel.
|
|
194
|
+
* @param {InviteCreateOptions} [options={}] The options for creating the invite from a channel.
|
|
195
|
+
* @returns {Promise<GuildInvite>}
|
|
196
|
+
* @example
|
|
197
|
+
* // Create an invite to a selected channel
|
|
198
|
+
* guild.invites.create('599942732013764608')
|
|
199
|
+
* .then(console.log)
|
|
200
|
+
* .catch(console.error);
|
|
201
|
+
*/
|
|
202
|
+
async create(
|
|
203
|
+
channel,
|
|
204
|
+
{ temporary, maxAge, maxUses, unique, targetUser, targetApplication, targetType, reason } = {},
|
|
205
|
+
) {
|
|
206
|
+
const id = this.guild.channels.resolveId(channel);
|
|
207
|
+
if (!id) throw new DiscordjsError(ErrorCodes.GuildChannelResolve);
|
|
208
|
+
|
|
209
|
+
const invite = await this.client.rest.post(Routes.channelInvites(id), {
|
|
210
|
+
body: {
|
|
211
|
+
temporary,
|
|
212
|
+
max_age: maxAge,
|
|
213
|
+
max_uses: maxUses,
|
|
214
|
+
unique,
|
|
215
|
+
target_user_id: this.client.users.resolveId(targetUser),
|
|
216
|
+
target_application_id: targetApplication?.id ?? targetApplication?.applicationId ?? targetApplication,
|
|
217
|
+
target_type: targetType,
|
|
218
|
+
},
|
|
219
|
+
reason,
|
|
220
|
+
});
|
|
221
|
+
return new GuildInvite(this.client, invite);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Deletes an invite.
|
|
226
|
+
*
|
|
227
|
+
* @param {InviteResolvable} invite The invite to delete
|
|
228
|
+
* @param {string} [reason] Reason for deleting the invite
|
|
229
|
+
* @returns {Promise<void>}
|
|
230
|
+
*/
|
|
231
|
+
async delete(invite, reason) {
|
|
232
|
+
const code = resolveInviteCode(invite);
|
|
233
|
+
|
|
234
|
+
await this.client.rest.delete(Routes.invite(code), { reason });
|
|
235
|
+
}
|
|
236
|
+
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { setTimeout, clearTimeout } from 'node:timers';
|
|
3
|
+
import { Collection } from '@ovencord/collection';
|
|
4
|
+
import { makeURLSearchParams } from '@ovencord/rest';
|
|
5
|
+
import { GatewayOpcodes, Routes, RouteBases } from 'discord-api-types/v10';
|
|
6
|
+
import { DiscordjsError, ErrorCodes } from '../errors/index.js';
|
|
7
|
+
import { ShardClientUtil } from '../sharding/ShardClientUtil.js';
|
|
8
|
+
import { Guild } from '../structures/Guild.js';
|
|
9
|
+
import { GuildChannel } from '../structures/GuildChannel.js';
|
|
10
|
+
import { GuildEmoji } from '../structures/GuildEmoji.js';
|
|
11
|
+
import { GuildInvite } from '../structures/GuildInvite.js';
|
|
12
|
+
import { GuildMember } from '../structures/GuildMember.js';
|
|
13
|
+
import { OAuth2Guild } from '../structures/OAuth2Guild.js';
|
|
14
|
+
import { Role } from '../structures/Role.js';
|
|
15
|
+
import { Events } from '../util/Events.js';
|
|
16
|
+
import { _transformAPIIncidentsData } from '../util/Transformers.js';
|
|
17
|
+
import { CachedManager } from './CachedManager.js';
|
|
18
|
+
|
|
19
|
+
let cacheWarningEmitted = false;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Manages API methods for Guilds and stores their cache.
|
|
23
|
+
*
|
|
24
|
+
* @extends {CachedManager}
|
|
25
|
+
*/
|
|
26
|
+
export class GuildManager extends CachedManager {
|
|
27
|
+
public client: any;
|
|
28
|
+
constructor(client, iterable) {
|
|
29
|
+
super(client, Guild, iterable);
|
|
30
|
+
if (!cacheWarningEmitted && this._cache.constructor.name !== 'Collection') {
|
|
31
|
+
cacheWarningEmitted = true;
|
|
32
|
+
process.emitWarning(
|
|
33
|
+
`Overriding the cache handling for ${this.constructor.name} is unsupported and breaks functionality.`,
|
|
34
|
+
'UnsupportedCacheOverwriteWarning',
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The cache of this Manager
|
|
41
|
+
*
|
|
42
|
+
* @type {Collection<Snowflake, Guild>}
|
|
43
|
+
* @name GuildManager#cache
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Data that resolves to give a Guild object. This can be:
|
|
48
|
+
* - A Guild object
|
|
49
|
+
* - A GuildChannel object
|
|
50
|
+
* - A GuildEmoji object
|
|
51
|
+
* - A Role object
|
|
52
|
+
* - A Snowflake
|
|
53
|
+
* - An Invite object
|
|
54
|
+
*
|
|
55
|
+
* @typedef {Guild|GuildChannel|GuildMember|GuildEmoji|Role|Snowflake|Invite} GuildResolvable
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Resolves a {@link GuildResolvable} to a {@link Guild} object.
|
|
60
|
+
*
|
|
61
|
+
* @method resolve
|
|
62
|
+
* @memberof GuildManager
|
|
63
|
+
* @instance
|
|
64
|
+
* @param {GuildResolvable} guild The guild resolvable to identify
|
|
65
|
+
* @returns {?Guild}
|
|
66
|
+
*/
|
|
67
|
+
resolve(guild) {
|
|
68
|
+
if (
|
|
69
|
+
guild instanceof GuildChannel ||
|
|
70
|
+
guild instanceof GuildMember ||
|
|
71
|
+
guild instanceof GuildEmoji ||
|
|
72
|
+
guild instanceof Role ||
|
|
73
|
+
(guild instanceof GuildInvite && guild.guild)
|
|
74
|
+
) {
|
|
75
|
+
return super.resolve(guild.guild);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return super.resolve(guild);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Resolves a {@link GuildResolvable} to a {@link Guild} id string.
|
|
83
|
+
*
|
|
84
|
+
* @method resolveId
|
|
85
|
+
* @memberof GuildManager
|
|
86
|
+
* @instance
|
|
87
|
+
* @param {GuildResolvable} guild The guild resolvable to identify
|
|
88
|
+
* @returns {?Snowflake}
|
|
89
|
+
*/
|
|
90
|
+
resolveId(guild) {
|
|
91
|
+
if (
|
|
92
|
+
guild instanceof GuildChannel ||
|
|
93
|
+
guild instanceof GuildMember ||
|
|
94
|
+
guild instanceof GuildEmoji ||
|
|
95
|
+
guild instanceof Role ||
|
|
96
|
+
(guild instanceof GuildInvite && guild.guild)
|
|
97
|
+
) {
|
|
98
|
+
return super.resolveId(guild.guild.id);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return super.resolveId(guild);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Options used to fetch a single guild.
|
|
106
|
+
*
|
|
107
|
+
* @typedef {BaseFetchOptions} FetchGuildOptions
|
|
108
|
+
* @property {GuildResolvable} guild The guild to fetch
|
|
109
|
+
* @property {boolean} [withCounts=true] Whether the approximate member and presence counts should be returned
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Options used to fetch multiple guilds.
|
|
114
|
+
*
|
|
115
|
+
* @typedef {Object} FetchGuildsOptions
|
|
116
|
+
* @property {Snowflake} [before] Get guilds before this guild id
|
|
117
|
+
* @property {Snowflake} [after] Get guilds after this guild id
|
|
118
|
+
* @property {number} [limit] Maximum number of guilds to request (1-200)
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Obtains one or multiple guilds from Discord, or the guild cache if it's already available.
|
|
123
|
+
*
|
|
124
|
+
* @param {GuildResolvable|FetchGuildOptions|FetchGuildsOptions} [options] The guild's id or options
|
|
125
|
+
* @returns {Promise<Guild|Collection<Snowflake, OAuth2Guild>>}
|
|
126
|
+
*/
|
|
127
|
+
async fetch(options = {}) {
|
|
128
|
+
const id = this.resolveId(options) ?? this.resolveId(options.guild);
|
|
129
|
+
|
|
130
|
+
if (id) {
|
|
131
|
+
if (!options.force) {
|
|
132
|
+
const existing = this.cache.get(id);
|
|
133
|
+
if (existing) return existing;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const innerData = await this.client.rest.get(Routes.guild(id), {
|
|
137
|
+
query: makeURLSearchParams({ with_counts: options.withCounts ?? true }),
|
|
138
|
+
});
|
|
139
|
+
innerData.shardId = ShardClientUtil.shardIdForGuildId(id, await this.client.ws.fetchShardCount());
|
|
140
|
+
return this._add(innerData, options.cache);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const data = await this.client.rest.get(Routes.userGuilds(), { query: makeURLSearchParams(options) });
|
|
144
|
+
return data.reduce((coll, guild) => coll.set(guild.id, new OAuth2Guild(this.client, guild)), new Collection());
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @typedef {Object} FetchSoundboardSoundsOptions
|
|
149
|
+
* @property {Snowflake[]} guildIds The ids of the guilds to fetch soundboard sounds for
|
|
150
|
+
* @property {number} [time=10_000] The timeout for receipt of the soundboard sounds
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Fetches soundboard sounds for the specified guilds.
|
|
155
|
+
*
|
|
156
|
+
* @param {FetchSoundboardSoundsOptions} options The options for fetching soundboard sounds
|
|
157
|
+
* @returns {Promise<Collection<Snowflake, Collection<Snowflake, SoundboardSound>>>}
|
|
158
|
+
* @example
|
|
159
|
+
* // Fetch soundboard sounds for multiple guilds
|
|
160
|
+
* const soundboardSounds = await client.guilds.fetchSoundboardSounds({
|
|
161
|
+
* guildIds: ['123456789012345678', '987654321098765432'],
|
|
162
|
+
* })
|
|
163
|
+
*
|
|
164
|
+
* console.log(soundboardSounds.get('123456789012345678'));
|
|
165
|
+
*/
|
|
166
|
+
async fetchSoundboardSounds({ guildIds, time = 10_000 }) {
|
|
167
|
+
const shardCount = await this.client.ws.getShardCount();
|
|
168
|
+
const shardIds = Map.groupBy(guildIds, guildId => ShardClientUtil.shardIdForGuildId(guildId, shardCount));
|
|
169
|
+
|
|
170
|
+
for (const [shardId, shardGuildIds] of shardIds) {
|
|
171
|
+
this.client.ws.send(shardId, {
|
|
172
|
+
op: GatewayOpcodes.RequestSoundboardSounds,
|
|
173
|
+
// eslint-disable-next-line id-length
|
|
174
|
+
d: {
|
|
175
|
+
guild_ids: shardGuildIds,
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return new Promise((resolve, reject) => {
|
|
181
|
+
const remainingGuildIds = new Set(guildIds);
|
|
182
|
+
|
|
183
|
+
const fetchedSoundboardSounds = new Collection();
|
|
184
|
+
|
|
185
|
+
const handler = (soundboardSounds, guild) => {
|
|
186
|
+
// eslint-disable-next-line no-use-before-define
|
|
187
|
+
timeout.refresh();
|
|
188
|
+
|
|
189
|
+
if (!remainingGuildIds.has(guild.id)) return;
|
|
190
|
+
|
|
191
|
+
fetchedSoundboardSounds.set(guild.id, soundboardSounds);
|
|
192
|
+
|
|
193
|
+
remainingGuildIds.delete(guild.id);
|
|
194
|
+
|
|
195
|
+
if (remainingGuildIds.size === 0) {
|
|
196
|
+
// eslint-disable-next-line no-use-before-define
|
|
197
|
+
clearTimeout(timeout);
|
|
198
|
+
this.client.removeListener(Events.SoundboardSounds, handler);
|
|
199
|
+
this.client.decrementMaxListeners();
|
|
200
|
+
|
|
201
|
+
resolve(fetchedSoundboardSounds);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const timeout = setTimeout(() => {
|
|
206
|
+
this.client.removeListener(Events.SoundboardSounds, handler);
|
|
207
|
+
this.client.decrementMaxListeners();
|
|
208
|
+
reject(new DiscordjsError(ErrorCodes.GuildSoundboardSoundsTimeout));
|
|
209
|
+
}, time).unref();
|
|
210
|
+
|
|
211
|
+
this.client.incrementMaxListeners();
|
|
212
|
+
this.client.on(Events.SoundboardSounds, handler);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Options used to set incident actions. Supplying `null` to any option will disable the action.
|
|
218
|
+
*
|
|
219
|
+
* @typedef {Object} IncidentActionsEditOptions
|
|
220
|
+
* @property {?DateResolvable} [invitesDisabledUntil] When invites should be enabled again
|
|
221
|
+
* @property {?DateResolvable} [dmsDisabledUntil] When direct messages should be enabled again
|
|
222
|
+
*/
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Sets the incident actions for a guild.
|
|
226
|
+
*
|
|
227
|
+
* @param {GuildResolvable} guild The guild
|
|
228
|
+
* @param {IncidentActionsEditOptions} incidentActions The incident actions to set
|
|
229
|
+
* @returns {Promise<IncidentActions>}
|
|
230
|
+
*/
|
|
231
|
+
async setIncidentActions(guild, { invitesDisabledUntil, dmsDisabledUntil }) {
|
|
232
|
+
const guildId = this.resolveId(guild);
|
|
233
|
+
|
|
234
|
+
const data = await this.client.rest.put(Routes.guildIncidentActions(guildId), {
|
|
235
|
+
body: {
|
|
236
|
+
invites_disabled_until: invitesDisabledUntil && new Date(invitesDisabledUntil).toISOString(),
|
|
237
|
+
dms_disabled_until: dmsDisabledUntil && new Date(dmsDisabledUntil).toISOString(),
|
|
238
|
+
},
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
const parsedData = _transformAPIIncidentsData(data);
|
|
242
|
+
const resolvedGuild = this.resolve(guild);
|
|
243
|
+
|
|
244
|
+
if (resolvedGuild) {
|
|
245
|
+
resolvedGuild.incidentsData = parsedData;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return parsedData;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Returns a URL for the PNG widget of a guild.
|
|
253
|
+
*
|
|
254
|
+
* @param {GuildResolvable} guild The guild of the widget image
|
|
255
|
+
* @param {GuildWidgetStyle} [style] The style for the widget image
|
|
256
|
+
* @returns {string}
|
|
257
|
+
*/
|
|
258
|
+
widgetImageURL(guild, style) {
|
|
259
|
+
const urlSearchParams = String(makeURLSearchParams({ style }));
|
|
260
|
+
|
|
261
|
+
return `${RouteBases.api}${Routes.guildWidgetImage(this.resolveId(guild))}${
|
|
262
|
+
urlSearchParams ? `?${urlSearchParams}` : ''
|
|
263
|
+
}`;
|
|
264
|
+
}
|
|
265
|
+
}
|