@wolfstar/plugin-gateway 0.5.0 → 0.6.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/README.md +39 -1
- package/dist/esm/index.d.ts +163 -32
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +192 -81
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["BaseStructure","BitField","BaseActivityFlagsBitField","BaseAttachmentFlagsBitField","BaseChannelFlagsBitField","BaseMessageFlagsBitField","BaseAnnouncementChannel","BaseAnnouncementThreadChannel","BaseChannelStructure","BaseCategoryChannel","BaseUser","BaseDMChannel","BaseForumChannel","BaseGroupDMChannel","BaseMediaChannel","BasePrivateThreadChannel","BasePublicThreadChannel","BaseStageChannel","BaseTextChannel","BaseVoiceChannel","BaseStageInstance","BaseAutoModerationRule","BaseEmoji","pick","BaseStructure","BaseSticker","BaseWebhook","toISO","BaseSoundboardSound","BaseActivity","BasePresence","BaseVoiceState","BaseReaction","BaseStructure","BaseAttachment","BaseEmbed","BaseStructure","pick","BasePollAnswer","BasePoll","BaseStructure","BaseMessage","BaseStructure","BaseStickerPack","DiscordCoreClient"],"sources":["../../src/EventGatewayListener.ts","../../src/util/channels.ts","../../src/structures/Mixin.ts","../../src/util/container.ts","../../src/structures/Structure.ts","../../src/util/flags.ts","../../src/structures/channels/mixins/BaseChannelMixin.ts","../../src/structures/channels/mixins/ChannelParentMixin.ts","../../src/structures/channels/PermissionOverwrites.ts","../../src/managers/PermissionOverwriteManager.ts","../../src/util/permissions.ts","../../src/structures/channels/mixins/edit.ts","../../src/structures/channels/mixins/ChannelPermissionMixin.ts","../../src/structures/channels/mixins/ChannelSlowmodeMixin.ts","../../src/managers/ChannelThreadManager.ts","../../src/structures/channels/mixins/ChannelThreadsMixin.ts","../../src/structures/channels/mixins/ChannelWebhooksMixin.ts","../../src/structures/channels/mixins/ChannelTopicMixin.ts","../../src/structures/channels/mixins/GuildChannelMixin.ts","../../src/managers/ChannelMessageManager.ts","../../src/structures/messages/MessagePayload.ts","../../src/structures/channels/mixins/TextChannelMixin.ts","../../src/structures/channels/AnnouncementChannel.ts","../../src/structures/channels/mixins/ChannelOwnerMixin.ts","../../src/managers/ThreadChannelMemberManager.ts","../../src/structures/channels/mixins/ThreadChannelMixin.ts","../../src/structures/channels/AnnouncementThreadChannel.ts","../../src/structures/channels/Channel.ts","../../src/structures/channels/BaseChannel.ts","../../src/structures/channels/CategoryChannel.ts","../../src/util/cdn.ts","../../src/structures/users/User.ts","../../src/structures/channels/mixins/DMChannelMixin.ts","../../src/structures/channels/DMChannel.ts","../../src/structures/channels/mixins/ThreadOnlyChannelMixin.ts","../../src/structures/channels/ForumChannel.ts","../../src/structures/channels/mixins/GroupDMMixin.ts","../../src/structures/channels/GroupDMChannel.ts","../../src/structures/channels/MediaChannel.ts","../../src/structures/channels/PrivateThreadChannel.ts","../../src/structures/channels/mixins/AppliedTagsMixin.ts","../../src/structures/channels/PublicThreadChannel.ts","../../src/structures/channels/mixins/VoiceChannelMixin.ts","../../src/structures/channels/StageChannel.ts","../../src/structures/channels/TextChannel.ts","../../src/structures/channels/VoiceChannel.ts","../../src/structures/stageInstances/StageInstance.ts","../../src/util/cache.ts","../../src/managers/CachedManager.ts","../../src/managers/ChannelManager.ts","../../src/structures/guilds/AnonymousGuild.ts","../../src/structures/guilds/Guild.ts","../../src/structures/automoderation/AutoModerationRule.ts","../../src/structures/emojis/Emoji.ts","../../src/structures/emojis/ReactionEmoji.ts","../../src/structures/guilds/GuildOnboarding.ts","../../src/structures/guilds/GuildScheduledEvent.ts","../../src/structures/guilds/Integration.ts","../../src/structures/invites/BaseInvite.ts","../../src/structures/guilds/InviteGuild.ts","../../src/structures/invites/GuildInvite.ts","../../src/structures/stickers/Sticker.ts","../../src/structures/webhooks/WebhookMixin.ts","../../src/structures/webhooks/Webhook.ts","../../src/util/auditLogs.ts","../../src/managers/GuildEmojiRoleManager.ts","../../src/structures/emojis/GuildEmoji.ts","../../src/structures/guilds/GuildPreview.ts","../../src/structures/guilds/GuildAuditLogsEntry.ts","../../src/structures/guilds/WelcomeScreen.ts","../../src/managers/AutoModerationRuleManager.ts","../../src/structures/guilds/GuildBan.ts","../../src/managers/GuildBanManager.ts","../../src/managers/GuildChannelManager.ts","../../src/managers/GuildIntegrationManager.ts","../../src/managers/GuildScheduledEventManager.ts","../../src/structures/soundboards/SoundboardSound.ts","../../src/managers/GuildSoundboardSoundManager.ts","../../src/managers/StageInstanceManager.ts","../../src/managers/GuildEmojiManager.ts","../../src/managers/GuildInviteManager.ts","../../src/managers/GuildStickerManager.ts","../../src/managers/GuildManager.ts","../../src/managers/GuildMemberRoleManager.ts","../../src/structures/guilds/GuildMember.ts","../../src/structures/presences/RichPresenceAssets.ts","../../src/structures/presences/Activity.ts","../../src/structures/presences/Presence.ts","../../src/structures/voice/VoiceState.ts","../../src/util/errors.ts","../../src/managers/GuildMemberManager.ts","../../src/managers/ReactionUserManager.ts","../../src/structures/messages/MessageReaction.ts","../../src/managers/ReactionManager.ts","../../src/util/equal.ts","../../src/structures/messages/Attachment.ts","../../src/structures/messages/Embed.ts","../../src/structures/messages/MessageMentions.ts","../../src/structures/polls/PollAnswer.ts","../../src/structures/polls/Poll.ts","../../src/structures/messages/Message.ts","../../src/managers/MessageManager.ts","../../src/structures/guilds/Role.ts","../../src/managers/RoleManager.ts","../../src/managers/WebhookManager.ts","../../src/structures/guilds/GuildTemplate.ts","../../src/managers/GuildTemplateManager.ts","../../src/managers/VoiceStateManager.ts","../../src/managers/PresenceManager.ts","../../src/managers/ThreadManager.ts","../../src/structures/channels/ThreadMember.ts","../../src/managers/ThreadMemberManager.ts","../../src/managers/UserManager.ts","../../src/structures/invites/GroupDMInvite.ts","../../src/structures/guilds/Widget.ts","../../src/structures/stickers/StickerPack.ts","../../src/structures/automoderation/AutoModerationActionExecution.ts","../../src/structures/users/ClientUser.ts","../../src/structures/channels/Typing.ts","../../src/util/events.ts","../../src/util/Partials.ts","../../src/util/dispatch.ts","../../src/actions/Action.ts","../../src/util/DispatchQueue.ts","../../src/util/sessions.ts","../../src/GatewayClient.ts","../../src/util/decorators.ts"],"sourcesContent":["import { Listener } from \"@wolfstar/http-framework\";\nimport type { Awaitable } from \"@wolfstar/plugin-cache\";\nimport type { GatewayEventMap, GatewayEventName } from \"./util/events.js\";\n\n/**\n * A {@link Listener} bound to one of the {@link GatewayEventMap} events of the {@link GatewayClient}, with strongly\n * typed arguments. It is loaded from the `listeners` directory by `client.load()` like any other listener.\n *\n * @example\n * ```typescript\n * // listeners/log-messages.ts\n * import { EventGatewayListener, type Message } from '@wolfstar/plugin-gateway';\n *\n * export class LogMessagesListener extends EventGatewayListener<'messageCreate'> {\n * public constructor(context: EventGatewayListener.LoaderContext) {\n * super(context, { event: 'messageCreate' });\n * }\n *\n * public override run(message: Message) {\n * console.log(`${message.author.username}: ${message.content}`);\n * }\n * }\n * ```\n */\nexport abstract class EventGatewayListener<\n Event extends GatewayEventName = GatewayEventName,\n> extends Listener<EventGatewayListener.ResolvedOptions<Event>> {\n /**\n * Whether this listener unloads itself after its first run.\n */\n public readonly once: boolean;\n\n public constructor(\n context: EventGatewayListener.LoaderContext,\n options: EventGatewayListener.Options<Event>,\n ) {\n super(context, { ...options, emitter: \"client\" });\n this.once = options.once ?? false;\n\n if (this.once) {\n // `_listener` is what the framework's loader strategy attaches to the emitter, wrapping it is the only way to\n // unload the piece on its first run while keeping `run` overridable.\n // oxlint-disable-next-line no-underscore-dangle\n const listener = this._listener;\n // oxlint-disable-next-line no-underscore-dangle\n this._listener = async (...args: readonly unknown[]) => {\n await this.unload();\n return listener(...args);\n };\n }\n }\n\n public abstract override run(...args: GatewayEventMap[Event]): Awaitable<unknown>;\n}\n\nexport namespace EventGatewayListener {\n export type LoaderContext = Listener.LoaderContext;\n\n export interface Options<Event extends GatewayEventName = GatewayEventName> extends Omit<\n Listener.Options,\n \"emitter\" | \"event\"\n > {\n /**\n * The event to listen to.\n */\n event: Event;\n /**\n * Whether to unload the listener after its first run.\n *\n * @default false\n */\n once?: boolean;\n }\n\n export interface ResolvedOptions<Event extends GatewayEventName = GatewayEventName>\n extends Listener.Options {\n event: Event;\n once?: boolean;\n }\n}\n","import {\n type OverwriteType,\n PermissionFlagsBits,\n type APIGuildForumDefaultReactionEmoji,\n type APIGuildForumTag,\n type APIOverwrite,\n type ChannelFlags,\n type ChannelType,\n type ForumLayoutType,\n type RESTPatchAPIChannelJSONBody,\n type SortOrderType,\n type ThreadAutoArchiveDuration,\n type VideoQualityMode,\n} from \"discord-api-types/v10\";\nimport {\n PermissionsBitField,\n type PermissionResolvable,\n type PermissionsString,\n} from \"./PermissionsBitField.js\";\n\n/**\n * Something with an ID: a structure, or the ID itself.\n */\nexport type IdResolvable = string | { id: string | null };\n\n/**\n * Gets the ID of an {@link IdResolvable}.\n *\n * @param value The ID, or something with one.\n */\nexport function resolveId(value: IdResolvable): string {\n const id = typeof value === \"string\" ? value : value.id;\n if (!id) throw new TypeError(\"Cannot resolve an ID from a structure without one\");\n return id;\n}\n\n/**\n * A permission overwrite to set on a channel: whom it targets, and what it allows and denies.\n */\nexport interface OverwriteData {\n /**\n * The role or member the overwrite targets.\n */\n id: IdResolvable;\n /**\n * Whether `id` is a role or a member. Required when `id` is a plain ID.\n */\n type: OverwriteType;\n allow?: PermissionResolvable;\n deny?: PermissionResolvable;\n}\n\n/**\n * Permissions to change in an overwrite: `true` allows, `false` denies, `null` falls back to the role or `@everyone`.\n */\nexport type PermissionOverwriteOptions = Partial<Record<PermissionsString, boolean | null>>;\n\n/**\n * Converts an {@link OverwriteData} to the API's shape.\n */\nexport function toAPIOverwrite(overwrite: OverwriteData): APIOverwrite {\n return {\n id: resolveId(overwrite.id),\n type: overwrite.type,\n allow: String(PermissionsBitField.resolve(overwrite.allow ?? 0n)),\n deny: String(PermissionsBitField.resolve(overwrite.deny ?? 0n)),\n };\n}\n\n/**\n * Applies {@link PermissionOverwriteOptions} to an overwrite's allowed and denied permissions.\n *\n * @param options The permissions to change.\n * @param initial The overwrite's current permissions, none by default.\n */\nexport function resolveOverwriteOptions(\n options: PermissionOverwriteOptions,\n initial: { allow?: bigint; deny?: bigint } = {},\n): { allow: bigint; deny: bigint } {\n let allow = initial.allow ?? 0n;\n let deny = initial.deny ?? 0n;\n for (const [name, value] of Object.entries(options)) {\n const bit = PermissionFlagsBits[name as PermissionsString];\n if (value === undefined || bit === undefined) continue;\n allow &= ~bit;\n deny &= ~bit;\n if (value === true) allow |= bit;\n else if (value === false) deny |= bit;\n }\n\n return { allow, deny };\n}\n\n/**\n * A forum tag to set: an existing one (with its ID) or a new one.\n */\nexport type GuildForumTagData = Omit<APIGuildForumTag, \"id\" | \"moderated\"> &\n Partial<Pick<APIGuildForumTag, \"id\" | \"moderated\">>;\n\n/**\n * The fields of a guild channel that can be edited. Each applies to the channel types that have it.\n */\nexport interface GuildChannelEditOptions {\n name?: string;\n /**\n * Converts a text channel to an announcement channel, or back.\n */\n type?: ChannelType.GuildText | ChannelType.GuildAnnouncement;\n position?: number;\n topic?: string | null;\n nsfw?: boolean;\n rateLimitPerUser?: number;\n bitrate?: number;\n userLimit?: number;\n permissionOverwrites?: readonly OverwriteData[];\n /**\n * The category, `null` to move the channel out of its category.\n */\n parent?: IdResolvable | null;\n /**\n * Whether to copy the category's overwrites: the new one with `parent`, else the current one. Exclusive with\n * `permissionOverwrites`.\n */\n lockPermissions?: boolean;\n rtcRegion?: string | null;\n videoQualityMode?: VideoQualityMode;\n defaultAutoArchiveDuration?: ThreadAutoArchiveDuration;\n availableTags?: readonly GuildForumTagData[];\n defaultReactionEmoji?: APIGuildForumDefaultReactionEmoji | null;\n defaultThreadRateLimitPerUser?: number;\n defaultSortOrder?: SortOrderType | null;\n defaultForumLayout?: ForumLayoutType;\n flags?: ChannelFlags;\n /**\n * Whether a thread is archived.\n */\n archived?: boolean;\n /**\n * Whether a thread is locked: only moderators can unarchive it.\n */\n locked?: boolean;\n /**\n * Whether non-moderators can add members to a private thread.\n */\n invitable?: boolean;\n /**\n * The minutes of inactivity after which a thread is archived.\n */\n autoArchiveDuration?: ThreadAutoArchiveDuration;\n /**\n * The IDs of the tags of a thread of a forum or media channel.\n */\n appliedTags?: readonly string[];\n reason?: string;\n}\n\n/**\n * Converts {@link GuildChannelEditOptions} to the API's body, without `lockPermissions` which needs the parent.\n */\nexport function toChannelBody(\n options: GuildChannelEditOptions | GuildChannelCreateOptions,\n): RESTPatchAPIChannelJSONBody {\n const body: Record<string, unknown> = {\n name: options.name,\n type: options.type,\n position: options.position,\n topic: options.topic,\n nsfw: options.nsfw,\n rate_limit_per_user: options.rateLimitPerUser,\n bitrate: options.bitrate,\n user_limit: options.userLimit,\n permission_overwrites: options.permissionOverwrites?.map(toAPIOverwrite),\n parent_id:\n options.parent === undefined\n ? undefined\n : options.parent === null\n ? null\n : resolveId(options.parent),\n rtc_region: options.rtcRegion,\n video_quality_mode: options.videoQualityMode,\n default_auto_archive_duration: options.defaultAutoArchiveDuration,\n available_tags: options.availableTags,\n default_reaction_emoji: options.defaultReactionEmoji,\n default_thread_rate_limit_per_user: options.defaultThreadRateLimitPerUser,\n default_sort_order: options.defaultSortOrder,\n default_forum_layout: options.defaultForumLayout,\n flags: \"flags\" in options ? options.flags : undefined,\n archived: \"archived\" in options ? options.archived : undefined,\n locked: \"locked\" in options ? options.locked : undefined,\n invitable: \"invitable\" in options ? options.invitable : undefined,\n auto_archive_duration:\n \"autoArchiveDuration\" in options ? options.autoArchiveDuration : undefined,\n applied_tags: \"appliedTags\" in options ? options.appliedTags : undefined,\n };\n for (const key of Object.keys(body)) if (body[key] === undefined) delete body[key];\n return body as RESTPatchAPIChannelJSONBody;\n}\n\n/**\n * The options to create a guild channel with.\n */\nexport interface GuildChannelCreateOptions extends Omit<\n GuildChannelEditOptions,\n | \"type\"\n | \"lockPermissions\"\n | \"flags\"\n | \"archived\"\n | \"locked\"\n | \"invitable\"\n | \"autoArchiveDuration\"\n | \"appliedTags\"\n> {\n name: string;\n type?: ChannelType;\n}\n","import type { StructureMixin } from \"./Structure.js\";\n\n/**\n * Any class, abstract or not.\n */\nexport type MixinBase = abstract new (...args: any[]) => object;\n\ntype UnionToIntersection<Union> = (Union extends unknown ? (value: Union) => void : never) extends (\n value: infer Intersection,\n) => void\n ? Intersection\n : never;\n\n/**\n * The members `Mixins` add to a class extending `Base`, for the interface declaring them.\n *\n * @remarks\n * Following `@discordjs/structures`' `MixinTypes`, the members `Base` already declares are left out: `Base` keeps typing\n * them, even though the mixins' implementations win at runtime, which must therefore stay assignable to `Base`'s types.\n * {@link StructureMixin}'s members are left out too: the interface extends it directly, so they keep their `this` type.\n *\n * ```typescript\n * export interface TextChannel\n * extends\n * StructureMixin<ChannelDataType<ChannelType.GuildText>>,\n * MixinTypes<BaseTextChannel, [TextChannelMixin<ChannelType.GuildText>]> {}\n * export class TextChannel extends BaseTextChannel {}\n * Mixin(TextChannel, [TextChannelMixin]);\n * ```\n *\n * @typeParam Base The class the mixins are mixed into.\n * @typeParam Mixins The instance types of the mixins.\n */\nexport type MixinTypes<Base extends object, Mixins extends readonly object[]> = Omit<\n UnionToIntersection<Mixins[number]>,\n keyof Base | keyof StructureMixin<object>\n>;\n\n/**\n * Copies the members of every mixin onto the prototype of `target`, the way `@discordjs/structures`' `Mixin` does.\n *\n * @remarks\n * Prototype members are copied. Static `DataTemplate`, `optimizeData`, and `enrichToJSON` hooks are\n * combined with the target's behavior, following `@discordjs/structures`.\n * Mixins must not rely on their constructor running. Declare an interface with the same name as `target`, extending\n * every mixin, so the members are visible to the type system as well:\n *\n * ```typescript\n * export interface TextChannel extends TextChannelMixin<ChannelType.GuildText> {}\n * export class TextChannel extends Channel<ChannelType.GuildText> {}\n * Mixin(TextChannel, [TextChannelMixin]);\n * ```\n *\n * Members already defined on `target` itself win over the mixins', and earlier mixins win over later ones.\n *\n * @param target The class to mix into.\n * @param mixins The classes whose members are copied.\n */\nexport function Mixin(target: MixinBase, mixins: readonly MixinBase[]): void {\n const prototype = target.prototype as object;\n const optimizations: Array<(this: object, data: object) => void> = [];\n const enrichments: Array<(this: object, data: object) => void> = [];\n const templates: object[] = [];\n const jsonKey = Symbol.for(\"djs.structures.mixin.toJSON\");\n const inheritedOptimization = Reflect.get(prototype, \"optimizeData\") as\n | ((this: object, data: object) => void)\n | undefined;\n if (inheritedOptimization) optimizations.push(inheritedOptimization);\n const inheritedEnrichment = Reflect.get(prototype, jsonKey) as\n | ((this: object, data: object) => void)\n | undefined;\n if (inheritedEnrichment) enrichments.push(inheritedEnrichment);\n\n for (const mixin of mixins) {\n const template = Reflect.get(mixin, \"DataTemplate\") as object | undefined;\n if (template) templates.push(template);\n const optimize = Reflect.get(mixin, \"optimizeData\") as\n | ((this: object, data: object) => void)\n | undefined;\n if (optimize) optimizations.push(optimize);\n const enrich = Reflect.get(mixin, \"enrichToJSON\") as\n | ((this: object, data: object) => void)\n | undefined;\n if (enrich) enrichments.push(enrich);\n for (const key of Reflect.ownKeys(mixin.prototype as object)) {\n if (key === \"constructor\") continue;\n\n const descriptor = Reflect.getOwnPropertyDescriptor(mixin.prototype as object, key)!;\n if (Object.hasOwn(prototype, key)) continue;\n Reflect.defineProperty(prototype, key, descriptor);\n }\n }\n\n if (optimizations.length > 1) {\n Reflect.defineProperty(prototype, \"optimizeData\", {\n configurable: true,\n value(this: object, data: object) {\n for (const optimize of optimizations) optimize.call(this, data);\n },\n });\n }\n\n if (templates.length > 0) {\n const base = Reflect.get(target, \"DataTemplate\") as object | undefined;\n const template = Object.defineProperties({}, Object.getOwnPropertyDescriptors(base ?? {}));\n for (const addition of templates) {\n Object.defineProperties(template, Object.getOwnPropertyDescriptors(addition));\n }\n Reflect.defineProperty(target, \"DataTemplate\", {\n configurable: true,\n value: template,\n });\n }\n\n if (enrichments.length > 0) {\n Reflect.defineProperty(prototype, jsonKey, {\n configurable: true,\n value(this: object, data: object) {\n for (const enrich of enrichments) enrich.call(this, data);\n },\n });\n }\n}\n","import { container } from \"@wolfstar/http-framework\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\n\n/**\n * Gets the {@link GatewayClient} registered in the framework's container.\n *\n * @remarks\n * The framework's `Client` registers itself as `container.client` on construction, so this is the most recently\n * constructed `GatewayClient`. It throws when that client is a plain `Client`.\n */\nexport function getGatewayClient(): GatewayClient {\n const { client } = container;\n if (!client || !(\"gateway\" in client)) {\n throw new Error(\"No GatewayClient has been constructed yet\");\n }\n\n return client as GatewayClient;\n}\n\ndeclare module \"@sapphire/pieces\" {\n interface Container {\n /**\n * The most recently constructed {@link GatewayClient}, which registers itself here on construction next to\n * `container.client`, so pieces reach its managers without {@link getGatewayClient} or a cast.\n *\n * @remarks\n * `container.client` keeps the framework's `Client` type: a module augmentation cannot redeclare a property with\n * another type (TS2717), and under `skipLibCheck` the framework's declaration silently wins.\n */\n gatewayClient: GatewayClient;\n }\n}\n","import { Structure as BaseStructure } from \"@discordjs/structures\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport { Mixin } from \"./Mixin.js\";\n\n// `@discordjs/structures` keys a structure's data and its patch/clone methods with symbols it does not export. They\n// are created with `Symbol.for`, in the global registry, so the same key yields the very same symbols here. Each is\n// typed as a `unique symbol` of our own, which lets the structures declare typed members keyed by them.\n\n/**\n * The symbol under which a {@link Structure} stores its raw API data, shared with `@discordjs/structures`.\n */\nexport const kData: unique symbol = Symbol.for(\"djs.structures.data\") as never;\n\n/**\n * The symbol of the method patching a {@link Structure}'s raw data in place, shared with `@discordjs/structures`.\n */\nexport const kPatch: unique symbol = Symbol.for(\"djs.structures.patch\") as never;\n\n/**\n * The symbol of the method cloning a {@link Structure}, shared with `@discordjs/structures`.\n */\nexport const kClone: unique symbol = Symbol.for(\"djs.structures.clone\") as never;\n\n/**\n * The symbol under which a {@link Structure} stores its relations: the structures its manager resolved from the cache,\n * like a message's author or a channel's guild.\n */\nexport const kRelations: unique symbol = Symbol.for(\"wolfstar.structures.relations\") as never;\n\n/**\n * The symbol under which a {@link Structure} stores the client that built it, see {@link StructureMixin.client}.\n */\nexport const kClient: unique symbol = Symbol.for(\"wolfstar.structures.client\") as never;\n\n/**\n * The symbol of the optional method a mixin defines to drop the relations a patch invalidates, called by\n * {@link StructureMixin}'s patch before the data is patched. Mixins cannot override the patch itself: the first mixin\n * defining a member wins, and {@link StructureMixin} comes first.\n *\n * @internal\n */\nexport const kPatchRelations: unique symbol = Symbol.for(\n \"wolfstar.structures.patchRelations\",\n) as never;\n\n/**\n * The Discord epoch, used to extract timestamps from snowflakes.\n */\nconst DiscordEpoch = 1_420_070_400_000n;\n\ntype Patch<Data> = (this: object, data: Readonly<Partial<Data>>) => unknown;\n\nconst kTimestamps: unique symbol = Symbol(\"wolfstar.structures.timestamps\") as never;\n\n/**\n * The members every structure of this package has on top of `@discordjs/structures`' own: relations resolved from the\n * cache, public patch/clone methods, and parsed timestamps.\n *\n * @remarks\n * It is mixed into {@link Structure} and into every class extending one of `@discordjs/structures`' structures, which\n * also have to call {@link initStructure} from their constructor:\n *\n * ```typescript\n * export interface User extends StructureMixin<APIUser> {}\n * export class User extends BaseUser {\n * public constructor(data: Partial<APIUser>, relations: object = {}) {\n * super(data);\n * initStructure(this, data, relations);\n * }\n * }\n * Mixin(User, [StructureMixin]);\n * ```\n *\n * @typeParam Data The raw API data the structure wraps.\n * @typeParam Relations The relations of the structure, resolved from the cache by its manager.\n */\nexport class StructureMixin<Data extends object, Relations extends object = object> {\n /**\n * The raw API data of this structure.\n */\n declare protected [kData]: Readonly<Data>;\n\n /**\n * The relations of this structure, resolved from the cache by its manager. Public only so that\n * {@link StructureMixin.dropRelations} can check relation names against it.\n *\n * @internal\n */\n declare public [kRelations]: Relations;\n\n declare private [kTimestamps]?: Map<string, number | null>;\n\n /**\n * The client that built this structure, set by its manager.\n *\n * @internal\n */\n declare public [kClient]?: GatewayClient;\n\n /**\n * The client that instantiated this structure, like discord.js's `Base#client`: the one whose manager built it, or\n * the most recently constructed {@link GatewayClient} for structures built by hand from a raw payload.\n *\n * @remarks\n * It is not part of the structure's data, so it is neither serialized by `toJSON` nor stored in the cache.\n */\n public get client(): GatewayClient {\n return this[kClient] ?? getGatewayClient();\n }\n\n /**\n * Patches the raw data of this structure in place, with a shallow merge.\n *\n * @param data The updated data.\n * @returns This structure.\n */\n public [kPatch](data: Readonly<Partial<Data>>): this {\n (this as { [kPatchRelations]?: (data: object) => void })[kPatchRelations]?.(data);\n (BaseStructure.prototype as unknown as Record<typeof kPatch, Patch<Data>>)[kPatch].call(\n this,\n data,\n );\n return this;\n }\n\n /**\n * Creates a copy of this structure, optionally patching the copy.\n *\n * @param patch The data to patch the copy with.\n * @returns The copy.\n */\n public [kClone](patch?: Readonly<Partial<Data>>): this {\n const clone = (BaseStructure.prototype as unknown as Record<typeof kClone, Patch<Data>>)[\n kClone\n ].call(this, patch ?? ({} as Readonly<Partial<Data>>)) as this;\n clone[kRelations] = { ...this[kRelations] };\n if (this[kClient]) clone[kClient] = this[kClient];\n return clone;\n }\n\n /** Parses a timestamp once when constructing or patching a structure. */\n protected optimizeTimestamp(key: string, value: string | null | undefined): void {\n if (value !== undefined) {\n (this[kTimestamps] ??= new Map()).set(key, value ? Date.parse(value) : null);\n }\n }\n\n /** Gets a timestamp previously parsed by `optimizeData`. */\n protected optimizedTimestamp(key: string): number | null {\n return this[kTimestamps]?.get(key) ?? null;\n }\n\n /**\n * Forgets resolved relations, e.g. when a patch carries fresher data for them.\n *\n * @param names The names of the relations.\n */\n protected dropRelations(...names: (keyof this[typeof kRelations] & string)[]): void {\n const relations: Record<string, unknown> = { ...(this[kRelations] as object) };\n for (const name of names) delete relations[name];\n this[kRelations] = relations as Relations;\n }\n\n /**\n * Forgets the relations whose ID a patch changes, e.g. a channel's parent when the patch moves it to another\n * category. A patch carrying the same ID keeps the relation.\n *\n * @param data The patch.\n * @param fields The names of the relations, mapped to the raw field holding their ID.\n */\n protected dropChangedRelations(\n data: object,\n fields: Partial<Record<keyof Relations & string, string>>,\n ): void {\n const current = this[kData] as Record<string, unknown>;\n const patch = data as Record<string, unknown>;\n const names = Object.entries(fields as Record<string, string>)\n .filter(([, key]) => key in patch && patch[key] !== current[key])\n .map(([name]) => name);\n if (names.length > 0) this.dropRelations(...(names as never[]));\n }\n}\n\n/**\n * Sets up the members {@link StructureMixin} adds, from the constructor of a structure extending one of\n * `@discordjs/structures`'.\n *\n * @param structure The structure being constructed.\n * @param data The raw API data it was constructed with.\n * @param relations The related structures, resolved from the cache by the structure's manager.\n */\nexport function initStructure(structure: object, data: object, relations: object): void {\n (structure as StructureMixin<object>)[kRelations] = relations;\n // `@discordjs/structures` only runs `optimizeData` from the constructors of the classes implementing it, which the\n // mixins' optimizations are not part of. Running it again is harmless: it only (re)parses fields.\n (structure as unknown as { optimizeData(data: object): void }).optimizeData(data);\n}\n\nexport interface Structure<\n Data extends object,\n Omitted extends keyof Data | \"\" = \"\",\n> extends StructureMixin<Data> {}\n\n/**\n * The base class of the structures `@discordjs/structures` has no counterpart for: its `Structure`, with\n * {@link StructureMixin} mixed in.\n *\n * @remarks\n * Structures can be built from any raw payload, be it a gateway dispatch, a cache hit, or a REST response. Their\n * {@link StructureMixin.client | client} is the one whose manager built them, the most recently constructed one\n * otherwise.\n *\n * @typeParam Data The raw API data this structure wraps.\n * @typeParam Omitted The keys the structure's `DataTemplate` strips from the stored data.\n */\nexport abstract class Structure<\n Data extends object,\n Omitted extends keyof Data | \"\" = \"\",\n> extends BaseStructure<Data, Omitted> {\n /**\n * @param data The raw API data.\n * @param relations The related structures, resolved from the cache by the structure's manager.\n */\n public constructor(data: Readonly<Partial<Data>>, relations: object = {}) {\n super(data as never);\n initStructure(this, data, relations);\n }\n}\n\nMixin(Structure, [StructureMixin]);\n\n/**\n * Binds a structure to the client that built it, see {@link StructureMixin.client}.\n *\n * @param structure The structure.\n * @param client The client.\n * @returns The structure.\n * @internal\n */\nexport function bindClient<Value extends object>(structure: Value, client: GatewayClient): Value {\n (structure as StructureMixin<object>)[kClient] = client;\n return structure;\n}\n\n/**\n * Gets the timestamp, in milliseconds, a snowflake was created at.\n *\n * @param id The snowflake.\n */\nexport function snowflakeTimestamp(id: string): number {\n return Number((BigInt(id) >> 22n) + DiscordEpoch);\n}\n","import {\n ActivityFlagsBitField as BaseActivityFlagsBitField,\n AttachmentFlagsBitField as BaseAttachmentFlagsBitField,\n BitField,\n ChannelFlagsBitField as BaseChannelFlagsBitField,\n MessageFlagsBitField as BaseMessageFlagsBitField,\n type BitFieldResolvable,\n} from \"@discordjs/structures\";\nimport {\n GatewayIntentBits,\n GuildMemberFlags,\n GuildSystemChannelFlags,\n RoleFlags,\n UserFlags,\n type ActivityFlags,\n type AttachmentFlags,\n type ChannelFlags,\n type MessageFlags,\n} from \"discord-api-types/v10\";\n\n// `@discordjs/structures`' `BitField.resolve` returns a flag's enum value as is, which is a `number` for the 32-bit\n// flag enums: combining it with the `bigint` bits then throws \"Cannot mix BigInt and other types\". Every flags bitfield\n// below overrides `resolve` to always return a `bigint`, including the ones `@discordjs/structures` ships.\n\n/**\n * A 32-bit flags bitfield, resolving flag names to `bigint`s and serializing to a `number`.\n */\nexport abstract class NumberFlagsBitField<Flags extends string> extends BitField<Flags> {\n public static override resolve<Flags extends string = string>(\n bit: BitFieldResolvable<Flags>,\n ): bigint {\n return BigInt(super.resolve(bit));\n }\n\n public override toJSON(): number {\n return super.toJSON(true) as number;\n }\n}\n\nexport type ActivityFlagsString = keyof typeof ActivityFlags;\nexport type ActivityFlagsResolvable = BitFieldResolvable<ActivityFlagsString>;\n\n/**\n * The flags of a presence activity.\n */\nexport class ActivityFlagsBitField extends BaseActivityFlagsBitField {\n public static override resolve<Flags extends string = string>(\n bit: BitFieldResolvable<Flags>,\n ): bigint {\n return BigInt(super.resolve(bit));\n }\n}\n\nexport type AttachmentFlagsString = keyof typeof AttachmentFlags;\nexport type AttachmentFlagsResolvable = BitFieldResolvable<AttachmentFlagsString>;\n\n/**\n * The flags of a message attachment.\n */\nexport class AttachmentFlagsBitField extends BaseAttachmentFlagsBitField {\n public static override resolve<Flags extends string = string>(\n bit: BitFieldResolvable<Flags>,\n ): bigint {\n return BigInt(super.resolve(bit));\n }\n}\n\nexport type ChannelFlagsString = keyof typeof ChannelFlags;\nexport type ChannelFlagsResolvable = BitFieldResolvable<ChannelFlagsString>;\n\n/**\n * The flags of a channel.\n */\nexport class ChannelFlagsBitField extends BaseChannelFlagsBitField {\n public static override resolve<Flags extends string = string>(\n bit: BitFieldResolvable<Flags>,\n ): bigint {\n return BigInt(super.resolve(bit));\n }\n}\n\nexport type MessageFlagsString = keyof typeof MessageFlags;\nexport type MessageFlagsResolvable = BitFieldResolvable<MessageFlagsString>;\n\n/**\n * The flags of a message.\n */\nexport class MessageFlagsBitField extends BaseMessageFlagsBitField {\n public static override resolve<Flags extends string = string>(\n bit: BitFieldResolvable<Flags>,\n ): bigint {\n return BigInt(super.resolve(bit));\n }\n}\n\nexport type GuildMemberFlagsString = keyof typeof GuildMemberFlags;\nexport type GuildMemberFlagsResolvable = BitFieldResolvable<GuildMemberFlagsString>;\n\n/**\n * The flags of a guild member.\n */\nexport class GuildMemberFlagsBitField extends NumberFlagsBitField<GuildMemberFlagsString> {\n public static override readonly Flags = GuildMemberFlags;\n}\n\nexport type IntentsString = keyof typeof GatewayIntentBits;\nexport type IntentsResolvable = BitFieldResolvable<IntentsString>;\n\n/**\n * The gateway intents to identify with.\n */\nexport class IntentsBitField extends NumberFlagsBitField<IntentsString> {\n public static override readonly Flags = GatewayIntentBits;\n}\n\nexport type RoleFlagsString = keyof typeof RoleFlags;\nexport type RoleFlagsResolvable = BitFieldResolvable<RoleFlagsString>;\n\n/**\n * The flags of a role.\n */\nexport class RoleFlagsBitField extends NumberFlagsBitField<RoleFlagsString> {\n public static override readonly Flags = RoleFlags;\n}\n\nexport type SystemChannelFlagsString = keyof typeof GuildSystemChannelFlags;\nexport type SystemChannelFlagsResolvable = BitFieldResolvable<SystemChannelFlagsString>;\n\n/**\n * The flags of a guild's system channel, deciding which system messages are suppressed.\n */\nexport class SystemChannelFlagsBitField extends NumberFlagsBitField<SystemChannelFlagsString> {\n public static override readonly Flags = GuildSystemChannelFlags;\n}\n\nexport type UserFlagsString = keyof typeof UserFlags;\nexport type UserFlagsResolvable = BitFieldResolvable<UserFlagsString>;\n\n/**\n * The flags (badges) of a user.\n */\nexport class UserFlagsBitField extends NumberFlagsBitField<UserFlagsString> {\n public static override readonly Flags = UserFlags;\n}\n","import type { Channel as BaseChannelStructure } from \"@discordjs/structures\";\nimport { type ChannelType } from \"discord-api-types/v10\";\nimport { ChannelFlagsBitField } from \"../../../util/flags.js\";\nimport type { ChannelDataType, ChannelRelations } from \"../Channel.js\";\nimport {\n kData,\n kPatch,\n kPatchRelations,\n snowflakeTimestamp,\n type StructureMixin,\n} from \"../../Structure.js\";\n\nexport interface BaseChannelMixin<Type extends ChannelType = ChannelType>\n extends BaseChannelStructure<Type>, StructureMixin<ChannelDataType<Type>, ChannelRelations> {}\n\n/**\n * Adds what every channel shares on top of `@discordjs/structures`' `Channel`: its relations, and the REST actions\n * every channel supports.\n */\nexport class BaseChannelMixin<Type extends ChannelType = ChannelType> {\n /**\n * Forgets the parent when a patch moves the channel.\n *\n * @internal\n */\n public [kPatchRelations](data: object): void {\n this.dropChangedRelations(data, { parent: \"parent_id\" });\n }\n\n /**\n * Whether the channel is partial, like discord.js's `BaseChannel#partial`: only direct messages can be, see\n * `Partials.Channel`.\n */\n public get partial(): boolean {\n return false;\n }\n\n /**\n * The flags of the channel.\n */\n public get flags(): Readonly<ChannelFlagsBitField> {\n return new ChannelFlagsBitField(this[kData].flags ?? 0).freeze();\n }\n\n public get createdTimestamp(): number {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt(): Date {\n return new Date(this.createdTimestamp);\n }\n\n public toString(): `<#${string}>` {\n return `<#${this.id}>`;\n }\n\n /**\n * Deletes the channel, or closes it for a direct message, and drops it from the cache.\n *\n * @param reason The reason for the audit log.\n */\n public async delete(reason?: string): Promise<this> {\n await this.client.channels.delete(this.id, reason);\n return this;\n }\n\n /**\n * Fetches the channel from the API and patches this structure with the result.\n */\n public async fetch(): Promise<this> {\n const data = await this.client.api.channels.get(this.id);\n if (data.type !== this.type) {\n throw new TypeError(`Channel ${this.id} changed type from ${this.type} to ${data.type}`);\n }\n\n return this[kPatch](data as ChannelDataType<Type>);\n }\n}\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../../../managers/ChannelManager.js\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData, kRelations } from \"../../Structure.js\";\n\ntype Data = { parent_id?: string | null; nsfw?: boolean };\n\nexport interface ChannelParentMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the parent (a category, or a channel for threads) and the age restriction of guild channels.\n */\nexport class ChannelParentMixin<Type extends ChannelType = ChannelType> {\n public get parentId(): string | null {\n return (this[kData] as Data).parent_id ?? null;\n }\n\n /**\n * The parent of the channel, from the cache, like discord.js's `parent`: the category of a guild channel, or the\n * channel a thread belongs to. `null` when it has none, when it is not cached, or when the channel was not built by\n * a manager.\n */\n public get parent(): AnyChannel | null {\n return this[kRelations].parent ?? null;\n }\n\n public get nsfw(): boolean {\n return (this[kData] as Data).nsfw ?? false;\n }\n}\n","import type { APIOverwrite } from \"discord-api-types/v10\";\nimport type { PermissionOverwriteOptions } from \"../../util/channels.js\";\nimport { PermissionsBitField } from \"../../util/PermissionsBitField.js\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport { kData, kPatch, kRelations, Structure } from \"../Structure.js\";\n\n/**\n * The relations of a {@link PermissionOverwrites}: the channel it belongs to.\n */\nexport interface PermissionOverwritesRelations {\n channel?: AnyChannel | null;\n}\n\n/**\n * The raw data of a permission overwrite, with the channel it belongs to.\n */\nexport type PermissionOverwritesData = APIOverwrite & { channel_id: string };\nconst kOptimizedAllow: unique symbol = Symbol(\"overwrite.allow\");\nconst kOptimizedDeny: unique symbol = Symbol(\"overwrite.deny\");\n\n/**\n * A permission overwrite of a channel: what it allows and denies to a role or a member.\n */\nexport class PermissionOverwrites extends Structure<PermissionOverwritesData> {\n declare public [kRelations]: PermissionOverwritesRelations;\n\n declare protected [kOptimizedAllow]: bigint;\n declare protected [kOptimizedDeny]: bigint;\n\n protected override optimizeData(data: Partial<PermissionOverwritesData>): void {\n if (data.allow !== undefined) this[kOptimizedAllow] = BigInt(data.allow);\n if (data.deny !== undefined) this[kOptimizedDeny] = BigInt(data.deny);\n }\n\n /**\n * The ID of the role or member the overwrite targets.\n */\n public get id() {\n return this[kData].id;\n }\n\n public get channelId() {\n return this[kData].channel_id;\n }\n\n /**\n * The channel the overwrite belongs to, like discord.js's `PermissionOverwrites#channel`: `null` when the overwrite\n * was not read from a channel.\n */\n public get channel(): AnyChannel | null {\n return this[kRelations].channel ?? null;\n }\n\n /**\n * Whether the overwrite targets a role or a member.\n */\n public get type() {\n return this[kData].type;\n }\n\n public get allow(): Readonly<PermissionsBitField> {\n return new PermissionsBitField(this[kOptimizedAllow] ?? 0n).freeze();\n }\n\n public get deny(): Readonly<PermissionsBitField> {\n return new PermissionsBitField(this[kOptimizedDeny] ?? 0n).freeze();\n }\n\n /**\n * Changes some permissions of the overwrite, keeping the others.\n *\n * @param options The permissions to change.\n * @param reason The reason for the audit log.\n */\n public async edit(options: PermissionOverwriteOptions, reason?: string): Promise<this> {\n const overwrites = await this.client.channels.permissionOverwrites(this.channelId);\n const edited = await overwrites.edit(this.id, options, { type: this.type, reason });\n return this[kPatch](edited.toJSON());\n }\n\n /**\n * Deletes the overwrite.\n *\n * @param reason The reason for the audit log.\n */\n public async delete(reason?: string): Promise<this> {\n const overwrites = await this.client.channels.permissionOverwrites(this.channelId);\n await overwrites.delete(this.id, reason);\n return this;\n }\n}\n","import { OverwriteType, type APIOverwrite } from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { bindClient } from \"../structures/Structure.js\";\nimport type { AnyChannel } from \"./ChannelManager.js\";\nimport { PermissionOverwrites } from \"../structures/channels/PermissionOverwrites.js\";\nimport {\n resolveId,\n resolveOverwriteOptions,\n type IdResolvable,\n type OverwriteData,\n type PermissionOverwriteOptions,\n} from \"../util/channels.js\";\n\n/**\n * The options of {@link PermissionOverwriteManager.create} and {@link PermissionOverwriteManager.edit}.\n */\nexport interface PermissionOverwriteEditOptions {\n /**\n * Whether the target is a role or a member. Guessed from the cache when absent: a cached role of the guild with\n * that ID makes it a role, anything else a member.\n */\n type?: OverwriteType;\n reason?: string;\n}\n\n/**\n * Manages the permission overwrites of one channel, as they were in the channel's payload.\n */\nexport class PermissionOverwriteManager {\n public readonly client: GatewayClient;\n public readonly channelId: string;\n public readonly guildId: string | null;\n\n readonly #overwrites: readonly APIOverwrite[];\n\n readonly #channel: AnyChannel | null;\n\n /**\n * @param client The client.\n * @param channelId The ID of the channel.\n * @param guildId The ID of the channel's guild, if known.\n * @param overwrites The raw overwrites of the channel.\n * @param channel The channel, which the overwrites refer to.\n */\n public constructor(\n client: GatewayClient,\n channelId: string,\n guildId: string | null,\n overwrites: readonly APIOverwrite[],\n channel: AnyChannel | null = null,\n ) {\n this.client = client;\n this.channelId = channelId;\n this.guildId = guildId;\n this.#overwrites = overwrites;\n this.#channel = channel;\n }\n\n /**\n * The overwrites of the channel.\n */\n public get cache(): PermissionOverwrites[] {\n return this.#overwrites.map((overwrite) =>\n bindClient(\n new PermissionOverwrites(\n { ...overwrite, channel_id: this.channelId },\n { channel: this.#channel },\n ),\n this.client,\n ),\n );\n }\n\n /**\n * Finds the overwrite of a role or member, if the channel has one.\n *\n * @param target The role or member, or its ID.\n */\n public resolve(target: IdResolvable): PermissionOverwrites | null {\n const id = resolveId(target);\n return this.cache.find((overwrite) => overwrite.id === id) ?? null;\n }\n\n /**\n * Replaces every overwrite of the channel.\n *\n * @param overwrites The new overwrites.\n * @param reason The reason for the audit log.\n */\n public async set(overwrites: readonly OverwriteData[], reason?: string): Promise<void> {\n await this.client.channels.edit(this.channelId, { permissionOverwrites: overwrites, reason });\n }\n\n /**\n * Creates the overwrite of a role or member, replacing any existing one.\n *\n * @param target The role or member, or its ID.\n * @param options The permissions to allow (`true`) or deny (`false`).\n * @param editOptions The target's type and the reason for the audit log.\n */\n public create(\n target: IdResolvable,\n options: PermissionOverwriteOptions,\n editOptions: PermissionOverwriteEditOptions = {},\n ): Promise<PermissionOverwrites> {\n return this.upsert(target, options, editOptions, false);\n }\n\n /**\n * Changes some permissions of the overwrite of a role or member, creating it if needed.\n *\n * @param target The role or member, or its ID.\n * @param options The permissions to allow (`true`), deny (`false`), or reset (`null`).\n * @param editOptions The target's type and the reason for the audit log.\n */\n public edit(\n target: IdResolvable,\n options: PermissionOverwriteOptions,\n editOptions: PermissionOverwriteEditOptions = {},\n ): Promise<PermissionOverwrites> {\n return this.upsert(target, options, editOptions, true);\n }\n\n /**\n * Deletes the overwrite of a role or member.\n *\n * @param target The role or member, or its ID.\n * @param reason The reason for the audit log.\n */\n public async delete(target: IdResolvable, reason?: string): Promise<void> {\n const id = resolveId(target);\n await this.client.api.channels.deletePermissionOverwrite(this.channelId, id, { reason });\n await this.patchCached((overwrites) => overwrites.filter((overwrite) => overwrite.id !== id));\n }\n\n private async upsert(\n target: IdResolvable,\n options: PermissionOverwriteOptions,\n editOptions: PermissionOverwriteEditOptions,\n keepExisting: boolean,\n ): Promise<PermissionOverwrites> {\n const id = resolveId(target);\n const existing = keepExisting ? this.resolve(id) : null;\n const type = editOptions.type ?? existing?.type ?? (await this.guessType(target, id));\n const { allow, deny } = resolveOverwriteOptions(options, {\n allow: existing?.allow.bitField,\n deny: existing?.deny.bitField,\n });\n\n const overwrite: APIOverwrite = { id, type, allow: String(allow), deny: String(deny) };\n await this.client.api.channels.editPermissionOverwrite(\n this.channelId,\n id,\n {\n type,\n allow: overwrite.allow,\n deny: overwrite.deny,\n },\n {\n reason: editOptions.reason,\n },\n );\n await this.patchCached((overwrites) => [\n ...overwrites.filter((current) => current.id !== id),\n overwrite,\n ]);\n return new PermissionOverwrites({ ...overwrite, channel_id: this.channelId });\n }\n\n private async guessType(target: IdResolvable, id: string): Promise<OverwriteType> {\n if (typeof target !== \"string\") {\n // Roles have a `hoist` flag, members and users do not.\n return \"hoist\" in target ? OverwriteType.Role : OverwriteType.Member;\n }\n\n if (id === this.guildId) return OverwriteType.Role;\n const role = this.guildId ? await this.client.roles.get(this.guildId, id) : undefined;\n return role ? OverwriteType.Role : OverwriteType.Member;\n }\n\n // The overwrite endpoints answer 204 without the channel, so the cached entry is patched instead of refetched.\n private async patchCached(\n update: (overwrites: readonly APIOverwrite[]) => APIOverwrite[],\n ): Promise<void> {\n const cache = this.client.cache?.channels;\n const cached = await cache?.get(this.channelId);\n if (!cached || !(\"permission_overwrites\" in cached)) return;\n await cache!.set(this.channelId, {\n ...cached,\n permission_overwrites: update(cached.permission_overwrites ?? []),\n } as typeof cached);\n }\n}\n","import {\n OverwriteType,\n PermissionFlagsBits,\n type APIOverwrite,\n type APIRole,\n type Snowflake,\n} from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../managers/ChannelManager.js\";\nimport type { GuildMember } from \"../structures/guilds/GuildMember.js\";\nimport type { Role } from \"../structures/guilds/Role.js\";\nimport { getGatewayClient } from \"./container.js\";\nimport { PermissionsBitField } from \"./PermissionsBitField.js\";\n\n/**\n * What {@link computeGuildPermissions} needs to know about a member of a guild.\n */\nexport interface GuildPermissionsContext {\n guildId: Snowflake;\n ownerId: Snowflake;\n userId: Snowflake;\n /**\n * The IDs of the member's roles, without `@everyone`.\n */\n memberRoleIds: readonly Snowflake[];\n /**\n * Every role of the guild, `@everyone` (whose ID is the guild's) included.\n */\n roles: readonly Pick<APIRole, \"id\" | \"permissions\">[];\n}\n\n/**\n * Computes a member's guild-wide permissions, the way Discord does before channel overwrites apply: the owner and\n * administrators get every permission, everyone else gets `@everyone`'s permissions combined with their roles'.\n *\n * @param context The member and the guild's roles.\n */\nexport function computeGuildPermissions(context: GuildPermissionsContext): PermissionsBitField {\n if (context.userId === context.ownerId) {\n return new PermissionsBitField(PermissionsBitField.All).freeze();\n }\n\n const granted = new Set([context.guildId, ...context.memberRoleIds]);\n let bits = 0n;\n for (const role of context.roles) {\n if (granted.has(role.id)) bits |= BigInt(role.permissions);\n }\n\n if ((bits & PermissionFlagsBits.Administrator) === PermissionFlagsBits.Administrator) {\n bits = PermissionsBitField.All;\n }\n\n return new PermissionsBitField(bits).freeze();\n}\n\n/**\n * Compares two roles the way Discord orders them: by position, then by ID for equal positions (older first).\n *\n * @returns A negative number when `a` is lower than `b`, a positive one when it is higher, `0` when they are the same.\n */\nexport function compareRolePositions(\n a: Pick<APIRole, \"id\" | \"position\">,\n b: Pick<APIRole, \"id\" | \"position\">,\n): number {\n if (a.position !== b.position) return a.position - b.position;\n // Among equal positions, the older (lower ID) role is the higher one.\n return Number(BigInt(b.id) - BigInt(a.id));\n}\n\n/**\n * What {@link computeChannelPermissions} needs to know about a channel and whom the permissions are for.\n */\nexport interface ChannelPermissionsContext {\n guildId: Snowflake;\n /**\n * The ID of the member, whose own overwrite applies last. Absent when computing a role's permissions.\n */\n userId?: Snowflake;\n /**\n * The IDs of the roles whose overwrites apply, without `@everyone`.\n */\n roleIds: readonly Snowflake[];\n overwrites: readonly APIOverwrite[];\n}\n\n/**\n * Applies a channel's permission overwrites to guild-wide permissions, the way Discord does: administrators keep\n * every permission, then the `@everyone` overwrite applies, then the roles' overwrites (combined), then the member's.\n *\n * @param base The guild-wide permissions, from {@link computeGuildPermissions}.\n * @param context The channel's overwrites, and the member or role.\n */\nexport function computeChannelPermissions(\n base: Readonly<PermissionsBitField>,\n context: ChannelPermissionsContext,\n): PermissionsBitField {\n if (base.has(PermissionFlagsBits.Administrator)) {\n return new PermissionsBitField(PermissionsBitField.All).freeze();\n }\n\n let bits = base.bitField;\n const apply = (allow: bigint, deny: bigint) => {\n bits = (bits & ~deny) | allow;\n };\n\n const everyone = context.overwrites.find((overwrite) => overwrite.id === context.guildId);\n if (everyone) apply(BigInt(everyone.allow), BigInt(everyone.deny));\n\n let allow = 0n;\n let deny = 0n;\n for (const overwrite of context.overwrites) {\n if (overwrite.type === OverwriteType.Role && context.roleIds.includes(overwrite.id)) {\n allow |= BigInt(overwrite.allow);\n deny |= BigInt(overwrite.deny);\n }\n }\n apply(allow, deny);\n\n const member = context.userId\n ? context.overwrites.find(\n (overwrite) => overwrite.type === OverwriteType.Member && overwrite.id === context.userId,\n )\n : undefined;\n if (member) apply(BigInt(member.allow), BigInt(member.deny));\n\n return new PermissionsBitField(bits).freeze();\n}\n\n/**\n * Computes the permissions of a member or role in a channel, given the channel's overwrites.\n *\n * @param guildId The ID of the channel's guild.\n * @param overwrites The channel's permission overwrites.\n * @param target A member, a role, or the ID of a member.\n */\nexport async function computeTargetPermissions(\n guildId: Snowflake,\n overwrites: readonly APIOverwrite[],\n target: GuildMember | Role | Snowflake,\n): Promise<PermissionsBitField> {\n const client = getGatewayClient();\n if (typeof target !== \"string\" && \"hoist\" in target) {\n // A role gets `@everyone`'s permissions and its own, then the `@everyone` and role overwrites.\n const everyone = await client.roles.everyone(guildId);\n const base = new PermissionsBitField(\n target.permissions.bitField | everyone.permissions.bitField,\n );\n if (base.has(PermissionFlagsBits.Administrator)) {\n return new PermissionsBitField(PermissionsBitField.All).freeze();\n }\n\n return computeChannelPermissions(base, { guildId, roleIds: [target.id], overwrites });\n }\n\n const member = typeof target === \"string\" ? await client.members.fetch(guildId, target) : target;\n return computeChannelPermissions(await member.fetchPermissions(), {\n guildId,\n userId: member.id ?? undefined,\n roleIds: member.roleIds,\n overwrites,\n });\n}\n\n/**\n * Computes the permissions of a member or role in a channel, fetching the channel if needed. Threads use their parent\n * channel's overwrites, like Discord does.\n *\n * @param channel The channel, or its ID.\n * @param target A member, a role, or the ID of a member.\n */\nexport async function computePermissionsIn(\n channel: AnyChannel | Snowflake,\n target: GuildMember | Role | Snowflake,\n): Promise<PermissionsBitField> {\n const client = getGatewayClient();\n let resolved = typeof channel === \"string\" ? await client.channels.fetch(channel) : channel;\n let data = resolved.toJSON() as OverwriteHolder;\n if (resolved.isThread() && data.parent_id) {\n resolved = await client.channels.fetch(data.parent_id);\n data = resolved.toJSON() as OverwriteHolder;\n }\n\n if (!data.guild_id) throw new Error(`Channel ${resolved.id} has no known guild`);\n return computeTargetPermissions(data.guild_id, data.permission_overwrites ?? [], target);\n}\n\ntype OverwriteHolder = {\n guild_id?: string;\n parent_id?: string | null;\n permission_overwrites?: APIOverwrite[];\n};\n","import type { GuildChannelEditOptions } from \"../../../util/channels.js\";\nimport { kPatch, type StructureMixin } from \"../../Structure.js\";\n\n/**\n * Edits a channel through `client.channels` and patches the structure with the result. Shared by the mixins' setters.\n *\n * @param channel The channel structure.\n * @param options The fields to edit.\n */\nexport async function editChannel<Value extends StructureMixin<object> & { id: string }>(\n channel: Value,\n options: GuildChannelEditOptions,\n): Promise<Value> {\n const edited = await channel.client.channels.edit(channel.id, options);\n return channel[kPatch](edited.toJSON() as never);\n}\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData, kPatch, kRelations } from \"../../Structure.js\";\nimport type { APIOverwrite } from \"discord-api-types/v10\";\nimport { PermissionOverwriteManager } from \"../../../managers/PermissionOverwriteManager.js\";\nimport type { IdResolvable } from \"../../../util/channels.js\";\nimport { computeTargetPermissions } from \"../../../util/permissions.js\";\nimport type { PermissionsBitField } from \"../../../util/PermissionsBitField.js\";\nimport type { GuildMember } from \"../../guilds/GuildMember.js\";\nimport type { Role } from \"../../guilds/Role.js\";\nimport { editChannel } from \"./edit.js\";\n\ntype Data = {\n guild_id?: string;\n parent_id?: string | null;\n position?: number;\n permission_overwrites?: APIOverwrite[];\n};\n\n// Whether two channels have the same permission overwrites, in any order.\nfunction sameOverwrites(channel: Data, parent: Data): boolean {\n const own = channel.permission_overwrites ?? [];\n const theirs = parent.permission_overwrites ?? [];\n return (\n own.length === theirs.length &&\n own.every((overwrite) =>\n theirs.some(\n (other) =>\n other.id === overwrite.id &&\n other.type === overwrite.type &&\n other.allow === overwrite.allow &&\n other.deny === overwrite.deny,\n ),\n )\n );\n}\n\nexport interface ChannelPermissionMixin<\n Type extends ChannelType = ChannelType,\n> extends Channel<Type> {}\n\n/**\n * Adds the position and permission overwrites of guild channels other than threads.\n */\nexport class ChannelPermissionMixin<Type extends ChannelType = ChannelType> {\n public get position(): number {\n return (this[kData] as Data).position ?? 0;\n }\n\n /**\n * The permission overwrites of the channel.\n */\n public get permissionOverwrites(): PermissionOverwriteManager {\n const data = this[kData] as Data;\n return new PermissionOverwriteManager(\n this.client,\n this.id,\n data.guild_id ?? null,\n data.permission_overwrites ?? [],\n this as never,\n );\n }\n\n /**\n * Whether the channel's overwrites are the same as its category's, like discord.js's\n * `GuildChannel#permissionsLocked`: `null` when it has no category, or when the category is not cached (see\n * {@link ChannelPermissionMixin.fetchPermissionsLocked}).\n */\n public get permissionsLocked(): boolean | null {\n const { parent } = this[kRelations];\n if (!parent) return null;\n return sameOverwrites(this[kData] as Data, parent.toJSON() as Data);\n }\n\n /**\n * Moves the channel.\n *\n * @param position The new position, or the offset from the current one with `relative`.\n * @param options Whether the position is relative, and the reason for the audit log.\n */\n public async setPosition(\n position: number,\n options: { relative?: boolean; reason?: string } = {},\n ): Promise<this> {\n const { guild_id: guildId } = this[kData] as Data;\n if (!guildId) throw new Error(`Channel ${this.id} has no known guild`);\n\n const target = options.relative ? this.position + position : position;\n await this.client.guilds\n .channels(guildId)\n .setPositions([{ channel: this.id, position: target }], options.reason);\n return this[kPatch]({ position: target } as never);\n }\n\n /**\n * Moves the channel into a category, or out of its category.\n *\n * @param parent The category, `null` to move the channel out.\n * @param options Whether to copy the category's overwrites (the default), and the reason for the audit log.\n */\n public setParent(\n parent: IdResolvable | null,\n options: { lockPermissions?: boolean; reason?: string } = {},\n ): Promise<this> {\n return editChannel(this, {\n parent,\n lockPermissions: options.lockPermissions ?? true,\n reason: options.reason,\n });\n }\n\n public setNSFW(nsfw = true, reason?: string): Promise<this> {\n return editChannel(this, { nsfw, reason });\n }\n\n /**\n * Replaces the channel's overwrites with its category's.\n *\n * @param reason The reason for the audit log.\n */\n public lockPermissions(reason?: string): Promise<this> {\n if (!(this[kData] as Data).parent_id) {\n throw new Error(`Channel ${this.id} has no category to sync its permissions with`);\n }\n\n return editChannel(this, { lockPermissions: true, reason });\n }\n\n /**\n * Fetches whether the channel's overwrites are the same as its category's. `null` without a category.\n */\n public async fetchPermissionsLocked(): Promise<boolean | null> {\n const { parent_id: parentId } = this[kData] as Data;\n if (!parentId) return null;\n\n const parent = (await this.client.channels.fetch(parentId)).toJSON() as Data;\n return sameOverwrites(this[kData] as Data, parent);\n }\n\n /**\n * Fetches the permissions of a member or role in the channel: their guild permissions with the channel's overwrites\n * applied. discord.js: `channel.permissionsFor(memberOrRole)`.\n *\n * @param target A member, a role, or the ID of a member.\n */\n public async fetchPermissionsFor(\n target: GuildMember | Role | string,\n ): Promise<Readonly<PermissionsBitField>> {\n const { guild_id: guildId, permission_overwrites: overwrites = [] } = this[kData] as Data;\n if (!guildId) throw new Error(`Channel ${this.id} has no known guild`);\n return computeTargetPermissions(guildId, overwrites, target);\n }\n}\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData } from \"../../Structure.js\";\nimport { editChannel } from \"./edit.js\";\n\ntype Data = { rate_limit_per_user?: number };\n\nexport interface ChannelSlowmodeMixin<\n Type extends ChannelType = ChannelType,\n> extends Channel<Type> {}\n\n/**\n * Adds the slowmode of channels users can send messages in.\n */\nexport class ChannelSlowmodeMixin<Type extends ChannelType = ChannelType> {\n /**\n * The slowmode, in seconds. `0` when disabled.\n */\n public get rateLimitPerUser(): number {\n return (this[kData] as Data).rate_limit_per_user ?? 0;\n }\n\n /**\n * Sets the slowmode.\n *\n * @param rateLimitPerUser The slowmode, in seconds, `0` to disable it.\n * @param reason The reason for the audit log.\n */\n public setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise<this> {\n return editChannel(this, { rateLimitPerUser, reason });\n }\n}\n","import type { GatewayClient } from \"../GatewayClient.js\";\nimport type {\n AnyThreadChannel,\n FetchArchivedThreadsOptions,\n FetchedThreads,\n ThreadCreateOptions,\n} from \"./ThreadManager.js\";\n\n/**\n * Manages the threads of one channel: `client.threads`, with the channel's ID filled in.\n */\nexport class ChannelThreadManager {\n public readonly client: GatewayClient;\n public readonly channelId: string;\n public readonly guildId: string | null;\n\n public constructor(client: GatewayClient, channelId: string, guildId: string | null) {\n this.client = client;\n this.channelId = channelId;\n this.guildId = guildId;\n }\n\n /**\n * Creates a thread in the channel, or a post in a forum or media channel (with `message`).\n *\n * @param options The thread's name and settings.\n */\n public create(options: ThreadCreateOptions): Promise<AnyThreadChannel> {\n return this.client.threads.create(this.channelId, options);\n }\n\n /**\n * Fetches the active threads of the channel, and caches them.\n */\n public async fetchActive(): Promise<FetchedThreads> {\n if (!this.guildId) throw new Error(`Channel ${this.channelId} has no known guild`);\n\n // Discord only lists the active threads of a whole guild.\n const { threads, members } = await this.client.threads.fetchActive(this.guildId);\n const own = threads.filter((thread) => thread.parentId === this.channelId);\n const ids = new Set(own.map((thread) => thread.id));\n return {\n threads: own,\n members: members.filter((member) => member.threadId && ids.has(member.threadId)),\n hasMore: false,\n };\n }\n\n /**\n * Fetches the archived threads of the channel, and caches them.\n *\n * @param options Public or private threads, and the page.\n */\n public fetchArchived(options?: FetchArchivedThreadsOptions): Promise<FetchedThreads> {\n return this.client.threads.fetchArchived(this.channelId, options);\n }\n}\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport { ChannelThreadManager } from \"../../../managers/ChannelThreadManager.js\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData } from \"../../Structure.js\";\n\ntype Data = { guild_id?: string };\n\nexport interface ChannelThreadsMixin<\n Type extends ChannelType = ChannelType,\n> extends Channel<Type> {}\n\n/**\n * Adds the threads of the channels that can have threads.\n */\nexport class ChannelThreadsMixin<Type extends ChannelType = ChannelType> {\n /**\n * The threads of the channel.\n */\n public get threads(): ChannelThreadManager {\n return new ChannelThreadManager(this.client, this.id, (this[kData] as Data).guild_id ?? null);\n }\n}\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { WebhookCreateOptions } from \"../../../managers/WebhookManager.js\";\nimport type { Channel } from \"../Channel.js\";\nimport type { Webhook } from \"../../webhooks/Webhook.js\";\n\nexport interface ChannelWebhooksMixin<\n Type extends ChannelType = ChannelType,\n> extends Channel<Type> {}\n\n/**\n * Adds the webhook actions of the channels that can have webhooks.\n */\nexport class ChannelWebhooksMixin<Type extends ChannelType = ChannelType> {\n /**\n * Fetches the webhooks of the channel.\n */\n public fetchWebhooks(): Promise<Webhook[]> {\n return this.client.webhooks.fetchChannel(this.id);\n }\n\n /**\n * Creates a webhook in the channel.\n *\n * @param options The webhook's name and avatar, and the reason for the audit log.\n */\n public createWebhook(options: WebhookCreateOptions): Promise<Webhook> {\n return this.client.webhooks.create(this.id, options);\n }\n}\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData } from \"../../Structure.js\";\nimport { editChannel } from \"./edit.js\";\n\ntype Data = { topic?: string | null };\n\nexport interface ChannelTopicMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the topic of text, announcement, forum, and media channels.\n */\nexport class ChannelTopicMixin<Type extends ChannelType = ChannelType> {\n public get topic(): string | null {\n return (this[kData] as Data).topic ?? null;\n }\n\n public setTopic(topic: string | null, reason?: string): Promise<this> {\n return editChannel(this, { topic, reason });\n }\n}\n","import type {\n APIGuildForumDefaultReactionEmoji,\n APIGuildForumTag,\n APIOverwrite,\n ChannelType,\n ForumLayoutType,\n SortOrderType,\n ThreadAutoArchiveDuration,\n VideoQualityMode,\n} from \"discord-api-types/v10\";\nimport type { Channel } from \"../Channel.js\";\nimport type { Guild } from \"../../guilds/Guild.js\";\nimport { kData, kRelations } from \"../../Structure.js\";\nimport type { GuildChannelCreateOptions, GuildChannelEditOptions } from \"../../../util/channels.js\";\nimport type { AnyChannel } from \"../../../managers/ChannelManager.js\";\nimport { editChannel } from \"./edit.js\";\n\ntype Data = { guild_id?: string; name?: string | null };\n\n// Every field `clone` copies, whichever the channel type.\ntype CloneableData = Data & {\n topic?: string | null;\n nsfw?: boolean;\n bitrate?: number;\n user_limit?: number;\n rate_limit_per_user?: number;\n parent_id?: string | null;\n position?: number;\n rtc_region?: string | null;\n video_quality_mode?: VideoQualityMode;\n default_auto_archive_duration?: ThreadAutoArchiveDuration;\n available_tags?: APIGuildForumTag[];\n default_reaction_emoji?: APIGuildForumDefaultReactionEmoji | null;\n default_thread_rate_limit_per_user?: number;\n default_sort_order?: SortOrderType | null;\n default_forum_layout?: ForumLayoutType;\n permission_overwrites?: APIOverwrite[];\n};\n\nexport interface GuildChannelMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the fields every guild channel has, threads included.\n */\nexport class GuildChannelMixin<Type extends ChannelType = ChannelType> {\n /**\n * The ID of the guild, when the payload included it.\n */\n public get guildId(): string | null {\n return (this[kData] as Data).guild_id ?? null;\n }\n\n /**\n * The guild, from the cache. `null` when the guild is not cached, or when the channel was not built by a manager: use\n * `fetchGuild()` to always get it.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * Fetches the guild, cache first. `null` when the payload did not include the guild's ID.\n */\n public async fetchGuild(): Promise<Guild | null> {\n const { guildId } = this;\n return guildId ? this.client.guilds.fetch(guildId) : null;\n }\n\n public get name(): string {\n return (this[kData] as Data).name ?? \"\";\n }\n\n /**\n * Edits the channel.\n *\n * @param options The fields to edit, and the reason for the audit log.\n */\n public edit(options: GuildChannelEditOptions): Promise<this> {\n return editChannel(this, options);\n }\n\n public setName(name: string, reason?: string): Promise<this> {\n return editChannel(this, { name, reason });\n }\n\n /**\n * Creates a copy of the channel in its guild: same type, name, settings, and overwrites.\n *\n * @param options The fields to change on the copy.\n */\n public async clone(options: Partial<GuildChannelCreateOptions> = {}): Promise<AnyChannel> {\n const { guildId } = this;\n if (!guildId) throw new Error(`Channel ${this.id} has no known guild`);\n\n const data = this[kData] as CloneableData;\n return this.client.guilds.channels(guildId).create({\n name: data.name ?? \"\",\n type: this.type,\n topic: data.topic,\n nsfw: data.nsfw,\n bitrate: data.bitrate,\n userLimit: data.user_limit,\n rateLimitPerUser: data.rate_limit_per_user,\n parent: data.parent_id,\n position: data.position,\n rtcRegion: data.rtc_region,\n videoQualityMode: data.video_quality_mode,\n defaultAutoArchiveDuration: data.default_auto_archive_duration,\n availableTags: data.available_tags,\n defaultReactionEmoji: data.default_reaction_emoji,\n defaultThreadRateLimitPerUser: data.default_thread_rate_limit_per_user,\n defaultSortOrder: data.default_sort_order,\n defaultForumLayout: data.default_forum_layout,\n permissionOverwrites: data.permission_overwrites?.map((overwrite) => ({\n id: overwrite.id,\n type: overwrite.type,\n allow: BigInt(overwrite.allow),\n deny: BigInt(overwrite.deny),\n })),\n ...options,\n });\n }\n}\n","import type { GatewayClient } from \"../GatewayClient.js\";\nimport type { Message } from \"../structures/messages/Message.js\";\nimport type { FetchOptions } from \"./CachedManager.js\";\nimport type { EmojiIdentifierResolvable } from \"../structures/emojis/ReactionEmoji.js\";\nimport type { User } from \"../structures/users/User.js\";\nimport type {\n MessageListOptions,\n MessageThreadCreateOptions,\n PinnedMessage,\n} from \"./MessageManager.js\";\nimport type { AnyThreadChannel } from \"./ThreadManager.js\";\nimport type {\n MessageCreateOptions,\n MessageEditOptions,\n MessagePayloadResolvable,\n} from \"../util/messages.js\";\n\n/**\n * Manages the messages of one channel: `client.messages`, with the channel's ID filled in.\n */\nexport class ChannelMessageManager {\n public readonly client: GatewayClient;\n public readonly channelId: string;\n\n public constructor(client: GatewayClient, channelId: string) {\n this.client = client;\n this.channelId = channelId;\n }\n\n /**\n * Gets a message of the channel from the cache.\n */\n public get(messageId: string): Promise<Message | undefined> {\n return this.client.messages.get(this.channelId, messageId);\n }\n\n /**\n * Gets a message of the channel from the cache, falling back to the API.\n */\n public fetch(messageId: string, options?: FetchOptions): Promise<Message> {\n return options\n ? this.client.messages.fetch(this.channelId, messageId, options)\n : this.client.messages.fetch(this.channelId, messageId);\n }\n\n /**\n * Lists the messages of the channel, newest first.\n */\n public list(options?: MessageListOptions): Promise<Message[]> {\n return this.client.messages.list(this.channelId, options);\n }\n\n public send(options: MessagePayloadResolvable<MessageCreateOptions>): Promise<Message> {\n return this.client.messages.send(this.channelId, options);\n }\n\n public edit(\n messageId: string,\n options: MessagePayloadResolvable<MessageEditOptions>,\n ): Promise<Message> {\n return this.client.messages.edit(this.channelId, messageId, options);\n }\n\n public delete(messageId: string, reason?: string): Promise<void> {\n return this.client.messages.delete(this.channelId, messageId, reason);\n }\n\n public fetchPins(options?: { limit?: number; before?: Date | number }): Promise<{\n items: PinnedMessage[];\n hasMore: boolean;\n }> {\n return this.client.messages.fetchPins(this.channelId, options);\n }\n\n public pin(messageId: string, reason?: string): Promise<void> {\n return this.client.messages.pin(this.channelId, messageId, reason);\n }\n\n public unpin(messageId: string, reason?: string): Promise<void> {\n return this.client.messages.unpin(this.channelId, messageId, reason);\n }\n\n public crosspost(messageId: string): Promise<Message> {\n return this.client.messages.crosspost(this.channelId, messageId);\n }\n\n public bulkDelete(messages: readonly string[] | number, filterOld = false): Promise<string[]> {\n return this.client.messages.bulkDelete(this.channelId, messages, filterOld);\n }\n\n public forward(messageId: string, targetChannelId: string): Promise<Message> {\n return this.client.messages.forward(this.channelId, messageId, targetChannelId);\n }\n\n public react(messageId: string, emoji: EmojiIdentifierResolvable): Promise<void> {\n return this.client.messages.react(this.channelId, messageId, emoji);\n }\n\n public removeReactionEmoji(messageId: string, emoji: EmojiIdentifierResolvable): Promise<void> {\n return this.client.messages.removeReactionEmoji(this.channelId, messageId, emoji);\n }\n\n public removeAllReactions(messageId: string): Promise<void> {\n return this.client.messages.removeAllReactions(this.channelId, messageId);\n }\n\n public startThread(\n messageId: string,\n options: MessageThreadCreateOptions,\n ): Promise<AnyThreadChannel> {\n return this.client.messages.startThread(this.channelId, messageId, options);\n }\n\n public endPoll(messageId: string): Promise<Message> {\n return this.client.messages.endPoll(this.channelId, messageId);\n }\n\n public fetchPollAnswerVoters(\n messageId: string,\n answerId: number,\n options?: { limit?: number; after?: string },\n ): Promise<User[]> {\n return this.client.messages.fetchPollAnswerVoters(this.channelId, messageId, answerId, options);\n }\n}\n","import { readFile } from \"node:fs/promises\";\nimport { basename } from \"node:path\";\nimport type { RawFile } from \"@discordjs/rest\";\nimport {\n MessageReferenceType,\n type APIAllowedMentions,\n type APIAttachment,\n type APIEmbed,\n type RESTAPIMessageReference,\n type APIMessageTopLevelComponent,\n type APIPollAnswer,\n type AllowedMentionsTypes,\n type PollLayoutType,\n type RESTAPIPoll,\n type RESTPostAPIChannelMessageJSONBody,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../../GatewayClient.js\";\nimport { MessageFlagsBitField, type MessageFlagsResolvable } from \"../../util/flags.js\";\n\n/**\n * Anything with a `toJSON` method, like the builders of `@discordjs/builders` and the structures of this package.\n */\nexport interface JSONEncodable<Value> {\n toJSON(): Value;\n}\n\n/**\n * Data a file can be resolved from: its contents, a path on disk, a URL, a stream, or a blob.\n */\nexport type BufferResolvable =\n | Uint8Array\n | ArrayBuffer\n | string\n | Blob\n | AsyncIterable<Uint8Array | string>;\n\n/**\n * A file described along with its attachment metadata, like discord.js's `AttachmentPayload`.\n */\nexport interface AttachmentPayload {\n /**\n * The contents of the file.\n */\n attachment: BufferResolvable;\n /**\n * The name of the file, inferred from a path or URL when omitted.\n */\n name?: string;\n /**\n * The description (alt text) of the file.\n */\n description?: string;\n /**\n * The title of the file.\n */\n title?: string;\n /**\n * Whether to mark the file as a spoiler, by prefixing its name with `SPOILER_`.\n */\n spoiler?: boolean;\n /**\n * The duration of a voice message, in seconds.\n */\n duration?: number;\n /**\n * The waveform of a voice message, base64-encoded.\n */\n waveform?: string;\n}\n\n/**\n * A file to attach to a message: a {@link RawFile} of `@discordjs/rest`, an {@link AttachmentPayload}, anything with\n * a `toJSON` returning one (e.g. an attachment builder), or its raw contents.\n */\nexport type AttachmentResolvable =\n | RawFile\n | AttachmentPayload\n | JSONEncodable<AttachmentPayload>\n | BufferResolvable;\n\n/**\n * The mentions a message may ping, in camel case like discord.js's `MessageMentionOptions`, or the raw API object.\n */\nexport type MessageMentionOptions =\n | APIAllowedMentions\n | {\n parse?: readonly AllowedMentionsTypes[];\n roles?: readonly string[];\n users?: readonly string[];\n /**\n * Whether to ping the author of the message replied to.\n */\n repliedUser?: boolean;\n };\n\n/**\n * The message a message replies to.\n */\nexport interface ReplyOptions {\n /**\n * The message, or its ID.\n */\n messageReference: string | { readonly id: string; readonly channelId?: string };\n /**\n * Whether to fail when the message no longer exists, rather than sending a regular message.\n *\n * @default GatewayClientOptions.failIfNotExists ?? true\n */\n failIfNotExists?: boolean;\n}\n\n/**\n * The message a message forwards.\n */\nexport interface ForwardOptions {\n /**\n * The message, or its ID along with `channel`.\n */\n message:\n | string\n | { readonly id: string; readonly channelId: string; readonly guildId?: string | null };\n /**\n * The channel of the message, or its ID, needed when `message` is an ID.\n */\n channel?: string | { readonly id: string };\n /**\n * The guild of the message, or its ID.\n */\n guild?: string | { readonly id: string };\n}\n\n/**\n * A poll to create, in camel case like discord.js's `PollCreateData`.\n */\nexport interface PollCreateData {\n question: { text: string };\n answers: readonly {\n text?: string;\n emoji?: string | { id?: string | null; name?: string | null };\n }[];\n /**\n * How long the poll lasts, in hours.\n */\n duration: number;\n allowMultiselect?: boolean;\n layoutType?: PollLayoutType;\n}\n\n/**\n * The options every message payload accepts, when creating and editing.\n *\n * @remarks\n * The keys of the raw REST body (`allowed_mentions`, `message_reference`, `sticker_ids`...) are accepted too, and are\n * sent as they are: the camel case ones win when both are set.\n */\nexport interface BaseMessageOptions {\n content?: string | null;\n embeds?: readonly (APIEmbed | JSONEncodable<APIEmbed>)[] | null;\n components?:\n | readonly (APIMessageTopLevelComponent | JSONEncodable<APIMessageTopLevelComponent>)[]\n | null;\n /**\n * The files to upload.\n */\n files?: readonly AttachmentResolvable[];\n /**\n * The attachments to keep, when editing, or their metadata.\n */\n attachments?: readonly (Partial<APIAttachment> | JSONEncodable<Partial<APIAttachment>>)[];\n allowedMentions?: MessageMentionOptions;\n flags?: MessageFlagsResolvable;\n poll?: PollCreateData | RESTAPIPoll | JSONEncodable<RESTAPIPoll>;\n}\n\n/**\n * The options to send a message with.\n */\nexport interface MessageCreateOptions\n extends\n BaseMessageOptions,\n Omit<Partial<RESTPostAPIChannelMessageJSONBody>, keyof BaseMessageOptions> {\n tts?: boolean;\n nonce?: string | number;\n /**\n * Whether to refuse sending a message whose nonce was used recently, deduplicating retries.\n */\n enforceNonce?: boolean;\n /**\n * The message to reply to.\n */\n reply?: ReplyOptions;\n /**\n * The message to forward.\n */\n forward?: ForwardOptions;\n /**\n * The stickers to send, or their IDs.\n */\n stickers?: readonly (string | { readonly id: string })[];\n}\n\n/**\n * The options to edit a message with.\n */\nexport interface MessageEditOptions extends BaseMessageOptions {}\n\n/**\n * The options only webhooks accept.\n */\nexport interface WebhookMessageOptions {\n username?: string;\n avatarURL?: string;\n /**\n * The name of the post to create, for webhooks of forum and media channels.\n */\n threadName?: string;\n /**\n * The tags of the post to create, for webhooks of forum and media channels.\n */\n appliedTags?: readonly string[];\n /**\n * Whether to allow components on a message of a webhook not owned by an application.\n */\n withComponents?: boolean;\n}\n\n/**\n * The thread a webhook message is in, for webhooks of forum and media channels, or of a thread's parent.\n */\nexport interface WebhookThreadOptions {\n threadId?: string;\n}\n\n/**\n * The options to send a message through a webhook with.\n */\nexport interface WebhookMessageCreateOptions\n extends BaseMessageOptions, WebhookMessageOptions, WebhookThreadOptions {\n tts?: boolean;\n}\n\n/**\n * The options to edit a message sent by a webhook with.\n */\nexport interface WebhookMessageEditOptions extends MessageEditOptions, WebhookThreadOptions {}\n\n/**\n * Anything with a client, e.g. a structure, which a {@link MessagePayload} reads its defaults from.\n */\nexport type MessageTarget = { readonly client: GatewayClient } | GatewayClient;\n\n/**\n * The extra flags telling a {@link MessagePayload} what its target accepts.\n */\nexport interface MessagePayloadContext {\n /**\n * Whether the message is sent through a webhook, which accepts {@link WebhookMessageOptions}.\n */\n webhook?: boolean;\n /**\n * Whether the message is edited rather than created: `null` clears fields instead of leaving them out.\n */\n edit?: boolean;\n}\n\n/**\n * The options of any message payload.\n */\nexport type MessagePayloadOptions = MessageCreateOptions & WebhookMessageOptions;\n\n/**\n * Anything accepted where a message payload is expected: its content, its options, or a {@link MessagePayload}.\n */\nexport type MessagePayloadResolvable<Options extends object = MessageCreateOptions> =\n | string\n | Options\n | MessagePayload;\n\n/**\n * The body and files a {@link MessagePayload} resolved to, ready for `@discordjs/core`.\n */\nexport interface ResolvedMessagePayload<Body = RESTPostAPIChannelMessageJSONBody> {\n body: Body;\n files: RawFile[] | undefined;\n}\n\nconst kOptionKeys = new Set([\n \"content\",\n \"embeds\",\n \"components\",\n \"files\",\n \"attachments\",\n \"allowedMentions\",\n \"flags\",\n \"poll\",\n \"tts\",\n \"nonce\",\n \"enforceNonce\",\n \"reply\",\n \"forward\",\n \"stickers\",\n \"username\",\n \"avatarURL\",\n \"threadName\",\n \"appliedTags\",\n \"withComponents\",\n \"threadId\",\n]);\n\n/**\n * Normalizes the options of a message into the REST body and files Discord expects, like discord.js's\n * `MessagePayload`: camel case options, builders, reply and forward shortcuts, stickers, polls, and files from paths,\n * URLs, streams, or buffers.\n *\n * @example\n * ```typescript\n * const payload = MessagePayload.create(channel, {\n * content: \"Awoo\",\n * reply: { messageReference: message },\n * files: [\"./wolf.png\", { attachment: buffer, name: \"howl.ogg\", description: \"A howl\" }],\n * });\n * await channel.send(payload);\n * ```\n */\nexport class MessagePayload {\n /**\n * What the message is sent to: the structure it is sent through, or the client.\n */\n public readonly target: MessageTarget;\n\n /**\n * The options the payload was created with.\n */\n public readonly options: MessagePayloadOptions;\n\n /**\n * What the target accepts.\n */\n public readonly context: Readonly<MessagePayloadContext>;\n\n /**\n * The resolved REST body, set by {@link MessagePayload.resolveBody}.\n */\n public body: RESTPostAPIChannelMessageJSONBody | null = null;\n\n /**\n * The resolved files, set by {@link MessagePayload.resolveFiles}.\n */\n public files: RawFile[] | null = null;\n\n public constructor(\n target: MessageTarget,\n options: MessagePayloadOptions,\n context: MessagePayloadContext = {},\n ) {\n this.target = target;\n this.options = options;\n this.context = context;\n }\n\n /**\n * The client the target belongs to.\n */\n public get client(): GatewayClient {\n return \"gateway\" in this.target ? (this.target as GatewayClient) : this.target.client;\n }\n\n /**\n * Whether the message is sent through a webhook.\n */\n public get isWebhook(): boolean {\n return this.context.webhook === true;\n }\n\n /**\n * Whether the message is edited rather than created.\n */\n public get isEdit(): boolean {\n return this.context.edit === true;\n }\n\n /**\n * Resolves the content of the message: `null` clears it when editing, and is left out otherwise.\n */\n public makeContent(): string | null | undefined {\n const { content } = this.options;\n if (content === null) return this.isEdit ? \"\" : undefined;\n if (content === undefined) return undefined;\n if (typeof content !== \"string\")\n throw new TypeError(\"The content of a message must be a string\");\n return content;\n }\n\n /**\n * Resolves the REST body of the message.\n */\n public resolveBody(): this {\n if (this.body) return this;\n\n const { options } = this;\n const raw: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(options)) {\n if (!kOptionKeys.has(key)) raw[key] = value;\n }\n\n const body: Record<string, unknown> = { ...raw };\n const set = (key: string, value: unknown) => {\n if (value !== undefined) body[key] = value;\n };\n\n set(\"content\", this.makeContent());\n set(\"tts\", options.tts);\n set(\"nonce\", this.resolveNonce(options.nonce));\n set(\"enforce_nonce\", options.enforceNonce);\n set(\"embeds\", this.resolveList(options.embeds));\n set(\"components\", this.resolveList(options.components));\n set(\n \"flags\",\n options.flags === undefined ? undefined : Number(MessageFlagsBitField.resolve(options.flags)),\n );\n set(\"allowed_mentions\", this.resolveAllowedMentions());\n set(\"message_reference\", this.resolveReference());\n set(\n \"sticker_ids\",\n options.stickers?.map((sticker) => (typeof sticker === \"string\" ? sticker : sticker.id)),\n );\n set(\"poll\", this.resolvePoll());\n set(\"attachments\", this.resolveAttachments());\n\n if (this.isWebhook) {\n set(\"username\", options.username);\n set(\"avatar_url\", options.avatarURL);\n set(\"thread_name\", options.threadName);\n set(\"applied_tags\", options.appliedTags?.slice());\n set(\"with_components\", options.withComponents);\n }\n\n this.body = body as unknown as RESTPostAPIChannelMessageJSONBody;\n return this;\n }\n\n /**\n * Resolves the files of the message, reading them from disk, the network, or streams.\n */\n public async resolveFiles(): Promise<this> {\n if (this.files) return this;\n this.files = await Promise.all(\n (this.options.files ?? []).map((file) => MessagePayload.resolveFile(file)),\n );\n return this;\n }\n\n /**\n * Resolves both the body and the files, for `@discordjs/core`.\n */\n public async resolve<Body = RESTPostAPIChannelMessageJSONBody>(): Promise<\n ResolvedMessagePayload<Body>\n > {\n await this.resolveBody().resolveFiles();\n return {\n body: this.body as unknown as Body,\n files: this.files!.length > 0 ? this.files! : undefined,\n };\n }\n\n private resolveNonce(nonce: string | number | undefined): string | number | undefined {\n if (nonce === undefined) return undefined;\n if (typeof nonce === \"string\" && nonce.length > 25) {\n throw new RangeError(\"A message nonce must be at most 25 characters long\");\n }\n if (typeof nonce === \"number\" && !Number.isInteger(nonce)) {\n throw new RangeError(\"A message nonce must be an integer\");\n }\n return nonce;\n }\n\n private resolveList<Value extends object>(\n values: readonly (Value | JSONEncodable<Value>)[] | null | undefined,\n ): Value[] | undefined {\n if (values === null) return this.isEdit ? [] : undefined;\n return values?.map((value) => MessagePayload.toJSON(value));\n }\n\n private resolveAllowedMentions(): APIAllowedMentions | undefined {\n const mentions = this.options.allowedMentions ?? this.clientOption(\"allowedMentions\");\n if (mentions === undefined) return undefined;\n\n const { repliedUser, ...rest } = mentions as { repliedUser?: boolean } & APIAllowedMentions;\n const resolved: APIAllowedMentions = { ...rest };\n if (rest.parse) resolved.parse = [...rest.parse];\n if (rest.roles) resolved.roles = [...rest.roles];\n if (rest.users) resolved.users = [...rest.users];\n if (repliedUser !== undefined) resolved.replied_user = repliedUser;\n return resolved;\n }\n\n private resolveReference(): RESTAPIMessageReference | undefined {\n const { reply, forward } = this.options as MessageCreateOptions;\n if (forward) {\n const { message, channel, guild } = forward;\n const channelId =\n typeof message === \"string\" ? MessagePayload.id(channel) : message.channelId;\n if (!channelId) throw new TypeError(\"Forwarding a message by ID needs its channel\");\n return {\n type: MessageReferenceType.Forward,\n message_id: typeof message === \"string\" ? message : message.id,\n channel_id: channelId,\n guild_id:\n MessagePayload.id(guild) ??\n (typeof message === \"string\" ? undefined : (message.guildId ?? undefined)),\n };\n }\n\n if (reply) {\n const { messageReference, failIfNotExists = this.clientOption(\"failIfNotExists\") ?? true } =\n reply;\n const reference: RESTAPIMessageReference = {\n type: MessageReferenceType.Default,\n message_id: typeof messageReference === \"string\" ? messageReference : messageReference.id,\n fail_if_not_exists: failIfNotExists,\n };\n if (typeof messageReference !== \"string\" && messageReference.channelId) {\n reference.channel_id = messageReference.channelId;\n }\n return reference;\n }\n\n return undefined;\n }\n\n private resolvePoll(): RESTAPIPoll | undefined {\n const { poll } = this.options;\n if (poll === undefined) return undefined;\n if (\"toJSON\" in poll && typeof poll.toJSON === \"function\") return poll.toJSON();\n if (!(\"allowMultiselect\" in poll || \"layoutType\" in poll || isCamelPoll(poll)))\n return poll as RESTAPIPoll;\n\n const data = poll as PollCreateData;\n return {\n question: { text: data.question.text },\n answers: data.answers.map(\n ({ text, emoji }) =>\n ({\n poll_media: {\n text,\n emoji: typeof emoji === \"string\" ? resolvePartialEmoji(emoji) : (emoji ?? undefined),\n },\n }) as Omit<APIPollAnswer, \"answer_id\">,\n ),\n duration: data.duration,\n allow_multiselect: data.allowMultiselect ?? false,\n layout_type: data.layoutType,\n } as RESTAPIPoll;\n }\n\n private resolveAttachments(): Partial<APIAttachment>[] | undefined {\n const { files, attachments } = this.options;\n if (files === undefined && attachments === undefined) return undefined;\n\n const resolved: Partial<APIAttachment>[] = (attachments ?? []).map((attachment) =>\n MessagePayload.toJSON(attachment),\n );\n for (const [index, file] of (files ?? []).entries()) {\n const payload = MessagePayload.attachmentPayload(file);\n const attachment: Record<string, unknown> = { id: index.toString() };\n if (payload?.description !== undefined) attachment.description = payload.description;\n if (payload?.title !== undefined) attachment.title = payload.title;\n if (payload?.duration !== undefined) attachment.duration_secs = payload.duration;\n if (payload?.waveform !== undefined) attachment.waveform = payload.waveform;\n resolved.push(attachment as Partial<APIAttachment>);\n }\n return resolved;\n }\n\n private clientOption<Key extends \"allowedMentions\" | \"failIfNotExists\">(\n key: Key,\n ): GatewayClientMessageDefaults[Key] {\n try {\n return (this.client.options as GatewayClientMessageDefaults)[key];\n } catch {\n return undefined;\n }\n }\n\n /**\n * Creates a payload, or returns it when it already is one.\n *\n * @param target What the message is sent to.\n * @param options The message, its content, or a payload.\n * @param context What the target accepts.\n */\n public static create(\n target: MessageTarget,\n options: MessagePayloadResolvable<MessagePayloadOptions | MessageEditOptions>,\n context?: MessagePayloadContext,\n ): MessagePayload {\n if (options instanceof MessagePayload) return options;\n return new MessagePayload(\n target,\n typeof options === \"string\" ? { content: options } : (options as MessagePayloadOptions),\n context,\n );\n }\n\n /**\n * Resolves a file to upload, reading paths from disk and downloading URLs.\n *\n * @param file The file.\n */\n public static async resolveFile(file: AttachmentResolvable): Promise<RawFile> {\n if (isRawFile(file)) return file;\n\n const payload = MessagePayload.attachmentPayload(file)!;\n const { attachment } = payload;\n let name = payload.name ?? (typeof attachment === \"string\" ? nameOf(attachment) : \"file.jpg\");\n if (payload.spoiler && !name.startsWith(\"SPOILER_\")) name = `SPOILER_${name}`;\n\n const { data, contentType } = await resolveBuffer(attachment);\n return contentType ? { name, data, contentType } : { name, data };\n }\n\n private static attachmentPayload(file: AttachmentResolvable): AttachmentPayload | null {\n if (isRawFile(file)) return null;\n if (isBufferResolvable(file)) return { attachment: file };\n if (\"toJSON\" in file && typeof file.toJSON === \"function\") return file.toJSON();\n return file as AttachmentPayload;\n }\n\n private static toJSON<Value extends object>(value: Value | JSONEncodable<Value>): Value {\n return \"toJSON\" in value && typeof value.toJSON === \"function\"\n ? value.toJSON()\n : (value as Value);\n }\n\n private static id(value: string | { readonly id: string } | undefined): string | undefined {\n return typeof value === \"string\" ? value : value?.id;\n }\n}\n\n/**\n * The message defaults read from the client's options.\n */\nexport interface GatewayClientMessageDefaults {\n /**\n * The mentions every message may ping, unless it sets its own.\n */\n allowedMentions?: MessageMentionOptions;\n /**\n * Whether replies fail when the message they reply to no longer exists, unless they set it themselves.\n *\n * @default true\n */\n failIfNotExists?: boolean;\n}\n\nfunction isCamelPoll(poll: object): boolean {\n const answers = (poll as { answers?: readonly object[] }).answers;\n return answers?.some((answer) => !(\"poll_media\" in answer)) ?? false;\n}\n\nfunction resolvePartialEmoji(emoji: string): { id?: string; name?: string } {\n const match = /<?(?:a?:)?(\\w{2,32}):(\\d{17,20})>?/.exec(emoji);\n return match ? { name: match[1], id: match[2] } : { name: emoji };\n}\n\nfunction isRawFile(file: AttachmentResolvable): file is RawFile {\n return (\n typeof file === \"object\" &&\n file !== null &&\n \"data\" in file &&\n \"name\" in file &&\n !(\"attachment\" in file)\n );\n}\n\nfunction isBufferResolvable(file: AttachmentResolvable): file is BufferResolvable {\n return (\n typeof file === \"string\" ||\n file instanceof Uint8Array ||\n file instanceof ArrayBuffer ||\n file instanceof Blob ||\n (typeof file === \"object\" && file !== null && Symbol.asyncIterator in file)\n );\n}\n\nfunction nameOf(path: string): string {\n if (/^https?:\\/\\//.test(path)) {\n const name = basename(new URL(path).pathname);\n return name || \"file.jpg\";\n }\n return basename(path);\n}\n\nasync function resolveBuffer(\n attachment: BufferResolvable,\n): Promise<{ data: Uint8Array; contentType?: string }> {\n if (attachment instanceof Uint8Array) return { data: attachment };\n if (attachment instanceof ArrayBuffer) return { data: new Uint8Array(attachment) };\n if (attachment instanceof Blob) {\n return {\n data: new Uint8Array(await attachment.arrayBuffer()),\n contentType: attachment.type || undefined,\n };\n }\n if (typeof attachment === \"string\") {\n if (/^https?:\\/\\//.test(attachment)) {\n const response = await fetch(attachment);\n if (!response.ok) throw new Error(`Could not download ${attachment}: ${response.status}`);\n return {\n data: new Uint8Array(await response.arrayBuffer()),\n contentType: response.headers.get(\"content-type\") ?? undefined,\n };\n }\n return { data: await readFile(attachment) };\n }\n\n const chunks: Uint8Array[] = [];\n for await (const chunk of attachment) {\n chunks.push(typeof chunk === \"string\" ? new TextEncoder().encode(chunk) : chunk);\n }\n return { data: Buffer.concat(chunks) };\n}\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport { ChannelMessageManager } from \"../../../managers/ChannelMessageManager.js\";\nimport {\n MessagePayload,\n type MessageCreateOptions,\n type MessagePayloadResolvable,\n} from \"../../messages/MessagePayload.js\";\nimport type { Channel, ChannelDataType } from \"../Channel.js\";\nimport type { Message } from \"../../messages/Message.js\";\nimport { kData } from \"../../Structure.js\";\n\ntype Data = { last_message_id?: string | null; last_pin_timestamp?: string | null };\nconst kLastPinTimestamp: unique symbol = Symbol.for(\n \"wolfstar.structures.lastPinTimestamp\",\n) as never;\nconst kLastPinRaw: unique symbol = Symbol.for(\"wolfstar.structures.lastPinRaw\") as never;\n\nexport interface TextChannelMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the fields and message actions of channels holding messages.\n */\nexport class TextChannelMixin<Type extends ChannelType = ChannelType> {\n public static DataTemplate = {\n set last_pin_timestamp(_value: string | null | undefined) {},\n };\n\n declare protected [kLastPinTimestamp]: number | null | undefined;\n declare protected [kLastPinRaw]: string | null | undefined;\n\n public static optimizeData(this: Channel, data: Partial<ChannelDataType>): void {\n const { last_pin_timestamp: timestamp } = data as Data;\n if (timestamp !== undefined) {\n (this as TextChannelMixin)[kLastPinTimestamp] = timestamp ? Date.parse(timestamp) : null;\n (this as TextChannelMixin)[kLastPinRaw] = timestamp;\n }\n }\n\n public static enrichToJSON(this: Channel, data: object): void {\n const raw = (this as TextChannelMixin)[kLastPinRaw];\n if (raw !== undefined) (data as Data).last_pin_timestamp = raw;\n }\n\n public get lastMessageId(): string | null {\n return (this[kData] as Data).last_message_id ?? null;\n }\n\n public get lastPinTimestamp(): number | null {\n return this[kLastPinTimestamp] ?? null;\n }\n\n public get lastPinAt(): Date | null {\n const { lastPinTimestamp } = this;\n return lastPinTimestamp === null ? null : new Date(lastPinTimestamp);\n }\n\n /**\n * The messages of the channel.\n */\n public get messages(): ChannelMessageManager {\n return new ChannelMessageManager(this.client, this.id);\n }\n\n /**\n * Sends a message to the channel.\n *\n * @param options The message, or its content.\n */\n public send(options: MessagePayloadResolvable<MessageCreateOptions>): Promise<Message> {\n return this.client.messages.send(this.id, MessagePayload.create(this, options));\n }\n\n /**\n * Shows the bot as typing in the channel, for about 10 seconds or until it sends a message.\n */\n public async sendTyping(): Promise<void> {\n await this.client.api.channels.showTyping(this.id);\n }\n\n /**\n * Deletes up to 100 messages at once.\n *\n * @param messages The IDs of the messages, or how many of the latest ones to delete.\n * @param filterOld Whether to drop the messages older than 14 days, which Discord refuses.\n * @returns The IDs of the deleted messages.\n */\n public bulkDelete(messages: readonly string[] | number, filterOld = false): Promise<string[]> {\n return this.client.messages.bulkDelete(this.id, messages, filterOld);\n }\n\n /**\n * Fetches the last message of the channel, cache first.\n */\n public async fetchLastMessage(): Promise<Message | null> {\n const { lastMessageId } = this;\n return lastMessageId ? this.client.messages.fetch(this.id, lastMessageId) : null;\n }\n}\n","import { AnnouncementChannel as BaseAnnouncementChannel } from \"@discordjs/structures\";\nimport { type ChannelType } from \"discord-api-types/v10\";\nimport { resolveId, type IdResolvable } from \"../../util/channels.js\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\nimport { ChannelPermissionMixin } from \"./mixins/ChannelPermissionMixin.js\";\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\nimport { ChannelThreadsMixin } from \"./mixins/ChannelThreadsMixin.js\";\nimport { ChannelWebhooksMixin } from \"./mixins/ChannelWebhooksMixin.js\";\nimport { ChannelTopicMixin } from \"./mixins/ChannelTopicMixin.js\";\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\n\nexport interface AnnouncementChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.GuildAnnouncement>, ChannelRelations>,\n MixinTypes<\n BaseAnnouncementChannel,\n [\n BaseChannelMixin<ChannelType.GuildAnnouncement>,\n TextChannelMixin<ChannelType.GuildAnnouncement>,\n GuildChannelMixin<ChannelType.GuildAnnouncement>,\n ChannelParentMixin<ChannelType.GuildAnnouncement>,\n ChannelPermissionMixin<ChannelType.GuildAnnouncement>,\n ChannelSlowmodeMixin<ChannelType.GuildAnnouncement>,\n ChannelTopicMixin<ChannelType.GuildAnnouncement>,\n ChannelWebhooksMixin<ChannelType.GuildAnnouncement>,\n ChannelThreadsMixin<ChannelType.GuildAnnouncement>,\n ]\n > {}\n\n/**\n * A guild announcement channel.\n */\nexport class AnnouncementChannel extends BaseAnnouncementChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(\n data: ChannelDataType<ChannelType.GuildAnnouncement>,\n relations: ChannelRelations = {},\n ) {\n super(data);\n initStructure(this, data, relations);\n }\n\n /**\n * Makes another channel follow this one: messages published here are crossposted there by a webhook.\n *\n * @param channel The channel to post to, or its ID.\n * @param reason The reason for the audit log.\n * @returns The ID of the follower webhook created in the target channel.\n */\n public async addFollower(channel: IdResolvable, reason?: string): Promise<string> {\n const result = await this.client.api.channels.followAnnouncements(this.id, resolveId(channel), {\n reason,\n });\n return result.webhook_id;\n }\n}\n\nMixin(AnnouncementChannel, [\n StructureMixin,\n BaseChannelMixin,\n TextChannelMixin,\n GuildChannelMixin,\n ChannelParentMixin,\n ChannelPermissionMixin,\n ChannelSlowmodeMixin,\n ChannelTopicMixin,\n ChannelWebhooksMixin,\n ChannelThreadsMixin,\n]);\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData } from \"../../Structure.js\";\n\ntype Data = { owner_id?: string };\n\nexport interface ChannelOwnerMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the owner of threads and group direct messages.\n */\nexport class ChannelOwnerMixin<Type extends ChannelType = ChannelType> {\n public get ownerId(): string | null {\n return (this[kData] as Data).owner_id ?? null;\n }\n}\n","import type { GatewayClient } from \"../GatewayClient.js\";\nimport type { ThreadMember } from \"../structures/channels/ThreadMember.js\";\nimport type { FetchOptions } from \"./CachedManager.js\";\nimport type { ThreadMemberListOptions } from \"./ThreadMemberManager.js\";\n\n/**\n * Manages the members of one thread: `client.threadMembers`, with the thread's ID filled in.\n */\nexport class ThreadChannelMemberManager {\n public readonly client: GatewayClient;\n public readonly threadId: string;\n\n public constructor(client: GatewayClient, threadId: string) {\n this.client = client;\n this.threadId = threadId;\n }\n\n /**\n * Gets a member of the thread from the cache.\n */\n public get(userId: string): Promise<ThreadMember | undefined> {\n return this.client.threadMembers.get(this.threadId, userId);\n }\n\n /**\n * Gets a member of the thread from the cache, falling back to the API.\n *\n * @param userId The ID of the user.\n * @param options The cache options, and whether to include the guild member (which always calls the API).\n */\n public fetch(\n userId: string,\n options: FetchOptions & { withMember?: boolean } = {},\n ): Promise<ThreadMember> {\n const { withMember, ...fetchOptions } = options;\n return withMember\n ? this.client.threadMembers.fetchWithMember(this.threadId, userId, { withMember })\n : this.client.threadMembers.fetch(this.threadId, userId, fetchOptions);\n }\n\n /**\n * Lists the members of the thread.\n */\n public list(options?: ThreadMemberListOptions): Promise<ThreadMember[]> {\n return this.client.threadMembers.list(this.threadId, options);\n }\n\n /**\n * Adds a user to the thread, the bot by default.\n */\n public add(userId = \"@me\"): Promise<void> {\n return this.client.threadMembers.add(this.threadId, userId);\n }\n\n /**\n * Removes a user from the thread, the bot by default.\n */\n public remove(userId = \"@me\"): Promise<void> {\n return this.client.threadMembers.remove(this.threadId, userId);\n }\n}\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { Channel, ChannelDataType } from \"../Channel.js\";\nimport type { ThreadAutoArchiveDuration } from \"discord-api-types/v10\";\nimport { ThreadChannelMemberManager } from \"../../../managers/ThreadChannelMemberManager.js\";\nimport type { Message } from \"../../messages/Message.js\";\nimport type { ThreadMember } from \"../ThreadMember.js\";\nimport { kData, kRelations } from \"../../Structure.js\";\nimport { editChannel } from \"./edit.js\";\nimport type { APIThreadMetadata } from \"discord-api-types/v10\";\n\ntype Data = {\n parent_id?: string | null;\n owner_id?: string;\n thread_metadata?: APIThreadMetadata;\n message_count?: number;\n member_count?: number;\n member?: object;\n};\nconst kArchiveTimestamp: unique symbol = Symbol.for(\n \"wolfstar.structures.archiveTimestamp\",\n) as never;\n\nexport interface ThreadChannelMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the metadata of threads.\n */\nexport class ThreadChannelMixin<Type extends ChannelType = ChannelType> {\n declare protected [kArchiveTimestamp]: number | null | undefined;\n\n public static optimizeData(this: Channel, data: Partial<ChannelDataType>): void {\n const metadata = (data as Data).thread_metadata;\n if (metadata !== undefined) {\n (this as ThreadChannelMixin)[kArchiveTimestamp] = metadata.archive_timestamp\n ? Date.parse(metadata.archive_timestamp)\n : null;\n }\n }\n\n public get archived(): boolean {\n return (this[kData] as Data).thread_metadata?.archived ?? false;\n }\n\n public get locked(): boolean {\n return (this[kData] as Data).thread_metadata?.locked ?? false;\n }\n\n public get archiveTimestamp(): number | null {\n return this[kArchiveTimestamp] ?? null;\n }\n\n /**\n * The minutes of inactivity after which the thread is archived.\n */\n public get autoArchiveDuration(): number | null {\n return (this[kData] as Data).thread_metadata?.auto_archive_duration ?? null;\n }\n\n public get messageCount(): number {\n return (this[kData] as Data).message_count ?? 0;\n }\n\n public get memberCount(): number {\n return (this[kData] as Data).member_count ?? 0;\n }\n\n /**\n * Whether non-moderators can add members, for private threads.\n */\n public get invitable(): boolean | null {\n return (this[kData] as Data).thread_metadata?.invitable ?? null;\n }\n\n /**\n * Whether the bot is a member of the thread, like discord.js's `ThreadChannel#joined`: from the thread member cache\n * when the thread was built by a manager, else whether the payload carries the bot's thread member.\n */\n public get joined(): boolean {\n return this[kRelations].joined ?? (this[kData] as Data).member !== undefined;\n }\n\n /**\n * The members of the thread.\n */\n public get members(): ThreadChannelMemberManager {\n return new ThreadChannelMemberManager(this.client, this.id);\n }\n\n public setArchived(archived = true, reason?: string): Promise<this> {\n return editChannel(this, { archived, reason });\n }\n\n public setLocked(locked = true, reason?: string): Promise<this> {\n return editChannel(this, { locked, reason });\n }\n\n /**\n * Sets whether non-moderators can add members to the private thread.\n */\n public setInvitable(invitable = true, reason?: string): Promise<this> {\n return editChannel(this, { invitable, reason });\n }\n\n public setAutoArchiveDuration(\n autoArchiveDuration: ThreadAutoArchiveDuration,\n reason?: string,\n ): Promise<this> {\n return editChannel(this, { autoArchiveDuration, reason });\n }\n\n /**\n * Joins the thread.\n */\n public async join(): Promise<this> {\n await this.client.threadMembers.add(this.id);\n return this;\n }\n\n /**\n * Leaves the thread.\n */\n public async leave(): Promise<this> {\n await this.client.threadMembers.remove(this.id);\n return this;\n }\n\n /**\n * Fetches the message the thread was started from, in its parent channel. Its ID is the thread's.\n */\n public fetchStarterMessage(): Promise<Message> {\n const { parent_id: parentId } = this[kData] as Data;\n if (!parentId) throw new Error(`Thread ${this.id} has no known parent`);\n return this.client.messages.fetch(parentId, this.id);\n }\n\n /**\n * Fetches the thread member of the thread's owner.\n */\n public fetchOwner(): Promise<ThreadMember> {\n const { owner_id: ownerId } = this[kData] as Data;\n if (!ownerId) throw new Error(`Thread ${this.id} has no known owner`);\n return this.client.threadMembers.fetch(this.id, ownerId);\n }\n}\n","import { AnnouncementThreadChannel as BaseAnnouncementThreadChannel } from \"@discordjs/structures\";\nimport type { ChannelType } from \"discord-api-types/v10\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelOwnerMixin } from \"./mixins/ChannelOwnerMixin.js\";\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\nimport { ThreadChannelMixin } from \"./mixins/ThreadChannelMixin.js\";\n\nexport interface AnnouncementThreadChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.AnnouncementThread>, ChannelRelations>,\n MixinTypes<\n BaseAnnouncementThreadChannel,\n [\n BaseChannelMixin<ChannelType.AnnouncementThread>,\n TextChannelMixin<ChannelType.AnnouncementThread>,\n GuildChannelMixin<ChannelType.AnnouncementThread>,\n ChannelOwnerMixin<ChannelType.AnnouncementThread>,\n ChannelParentMixin<ChannelType.AnnouncementThread>,\n ChannelSlowmodeMixin<ChannelType.AnnouncementThread>,\n ThreadChannelMixin<ChannelType.AnnouncementThread>,\n ]\n > {}\n\n/**\n * A thread of an announcement channel.\n */\nexport class AnnouncementThreadChannel extends BaseAnnouncementThreadChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(\n data: ChannelDataType<ChannelType.AnnouncementThread>,\n relations: ChannelRelations = {},\n ) {\n super(data);\n initStructure(this, data, relations);\n }\n}\n\nMixin(AnnouncementThreadChannel, [\n StructureMixin,\n BaseChannelMixin,\n TextChannelMixin,\n GuildChannelMixin,\n ChannelOwnerMixin,\n ChannelParentMixin,\n ChannelSlowmodeMixin,\n ThreadChannelMixin,\n]);\n","import { Channel as BaseChannelStructure } from \"@discordjs/structures\";\nimport { ChannelType, type APIChannel, type Snowflake } from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport type { StageInstance } from \"../stageInstances/StageInstance.js\";\nimport type { User } from \"../users/User.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, kRelations, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\n\n/**\n * The raw data of a channel of type `Type`. Channels sent within a guild payload carry their `guild_id` too.\n */\nexport type ChannelDataType<Type extends ChannelType = ChannelType> = Extract<\n APIChannel,\n { type: Type }\n> & { guild_id?: Snowflake };\n\n/**\n * The relations of a channel, resolved from the cache by `client.channels` and `client.threads`.\n */\nexport interface ChannelRelations {\n guild?: Guild | null;\n /**\n * The parent of a guild channel: its category, or the channel a thread belongs to.\n */\n parent?: AnyChannel | null;\n /**\n * The user a direct message is with.\n */\n recipient?: User | null;\n /**\n * The live stage of a stage channel.\n */\n stageInstance?: StageInstance | null;\n /**\n * Whether the bot is a member of a thread, as the thread member cache knows it.\n */\n joined?: boolean;\n}\n\nconst ThreadTypes: readonly ChannelType[] = [\n ChannelType.AnnouncementThread,\n ChannelType.PublicThread,\n ChannelType.PrivateThread,\n];\n\n/** Whether a raw channel type belongs in the thread cache. */\nexport function isThreadChannelType(type: ChannelType): boolean {\n return ThreadTypes.includes(type);\n}\n\nexport interface Channel<Type extends ChannelType = ChannelType>\n extends\n StructureMixin<ChannelDataType<Type>, ChannelRelations>,\n MixinTypes<BaseChannelStructure<Type>, [BaseChannelMixin<Type>]> {}\n\n/**\n * A channel: `@discordjs/structures`' `Channel`, with what every channel type shares.\n *\n * @remarks\n * Concrete channels (`TextChannel`, `DMChannel`, ...) extend `@discordjs/structures`' own and add their fields through\n * mixins, following its design. `ChannelManager` picks the right one for a raw channel.\n *\n * @typeParam Type The type of the channel.\n */\nexport class Channel<Type extends ChannelType = ChannelType> extends BaseChannelStructure<Type> {\n /**\n * Whether a value is a channel of this package. The concrete channels extend `@discordjs/structures`' own rather than\n * this class, so `instanceof Channel` matches any `@discordjs/structures` channel carrying {@link StructureMixin}.\n * Subclasses keep the default `instanceof` behavior.\n *\n * @param value The value to check.\n */\n public static override [Symbol.hasInstance](value: unknown): boolean {\n if (this !== Channel) return Function.prototype[Symbol.hasInstance].call(this, value);\n return value instanceof BaseChannelStructure && kRelations in value;\n }\n\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(data: ChannelDataType<Type>, relations: ChannelRelations = {}) {\n super(data as never);\n initStructure(this, data, relations);\n }\n}\n\nMixin(Channel, [StructureMixin, BaseChannelMixin]);\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport { Channel } from \"./Channel.js\";\n\n/**\n * A channel of a type no other structure covers yet.\n */\nexport class BaseChannel extends Channel<ChannelType> {}\n","import { CategoryChannel as BaseCategoryChannel } from \"@discordjs/structures\";\nimport type { ChannelType } from \"discord-api-types/v10\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelPermissionMixin } from \"./mixins/ChannelPermissionMixin.js\";\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\n\nexport interface CategoryChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.GuildCategory>, ChannelRelations>,\n MixinTypes<\n BaseCategoryChannel,\n [\n BaseChannelMixin<ChannelType.GuildCategory>,\n GuildChannelMixin<ChannelType.GuildCategory>,\n ChannelPermissionMixin<ChannelType.GuildCategory>,\n ]\n > {}\n\n/**\n * A guild category.\n */\nexport class CategoryChannel extends BaseCategoryChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(\n data: ChannelDataType<ChannelType.GuildCategory>,\n relations: ChannelRelations = {},\n ) {\n super(data);\n initStructure(this, data, relations);\n }\n}\n\nMixin(CategoryChannel, [\n StructureMixin,\n BaseChannelMixin,\n GuildChannelMixin,\n ChannelPermissionMixin,\n]);\n","import { CDN } from \"@discordjs/rest\";\n\n/**\n * @internal The CDN URL builder shared by the structures. Structures never hold a client, so they cannot use\n * `container.rest.cdn`.\n */\nexport const cdn = new CDN();\n","import type { BaseImageURLOptions, ImageURLOptions } from \"@discordjs/rest\";\nimport { User as BaseUser } from \"@discordjs/structures\";\nimport type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type {\n APIAvatarDecorationData,\n APICollectibles,\n APIUserPrimaryGuild,\n} from \"discord-api-types/v10\";\nimport { cdn } from \"../../util/cdn.js\";\nimport { UserFlagsBitField } from \"../../util/flags.js\";\nimport {\n MessagePayload,\n type MessageCreateOptions,\n type MessagePayloadResolvable,\n} from \"../messages/MessagePayload.js\";\nimport type { DMChannel } from \"../channels/DMChannel.js\";\nimport type { Message } from \"../messages/Message.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, kPatch, snowflakeTimestamp, StructureMixin } from \"../Structure.js\";\n\nexport interface User extends StructureMixin<CacheEntityTypes[\"users\"]> {}\n\n/**\n * A Discord user: `@discordjs/structures`' `User`, with CDN URLs and actions through the client.\n */\nexport class User extends BaseUser {\n /**\n * @param data The raw user.\n * @param relations The related structures, resolved from the cache.\n */\n public constructor(data: CacheEntityTypes[\"users\"], relations: object = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n /**\n * The user's tag: their username for migrated users, `username#discriminator` for legacy ones.\n */\n public get tag(): string {\n return this.discriminator === \"0\" ? this.username : `${this.username}#${this.discriminator}`;\n }\n\n /**\n * The user's accent color as a `#rrggbb` string, with the same `undefined`/`null` semantics.\n */\n public get hexAccentColor(): `#${string}` | null | undefined {\n const { accentColor } = this;\n if (typeof accentColor !== \"number\") return accentColor;\n return `#${accentColor.toString(16).padStart(6, \"0\")}`;\n }\n\n public get avatarDecorationData(): APIAvatarDecorationData | null {\n return this[kData].avatar_decoration_data ?? null;\n }\n\n public get collectibles(): APICollectibles | null {\n return this[kData].collectibles ?? null;\n }\n\n /**\n * The guild whose tag the user displays, if any.\n */\n public get primaryGuild(): APIUserPrimaryGuild | null {\n return this[kData].primary_guild ?? null;\n }\n\n /**\n * The user's public flags (badges).\n */\n public get flags(): Readonly<UserFlagsBitField> {\n return new UserFlagsBitField(this[kData].public_flags ?? this[kData].flags ?? 0).freeze();\n }\n\n public get createdTimestamp() {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n\n /**\n * Gets the URL of the user's avatar, or `null` if they have none.\n * @param options The image options.\n */\n public avatarURL(options?: ImageURLOptions): string | null {\n const { avatar } = this[kData];\n return avatar ? cdn.avatar(this.id, avatar, options) : null;\n }\n\n /**\n * The URL of the user's default avatar.\n */\n public get defaultAvatarURL(): string {\n return cdn.defaultAvatar(this.defaultAvatarIndex);\n }\n\n /**\n * Gets the URL of the user's avatar, falling back to their default avatar.\n * @param options The image options.\n */\n public displayAvatarURL(options?: ImageURLOptions): string {\n return this.avatarURL(options) ?? this.defaultAvatarURL;\n }\n\n /**\n * The index of the user's default avatar: migrated users (discriminator `\"0\"`) derive it from their ID, legacy ones\n * from their discriminator.\n */\n public get defaultAvatarIndex(): number {\n return this.discriminator === \"0\"\n ? Number((BigInt(this.id) >> 22n) % 6n)\n : Number(this.discriminator) % 5;\n }\n\n /**\n * Gets the URL of the user's avatar decoration, or `null` if they have none.\n */\n public avatarDecorationURL(): string | null {\n const asset = this.avatarDecorationData?.asset;\n return asset ? cdn.avatarDecoration(asset) : null;\n }\n\n /**\n * Gets the URL of the user's banner: `undefined` when unknown (not fetched), `null` when they have none.\n * @param options The image options.\n */\n public bannerURL(options?: ImageURLOptions): string | null | undefined {\n const { banner } = this;\n return banner ? cdn.banner(this.id, banner, options) : banner;\n }\n\n /**\n * Gets the URL of the badge of the guild tag the user displays, or `null` if they display none.\n * @param options The image options.\n */\n public guildTagBadgeURL(options?: BaseImageURLOptions): string | null {\n const guild = this.primaryGuild;\n return guild?.identity_guild_id && guild.badge\n ? cdn.guildTagBadge(guild.identity_guild_id, guild.badge, options)\n : null;\n }\n\n /**\n * Opens a direct message channel with the user, or gets the existing one.\n */\n public createDM(): Promise<DMChannel> {\n return this.client.users.createDM(this.id);\n }\n\n /**\n * Closes the direct message channel with the user.\n */\n public deleteDM(): Promise<DMChannel> {\n return this.client.users.deleteDM(this.id);\n }\n\n /**\n * Sends a direct message to the user.\n *\n * @param options The message, or its content.\n */\n public send(options: MessagePayloadResolvable<MessageCreateOptions>): Promise<Message> {\n return this.client.users.send(this.id, MessagePayload.create(this, options));\n }\n\n /**\n * Whether the user is partial: built from its ID alone for an event about an uncached user, see `Partials.User`.\n * Only its ID is reliable then, and {@link User.fetch} completes it.\n */\n public get partial(): boolean {\n return this[kData].username === undefined;\n }\n\n /**\n * Fetches the user from the API and patches this structure with the result.\n */\n public async fetch(): Promise<this> {\n const user = await this.client.users.fetch(this.id, { force: true });\n return this[kPatch](user.toJSON());\n }\n\n /**\n * Whether this user has the same data as another one.\n * @param user The user to compare with.\n */\n public equals(user: User): boolean {\n return (\n this.id === user.id &&\n this.username === user.username &&\n this.discriminator === user.discriminator &&\n this.globalName === user.globalName &&\n this.avatar === user.avatar &&\n this.flags.bitField === user.flags.bitField &&\n this.banner === user.banner &&\n this.accentColor === user.accentColor &&\n this.avatarDecorationData?.asset === user.avatarDecorationData?.asset\n );\n }\n\n public toString(): `<@${string}>` {\n return `<@${this.id}>`;\n }\n}\nMixin(User, [StructureMixin]);\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData } from \"../../Structure.js\";\nimport type { APIUser } from \"discord-api-types/v10\";\nimport { User } from \"../../users/User.js\";\n\ntype Data = { recipients?: APIUser[] };\n\nexport interface DMChannelMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the recipients of direct messages.\n */\nexport class DMChannelMixin<Type extends ChannelType = ChannelType> {\n public get recipients(): User[] {\n return ((this[kData] as Data).recipients ?? []).map((user) => new User(user));\n }\n}\n","import { DMChannel as BaseDMChannel } from \"@discordjs/structures\";\nimport type { ChannelType } from \"discord-api-types/v10\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, kData, kRelations, StructureMixin } from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { DMChannelMixin } from \"./mixins/DMChannelMixin.js\";\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\n\nexport interface DMChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.DM>, ChannelRelations>,\n MixinTypes<\n BaseDMChannel,\n [\n BaseChannelMixin<ChannelType.DM>,\n DMChannelMixin<ChannelType.DM>,\n TextChannelMixin<ChannelType.DM>,\n ]\n > {}\n\n/**\n * A direct message channel.\n */\nexport class DMChannel extends BaseDMChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(data: ChannelDataType<ChannelType.DM>, relations: ChannelRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n /**\n * Whether the direct message is partial: built from its ID alone for an event in an uncached direct message, see\n * `Partials.Channel`. Only its ID (and its recipient, when the event carried them) is reliable then, and `fetch()`\n * completes it.\n */\n public get partial(): boolean {\n return this[kData].last_message_id === undefined;\n }\n\n /**\n * The ID of the user the direct message is with, when the payload included them.\n */\n public get recipientId(): string | null {\n return this[kData].recipients?.[0]?.id ?? null;\n }\n\n /**\n * The user the direct message is with, like discord.js's `DMChannel#recipient`: the cached user, else the one of the\n * payload. `null` when the payload did not include them.\n */\n public get recipient(): User | null {\n const recipient = this[kData].recipients?.[0];\n return this[kRelations].recipient ?? (recipient ? new User(recipient) : null);\n }\n}\n\nMixin(DMChannel, [StructureMixin, BaseChannelMixin, DMChannelMixin, TextChannelMixin]);\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData } from \"../../Structure.js\";\nimport type { GuildForumTagData } from \"../../../util/channels.js\";\nimport { editChannel } from \"./edit.js\";\nimport type {\n APIGuildForumDefaultReactionEmoji,\n APIGuildForumTag,\n ForumLayoutType,\n SortOrderType,\n} from \"discord-api-types/v10\";\n\ntype Data = {\n available_tags?: APIGuildForumTag[];\n default_reaction_emoji?: APIGuildForumDefaultReactionEmoji | null;\n default_thread_rate_limit_per_user?: number;\n};\n\nexport interface ThreadOnlyChannelMixin<\n Type extends ChannelType = ChannelType,\n> extends Channel<Type> {}\n\n/**\n * Adds the fields of forum and media channels, which only hold threads.\n */\nexport class ThreadOnlyChannelMixin<Type extends ChannelType = ChannelType> {\n public get availableTags(): readonly APIGuildForumTag[] {\n return (this[kData] as Data).available_tags ?? [];\n }\n\n public get defaultReactionEmoji(): APIGuildForumDefaultReactionEmoji | null {\n return (this[kData] as Data).default_reaction_emoji ?? null;\n }\n\n public get defaultThreadRateLimitPerUser(): number {\n return (this[kData] as Data).default_thread_rate_limit_per_user ?? 0;\n }\n\n public setAvailableTags(\n availableTags: readonly GuildForumTagData[],\n reason?: string,\n ): Promise<this> {\n return editChannel(this, { availableTags, reason });\n }\n\n public setDefaultReactionEmoji(\n defaultReactionEmoji: APIGuildForumDefaultReactionEmoji | null,\n reason?: string,\n ): Promise<this> {\n return editChannel(this, { defaultReactionEmoji, reason });\n }\n\n public setDefaultThreadRateLimitPerUser(\n defaultThreadRateLimitPerUser: number,\n reason?: string,\n ): Promise<this> {\n return editChannel(this, { defaultThreadRateLimitPerUser, reason });\n }\n\n public setDefaultSortOrder(\n defaultSortOrder: SortOrderType | null,\n reason?: string,\n ): Promise<this> {\n return editChannel(this, { defaultSortOrder, reason });\n }\n\n public setDefaultForumLayout(\n defaultForumLayout: ForumLayoutType,\n reason?: string,\n ): Promise<this> {\n return editChannel(this, { defaultForumLayout, reason });\n }\n}\n","import { ForumChannel as BaseForumChannel } from \"@discordjs/structures\";\nimport type { ChannelType } from \"discord-api-types/v10\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\nimport { ChannelPermissionMixin } from \"./mixins/ChannelPermissionMixin.js\";\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\nimport { ChannelThreadsMixin } from \"./mixins/ChannelThreadsMixin.js\";\nimport { ChannelWebhooksMixin } from \"./mixins/ChannelWebhooksMixin.js\";\nimport { ChannelTopicMixin } from \"./mixins/ChannelTopicMixin.js\";\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\nimport { ThreadOnlyChannelMixin } from \"./mixins/ThreadOnlyChannelMixin.js\";\n\nexport interface ForumChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.GuildForum>, ChannelRelations>,\n MixinTypes<\n BaseForumChannel,\n [\n BaseChannelMixin<ChannelType.GuildForum>,\n GuildChannelMixin<ChannelType.GuildForum>,\n ChannelParentMixin<ChannelType.GuildForum>,\n ChannelPermissionMixin<ChannelType.GuildForum>,\n ChannelSlowmodeMixin<ChannelType.GuildForum>,\n ChannelTopicMixin<ChannelType.GuildForum>,\n ThreadOnlyChannelMixin<ChannelType.GuildForum>,\n ChannelWebhooksMixin<ChannelType.GuildForum>,\n ChannelThreadsMixin<ChannelType.GuildForum>,\n ]\n > {}\n\n/**\n * A guild forum channel.\n */\nexport class ForumChannel extends BaseForumChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(\n data: ChannelDataType<ChannelType.GuildForum>,\n relations: ChannelRelations = {},\n ) {\n super(data);\n initStructure(this, data, relations);\n }\n}\n\nMixin(ForumChannel, [\n StructureMixin,\n BaseChannelMixin,\n GuildChannelMixin,\n ChannelParentMixin,\n ChannelPermissionMixin,\n ChannelSlowmodeMixin,\n ChannelTopicMixin,\n ThreadOnlyChannelMixin,\n ChannelWebhooksMixin,\n ChannelThreadsMixin,\n]);\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData } from \"../../Structure.js\";\nimport type { ImageURLOptions } from \"@discordjs/rest\";\nimport { cdn } from \"../../../util/cdn.js\";\n\ntype Data = { name?: string | null; icon?: string | null; application_id?: string };\n\nexport interface GroupDMMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the fields of group direct messages.\n */\nexport class GroupDMMixin<Type extends ChannelType = ChannelType> {\n public get name(): string | null {\n return (this[kData] as Data).name ?? null;\n }\n\n public get icon(): string | null {\n return (this[kData] as Data).icon ?? null;\n }\n\n /**\n * The ID of the application that created the group, if any.\n */\n public get applicationId(): string | null {\n return (this[kData] as Data).application_id ?? null;\n }\n\n /**\n * Gets the URL of the group's icon, or `null` if it has none.\n * @param options The image options.\n */\n public iconURL(options?: ImageURLOptions): string | null {\n const { icon } = this[kData] as Data;\n return icon ? cdn.channelIcon(this.id, icon, options) : null;\n }\n}\n","import { GroupDMChannel as BaseGroupDMChannel } from \"@discordjs/structures\";\nimport type { ChannelType } from \"discord-api-types/v10\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelOwnerMixin } from \"./mixins/ChannelOwnerMixin.js\";\nimport { DMChannelMixin } from \"./mixins/DMChannelMixin.js\";\nimport { GroupDMMixin } from \"./mixins/GroupDMMixin.js\";\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\n\nexport interface GroupDMChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.GroupDM>, ChannelRelations>,\n MixinTypes<\n BaseGroupDMChannel,\n [\n BaseChannelMixin<ChannelType.GroupDM>,\n DMChannelMixin<ChannelType.GroupDM>,\n TextChannelMixin<ChannelType.GroupDM>,\n ChannelOwnerMixin<ChannelType.GroupDM>,\n GroupDMMixin<ChannelType.GroupDM>,\n ]\n > {}\n\n/**\n * A group direct message channel.\n */\nexport class GroupDMChannel extends BaseGroupDMChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(data: ChannelDataType<ChannelType.GroupDM>, relations: ChannelRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n}\n\nMixin(GroupDMChannel, [\n StructureMixin,\n BaseChannelMixin,\n DMChannelMixin,\n TextChannelMixin,\n ChannelOwnerMixin,\n GroupDMMixin,\n]);\n","import { MediaChannel as BaseMediaChannel } from \"@discordjs/structures\";\nimport type { ChannelType } from \"discord-api-types/v10\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\nimport { ChannelPermissionMixin } from \"./mixins/ChannelPermissionMixin.js\";\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\nimport { ChannelThreadsMixin } from \"./mixins/ChannelThreadsMixin.js\";\nimport { ChannelWebhooksMixin } from \"./mixins/ChannelWebhooksMixin.js\";\nimport { ChannelTopicMixin } from \"./mixins/ChannelTopicMixin.js\";\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\nimport { ThreadOnlyChannelMixin } from \"./mixins/ThreadOnlyChannelMixin.js\";\n\nexport interface MediaChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.GuildMedia>, ChannelRelations>,\n MixinTypes<\n BaseMediaChannel,\n [\n BaseChannelMixin<ChannelType.GuildMedia>,\n GuildChannelMixin<ChannelType.GuildMedia>,\n ChannelParentMixin<ChannelType.GuildMedia>,\n ChannelPermissionMixin<ChannelType.GuildMedia>,\n ChannelSlowmodeMixin<ChannelType.GuildMedia>,\n ChannelTopicMixin<ChannelType.GuildMedia>,\n ThreadOnlyChannelMixin<ChannelType.GuildMedia>,\n ChannelWebhooksMixin<ChannelType.GuildMedia>,\n ChannelThreadsMixin<ChannelType.GuildMedia>,\n ]\n > {}\n\n/**\n * A guild media channel.\n */\nexport class MediaChannel extends BaseMediaChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(\n data: ChannelDataType<ChannelType.GuildMedia>,\n relations: ChannelRelations = {},\n ) {\n super(data);\n initStructure(this, data, relations);\n }\n}\n\nMixin(MediaChannel, [\n StructureMixin,\n BaseChannelMixin,\n GuildChannelMixin,\n ChannelParentMixin,\n ChannelPermissionMixin,\n ChannelSlowmodeMixin,\n ChannelTopicMixin,\n ThreadOnlyChannelMixin,\n ChannelWebhooksMixin,\n ChannelThreadsMixin,\n]);\n","import { PrivateThreadChannel as BasePrivateThreadChannel } from \"@discordjs/structures\";\nimport type { ChannelType } from \"discord-api-types/v10\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelOwnerMixin } from \"./mixins/ChannelOwnerMixin.js\";\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\nimport { ThreadChannelMixin } from \"./mixins/ThreadChannelMixin.js\";\n\nexport interface PrivateThreadChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.PrivateThread>, ChannelRelations>,\n MixinTypes<\n BasePrivateThreadChannel,\n [\n BaseChannelMixin<ChannelType.PrivateThread>,\n TextChannelMixin<ChannelType.PrivateThread>,\n GuildChannelMixin<ChannelType.PrivateThread>,\n ChannelOwnerMixin<ChannelType.PrivateThread>,\n ChannelParentMixin<ChannelType.PrivateThread>,\n ChannelSlowmodeMixin<ChannelType.PrivateThread>,\n ThreadChannelMixin<ChannelType.PrivateThread>,\n ]\n > {}\n\n/**\n * A private thread.\n */\nexport class PrivateThreadChannel extends BasePrivateThreadChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(\n data: ChannelDataType<ChannelType.PrivateThread>,\n relations: ChannelRelations = {},\n ) {\n super(data);\n initStructure(this, data, relations);\n }\n}\n\nMixin(PrivateThreadChannel, [\n StructureMixin,\n BaseChannelMixin,\n TextChannelMixin,\n GuildChannelMixin,\n ChannelOwnerMixin,\n ChannelParentMixin,\n ChannelSlowmodeMixin,\n ThreadChannelMixin,\n]);\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData } from \"../../Structure.js\";\nimport { editChannel } from \"./edit.js\";\n\ntype Data = { applied_tags?: string[] };\n\nexport interface AppliedTagsMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the tags applied to a thread of a forum or media channel.\n */\nexport class AppliedTagsMixin<Type extends ChannelType = ChannelType> {\n public get appliedTagIds(): readonly string[] {\n return (this[kData] as Data).applied_tags ?? [];\n }\n\n /**\n * Sets the tags of the thread.\n *\n * @param appliedTags The IDs of the tags.\n * @param reason The reason for the audit log.\n */\n public setAppliedTags(appliedTags: readonly string[], reason?: string): Promise<this> {\n return editChannel(this, { appliedTags, reason });\n }\n}\n","import { PublicThreadChannel as BasePublicThreadChannel } from \"@discordjs/structures\";\nimport type { ChannelType } from \"discord-api-types/v10\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, StructureMixin } from \"../Structure.js\";\nimport { AppliedTagsMixin } from \"./mixins/AppliedTagsMixin.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelOwnerMixin } from \"./mixins/ChannelOwnerMixin.js\";\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\nimport { ThreadChannelMixin } from \"./mixins/ThreadChannelMixin.js\";\n\nexport interface PublicThreadChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.PublicThread>, ChannelRelations>,\n MixinTypes<\n BasePublicThreadChannel,\n [\n BaseChannelMixin<ChannelType.PublicThread>,\n TextChannelMixin<ChannelType.PublicThread>,\n GuildChannelMixin<ChannelType.PublicThread>,\n ChannelOwnerMixin<ChannelType.PublicThread>,\n ChannelParentMixin<ChannelType.PublicThread>,\n ChannelSlowmodeMixin<ChannelType.PublicThread>,\n ThreadChannelMixin<ChannelType.PublicThread>,\n AppliedTagsMixin<ChannelType.PublicThread>,\n ]\n > {}\n\n/**\n * A public thread.\n */\nexport class PublicThreadChannel extends BasePublicThreadChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(\n data: ChannelDataType<ChannelType.PublicThread>,\n relations: ChannelRelations = {},\n ) {\n super(data);\n initStructure(this, data, relations);\n }\n}\n\nMixin(PublicThreadChannel, [\n StructureMixin,\n BaseChannelMixin,\n TextChannelMixin,\n GuildChannelMixin,\n ChannelOwnerMixin,\n ChannelParentMixin,\n ChannelSlowmodeMixin,\n ThreadChannelMixin,\n AppliedTagsMixin,\n]);\n","import type { ChannelType, VideoQualityMode } from \"discord-api-types/v10\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData } from \"../../Structure.js\";\nimport { editChannel } from \"./edit.js\";\n\ntype Data = {\n bitrate?: number;\n user_limit?: number;\n rtc_region?: string | null;\n video_quality_mode?: number;\n};\n\nexport interface VoiceChannelMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the fields of voice and stage channels.\n */\nexport class VoiceChannelMixin<Type extends ChannelType = ChannelType> {\n public get bitrate(): number {\n return (this[kData] as Data).bitrate ?? 0;\n }\n\n /**\n * The user limit, `0` when unlimited.\n */\n public get userLimit(): number {\n return (this[kData] as Data).user_limit ?? 0;\n }\n\n /**\n * The voice region, `null` for automatic.\n */\n public get rtcRegion(): string | null {\n return (this[kData] as Data).rtc_region ?? null;\n }\n\n public get videoQualityMode(): number | null {\n return (this[kData] as Data).video_quality_mode ?? null;\n }\n\n public setBitrate(bitrate: number, reason?: string): Promise<this> {\n return editChannel(this, { bitrate, reason });\n }\n\n /**\n * Sets the user limit.\n *\n * @param userLimit The user limit, `0` for none.\n * @param reason The reason for the audit log.\n */\n public setUserLimit(userLimit: number, reason?: string): Promise<this> {\n return editChannel(this, { userLimit, reason });\n }\n\n /**\n * Sets the voice region.\n *\n * @param rtcRegion The region, `null` for automatic.\n * @param reason The reason for the audit log.\n */\n public setRTCRegion(rtcRegion: string | null, reason?: string): Promise<this> {\n return editChannel(this, { rtcRegion, reason });\n }\n\n public setVideoQualityMode(videoQualityMode: VideoQualityMode, reason?: string): Promise<this> {\n return editChannel(this, { videoQualityMode, reason });\n }\n}\n","import { StageChannel as BaseStageChannel } from \"@discordjs/structures\";\nimport { DiscordAPIError } from \"@discordjs/rest\";\nimport type { ChannelType } from \"discord-api-types/v10\";\nimport type { StageInstanceCreateOptions } from \"../../managers/StageInstanceManager.js\";\nimport type { StageInstance } from \"../stageInstances/StageInstance.js\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, kRelations, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\nimport { ChannelPermissionMixin } from \"./mixins/ChannelPermissionMixin.js\";\nimport { ChannelWebhooksMixin } from \"./mixins/ChannelWebhooksMixin.js\";\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\nimport { VoiceChannelMixin } from \"./mixins/VoiceChannelMixin.js\";\n\nexport interface StageChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.GuildStageVoice>, ChannelRelations>,\n MixinTypes<\n BaseStageChannel,\n [\n BaseChannelMixin<ChannelType.GuildStageVoice>,\n TextChannelMixin<ChannelType.GuildStageVoice>,\n GuildChannelMixin<ChannelType.GuildStageVoice>,\n ChannelParentMixin<ChannelType.GuildStageVoice>,\n ChannelPermissionMixin<ChannelType.GuildStageVoice>,\n ChannelSlowmodeMixin<ChannelType.GuildStageVoice>,\n VoiceChannelMixin<ChannelType.GuildStageVoice>,\n ChannelWebhooksMixin<ChannelType.GuildStageVoice>,\n ]\n > {}\n\n/**\n * A guild stage channel.\n */\nexport class StageChannel extends BaseStageChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(\n data: ChannelDataType<ChannelType.GuildStageVoice>,\n relations: ChannelRelations = {},\n ) {\n super(data);\n initStructure(this, data, relations);\n }\n\n /**\n * The live stage of the channel, from the cache, like discord.js's `StageChannel#stageInstance`: `null` when the\n * stage is not live, when it is not cached, or when the channel was not built by a manager.\n *\n * @remarks\n * Its own `channel` is this channel, and its scheduled event is not resolved: use\n * {@link StageChannel.fetchStageInstance} for the stage with every relation.\n */\n public get stageInstance(): StageInstance | null {\n return this[kRelations].stageInstance ?? null;\n }\n\n /**\n * Fetches the live stage of the channel, `null` when the stage is not live.\n */\n public async fetchStageInstance(): Promise<StageInstance | null> {\n const { guildId } = this;\n if (!guildId) return null;\n try {\n return await this.client.guilds.stageInstances(guildId).fetch(this.id);\n } catch (error) {\n // Discord answers 404 (Unknown Stage Instance) when the stage is not live.\n if (error instanceof DiscordAPIError && error.status === 404) return null;\n throw error;\n }\n }\n\n /**\n * Starts a stage in the channel.\n *\n * @param options The topic and privacy level, and whether to notify the guild.\n */\n public createStageInstance(options: StageInstanceCreateOptions): Promise<StageInstance> {\n const { guildId } = this;\n if (!guildId) return Promise.reject(new Error(`Channel ${this.id} has no known guild`));\n return this.client.guilds.stageInstances(guildId).create(this.id, options);\n }\n}\n\nMixin(StageChannel, [\n StructureMixin,\n BaseChannelMixin,\n TextChannelMixin,\n GuildChannelMixin,\n ChannelParentMixin,\n ChannelPermissionMixin,\n ChannelSlowmodeMixin,\n VoiceChannelMixin,\n ChannelWebhooksMixin,\n]);\n","import { TextChannel as BaseTextChannel } from \"@discordjs/structures\";\nimport type { ChannelType } from \"discord-api-types/v10\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\nimport { ChannelPermissionMixin } from \"./mixins/ChannelPermissionMixin.js\";\nimport { ChannelThreadsMixin } from \"./mixins/ChannelThreadsMixin.js\";\nimport { ChannelWebhooksMixin } from \"./mixins/ChannelWebhooksMixin.js\";\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\nimport { ChannelTopicMixin } from \"./mixins/ChannelTopicMixin.js\";\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\n\nexport interface TextChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.GuildText>, ChannelRelations>,\n MixinTypes<\n BaseTextChannel,\n [\n BaseChannelMixin<ChannelType.GuildText>,\n TextChannelMixin<ChannelType.GuildText>,\n GuildChannelMixin<ChannelType.GuildText>,\n ChannelParentMixin<ChannelType.GuildText>,\n ChannelPermissionMixin<ChannelType.GuildText>,\n ChannelSlowmodeMixin<ChannelType.GuildText>,\n ChannelTopicMixin<ChannelType.GuildText>,\n ChannelWebhooksMixin<ChannelType.GuildText>,\n ChannelThreadsMixin<ChannelType.GuildText>,\n ]\n > {}\n\n/**\n * A guild text channel.\n */\nexport class TextChannel extends BaseTextChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(\n data: ChannelDataType<ChannelType.GuildText>,\n relations: ChannelRelations = {},\n ) {\n super(data);\n initStructure(this, data, relations);\n }\n}\n\nMixin(TextChannel, [\n StructureMixin,\n BaseChannelMixin,\n TextChannelMixin,\n GuildChannelMixin,\n ChannelParentMixin,\n ChannelPermissionMixin,\n ChannelSlowmodeMixin,\n ChannelTopicMixin,\n ChannelWebhooksMixin,\n ChannelThreadsMixin,\n]);\n","import { VoiceChannel as BaseVoiceChannel } from \"@discordjs/structures\";\nimport {\n type ChannelType,\n type RESTPostAPISoundboardSendSoundJSONBody,\n} from \"discord-api-types/v10\";\nimport type { SoundboardSound } from \"../soundboards/SoundboardSound.js\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\nimport { ChannelPermissionMixin } from \"./mixins/ChannelPermissionMixin.js\";\nimport { ChannelWebhooksMixin } from \"./mixins/ChannelWebhooksMixin.js\";\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\nimport { VoiceChannelMixin } from \"./mixins/VoiceChannelMixin.js\";\n\nexport interface VoiceChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.GuildVoice>, ChannelRelations>,\n MixinTypes<\n BaseVoiceChannel,\n [\n BaseChannelMixin<ChannelType.GuildVoice>,\n TextChannelMixin<ChannelType.GuildVoice>,\n GuildChannelMixin<ChannelType.GuildVoice>,\n ChannelParentMixin<ChannelType.GuildVoice>,\n ChannelPermissionMixin<ChannelType.GuildVoice>,\n ChannelSlowmodeMixin<ChannelType.GuildVoice>,\n VoiceChannelMixin<ChannelType.GuildVoice>,\n ChannelWebhooksMixin<ChannelType.GuildVoice>,\n ]\n > {}\n\n/**\n * A guild voice channel.\n */\nexport class VoiceChannel extends BaseVoiceChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(\n data: ChannelDataType<ChannelType.GuildVoice>,\n relations: ChannelRelations = {},\n ) {\n super(data);\n initStructure(this, data, relations);\n }\n\n /**\n * Plays a soundboard sound in the channel. The bot must be connected to it.\n *\n * @param sound The sound, or its ID with the ID of its guild (none for a default sound).\n */\n public async sendSoundboardSound(\n sound: SoundboardSound | { soundId: string; guildId?: string | null },\n ): Promise<void> {\n const body: RESTPostAPISoundboardSendSoundJSONBody = {\n sound_id: sound.soundId,\n source_guild_id: sound.guildId ?? undefined,\n };\n await this.client.api.channels.sendSoundboardSound(this.id, body);\n }\n}\n\nMixin(VoiceChannel, [\n StructureMixin,\n BaseChannelMixin,\n TextChannelMixin,\n GuildChannelMixin,\n ChannelParentMixin,\n ChannelPermissionMixin,\n ChannelSlowmodeMixin,\n VoiceChannelMixin,\n ChannelWebhooksMixin,\n]);\n","import { StageInstance as BaseStageInstance } from \"@discordjs/structures\";\nimport type { APIStageInstance, StageInstancePrivacyLevel } from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { StageInstanceEditOptions } from \"../../managers/StageInstanceManager.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport type { GuildScheduledEvent } from \"../guilds/GuildScheduledEvent.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport {\n initStructure,\n kPatch,\n kPatchRelations,\n kRelations,\n snowflakeTimestamp,\n StructureMixin,\n} from \"../Structure.js\";\n\n/**\n * The relations of a {@link StageInstance}, resolved from the cache by the guild's stage instance manager.\n */\nexport interface StageInstanceRelations {\n guild?: Guild | null;\n channel?: AnyChannel | null;\n guildScheduledEvent?: GuildScheduledEvent | null;\n}\n\nexport interface StageInstance extends StructureMixin<APIStageInstance, StageInstanceRelations> {}\n\n/**\n * A live stage, the topic of a stage channel while it is open: `@discordjs/structures`' `StageInstance`, with its\n * guild and channel, and actions through the client.\n */\nexport class StageInstance extends BaseStageInstance {\n /**\n * @param data The raw stage instance.\n * @param relations The guild and channel as resolved from the cache, by the guild's stage instance manager.\n */\n public constructor(data: APIStageInstance, relations: StageInstanceRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n public get channel(): AnyChannel | null {\n return this[kRelations].channel ?? null;\n }\n\n /**\n * The scheduled event the stage belongs to, from the cache, like discord.js's\n * `StageInstance#guildScheduledEvent`: `null` when it has none, when it is not cached, or when the stage was not\n * built by its guild's stage instance manager.\n */\n public get guildScheduledEvent(): GuildScheduledEvent | null {\n return this[kRelations].guildScheduledEvent ?? null;\n }\n\n public [kPatchRelations](data: object): void {\n this.dropChangedRelations(data, { guildScheduledEvent: \"guild_scheduled_event_id\" });\n }\n\n public override get createdTimestamp(): number {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n\n /**\n * Fetches the scheduled event the stage belongs to, if any.\n */\n public async fetchGuildScheduledEvent(): Promise<GuildScheduledEvent | null> {\n const { guildScheduledEventId } = this;\n return guildScheduledEventId\n ? this.client.guilds.scheduledEvents(this.guildId).fetch(guildScheduledEventId)\n : null;\n }\n\n /**\n * Edits the stage.\n *\n * @param options The topic and privacy level, and the reason for the audit log.\n */\n public async edit(options: StageInstanceEditOptions): Promise<this> {\n const instance = await this.client.guilds\n .stageInstances(this.guildId)\n .edit(this.channelId, options);\n return this[kPatch](instance.toJSON());\n }\n\n public setTopic(topic: string, reason?: string): Promise<this> {\n return this.edit({ topic, reason });\n }\n\n public setPrivacyLevel(privacyLevel: StageInstancePrivacyLevel, reason?: string): Promise<this> {\n return this.edit({ privacyLevel, reason });\n }\n\n /**\n * Ends the stage.\n *\n * @param reason The reason for the audit log.\n */\n public async delete(reason?: string): Promise<this> {\n await this.client.guilds.stageInstances(this.guildId).delete(this.channelId, reason);\n return this;\n }\n}\n\nMixin(StageInstance, [StructureMixin]);\n","import type { Awaitable } from \"@wolfstar/plugin-cache\";\nimport type { StructureMixin } from \"../structures/Structure.js\";\n\n/**\n * The raw API data a {@link StructureMixin | structure} wraps.\n */\nexport type RawAPIType<Value extends StructureMixin<object>> =\n Value extends StructureMixin<infer Type> ? Type : never;\n\n/**\n * A function building a {@link StructureMixin | structure} out of its raw API data.\n */\nexport type StructureCreator<\n Value extends StructureMixin<object>,\n Raw extends RawAPIType<Value> = RawAPIType<Value>,\n> = (data: Raw) => Value;\n\n/**\n * Whether an {@link Awaitable} is a promise, rather than the value itself.\n *\n * @internal\n */\nexport function isPromiseLike<T>(value: Awaitable<T>): value is Promise<T> {\n return typeof (value as { then?: unknown } | null | undefined)?.then === \"function\";\n}\n\n/**\n * Waits for a list of {@link Awaitable}s like `Promise.all`, then calls a function with their values. Unlike\n * `Promise.all`, it stays synchronous when none of them is a promise, which is what lets a synchronous cache build\n * structures without awaiting them.\n *\n * @param values The values, some of which may be promises.\n * @param callback The function to call with the values.\n * @internal\n */\nexport function whenAll<const T extends readonly unknown[], R>(\n values: T,\n callback: (values: { -readonly [Index in keyof T]: Awaited<T[Index]> }) => Awaitable<R>,\n): Awaitable<R> {\n return values.some(isPromiseLike)\n ? Promise.all(values).then(callback)\n : callback(values as { -readonly [Index in keyof T]: Awaited<T[Index]> });\n}\n\n/**\n * Picks the cached structures of some IDs, in their order, skipping the ones that are not cached: the equivalent of\n * the collections discord.js fills from its caches, e.g. `MessageMentions#channels`.\n *\n * @param ids The IDs.\n * @param cached The cached structures, by ID.\n * @internal\n */\nexport function pickCached<Value>(\n ids: readonly string[],\n cached: ReadonlyMap<string, Value> | undefined,\n): Map<string, Value> {\n const picked = new Map<string, Value>();\n for (const id of ids) {\n const value = cached?.get(id);\n if (value) picked.set(id, value);\n }\n\n return picked;\n}\n\n/**\n * Reads the cached structures of some IDs, synchronously when every read is, skipping duplicates and the IDs that\n * are not cached. The {@link Awaitable} counterpart of discord.js's collections filled from its caches.\n *\n * @param ids The IDs.\n * @param get Reads the structure of an ID.\n * @internal\n */\nexport function whenCachedMap<Value>(\n ids: Iterable<string>,\n get: (id: string) => Awaitable<Value | null | undefined>,\n): Awaitable<Map<string, Value>> {\n const unique = [...new Set(ids)];\n return whenAll(unique.map(get), (values) => {\n const map = new Map<string, Value>();\n for (const [index, value] of values.entries()) if (value) map.set(unique[index]!, value);\n return map;\n });\n}\n","import type {\n Awaitable,\n CacheEntityName,\n CacheEntityTypes,\n EntityCache,\n} from \"@wolfstar/plugin-cache\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport type { Guild } from \"../structures/guilds/Guild.js\";\nimport { bindClient, type StructureMixin } from \"../structures/Structure.js\";\nimport { isPromiseLike, whenAll } from \"../util/cache.js\";\n\n/**\n * The options to fetch an entity with.\n */\nexport interface FetchOptions {\n /**\n * Whether to skip the cache lookup and always hit the API.\n *\n * @default false\n */\n force?: boolean;\n /**\n * Whether to store the entity fetched from the API in the cache.\n *\n * @default true\n */\n cache?: boolean;\n}\n\n/**\n * The options of {@link CachedManager._add}.\n */\nexport interface AddOptions {\n /**\n * The cache key of the entity, when it cannot be derived from its data.\n */\n key?: string;\n}\n\n/**\n * The base class of every manager: it reads raw data from one of the client's entity caches, falls back to the REST\n * API when asked to, and wraps the result in a {@link StructureMixin | structure}.\n *\n * @remarks\n * The cache only ever holds raw API data, building structures is always the manager's job. Without a cache, `get`\n * always resolves to `undefined` and `fetch` always hits the API.\n *\n * Every method is asynchronous since the cache can be Redis, except {@link CachedManager.cached}, which reads a\n * synchronous cache (`createInMemoryCache`) without awaiting it.\n *\n * Like discord.js's `CachedManager`, every payload coming from the API goes through {@link CachedManager._add}, which\n * patches the cached entry and builds the structure. Structures are built by {@link CachedManager.hydrate}, which\n * resolves their relations (a message's author, a member's user, ...) from the cache, so they carry the latest known\n * data rather than the copy embedded in the payload.\n *\n * @typeParam Name The name of the entity cache this manager reads from.\n * @typeParam Value The structure this manager builds.\n * @typeParam Args The arguments identifying an entity, e.g. `[id]` or `[guildId, userId]`.\n */\nexport abstract class CachedManager<\n Name extends CacheEntityName,\n Value extends StructureMixin<object>,\n Args extends readonly string[],\n> {\n /**\n * The client this manager belongs to.\n */\n public readonly client: GatewayClient;\n\n /**\n * The name of the entity cache this manager reads from.\n */\n public readonly entity: Name;\n\n public constructor(client: GatewayClient, entity: Name) {\n this.client = client;\n this.entity = entity;\n }\n\n /**\n * The entity cache this manager reads from, or `undefined` when the client has no cache.\n */\n public get cache(): EntityCache<CacheEntityTypes[Name]> | undefined {\n return this.client.cache?.[this.entity] as EntityCache<CacheEntityTypes[Name]> | undefined;\n }\n\n /**\n * Gets an entity from the cache.\n *\n * @param args The arguments identifying the entity.\n * @returns The entity, or `undefined` if it is not cached.\n */\n public async get(...args: Args): Promise<Value | undefined> {\n return this._get(...args);\n }\n\n /**\n * Gets an entity from a synchronous cache, without awaiting it: the synchronous counterpart of\n * {@link CachedManager.get}, for hot paths such as message filters.\n *\n * @remarks\n * It builds the same structure as `get`, relations included, so the entity caches they are read from must be\n * synchronous too, which they all are with `createInMemoryCache`. `manager.cache?.synchronous` tells whether it can\n * be called.\n *\n * An asynchronous cache throws rather than returning `undefined`: it cannot tell whether the entity is cached, and\n * reporting a miss would silently skip whatever the caller does with cached entities, e.g. a filter.\n *\n * @example\n * ```typescript\n * const member = client.members.cached(guildId, userId);\n * ```\n *\n * @param args The arguments identifying the entity.\n * @returns The entity, or `undefined` if it is not cached or the client has no cache.\n * @throws {TypeError} When the entity cache, or one of the caches its relations are read from, is asynchronous.\n */\n public cached(...args: Args): Value | undefined {\n const { cache } = this;\n if (cache === undefined) return undefined;\n if (cache.synchronous !== true) {\n throw new TypeError(`The ${this.entity} cache is asynchronous, use get instead of cached`);\n }\n\n const value = this._get(...args);\n if (isPromiseLike(value)) {\n // Nothing awaits the promise anymore, so its rejection must not go unhandled.\n value.catch(() => undefined);\n throw new TypeError(\n `The relations of the ${this.entity} cache are read from an asynchronous cache, use get instead of cached`,\n );\n }\n\n return value;\n }\n\n /**\n * Gets an entity from the cache, synchronously when every cache it reads is: the {@link Awaitable} counterpart of\n * {@link CachedManager.get}, which both `get` and {@link CachedManager.cached} rely on.\n *\n * @param args The arguments identifying the entity.\n * @internal\n */\n public _get(...args: Args): Awaitable<Value | undefined> {\n return this.getByKey(this.resolveKey(...args));\n }\n\n /**\n * Resolves a structure or a cache key to a structure, like discord.js's `DataManager#resolve`.\n *\n * @param value A structure, returned as is, or the cache key of an entity (its ID, for managers keyed by ID).\n * @returns The structure, or `null` if the key is not cached.\n */\n public async resolve(value: Value | string): Promise<Value | null> {\n if (typeof value !== \"string\") return value;\n return (await this.getByKey(value)) ?? null;\n }\n\n /**\n * Adds an API payload to the cache, patching the cached entry with it, and builds its structure. The counterpart of\n * discord.js's `CachedManager#_add`, asynchronous since the cache can be remote.\n *\n * @remarks\n * Like discord.js's `_patch`, the payload is shallowly merged into the cached entry, so the fields a partial payload\n * lacks keep their cached value. With `cache` set to `false`, the merged entry is built but not written.\n *\n * The merge is a read followed by a write, not an atomic operation: on a shared cache, a write landing in between\n * (another process, or a dispatch outside the guild's queue) is overwritten. `@wolfstar/plugin-cache` merges partial\n * dispatches the same way, and the fields at stake are refreshed by the next payload of the entity.\n *\n * @param data The raw data.\n * @param cache Whether to write the merged entry to the cache.\n * @param options The cache key, when it cannot be derived from the data.\n * @internal\n */\n public async _add(\n data: CacheEntityTypes[Name],\n cache = true,\n { key = this.keyOf(data) }: AddOptions = {},\n ): Promise<Value> {\n const existing = await this.cache?.get(key);\n const merged = existing ? { ...existing, ...data } : data;\n if (cache) await this.storeRaw(key, merged);\n return this.hydrate(merged);\n }\n\n /**\n * Gets the cached structure of the entity raw data describes, or builds one from the data when it is not cached.\n * Used to resolve the relations of other structures, e.g. a message's author.\n *\n * @param data The raw data.\n */\n public async resolveData(data: CacheEntityTypes[Name]): Promise<Value> {\n return this._resolveData(data);\n }\n\n /**\n * The {@link Awaitable} counterpart of {@link CachedManager.resolveData}, synchronous when every cache it reads is.\n *\n * @param data The raw data.\n * @internal\n */\n public _resolveData(data: CacheEntityTypes[Name]): Awaitable<Value> {\n return whenAll([this.getByKey(this.keyOf(data))], ([cached]) => cached ?? this.build(data));\n }\n\n /**\n * Gets a guild from the cache, to resolve the `guild` of a structure. Synchronous when the guild cache is.\n *\n * @param guildId The ID of the guild, if the structure belongs to one.\n * @remarks\n * The guild does not resolve its own channel relations, see `GuildManager._getShallow`.\n *\n * @returns The guild, or `null` when there is no ID or the guild is not cached.\n */\n protected cachedGuild(guildId: string | null | undefined): Awaitable<Guild | null> {\n return guildId\n ? whenAll([this.client.guilds._getShallow(guildId)], ([guild]) => guild ?? null)\n : null;\n }\n\n /**\n * Builds the structure of raw data, resolving its relations from the cache. Without relations to resolve, the same\n * as {@link CachedManager.createStructure}.\n *\n * @param data The raw data.\n */\n public async hydrate(data: CacheEntityTypes[Name]): Promise<Value> {\n return this.build(data);\n }\n\n /**\n * The {@link Awaitable} counterpart of {@link CachedManager.hydrate}, synchronous when every cache the relations\n * are read from is. Managers resolving relations override this one, so `hydrate` and\n * {@link CachedManager.cached} build the same structures.\n *\n * @param data The raw data.\n * @internal\n */\n public _hydrate(data: CacheEntityTypes[Name]): Awaitable<Value> {\n return this.createStructure(data);\n }\n\n /**\n * Gets an entity from the cache, fetching it from the API (and caching it) on a cache miss.\n *\n * @example\n * ```typescript\n * await client.users.fetch(userId); // cache first\n * await client.users.fetch(userId, { force: true }); // always the API\n * await client.users.fetch(userId, { force: true, cache: false }); // the API, without storing the result\n * ```\n *\n * @param args The arguments identifying the entity, optionally followed by {@link FetchOptions}.\n */\n public async fetch(...args: [...Args] | [...Args, FetchOptions]): Promise<Value> {\n const ids = args.slice(0, this.resolveKey.length) as unknown as Args;\n const { force = false, cache = true } = (args[this.resolveKey.length] ?? {}) as FetchOptions;\n\n if (!force) {\n const cached = await this.get(...ids);\n if (cached) return cached;\n }\n\n const raw = await this.fetchRaw(...ids);\n return this._add(raw, cache, { key: this.resolveKey(...ids) });\n }\n\n /**\n * Fetches an entity from the API, bypassing and then updating the cache. Same as `fetch(...args, { force: true })`.\n *\n * @param args The arguments identifying the entity.\n */\n public refresh(...args: Args): Promise<Value> {\n return this.fetch(...args, { force: true });\n }\n\n /**\n * Wraps raw data in this manager's structure.\n *\n * @param data The raw data.\n */\n public abstract createStructure(data: CacheEntityTypes[Name]): Value;\n\n /**\n * Gets the cache key of raw data.\n *\n * @param data The raw data.\n */\n public abstract keyOf(data: CacheEntityTypes[Name]): string;\n\n /**\n * Gets the cache key of an entity.\n *\n * @param args The arguments identifying the entity.\n */\n public abstract resolveKey(...args: Args): string;\n\n /**\n * Fetches the raw data of an entity from the API.\n *\n * @param args The arguments identifying the entity.\n */\n protected abstract fetchRaw(...args: Args): Promise<CacheEntityTypes[Name]>;\n\n /**\n * Writes raw data to the cache.\n *\n * @param key The cache key of the entity.\n * @param raw The raw data of the entity.\n */\n protected async storeRaw(key: string, raw: CacheEntityTypes[Name]): Promise<void> {\n await this.cache?.set(key, raw);\n }\n\n /**\n * Gets an entity from the cache by its key, synchronously when every cache it reads is.\n *\n * @param key The cache key of the entity.\n */\n protected getByKey(key: string): Awaitable<Value | undefined> {\n return whenAll([this.cache?.get(key)], ([raw]) =>\n raw === undefined ? undefined : this.build(raw),\n );\n }\n\n /**\n * Builds the structure of raw data with {@link CachedManager._hydrate}, bound to this manager's client.\n *\n * @param data The raw data.\n */\n protected build(data: CacheEntityTypes[Name]): Awaitable<Value> {\n return whenAll([this._hydrate(data)], ([value]) => bindClient(value, this.client));\n }\n}\n","import type { Awaitable, CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport { applyGatewayDispatch, stageInstanceKey, threadMemberKey } from \"@wolfstar/plugin-cache\";\nimport {\n ChannelType,\n GatewayDispatchEvents,\n GatewayOpcodes,\n type APIOverwrite,\n type GatewayDispatchPayload,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { AnnouncementChannel } from \"../structures/channels/AnnouncementChannel.js\";\nimport { AnnouncementThreadChannel } from \"../structures/channels/AnnouncementThreadChannel.js\";\nimport { BaseChannel } from \"../structures/channels/BaseChannel.js\";\nimport { isThreadChannelType, type ChannelRelations } from \"../structures/channels/Channel.js\";\nimport { CategoryChannel } from \"../structures/channels/CategoryChannel.js\";\nimport { DMChannel } from \"../structures/channels/DMChannel.js\";\nimport { ForumChannel } from \"../structures/channels/ForumChannel.js\";\nimport { GroupDMChannel } from \"../structures/channels/GroupDMChannel.js\";\nimport { MediaChannel } from \"../structures/channels/MediaChannel.js\";\nimport { PrivateThreadChannel } from \"../structures/channels/PrivateThreadChannel.js\";\nimport { PublicThreadChannel } from \"../structures/channels/PublicThreadChannel.js\";\nimport { StageChannel } from \"../structures/channels/StageChannel.js\";\nimport { TextChannel } from \"../structures/channels/TextChannel.js\";\nimport { VoiceChannel } from \"../structures/channels/VoiceChannel.js\";\nimport type { Guild } from \"../structures/guilds/Guild.js\";\nimport { StageInstance } from \"../structures/stageInstances/StageInstance.js\";\nimport { bindClient } from \"../structures/Structure.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { resolveId, toChannelBody, type GuildChannelEditOptions } from \"../util/channels.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\nimport { PermissionOverwriteManager } from \"./PermissionOverwriteManager.js\";\n\n/**\n * Any of the channel structures {@link ChannelManager} builds.\n */\nexport type AnyChannel =\n | AnnouncementChannel\n | AnnouncementThreadChannel\n | BaseChannel\n | CategoryChannel\n | DMChannel\n | ForumChannel\n | GroupDMChannel\n | MediaChannel\n | PrivateThreadChannel\n | PublicThreadChannel\n | StageChannel\n | TextChannel\n | VoiceChannel;\n\n/**\n * Builds the channel structure matching the type of a raw channel, {@link BaseChannel} for unknown types.\n *\n * @param data The raw channel.\n */\nexport function createChannel(\n data: CacheEntityTypes[\"channels\"],\n relations: ChannelRelations = {},\n): AnyChannel {\n switch (data.type) {\n case ChannelType.AnnouncementThread:\n return new AnnouncementThreadChannel(data, relations);\n case ChannelType.DM:\n return new DMChannel(data, relations);\n case ChannelType.GroupDM:\n return new GroupDMChannel(data, relations);\n case ChannelType.GuildAnnouncement:\n return new AnnouncementChannel(data, relations);\n case ChannelType.GuildCategory:\n return new CategoryChannel(data, relations);\n case ChannelType.GuildForum:\n return new ForumChannel(data, relations);\n case ChannelType.GuildMedia:\n return new MediaChannel(data, relations);\n case ChannelType.GuildStageVoice:\n return new StageChannel(data, relations);\n case ChannelType.GuildText:\n return new TextChannel(data, relations);\n case ChannelType.GuildVoice:\n return new VoiceChannel(data, relations);\n case ChannelType.PrivateThread:\n return new PrivateThreadChannel(data, relations);\n case ChannelType.PublicThread:\n return new PublicThreadChannel(data, relations);\n default:\n return new BaseChannel(data, relations);\n }\n}\n\n// The raw fields of a guild channel the managers read, whichever its type.\nfunction overwriteHolder(channel: AnyChannel): {\n guild_id?: string;\n parent_id?: string | null;\n permission_overwrites?: APIOverwrite[];\n} {\n return channel.toJSON() as never;\n}\n\n// A thread, its channel, and the channel's category: no parent chain is any longer.\nconst MaxParentDepth = 2;\n\n// Guild channels carry their guild's ID, except inside a `GUILD_CREATE`, where the cache adds it.\nfunction channelGuildId(data: CacheEntityTypes[\"channels\"]): string | undefined {\n return \"guild_id\" in data ? (data.guild_id ?? undefined) : undefined;\n}\n\n/**\n * Manages the channels known to the client, threads included.\n *\n * @remarks\n * Threads live in their own entity cache, managed by `client.threads`, which {@link ChannelManager.get} falls back\n * to, so a thread ID resolves like any other channel ID.\n */\nexport class ChannelManager extends CachedManager<\"channels\", AnyChannel, [channelId: string]> {\n public constructor(client: GatewayClient) {\n super(client, \"channels\");\n }\n\n public createStructure(data: CacheEntityTypes[\"channels\"]): AnyChannel {\n return createChannel(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"channels\"]): string {\n return data.id;\n }\n\n public override _hydrate(data: CacheEntityTypes[\"channels\"]): Awaitable<AnyChannel> {\n return whenAll([this.cachedGuild(channelGuildId(data))], ([guild]) =>\n this._hydrateInGuild(data, guild),\n );\n }\n\n /**\n * Builds a channel (or a thread) whose guild is already resolved, resolving its other relations from the cache: its\n * parent, within the same guild, the recipient of a direct message, the live stage of a stage channel, and whether\n * the bot joined a thread. Used by\n * `client.threads` and by the guild's own channel relations, which must not resolve the guild again.\n *\n * @param data The raw channel.\n * @param guild The guild of the channel, `null` outside of guilds or when it is not cached.\n * @param depth How many parents deep the channel is, which bounds the parent chain (a thread, its channel, and its\n * category) against a corrupted cache.\n * @internal\n */\n public _hydrateInGuild(\n data: CacheEntityTypes[\"channels\"],\n guild: Guild | null,\n depth = 0,\n ): Awaitable<AnyChannel> {\n const { client } = this;\n const parentId = \"parent_id\" in data ? data.parent_id : null;\n const recipient = data.type === ChannelType.DM ? data.recipients?.[0] : undefined;\n const guildId = channelGuildId(data) ?? guild?.id;\n const thread = isThreadChannelType(data.type);\n return whenAll(\n [\n parentId && depth < MaxParentDepth ? this.cache?.get(parentId) : undefined,\n recipient ? client.users._resolveData(recipient) : undefined,\n data.type === ChannelType.GuildStageVoice && guildId\n ? client.cache?.stageInstances.get(stageInstanceKey(guildId, data.id))\n : undefined,\n thread\n ? client.cache?.threadMembers.get(threadMemberKey(data.id, client.user?.id ?? client.id))\n : undefined,\n ],\n ([parentData, resolvedRecipient, stageData, me]) =>\n whenAll(\n [parentData ? this._hydrateInGuild(parentData, guild, depth + 1) : null],\n ([parent]) => {\n const relations: ChannelRelations = { guild, parent };\n if (recipient) relations.recipient = resolvedRecipient ?? null;\n if (thread && client.cache) relations.joined = me !== undefined;\n const channel = bindClient(createChannel(data, relations), client);\n if (data.type === ChannelType.GuildStageVoice) {\n // Built here rather than by the stage instance manager, whose relations lead back to this channel.\n relations.stageInstance = stageData\n ? bindClient(new StageInstance(stageData, { guild, channel }), client)\n : null;\n }\n\n return channel;\n },\n ),\n );\n }\n\n /**\n * Gets a channel of a guild whose structure is already built, for the guild's own channel relations.\n *\n * @param channelId The ID of the channel.\n * @param guild The guild.\n * @internal\n */\n public _getInGuild(channelId: string, guild: Guild): Awaitable<AnyChannel | null> {\n return whenAll([this.cache?.get(channelId)], ([data]) =>\n data ? this._hydrateInGuild(data, guild) : null,\n );\n }\n\n public resolveKey(channelId: string): string {\n return channelId;\n }\n\n /**\n * Adds a channel to the cache, handing threads to `client.threads`, whose cache holds them.\n *\n * @internal\n */\n public override _add(\n data: CacheEntityTypes[\"channels\"],\n cache = true,\n options?: AddOptions,\n ): Promise<AnyChannel> {\n return isThreadChannelType(data.type)\n ? this.client.threads._add(data as CacheEntityTypes[\"threads\"], cache, options)\n : super._add(data, cache, options);\n }\n\n /**\n * Gets a channel from the cache, looking it up in the thread cache as well, which `get` and `cached` rely on.\n *\n * @param channelId The ID of the channel.\n * @internal\n */\n public override _get(channelId: string): Awaitable<AnyChannel | undefined> {\n return whenAll(\n [super._get(channelId)],\n ([channel]) => channel ?? this.client.threads._get(channelId),\n );\n }\n\n /**\n * Writes a channel to the cache, threads to the thread cache.\n *\n * @param channelId The ID of the channel.\n * @param raw The raw channel.\n */\n protected override async storeRaw(\n channelId: string,\n raw: CacheEntityTypes[\"channels\"],\n ): Promise<void> {\n if (isThreadChannelType(raw.type)) {\n await this.client.cache?.threads.set(channelId, raw as CacheEntityTypes[\"threads\"]);\n } else {\n await this.cache?.set(channelId, raw);\n }\n }\n\n /**\n * Edits a channel.\n *\n * @param channelId The ID of the channel.\n * @param options The fields to edit, and the reason for the audit log.\n */\n public async edit(channelId: string, options: GuildChannelEditOptions): Promise<AnyChannel> {\n if (options.lockPermissions && options.permissionOverwrites) {\n throw new TypeError(\"Pass either lockPermissions or permissionOverwrites, not both\");\n }\n\n const body = toChannelBody(options);\n if (options.lockPermissions) {\n const parentId =\n options.parent === undefined\n ? (overwriteHolder(await this.fetch(channelId)).parent_id ?? null)\n : options.parent && resolveId(options.parent);\n if (parentId) {\n body.permission_overwrites = overwriteHolder(\n await this.fetch(parentId),\n ).permission_overwrites;\n }\n }\n\n const channel = await this.client.api.channels.edit(channelId, body, {\n reason: options.reason,\n });\n return this._add(channel);\n }\n\n /**\n * Deletes a channel, or closes a direct message, and drops it from the cache with its messages.\n *\n * @param channelId The ID of the channel.\n * @param reason The reason for the audit log.\n */\n public async delete(channelId: string, reason?: string): Promise<void> {\n const channel = await this.client.api.channels.delete(channelId, {\n reason,\n });\n if (!this.client.cache) return;\n\n // The same cascade as the `CHANNEL_DELETE` (or `THREAD_DELETE`) that follows.\n await applyGatewayDispatch(this.client.cache, {\n op: GatewayOpcodes.Dispatch,\n s: 0,\n t: isThreadChannelType(channel.type)\n ? GatewayDispatchEvents.ThreadDelete\n : GatewayDispatchEvents.ChannelDelete,\n d: channel,\n } as GatewayDispatchPayload);\n }\n\n /**\n * Gets the permission overwrites of a channel, cache first.\n *\n * @param channelId The ID of the channel.\n */\n public async permissionOverwrites(channelId: string): Promise<PermissionOverwriteManager> {\n const data = overwriteHolder(await this.fetch(channelId));\n return new PermissionOverwriteManager(\n this.client,\n channelId,\n data.guild_id ?? null,\n data.permission_overwrites ?? [],\n );\n }\n\n protected async fetchRaw(channelId: string) {\n return this.client.api.channels.get(channelId);\n }\n}\n","import type { BaseImageURLOptions, ImageURLOptions } from \"@discordjs/rest\";\nimport { GuildFeature, type APIGuild } from \"discord-api-types/v10\";\nimport { cdn } from \"../../util/cdn.js\";\nimport { kData, snowflakeTimestamp, Structure } from \"../Structure.js\";\n\n/**\n * The raw fields every guild-like payload carries, from the partial guilds of invites to full guilds.\n */\nexport type AnonymousGuildData = Pick<APIGuild, \"features\" | \"icon\" | \"id\" | \"name\"> &\n Partial<\n Pick<\n APIGuild,\n | \"banner\"\n | \"description\"\n | \"nsfw_level\"\n | \"premium_subscription_count\"\n | \"splash\"\n | \"vanity_url_code\"\n | \"verification_level\"\n >\n >;\n\n/**\n * The public attributes shared by {@link Guild} and {@link InviteGuild}, i.e. what an anonymous user can see of a\n * guild.\n *\n * @remarks\n * Merges discord.js's `BaseGuild` and `AnonymousGuild`, there being no `OAuth2Guild` here to justify the split.\n *\n * @typeParam Data The raw guild data this structure wraps.\n */\nexport class AnonymousGuild<\n Data extends AnonymousGuildData = AnonymousGuildData,\n> extends Structure<Data> {\n public get id() {\n return this[kData].id;\n }\n\n public get name() {\n return this[kData].name;\n }\n\n public get icon() {\n return this[kData].icon;\n }\n\n public get features() {\n return this[kData].features;\n }\n\n public get splash(): string | null {\n return this[kData].splash ?? null;\n }\n\n public get banner(): string | null {\n return this[kData].banner ?? null;\n }\n\n public get description(): string | null {\n return this[kData].description ?? null;\n }\n\n public get verificationLevel() {\n return this[kData].verification_level ?? null;\n }\n\n /**\n * The vanity invite code of the guild, if any.\n */\n public get vanityURLCode(): string | null {\n return this[kData].vanity_url_code ?? null;\n }\n\n public get nsfwLevel() {\n return this[kData].nsfw_level ?? null;\n }\n\n /**\n * The total number of boosts of the guild, or `null` if unknown.\n */\n public get premiumSubscriptionCount(): number | null {\n return this[kData].premium_subscription_count ?? null;\n }\n\n public get createdTimestamp() {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n\n /**\n * The acronym shown in place of the guild's icon when it has none.\n */\n public get nameAcronym(): string {\n return this.name\n .replaceAll(\"'s \", \" \")\n .replaceAll(/\\w+/g, (word) => word[0]!)\n .replaceAll(/\\s/g, \"\");\n }\n\n /**\n * Whether the guild is partnered.\n */\n public get partnered(): boolean {\n return this.features.includes(GuildFeature.Partnered);\n }\n\n /**\n * Whether the guild is verified.\n */\n public get verified(): boolean {\n return this.features.includes(GuildFeature.Verified);\n }\n\n /**\n * Gets the URL of the guild's icon, or `null` if it has none.\n * @param options The image options.\n */\n public iconURL(options?: ImageURLOptions): string | null {\n const { icon } = this[kData];\n return icon ? cdn.icon(this.id, icon, options) : null;\n }\n\n /**\n * Gets the URL of the guild's banner, or `null` if it has none.\n * @param options The image options.\n */\n public bannerURL(options?: ImageURLOptions): string | null {\n const { banner } = this[kData];\n return banner ? cdn.banner(this.id, banner, options) : null;\n }\n\n /**\n * Gets the URL of the guild's invite splash image, or `null` if it has none.\n * @param options The image options.\n */\n public splashURL(options?: BaseImageURLOptions): string | null {\n const { splash } = this[kData];\n return splash ? cdn.splash(this.id, splash, options) : null;\n }\n\n public toString(): string {\n return this.name;\n }\n}\n","import type { BaseImageURLOptions } from \"@discordjs/rest\";\nimport type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n GuildFeature,\n GuildPremiumTier,\n type APIGuild,\n type APIIncidentsData,\n type APIVoiceRegion,\n type GuildDefaultMessageNotifications,\n type GuildExplicitContentFilter,\n type GuildVerificationLevel,\n type Locale,\n type RESTGetAPIGuildVanityUrlResult,\n type RESTPatchAPIGuildJSONBody,\n} from \"discord-api-types/v10\";\nimport type { AutoModerationRuleManager } from \"../../managers/AutoModerationRuleManager.js\";\nimport type { GuildBanManager } from \"../../managers/GuildBanManager.js\";\nimport type { GuildScheduledEventManager } from \"../../managers/GuildScheduledEventManager.js\";\nimport type { GuildSoundboardSoundManager } from \"../../managers/GuildSoundboardSoundManager.js\";\nimport type { StageInstanceManager } from \"../../managers/StageInstanceManager.js\";\nimport type { GuildChannelManager } from \"../../managers/GuildChannelManager.js\";\nimport type { FetchedThreads } from \"../../managers/ThreadManager.js\";\nimport type { GuildEmojiManager } from \"../../managers/GuildEmojiManager.js\";\nimport type { GuildIntegrationManager } from \"../../managers/GuildIntegrationManager.js\";\nimport type { GuildMembersRequestOptions } from \"../../managers/GuildMemberManager.js\";\nimport type {\n GuildAuditLogs,\n GuildAuditLogsFetchOptions,\n GuildIncidentActionsOptions,\n GuildOnboardingEditOptions,\n GuildWelcomeScreenEditOptions,\n GuildWidgetSettings,\n GuildWidgetSettingsEditOptions,\n} from \"../../managers/GuildManager.js\";\nimport type { GuildTemplateCreateOptions } from \"../../managers/GuildTemplateManager.js\";\nimport type { GuildInviteManager } from \"../../managers/GuildInviteManager.js\";\nimport type { GuildStickerManager } from \"../../managers/GuildStickerManager.js\";\nimport { cdn } from \"../../util/cdn.js\";\nimport type { Webhook } from \"../webhooks/Webhook.js\";\nimport { SystemChannelFlagsBitField, type SystemChannelFlagsResolvable } from \"../../util/flags.js\";\nimport { AnonymousGuild } from \"./AnonymousGuild.js\";\nimport type { GuildInvite } from \"../invites/GuildInvite.js\";\nimport type { GuildMember } from \"./GuildMember.js\";\nimport type { GuildOnboarding } from \"./GuildOnboarding.js\";\nimport type { GuildPreview } from \"./GuildPreview.js\";\nimport type { GuildTemplate } from \"./GuildTemplate.js\";\nimport type { Integration } from \"./Integration.js\";\nimport type { WelcomeScreen } from \"./WelcomeScreen.js\";\nimport type { Widget } from \"./Widget.js\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport { kData, kPatch, kPatchRelations, kRelations } from \"../Structure.js\";\n\n/**\n * The relations of a {@link Guild}: its special channels, resolved from the cache by `client.guilds`.\n */\nexport interface GuildRelations {\n afkChannel?: AnyChannel | null;\n systemChannel?: AnyChannel | null;\n widgetChannel?: AnyChannel | null;\n rulesChannel?: AnyChannel | null;\n publicUpdatesChannel?: AnyChannel | null;\n safetyAlertsChannel?: AnyChannel | null;\n}\n\n/**\n * The raw field holding the ID of each channel of {@link GuildRelations}.\n *\n * @internal\n */\nexport const GuildChannelFields = {\n afkChannel: \"afk_channel_id\",\n systemChannel: \"system_channel_id\",\n widgetChannel: \"widget_channel_id\",\n rulesChannel: \"rules_channel_id\",\n publicUpdatesChannel: \"public_updates_channel_id\",\n safetyAlertsChannel: \"safety_alerts_channel_id\",\n} as const satisfies Record<keyof GuildRelations, string>;\n\n/**\n * The options to edit a guild with. Images are data URIs (`data:image/png;base64,...`), channels are IDs.\n */\nexport interface GuildEditOptions {\n afkChannel?: string | null;\n afkTimeout?: RESTPatchAPIGuildJSONBody[\"afk_timeout\"];\n banner?: string | null;\n defaultMessageNotifications?: GuildDefaultMessageNotifications | null;\n description?: string | null;\n discoverySplash?: string | null;\n explicitContentFilter?: GuildExplicitContentFilter | null;\n features?: APIGuild[\"features\"];\n icon?: string | null;\n name?: string;\n /**\n * The ID of the member to transfer the ownership to.\n */\n owner?: string;\n preferredLocale?: Locale | null;\n premiumProgressBarEnabled?: boolean;\n publicUpdatesChannel?: string | null;\n reason?: string;\n rulesChannel?: string | null;\n safetyAlertsChannel?: string | null;\n splash?: string | null;\n systemChannel?: string | null;\n systemChannelFlags?: SystemChannelFlagsResolvable;\n verificationLevel?: GuildVerificationLevel | null;\n}\n\n/**\n * A Discord guild.\n *\n * @remarks\n * The collections sent in `GUILD_CREATE` (channels, members, roles, ...) are not kept on the guild: they are stored in\n * their own entity caches and exposed by the client's managers, e.g. `client.members.fetch(guild.id, userId)`. The\n * guild-scoped ones discord.js exposes on the guild itself (`emojis`, `stickers`, `invites`) are here too.\n */\nexport class Guild extends AnonymousGuild<CacheEntityTypes[\"guilds\"]> {\n declare public [kRelations]: GuildRelations;\n\n /**\n * @param data The raw guild.\n * @param relations The channels of the guild, as resolved from the cache by `client.guilds`.\n */\n public constructor(data: CacheEntityTypes[\"guilds\"], relations: GuildRelations = {}) {\n super(data, relations);\n }\n\n protected override optimizeData(data: Partial<CacheEntityTypes[\"guilds\"]>): void {\n super.optimizeData(data);\n this.optimizeTimestamp(\"joined_at\", data.joined_at);\n }\n\n public get ownerId() {\n return this[kData].owner_id;\n }\n\n public get discoverySplash() {\n return this[kData].discovery_splash;\n }\n\n public get afkChannelId() {\n return this[kData].afk_channel_id;\n }\n\n /**\n * The time, in seconds, before a member is moved to the AFK channel.\n */\n public get afkTimeout() {\n return this[kData].afk_timeout;\n }\n\n public get widgetEnabled(): boolean {\n return this[kData].widget_enabled ?? false;\n }\n\n public get widgetChannelId(): string | null {\n return this[kData].widget_channel_id ?? null;\n }\n\n public override get verificationLevel(): GuildVerificationLevel {\n return this[kData].verification_level;\n }\n\n public get defaultMessageNotifications() {\n return this[kData].default_message_notifications;\n }\n\n public get explicitContentFilter() {\n return this[kData].explicit_content_filter;\n }\n\n public get mfaLevel() {\n return this[kData].mfa_level;\n }\n\n /**\n * The ID of the application that created the guild, for bot-created guilds.\n */\n public get applicationId() {\n return this[kData].application_id;\n }\n\n public get systemChannelId() {\n return this[kData].system_channel_id;\n }\n\n /**\n * The flags deciding which system messages are suppressed in the system channel.\n */\n public get systemChannelFlags(): Readonly<SystemChannelFlagsBitField> {\n return new SystemChannelFlagsBitField(this[kData].system_channel_flags ?? 0).freeze();\n }\n\n public get rulesChannelId() {\n return this[kData].rules_channel_id;\n }\n\n public get publicUpdatesChannelId() {\n return this[kData].public_updates_channel_id;\n }\n\n public get safetyAlertsChannelId() {\n return this[kData].safety_alerts_channel_id;\n }\n\n /**\n * The channel members are moved to when idle, from the cache, like discord.js's `Guild#afkChannel`. `null` when\n * the guild has none, when it is not cached, or when the guild was not built by a manager.\n */\n public get afkChannel(): AnyChannel | null {\n return this.relatedChannel(\"afkChannel\");\n }\n\n /**\n * The channel system messages are sent to, from the cache.\n */\n public get systemChannel(): AnyChannel | null {\n return this.relatedChannel(\"systemChannel\");\n }\n\n /**\n * The channel the widget's invite leads to, from the cache.\n */\n public get widgetChannel(): AnyChannel | null {\n return this.relatedChannel(\"widgetChannel\");\n }\n\n /**\n * The rules channel of a community guild, from the cache.\n */\n public get rulesChannel(): AnyChannel | null {\n return this.relatedChannel(\"rulesChannel\");\n }\n\n /**\n * The channel Discord sends community updates to, from the cache.\n */\n public get publicUpdatesChannel(): AnyChannel | null {\n return this.relatedChannel(\"publicUpdatesChannel\");\n }\n\n /**\n * The channel Discord sends safety alerts to, from the cache.\n */\n public get safetyAlertsChannel(): AnyChannel | null {\n return this.relatedChannel(\"safetyAlertsChannel\");\n }\n\n /**\n * Gets one of the channels of {@link GuildRelations}: the one `client.guilds` resolved, else, for guilds built\n * without their channels (e.g. `message.guild`), a lookup in a synchronous cache.\n */\n private relatedChannel(name: keyof GuildRelations): AnyChannel | null {\n const resolved = this[kRelations][name];\n if (resolved !== undefined) return resolved;\n\n const channelId = (this[kData] as unknown as Record<string, string | null | undefined>)[\n GuildChannelFields[name]\n ];\n if (!channelId || this.client.cache?.channels.synchronous !== true) return null;\n try {\n return this.client.channels.cached(channelId) ?? null;\n } catch {\n // A relation of the channel is read from an asynchronous cache.\n return null;\n }\n }\n\n /**\n * Forgets the channels a patch changes.\n *\n * @internal\n */\n public [kPatchRelations](data: object): void {\n this.dropChangedRelations(data, GuildChannelFields);\n }\n\n /**\n * The maximum number of presences of the guild, `null` for the default limit.\n */\n public get maximumPresences(): number | null {\n return this[kData].max_presences ?? null;\n }\n\n public get maximumMembers(): number | null {\n return this[kData].max_members ?? null;\n }\n\n /**\n * The maximum number of users in a video channel.\n */\n public get maxVideoChannelUsers(): number | null {\n return this[kData].max_video_channel_users ?? null;\n }\n\n /**\n * The maximum number of users in a stage video channel.\n */\n public get maxStageVideoChannelUsers(): number | null {\n return this[kData].max_stage_video_channel_users ?? null;\n }\n\n public override get nsfwLevel() {\n return this[kData].nsfw_level;\n }\n\n public get premiumTier() {\n return this[kData].premium_tier;\n }\n\n public get premiumProgressBarEnabled(): boolean {\n return this[kData].premium_progress_bar_enabled ?? false;\n }\n\n public get preferredLocale() {\n return this[kData].preferred_locale;\n }\n\n /**\n * Until when invites or direct messages are paused because of raid activity, as set with `setIncidentActions`.\n */\n public get incidentsData(): APIIncidentsData | null {\n return this[kData].incidents_data ?? null;\n }\n\n /**\n * Whether the guild is considered large by the gateway, `false` if unknown.\n */\n public get large(): boolean {\n return this[kData].large ?? false;\n }\n\n /**\n * The member count, as sent in `GUILD_CREATE` or by the API, or `null` if unknown.\n */\n public get memberCount(): number | null {\n return this[kData].member_count ?? this[kData].approximate_member_count ?? null;\n }\n\n /**\n * The approximate member count, only present when fetched with counts.\n */\n public get approximateMemberCount(): number | null {\n return this[kData].approximate_member_count ?? null;\n }\n\n /**\n * The approximate number of online members, only present when fetched with counts.\n */\n public get approximatePresenceCount(): number | null {\n return this[kData].approximate_presence_count ?? null;\n }\n\n /**\n * The timestamp the client user joined the guild at, as sent in `GUILD_CREATE`, or `null` if unknown.\n */\n public get joinedTimestamp(): number | null {\n return this.optimizedTimestamp(\"joined_at\");\n }\n\n public get joinedAt(): Date | null {\n const { joinedTimestamp } = this;\n return joinedTimestamp === null ? null : new Date(joinedTimestamp);\n }\n\n /**\n * Whether the guild is available, `false` during a Discord outage.\n */\n public get available(): boolean {\n return !this[kData].unavailable;\n }\n\n /**\n * The maximum bitrate, in bits per second, voice channels of the guild can use.\n */\n public get maximumBitrate(): number {\n if (this.features.includes(GuildFeature.VIPRegions)) return 384_000;\n return this.maximumStageBitrate;\n }\n\n /**\n * The maximum bitrate, in bits per second, stage channels of the guild can use.\n */\n public get maximumStageBitrate(): number {\n switch (this.premiumTier) {\n case GuildPremiumTier.Tier1:\n return 128_000;\n case GuildPremiumTier.Tier2:\n return 256_000;\n case GuildPremiumTier.Tier3:\n return 384_000;\n default:\n return 96_000;\n }\n }\n\n /**\n * The custom emojis of the guild.\n */\n public get emojis(): GuildEmojiManager {\n return this.client.guilds.emojis(this.id);\n }\n\n /**\n * The custom stickers of the guild.\n */\n public get stickers(): GuildStickerManager {\n return this.client.guilds.stickers(this.id);\n }\n\n /**\n * Fetches the active threads of the guild, and caches them.\n */\n public fetchActiveThreads(): Promise<FetchedThreads> {\n return this.client.threads.fetchActive(this.id);\n }\n\n /**\n * Fetches the webhooks of the guild.\n */\n public fetchWebhooks(): Promise<Webhook[]> {\n return this.client.webhooks.fetchGuild(this.id);\n }\n\n /**\n * The scheduled events of the guild.\n */\n public get scheduledEvents(): GuildScheduledEventManager {\n return this.client.guilds.scheduledEvents(this.id);\n }\n\n /**\n * The live stages of the guild.\n */\n public get stageInstances(): StageInstanceManager {\n return this.client.guilds.stageInstances(this.id);\n }\n\n /**\n * The soundboard sounds of the guild.\n */\n public get soundboardSounds(): GuildSoundboardSoundManager {\n return this.client.guilds.soundboardSounds(this.id);\n }\n\n /**\n * The integrations of the guild.\n */\n public get integrations(): GuildIntegrationManager {\n return this.client.guilds.integrations(this.id);\n }\n\n /**\n * Fetches every integration of the guild.\n */\n public fetchIntegrations(): Promise<Integration[]> {\n return this.integrations.fetchAll();\n }\n\n /**\n * Fetches the templates of the guild.\n */\n public fetchTemplates(): Promise<GuildTemplate[]> {\n return this.client.templates.list(this.id);\n }\n\n /**\n * Creates a template of the guild.\n *\n * @param name The name of the template.\n * @param description The description of the template.\n */\n public createTemplate(name: string, description?: string | null): Promise<GuildTemplate> {\n const options: GuildTemplateCreateOptions = { name, description };\n return this.client.templates.create(this.id, options);\n }\n\n /**\n * Fetches the welcome screen of the guild.\n */\n public fetchWelcomeScreen(): Promise<WelcomeScreen> {\n return this.client.guilds.fetchWelcomeScreen(this.id);\n }\n\n /**\n * Edits the welcome screen of the guild.\n *\n * @param options The changes to apply.\n */\n public editWelcomeScreen(options: GuildWelcomeScreenEditOptions): Promise<WelcomeScreen> {\n return this.client.guilds.editWelcomeScreen(this.id, options);\n }\n\n /**\n * Fetches the public widget of the guild, which must be enabled.\n */\n public fetchWidget(): Promise<Widget> {\n return this.client.fetchGuildWidget(this.id);\n }\n\n /**\n * Fetches whether the widget of the guild is enabled, and its channel.\n */\n public fetchWidgetSettings(): Promise<GuildWidgetSettings> {\n return this.client.guilds.fetchWidgetSettings(this.id);\n }\n\n /**\n * Edits the widget settings of the guild, and patches {@link Guild.widgetEnabled} and\n * {@link Guild.widgetChannelId} in place.\n *\n * @param options Whether to enable the widget, and its channel.\n */\n public async setWidgetSettings(options: GuildWidgetSettingsEditOptions): Promise<this> {\n const settings = await this.client.guilds.editWidgetSettings(this.id, options);\n return this[kPatch]({\n widget_enabled: settings.enabled,\n widget_channel_id: settings.channelId,\n });\n }\n\n /**\n * Fetches the onboarding of the guild.\n */\n public fetchOnboarding(): Promise<GuildOnboarding> {\n return this.client.guilds.fetchOnboarding(this.id);\n }\n\n /**\n * Edits the onboarding of the guild.\n *\n * @param options The changes to apply. The prompts replace every existing one.\n */\n public editOnboarding(options: GuildOnboardingEditOptions): Promise<GuildOnboarding> {\n return this.client.guilds.editOnboarding(this.id, options);\n }\n\n /**\n * The bans of the guild.\n */\n public get bans(): GuildBanManager {\n return this.client.guilds.bans(this.id);\n }\n\n /**\n * The auto moderation rules of the guild.\n */\n public get autoModerationRules(): AutoModerationRuleManager {\n return this.client.guilds.autoModerationRules(this.id);\n }\n\n /**\n * Fetches a page of the guild's audit log.\n *\n * @param options Which user and action to filter by, and the page.\n */\n public fetchAuditLogs(options?: GuildAuditLogsFetchOptions): Promise<GuildAuditLogs> {\n return this.client.guilds.fetchAuditLogs(this.id, options);\n }\n\n /**\n * The channels of the guild.\n */\n public get channels(): GuildChannelManager {\n return this.client.guilds.channels(this.id);\n }\n\n /**\n * The invites of the guild.\n */\n public get invites(): GuildInviteManager {\n return this.client.guilds.invites(this.id);\n }\n\n /**\n * Gets the URL of the guild's discovery splash image, or `null` if it has none.\n * @param options The image options.\n */\n public discoverySplashURL(options?: BaseImageURLOptions): string | null {\n const { discovery_splash: discoverySplash } = this[kData];\n return discoverySplash ? cdn.discoverySplash(this.id, discoverySplash, options) : null;\n }\n\n /**\n * Fetches this guild from the API, with its approximate counts, and patches it in place.\n */\n public async fetch(): Promise<this> {\n const guild = await this.client.guilds.fetch(this.id, { force: true });\n return this[kPatch](guild.toJSON());\n }\n\n /**\n * Fetches the member owning this guild.\n */\n public fetchOwner(): Promise<GuildMember> {\n return this.client.members.fetch(this.id, this.ownerId);\n }\n\n /**\n * Requests the members of this guild over the gateway, every one of them by default, and caches them. discord.js:\n * `guild.members.fetch()`. See `client.members.request`.\n *\n * @param options Which members to request.\n */\n public requestMembers(options?: GuildMembersRequestOptions): Promise<GuildMember[]> {\n return this.client.members.request(this.id, options);\n }\n\n /**\n * Fetches every invite of this guild.\n */\n public fetchInvites(): Promise<GuildInvite[]> {\n return this.invites.fetchAll();\n }\n\n /**\n * Fetches the public preview of this guild.\n */\n public fetchPreview(): Promise<GuildPreview> {\n return this.client.guilds.fetchPreview(this.id);\n }\n\n /**\n * Fetches the voice regions available to this guild.\n */\n public fetchVoiceRegions(): Promise<APIVoiceRegion[]> {\n return this.client.guilds.fetchVoiceRegions(this.id);\n }\n\n /**\n * Fetches the vanity URL of this guild, patching {@link AnonymousGuild.vanityURLCode} in place.\n */\n public async fetchVanityData(): Promise<RESTGetAPIGuildVanityUrlResult> {\n const data = await this.client.guilds.fetchVanityData(this.id);\n this[kPatch]({ vanity_url_code: data.code });\n return data;\n }\n\n /**\n * Edits this guild.\n *\n * @param options The changes to apply.\n */\n public async edit(options: GuildEditOptions): Promise<this> {\n const guild = await this.client.guilds.edit(this.id, options);\n return this[kPatch](guild.toJSON());\n }\n\n public setName(name: string, reason?: string): Promise<this> {\n return this.edit({ name, reason });\n }\n\n /**\n * Sets the icon of this guild, as a data URI, `null` to remove it.\n */\n public setIcon(icon: string | null, reason?: string): Promise<this> {\n return this.edit({ icon, reason });\n }\n\n /**\n * Sets the banner of this guild, as a data URI, `null` to remove it.\n */\n public setBanner(banner: string | null, reason?: string): Promise<this> {\n return this.edit({ banner, reason });\n }\n\n /**\n * Sets the invite splash image of this guild, as a data URI, `null` to remove it.\n */\n public setSplash(splash: string | null, reason?: string): Promise<this> {\n return this.edit({ splash, reason });\n }\n\n /**\n * Sets the discovery splash image of this guild, as a data URI, `null` to remove it.\n */\n public setDiscoverySplash(discoverySplash: string | null, reason?: string): Promise<this> {\n return this.edit({ discoverySplash, reason });\n }\n\n public setSystemChannel(systemChannel: string | null, reason?: string): Promise<this> {\n return this.edit({ systemChannel, reason });\n }\n\n public setSystemChannelFlags(\n systemChannelFlags: SystemChannelFlagsResolvable,\n reason?: string,\n ): Promise<this> {\n return this.edit({ systemChannelFlags, reason });\n }\n\n public setAFKChannel(afkChannel: string | null, reason?: string): Promise<this> {\n return this.edit({ afkChannel, reason });\n }\n\n /**\n * Sets the AFK timeout of this guild, in seconds.\n */\n public setAFKTimeout(\n afkTimeout: RESTPatchAPIGuildJSONBody[\"afk_timeout\"],\n reason?: string,\n ): Promise<this> {\n return this.edit({ afkTimeout, reason });\n }\n\n public setRulesChannel(rulesChannel: string | null, reason?: string): Promise<this> {\n return this.edit({ rulesChannel, reason });\n }\n\n public setPublicUpdatesChannel(\n publicUpdatesChannel: string | null,\n reason?: string,\n ): Promise<this> {\n return this.edit({ publicUpdatesChannel, reason });\n }\n\n public setSafetyAlertsChannel(\n safetyAlertsChannel: string | null,\n reason?: string,\n ): Promise<this> {\n return this.edit({ safetyAlertsChannel, reason });\n }\n\n public setVerificationLevel(\n verificationLevel: GuildVerificationLevel | null,\n reason?: string,\n ): Promise<this> {\n return this.edit({ verificationLevel, reason });\n }\n\n public setExplicitContentFilter(\n explicitContentFilter: GuildExplicitContentFilter | null,\n reason?: string,\n ): Promise<this> {\n return this.edit({ explicitContentFilter, reason });\n }\n\n public setDefaultMessageNotifications(\n defaultMessageNotifications: GuildDefaultMessageNotifications | null,\n reason?: string,\n ): Promise<this> {\n return this.edit({ defaultMessageNotifications, reason });\n }\n\n public setPreferredLocale(preferredLocale: Locale | null, reason?: string): Promise<this> {\n return this.edit({ preferredLocale, reason });\n }\n\n public setPremiumProgressBarEnabled(enabled = true, reason?: string): Promise<this> {\n return this.edit({ premiumProgressBarEnabled: enabled, reason });\n }\n\n /**\n * Transfers the ownership of this guild to another member. The client user must own the guild.\n *\n * @param owner The ID of the new owner.\n */\n public setOwner(owner: string, reason?: string): Promise<this> {\n return this.edit({ owner, reason });\n }\n\n /**\n * Pauses or resumes invites to this guild, through the `INVITES_DISABLED` feature.\n *\n * @param disabled Whether to pause invites.\n */\n public disableInvites(disabled = true): Promise<this> {\n const features: GuildFeature[] = this.features.filter(\n (feature) => feature !== GuildFeature.InvitesDisabled,\n );\n if (disabled) features.push(GuildFeature.InvitesDisabled);\n return this.edit({ features });\n }\n\n /**\n * Pauses invites or direct messages for up to a day, e.g. during a raid.\n *\n * @param options Until when to pause each, `null` to resume.\n */\n public async setIncidentActions(options: GuildIncidentActionsOptions): Promise<APIIncidentsData> {\n const incidents = await this.client.guilds.setIncidentActions(this.id, options);\n this[kPatch]({ incidents_data: incidents });\n return incidents;\n }\n\n /**\n * Makes the client user leave this guild.\n */\n public async leave(): Promise<this> {\n await this.client.guilds.leave(this.id);\n return this;\n }\n\n /**\n * Deletes this guild. The client user must own it.\n */\n public async delete(): Promise<this> {\n await this.client.guilds.delete(this.id);\n return this;\n }\n\n /**\n * Whether this guild has the same data as another one.\n * @param guild The guild to compare with.\n */\n public equals(guild: Guild): boolean {\n return (\n this.id === guild.id &&\n this.name === guild.name &&\n this.icon === guild.icon &&\n this.splash === guild.splash &&\n this.discoverySplash === guild.discoverySplash &&\n this.ownerId === guild.ownerId &&\n this.afkTimeout === guild.afkTimeout &&\n this.afkChannelId === guild.afkChannelId &&\n this.systemChannelId === guild.systemChannelId &&\n this.verificationLevel === guild.verificationLevel &&\n this.explicitContentFilter === guild.explicitContentFilter &&\n this.mfaLevel === guild.mfaLevel &&\n this.banner === guild.banner &&\n this.description === guild.description &&\n this.vanityURLCode === guild.vanityURLCode &&\n this.features.length === guild.features.length &&\n this.features.every((feature) => guild.features.includes(feature))\n );\n }\n}\n","import { AutoModerationRule as BaseAutoModerationRule } from \"@discordjs/structures\";\nimport type {\n APIAutoModerationAction,\n APIAutoModerationRule,\n APIAutoModerationRuleTriggerMetadata,\n AutoModerationRuleEventType,\n AutoModerationRuleKeywordPresetType,\n} from \"discord-api-types/v10\";\nimport type { AutoModerationRuleEditOptions } from \"../../managers/AutoModerationRuleManager.js\";\nimport type { IdResolvable } from \"../../util/channels.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, kPatch, kRelations, StructureMixin } from \"../Structure.js\";\n\n/**\n * The relations of an {@link AutoModerationRule}, resolved from the cache by the guild's rule manager.\n */\nexport interface AutoModerationRuleRelations {\n guild?: Guild | null;\n}\n\nexport interface AutoModerationRule extends StructureMixin<\n APIAutoModerationRule,\n AutoModerationRuleRelations\n> {}\n\n/**\n * An auto moderation rule of a guild: `@discordjs/structures`' `AutoModerationRule`, with its trigger, actions, and\n * exemptions, and actions through the client.\n */\nexport class AutoModerationRule extends BaseAutoModerationRule {\n /**\n * @param data The raw rule.\n * @param relations The guild as resolved from the cache, by the guild's rule manager.\n */\n public constructor(data: APIAutoModerationRule, relations: AutoModerationRuleRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n public get triggerMetadata(): Readonly<APIAutoModerationRuleTriggerMetadata> {\n return this[kData].trigger_metadata;\n }\n\n public get actions(): readonly APIAutoModerationAction[] {\n return this[kData].actions;\n }\n\n public get exemptRoles(): readonly string[] {\n return this[kData].exempt_roles;\n }\n\n public get exemptChannels(): readonly string[] {\n return this[kData].exempt_channels;\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * Edits the rule.\n *\n * @param options The fields to edit, and the reason for the audit log.\n */\n public async edit(options: AutoModerationRuleEditOptions): Promise<this> {\n const rule = await this.client.guilds.autoModerationRules(this.guildId).edit(this.id, options);\n return this[kPatch](rule.toJSON());\n }\n\n public setName(name: string, reason?: string): Promise<this> {\n return this.edit({ name, reason });\n }\n\n public setEventType(eventType: AutoModerationRuleEventType, reason?: string): Promise<this> {\n return this.edit({ eventType, reason });\n }\n\n public setEnabled(enabled = true, reason?: string): Promise<this> {\n return this.edit({ enabled, reason });\n }\n\n public setActions(actions: readonly APIAutoModerationAction[], reason?: string): Promise<this> {\n return this.edit({ actions, reason });\n }\n\n public setExemptRoles(roles: readonly IdResolvable[], reason?: string): Promise<this> {\n return this.edit({ exemptRoles: roles, reason });\n }\n\n public setExemptChannels(channels: readonly IdResolvable[], reason?: string): Promise<this> {\n return this.edit({ exemptChannels: channels, reason });\n }\n\n /**\n * Sets the keywords of a keyword rule, keeping the rest of its trigger.\n */\n public setKeywordFilter(keywordFilter: readonly string[], reason?: string): Promise<this> {\n return this.editTrigger({ keyword_filter: [...keywordFilter] }, reason);\n }\n\n /**\n * Sets the regular expressions of a keyword rule, keeping the rest of its trigger.\n */\n public setRegexPatterns(regexPatterns: readonly string[], reason?: string): Promise<this> {\n return this.editTrigger({ regex_patterns: [...regexPatterns] }, reason);\n }\n\n /**\n * Sets the keyword presets of a keyword preset rule, keeping the rest of its trigger.\n */\n public setPresets(\n presets: readonly AutoModerationRuleKeywordPresetType[],\n reason?: string,\n ): Promise<this> {\n return this.editTrigger({ presets: [...presets] }, reason);\n }\n\n /**\n * Sets the keywords exempt from the rule, keeping the rest of its trigger.\n */\n public setAllowList(allowList: readonly string[], reason?: string): Promise<this> {\n return this.editTrigger({ allow_list: [...allowList] }, reason);\n }\n\n /**\n * Sets how many mentions a message may have, for a mention spam rule.\n */\n public setMentionTotalLimit(mentionTotalLimit: number, reason?: string): Promise<this> {\n return this.editTrigger({ mention_total_limit: mentionTotalLimit }, reason);\n }\n\n /**\n * Sets whether a mention spam rule detects mention raids.\n */\n public setMentionRaidProtectionEnabled(enabled = true, reason?: string): Promise<this> {\n return this.editTrigger({ mention_raid_protection_enabled: enabled }, reason);\n }\n\n /**\n * Deletes the rule.\n *\n * @param reason The reason for the audit log.\n */\n public async delete(reason?: string): Promise<this> {\n await this.client.guilds.autoModerationRules(this.guildId).delete(this.id, reason);\n return this;\n }\n\n // Discord replaces the whole trigger metadata, so the setters merge their field into the current one.\n private editTrigger(patch: APIAutoModerationRuleTriggerMetadata, reason?: string): Promise<this> {\n return this.edit({ triggerMetadata: { ...this.triggerMetadata, ...patch }, reason });\n }\n}\n\nMixin(AutoModerationRule, [StructureMixin]);\n","import type { EmojiURLOptions } from \"@discordjs/rest\";\nimport { Emoji as BaseEmoji } from \"@discordjs/structures\";\nimport type { APIEmoji } from \"discord-api-types/v10\";\nimport { cdn } from \"../../util/cdn.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, StructureMixin } from \"../Structure.js\";\n\n/**\n * The raw fields any emoji carries: a custom emoji has an ID, a Unicode one only a name.\n */\nexport type EmojiData = Pick<APIEmoji, \"id\" | \"name\"> & Partial<Pick<APIEmoji, \"animated\">>;\n\nexport interface Emoji<\n Data extends EmojiData = EmojiData,\n Relations extends object = object,\n> extends StructureMixin<Data, Relations> {}\n\n/**\n * An emoji, a custom one (with an ID) or a Unicode one: `@discordjs/structures`' `Emoji`, with its identifier, image\n * URL, and mention.\n *\n * @typeParam Data The raw emoji data this structure wraps.\n * @typeParam Relations The related structures, resolved from the cache.\n */\nexport class Emoji<\n Data extends EmojiData = EmojiData,\n Relations extends object = object,\n> extends BaseEmoji {\n /**\n * @param data The raw emoji.\n * @param relations The related structures, resolved from the cache.\n */\n public constructor(data: Data, relations: Relations = {} as Relations) {\n super(data);\n initStructure(this, data, relations);\n }\n\n public override get animated(): boolean {\n return this[kData].animated ?? false;\n }\n\n /**\n * The form reactions routes expect: `name:id` for custom emojis, the URL-encoded emoji for Unicode ones.\n */\n public get identifier(): string {\n const { id, name } = this;\n if (id) return `${this.animated ? \"a:\" : \"\"}${name ?? \"_\"}:${id}`;\n return encodeURIComponent(name ?? \"\");\n }\n\n public get createdAt(): Date | null {\n return this.createdDate;\n }\n\n /**\n * Gets the URL of the custom emoji's image, `null` for a Unicode emoji. Animated emojis default to a GIF.\n * @param options The image options.\n */\n public imageURL(options?: EmojiURLOptions): string | null {\n const { id } = this;\n if (!id) return null;\n return cdn.emoji(id, options ?? (this.animated ? { extension: \"gif\" } : undefined));\n }\n\n /**\n * The emoji as it is written in a message: `<:name:id>`, `<a:name:id>`, or the Unicode emoji itself.\n */\n public toString(): string {\n const { id, name } = this;\n return id ? `<${this.animated ? \"a\" : \"\"}:${name ?? \"_\"}:${id}>` : (name ?? \"\");\n }\n}\n\nMixin(Emoji, [StructureMixin]);\n","import { FormattingPatterns, type APIPartialEmoji } from \"discord-api-types/v10\";\nimport { Emoji } from \"./Emoji.js\";\n\n/**\n * Anything identifying an emoji: a Unicode emoji, a custom emoji mention (`<a:name:id>`), a `name:id` pair, a bare\n * emoji ID, or any object carrying `id`/`name`/`animated` (an {@link Emoji}, a raw `APIPartialEmoji`, ...).\n */\nexport type EmojiIdentifierResolvable =\n | string\n | { id?: string | null; name?: string | null; animated?: boolean | null };\n\n/**\n * Matches a `name:id` or `a:name:id` pair without the mention brackets.\n */\nconst CustomEmojiPattern = /^(?:(?<animated>a):)?(?<name>\\w{2,32}):(?<id>\\d{17,20})$/;\n\n/**\n * The emoji of a reaction or of a poll answer: a Unicode emoji, or a custom one known only by its ID and name.\n */\nexport class ReactionEmoji extends Emoji<APIPartialEmoji> {\n /**\n * Resolves anything {@link EmojiIdentifierResolvable} to the identifier reaction routes expect.\n *\n * @param emoji The emoji to resolve.\n * @throws A `TypeError` when the value identifies no emoji.\n */\n public static resolveIdentifier(emoji: EmojiIdentifierResolvable): string {\n if (typeof emoji === \"string\") {\n const decoded = emoji.includes(\"%\") ? decodeURIComponent(emoji) : emoji;\n if (/^\\d{17,20}$/.test(decoded)) return `_:${decoded}`;\n\n const custom = FormattingPatterns.Emoji.exec(decoded) ?? CustomEmojiPattern.exec(decoded);\n if (custom?.groups) {\n const { animated, name, id } = custom.groups;\n return `${animated ? \"a:\" : \"\"}${name}:${id}`;\n }\n\n if (!decoded) throw new TypeError(\"Cannot resolve an empty string to an emoji\");\n return encodeURIComponent(decoded);\n }\n\n const { id, name, animated } = emoji;\n if (id) return `${animated ? \"a:\" : \"\"}${name ?? \"_\"}:${id}`;\n if (name) return encodeURIComponent(name);\n throw new TypeError(\"Cannot resolve an emoji without an ID nor a name\");\n }\n\n /**\n * Resolves anything {@link EmojiIdentifierResolvable} to the ID and name pair of welcome screens and onboarding.\n *\n * @param emoji The emoji to resolve.\n */\n public static resolvePartial(emoji: EmojiIdentifierResolvable): {\n id: string | null;\n name: string | null;\n animated: boolean;\n } {\n if (typeof emoji !== \"string\") {\n return { id: emoji.id ?? null, name: emoji.name ?? null, animated: emoji.animated ?? false };\n }\n\n if (/^\\d{17,20}$/.test(emoji)) return { id: emoji, name: null, animated: false };\n const custom = FormattingPatterns.Emoji.exec(emoji) ?? CustomEmojiPattern.exec(emoji);\n if (custom?.groups) {\n const { animated, name, id } = custom.groups;\n return { id: id!, name: name!, animated: Boolean(animated) };\n }\n\n return { id: null, name: emoji, animated: false };\n }\n}\n","import type {\n APIGuildOnboarding,\n APIGuildOnboardingPrompt,\n APIGuildOnboardingPromptOption,\n} from \"discord-api-types/v10\";\nimport type { GuildOnboardingEditOptions } from \"../../managers/GuildManager.js\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { GuildEmoji } from \"../emojis/GuildEmoji.js\";\nimport type { Guild } from \"./Guild.js\";\nimport type { Role } from \"./Role.js\";\nimport { ReactionEmoji } from \"../emojis/ReactionEmoji.js\";\nimport { pickCached as pick } from \"../../util/cache.js\";\nimport { bindClient, kData, kPatch, kRelations, Structure } from \"../Structure.js\";\n\n/**\n * The relations of a {@link GuildOnboarding}, shared with its prompts and their options: its guild, and the channels,\n * roles, and custom emojis its prompts refer to, resolved from the cache by `client.guilds`.\n */\nexport interface GuildOnboardingRelations {\n guild?: Guild | null;\n channels?: ReadonlyMap<string, AnyChannel>;\n roles?: ReadonlyMap<string, Role>;\n emojis?: ReadonlyMap<string, GuildEmoji>;\n}\n\n/**\n * An answer of an onboarding prompt, with the channels and roles it gives.\n */\nexport class GuildOnboardingPromptOption extends Structure<APIGuildOnboardingPromptOption> {\n declare public [kRelations]: GuildOnboardingRelations;\n\n /**\n * The guild, from the cache, like discord.js's `GuildOnboardingPromptOption#guild`.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * The cached channels the option gives access to, by ID, like discord.js's `GuildOnboardingPromptOption#channels`.\n */\n public get channels(): Map<string, AnyChannel> {\n return pick(this[kData].channel_ids, this[kRelations].channels);\n }\n\n /**\n * The cached roles the option gives, by ID, like discord.js's `GuildOnboardingPromptOption#roles`.\n */\n public get roles(): Map<string, Role> {\n return pick(this[kData].role_ids, this[kRelations].roles);\n }\n public get id() {\n return this[kData].id;\n }\n\n public get title() {\n return this[kData].title;\n }\n\n public get description() {\n return this[kData].description;\n }\n\n public get channelIds() {\n return this[kData].channel_ids;\n }\n\n public get roleIds() {\n return this[kData].role_ids;\n }\n\n /**\n * The emoji of the option: the cached custom emoji of the guild, like discord.js, else the payload's.\n */\n public get emoji(): GuildEmoji | ReactionEmoji | null {\n const { emoji } = this[kData];\n const cached = emoji?.id ? this[kRelations].emojis?.get(emoji.id) : undefined;\n return cached ?? (emoji?.id || emoji?.name ? new ReactionEmoji(emoji) : null);\n }\n}\n\n/**\n * A question of a guild's onboarding.\n */\nexport class GuildOnboardingPrompt extends Structure<APIGuildOnboardingPrompt> {\n declare public [kRelations]: GuildOnboardingRelations;\n\n /**\n * The guild, from the cache, like discord.js's `GuildOnboardingPrompt#guild`.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n public get id() {\n return this[kData].id;\n }\n\n public get title() {\n return this[kData].title;\n }\n\n public get type() {\n return this[kData].type;\n }\n\n public get singleSelect() {\n return this[kData].single_select;\n }\n\n public get required() {\n return this[kData].required;\n }\n\n /**\n * Whether the prompt is asked during onboarding, rather than only in the channels & roles page.\n */\n public get inOnboarding() {\n return this[kData].in_onboarding;\n }\n\n public get options(): GuildOnboardingPromptOption[] {\n return this[kData].options.map((option) =>\n bindClient(new GuildOnboardingPromptOption(option, this[kRelations]), this.client),\n );\n }\n}\n\n/**\n * The onboarding of a guild: the prompts new members answer, and the channels they start in.\n */\nexport class GuildOnboarding extends Structure<APIGuildOnboarding> {\n declare public [kRelations]: GuildOnboardingRelations;\n\n /**\n * @param data The raw onboarding.\n * @param relations The guild, as resolved from the cache.\n */\n public constructor(data: APIGuildOnboarding, relations: GuildOnboardingRelations = {}) {\n super(data, relations);\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n public get prompts(): GuildOnboardingPrompt[] {\n return this[kData].prompts.map((prompt) =>\n bindClient(new GuildOnboardingPrompt(prompt, this[kRelations]), this.client),\n );\n }\n\n /**\n * The channels members are in by default.\n */\n public get defaultChannelIds() {\n return this[kData].default_channel_ids;\n }\n\n /**\n * The cached channels members are added to by default, by ID, like discord.js's\n * `GuildOnboarding#defaultChannels`.\n */\n public get defaultChannels(): Map<string, AnyChannel> {\n return pick(this[kData].default_channel_ids, this[kRelations].channels);\n }\n\n public get enabled() {\n return this[kData].enabled;\n }\n\n public get mode() {\n return this[kData].mode;\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * Edits the onboarding.\n *\n * @param options The changes to apply.\n */\n public async edit(options: GuildOnboardingEditOptions): Promise<this> {\n const onboarding = await this.client.guilds.editOnboarding(this.guildId, options);\n return this[kPatch](onboarding.toJSON());\n }\n}\n","import type { ImageURLOptions } from \"@discordjs/rest\";\nimport {\n GuildScheduledEventStatus,\n type APIGuildScheduledEvent,\n type APIGuildScheduledEventRecurrenceRule,\n} from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type {\n GuildScheduledEventEditOptions,\n GuildScheduledEventSubscriber,\n GuildScheduledEventSubscribersOptions,\n} from \"../../managers/GuildScheduledEventManager.js\";\nimport { cdn } from \"../../util/cdn.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kPatch, kRelations, snowflakeTimestamp, Structure } from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\n/**\n * The relations of a {@link GuildScheduledEvent}, resolved from the cache by the guild's event manager.\n */\nexport interface GuildScheduledEventRelations {\n creator?: User | null;\n guild?: Guild | null;\n channel?: AnyChannel | null;\n}\n\n/**\n * An event scheduled in a guild: in a stage or voice channel, or somewhere else.\n */\nexport class GuildScheduledEvent extends Structure<APIGuildScheduledEvent> {\n declare public [kRelations]: GuildScheduledEventRelations;\n\n protected override optimizeData(data: Partial<APIGuildScheduledEvent>): void {\n this.optimizeTimestamp(\"scheduled_start_time\", data.scheduled_start_time);\n this.optimizeTimestamp(\"scheduled_end_time\", data.scheduled_end_time);\n }\n\n /**\n * @param data The raw event.\n * @param relations The creator, guild, and channel as resolved from the cache, by the guild's event manager.\n */\n public constructor(data: APIGuildScheduledEvent, relations: GuildScheduledEventRelations = {}) {\n super(data, relations);\n }\n\n public override [kPatch](data: Readonly<Partial<APIGuildScheduledEvent>>): this {\n if (data.creator) this.dropRelations(\"creator\");\n if (data.channel_id !== undefined) this.dropRelations(\"channel\");\n return super[kPatch](data);\n }\n\n public get id() {\n return this[kData].id;\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n public get channelId(): string | null {\n return this[kData].channel_id;\n }\n\n public get creatorId(): string | null {\n return this[kData].creator_id ?? null;\n }\n\n public get name() {\n return this[kData].name;\n }\n\n /**\n * Whether the event is partial: built from its IDs alone for an event about an uncached scheduled event, see\n * `Partials.GuildScheduledEvent`. Only `id` and `guildId` are reliable then, and {@link GuildScheduledEvent.fetch}\n * completes it.\n */\n public get partial(): boolean {\n return this[kData].name === undefined;\n }\n\n /**\n * Fetches the event from the API and patches this structure with the result.\n */\n public async fetch(): Promise<this> {\n const event = await this.client.guilds\n .scheduledEvents(this.guildId)\n .fetch(this.id, { force: true });\n return this[kPatch](event.toJSON());\n }\n\n public get description(): string | null {\n return this[kData].description ?? null;\n }\n\n public get scheduledStartTimestamp(): number {\n return this.optimizedTimestamp(\"scheduled_start_time\")!;\n }\n\n public get scheduledStartAt(): Date {\n return new Date(this.scheduledStartTimestamp);\n }\n\n public get scheduledEndTimestamp(): number | null {\n return this.optimizedTimestamp(\"scheduled_end_time\");\n }\n\n public get scheduledEndAt(): Date | null {\n const { scheduledEndTimestamp } = this;\n return scheduledEndTimestamp === null ? null : new Date(scheduledEndTimestamp);\n }\n\n public get privacyLevel() {\n return this[kData].privacy_level;\n }\n\n public get status() {\n return this[kData].status;\n }\n\n public get entityType() {\n return this[kData].entity_type;\n }\n\n public get entityId(): string | null {\n return this[kData].entity_id;\n }\n\n /**\n * Where an external event takes place.\n */\n public get location(): string | null {\n return this[kData].entity_metadata?.location ?? null;\n }\n\n /**\n * How many users subscribed, when the payload includes it.\n */\n public get userCount(): number | null {\n return this[kData].user_count ?? null;\n }\n\n public get image(): string | null {\n return this[kData].image ?? null;\n }\n\n public get recurrenceRule(): APIGuildScheduledEventRecurrenceRule | null {\n return this[kData].recurrence_rule;\n }\n\n /**\n * The creator, from the payload or the cache.\n */\n public get creator(): User | null {\n const { creator } = this[kData];\n return this[kRelations].creator ?? (creator ? new User(creator) : null);\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n public get channel(): AnyChannel | null {\n return this[kRelations].channel ?? null;\n }\n\n /**\n * The URL of the event.\n */\n public get url(): string {\n return `https://discord.com/events/${this.guildId}/${this.id}`;\n }\n\n public get createdTimestamp() {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n\n public coverImageURL(options?: Readonly<ImageURLOptions>): string | null {\n const { image } = this;\n return image ? cdn.guildScheduledEventCover(this.id, image, options) : null;\n }\n\n public isScheduled(): boolean {\n return this.status === GuildScheduledEventStatus.Scheduled;\n }\n\n public isActive(): boolean {\n return this.status === GuildScheduledEventStatus.Active;\n }\n\n public isCompleted(): boolean {\n return this.status === GuildScheduledEventStatus.Completed;\n }\n\n public isCanceled(): boolean {\n return this.status === GuildScheduledEventStatus.Canceled;\n }\n\n /**\n * Edits the event.\n *\n * @param options The fields to edit, and the reason for the audit log.\n */\n public async edit(options: GuildScheduledEventEditOptions): Promise<this> {\n const event = await this.client.guilds.scheduledEvents(this.guildId).edit(this.id, options);\n return this[kPatch](event.toJSON());\n }\n\n public setName(name: string, reason?: string): Promise<this> {\n return this.edit({ name, reason });\n }\n\n public setDescription(description: string | null, reason?: string): Promise<this> {\n return this.edit({ description, reason });\n }\n\n public setScheduledStartTime(scheduledStartTime: Date | number, reason?: string): Promise<this> {\n return this.edit({ scheduledStartTime, reason });\n }\n\n public setScheduledEndTime(\n scheduledEndTime: Date | number | null,\n reason?: string,\n ): Promise<this> {\n return this.edit({ scheduledEndTime, reason });\n }\n\n public setStatus(status: GuildScheduledEventStatus, reason?: string): Promise<this> {\n return this.edit({ status, reason });\n }\n\n /**\n * Sets where an external event takes place.\n */\n public setLocation(location: string, reason?: string): Promise<this> {\n return this.edit({ entityMetadata: { location }, reason });\n }\n\n /**\n * Fetches the users who subscribed to the event, paginated by user ID.\n *\n * @param options How many users, around which user ID, and whether to include their members.\n */\n public fetchSubscribers(\n options?: GuildScheduledEventSubscribersOptions,\n ): Promise<GuildScheduledEventSubscriber[]> {\n return this.client.guilds.scheduledEvents(this.guildId).fetchSubscribers(this.id, options);\n }\n\n public async delete(reason?: string): Promise<this> {\n await this.client.guilds.scheduledEvents(this.guildId).delete(this.id, reason);\n return this;\n }\n}\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { Guild } from \"./Guild.js\";\nimport type { Role } from \"./Role.js\";\nimport { kData, kPatch, kRelations, Structure } from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\n/**\n * The relations of an {@link Integration}, resolved from the cache by the guild's integration manager.\n */\nexport interface IntegrationRelations {\n user?: User | null;\n guild?: Guild | null;\n role?: Role | null;\n}\n\n/**\n * An integration of a guild: a bot, a Twitch or YouTube subscription, or a guild subscription.\n */\nexport class Integration extends Structure<CacheEntityTypes[\"integrations\"]> {\n declare public [kRelations]: IntegrationRelations;\n\n protected override optimizeData(data: Partial<CacheEntityTypes[\"integrations\"]>): void {\n this.optimizeTimestamp(\"synced_at\", data.synced_at);\n }\n\n /**\n * @param data The raw integration.\n * @param relations The user and guild as resolved from the cache, by the guild's integration manager.\n */\n public constructor(data: CacheEntityTypes[\"integrations\"], relations: IntegrationRelations = {}) {\n super(data, relations);\n }\n\n public get id() {\n return this[kData].id;\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n public get name() {\n return this[kData].name;\n }\n\n public get type() {\n return this[kData].type;\n }\n\n public get enabled(): boolean | null {\n return this[kData].enabled ?? null;\n }\n\n /**\n * Whether the integration is syncing. Bot integrations have none.\n */\n public get syncing(): boolean | null {\n return this[kData].syncing ?? null;\n }\n\n /**\n * The role given to the integration's subscribers.\n */\n public get roleId(): string | null {\n return this[kData].role_id ?? null;\n }\n\n /**\n * The role given to the integration's subscribers, from the cache, like discord.js's `Integration#role`: `null`\n * when it has none, when it is not cached, or when the integration was not built by a manager.\n */\n public get role(): Role | null {\n return this[kRelations].role ?? null;\n }\n\n public override [kPatch](data: Readonly<Partial<CacheEntityTypes[\"integrations\"]>>): this {\n if (data.user) this.dropRelations(\"user\");\n this.dropChangedRelations(data, { role: \"role_id\" });\n return super[kPatch](data);\n }\n\n public get enableEmoticons(): boolean | null {\n return this[kData].enable_emoticons ?? null;\n }\n\n public get expireBehavior() {\n return this[kData].expire_behavior ?? null;\n }\n\n /**\n * The grace period, in days, before expiring subscribers.\n */\n public get expireGracePeriod(): number | null {\n return this[kData].expire_grace_period ?? null;\n }\n\n /**\n * The user who added the integration.\n */\n public get user(): User | null {\n const { user } = this[kData];\n return this[kRelations].user ?? (user ? new User(user) : null);\n }\n\n /**\n * The account on the integration's service.\n */\n public get account() {\n return this[kData].account;\n }\n\n public get syncedTimestamp(): number | null {\n return this.optimizedTimestamp(\"synced_at\");\n }\n\n public get syncedAt(): Date | null {\n const { syncedTimestamp } = this;\n return syncedTimestamp === null ? null : new Date(syncedTimestamp);\n }\n\n public get subscriberCount(): number | null {\n return this[kData].subscriber_count ?? null;\n }\n\n public get revoked(): boolean | null {\n return this[kData].revoked ?? null;\n }\n\n /**\n * The application of a bot integration.\n */\n public get application() {\n return this[kData].application ?? null;\n }\n\n /**\n * The OAuth2 scopes the application was authorized with.\n */\n public get scopes() {\n return this[kData].scopes ?? [];\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * Removes the integration from the guild, kicking its bot if it has one.\n *\n * @param reason The reason for the audit log.\n */\n public async delete(reason?: string): Promise<this> {\n await this.client.guilds.integrations(this.guildId).delete(this.id, reason);\n return this;\n }\n}\n","import { Invite, Structure as BaseStructure, type APIActualInvite } from \"@discordjs/structures\";\nimport {\n InviteType,\n type APIApplication,\n type APIExtendedInvite,\n type APIInviteChannel,\n type GatewayInviteCreateDispatchData,\n} from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, kPatch, kRelations, StructureMixin } from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\n/**\n * The raw data of an invite, from the REST API (`APIExtendedInvite`, with a nested `channel` and `guild`) or from an\n * `INVITE_CREATE` dispatch (with `channel_id` and `guild_id`).\n */\nexport type InviteData = { code: string } & Partial<Omit<APIExtendedInvite, \"code\" | \"uses\">> &\n Partial<Omit<GatewayInviteCreateDispatchData, \"code\" | \"uses\">> & { uses?: number };\n\n/**\n * The relations of an invite, resolved from the cache by `client.guilds.invites()`.\n */\nexport interface InviteRelations {\n inviter?: User;\n targetUser?: User;\n guild?: Guild | null;\n channel?: AnyChannel | null;\n}\n\nexport interface BaseInvite<Data extends InviteData = InviteData> extends StructureMixin<\n Data,\n InviteRelations\n> {}\n\n/**\n * The base of every invite, to a guild, to a group direct message, or a friend invite: `@discordjs/structures`'\n * `Invite`, with its channel, inviter, target user, and discord.js' helpers.\n *\n * @typeParam Data The raw invite data this structure wraps.\n */\nexport class BaseInvite<Data extends InviteData = InviteData> extends Invite<\"\"> {\n /**\n * Keeps the raw `created_at` and `expires_at`, which `@discordjs/structures` strips and re-serializes in its own\n * format, so that {@link BaseInvite.toJSON} returns the invite as received.\n */\n public static override readonly DataTemplate: Partial<APIActualInvite> = {};\n\n protected override optimizeData(data: Partial<Data>): void {\n super.optimizeData(data as Partial<APIActualInvite>);\n this.optimizeTimestamp(\"created_at\", data.created_at);\n this.optimizeTimestamp(\"expires_at\", data.expires_at);\n }\n\n /**\n * @param data The raw invite.\n * @param relations The inviter, target user, and guild as resolved from the cache, by `client.guilds.invites()`.\n */\n public constructor(data: Data, relations: InviteRelations = {}) {\n // An `INVITE_CREATE` dispatch has neither the `type` nor the `channel` `@discordjs/structures` expects.\n super(data as unknown as APIActualInvite);\n initStructure(this, data, relations);\n }\n\n public [kPatch](data: Readonly<Partial<Data>>): this {\n if (data.inviter) this.dropRelations(\"inviter\");\n if (data.target_user) this.dropRelations(\"targetUser\");\n return StructureMixin.prototype[kPatch].call(this, data) as this;\n }\n\n /**\n * The URL of the invite.\n */\n public override get url(): string {\n return `https://discord.gg/${this.code}`;\n }\n\n public override get type(): InviteType {\n return this[kData].type ?? (this[kData].guild_id ? InviteType.Guild : InviteType.Friend);\n }\n\n public get channelId(): string | null {\n return this[kData].channel?.id ?? this[kData].channel_id ?? null;\n }\n\n /**\n * The channel the invite leads to, like discord.js's `BaseInvite#channel`: the cached channel, else the partial\n * channel the API returns with the invite, if any.\n */\n public get channel(): AnyChannel | APIInviteChannel | null {\n return this[kRelations].channel ?? this[kData].channel ?? null;\n }\n\n /**\n * The user who created the invite, if known.\n */\n public get inviter(): User | null {\n const { inviter } = this[kData];\n return this[kRelations].inviter ?? (inviter ? new User(inviter) : null);\n }\n\n public get inviterId(): string | null {\n return this[kData].inviter?.id ?? null;\n }\n\n public get targetUser(): User | null {\n const { target_user: targetUser } = this[kData];\n return this[kRelations].targetUser ?? (targetUser ? new User(targetUser) : null);\n }\n\n public get targetApplication(): Partial<APIApplication> | null {\n return this[kData].target_application ?? null;\n }\n\n public override get createdTimestamp(): number | null {\n return this.optimizedTimestamp(\"created_at\");\n }\n\n public get createdAt(): Date | null {\n const { createdTimestamp } = this;\n return createdTimestamp === null ? null : new Date(createdTimestamp);\n }\n\n /**\n * When the invite expires, `null` when it never does or it is unknown.\n */\n public override get expiresTimestamp(): number | null {\n const expiresAt = this.optimizedTimestamp(\"expires_at\");\n if (expiresAt !== null) return expiresAt;\n\n const { createdTimestamp, maxAge } = this;\n return createdTimestamp !== null && maxAge ? createdTimestamp + maxAge * 1000 : null;\n }\n\n public get expiresAt(): Date | null {\n const { expiresTimestamp } = this;\n return expiresTimestamp === null ? null : new Date(expiresTimestamp);\n }\n\n /**\n * Transforms this invite into its raw data, as received.\n *\n * @remarks\n * Typed as `@discordjs/structures`' `APIActualInvite`, but an invite built from an `INVITE_CREATE` dispatch has the\n * dispatch's fields instead.\n */\n public override toJSON(): APIActualInvite {\n return BaseStructure.prototype.toJSON.call(this) as APIActualInvite;\n }\n\n public override valueOf(): string {\n return this.code;\n }\n}\n\nMixin(BaseInvite, [StructureMixin]);\n","import type { APIInviteGuild } from \"discord-api-types/v10\";\nimport { AnonymousGuild } from \"./AnonymousGuild.js\";\n\n/**\n * The partial guild carried by a {@link GuildInvite}.\n *\n * @remarks\n * The welcome screen discord.js attaches here comes with the admin phase (see #54).\n */\nexport class InviteGuild extends AnonymousGuild<APIInviteGuild> {}\n","import { BaseInvite } from \"./BaseInvite.js\";\nimport { InviteGuild } from \"../guilds/InviteGuild.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport { kData, kRelations } from \"../Structure.js\";\n\n/**\n * An invite to a guild.\n */\nexport class GuildInvite extends BaseInvite {\n public get guildId(): string | null {\n return this[kData].guild?.id ?? this[kData].guild_id ?? null;\n }\n\n /**\n * The guild the invite leads to: the cached guild when the invite comes from a manager, like discord.js, else the\n * partial guild the API returns with the invite, if any.\n */\n public get guild(): Guild | InviteGuild | null {\n const { guild } = this[kData];\n return this[kRelations].guild ?? (guild ? new InviteGuild(guild) : null);\n }\n\n /**\n * Whether the bot can delete the invite: it created it, or it has `ManageGuild` (or `ManageChannels`).\n */\n public async fetchDeletable(): Promise<boolean> {\n const client = this.client;\n const { guildId } = this;\n if (!guildId) return false;\n if (this.inviterId === (client.user?.id ?? client.id)) return true;\n\n const me = await client.members.fetchMe(guildId);\n const permissions = await me.fetchPermissions();\n return permissions.any([\"ManageGuild\", \"ManageChannels\"]);\n }\n\n /**\n * Deletes the invite.\n *\n * @param reason The reason for the audit log.\n */\n public async delete(reason?: string): Promise<this> {\n const { guildId } = this;\n if (!guildId) throw new Error(`Invite ${this.code} has no known guild`);\n await this.client.guilds.invites(guildId).delete(this.code, reason);\n return this;\n }\n}\n","import type { StickerExtension } from \"@discordjs/rest\";\nimport { Sticker as BaseSticker } from \"@discordjs/structures\";\nimport { StickerFormatType, type APISticker } from \"discord-api-types/v10\";\nimport type { GuildStickerEditOptions } from \"../../managers/GuildStickerManager.js\";\nimport { cdn } from \"../../util/cdn.js\";\nimport type { StickerPack } from \"./StickerPack.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport {\n initStructure,\n kData,\n kPatch,\n kRelations,\n snowflakeTimestamp,\n StructureMixin,\n} from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\n/**\n * The relations of a {@link Sticker}, resolved from the cache by the guild's sticker manager.\n */\nexport interface StickerRelations {\n user?: User;\n guild?: Guild | null;\n}\n\nexport interface Sticker extends StructureMixin<APISticker, StickerRelations> {}\n\n/**\n * A sticker, a standard one from a sticker pack or a custom one of a guild: `@discordjs/structures`' `Sticker`, with\n * its guild, uploader, and URL, and actions through the client.\n */\nexport class Sticker extends BaseSticker {\n /**\n * @param data The raw sticker.\n * @param relations The uploader and guild as resolved from the cache, by the guild's sticker manager.\n */\n public constructor(data: APISticker, relations: StickerRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n public [kPatch](data: Readonly<Partial<APISticker>>): this {\n if (data.user) this.dropRelations(\"user\");\n return StructureMixin.prototype[kPatch].call(this, data) as this;\n }\n\n /**\n * The format of the sticker's image, an alias of `formatType`.\n */\n public get format() {\n return this.formatType;\n }\n\n /**\n * Whether the sticker can be used, `false` when its guild lost the boosts it needs.\n */\n public override get available(): boolean {\n return this[kData].available ?? true;\n }\n\n public get guildId(): string | null {\n return this[kData].guild_id ?? null;\n }\n\n /**\n * The guild, from the cache. `null` outside of guilds, when the guild is not cached, or when the sticker was not built by\n * a manager: use `fetchGuild()` to always get it.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * Fetches the guild, cache first. `null` outside of guilds.\n */\n public async fetchGuild(): Promise<Guild | null> {\n const { guildId } = this;\n return guildId ? this.client.guilds.fetch(guildId) : null;\n }\n\n /**\n * The ID of the pack of a standard sticker.\n */\n public get packId(): string | null {\n return this[kData].pack_id ?? null;\n }\n\n /**\n * The position of a standard sticker in its pack.\n */\n public get sortValue(): number | null {\n return this[kData].sort_value ?? null;\n }\n\n /**\n * The user who uploaded a guild sticker, when the payload includes it (it needs `ManageGuildExpressions`).\n */\n public get user(): User | null {\n const { user } = this[kData];\n return this[kRelations].user ?? (user ? new User(user) : null);\n }\n\n public override get createdTimestamp(): number {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n\n /**\n * The URL of the sticker's image: a GIF for GIF stickers, a JSON file for Lottie ones, a PNG otherwise.\n */\n public get url(): string {\n const extension: StickerExtension =\n this.formatType === StickerFormatType.GIF\n ? \"gif\"\n : this.formatType === StickerFormatType.Lottie\n ? \"json\"\n : \"png\";\n return cdn.sticker(this.id, extension);\n }\n\n /**\n * Fetches the sticker from the API and patches this structure with the result.\n */\n public async fetch(): Promise<this> {\n const sticker = await this.client.fetchSticker(this.id);\n return this[kPatch](sticker.toJSON());\n }\n\n /**\n * Fetches the pack of a standard sticker, `null` for a guild sticker.\n */\n public async fetchPack(): Promise<StickerPack | null> {\n const { packId } = this;\n if (!packId) return null;\n const packs = await this.client.fetchStickerPacks();\n return packs.find((pack) => pack.id === packId) ?? null;\n }\n\n /**\n * Fetches the user who uploaded a guild sticker, `null` for a standard one or without `ManageGuildExpressions`.\n */\n public async fetchUser(): Promise<User | null> {\n const { guildId } = this;\n if (!guildId) return null;\n return this.client.guilds.stickers(guildId).fetchUser(this.id);\n }\n\n /**\n * Edits a guild sticker.\n *\n * @param options The changes to apply.\n */\n public async edit(options: GuildStickerEditOptions): Promise<this> {\n const sticker = await this.client.guilds.stickers(this.requireGuildId()).edit(this.id, options);\n return this[kPatch](sticker.toJSON());\n }\n\n /**\n * Deletes a guild sticker.\n *\n * @param reason The reason for the audit log.\n */\n public async delete(reason?: string): Promise<this> {\n await this.client.guilds.stickers(this.requireGuildId()).delete(this.id, reason);\n return this;\n }\n\n /**\n * Whether this sticker has the same data as another one.\n * @param sticker The sticker to compare with.\n */\n public equals(sticker: Sticker): boolean {\n return (\n this.id === sticker.id &&\n this.name === sticker.name &&\n this.description === sticker.description &&\n this.tags === sticker.tags &&\n this.formatType === sticker.formatType &&\n this.available === sticker.available &&\n this.guildId === sticker.guildId\n );\n }\n\n private requireGuildId(): string {\n const { guildId } = this;\n if (!guildId) throw new Error(\"Only guild stickers can be edited or deleted\");\n return guildId;\n }\n}\n\nMixin(Sticker, [StructureMixin]);\n","import type { GatewayClient } from \"../../GatewayClient.js\";\nimport type { Message } from \"../messages/Message.js\";\nimport {\n MessagePayload,\n type MessagePayloadResolvable,\n type WebhookMessageCreateOptions,\n type WebhookMessageEditOptions,\n type WebhookThreadOptions,\n} from \"../messages/MessagePayload.js\";\nimport { snowflakeTimestamp } from \"../Structure.js\";\n\n/**\n * What {@link WebhookMixin} needs from the class it is mixed into.\n */\nexport interface WebhookMixin {\n readonly id: string;\n readonly token: string | null | undefined;\n readonly client: GatewayClient;\n}\n\n/**\n * The members shared by everything posting through a webhook's token, like discord.js's `Webhook.applyToClass`.\n *\n * @remarks\n * Every method calls the API with the webhook's token rather than with the bot's authorization, so they work for\n * webhooks of other applications too.\n */\nexport class WebhookMixin {\n /**\n * The URL to post to, built from the webhook's ID and token.\n */\n public get url(): string | undefined {\n const { token } = this;\n return token ? `https://discord.com/api/webhooks/${this.id}/${token}` : undefined;\n }\n\n public get createdTimestamp(): number {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt(): Date {\n return new Date(this.createdTimestamp);\n }\n\n /**\n * Sends a message through the webhook.\n *\n * @param options The message, its content, or a {@link MessagePayload}, and the thread to send it in.\n */\n public send(options: MessagePayloadResolvable<WebhookMessageCreateOptions>): Promise<Message> {\n return this.client.webhooks.send(\n this.id,\n this.requireToken(),\n MessagePayload.create(this, options, { webhook: true }),\n );\n }\n\n /**\n * Sends a Slack-compatible message through the webhook.\n *\n * @param body The Slack message.\n * @param options The thread to send it in.\n */\n public async sendSlackMessage(body: unknown, options: WebhookThreadOptions = {}): Promise<void> {\n await this.client.api.webhooks.executeSlack(this.id, this.requireToken(), body, {\n thread_id: options.threadId,\n });\n }\n\n /**\n * Fetches a message sent by the webhook.\n *\n * @param messageId The ID of the message.\n * @param options The thread the message is in.\n */\n public fetchMessage(messageId: string, options?: WebhookThreadOptions): Promise<Message> {\n return this.client.webhooks.fetchMessage(this.id, this.requireToken(), messageId, options);\n }\n\n /**\n * Edits a message sent by the webhook.\n *\n * @param messageId The ID of the message.\n * @param options The changes, the new content, or a {@link MessagePayload}, and the thread the message is in.\n */\n public editMessage(\n messageId: string,\n options: MessagePayloadResolvable<WebhookMessageEditOptions>,\n ): Promise<Message> {\n return this.client.webhooks.editMessage(\n this.id,\n this.requireToken(),\n messageId,\n MessagePayload.create(this, options, { webhook: true, edit: true }),\n );\n }\n\n /**\n * Deletes a message sent by the webhook.\n *\n * @param messageId The ID of the message.\n * @param options The thread the message is in.\n */\n public deleteMessage(messageId: string, options?: WebhookThreadOptions): Promise<void> {\n return this.client.webhooks.deleteMessage(this.id, this.requireToken(), messageId, options);\n }\n\n /**\n * Gets the webhook's token, throwing when it has none.\n *\n * @internal\n */\n public requireToken(): string {\n const { token } = this;\n if (!token) throw new Error(`Webhook ${this.id} has no token to post with`);\n return token;\n }\n}\n","import type { ImageURLOptions } from \"@discordjs/rest\";\nimport { Webhook as BaseWebhook } from \"@discordjs/structures\";\nimport { WebhookType, type APIWebhook } from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { WebhookEditOptions } from \"../../managers/WebhookManager.js\";\nimport { cdn } from \"../../util/cdn.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport {\n initStructure,\n kData,\n kPatch,\n kRelations,\n snowflakeTimestamp,\n StructureMixin,\n} from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\nimport { WebhookMixin } from \"./WebhookMixin.js\";\n\n/**\n * The relations of a {@link Webhook}, resolved from the cache by `client.webhooks`.\n */\nexport interface WebhookRelations {\n guild?: Guild | null;\n channel?: AnyChannel | null;\n sourceGuild?: Guild | null;\n sourceChannel?: AnyChannel | null;\n owner?: User;\n}\n\nexport interface Webhook\n extends StructureMixin<APIWebhook, WebhookRelations>, MixinTypes<BaseWebhook, [WebhookMixin]> {}\n\n/**\n * A webhook, an incoming one posting to a channel, a channel follower, or an application's: `@discordjs/structures`'\n * `Webhook`, with its owner, source, and URLs, and actions through the client.\n *\n * @remarks\n * `token` is only set for incoming webhooks, and only their creator (or the guild's managers) see it.\n */\nexport class Webhook extends BaseWebhook {\n /**\n * @param data The raw webhook.\n * @param relations The related structures, resolved from the cache.\n */\n public constructor(data: APIWebhook, relations: object = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n declare public [kRelations]: WebhookRelations;\n\n public override get guildId(): string | null {\n return this[kData].guild_id ?? null;\n }\n\n /**\n * The guild of the webhook, from the cache, like discord.js's `Webhook#guild`: `null` when it is not cached.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * The channel the webhook posts to, from the cache: `null` when it is not cached.\n */\n public get channel(): AnyChannel | null {\n return this[kRelations].channel ?? null;\n }\n\n /**\n * The user who created the webhook, from the cache, else from the payload.\n */\n public get owner(): User | null {\n const { user } = this[kData];\n return this[kRelations].owner ?? (user ? new User(user) : null);\n }\n\n /**\n * The guild a channel follower webhook posts from: the cached guild, else the partial one of the payload.\n */\n public get sourceGuild(): Guild | NonNullable<APIWebhook[\"source_guild\"]> | null {\n return this[kRelations].sourceGuild ?? this[kData].source_guild ?? null;\n }\n\n /**\n * The channel a channel follower webhook posts from: the cached channel, else the partial one of the payload.\n */\n public get sourceChannel(): AnyChannel | NonNullable<APIWebhook[\"source_channel\"]> | null {\n return this[kRelations].sourceChannel ?? this[kData].source_channel ?? null;\n }\n\n /**\n * The URL to post to, for webhooks with a token: the one Discord sent, or one built from the token.\n */\n public override get url(): string | undefined {\n const { token } = this;\n return (\n this[kData].url ??\n (token ? `https://discord.com/api/webhooks/${this.id}/${token}` : undefined)\n );\n }\n\n public override get createdTimestamp(): number {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n\n public avatarURL(options?: Readonly<ImageURLOptions>): string | null {\n const { avatar } = this;\n return avatar ? cdn.avatar(this.id, avatar, options) : null;\n }\n\n public isIncoming(): boolean {\n return this.type === WebhookType.Incoming;\n }\n\n public isChannelFollower(): boolean {\n return this.type === WebhookType.ChannelFollower;\n }\n\n public isApplicationCreated(): boolean {\n return this.type === WebhookType.Application;\n }\n\n /**\n * Edits the webhook, with its token when it has one (then it cannot be moved to another channel).\n *\n * @param options The fields to edit, and the reason for the audit log.\n */\n public async edit(options: WebhookEditOptions): Promise<this> {\n const token = options.channel === undefined ? this.token : undefined;\n const webhook = await this.client.webhooks.edit(this.id, options, token);\n return this[kPatch](webhook.toJSON());\n }\n\n /**\n * Deletes the webhook.\n *\n * @param reason The reason for the audit log.\n */\n public async delete(reason?: string): Promise<this> {\n await this.client.webhooks.delete(this.id, { token: this.token, reason });\n return this;\n }\n}\n\nMixin(Webhook, [StructureMixin, WebhookMixin]);\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n AuditLogEvent,\n type APIApplicationCommand,\n type APIAuditLogChange,\n type APIWebhook,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport type { AnyChannel } from \"../managers/ChannelManager.js\";\nimport { AutoModerationRule } from \"../structures/automoderation/AutoModerationRule.js\";\nimport type { GuildEmoji } from \"../structures/emojis/GuildEmoji.js\";\nimport type { Guild } from \"../structures/guilds/Guild.js\";\nimport { GuildOnboardingPrompt } from \"../structures/guilds/GuildOnboarding.js\";\nimport { GuildScheduledEvent } from \"../structures/guilds/GuildScheduledEvent.js\";\nimport { Integration } from \"../structures/guilds/Integration.js\";\nimport type { Role } from \"../structures/guilds/Role.js\";\nimport { GuildInvite } from \"../structures/invites/GuildInvite.js\";\nimport type { SoundboardSound } from \"../structures/soundboards/SoundboardSound.js\";\nimport { StageInstance } from \"../structures/stageInstances/StageInstance.js\";\nimport { Sticker } from \"../structures/stickers/Sticker.js\";\nimport { bindClient } from \"../structures/Structure.js\";\nimport type { User } from \"../structures/users/User.js\";\nimport { Webhook } from \"../structures/webhooks/Webhook.js\";\n\n/**\n * The kind of entity an audit log entry targets, like discord.js's `GuildAuditLogs.Targets`.\n */\nexport type AuditLogTargetType =\n | \"ApplicationCommand\"\n | \"AutoModeration\"\n | \"Channel\"\n | \"Emoji\"\n | \"Guild\"\n | \"GuildOnboardingPrompt\"\n | \"GuildScheduledEvent\"\n | \"Integration\"\n | \"Invite\"\n | \"Message\"\n | \"Role\"\n | \"SoundboardSound\"\n | \"StageInstance\"\n | \"Sticker\"\n | \"Thread\"\n | \"Unknown\"\n | \"User\"\n | \"Webhook\";\n\n/**\n * The entity an audit log entry targets, like discord.js's `AuditLogEntryTarget`: the cached structure, else a\n * structure (or an object) built from the entry's changes, at least holding the target's ID.\n */\nexport type AuditLogEntryTarget =\n | AnyChannel\n | APIApplicationCommand\n | AutoModerationRule\n | Guild\n | GuildEmoji\n | GuildInvite\n | GuildOnboardingPrompt\n | GuildScheduledEvent\n | Integration\n | Role\n | SoundboardSound\n | StageInstance\n | Sticker\n | User\n | Webhook\n | AuditLogPartialTarget;\n\n/**\n * A target known only by the entry: its ID, and the fields the entry changed.\n */\ninterface AuditLogPartialTarget {\n id: string | null;\n [key: string]: unknown;\n}\n\n/**\n * The entities of an audit log page, which the targets are looked up in before the cache.\n *\n * @internal\n */\nexport interface AuditLogEntities {\n users?: ReadonlyMap<string, User>;\n webhooks?: ReadonlyMap<string, Webhook>;\n integrations?: ReadonlyMap<string, Integration>;\n applicationCommands?: ReadonlyMap<string, APIApplicationCommand>;\n}\n\n/**\n * Gets the kind of entity an audit log action targets, like discord.js's `GuildAuditLogsEntry.targetType`.\n *\n * @param action The action.\n */\nexport function auditLogTargetType(action: AuditLogEvent): AuditLogTargetType {\n if (action < 10) return \"Guild\";\n if (action < 20) return \"Channel\";\n if (action < 30) return \"User\";\n if (action < 40) return \"Role\";\n if (action < 50) return \"Invite\";\n if (action < 60) return \"Webhook\";\n if (action < 70) return \"Emoji\";\n if (action < 80) return \"Message\";\n if (action < 83) return \"Integration\";\n if (action < 86) return \"StageInstance\";\n if (action < 100) return \"Sticker\";\n if (action < 110) return \"GuildScheduledEvent\";\n if (action < 120) return \"Thread\";\n if (action < 130) return \"ApplicationCommand\";\n if (action < 140) return \"SoundboardSound\";\n if (action < 143) return \"AutoModeration\";\n if (action < 146) return \"User\";\n if (action >= 163 && action <= 165) return \"GuildOnboardingPrompt\";\n return \"Unknown\";\n}\n\n/**\n * Folds the changes of an entry into the target's data, their new value else their old one, like discord.js.\n */\nfunction changesReduce(\n changes: readonly APIAuditLogChange[] | undefined,\n initial: Record<string, unknown> = {},\n): AuditLogPartialTarget {\n const data: AuditLogPartialTarget = { id: null, ...initial };\n for (const change of changes ?? []) {\n const {\n key,\n new_value: newValue,\n old_value: oldValue,\n } = change as {\n key: string;\n new_value?: unknown;\n old_value?: unknown;\n };\n data[key] = newValue ?? oldValue;\n }\n\n return data;\n}\n\n// A cache read that never rejects, so a failing cache degrades to the fallback target.\nasync function read<Value>(value: Promise<Value | undefined>): Promise<Value | undefined> {\n return value.catch(() => undefined);\n}\n\n/**\n * Resolves the target of an audit log entry from the cache, like discord.js's `GuildAuditLogsEntry#target`.\n *\n * @param client The client.\n * @param entry The raw entry, with its guild's ID.\n * @param entities The entities of the audit log page the entry comes from, if any.\n * @returns The target, `null` for user targets that are not cached (like discord.js without the `User` partial) and\n * for entries without a target.\n * @internal\n */\nexport async function resolveAuditLogTarget(\n client: GatewayClient,\n entry: CacheEntityTypes[\"auditLogEntries\"],\n entities: AuditLogEntities = {},\n): Promise<AuditLogEntryTarget | null> {\n const { guild_id: guildId, target_id: targetId, changes, options } = entry;\n const type = auditLogTargetType(entry.action_type);\n const { guilds } = client;\n const built = <Value extends object>(value: Value) => bindClient(value, client);\n\n if (type === \"Unknown\") return changesReduce(changes, { id: targetId });\n const user = async (userId: string) =>\n entities.users?.get(userId) ?? (await read(client.users.get(userId))) ?? null;\n if (type === \"User\") return targetId ? user(targetId) : null;\n if (!targetId && type !== \"Invite\") return null;\n const id = targetId!;\n\n switch (type) {\n case \"Guild\":\n return (await read(guilds.get(id))) ?? { id };\n case \"Channel\":\n case \"Thread\":\n return (await read(client.channels.get(id))) ?? changesReduce(changes, { id });\n case \"Role\":\n return (await read(client.roles.get(guildId, id))) ?? { id };\n case \"Invite\": {\n const { id: _id, ...changed } = changesReduce(changes);\n const code = changed.code as string | undefined;\n const cached = code ? await read(guilds.invites(guildId).get(code)) : undefined;\n return cached ?? built(new GuildInvite({ ...changed, code: code ?? \"\", guild_id: guildId }));\n }\n case \"Webhook\":\n return (\n entities.webhooks?.get(id) ??\n built(\n new Webhook(changesReduce(changes, { id, guild_id: guildId }) as unknown as APIWebhook),\n )\n );\n case \"Emoji\":\n return (await read(guilds.emojis(guildId).get(id))) ?? { id };\n case \"Message\":\n // Discord sends the channel's ID for bulk deletions, the author's otherwise.\n return entry.action_type === AuditLogEvent.MessageBulkDelete\n ? ((await read(client.channels.get(id))) ?? { id })\n : user(id);\n case \"Integration\":\n return (\n entities.integrations?.get(id) ??\n (await read(guilds.integrations(guildId).get(id))) ??\n built(new Integration(changesReduce(changes, { id, guild_id: guildId }) as never))\n );\n case \"StageInstance\": {\n const channelId = options?.channel_id;\n const cached = channelId\n ? await read(guilds.stageInstances(guildId).get(channelId))\n : undefined;\n return (\n cached ??\n built(\n new StageInstance(\n changesReduce(changes, { id, channel_id: channelId, guild_id: guildId }) as never,\n ),\n )\n );\n }\n case \"Sticker\":\n return (\n (await read(guilds.stickers(guildId).get(id))) ??\n built(new Sticker(changesReduce(changes, { id }) as never))\n );\n case \"GuildScheduledEvent\":\n return (\n (await read(guilds.scheduledEvents(guildId).get(id))) ??\n built(new GuildScheduledEvent(changesReduce(changes, { id, guild_id: guildId }) as never))\n );\n case \"ApplicationCommand\":\n return entities.applicationCommands?.get(id) ?? { id };\n case \"SoundboardSound\":\n return (await read(guilds.soundboardSounds(guildId).get(id))) ?? { id };\n case \"AutoModeration\":\n return (\n (await read(guilds.autoModerationRules(guildId).get(id))) ??\n built(new AutoModerationRule(changesReduce(changes, { id, guild_id: guildId }) as never))\n );\n case \"GuildOnboardingPrompt\":\n return entry.action_type === AuditLogEvent.OnboardingPromptCreate\n ? built(new GuildOnboardingPrompt(changesReduce(changes, { id }) as never))\n : changesReduce(changes, { id });\n default:\n return { id };\n }\n}\n","import type { GatewayClient } from \"../GatewayClient.js\";\nimport type { GuildEmoji } from \"../structures/emojis/GuildEmoji.js\";\nimport type { Role } from \"../structures/guilds/Role.js\";\n\n/**\n * Manages the roles allowed to use one custom emoji. When it has none, everyone can use it.\n */\nexport class GuildEmojiRoleManager {\n public readonly client: GatewayClient;\n public readonly guildId: string;\n public readonly emojiId: string;\n\n readonly #roleIds: readonly string[];\n\n public constructor(\n client: GatewayClient,\n guildId: string,\n emojiId: string,\n roleIds: readonly string[],\n ) {\n this.client = client;\n this.guildId = guildId;\n this.emojiId = emojiId;\n this.#roleIds = roleIds;\n }\n\n /**\n * The IDs of the allowed roles.\n */\n public get ids(): readonly string[] {\n return this.#roleIds;\n }\n\n /**\n * Fetches the allowed roles, cache first.\n */\n public fetch(): Promise<Role[]> {\n return Promise.all(this.#roleIds.map((id) => this.client.roles.fetch(this.guildId, id)));\n }\n\n /**\n * Allows more roles to use the emoji.\n *\n * @param roles The ID of the role, or several IDs.\n */\n public add(roles: string | readonly string[]): Promise<GuildEmoji> {\n const added = typeof roles === \"string\" ? [roles] : roles;\n return this.set([...new Set([...this.#roleIds, ...added])]);\n }\n\n /**\n * Stops allowing roles to use the emoji.\n *\n * @param roles The ID of the role, or several IDs.\n */\n public remove(roles: string | readonly string[]): Promise<GuildEmoji> {\n const removed = new Set(typeof roles === \"string\" ? [roles] : roles);\n return this.set(this.#roleIds.filter((id) => !removed.has(id)));\n }\n\n /**\n * Replaces the allowed roles, everyone when empty.\n *\n * @param roles The IDs of the roles.\n */\n public set(roles: readonly string[]): Promise<GuildEmoji> {\n return this.client.guilds.emojis(this.guildId).edit(this.emojiId, { roles });\n }\n}\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { GuildEmojiEditOptions } from \"../../managers/GuildEmojiManager.js\";\nimport { GuildEmojiRoleManager } from \"../../managers/GuildEmojiRoleManager.js\";\nimport { Emoji } from \"./Emoji.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport { kData, kPatch, kRelations } from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\n/**\n * The relations of a {@link GuildEmoji}, resolved from the cache by the guild's emoji manager.\n */\nexport interface GuildEmojiRelations {\n author?: User;\n guild?: Guild | null;\n}\n\n/**\n * A custom emoji of a guild.\n */\nexport class GuildEmoji extends Emoji<CacheEntityTypes[\"emojis\"], GuildEmojiRelations> {\n /**\n * @param data The raw emoji.\n * @param relations The uploader and guild as resolved from the cache, by the guild's emoji manager.\n */\n public constructor(data: CacheEntityTypes[\"emojis\"], relations: GuildEmojiRelations = {}) {\n super(data, relations);\n }\n\n public override [kPatch](data: Readonly<Partial<CacheEntityTypes[\"emojis\"]>>): this {\n if (data.user) this.dropRelations(\"author\");\n return super[kPatch](data);\n }\n\n public override get id(): string {\n return this[kData].id!;\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n /**\n * The guild, from the cache. `null` when the guild is not cached, or when the emoji was not built by a manager: use\n * `fetchGuild()` to always get it.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * Fetches the guild, cache first.\n */\n public fetchGuild(): Promise<Guild> {\n return this.client.guilds.fetch(this.guildId);\n }\n\n /**\n * Whether the emoji is managed by an integration, e.g. Twitch.\n */\n public override get managed(): boolean {\n return this[kData].managed ?? false;\n }\n\n public get requiresColons(): boolean {\n return this[kData].require_colons ?? true;\n }\n\n /**\n * Whether the emoji can be used, `false` when the guild lost the boosts it needs.\n */\n public override get available(): boolean {\n return this[kData].available ?? true;\n }\n\n /**\n * The IDs of the roles allowed to use the emoji, everyone when empty.\n */\n public get roleIds(): readonly string[] {\n return this[kData].roles ?? [];\n }\n\n /**\n * The roles allowed to use the emoji.\n */\n public get roles(): GuildEmojiRoleManager {\n return new GuildEmojiRoleManager(this.client, this.guildId, this.id, this.roleIds);\n }\n\n /**\n * The user who uploaded the emoji, when the payload includes it (it needs `ManageGuildExpressions`).\n */\n public get author(): User | null {\n const { user } = this[kData];\n return this[kRelations].author ?? (user ? new User(user) : null);\n }\n\n /**\n * Whether the bot can delete the emoji: it is not managed, and the bot has `ManageGuildExpressions`.\n */\n public async fetchDeletable(): Promise<boolean> {\n if (this.managed) return false;\n const me = await this.client.members.fetchMe(this.guildId);\n return (await me.fetchPermissions()).has(\"ManageGuildExpressions\");\n }\n\n /**\n * Fetches the user who uploaded the emoji.\n */\n public fetchAuthor(): Promise<User | null> {\n return this.client.guilds.emojis(this.guildId).fetchAuthor(this.id);\n }\n\n public async edit(options: GuildEmojiEditOptions): Promise<this> {\n const emoji = await this.client.guilds.emojis(this.guildId).edit(this.id, options);\n return this[kPatch](emoji.toJSON());\n }\n\n public setName(name: string, reason?: string): Promise<this> {\n return this.edit({ name, reason });\n }\n\n public async delete(reason?: string): Promise<this> {\n await this.client.guilds.emojis(this.guildId).delete(this.id, reason);\n return this;\n }\n\n /**\n * Whether this emoji has the same data as another one.\n * @param emoji The emoji to compare with.\n */\n public equals(emoji: GuildEmoji): boolean {\n return (\n this.id === emoji.id &&\n this.name === emoji.name &&\n this.managed === emoji.managed &&\n this.available === emoji.available &&\n this.requiresColons === emoji.requiresColons &&\n this.roleIds.length === emoji.roleIds.length &&\n this.roleIds.every((id) => emoji.roleIds.includes(id))\n );\n }\n}\n","import type { BaseImageURLOptions, ImageURLOptions } from \"@discordjs/rest\";\nimport type { APIGuildPreview } from \"discord-api-types/v10\";\nimport { cdn } from \"../../util/cdn.js\";\nimport { GuildEmoji } from \"../emojis/GuildEmoji.js\";\nimport { Sticker } from \"../stickers/Sticker.js\";\nimport { kData, snowflakeTimestamp, Structure } from \"../Structure.js\";\n\n/**\n * The public preview of a guild, available for discoverable guilds and the ones the bot is in.\n */\nexport class GuildPreview extends Structure<APIGuildPreview> {\n public get id() {\n return this[kData].id;\n }\n\n public get name() {\n return this[kData].name;\n }\n\n public get icon() {\n return this[kData].icon;\n }\n\n public get splash() {\n return this[kData].splash;\n }\n\n public get discoverySplash() {\n return this[kData].discovery_splash;\n }\n\n public get description() {\n return this[kData].description;\n }\n\n public get features() {\n return this[kData].features;\n }\n\n public get approximateMemberCount() {\n return this[kData].approximate_member_count;\n }\n\n public get approximatePresenceCount() {\n return this[kData].approximate_presence_count;\n }\n\n public get emojis(): GuildEmoji[] {\n return this[kData].emojis.map((emoji) => new GuildEmoji({ ...emoji, guild_id: this.id }));\n }\n\n public get stickers(): Sticker[] {\n return this[kData].stickers.map((sticker) => new Sticker(sticker));\n }\n\n public get createdTimestamp() {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n\n public iconURL(options?: ImageURLOptions): string | null {\n const { icon } = this;\n return icon ? cdn.icon(this.id, icon, options) : null;\n }\n\n public splashURL(options?: BaseImageURLOptions): string | null {\n const { splash } = this;\n return splash ? cdn.splash(this.id, splash, options) : null;\n }\n\n public discoverySplashURL(options?: BaseImageURLOptions): string | null {\n const { discoverySplash } = this;\n return discoverySplash ? cdn.discoverySplash(this.id, discoverySplash, options) : null;\n }\n\n public toString(): string {\n return this.name;\n }\n}\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport { AuditLogEvent, type APIAuditLogChange } from \"discord-api-types/v10\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kRelations, snowflakeTimestamp, Structure } from \"../Structure.js\";\nimport type { User } from \"../users/User.js\";\nimport {\n auditLogTargetType,\n type AuditLogEntryTarget,\n type AuditLogTargetType,\n} from \"../../util/auditLogs.js\";\n\n/**\n * Whether an audit log action created, deleted, or updated something, like discord.js's `actionType`.\n */\nexport type AuditLogActionType = \"Create\" | \"Delete\" | \"Update\";\n\nconst CreateActions = new Set<AuditLogEvent>([\n AuditLogEvent.ChannelCreate,\n AuditLogEvent.ChannelOverwriteCreate,\n AuditLogEvent.MemberBanRemove,\n AuditLogEvent.BotAdd,\n AuditLogEvent.RoleCreate,\n AuditLogEvent.InviteCreate,\n AuditLogEvent.WebhookCreate,\n AuditLogEvent.EmojiCreate,\n AuditLogEvent.MessagePin,\n AuditLogEvent.IntegrationCreate,\n AuditLogEvent.StageInstanceCreate,\n AuditLogEvent.StickerCreate,\n AuditLogEvent.GuildScheduledEventCreate,\n AuditLogEvent.ThreadCreate,\n AuditLogEvent.SoundboardSoundCreate,\n AuditLogEvent.AutoModerationRuleCreate,\n AuditLogEvent.OnboardingPromptCreate,\n]);\n\nconst DeleteActions = new Set<AuditLogEvent>([\n AuditLogEvent.ChannelDelete,\n AuditLogEvent.ChannelOverwriteDelete,\n AuditLogEvent.MemberKick,\n AuditLogEvent.MemberPrune,\n AuditLogEvent.MemberBanAdd,\n AuditLogEvent.MemberDisconnect,\n AuditLogEvent.RoleDelete,\n AuditLogEvent.InviteDelete,\n AuditLogEvent.WebhookDelete,\n AuditLogEvent.EmojiDelete,\n AuditLogEvent.MessageDelete,\n AuditLogEvent.MessageBulkDelete,\n AuditLogEvent.MessageUnpin,\n AuditLogEvent.IntegrationDelete,\n AuditLogEvent.StageInstanceDelete,\n AuditLogEvent.StickerDelete,\n AuditLogEvent.GuildScheduledEventDelete,\n AuditLogEvent.ThreadDelete,\n AuditLogEvent.SoundboardSoundDelete,\n AuditLogEvent.AutoModerationRuleDelete,\n AuditLogEvent.OnboardingPromptDelete,\n]);\n\n/**\n * The relations of a {@link GuildAuditLogsEntry}: the users of the audit log page, or of the cache.\n */\nexport interface GuildAuditLogsEntryRelations {\n executor?: User | null;\n guild?: Guild | null;\n /**\n * The entity the entry targets, see {@link GuildAuditLogsEntry.target}.\n */\n target?: AuditLogEntryTarget | null;\n}\n\n/**\n * An entry of a guild's audit log.\n */\nexport class GuildAuditLogsEntry extends Structure<CacheEntityTypes[\"auditLogEntries\"]> {\n declare public [kRelations]: GuildAuditLogsEntryRelations;\n\n /**\n * @param data The raw entry, with its guild's ID.\n * @param relations The executor and guild, resolved by `guild.fetchAuditLogs()` or the event.\n */\n public constructor(\n data: CacheEntityTypes[\"auditLogEntries\"],\n relations: GuildAuditLogsEntryRelations = {},\n ) {\n super(data, relations);\n }\n\n public get id() {\n return this[kData].id;\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n public get action(): AuditLogEvent {\n return this[kData].action_type;\n }\n\n public get actionType(): AuditLogActionType {\n if (CreateActions.has(this.action)) return \"Create\";\n if (DeleteActions.has(this.action)) return \"Delete\";\n return \"Update\";\n }\n\n /**\n * The ID of the user or application that made the change.\n */\n public get executorId(): string | null {\n return this[kData].user_id;\n }\n\n /**\n * The ID of the affected entity: a user, role, channel, webhook, ...\n */\n public get targetId(): string | null {\n return this[kData].target_id;\n }\n\n /**\n * The kind of entity the entry targets, like discord.js's `GuildAuditLogsEntry#targetType`.\n */\n public get targetType(): AuditLogTargetType {\n return auditLogTargetType(this.action);\n }\n\n /**\n * The entity the entry targets, like discord.js's `GuildAuditLogsEntry#target`: the cached structure, else one (or\n * an object) built from the entry's changes, holding at least the target's ID. `null` for users that are not\n * cached, and for entries without a target. Without a manager, only `{ id }`.\n */\n public get target(): AuditLogEntryTarget | null {\n const resolved = this[kRelations].target;\n if (resolved !== undefined) return resolved;\n const { targetId } = this;\n return targetId ? { id: targetId } : null;\n }\n\n public get reason(): string | null {\n return this[kData].reason ?? null;\n }\n\n /**\n * The changed fields, with their old and new values.\n */\n public get changes(): readonly APIAuditLogChange[] {\n return this[kData].changes ?? [];\n }\n\n /**\n * The extra details of some actions, e.g. the channel of a message deletion.\n */\n public get extra() {\n return this[kData].options ?? null;\n }\n\n public get executor(): User | null {\n return this[kRelations].executor ?? null;\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n public get createdTimestamp() {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n}\n","import { GuildFeature, type APIGuildWelcomeScreen } from \"discord-api-types/v10\";\nimport type { GuildWelcomeScreenEditOptions } from \"../../managers/GuildManager.js\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { GuildEmoji } from \"../emojis/GuildEmoji.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { ReactionEmoji } from \"../emojis/ReactionEmoji.js\";\nimport { kData, kPatch, kRelations, Structure } from \"../Structure.js\";\n\n/**\n * The raw data of a welcome screen, with the ID of its guild.\n */\nexport type WelcomeScreenData = APIGuildWelcomeScreen & { guild_id: string };\n\n/**\n * A channel suggested by a welcome screen.\n */\nexport interface WelcomeChannel {\n channelId: string;\n /**\n * The channel, from the cache, like discord.js's `WelcomeChannel#channel`: `null` when it is not cached, or when\n * the welcome screen was not built by `client.guilds`.\n */\n channel: AnyChannel | null;\n description: string;\n /**\n * The emoji shown next to the channel, if any: the cached custom emoji of the guild, else the payload's.\n */\n emoji: GuildEmoji | ReactionEmoji | null;\n}\n\n/**\n * The relations of a {@link WelcomeScreen}: its guild, and the channels and emojis of its welcome channels, when\n * cached.\n */\nexport interface WelcomeScreenRelations {\n guild?: Guild | null;\n /**\n * The cached channels of the welcome channels, by ID.\n */\n channels?: ReadonlyMap<string, AnyChannel>;\n /**\n * The cached custom emojis of the welcome channels, by ID.\n */\n emojis?: ReadonlyMap<string, GuildEmoji>;\n}\n\n/**\n * The screen new members of a community guild see, suggesting channels to start with.\n */\nexport class WelcomeScreen extends Structure<WelcomeScreenData> {\n declare public [kRelations]: WelcomeScreenRelations;\n\n /**\n * @param data The raw welcome screen.\n * @param relations The guild, as resolved from the cache.\n */\n public constructor(data: WelcomeScreenData, relations: WelcomeScreenRelations = {}) {\n super(data, relations);\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n public get description() {\n return this[kData].description;\n }\n\n public get welcomeChannels(): WelcomeChannel[] {\n const { channels, emojis } = this[kRelations];\n return this[kData].welcome_channels.map((channel) => ({\n channelId: channel.channel_id,\n channel: channels?.get(channel.channel_id) ?? null,\n description: channel.description,\n emoji:\n (channel.emoji_id && emojis?.get(channel.emoji_id)) ||\n (channel.emoji_id || channel.emoji_name\n ? new ReactionEmoji({ id: channel.emoji_id, name: channel.emoji_name })\n : null),\n }));\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * Whether the welcome screen is shown, from the features of the cached guild; `null` when it is not cached.\n */\n public get enabled(): boolean | null {\n return this.guild?.features.includes(GuildFeature.WelcomeScreenEnabled) ?? null;\n }\n\n /**\n * Edits the welcome screen.\n *\n * @param options The changes to apply.\n */\n public async edit(options: GuildWelcomeScreenEditOptions): Promise<this> {\n const screen = await this.client.guilds.editWelcomeScreen(this.guildId, options);\n return this[kPatch](screen.toJSON());\n }\n}\n","import {\n autoModerationRuleKey,\n type Awaitable,\n type CacheEntityTypes,\n} from \"@wolfstar/plugin-cache\";\nimport {\n type APIAutoModerationAction,\n type APIAutoModerationRuleTriggerMetadata,\n type AutoModerationRuleEventType,\n type AutoModerationRuleTriggerType,\n type RESTPatchAPIAutoModerationRuleJSONBody,\n type RESTPostAPIAutoModerationRuleJSONBody,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { AutoModerationRule } from \"../structures/automoderation/AutoModerationRule.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { resolveId, type IdResolvable } from \"../util/channels.js\";\nimport { CachedManager } from \"./CachedManager.js\";\n\n/**\n * The fields of an auto moderation rule that can be edited.\n */\nexport interface AutoModerationRuleEditOptions {\n name?: string;\n eventType?: AutoModerationRuleEventType;\n /**\n * The trigger's settings. Discord replaces them as a whole.\n */\n triggerMetadata?: APIAutoModerationRuleTriggerMetadata;\n actions?: readonly APIAutoModerationAction[];\n enabled?: boolean;\n exemptRoles?: readonly IdResolvable[];\n exemptChannels?: readonly IdResolvable[];\n reason?: string;\n}\n\n/**\n * The options to create an auto moderation rule with.\n */\nexport interface AutoModerationRuleCreateOptions extends AutoModerationRuleEditOptions {\n name: string;\n eventType: AutoModerationRuleEventType;\n triggerType: AutoModerationRuleTriggerType;\n actions: readonly APIAutoModerationAction[];\n}\n\n/**\n * Manages the auto moderation rules of one guild.\n */\nexport class AutoModerationRuleManager extends CachedManager<\n \"autoModerationRules\",\n AutoModerationRule,\n [ruleId: string]\n> {\n public readonly guildId: string;\n\n public constructor(client: GatewayClient, guildId: string) {\n super(client, \"autoModerationRules\");\n this.guildId = guildId;\n }\n\n public createStructure(data: CacheEntityTypes[\"autoModerationRules\"]): AutoModerationRule {\n return new AutoModerationRule(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"autoModerationRules\"]): string {\n return this.resolveKey(data.id);\n }\n\n public resolveKey(ruleId: string): string {\n return autoModerationRuleKey(this.guildId, ruleId);\n }\n\n public override _hydrate(\n data: CacheEntityTypes[\"autoModerationRules\"],\n ): Awaitable<AutoModerationRule> {\n return whenAll(\n [this.cachedGuild(data.guild_id)],\n ([guild]) => new AutoModerationRule(data, { guild }),\n );\n }\n\n /**\n * Fetches every rule of the guild, and caches them.\n */\n public async fetchAll(): Promise<AutoModerationRule[]> {\n const rules = await this.client.api.guilds.getAutoModerationRules(this.guildId);\n return Promise.all(rules.map((rule) => this._add(rule)));\n }\n\n /**\n * Creates a rule.\n *\n * @param options The rule's name, trigger, actions, and exemptions.\n */\n public async create(options: AutoModerationRuleCreateOptions): Promise<AutoModerationRule> {\n const body: RESTPostAPIAutoModerationRuleJSONBody = {\n ...toRuleBody(options),\n name: options.name,\n event_type: options.eventType,\n trigger_type: options.triggerType,\n actions: [...options.actions],\n };\n const rule = await this.client.api.guilds.createAutoModerationRule(this.guildId, body, {\n reason: options.reason,\n });\n return this._add(rule);\n }\n\n /**\n * Edits a rule.\n *\n * @param ruleId The ID of the rule.\n * @param options The fields to edit, and the reason for the audit log.\n */\n public async edit(\n ruleId: string,\n options: AutoModerationRuleEditOptions,\n ): Promise<AutoModerationRule> {\n const rule = await this.client.api.guilds.editAutoModerationRule(\n this.guildId,\n ruleId,\n toRuleBody(options),\n {\n reason: options.reason,\n },\n );\n return this._add(rule);\n }\n\n /**\n * Deletes a rule.\n *\n * @param ruleId The ID of the rule.\n * @param reason The reason for the audit log.\n */\n public async delete(ruleId: string, reason?: string): Promise<void> {\n await this.client.api.guilds.deleteAutoModerationRule(this.guildId, ruleId, { reason });\n await this.cache?.delete(this.resolveKey(ruleId));\n }\n\n protected async fetchRaw(ruleId: string) {\n return this.client.api.guilds.getAutoModerationRule(this.guildId, ruleId);\n }\n}\n\nfunction toRuleBody(\n options: AutoModerationRuleEditOptions,\n): RESTPatchAPIAutoModerationRuleJSONBody {\n const body: RESTPatchAPIAutoModerationRuleJSONBody = {\n name: options.name,\n event_type: options.eventType,\n trigger_metadata: options.triggerMetadata,\n actions: options.actions && [...options.actions],\n enabled: options.enabled,\n exempt_roles: options.exemptRoles?.map(resolveId),\n exempt_channels: options.exemptChannels?.map(resolveId),\n };\n for (const key of Object.keys(body) as (keyof typeof body)[]) {\n if (body[key] === undefined) delete body[key];\n }\n\n return body;\n}\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kRelations, Structure } from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\n/**\n * The raw data of a ban: the banned user, the guild, and the reason when it came from the API.\n */\nexport type GuildBanData = CacheEntityTypes[\"bans\"] & { reason?: string | null };\n\n/**\n * The relations of a {@link GuildBan}, resolved from the cache by the guild's ban manager.\n */\nexport interface GuildBanRelations {\n user?: User;\n guild?: Guild | null;\n}\n\n/**\n * A ban of a user from a guild.\n */\nexport class GuildBan extends Structure<GuildBanData> {\n declare public [kRelations]: GuildBanRelations;\n\n /**\n * @param data The raw ban.\n * @param relations The user and guild as resolved from the cache, by the guild's ban manager.\n */\n public constructor(data: GuildBanData, relations: GuildBanRelations = {}) {\n super(data, relations);\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n public get user(): User {\n return this[kRelations].user ?? new User(this[kData].user);\n }\n\n /**\n * The reason of the ban. Only bans fetched from the API have it: the gateway does not send it.\n */\n public get reason(): string | null {\n return this[kData].reason ?? null;\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * Fetches the ban from the API, which knows its reason.\n */\n public fetch(): Promise<GuildBan> {\n return this.client.guilds.bans(this.guildId).fetch(this.user.id, { force: true });\n }\n\n /**\n * Lifts the ban.\n *\n * @param reason The reason for the audit log.\n */\n public async remove(reason?: string): Promise<this> {\n await this.client.guilds.bans(this.guildId).remove(this.user.id, reason);\n return this;\n }\n}\n","import { banKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { APIBan } from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { GuildBan, type GuildBanData } from \"../structures/guilds/GuildBan.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { resolveId, type IdResolvable } from \"../util/channels.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\nimport type { BanOptions } from \"./GuildMemberManager.js\";\n\n/**\n * The options to list the bans of a guild with. `before` and `after` are user IDs.\n */\nexport interface GuildBanListOptions {\n /**\n * How many bans to fetch, up to 1000.\n */\n limit?: number;\n before?: string;\n after?: string;\n}\n\n/**\n * Manages the bans of one guild.\n *\n * @remarks\n * The gateway does not send ban reasons, so bans cached from `guildBanAdd` have none. `fetch` with `force` gets it.\n */\nexport class GuildBanManager extends CachedManager<\"bans\", GuildBan, [userId: string]> {\n public readonly guildId: string;\n\n public constructor(client: GatewayClient, guildId: string) {\n super(client, \"bans\");\n this.guildId = guildId;\n }\n\n public createStructure(data: CacheEntityTypes[\"bans\"]): GuildBan {\n return new GuildBan(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"bans\"]): string {\n return this.resolveKey(data.user.id);\n }\n\n public resolveKey(userId: string): string {\n return banKey(this.guildId, userId);\n }\n\n /**\n * Adds a ban to the cache, and its user to `client.users`.\n *\n * @internal\n */\n public override async _add(\n data: CacheEntityTypes[\"bans\"],\n cache = true,\n options?: AddOptions,\n ): Promise<GuildBan> {\n await this.client.users._add(data.user, cache);\n return super._add(data, cache, options);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"bans\"]): Awaitable<GuildBan> {\n return whenAll(\n [this.client.users._resolveData(data.user), this.cachedGuild(data.guild_id)],\n ([user, guild]) => new GuildBan(data, { user, guild }),\n );\n }\n\n /**\n * Lists the bans of the guild, paginated by user ID, and caches them.\n *\n * @param options How many bans, and around which user ID.\n */\n public async list(options: GuildBanListOptions = {}): Promise<GuildBan[]> {\n const bans = await this.client.api.guilds.getMemberBans(this.guildId, options);\n return Promise.all(bans.map((ban) => this._add(this.toData(ban))));\n }\n\n /**\n * Bans a user, member or not. The same as `client.members.ban`.\n *\n * @param user The user, or its ID.\n * @param options The reason, and how many seconds of the user's messages to delete.\n */\n public create(user: IdResolvable, options?: BanOptions): Promise<void> {\n return this.client.members.ban(this.guildId, resolveId(user), options);\n }\n\n /**\n * Lifts a ban, and drops it from the cache.\n *\n * @param user The user, or its ID.\n * @param reason The reason for the audit log.\n */\n public async remove(user: IdResolvable, reason?: string): Promise<void> {\n const userId = resolveId(user);\n await this.client.members.unban(this.guildId, userId, reason);\n await this.cache?.delete(this.resolveKey(userId));\n }\n\n /**\n * Bans up to 200 users at once.\n *\n * @param users The users, or their IDs.\n * @param options The reason, and how many seconds of the users' messages to delete.\n */\n public bulkCreate(\n users: readonly IdResolvable[],\n options?: BanOptions,\n ): Promise<{ bannedUsers: string[]; failedUsers: string[] }> {\n return this.client.members.bulkBan(this.guildId, users.map(resolveId), options);\n }\n\n protected async fetchRaw(userId: string) {\n const ban = await this.client.api.guilds.getMemberBan(this.guildId, userId);\n return this.toData(ban);\n }\n\n private toData(ban: APIBan): CacheEntityTypes[\"bans\"] {\n const data: GuildBanData = { ...ban, guild_id: this.guildId };\n return data;\n }\n}\n","import type { APIChannel, RESTPostAPIGuildChannelJSONBody } from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport {\n resolveId,\n toChannelBody,\n type GuildChannelCreateOptions,\n type GuildChannelEditOptions,\n type IdResolvable,\n} from \"../util/channels.js\";\nimport type { AnyChannel } from \"./ChannelManager.js\";\n\n/**\n * A channel's new position, for {@link GuildChannelManager.setPositions}.\n */\nexport interface ChannelPosition {\n channel: IdResolvable;\n position?: number;\n /**\n * The new category, `null` to move the channel out of its category.\n */\n parent?: IdResolvable | null;\n /**\n * Whether to copy the new category's overwrites, when `parent` is set.\n */\n lockPermissions?: boolean;\n}\n\n/**\n * Manages the channels of one guild. Channels are cached by `client.channels`, which this manager writes to.\n */\nexport class GuildChannelManager {\n public readonly client: GatewayClient;\n public readonly guildId: string;\n\n public constructor(client: GatewayClient, guildId: string) {\n this.client = client;\n this.guildId = guildId;\n }\n\n /**\n * Fetches every channel of the guild, threads excluded, and caches them.\n */\n public async fetch(): Promise<AnyChannel[]> {\n const channels = (await this.client.api.guilds.getChannels(this.guildId)) as APIChannel[];\n return Promise.all(\n channels.map((channel) => this.client.channels._add({ ...channel, guild_id: this.guildId })),\n );\n }\n\n /**\n * Creates a channel in the guild.\n *\n * @param options The channel's name, type, and settings.\n */\n public async create(options: GuildChannelCreateOptions): Promise<AnyChannel> {\n const body = {\n ...toChannelBody(options),\n type: options.type,\n } as RESTPostAPIGuildChannelJSONBody;\n const channel = await this.client.api.guilds.createChannel(this.guildId, body, {\n reason: options.reason,\n });\n return this.client.channels._add(channel);\n }\n\n /**\n * Edits a channel of the guild.\n *\n * @param channel The channel, or its ID.\n * @param options The fields to edit, and the reason for the audit log.\n */\n public edit(channel: IdResolvable, options: GuildChannelEditOptions): Promise<AnyChannel> {\n return this.client.channels.edit(resolveId(channel), options);\n }\n\n /**\n * Deletes a channel of the guild.\n *\n * @param channel The channel, or its ID.\n * @param reason The reason for the audit log.\n */\n public delete(channel: IdResolvable, reason?: string): Promise<void> {\n return this.client.channels.delete(resolveId(channel), reason);\n }\n\n /**\n * Moves several channels at once.\n *\n * @param positions The channels and their new positions or categories.\n * @param reason The reason for the audit log.\n */\n public async setPositions(positions: readonly ChannelPosition[], reason?: string): Promise<void> {\n const body = positions.map((position) => ({\n id: resolveId(position.channel),\n position: position.position,\n parent_id:\n position.parent === undefined\n ? undefined\n : position.parent === null\n ? null\n : resolveId(position.parent),\n lock_permissions: position.lockPermissions,\n }));\n await this.client.api.guilds.setChannelPositions(this.guildId, body, { reason });\n\n // The endpoint answers 204: refetch the moved channels rather than guessing the positions Discord shifted.\n await this.fetch();\n }\n}\n","import { integrationKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { Integration } from \"../structures/guilds/Integration.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\n\n/**\n * Manages the integrations of one guild.\n *\n * @remarks\n * Discord has no route to fetch a single integration: `fetch` lists them all, and rejects when the ID is not among\n * them.\n */\nexport class GuildIntegrationManager extends CachedManager<\n \"integrations\",\n Integration,\n [integrationId: string]\n> {\n public readonly guildId: string;\n\n public constructor(client: GatewayClient, guildId: string) {\n super(client, \"integrations\");\n this.guildId = guildId;\n }\n\n public createStructure(data: CacheEntityTypes[\"integrations\"]): Integration {\n return new Integration(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"integrations\"]): string {\n return this.resolveKey(data.id);\n }\n\n public resolveKey(integrationId: string): string {\n return integrationKey(this.guildId, integrationId);\n }\n\n /**\n * Adds an integration to the cache, and its user to `client.users`.\n *\n * @internal\n */\n public override async _add(\n data: CacheEntityTypes[\"integrations\"],\n cache = true,\n options?: AddOptions,\n ): Promise<Integration> {\n if (data.user) await this.client.users._add(data.user, cache);\n return super._add(data, cache, options);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"integrations\"]): Awaitable<Integration> {\n return whenAll(\n [\n data.user ? this.client.users._resolveData(data.user) : null,\n this.cachedGuild(data.guild_id),\n data.role_id ? this.client.roles._get(data.guild_id, data.role_id) : undefined,\n ],\n ([user, guild, role]) => new Integration(data, { user, guild, role: role ?? null }),\n );\n }\n\n /**\n * Fetches every integration of the guild, and caches them.\n */\n public async fetchAll(): Promise<Integration[]> {\n const integrations = await this.list();\n return Promise.all(integrations.map((integration) => this._add(integration)));\n }\n\n /**\n * Removes an integration from the guild, kicking its bot if it has one, and drops it from the cache.\n *\n * @param integrationId The ID of the integration.\n * @param reason The reason for the audit log.\n */\n public async delete(integrationId: string, reason?: string): Promise<void> {\n await this.client.api.guilds.deleteIntegration(this.guildId, integrationId, { reason });\n await this.cache?.delete(this.resolveKey(integrationId));\n }\n\n protected async fetchRaw(integrationId: string) {\n const integration = (await this.list()).find(({ id }) => id === integrationId);\n if (!integration) {\n throw new RangeError(`The guild ${this.guildId} has no integration ${integrationId}`);\n }\n\n return integration;\n }\n\n private async list(): Promise<CacheEntityTypes[\"integrations\"][]> {\n const integrations = await this.client.api.guilds.getIntegrations(this.guildId);\n return integrations.map((integration) => ({ ...integration, guild_id: this.guildId }));\n }\n}\n","import { scheduledEventKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n type APIGuildScheduledEventEntityMetadata,\n type APIGuildScheduledEventRecurrenceRule,\n type GuildScheduledEventEntityType,\n type GuildScheduledEventPrivacyLevel,\n type GuildScheduledEventStatus,\n type RESTPatchAPIGuildScheduledEventJSONBody,\n type RESTPostAPIGuildScheduledEventJSONBody,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { GuildScheduledEvent } from \"../structures/guilds/GuildScheduledEvent.js\";\nimport type { GuildMember } from \"../structures/guilds/GuildMember.js\";\nimport type { User } from \"../structures/users/User.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { resolveId, type IdResolvable } from \"../util/channels.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\n\n/**\n * The fields of a scheduled event that can be edited.\n */\nexport interface GuildScheduledEventEditOptions {\n name?: string;\n description?: string | null;\n /**\n * The stage or voice channel, `null` for an external event.\n */\n channel?: IdResolvable | null;\n scheduledStartTime?: Date | number;\n scheduledEndTime?: Date | number | null;\n privacyLevel?: GuildScheduledEventPrivacyLevel;\n entityType?: GuildScheduledEventEntityType;\n /**\n * Where an external event takes place.\n */\n entityMetadata?: APIGuildScheduledEventEntityMetadata | null;\n /**\n * Starts, ends, or cancels the event.\n */\n status?: GuildScheduledEventStatus;\n /**\n * The cover image, as a data URI.\n */\n image?: string | null;\n recurrenceRule?: APIGuildScheduledEventRecurrenceRule | null;\n reason?: string;\n}\n\n/**\n * The options to create a scheduled event with.\n */\nexport interface GuildScheduledEventCreateOptions extends Omit<\n GuildScheduledEventEditOptions,\n \"status\"\n> {\n name: string;\n scheduledStartTime: Date | number;\n privacyLevel: GuildScheduledEventPrivacyLevel;\n entityType: GuildScheduledEventEntityType;\n}\n\n/**\n * The options to fetch the subscribers of an event with. `before` and `after` are user IDs.\n */\nexport interface GuildScheduledEventSubscribersOptions {\n /**\n * How many users to fetch, up to 100.\n */\n limit?: number;\n before?: string;\n after?: string;\n /**\n * Whether to include each user's guild member.\n */\n withMember?: boolean;\n}\n\n/**\n * A user subscribed to a scheduled event.\n */\nexport interface GuildScheduledEventSubscriber {\n user: User;\n member: GuildMember | null;\n}\n\n/**\n * Manages the scheduled events of one guild.\n */\nexport class GuildScheduledEventManager extends CachedManager<\n \"scheduledEvents\",\n GuildScheduledEvent,\n [eventId: string]\n> {\n public readonly guildId: string;\n\n public constructor(client: GatewayClient, guildId: string) {\n super(client, \"scheduledEvents\");\n this.guildId = guildId;\n }\n\n public createStructure(data: CacheEntityTypes[\"scheduledEvents\"]): GuildScheduledEvent {\n return new GuildScheduledEvent(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"scheduledEvents\"]): string {\n return this.resolveKey(data.id);\n }\n\n public resolveKey(eventId: string): string {\n return scheduledEventKey(this.guildId, eventId);\n }\n\n /**\n * Adds an event to the cache, and its creator to `client.users`.\n *\n * @internal\n */\n public override async _add(\n data: CacheEntityTypes[\"scheduledEvents\"],\n cache = true,\n options?: AddOptions,\n ): Promise<GuildScheduledEvent> {\n if (data.creator) await this.client.users._add(data.creator, cache);\n return super._add(data, cache, options);\n }\n\n public override _hydrate(\n data: CacheEntityTypes[\"scheduledEvents\"],\n ): Awaitable<GuildScheduledEvent> {\n return whenAll(\n [\n data.creator\n ? this.client.users._resolveData(data.creator)\n : data.creator_id\n ? this.client.users._get(data.creator_id)\n : undefined,\n this.cachedGuild(data.guild_id),\n data.channel_id ? this.client.channels._get(data.channel_id) : undefined,\n ],\n ([creator, guild, channel]) =>\n new GuildScheduledEvent(data, {\n creator: creator ?? null,\n guild,\n channel: channel ?? null,\n }),\n );\n }\n\n /**\n * Fetches every scheduled event of the guild, and caches them.\n *\n * @param options Whether to include how many users subscribed to each.\n */\n public async fetchAll(options: { withUserCount?: boolean } = {}): Promise<GuildScheduledEvent[]> {\n const events = await this.client.api.guilds.getScheduledEvents(this.guildId, {\n with_user_count: options.withUserCount ?? true,\n });\n return Promise.all(events.map((event) => this._add(event)));\n }\n\n /**\n * Creates a scheduled event.\n *\n * @param options The event's name, time, place, and privacy.\n */\n public async create(options: GuildScheduledEventCreateOptions): Promise<GuildScheduledEvent> {\n const event = await this.client.api.guilds.createScheduledEvent(\n this.guildId,\n toEventBody(options) as RESTPostAPIGuildScheduledEventJSONBody,\n {\n reason: options.reason,\n },\n );\n return this._add(event);\n }\n\n /**\n * Edits a scheduled event.\n *\n * @param eventId The ID of the event.\n * @param options The fields to edit, and the reason for the audit log.\n */\n public async edit(\n eventId: string,\n options: GuildScheduledEventEditOptions,\n ): Promise<GuildScheduledEvent> {\n const event = await this.client.api.guilds.editScheduledEvent(\n this.guildId,\n eventId,\n toEventBody(options),\n {\n reason: options.reason,\n },\n );\n return this._add(event);\n }\n\n /**\n * Deletes a scheduled event.\n *\n * @param eventId The ID of the event.\n * @param reason The reason for the audit log.\n */\n public async delete(eventId: string, reason?: string): Promise<void> {\n await this.client.api.guilds.deleteScheduledEvent(this.guildId, eventId, { reason });\n await this.cache?.delete(this.resolveKey(eventId));\n }\n\n /**\n * Fetches the users who subscribed to an event, and caches them.\n *\n * @param eventId The ID of the event.\n * @param options How many users, around which user ID, and whether to include their members.\n */\n public async fetchSubscribers(\n eventId: string,\n options: GuildScheduledEventSubscribersOptions = {},\n ): Promise<GuildScheduledEventSubscriber[]> {\n const subscribers = await this.client.api.guilds.getScheduledEventUsers(this.guildId, eventId, {\n with_member: options.withMember ?? false,\n limit: options.limit,\n before: options.before,\n after: options.after,\n });\n return Promise.all(\n subscribers.map(async (subscriber) => ({\n user: await this.client.users._add(subscriber.user),\n member: subscriber.member\n ? await this.client.members._add({\n ...subscriber.member,\n user: subscriber.user,\n guild_id: this.guildId,\n })\n : null,\n })),\n );\n }\n\n protected async fetchRaw(eventId: string) {\n return this.client.api.guilds.getScheduledEvent(this.guildId, eventId, {\n with_user_count: true,\n });\n }\n}\n\nfunction toISO(value: Date | number | null | undefined): string | null | undefined {\n return value === undefined || value === null ? value : new Date(value).toISOString();\n}\n\nfunction toEventBody(\n options: GuildScheduledEventEditOptions,\n): RESTPatchAPIGuildScheduledEventJSONBody {\n const body: Record<string, unknown> = {\n name: options.name,\n description: options.description,\n channel_id:\n options.channel === undefined\n ? undefined\n : options.channel === null\n ? null\n : resolveId(options.channel),\n scheduled_start_time: toISO(options.scheduledStartTime),\n scheduled_end_time: toISO(options.scheduledEndTime),\n privacy_level: options.privacyLevel,\n entity_type: options.entityType,\n entity_metadata: options.entityMetadata,\n status: options.status,\n image: options.image,\n recurrence_rule: options.recurrenceRule,\n };\n for (const key of Object.keys(body)) if (body[key] === undefined) delete body[key];\n return body as RESTPatchAPIGuildScheduledEventJSONBody;\n}\n","import { SoundboardSound as BaseSoundboardSound } from \"@discordjs/structures\";\nimport type { APISoundboardSound } from \"discord-api-types/v10\";\nimport type { SoundboardSoundEditOptions } from \"../../managers/GuildSoundboardSoundManager.js\";\nimport { cdn } from \"../../util/cdn.js\";\nimport type { GuildEmoji } from \"../emojis/GuildEmoji.js\";\nimport { ReactionEmoji } from \"../emojis/ReactionEmoji.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, kPatch, kRelations, StructureMixin } from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\n/**\n * The relations of a {@link SoundboardSound}, resolved from the cache by the guild's soundboard manager.\n */\nexport interface SoundboardSoundRelations {\n user?: User | null;\n guild?: Guild | null;\n /**\n * The custom emoji of the sound, when it belongs to the sound's guild and is cached.\n */\n emoji?: GuildEmoji | null;\n}\n\nexport interface SoundboardSound extends StructureMixin<\n APISoundboardSound,\n SoundboardSoundRelations\n> {}\n\n/**\n * A soundboard sound, one of Discord's defaults or a guild's: `@discordjs/structures`' `SoundboardSound`, with its\n * uploader, guild, and URL, and actions through the client.\n */\nexport class SoundboardSound extends BaseSoundboardSound {\n /**\n * @param data The raw sound.\n * @param relations The uploader and guild as resolved from the cache, by the guild's soundboard manager.\n */\n public constructor(data: APISoundboardSound, relations: SoundboardSoundRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n public [kPatch](data: Readonly<Partial<APISoundboardSound>>): this {\n if (data.user) this.dropRelations(\"user\");\n this.dropChangedRelations(data, { emoji: \"emoji_id\" });\n return StructureMixin.prototype[kPatch].call(this, data) as this;\n }\n\n /**\n * The user who uploaded a guild sound, when the payload includes it.\n */\n public get user(): User | null {\n const { user } = this[kData];\n return this[kRelations].user ?? (user ? new User(user) : null);\n }\n\n /**\n * The emoji of the sound, like discord.js's `SoundboardSound#emoji`: the cached custom emoji of the sound's guild,\n * else the emoji of the payload. `null` when the sound has none.\n */\n public get emoji(): GuildEmoji | ReactionEmoji | null {\n const resolved = this[kRelations].emoji;\n if (resolved) return resolved;\n const { emoji_id: id, emoji_name: name } = this[kData];\n return id || name ? new ReactionEmoji({ id, name }) : null;\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * The URL of the sound file.\n */\n public get url(): string {\n return cdn.soundboardSound(this.soundId);\n }\n\n /**\n * Whether the sound is partial: built from its IDs alone for an event about an uncached sound, see\n * `Partials.SoundboardSound`. Only `soundId` and `guildId` are reliable then, and {@link SoundboardSound.fetch}\n * completes it.\n */\n public get partial(): boolean {\n return this[kData].name === undefined;\n }\n\n /**\n * Fetches the guild sound from the API and patches this structure with the result.\n */\n public fetch(): Promise<this> {\n return this.withGuild(async (guildId) => {\n const sound = await this.client.guilds\n .soundboardSounds(guildId)\n .fetch(this.soundId, { force: true });\n return this[kPatch](sound.toJSON());\n });\n }\n\n public edit(options: SoundboardSoundEditOptions): Promise<this> {\n return this.withGuild(async (guildId) => {\n const sound = await this.client.guilds.soundboardSounds(guildId).edit(this.soundId, options);\n return this[kPatch](sound.toJSON());\n });\n }\n\n public delete(reason?: string): Promise<this> {\n return this.withGuild(async (guildId) => {\n await this.client.guilds.soundboardSounds(guildId).delete(this.soundId, reason);\n return this;\n });\n }\n\n private withGuild(action: (guildId: string) => Promise<this>): Promise<this> {\n const { guildId } = this;\n if (!guildId) return Promise.reject(new Error(\"Default soundboard sounds cannot be changed\"));\n return action(guildId);\n }\n}\n\nMixin(SoundboardSound, [StructureMixin]);\n","import { soundboardSoundKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n type APISoundboardSound,\n type RESTPatchAPIGuildSoundboardSoundJSONBody,\n type RESTPostAPIGuildSoundboardSoundJSONBody,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { SoundboardSound } from \"../structures/soundboards/SoundboardSound.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\n\n/**\n * The fields of a soundboard sound that can be edited.\n */\nexport interface SoundboardSoundEditOptions {\n name?: string;\n /**\n * The volume, from 0 to 1.\n */\n volume?: number | null;\n emojiId?: string | null;\n emojiName?: string | null;\n reason?: string;\n}\n\n/**\n * The options to upload a soundboard sound with.\n */\nexport interface SoundboardSoundCreateOptions extends SoundboardSoundEditOptions {\n name: string;\n /**\n * The MP3 or OGG sound, as a data URI.\n */\n sound: string;\n}\n\n/**\n * Manages the soundboard sounds of one guild.\n */\nexport class GuildSoundboardSoundManager extends CachedManager<\n \"soundboardSounds\",\n SoundboardSound,\n [soundId: string]\n> {\n public readonly guildId: string;\n\n public constructor(client: GatewayClient, guildId: string) {\n super(client, \"soundboardSounds\");\n this.guildId = guildId;\n }\n\n public createStructure(data: CacheEntityTypes[\"soundboardSounds\"]): SoundboardSound {\n return new SoundboardSound(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"soundboardSounds\"]): string {\n return this.resolveKey(data.sound_id);\n }\n\n public resolveKey(soundId: string): string {\n return soundboardSoundKey(this.guildId, soundId);\n }\n\n /**\n * Adds a sound to the cache, and its uploader to `client.users`.\n *\n * @internal\n */\n public override async _add(\n data: CacheEntityTypes[\"soundboardSounds\"],\n cache = true,\n options?: AddOptions,\n ): Promise<SoundboardSound> {\n if (data.user) await this.client.users._add(data.user, cache);\n return super._add(data, cache, options);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"soundboardSounds\"]): Awaitable<SoundboardSound> {\n return whenAll(\n [\n data.user ? this.client.users._resolveData(data.user) : null,\n this.cachedGuild(data.guild_id),\n data.emoji_id && data.guild_id\n ? this.client.guilds.emojis(data.guild_id)._get(data.emoji_id)\n : undefined,\n ],\n ([user, guild, emoji]) => new SoundboardSound(data, { user, guild, emoji: emoji ?? null }),\n );\n }\n\n /**\n * Fetches every soundboard sound of the guild, and caches them.\n */\n public async fetchAll(): Promise<SoundboardSound[]> {\n const { items } = await this.client.api.guilds.getSoundboardSounds(this.guildId);\n return Promise.all(items.map((sound) => this._add(this.withGuildId(sound))));\n }\n\n /**\n * Uploads a soundboard sound.\n *\n * @param options The sound file, its name, volume, and emoji.\n */\n public async create(options: SoundboardSoundCreateOptions): Promise<SoundboardSound> {\n const body: RESTPostAPIGuildSoundboardSoundJSONBody = {\n ...toSoundBody(options),\n name: options.name,\n sound: options.sound,\n };\n const sound = await this.client.api.guilds.createSoundboardSound(this.guildId, body, {\n reason: options.reason,\n });\n return this._add(this.withGuildId(sound));\n }\n\n /**\n * Edits a soundboard sound.\n *\n * @param soundId The ID of the sound.\n * @param options The fields to edit, and the reason for the audit log.\n */\n public async edit(\n soundId: string,\n options: SoundboardSoundEditOptions,\n ): Promise<SoundboardSound> {\n const sound = await this.client.api.guilds.editSoundboardSound(\n this.guildId,\n soundId,\n toSoundBody(options),\n {\n reason: options.reason,\n },\n );\n return this._add(this.withGuildId(sound));\n }\n\n /**\n * Deletes a soundboard sound.\n *\n * @param soundId The ID of the sound.\n * @param reason The reason for the audit log.\n */\n public async delete(soundId: string, reason?: string): Promise<void> {\n await this.client.api.guilds.deleteSoundboardSound(this.guildId, soundId, { reason });\n await this.cache?.delete(this.resolveKey(soundId));\n }\n\n protected async fetchRaw(soundId: string) {\n const sound = await this.client.api.guilds.getSoundboardSound(this.guildId, soundId);\n return this.withGuildId(sound);\n }\n\n private withGuildId(sound: APISoundboardSound): APISoundboardSound {\n return { ...sound, guild_id: sound.guild_id ?? this.guildId };\n }\n}\n\nfunction toSoundBody(\n options: SoundboardSoundEditOptions,\n): RESTPatchAPIGuildSoundboardSoundJSONBody {\n const body: RESTPatchAPIGuildSoundboardSoundJSONBody = {\n name: options.name,\n volume: options.volume,\n emoji_id: options.emojiId,\n emoji_name: options.emojiName,\n };\n for (const key of Object.keys(body) as (keyof typeof body)[]) {\n if (body[key] === undefined) delete body[key];\n }\n\n return body;\n}\n","import { stageInstanceKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n type RESTPatchAPIStageInstanceJSONBody,\n type RESTPostAPIStageInstanceJSONBody,\n type StageInstancePrivacyLevel,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { StageInstance } from \"../structures/stageInstances/StageInstance.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { resolveId, type IdResolvable } from \"../util/channels.js\";\nimport { CachedManager } from \"./CachedManager.js\";\n\n/**\n * The fields of a stage instance that can be edited.\n */\nexport interface StageInstanceEditOptions {\n topic?: string;\n privacyLevel?: StageInstancePrivacyLevel;\n reason?: string;\n}\n\n/**\n * The options to start a stage with.\n */\nexport interface StageInstanceCreateOptions extends StageInstanceEditOptions {\n topic: string;\n /**\n * Whether to notify the members of the guild that the stage started.\n */\n sendStartNotification?: boolean;\n /**\n * The scheduled event the stage belongs to.\n */\n guildScheduledEvent?: IdResolvable;\n}\n\n/**\n * Manages the stage instances of one guild, keyed by the ID of their stage channel.\n */\nexport class StageInstanceManager extends CachedManager<\n \"stageInstances\",\n StageInstance,\n [channelId: string]\n> {\n public readonly guildId: string;\n\n public constructor(client: GatewayClient, guildId: string) {\n super(client, \"stageInstances\");\n this.guildId = guildId;\n }\n\n public createStructure(data: CacheEntityTypes[\"stageInstances\"]): StageInstance {\n return new StageInstance(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"stageInstances\"]): string {\n return this.resolveKey(data.channel_id);\n }\n\n public resolveKey(channelId: string): string {\n return stageInstanceKey(this.guildId, channelId);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"stageInstances\"]): Awaitable<StageInstance> {\n return whenAll(\n [\n this.cachedGuild(data.guild_id),\n this.client.channels._get(data.channel_id),\n data.guild_scheduled_event_id\n ? this.client.guilds.scheduledEvents(data.guild_id)._get(data.guild_scheduled_event_id)\n : undefined,\n ],\n ([guild, channel, guildScheduledEvent]) =>\n new StageInstance(data, {\n guild,\n channel: channel ?? null,\n guildScheduledEvent: guildScheduledEvent ?? null,\n }),\n );\n }\n\n /**\n * Starts a stage in a stage channel.\n *\n * @param channel The stage channel, or its ID.\n * @param options The topic and privacy level, and whether to notify the guild.\n */\n public async create(\n channel: IdResolvable,\n options: StageInstanceCreateOptions,\n ): Promise<StageInstance> {\n const body: RESTPostAPIStageInstanceJSONBody = {\n channel_id: resolveId(channel),\n topic: options.topic,\n privacy_level: options.privacyLevel,\n send_start_notification: options.sendStartNotification,\n guild_scheduled_event_id:\n options.guildScheduledEvent && resolveId(options.guildScheduledEvent),\n };\n const instance = await this.client.api.stageInstances.create(body, {\n reason: options.reason,\n });\n return this._add(instance);\n }\n\n /**\n * Edits the stage of a channel.\n *\n * @param channelId The ID of the stage channel.\n * @param options The topic and privacy level, and the reason for the audit log.\n */\n public async edit(channelId: string, options: StageInstanceEditOptions): Promise<StageInstance> {\n const body: RESTPatchAPIStageInstanceJSONBody = {\n topic: options.topic,\n privacy_level: options.privacyLevel,\n };\n const instance = await this.client.api.stageInstances.edit(channelId, body, {\n reason: options.reason,\n });\n return this._add(instance);\n }\n\n /**\n * Ends the stage of a channel.\n *\n * @param channelId The ID of the stage channel.\n * @param reason The reason for the audit log.\n */\n public async delete(channelId: string, reason?: string): Promise<void> {\n await this.client.api.stageInstances.delete(channelId, { reason });\n await this.cache?.delete(this.resolveKey(channelId));\n }\n\n protected async fetchRaw(channelId: string) {\n return this.client.api.stageInstances.get(channelId);\n }\n}\n","import { emojiKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n type APIEmoji,\n type RESTPatchAPIGuildEmojiJSONBody,\n type RESTPostAPIGuildEmojiJSONBody,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { GuildEmoji } from \"../structures/emojis/GuildEmoji.js\";\nimport type { User } from \"../structures/users/User.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\n\n/**\n * The options to create an emoji with.\n */\nexport interface GuildEmojiCreateOptions {\n /**\n * The image, as a data URI (`data:image/png;base64,...`), up to 256 KiB.\n */\n attachment: string;\n name: string;\n /**\n * The IDs of the roles allowed to use the emoji, everyone when omitted.\n */\n roles?: readonly string[];\n reason?: string;\n}\n\n/**\n * The options to edit an emoji with.\n */\nexport interface GuildEmojiEditOptions {\n name?: string;\n /**\n * The IDs of the roles allowed to use the emoji, `null` or empty for everyone.\n */\n roles?: readonly string[] | null;\n reason?: string;\n}\n\n/**\n * Manages the custom emojis of one guild.\n */\nexport class GuildEmojiManager extends CachedManager<\"emojis\", GuildEmoji, [emojiId: string]> {\n /**\n * The ID of the guild.\n */\n public readonly guildId: string;\n\n public constructor(client: GatewayClient, guildId: string) {\n super(client, \"emojis\");\n this.guildId = guildId;\n }\n\n public createStructure(data: CacheEntityTypes[\"emojis\"]): GuildEmoji {\n return new GuildEmoji(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"emojis\"]): string {\n return this.resolveKey(data.id!);\n }\n\n /**\n * Adds an emoji to the cache, and its uploader to `client.users`.\n *\n * @internal\n */\n public override async _add(\n data: CacheEntityTypes[\"emojis\"],\n cache = true,\n options?: AddOptions,\n ): Promise<GuildEmoji> {\n if (data.user) await this.client.users._add(data.user, cache);\n return super._add(data, cache, options);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"emojis\"]): Awaitable<GuildEmoji> {\n return whenAll(\n [\n data.user ? this.client.users._resolveData(data.user) : undefined,\n this.cachedGuild(data.guild_id),\n ],\n ([author, guild]) => new GuildEmoji(data, { author, guild }),\n );\n }\n\n public resolveKey(emojiId: string): string {\n return emojiKey(this.guildId, emojiId);\n }\n\n /**\n * Fetches every emoji of the guild, and caches them.\n */\n public async fetchAll(): Promise<GuildEmoji[]> {\n const emojis = await this.client.api.guilds.getEmojis(this.guildId);\n return Promise.all(emojis.map((emoji) => this.store(emoji)));\n }\n\n /**\n * Uploads an emoji.\n *\n * @param options The image, name, and allowed roles.\n */\n public async create(options: GuildEmojiCreateOptions): Promise<GuildEmoji> {\n const body: RESTPostAPIGuildEmojiJSONBody = {\n image: options.attachment,\n name: options.name,\n roles: options.roles ? [...options.roles] : undefined,\n };\n const emoji = await this.client.api.guilds.createEmoji(this.guildId, body, {\n reason: options.reason,\n });\n return this.store(emoji);\n }\n\n /**\n * Edits an emoji.\n *\n * @param emojiId The ID of the emoji.\n * @param options The changes to apply.\n */\n public async edit(emojiId: string, options: GuildEmojiEditOptions): Promise<GuildEmoji> {\n const body: RESTPatchAPIGuildEmojiJSONBody = {\n name: options.name,\n roles:\n options.roles === undefined || options.roles === null ? options.roles : [...options.roles],\n };\n const emoji = await this.client.api.guilds.editEmoji(this.guildId, emojiId, body, {\n reason: options.reason,\n });\n return this.store(emoji);\n }\n\n /**\n * Deletes an emoji.\n *\n * @param emojiId The ID of the emoji.\n * @param reason The reason for the audit log.\n */\n public async delete(emojiId: string, reason?: string): Promise<void> {\n await this.client.api.guilds.deleteEmoji(this.guildId, emojiId, { reason });\n await this.cache?.delete(this.resolveKey(emojiId));\n }\n\n /**\n * Fetches the user who uploaded an emoji, which the API only returns with `ManageGuildExpressions`.\n *\n * @param emojiId The ID of the emoji.\n */\n public async fetchAuthor(emojiId: string): Promise<User | null> {\n const emoji = await this.fetch(emojiId, { force: true });\n return emoji.author;\n }\n\n /**\n * Lists the emojis of the guild held in the cache, without calling the API.\n *\n * @remarks\n * It enumerates the whole entity cache, which a Redis store answers from its index: prefer `fetchAll` when the\n * cache may be incomplete.\n */\n public async listCached(): Promise<GuildEmoji[]> {\n const cache = this.cache;\n if (!cache) return [];\n\n const prefix = `${this.guildId}:`;\n const keys = (await cache.keys()).filter((key) => key.startsWith(prefix));\n const values = await Promise.all(keys.map((key) => cache.get(key)));\n return Promise.all(\n values.filter((value) => value !== undefined).map((value) => this.hydrate(value)),\n );\n }\n\n protected async fetchRaw(emojiId: string) {\n const emoji = await this.client.api.guilds.getEmoji(this.guildId, emojiId);\n return { ...emoji, guild_id: this.guildId };\n }\n\n private store(emoji: APIEmoji): Promise<GuildEmoji> {\n return this._add({ ...emoji, guild_id: this.guildId });\n }\n}\n","import { inviteKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n type APIExtendedInvite,\n type APIInvite,\n type InviteTargetType,\n type RESTPostAPIChannelInviteJSONBody,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport type { InviteData } from \"../structures/invites/BaseInvite.js\";\nimport { GuildInvite } from \"../structures/invites/GuildInvite.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\n\n/**\n * The options to create an invite with.\n */\nexport interface InviteCreateOptions {\n /**\n * How long the invite lasts, in seconds, up to 7 days. `0` never expires.\n *\n * @default 86_400\n */\n maxAge?: number;\n /**\n * How many times the invite can be used, `0` for unlimited.\n */\n maxUses?: number;\n /**\n * Whether the invite only grants temporary membership.\n */\n temporary?: boolean;\n /**\n * Whether to always create a new invite, instead of reusing a similar one.\n */\n unique?: boolean;\n targetType?: InviteTargetType;\n targetUserId?: string;\n targetApplicationId?: string;\n reason?: string;\n}\n\n/**\n * Manages the invites of one guild.\n */\nexport class GuildInviteManager extends CachedManager<\"invites\", GuildInvite, [code: string]> {\n /**\n * The ID of the guild.\n */\n public readonly guildId: string;\n\n public constructor(client: GatewayClient, guildId: string) {\n super(client, \"invites\");\n this.guildId = guildId;\n }\n\n public createStructure(data: CacheEntityTypes[\"invites\"]): GuildInvite {\n return new GuildInvite(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"invites\"]): string {\n return this.resolveKey(data.code);\n }\n\n /**\n * Adds an invite to the cache, and its inviter and target user to `client.users`.\n *\n * @internal\n */\n public override async _add(\n data: CacheEntityTypes[\"invites\"],\n cache = true,\n options?: AddOptions,\n ): Promise<GuildInvite> {\n if (data.inviter) await this.client.users._add(data.inviter, cache);\n if (data.target_user) await this.client.users._add(data.target_user, cache);\n return super._add(data, cache, options);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"invites\"]): Awaitable<GuildInvite> {\n const { users } = this.client;\n return whenAll(\n [\n data.inviter ? users._resolveData(data.inviter) : undefined,\n data.target_user ? users._resolveData(data.target_user) : undefined,\n this.cachedGuild(this.guildId),\n data.channel_id ? this.client.channels._get(data.channel_id) : undefined,\n ],\n ([inviter, targetUser, guild, channel]) =>\n new GuildInvite(data, { inviter, targetUser, guild, channel: channel ?? null }),\n );\n }\n\n public resolveKey(code: string): string {\n return inviteKey(this.guildId, code);\n }\n\n /**\n * Fetches every invite of the guild, with their metadata, and caches them.\n */\n public async fetchAll(): Promise<GuildInvite[]> {\n const invites = await this.client.api.guilds.getInvites(this.guildId);\n return Promise.all(invites.map((invite) => this.store(invite)));\n }\n\n /**\n * Fetches every invite of a channel of the guild, and caches them.\n *\n * @param channelId The ID of the channel.\n */\n public async fetchChannel(channelId: string): Promise<GuildInvite[]> {\n const invites = await this.client.api.channels.getInvites(channelId);\n return Promise.all(invites.map((invite) => this.store(invite)));\n }\n\n /**\n * Creates an invite to a channel of the guild.\n *\n * @param channelId The ID of the channel.\n * @param options The invite's limits and target.\n */\n public async create(channelId: string, options: InviteCreateOptions = {}): Promise<GuildInvite> {\n const body: RESTPostAPIChannelInviteJSONBody = {\n max_age: options.maxAge,\n max_uses: options.maxUses,\n temporary: options.temporary,\n unique: options.unique,\n target_type: options.targetType,\n target_user_id: options.targetUserId,\n target_application_id: options.targetApplicationId,\n };\n const invite = await this.client.api.channels.createInvite(channelId, body, {\n reason: options.reason,\n });\n return this.store(invite);\n }\n\n /**\n * Deletes an invite.\n *\n * @param code The code of the invite.\n * @param reason The reason for the audit log.\n */\n public async delete(code: string, reason?: string): Promise<void> {\n await this.client.api.invites.delete(code, { reason });\n await this.cache?.delete(this.resolveKey(code));\n }\n\n protected async fetchRaw(code: string) {\n const invite = await this.client.api.invites.get(code, { with_counts: true });\n return this.toCached(invite);\n }\n\n private store(invite: APIInvite | APIExtendedInvite): Promise<GuildInvite> {\n return this._add(this.toCached(invite));\n }\n\n // The cache holds the `INVITE_CREATE` shape: REST invites keep their nested objects, plus the flat IDs it needs.\n private toCached(invite: APIInvite | APIExtendedInvite): CacheEntityTypes[\"invites\"] {\n const data: InviteData = {\n ...invite,\n guild_id: invite.guild?.id ?? this.guildId,\n channel_id: invite.channel?.id,\n };\n return data as CacheEntityTypes[\"invites\"];\n }\n}\n","import type { RawFile } from \"@discordjs/rest\";\nimport { stickerKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport { type APISticker, type RESTPatchAPIGuildStickerJSONBody } from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { Sticker } from \"../structures/stickers/Sticker.js\";\nimport type { User } from \"../structures/users/User.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\n\n/**\n * The options to upload a sticker with.\n */\nexport interface GuildStickerCreateOptions {\n /**\n * The PNG, APNG, GIF, or Lottie JSON file, up to 512 KiB.\n */\n file: RawFile;\n name: string;\n /**\n * The name of the Unicode emoji the sticker relates to, used for suggestions.\n */\n tags: string;\n description?: string;\n reason?: string;\n}\n\n/**\n * The options to edit a sticker with.\n */\nexport interface GuildStickerEditOptions {\n name?: string;\n description?: string | null;\n tags?: string;\n reason?: string;\n}\n\n/**\n * Manages the custom stickers of one guild.\n */\nexport class GuildStickerManager extends CachedManager<\"stickers\", Sticker, [stickerId: string]> {\n /**\n * The ID of the guild.\n */\n public readonly guildId: string;\n\n public constructor(client: GatewayClient, guildId: string) {\n super(client, \"stickers\");\n this.guildId = guildId;\n }\n\n public createStructure(data: CacheEntityTypes[\"stickers\"]): Sticker {\n return new Sticker(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"stickers\"]): string {\n return this.resolveKey(data.id);\n }\n\n /**\n * Adds a sticker to the cache, and its uploader to `client.users`.\n *\n * @internal\n */\n public override async _add(\n data: CacheEntityTypes[\"stickers\"],\n cache = true,\n options?: AddOptions,\n ): Promise<Sticker> {\n if (data.user) await this.client.users._add(data.user, cache);\n return super._add(data, cache, options);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"stickers\"]): Awaitable<Sticker> {\n return whenAll(\n [\n data.user ? this.client.users._resolveData(data.user) : undefined,\n this.cachedGuild(data.guild_id),\n ],\n ([user, guild]) => new Sticker(data, { user, guild }),\n );\n }\n\n public resolveKey(stickerId: string): string {\n return stickerKey(this.guildId, stickerId);\n }\n\n /**\n * Fetches every sticker of the guild, and caches them.\n */\n public async fetchAll(): Promise<Sticker[]> {\n const stickers = await this.client.api.guilds.getStickers(this.guildId);\n return Promise.all(stickers.map((sticker) => this.store(sticker)));\n }\n\n /**\n * Uploads a sticker.\n *\n * @param options The file, name, and tags.\n */\n public async create(options: GuildStickerCreateOptions): Promise<Sticker> {\n const sticker = await this.client.api.guilds.createSticker(\n this.guildId,\n {\n name: options.name,\n tags: options.tags,\n description: options.description ?? \"\",\n file: options.file,\n },\n { reason: options.reason },\n );\n return this.store(sticker);\n }\n\n /**\n * Edits a sticker.\n *\n * @param stickerId The ID of the sticker.\n * @param options The changes to apply.\n */\n public async edit(stickerId: string, options: GuildStickerEditOptions): Promise<Sticker> {\n const body: RESTPatchAPIGuildStickerJSONBody = {\n name: options.name,\n description: options.description,\n tags: options.tags,\n };\n const sticker = await this.client.api.guilds.editSticker(this.guildId, stickerId, body, {\n reason: options.reason,\n });\n return this.store(sticker);\n }\n\n /**\n * Deletes a sticker.\n *\n * @param stickerId The ID of the sticker.\n * @param reason The reason for the audit log.\n */\n public async delete(stickerId: string, reason?: string): Promise<void> {\n await this.client.api.guilds.deleteSticker(this.guildId, stickerId, { reason });\n await this.cache?.delete(this.resolveKey(stickerId));\n }\n\n /**\n * Fetches the user who uploaded a sticker, which the API only returns with `ManageGuildExpressions`.\n *\n * @param stickerId The ID of the sticker.\n */\n public async fetchUser(stickerId: string): Promise<User | null> {\n const sticker = await this.fetch(stickerId, { force: true });\n return sticker.user;\n }\n\n /**\n * Lists the stickers of the guild held in the cache, without calling the API.\n *\n * @remarks\n * It enumerates the whole entity cache, which a Redis store answers from its index: prefer `fetchAll` when the\n * cache may be incomplete.\n */\n public async listCached(): Promise<Sticker[]> {\n const cache = this.cache;\n if (!cache) return [];\n\n const prefix = `${this.guildId}:`;\n const keys = (await cache.keys()).filter((key) => key.startsWith(prefix));\n const values = await Promise.all(keys.map((key) => cache.get(key)));\n return Promise.all(\n values.filter((value) => value !== undefined).map((value) => this.hydrate(value)),\n );\n }\n\n protected async fetchRaw(stickerId: string) {\n const sticker = await this.client.api.guilds.getSticker(this.guildId, stickerId);\n return { ...sticker, guild_id: this.guildId };\n }\n\n private store(sticker: APISticker): Promise<Sticker> {\n return this._add({ ...sticker, guild_id: this.guildId });\n }\n}\n","import type { Awaitable, CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n GatewayDispatchEvents,\n GatewayOpcodes,\n type APIGuild,\n type APIIncidentsData,\n type APIVoiceRegion,\n type RESTGetAPIGuildVanityUrlResult,\n type RESTPatchAPIGuildJSONBody,\n type RESTPostAPIGuildsJSONBody,\n type RESTPutAPIGuildIncidentActionsJSONBody,\n type APIApplicationCommand,\n type APIGuildScheduledEvent,\n type APIThreadChannel,\n type AuditLogEvent,\n type GuildOnboardingMode,\n type GuildOnboardingPromptType,\n type APIGuildWelcomeScreen,\n type APIGuildOnboarding,\n type RESTPatchAPIGuildWelcomeScreenJSONBody,\n type RESTPatchAPIGuildWidgetSettingsJSONBody,\n type RESTPutAPIGuildOnboardingJSONBody,\n} from \"discord-api-types/v10\";\nimport { applyGatewayDispatch } from \"@wolfstar/plugin-cache\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { AnonymousGuild } from \"../structures/guilds/AnonymousGuild.js\";\nimport {\n Guild,\n GuildChannelFields,\n type GuildEditOptions,\n type GuildRelations,\n} from \"../structures/guilds/Guild.js\";\nimport { bindClient } from \"../structures/Structure.js\";\nimport { resolveAuditLogTarget, type AuditLogEntities } from \"../util/auditLogs.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { GuildPreview } from \"../structures/guilds/GuildPreview.js\";\nimport { GuildAuditLogsEntry } from \"../structures/guilds/GuildAuditLogsEntry.js\";\nimport { GuildOnboarding } from \"../structures/guilds/GuildOnboarding.js\";\nimport type { Integration } from \"../structures/guilds/Integration.js\";\nimport {\n ReactionEmoji,\n type EmojiIdentifierResolvable,\n} from \"../structures/emojis/ReactionEmoji.js\";\nimport { WelcomeScreen } from \"../structures/guilds/WelcomeScreen.js\";\nimport type { AutoModerationRule } from \"../structures/automoderation/AutoModerationRule.js\";\nimport type { User } from \"../structures/users/User.js\";\nimport type { Webhook } from \"../structures/webhooks/Webhook.js\";\nimport { resolveId, type IdResolvable } from \"../util/channels.js\";\nimport { SystemChannelFlagsBitField } from \"../util/flags.js\";\nimport { CachedManager } from \"./CachedManager.js\";\nimport { AutoModerationRuleManager } from \"./AutoModerationRuleManager.js\";\nimport { GuildBanManager } from \"./GuildBanManager.js\";\nimport { GuildChannelManager } from \"./GuildChannelManager.js\";\nimport { GuildIntegrationManager } from \"./GuildIntegrationManager.js\";\nimport { GuildScheduledEventManager } from \"./GuildScheduledEventManager.js\";\nimport { GuildSoundboardSoundManager } from \"./GuildSoundboardSoundManager.js\";\nimport { StageInstanceManager } from \"./StageInstanceManager.js\";\nimport type { AnyThreadChannel } from \"./ThreadManager.js\";\nimport { GuildEmojiManager } from \"./GuildEmojiManager.js\";\nimport { GuildInviteManager } from \"./GuildInviteManager.js\";\nimport { GuildStickerManager } from \"./GuildStickerManager.js\";\n\n/**\n * Until when to pause invites and direct messages in a guild, at most 24 hours ahead; `null` resumes them.\n */\nexport interface GuildIncidentActionsOptions {\n invitesDisabledUntil?: Date | number | null;\n dmsDisabledUntil?: Date | number | null;\n}\n\n/**\n * The options to fetch a page of a guild's audit log with.\n */\nexport interface GuildAuditLogsFetchOptions {\n /**\n * Only the entries of this user's actions.\n */\n user?: IdResolvable;\n /**\n * Only the entries of this action.\n */\n type?: AuditLogEvent;\n /**\n * The entry (or ID) to fetch entries before.\n */\n before?: IdResolvable;\n after?: IdResolvable;\n /**\n * How many entries to fetch, up to 100.\n */\n limit?: number;\n}\n\n/**\n * A page of a guild's audit log, with the entities its entries refer to.\n */\nexport interface GuildAuditLogs {\n entries: GuildAuditLogsEntry[];\n users: User[];\n webhooks: Webhook[];\n autoModerationRules: AutoModerationRule[];\n threads: AnyThreadChannel[];\n /**\n * The integrations the entries refer to, partial: an ID, a name, a type, and an account.\n */\n integrations: Integration[];\n applicationCommands: APIApplicationCommand[];\n guildScheduledEvents: APIGuildScheduledEvent[];\n}\n\n/**\n * A channel to suggest in a welcome screen.\n */\nexport interface WelcomeChannelData {\n channel: IdResolvable;\n description: string;\n emoji?: EmojiIdentifierResolvable | null;\n}\n\n/**\n * The options to edit a welcome screen with.\n */\nexport interface GuildWelcomeScreenEditOptions {\n enabled?: boolean;\n description?: string | null;\n welcomeChannels?: readonly WelcomeChannelData[];\n reason?: string;\n}\n\n/**\n * The widget settings of a guild.\n */\nexport interface GuildWidgetSettings {\n enabled: boolean;\n /**\n * The channel the widget's invite leads to.\n */\n channelId: string | null;\n}\n\n/**\n * The options to edit the widget settings of a guild with.\n */\nexport interface GuildWidgetSettingsEditOptions {\n enabled?: boolean;\n channel?: IdResolvable | null;\n reason?: string;\n}\n\n/**\n * An answer of an onboarding prompt. Without an ID, it is a new one.\n */\nexport interface GuildOnboardingPromptOptionData {\n id?: string;\n title: string;\n description?: string | null;\n channels?: readonly IdResolvable[];\n roles?: readonly IdResolvable[];\n emoji?: EmojiIdentifierResolvable | null;\n}\n\n/**\n * A question of an onboarding. Without an ID, it is a new one.\n */\nexport interface GuildOnboardingPromptData {\n id?: string;\n title: string;\n options: readonly GuildOnboardingPromptOptionData[];\n type?: GuildOnboardingPromptType;\n singleSelect?: boolean;\n required?: boolean;\n inOnboarding?: boolean;\n}\n\n/**\n * The options to edit an onboarding with. The prompts replace every existing one.\n */\nexport interface GuildOnboardingEditOptions {\n prompts?: readonly GuildOnboardingPromptData[];\n defaultChannels?: readonly IdResolvable[];\n enabled?: boolean;\n mode?: GuildOnboardingMode;\n reason?: string;\n}\n\n/**\n * Manages the {@link Guild}s known to the client.\n */\nexport class GuildManager extends CachedManager<\"guilds\", Guild, [guildId: string]> {\n public constructor(client: GatewayClient) {\n super(client, \"guilds\");\n }\n\n public createStructure(data: CacheEntityTypes[\"guilds\"]): Guild {\n return new Guild(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"guilds\"]): string {\n return data.id;\n }\n\n /**\n * Builds a guild, resolving its AFK, system, widget, rules, public updates, and safety alerts channels from the\n * cache.\n *\n * @internal\n */\n public override _hydrate(data: CacheEntityTypes[\"guilds\"]): Awaitable<Guild> {\n const relations: GuildRelations = {};\n // The channels resolve their guild to this very structure, rather than reading it again.\n const guild = bindClient(new Guild(data, relations), this.client);\n const fields = Object.entries(GuildChannelFields) as [keyof GuildRelations, string][];\n return whenAll(\n fields.map(([, key]) => {\n const channelId = (data as unknown as Record<string, string | null | undefined>)[key];\n return channelId ? this.client.channels._getInGuild(channelId, guild) : null;\n }),\n (channels) => {\n for (const [index, [name]] of fields.entries()) relations[name] = channels[index] ?? null;\n return guild;\n },\n );\n }\n\n /**\n * Gets a guild from the cache without resolving its channels, for the relations of other structures: a message\n * resolving its guild should not read six more channels. Its channel getters fall back to a synchronous cache.\n *\n * @param guildId The ID of the guild.\n * @internal\n */\n public _getShallow(guildId: string): Awaitable<Guild | undefined> {\n return whenAll([this.cache?.get(guildId)], ([raw]) =>\n raw === undefined ? undefined : bindClient(this.createStructure(raw), this.client),\n );\n }\n\n public resolveKey(guildId: string): string {\n return guildId;\n }\n\n /**\n * Gets the manager of a guild's scheduled events.\n *\n * @param guildId The ID of the guild.\n */\n public scheduledEvents(guildId: string): GuildScheduledEventManager {\n return new GuildScheduledEventManager(this.client, guildId);\n }\n\n /**\n * Gets the manager of a guild's stage instances.\n *\n * @param guildId The ID of the guild.\n */\n public stageInstances(guildId: string): StageInstanceManager {\n return new StageInstanceManager(this.client, guildId);\n }\n\n /**\n * Gets the manager of a guild's soundboard sounds.\n *\n * @param guildId The ID of the guild.\n */\n public soundboardSounds(guildId: string): GuildSoundboardSoundManager {\n return new GuildSoundboardSoundManager(this.client, guildId);\n }\n\n /**\n * Gets the manager of a guild's integrations.\n *\n * @param guildId The ID of the guild.\n */\n public integrations(guildId: string): GuildIntegrationManager {\n return new GuildIntegrationManager(this.client, guildId);\n }\n\n /**\n * Fetches the welcome screen of a guild.\n *\n * @param guildId The ID of the guild.\n */\n public async fetchWelcomeScreen(guildId: string): Promise<WelcomeScreen> {\n const screen = await this.client.api.guilds.getWelcomeScreen(guildId);\n return this.welcomeScreen(guildId, screen);\n }\n\n /**\n * Edits the welcome screen of a guild.\n *\n * @param guildId The ID of the guild.\n * @param options The changes to apply.\n */\n public async editWelcomeScreen(\n guildId: string,\n options: GuildWelcomeScreenEditOptions,\n ): Promise<WelcomeScreen> {\n const body: RESTPatchAPIGuildWelcomeScreenJSONBody = {\n enabled: options.enabled,\n description: options.description,\n welcome_channels: options.welcomeChannels?.map((channel) => {\n const emoji = channel.emoji ? ReactionEmoji.resolvePartial(channel.emoji) : null;\n return {\n channel_id: resolveId(channel.channel),\n description: channel.description,\n emoji_id: emoji?.id ?? null,\n emoji_name: emoji?.name ?? null,\n };\n }),\n };\n const screen = await this.client.api.guilds.editWelcomeScreen(guildId, body, {\n reason: options.reason,\n });\n return this.welcomeScreen(guildId, screen);\n }\n\n /**\n * Fetches whether the widget of a guild is enabled, and its channel.\n *\n * @param guildId The ID of the guild.\n */\n public async fetchWidgetSettings(guildId: string): Promise<GuildWidgetSettings> {\n const settings = await this.client.api.guilds.getWidgetSettings(guildId);\n return { enabled: settings.enabled, channelId: settings.channel_id };\n }\n\n /**\n * Edits the widget settings of a guild, and patches the cached guild.\n *\n * @param guildId The ID of the guild.\n * @param options Whether to enable the widget, and its channel.\n */\n public async editWidgetSettings(\n guildId: string,\n options: GuildWidgetSettingsEditOptions,\n ): Promise<GuildWidgetSettings> {\n const body: RESTPatchAPIGuildWidgetSettingsJSONBody = {\n enabled: options.enabled,\n channel_id:\n options.channel === undefined ? undefined : options.channel && resolveId(options.channel),\n };\n const settings = await this.client.api.guilds.editWidgetSettings(guildId, body, {\n reason: options.reason,\n });\n const cached = await this.cache?.get(guildId);\n if (cached) {\n await this.cache!.set(guildId, {\n ...cached,\n widget_enabled: settings.enabled,\n widget_channel_id: settings.channel_id,\n });\n }\n\n return { enabled: settings.enabled, channelId: settings.channel_id };\n }\n\n /**\n * Fetches the onboarding of a guild.\n *\n * @param guildId The ID of the guild.\n */\n public async fetchOnboarding(guildId: string): Promise<GuildOnboarding> {\n const onboarding = await this.client.api.guilds.getOnboarding(guildId);\n return this.onboarding(guildId, onboarding);\n }\n\n /**\n * Edits the onboarding of a guild.\n *\n * @param guildId The ID of the guild.\n * @param options The changes to apply. The prompts replace every existing one.\n */\n public async editOnboarding(\n guildId: string,\n options: GuildOnboardingEditOptions,\n ): Promise<GuildOnboarding> {\n const body: RESTPutAPIGuildOnboardingJSONBody = {\n prompts: options.prompts?.map((prompt) => ({\n id: prompt.id ?? placeholderId(),\n title: prompt.title,\n type: prompt.type,\n single_select: prompt.singleSelect,\n required: prompt.required,\n in_onboarding: prompt.inOnboarding,\n options: prompt.options.map((option) => {\n const emoji = option.emoji ? ReactionEmoji.resolvePartial(option.emoji) : null;\n return {\n id: option.id ?? placeholderId(),\n title: option.title,\n description: option.description,\n channel_ids: option.channels?.map(resolveId),\n role_ids: option.roles?.map(resolveId),\n emoji_id: emoji?.id,\n emoji_name: emoji?.name,\n emoji_animated: emoji?.animated,\n };\n }),\n })),\n default_channel_ids: options.defaultChannels?.map(resolveId),\n enabled: options.enabled,\n mode: options.mode,\n };\n const onboarding = await this.client.api.guilds.editOnboarding(guildId, body, {\n reason: options.reason,\n });\n return this.onboarding(guildId, onboarding);\n }\n\n /**\n * Gets the manager of a guild's bans.\n *\n * @param guildId The ID of the guild.\n */\n public bans(guildId: string): GuildBanManager {\n return new GuildBanManager(this.client, guildId);\n }\n\n /**\n * Gets the manager of a guild's auto moderation rules.\n *\n * @param guildId The ID of the guild.\n */\n public autoModerationRules(guildId: string): AutoModerationRuleManager {\n return new AutoModerationRuleManager(this.client, guildId);\n }\n\n /**\n * Fetches a page of a guild's audit log, newest first, and caches its users.\n *\n * @param guildId The ID of the guild.\n * @param options Which user and action to filter by, and the page.\n */\n public async fetchAuditLogs(\n guildId: string,\n options: GuildAuditLogsFetchOptions = {},\n ): Promise<GuildAuditLogs> {\n const log = await this.client.api.guilds.getAuditLogs(guildId, {\n user_id: options.user && resolveId(options.user),\n action_type: options.type,\n before: options.before && resolveId(options.before),\n after: options.after && resolveId(options.after),\n limit: options.limit,\n });\n const [users, guild] = await Promise.all([\n Promise.all(log.users.map((user) => this.client.users._add(user))),\n this.cachedGuild(guildId),\n ]);\n const usersById = new Map(users.map((user) => [user.id, user]));\n const rules = this.autoModerationRules(guildId);\n const integrations = this.integrations(guildId);\n const [webhooks, autoModerationRules, threads, pageIntegrations] = await Promise.all([\n Promise.all(log.webhooks.map((webhook) => this.client.webhooks.hydrate(webhook))),\n Promise.all(log.auto_moderation_rules.map((rule) => rules.hydrate(rule))),\n Promise.all(\n log.threads.map((thread) => this.client.threads.hydrate(thread as APIThreadChannel)),\n ),\n // Partial: the page only holds an ID, a name, a type, and an account.\n Promise.all(\n log.integrations.map((integration) =>\n integrations.hydrate({ ...integration, guild_id: guildId } as never),\n ),\n ),\n ]);\n const entities: AuditLogEntities = {\n users: usersById,\n webhooks: new Map(webhooks.map((webhook) => [webhook.id, webhook])),\n integrations: new Map(pageIntegrations.map((integration) => [integration.id, integration])),\n applicationCommands: new Map(\n log.application_commands.map((command) => [command.id, command]),\n ),\n };\n\n return {\n entries: await Promise.all(\n log.audit_log_entries.map(async (raw) => {\n const entry = { ...raw, guild_id: guildId };\n return bindClient(\n new GuildAuditLogsEntry(entry, {\n executor: (entry.user_id && usersById.get(entry.user_id)) || null,\n guild,\n target: await resolveAuditLogTarget(this.client, entry, entities),\n }),\n this.client,\n );\n }),\n ),\n users,\n webhooks,\n autoModerationRules,\n threads,\n integrations: pageIntegrations,\n applicationCommands: log.application_commands,\n guildScheduledEvents: log.guild_scheduled_events,\n };\n }\n\n /**\n * Gets the manager of a guild's channels.\n *\n * @param guildId The ID of the guild.\n */\n public channels(guildId: string): GuildChannelManager {\n return new GuildChannelManager(this.client, guildId);\n }\n\n /**\n * Gets the manager of a guild's custom emojis.\n *\n * @param guildId The ID of the guild.\n */\n public emojis(guildId: string): GuildEmojiManager {\n return new GuildEmojiManager(this.client, guildId);\n }\n\n /**\n * Gets the manager of a guild's custom stickers.\n *\n * @param guildId The ID of the guild.\n */\n public stickers(guildId: string): GuildStickerManager {\n return new GuildStickerManager(this.client, guildId);\n }\n\n /**\n * Gets the manager of a guild's invites.\n *\n * @param guildId The ID of the guild.\n */\n public invites(guildId: string): GuildInviteManager {\n return new GuildInviteManager(this.client, guildId);\n }\n\n /**\n * Lists the guilds the bot is in, as the partial guilds the API returns, paginated by guild ID.\n *\n * @param options How many guilds to list (up to 200), around which guild ID, and whether to include counts.\n */\n public async fetchPartials(\n options: { limit?: number; before?: string; after?: string; withCounts?: boolean } = {},\n ): Promise<AnonymousGuild[]> {\n const guilds = await this.client.api.users.getGuilds({\n limit: options.limit,\n before: options.before,\n after: options.after,\n with_counts: options.withCounts,\n });\n return guilds.map((guild) => new AnonymousGuild(guild));\n }\n\n /**\n * Creates a guild owned by the bot, which Discord only allows to bots in fewer than 10 guilds.\n *\n * @param options The guild's name and initial setup.\n */\n public async create(options: RESTPostAPIGuildsJSONBody): Promise<Guild> {\n const guild = await this.client.api.guilds.create(options);\n return this.store(guild);\n }\n\n /**\n * Edits a guild.\n *\n * @param guildId The ID of the guild.\n * @param options The changes to apply.\n */\n public async edit(guildId: string, options: GuildEditOptions): Promise<Guild> {\n const body: RESTPatchAPIGuildJSONBody = {\n name: options.name,\n description: options.description,\n features: options.features,\n owner_id: options.owner,\n verification_level: options.verificationLevel,\n default_message_notifications: options.defaultMessageNotifications,\n explicit_content_filter: options.explicitContentFilter,\n afk_channel_id: options.afkChannel,\n afk_timeout: options.afkTimeout,\n icon: options.icon,\n splash: options.splash,\n discovery_splash: options.discoverySplash,\n banner: options.banner,\n system_channel_id: options.systemChannel,\n system_channel_flags:\n options.systemChannelFlags === undefined\n ? undefined\n : Number(SystemChannelFlagsBitField.resolve(options.systemChannelFlags)),\n rules_channel_id: options.rulesChannel,\n public_updates_channel_id: options.publicUpdatesChannel,\n preferred_locale: options.preferredLocale,\n premium_progress_bar_enabled: options.premiumProgressBarEnabled,\n safety_alerts_channel_id: options.safetyAlertsChannel,\n };\n const guild = await this.client.api.guilds.edit(guildId, body, {\n reason: options.reason,\n });\n return this.store(guild);\n }\n\n /**\n * Makes the bot leave a guild, and drops it from the cache with everything it scopes.\n *\n * @param guildId The ID of the guild.\n */\n public async leave(guildId: string): Promise<void> {\n await this.client.api.users.leaveGuild(guildId);\n await this.forget(guildId);\n }\n\n /**\n * Deletes a guild the bot owns, and drops it from the cache with everything it scopes.\n *\n * @param guildId The ID of the guild.\n */\n public async delete(guildId: string): Promise<void> {\n await this.client.api.guilds.delete(guildId);\n await this.forget(guildId);\n }\n\n /**\n * Fetches the public preview of a guild.\n *\n * @param guildId The ID of the guild.\n */\n public async fetchPreview(guildId: string): Promise<GuildPreview> {\n return new GuildPreview(await this.client.api.guilds.getPreview(guildId));\n }\n\n /**\n * Fetches the voice regions available to a guild.\n *\n * @param guildId The ID of the guild.\n */\n public async fetchVoiceRegions(guildId: string): Promise<APIVoiceRegion[]> {\n return this.client.api.guilds.getVoiceRegions(guildId);\n }\n\n /**\n * Fetches the vanity invite code of a guild and how many times it was used.\n *\n * @param guildId The ID of the guild.\n */\n public async fetchVanityData(guildId: string): Promise<RESTGetAPIGuildVanityUrlResult> {\n return this.client.api.guilds.getVanityURL(guildId);\n }\n\n /**\n * Pauses invites or direct messages in a guild for up to a day.\n *\n * @param guildId The ID of the guild.\n * @param options Until when to pause each, `null` to resume.\n */\n public async setIncidentActions(\n guildId: string,\n options: GuildIncidentActionsOptions,\n ): Promise<APIIncidentsData> {\n const body: RESTPutAPIGuildIncidentActionsJSONBody = {\n invites_disabled_until: toISO(options.invitesDisabledUntil),\n dms_disabled_until: toISO(options.dmsDisabledUntil),\n };\n const incidents = await this.client.api.guilds.editIncidentActions(guildId, body);\n const cached = await this.cache?.get(guildId);\n if (cached) await this.cache!.set(guildId, { ...cached, incidents_data: incidents });\n return incidents;\n }\n\n protected async fetchRaw(guildId: string) {\n return this.client.api.guilds.get(guildId, { with_counts: true });\n }\n\n private store(guild: APIGuild): Promise<Guild> {\n return this._add(guild);\n }\n\n // Resolves the guild of a welcome screen, and the channels and custom emojis of its welcome channels.\n private async welcomeScreen(\n guildId: string,\n screen: APIGuildWelcomeScreen,\n ): Promise<WelcomeScreen> {\n const channels = screen.welcome_channels;\n const [guild, cachedChannels, emojis] = await Promise.all([\n this.cachedGuild(guildId),\n cachedMap(\n channels.map((channel) => channel.channel_id),\n (id) => this.client.channels.get(id),\n ),\n cachedMap(\n channels.flatMap((channel) => (channel.emoji_id ? [channel.emoji_id] : [])),\n (id) => this.emojis(guildId).get(id),\n ),\n ]);\n return bindClient(\n new WelcomeScreen(\n { ...screen, guild_id: guildId },\n { guild, channels: cachedChannels, emojis },\n ),\n this.client,\n );\n }\n\n // Resolves the guild of an onboarding, and the channels, roles, and custom emojis its prompts refer to.\n private async onboarding(\n guildId: string,\n onboarding: APIGuildOnboarding,\n ): Promise<GuildOnboarding> {\n const options = onboarding.prompts.flatMap((prompt) => prompt.options);\n const [guild, channels, roles, emojis] = await Promise.all([\n this.cachedGuild(guildId),\n cachedMap(\n [...onboarding.default_channel_ids, ...options.flatMap((option) => option.channel_ids)],\n (id) => this.client.channels.get(id),\n ),\n cachedMap(\n options.flatMap((option) => option.role_ids),\n (id) => this.client.roles.get(guildId, id),\n ),\n cachedMap(\n options.flatMap((option) => (option.emoji?.id ? [option.emoji.id] : [])),\n (id) => this.emojis(guildId).get(id),\n ),\n ]);\n return bindClient(\n new GuildOnboarding(onboarding, { guild, channels, roles, emojis }),\n this.client,\n );\n }\n\n // The same cascade as a `GUILD_DELETE`, so no channel, member, or role of the guild outlives it. It is queued with\n // the guild's dispatches, so it never interleaves with one still being written.\n private async forget(guildId: string): Promise<void> {\n const { cache } = this.client;\n if (!cache) return;\n await this.client.runInGuildOrder(guildId, () =>\n applyGatewayDispatch(cache, {\n op: GatewayOpcodes.Dispatch,\n s: 0,\n t: GatewayDispatchEvents.GuildDelete,\n d: { id: guildId },\n }),\n );\n }\n}\n\n// Reads the cached structures of some IDs, skipping the ones that are not cached (or whose read fails).\nasync function cachedMap<Value>(\n ids: readonly string[],\n get: (id: string) => Promise<Value | undefined>,\n): Promise<Map<string, Value>> {\n const unique = [...new Set(ids)];\n const values = await Promise.all(unique.map((id) => get(id).catch(() => undefined)));\n const map = new Map<string, Value>();\n for (const [index, value] of values.entries()) if (value) map.set(unique[index]!, value);\n return map;\n}\n\n// Discord requires an ID on every prompt and option, and takes any snowflake for the new ones.\nlet placeholderSequence = 0;\nfunction placeholderId(): string {\n placeholderSequence = (placeholderSequence + 1) % 4096;\n return String(((BigInt(Date.now()) - 1_420_070_400_000n) << 22n) | BigInt(placeholderSequence));\n}\n\nfunction toISO(value: Date | number | null | undefined): string | null | undefined {\n return value === undefined || value === null ? value : new Date(value).toISOString();\n}\n","import type { GatewayClient } from \"../GatewayClient.js\";\nimport type { Role } from \"../structures/guilds/Role.js\";\n\n/**\n * Manages the roles of one {@link GuildMember}, reading them through the client's role manager.\n *\n * @remarks\n * discord.js's synchronous `member.roles.cache`, `highest`, `color`, ... become the `fetch*` methods here: the roles\n * are read from the (possibly asynchronous) cache, falling back to the API.\n */\nexport class GuildMemberRoleManager {\n public readonly client: GatewayClient;\n public readonly guildId: string;\n public readonly userId: string;\n\n readonly #roleIds: readonly string[];\n\n /**\n * @param client The client.\n * @param guildId The ID of the guild.\n * @param userId The ID of the member's user.\n * @param roleIds The IDs of the member's roles, as known to the member structure.\n */\n public constructor(\n client: GatewayClient,\n guildId: string,\n userId: string,\n roleIds: readonly string[],\n ) {\n this.client = client;\n this.guildId = guildId;\n this.userId = userId;\n this.#roleIds = roleIds;\n }\n\n /**\n * The IDs of the member's roles, `@everyone` excluded.\n */\n public get ids(): readonly string[] {\n return this.#roleIds;\n }\n\n /**\n * Fetches the member's roles, `@everyone` included, highest first.\n */\n public async fetch(): Promise<Role[]> {\n const ids = [...this.#roleIds, this.guildId];\n const roles = await Promise.all(ids.map((id) => this.client.roles.fetch(this.guildId, id)));\n return roles.toSorted((a, b) => b.comparePositionTo(a));\n }\n\n /**\n * Fetches the member's highest role, `@everyone` when they have no other.\n */\n public async fetchHighest(): Promise<Role | null> {\n return (await this.fetch())[0] ?? null;\n }\n\n /**\n * Fetches the role the member is displayed under in the member list, if any.\n */\n public async fetchHoist(): Promise<Role | null> {\n return (await this.fetch()).find((role) => role.hoist) ?? null;\n }\n\n /**\n * Fetches the highest role giving the member a color, if any.\n */\n public async fetchColor(): Promise<Role | null> {\n return (await this.fetch()).find((role) => role.color !== 0) ?? null;\n }\n\n /**\n * Fetches the highest role giving the member an icon, if any.\n */\n public async fetchIcon(): Promise<Role | null> {\n return (await this.fetch()).find((role) => role.icon ?? role.unicodeEmoji) ?? null;\n }\n\n /**\n * Fetches the server booster role, if the member has it.\n */\n public async fetchPremiumSubscriberRole(): Promise<Role | null> {\n return (await this.fetch()).find((role) => role.tags?.premium_subscriber === null) ?? null;\n }\n\n /**\n * Fetches the role Discord manages for the member, when the member is a bot.\n */\n public async fetchBotRole(): Promise<Role | null> {\n return (await this.fetch()).find((role) => role.tags?.bot_id === this.userId) ?? null;\n }\n\n /**\n * Adds roles to the member.\n *\n * @param roles The ID of the role, or several IDs.\n * @param reason The reason for the audit log.\n */\n public async add(roles: string | readonly string[], reason?: string) {\n if (typeof roles === \"string\") {\n return this.client.members.addRole(this.guildId, this.userId, roles, reason);\n }\n\n return this.set([...new Set([...this.#roleIds, ...roles])], reason);\n }\n\n /**\n * Removes roles from the member.\n *\n * @param roles The ID of the role, or several IDs.\n * @param reason The reason for the audit log.\n */\n public async remove(roles: string | readonly string[], reason?: string) {\n if (typeof roles === \"string\") {\n return this.client.members.removeRole(this.guildId, this.userId, roles, reason);\n }\n\n const removed = new Set(roles);\n return this.set(\n this.#roleIds.filter((id) => !removed.has(id)),\n reason,\n );\n }\n\n /**\n * Replaces the member's roles.\n *\n * @param roles The IDs of the roles the member ends up with.\n * @param reason The reason for the audit log.\n */\n public set(roles: readonly string[], reason?: string) {\n return this.client.members.edit(this.guildId, this.userId, { roles, reason });\n }\n}\n","import { DiscordAPIError, type ImageURLOptions } from \"@discordjs/rest\";\nimport type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { APIAvatarDecorationData } from \"discord-api-types/v10\";\nimport type { BanOptions, GuildMemberEditOptions } from \"../../managers/GuildMemberManager.js\";\nimport { GuildMemberRoleManager } from \"../../managers/GuildMemberRoleManager.js\";\nimport { cdn } from \"../../util/cdn.js\";\nimport { GuildMemberFlagsBitField, type GuildMemberFlagsResolvable } from \"../../util/flags.js\";\nimport {\n MessagePayload,\n type MessageCreateOptions,\n type MessagePayloadResolvable,\n} from \"../messages/MessagePayload.js\";\nimport { computeGuildPermissions, computePermissionsIn } from \"../../util/permissions.js\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { PermissionsBitField } from \"../../util/PermissionsBitField.js\";\nimport type { DMChannel } from \"../channels/DMChannel.js\";\nimport type { Message } from \"../messages/Message.js\";\nimport type { Presence } from \"../presences/Presence.js\";\nimport type { VoiceState } from \"../voice/VoiceState.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kPatch, kRelations, Structure } from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\n/**\n * The relations of a {@link GuildMember}, resolved from the cache by `client.members`.\n */\nexport interface GuildMemberRelations {\n user?: User;\n guild?: Guild | null;\n /**\n * The member's voice state, `null` when they are not connected.\n */\n voice?: VoiceState | null;\n presence?: Presence | null;\n}\n\n/**\n * A member of a Discord guild.\n *\n * @remarks\n * Relations are asynchronous, unlike discord.js: `member.roles` reads roles through the (possibly asynchronous)\n * cache, and discord.js's `permissions`, `manageable`, `kickable`, ... are the `fetch*` methods below.\n */\nexport class GuildMember extends Structure<CacheEntityTypes[\"members\"]> {\n declare public [kRelations]: GuildMemberRelations;\n\n protected override optimizeData(data: Partial<CacheEntityTypes[\"members\"]>): void {\n this.optimizeTimestamp(\"joined_at\", data.joined_at);\n this.optimizeTimestamp(\"premium_since\", data.premium_since);\n this.optimizeTimestamp(\"communication_disabled_until\", data.communication_disabled_until);\n }\n\n /**\n * @param data The raw member.\n * @param relations The member's user and guild as resolved from the cache, by `client.members`.\n */\n public constructor(data: CacheEntityTypes[\"members\"], relations: GuildMemberRelations = {}) {\n super(data, relations);\n }\n\n /**\n * The ID of the member's user, or `null` if the payload did not include it.\n */\n public get id(): string | null {\n return this[kData].user?.id ?? null;\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n /**\n * The guild, from the cache. `null` when the guild is not cached, or when the member was not built by a manager: use\n * `fetchGuild()` to always get it.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * Fetches the guild, cache first.\n */\n public fetchGuild(): Promise<Guild> {\n return this.client.guilds.fetch(this.guildId);\n }\n\n public override [kPatch](data: Readonly<Partial<CacheEntityTypes[\"members\"]>>): this {\n // A payload carrying the user is fresher than the one resolved when the member was built.\n if (data.user) this.dropRelations(\"user\");\n return super[kPatch](data);\n }\n\n /**\n * The member's user, or `null` if the payload did not include it. Resolved from `client.users` when the member\n * comes from a manager.\n */\n public get user(): User | null {\n const { user } = this[kData];\n return this[kRelations].user ?? (user ? new User(user) : null);\n }\n\n public get nickname(): string | null {\n return this[kData].nick ?? null;\n }\n\n /**\n * The name to show for this member: their nickname, falling back to their user's display name.\n */\n public get displayName(): string | null {\n return this.nickname ?? this.user?.displayName ?? null;\n }\n\n /**\n * The IDs of the member's roles, excluding the implicit `@everyone` role.\n */\n public get roleIds(): readonly string[] {\n return this[kData].roles;\n }\n\n /**\n * The member's roles. It needs the member's user ID, which every payload but some partial ones carries.\n */\n public get roles(): GuildMemberRoleManager {\n return new GuildMemberRoleManager(this.client, this.guildId, this.requireId(), this.roleIds);\n }\n\n public get joinedTimestamp(): number | null {\n return this.optimizedTimestamp(\"joined_at\");\n }\n\n public get joinedAt(): Date | null {\n const { joinedTimestamp } = this;\n return joinedTimestamp === null ? null : new Date(joinedTimestamp);\n }\n\n /**\n * When the member started boosting the guild, `null` if they are not boosting it.\n */\n public get premiumSinceTimestamp(): number | null {\n return this.optimizedTimestamp(\"premium_since\");\n }\n\n public get premiumSince(): Date | null {\n const { premiumSinceTimestamp } = this;\n return premiumSinceTimestamp === null ? null : new Date(premiumSinceTimestamp);\n }\n\n public get communicationDisabledUntilTimestamp(): number | null {\n return this.optimizedTimestamp(\"communication_disabled_until\");\n }\n\n public get communicationDisabledUntil(): Date | null {\n const { communicationDisabledUntilTimestamp } = this;\n return communicationDisabledUntilTimestamp === null\n ? null\n : new Date(communicationDisabledUntilTimestamp);\n }\n\n public get pending(): boolean {\n return this[kData].pending ?? false;\n }\n\n /**\n * Whether the member is deafened in voice channels, by a moderator.\n */\n public get deaf(): boolean {\n return this[kData].deaf ?? false;\n }\n\n /**\n * Whether the member is muted in voice channels, by a moderator.\n */\n public get mute(): boolean {\n return this[kData].mute ?? false;\n }\n\n public get flags(): Readonly<GuildMemberFlagsBitField> {\n return new GuildMemberFlagsBitField(this[kData].flags ?? 0).freeze();\n }\n\n /**\n * The member's guild avatar hash, if any.\n */\n public get avatar(): string | null {\n return this[kData].avatar ?? null;\n }\n\n /**\n * The member's guild banner hash, if any.\n */\n public get banner(): string | null {\n return this[kData].banner ?? null;\n }\n\n /**\n * The member's guild avatar decoration, if any.\n */\n public get avatarDecorationData(): APIAvatarDecorationData | null {\n return this[kData].avatar_decoration_data ?? null;\n }\n\n /**\n * Whether the member is timed out right now.\n */\n public isCommunicationDisabled(): boolean {\n const until = this.communicationDisabledUntilTimestamp;\n return until !== null && until > Date.now();\n }\n\n /**\n * Gets the URL of the member's guild avatar, or `null` if they have none.\n * @param options The image options.\n */\n public avatarURL(options?: ImageURLOptions): string | null {\n const { avatar, id } = this;\n return avatar && id ? cdn.guildMemberAvatar(this.guildId, id, avatar, options) : null;\n }\n\n /**\n * Gets the URL of the member's guild avatar, falling back to their user's avatar.\n * @param options The image options.\n */\n public displayAvatarURL(options?: ImageURLOptions): string | null {\n return this.avatarURL(options) ?? this.user?.displayAvatarURL(options) ?? null;\n }\n\n /**\n * Gets the URL of the member's guild banner, or `null` if they have none.\n * @param options The image options.\n */\n public bannerURL(options?: ImageURLOptions): string | null {\n const { banner, id } = this;\n return banner && id ? cdn.guildMemberBanner(this.guildId, id, banner, options) : null;\n }\n\n /**\n * Gets the URL of the member's guild banner, falling back to their user's banner when known.\n * @param options The image options.\n */\n public displayBannerURL(options?: ImageURLOptions): string | null {\n return this.bannerURL(options) ?? this.user?.bannerURL(options) ?? null;\n }\n\n /**\n * Gets the URL of the member's guild avatar decoration, or `null` if they have none.\n */\n public avatarDecorationURL(): string | null {\n const asset = this.avatarDecorationData?.asset;\n return asset ? cdn.avatarDecoration(asset) : null;\n }\n\n /**\n * Gets the URL of the member's guild avatar decoration, falling back to their user's.\n */\n public displayAvatarDecorationURL(): string | null {\n return this.avatarDecorationURL() ?? this.user?.avatarDecorationURL() ?? null;\n }\n\n /**\n * Computes the member's guild-wide permissions, before channel overwrites.\n */\n public async fetchPermissions(): Promise<Readonly<PermissionsBitField>> {\n const client = this.client;\n const guild = await client.guilds.fetch(this.guildId);\n const roles = await this.roles.fetch();\n return computeGuildPermissions({\n guildId: this.guildId,\n ownerId: guild.ownerId,\n userId: this.requireId(),\n memberRoleIds: this.roleIds,\n roles: roles.map((role) => role.toJSON()),\n });\n }\n\n /**\n * Fetches the member's permissions in a channel: their guild permissions with the channel's overwrites applied.\n * discord.js: `member.permissionsIn(channel)`.\n *\n * @param channel The channel, or its ID. Threads use their parent's overwrites.\n */\n public fetchPermissionsIn(channel: AnyChannel | string): Promise<Readonly<PermissionsBitField>> {\n return computePermissionsIn(channel, this);\n }\n\n /**\n * The member's voice state, from the cache, like discord.js's `GuildMember#voice`: `null` when they are not\n * connected, when the voice state is not cached (it needs the `GuildVoiceStates` intent), or when the member was not\n * built by a manager. Use {@link GuildMember.fetchVoiceState} to ask the API.\n */\n public get voice(): VoiceState | null {\n return this[kRelations].voice ?? null;\n }\n\n /**\n * The member's presence, from the cache, like discord.js's `GuildMember#presence`: `null` when it is not cached\n * (it needs the `GuildPresences` intent), or when the member was not built by a manager.\n */\n public get presence(): Presence | null {\n return this[kRelations].presence ?? null;\n }\n\n /**\n * Fetches the member's voice state, cache first. discord.js: `member.voice`.\n *\n * @returns The voice state, or `null` when the member is not connected to voice.\n */\n public async fetchVoiceState(): Promise<VoiceState | null> {\n try {\n return await this.client.voiceStates.fetch(this.guildId, this.requireId());\n } catch (error) {\n // Discord answers 404 (Unknown Voice State) for members who are not connected.\n if (error instanceof DiscordAPIError && error.status === 404) return null;\n throw error;\n }\n }\n\n /**\n * Gets the member's presence from the cache. discord.js: `member.presence`.\n *\n * @returns The presence, or `null` when it is not cached (the bot needs the `GuildPresences` intent).\n */\n public async fetchPresence(): Promise<Presence | null> {\n return (await this.client.presences.get(this.guildId, this.requireId())) ?? null;\n }\n\n /**\n * Fetches the color the member's name is displayed in, `0` when none of their roles has one.\n */\n public async fetchDisplayColor(): Promise<number> {\n return (await this.roles.fetchColor())?.color ?? 0;\n }\n\n /**\n * Fetches the color the member's name is displayed in, as a `#rrggbb` string.\n */\n public async fetchDisplayHexColor(): Promise<`#${string}`> {\n return `#${(await this.fetchDisplayColor()).toString(16).padStart(6, \"0\")}`;\n }\n\n /**\n * Whether the bot ranks above the member: it is not the guild owner, not the bot itself, and the bot's highest\n * role is higher than theirs (or the bot owns the guild).\n */\n public async fetchManageable(): Promise<boolean> {\n const client = this.client;\n const id = this.requireId();\n const guild = await client.guilds.fetch(this.guildId);\n const meId = client.user?.id ?? client.id;\n if (id === guild.ownerId || id === meId) return false;\n if (meId === guild.ownerId) return true;\n\n const me = await client.members.fetchMe(this.guildId);\n const [mine, theirs] = await Promise.all([me.roles.fetchHighest(), this.roles.fetchHighest()]);\n return mine !== null && theirs !== null && mine.comparePositionTo(theirs) > 0;\n }\n\n /**\n * Whether the bot can kick the member: it outranks them and has `KickMembers`.\n */\n public fetchKickable(): Promise<boolean> {\n return this.managedWith(\"KickMembers\");\n }\n\n /**\n * Whether the bot can ban the member: it outranks them and has `BanMembers`.\n */\n public fetchBannable(): Promise<boolean> {\n return this.managedWith(\"BanMembers\");\n }\n\n /**\n * Whether the bot can time the member out: it outranks them, has `ModerateMembers`, and they are no administrator.\n */\n public async fetchModeratable(): Promise<boolean> {\n if (!(await this.managedWith(\"ModerateMembers\"))) return false;\n return !(await this.fetchPermissions()).has(\"Administrator\");\n }\n\n /**\n * Edits the member.\n *\n * @param options The fields to edit.\n * @returns This member, patched.\n */\n public async edit(options: GuildMemberEditOptions): Promise<this> {\n const member = await this.client.members.edit(this.guildId, this.requireId(), options);\n return this[kPatch](member.toJSON());\n }\n\n public setNickname(nick: string | null, reason?: string): Promise<this> {\n return this.edit({ nick, reason });\n }\n\n public setFlags(flags: GuildMemberFlagsResolvable, reason?: string): Promise<this> {\n return this.edit({ flags, reason });\n }\n\n /**\n * Times the member out until a given time, or lifts the timeout with `null`.\n */\n public disableCommunicationUntil(\n communicationDisabledUntil: Date | number | null,\n reason?: string,\n ): Promise<this> {\n return this.edit({ communicationDisabledUntil, reason });\n }\n\n /**\n * Times the member out for a duration in milliseconds, or lifts the timeout with `null`.\n */\n public timeout(duration: number | null, reason?: string): Promise<this> {\n return this.disableCommunicationUntil(duration === null ? null : Date.now() + duration, reason);\n }\n\n public async kick(reason?: string): Promise<this> {\n await this.client.members.kick(this.guildId, this.requireId(), reason);\n return this;\n }\n\n public async ban(options?: BanOptions): Promise<this> {\n await this.client.members.ban(this.guildId, this.requireId(), options);\n return this;\n }\n\n public createDM(): Promise<DMChannel> {\n return this.client.users.createDM(this.requireId());\n }\n\n public deleteDM(): Promise<DMChannel> {\n return this.client.users.deleteDM(this.requireId());\n }\n\n public send(options: MessagePayloadResolvable<MessageCreateOptions>): Promise<Message> {\n return this.client.users.send(this.requireId(), MessagePayload.create(this, options));\n }\n\n /**\n * Whether the member is partial: built from its IDs alone for an event about an uncached member, see\n * `Partials.GuildMember`. Only its IDs (and the user a removal carries) are reliable then, and\n * {@link GuildMember.fetch} completes it.\n */\n public get partial(): boolean {\n return this[kData].joined_at === undefined;\n }\n\n /**\n * Fetches the member from the API and patches this structure with the result.\n */\n public async fetch(): Promise<this> {\n const member = await this.client.members.fetch(this.guildId, this.requireId(), {\n force: true,\n });\n return this[kPatch](member.toJSON());\n }\n\n /**\n * Fetches the member's user, cache first.\n */\n public fetchUser(): Promise<User> {\n return this.client.users.fetch(this.requireId());\n }\n\n /**\n * Whether this member has the same data as another one.\n * @param member The member to compare with.\n */\n public equals(member: GuildMember): boolean {\n return (\n this.id === member.id &&\n this.guildId === member.guildId &&\n this.nickname === member.nickname &&\n this.avatar === member.avatar &&\n this.joinedTimestamp === member.joinedTimestamp &&\n this.premiumSinceTimestamp === member.premiumSinceTimestamp &&\n this.communicationDisabledUntilTimestamp === member.communicationDisabledUntilTimestamp &&\n this.flags.bitField === member.flags.bitField &&\n this.roleIds.length === member.roleIds.length &&\n this.roleIds.every((id) => member.roleIds.includes(id))\n );\n }\n\n public toString(): string {\n return this.id ? `<@${this.id}>` : \"\";\n }\n\n private async managedWith(permission: \"KickMembers\" | \"BanMembers\" | \"ModerateMembers\") {\n if (!(await this.fetchManageable())) return false;\n const me = await this.client.members.fetchMe(this.guildId);\n return (await me.fetchPermissions()).has(permission);\n }\n\n private requireId(): string {\n const { id } = this;\n if (id === null) throw new Error(\"This member has no user data: its ID is unknown\");\n return id;\n }\n}\n","import type { ImageURLOptions } from \"@discordjs/rest\";\nimport type { GatewayActivityAssets } from \"discord-api-types/v10\";\nimport { cdn } from \"../../util/cdn.js\";\nimport { kData, Structure } from \"../Structure.js\";\n\n/**\n * The raw assets of an activity, with the ID of the activity's application.\n */\nexport type RichPresenceAssetsData = GatewayActivityAssets & { application_id?: string | null };\n\n/**\n * The assets (images and their hover texts) of a rich presence activity.\n */\nexport class RichPresenceAssets extends Structure<RichPresenceAssetsData> {\n /**\n * The ID of the application the assets belong to, needed to build the URLs of application assets.\n */\n public get applicationId(): string | null {\n return this[kData].application_id ?? null;\n }\n\n /**\n * The hover text of the large image.\n */\n public get largeText(): string | null {\n return this[kData].large_text ?? null;\n }\n\n /**\n * The hover text of the small image.\n */\n public get smallText(): string | null {\n return this[kData].small_text ?? null;\n }\n\n /**\n * The ID of the large image asset, or an external asset in the `platform:id` form.\n */\n public get largeImage(): string | null {\n return this[kData].large_image ?? null;\n }\n\n /**\n * The ID of the small image asset, or an external asset in the `platform:id` form.\n */\n public get smallImage(): string | null {\n return this[kData].small_image ?? null;\n }\n\n /**\n * Gets the URL of the small image, or `null` if there is none or it comes from an unsupported platform.\n *\n * @param options The image options, ignored for external assets.\n */\n public smallImageURL(options?: ImageURLOptions): string | null {\n const { smallImage } = this;\n if (!smallImage) return null;\n if (smallImage.includes(\":\")) {\n const [platform, id] = smallImage.split(\":\") as [string, string];\n switch (platform) {\n case \"mp\":\n return `https://media.discordapp.net/${id}`;\n default:\n return null;\n }\n }\n\n return this.applicationId ? cdn.appAsset(this.applicationId, smallImage, options) : null;\n }\n\n /**\n * Gets the URL of the large image, or `null` if there is none or it comes from an unsupported platform.\n *\n * @param options The image options, ignored for external assets.\n */\n public largeImageURL(options?: ImageURLOptions): string | null {\n const { largeImage } = this;\n if (!largeImage) return null;\n if (largeImage.includes(\":\")) {\n const [platform, id] = largeImage.split(\":\") as [string, string];\n switch (platform) {\n case \"mp\":\n return `https://media.discordapp.net/${id}`;\n case \"spotify\":\n return `https://i.scdn.co/image/${id}`;\n case \"youtube\":\n return `https://i.ytimg.com/vi/${id}/hqdefault_live.jpg`;\n case \"twitch\":\n return `https://static-cdn.jtvnw.net/previews-ttv/live_user_${id}.png`;\n default:\n return null;\n }\n }\n\n return this.applicationId ? cdn.appAsset(this.applicationId, largeImage, options) : null;\n }\n}\n","import { Activity as BaseActivity } from \"@discordjs/structures\";\nimport type { GatewayActivity } from \"discord-api-types/v10\";\nimport { ActivityFlagsBitField } from \"../../util/flags.js\";\nimport { RichPresenceAssets } from \"./RichPresenceAssets.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, StructureMixin } from \"../Structure.js\";\n\n/**\n * The start and end of an activity.\n */\nexport interface ActivityTimestamps {\n /**\n * When the activity started, if known.\n */\n start: Date | null;\n /**\n * When the activity ends, if known.\n */\n end: Date | null;\n}\n\n/**\n * The party of an activity.\n */\nexport interface ActivityParty {\n /**\n * The ID of the party.\n */\n id: string | null;\n /**\n * The size of the party, as `[current, max]`.\n */\n size: readonly [current: number, max: number] | null;\n}\n\n/**\n * The emoji of a custom status activity.\n */\nexport interface ActivityEmoji {\n /**\n * The ID of the emoji, or `null` for a unicode emoji.\n */\n id: string | null;\n /**\n * The name of the emoji, or the unicode character.\n */\n name: string | null;\n /**\n * Whether the emoji is animated.\n */\n animated: boolean;\n}\n\nexport interface Activity extends StructureMixin<GatewayActivity> {}\n\n/**\n * An activity of a user's presence: `@discordjs/structures`' `Activity`, with its timestamps, party, assets, emoji,\n * and buttons.\n */\nexport class Activity extends BaseActivity {\n /**\n * @param data The raw activity.\n * @param relations The related structures, resolved from the cache.\n */\n public constructor(data: GatewayActivity, relations: object = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n /**\n * The URL of the stream, when the activity is being streamed.\n */\n public override get url(): string | null {\n return this[kData].url ?? null;\n }\n\n /**\n * What the user is currently doing.\n */\n public override get details(): string | null {\n return this[kData].details ?? null;\n }\n\n /**\n * The user's current party status, or the text of a custom status.\n */\n public override get state(): string | null {\n return this[kData].state ?? null;\n }\n\n /**\n * When the activity started and ends, if known.\n */\n public get timestamps(): ActivityTimestamps | null {\n const { timestamps } = this[kData];\n if (!timestamps) return null;\n return {\n start: timestamps.start ? new Date(Number(timestamps.start)) : null,\n end: timestamps.end ? new Date(Number(timestamps.end)) : null,\n };\n }\n\n /**\n * The party of the activity.\n */\n public get party(): ActivityParty | null {\n const { party } = this[kData];\n if (!party) return null;\n return { id: party.id ?? null, size: party.size ?? null };\n }\n\n /**\n * The sync ID of the activity, which is the track ID for Spotify activities.\n *\n * @remarks This field is not documented by Discord.\n */\n public get syncId(): string | null {\n return this[kData].sync_id ?? null;\n }\n\n /**\n * The assets of the activity, when it is a rich presence.\n */\n public get assets(): RichPresenceAssets | null {\n const { assets } = this[kData];\n return assets\n ? new RichPresenceAssets({ ...assets, application_id: this.applicationId })\n : null;\n }\n\n /**\n * The flags describing the activity.\n */\n public override get flags(): Readonly<ActivityFlagsBitField> {\n return new ActivityFlagsBitField(this[kData].flags ?? 0).freeze();\n }\n\n /**\n * The emoji of a custom status activity.\n */\n public get emoji(): ActivityEmoji | null {\n const { emoji } = this[kData];\n if (!emoji) return null;\n return { id: emoji.id ?? null, name: emoji.name, animated: emoji.animated ?? false };\n }\n\n /**\n * The labels of the buttons of a rich presence activity.\n */\n public get buttons(): string[] {\n return (this[kData].buttons ?? []).map((button) =>\n typeof button === \"string\" ? button : button.label,\n );\n }\n\n /**\n * The time at which the activity was added to the user's session.\n */\n public get createdAt(): Date {\n return new Date(this.createdTimestamp);\n }\n\n /**\n * Whether this activity equals another: same name, type, URL, state, details and emoji.\n *\n * @param activity The activity to compare with.\n */\n public equals(activity: Activity | null | undefined): boolean {\n if (this === activity) return true;\n if (!activity) return false;\n return (\n this.name === activity.name &&\n this.type === activity.type &&\n this.url === activity.url &&\n this.state === activity.state &&\n this.details === activity.details &&\n this.emoji?.id === activity.emoji?.id &&\n this.emoji?.name === activity.emoji?.name\n );\n }\n\n public toString(): string {\n return this.name;\n }\n}\n\nMixin(Activity, [StructureMixin]);\n","import { Presence as BasePresence } from \"@discordjs/structures\";\nimport type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n PresenceUpdateStatus,\n type GatewayPresenceClientStatus,\n type PresenceUpdateReceiveStatus,\n} from \"discord-api-types/v10\";\nimport { Activity } from \"./Activity.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport type { GuildMember } from \"../guilds/GuildMember.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, kRelations, StructureMixin } from \"../Structure.js\";\nimport type { User } from \"../users/User.js\";\n\n/**\n * The status of a presence on each of the user's platforms; a missing platform means the user is offline there.\n */\nexport type ClientStatus = GatewayPresenceClientStatus;\n\n/**\n * The relations of a {@link Presence}, resolved from the cache by `client.presences`.\n */\nexport interface PresenceRelations {\n user?: User | null;\n member?: GuildMember | null;\n guild?: Guild | null;\n}\n\nexport interface Presence extends StructureMixin<\n CacheEntityTypes[\"presences\"],\n PresenceRelations\n> {}\n\n/**\n * The presence of a user in a guild, their status and activities: `@discordjs/structures`' `Presence`, with its user,\n * member, and guild, and actions through the client.\n */\nexport class Presence extends BasePresence {\n /**\n * @param data The raw presence.\n * @param relations The user, member, and guild as resolved from the cache, by `client.presences`.\n */\n public constructor(data: CacheEntityTypes[\"presences\"], relations: PresenceRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n public get userId() {\n return this[kData].user.id;\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n /**\n * The status of the user, `offline` when the payload did not include it.\n */\n public override get status(): PresenceUpdateReceiveStatus {\n return this[kData].status ?? PresenceUpdateStatus.Offline;\n }\n\n public get activities(): Activity[] {\n return (this[kData].activities ?? []).map((activity) => new Activity(activity));\n }\n\n /**\n * The status of the user on each of their platforms, `null` when the payload did not include it.\n */\n public get clientStatus(): ClientStatus | null {\n return this[kData].client_status ?? null;\n }\n\n /**\n * The user, from the cache. Presence payloads only carry the user's changed fields.\n */\n public get user(): User | null {\n return this[kRelations].user ?? null;\n }\n\n public get member(): GuildMember | null {\n return this[kRelations].member ?? null;\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n public fetchMember(): Promise<GuildMember> {\n return this.client.members.fetch(this.guildId, this.userId);\n }\n\n public fetchUser(): Promise<User> {\n return this.client.users.fetch(this.userId);\n }\n\n /**\n * Whether this presence has the same status, client status, and activities as another.\n *\n * @param presence The presence to compare with.\n */\n public equals(presence: Presence | null | undefined): boolean {\n if (this === presence) return true;\n if (!presence) return false;\n\n const activities = this.activities;\n const otherActivities = presence.activities;\n return (\n this.status === presence.status &&\n this.clientStatus?.web === presence.clientStatus?.web &&\n this.clientStatus?.mobile === presence.clientStatus?.mobile &&\n this.clientStatus?.desktop === presence.clientStatus?.desktop &&\n activities.length === otherActivities.length &&\n activities.every((activity, index) => activity.equals(otherActivities[index]))\n );\n }\n}\n\nMixin(Presence, [StructureMixin]);\n","import { VoiceState as BaseVoiceState } from \"@discordjs/structures\";\nimport type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport type { GuildMember } from \"../guilds/GuildMember.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, kPatch, kRelations, StructureMixin } from \"../Structure.js\";\nimport type { User } from \"../users/User.js\";\n\n/**\n * The options to edit a voice state with, only applicable in stage channels.\n */\nexport interface VoiceStateEditOptions {\n /**\n * Whether the bot requests to become a speaker. Only available on the bot's own voice state.\n */\n requestToSpeak?: boolean;\n /**\n * Whether the user is suppressed, i.e. moved to the audience.\n */\n suppressed?: boolean;\n}\n\n/**\n * The relations of a {@link VoiceState}, resolved from the cache by `client.voiceStates`.\n */\nexport interface VoiceStateRelations {\n member?: GuildMember | null;\n guild?: Guild | null;\n channel?: AnyChannel | null;\n}\n\nexport interface VoiceState extends StructureMixin<\n CacheEntityTypes[\"voiceStates\"],\n VoiceStateRelations\n> {}\n\n/**\n * The voice state of a guild member: `@discordjs/structures`' `VoiceState`, with its member and guild, and actions\n * through the client.\n *\n * @remarks\n * Unlike `@discordjs/structures`', `deaf` and `mute` also account for the member's own deafen and mute; `serverDeaf`\n * and `serverMute` are the server-wide ones.\n */\nexport class VoiceState extends BaseVoiceState {\n protected override optimizeData(data: Partial<CacheEntityTypes[\"voiceStates\"]>): void {\n this.optimizeTimestamp(\"request_to_speak_timestamp\", data.request_to_speak_timestamp);\n }\n\n /**\n * @param data The raw voice state.\n * @param relations The member and guild as resolved from the cache, by `client.voiceStates`.\n */\n public constructor(data: CacheEntityTypes[\"voiceStates\"], relations: VoiceStateRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n public [kPatch](data: Readonly<Partial<CacheEntityTypes[\"voiceStates\"]>>): this {\n if (data.member) this.dropRelations(\"member\");\n this.dropChangedRelations(data, { channel: \"channel_id\" });\n return StructureMixin.prototype[kPatch].call(this, data) as this;\n }\n\n /**\n * Whether the member is deafened server-wide.\n */\n public get serverDeaf() {\n return this[kData].deaf;\n }\n\n /**\n * Whether the member is muted server-wide.\n */\n public get serverMute() {\n return this[kData].mute;\n }\n\n /**\n * Whether the member is streaming using \"Screen Share\", `false` when the payload did not include it.\n */\n public get streaming() {\n return this[kData].self_stream ?? false;\n }\n\n /**\n * The time at which the member requested to speak, or `null` if they did not. Only meaningful in stage channels.\n */\n public get requestToSpeakAt(): Date | null {\n const timestamp = this.optimizedTimestamp(\"request_to_speak_timestamp\");\n return timestamp === null ? null : new Date(timestamp);\n }\n\n /**\n * Whether the member is deafened, either by themselves or server-wide.\n */\n public override get deaf() {\n return this.serverDeaf || this.selfDeaf;\n }\n\n /**\n * Whether the member is muted, either by themselves or server-wide.\n */\n public override get mute() {\n return this.serverMute || this.selfMute;\n }\n\n /**\n * The member, from the payload or the cache. `null` when neither has it, or when the voice state was not built by a\n * manager.\n */\n public get member(): GuildMember | null {\n return this[kRelations].member ?? null;\n }\n\n /**\n * The guild, from the cache.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * The channel the member is connected to, from the cache, like discord.js's `VoiceState#channel`. `null` when they\n * are disconnected, when the channel is not cached, or when the voice state was not built by a manager.\n */\n public get channel(): AnyChannel | null {\n return this[kRelations].channel ?? null;\n }\n\n public fetchMember(): Promise<GuildMember> {\n return this.client.members.fetch(this.requireGuildId(), this.userId);\n }\n\n public fetchUser(): Promise<User> {\n return this.client.users.fetch(this.userId);\n }\n\n /**\n * Fetches the channel the member is connected to, `null` when they are disconnected.\n */\n public async fetchChannel(): Promise<AnyChannel | null> {\n const { channelId } = this;\n return channelId ? this.client.channels.fetch(channelId) : null;\n }\n\n /**\n * Fetches the voice state from the API, and patches this structure with the result.\n */\n public async fetch(): Promise<this> {\n const state = await this.client.voiceStates.fetch(this.requireGuildId(), this.userId, {\n force: true,\n });\n return this[kPatch](state.toJSON());\n }\n\n /**\n * Mutes or unmutes the member server-wide.\n */\n public setMute(mute = true, reason?: string): Promise<GuildMember> {\n return this.client.members.edit(this.requireGuildId(), this.userId, { mute, reason });\n }\n\n /**\n * Deafens or undeafens the member server-wide.\n */\n public setDeaf(deaf = true, reason?: string): Promise<GuildMember> {\n return this.client.members.edit(this.requireGuildId(), this.userId, { deaf, reason });\n }\n\n /**\n * Moves the member to another voice channel, or disconnects them with `null`.\n */\n public setChannel(channel: string | null, reason?: string): Promise<GuildMember> {\n return this.client.members.edit(this.requireGuildId(), this.userId, {\n channel,\n reason,\n });\n }\n\n public disconnect(reason?: string): Promise<GuildMember> {\n return this.setChannel(null, reason);\n }\n\n /**\n * Edits the voice state in a stage channel.\n *\n * @param options Whether to request to speak (the bot only), and whether the member is suppressed.\n */\n public async edit(options: VoiceStateEditOptions): Promise<this> {\n const target = this.resolveTarget();\n if (target !== \"@me\" && options.requestToSpeak !== undefined) {\n throw new Error(\"Only the bot's own voice state can request to speak\");\n }\n\n const requestToSpeakTimestamp = options.requestToSpeak\n ? new Date().toISOString()\n : options.requestToSpeak === false\n ? null\n : undefined;\n const body = {\n channel_id: this.channelId ?? undefined,\n request_to_speak_timestamp: requestToSpeakTimestamp,\n suppress: options.suppressed,\n };\n if (target === \"@me\") {\n await this.client.api.voice.editVoiceState(this.requireGuildId(), body);\n } else {\n await this.client.api.voice.editUserVoiceState(this.requireGuildId(), target, body);\n }\n\n return this[kPatch]({\n ...(requestToSpeakTimestamp !== undefined && {\n request_to_speak_timestamp: requestToSpeakTimestamp,\n }),\n ...(options.suppressed !== undefined && { suppress: options.suppressed }),\n });\n }\n\n /**\n * Requests to speak in a stage channel, or withdraws the request. The bot's own voice state only.\n */\n public setRequestToSpeak(requestToSpeak = true): Promise<this> {\n return this.edit({ requestToSpeak });\n }\n\n /**\n * Moves the member to the audience of a stage channel, or invites them to speak.\n */\n public setSuppressed(suppressed = true): Promise<this> {\n return this.edit({ suppressed });\n }\n\n private requireGuildId(): string {\n const { guildId } = this;\n if (!guildId) throw new Error(\"This voice state does not belong to a guild\");\n return guildId;\n }\n\n // The bot's own voice state is addressed as `@me`, the only one allowed to request to speak.\n private resolveTarget(): string {\n const client = this.client;\n return (client.user?.id ?? client.id) === this.userId ? \"@me\" : this.userId;\n }\n}\n\nMixin(VoiceState, [StructureMixin]);\n","/**\n * Emitted as an `error` when a dispatch takes longer than `GatewayClientOptions.dispatchTimeout` to process.\n *\n * @remarks\n * The dispatch is not cancelled: it keeps running, and later dispatches of its partition keep waiting for it, so the\n * event order is preserved. The error only reports that the partition is stuck, usually on a slow or unreachable\n * cache.\n */\nexport class DispatchTimeoutError extends Error {\n /**\n * The type of the slow dispatch, e.g. `MESSAGE_CREATE`.\n */\n public readonly type: string;\n\n /**\n * The shard the dispatch was received on.\n */\n public readonly shardId: number;\n\n /**\n * The partition the dispatch runs in, `null` for a barrier.\n */\n public readonly partition: string | null;\n\n /**\n * The timeout that was exceeded, in milliseconds.\n */\n public readonly timeout: number;\n\n public constructor(type: string, shardId: number, partition: string | null, timeout: number) {\n super(\n `Processing ${type} on shard ${shardId} (${partition ?? \"barrier\"}) took longer than ${timeout}ms`,\n );\n this.name = \"DispatchTimeoutError\";\n this.type = type;\n this.shardId = shardId;\n this.partition = partition;\n this.timeout = timeout;\n }\n}\n\n/**\n * Thrown by `GuildMemberManager#request` when Discord stops sending the chunks of the requested members.\n *\n * @remarks\n * The request is dropped: chunks arriving later still update the cache and emit `guildMembersChunk`.\n */\nexport class GuildMembersTimeoutError extends Error {\n /**\n * The ID of the guild whose members were requested.\n */\n public readonly guildId: string;\n\n /**\n * The nonce of the request.\n */\n public readonly nonce: string;\n\n /**\n * The timeout that was exceeded, in milliseconds.\n */\n public readonly timeout: number;\n\n public constructor(guildId: string, nonce: string, timeout: number) {\n super(`Requesting the members of guild ${guildId} (${nonce}) took longer than ${timeout}ms`);\n this.name = \"GuildMembersTimeoutError\";\n this.guildId = guildId;\n this.nonce = nonce;\n this.timeout = timeout;\n }\n}\n\n/**\n * Thrown by `GuildMemberManager#request` when Discord answers with `RATE_LIMITED` instead of the members' chunks.\n */\nexport class GuildMembersRateLimitError extends Error {\n /**\n * The ID of the guild whose members were requested.\n */\n public readonly guildId: string;\n\n /**\n * The nonce of the request.\n */\n public readonly nonce: string;\n\n /**\n * How long to wait before requesting the members again, in milliseconds.\n */\n public readonly retryAfter: number;\n\n public constructor(guildId: string, nonce: string, retryAfter: number) {\n super(\n `Requesting the members of guild ${guildId} (${nonce}) is rate limited, retry after ${retryAfter}ms`,\n );\n this.name = \"GuildMembersRateLimitError\";\n this.guildId = guildId;\n this.nonce = nonce;\n this.retryAfter = retryAfter;\n }\n}\n\n/**\n * Emitted as an `error` when `GatewayClientOptions.sessionStore` fails to read or write the session of a shard.\n *\n * @remarks\n * Neither failure stops the shard: a failed (or timed out) read identifies instead of resuming, and a failed write\n * only means the session may not be resumed after a restart. The store's error is the `cause`.\n */\nexport class GatewaySessionStoreError extends Error {\n /**\n * Whether the store failed to read (`\"get\"`) or write (`\"set\"`) the session.\n */\n public readonly operation: \"get\" | \"set\";\n\n /**\n * The shard whose session was read or written.\n */\n public readonly shardId: number;\n\n public constructor(operation: \"get\" | \"set\", shardId: number, cause: unknown) {\n super(\n `Cannot ${operation === \"get\" ? \"read\" : \"write\"} the session of shard ${shardId} in the session store`,\n { cause },\n );\n this.name = \"GatewaySessionStoreError\";\n this.operation = operation;\n this.shardId = shardId;\n }\n}\n","import { randomBytes } from \"node:crypto\";\nimport { memberKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n GatewayOpcodes,\n type APIGuildMember,\n type GatewayGuildMembersChunkDispatchData,\n type GatewayRateLimitedDispatchData,\n type GatewayRequestGuildMembersData,\n type RESTPatchAPICurrentGuildMemberJSONBody,\n type RESTPatchAPIGuildMemberJSONBody,\n type RESTPostAPIGuildBulkBanJSONBody,\n type RESTPutAPIGuildBanJSONBody,\n type RESTPutAPIGuildMemberJSONBody,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { GuildMember, type GuildMemberRelations } from \"../structures/guilds/GuildMember.js\";\nimport { Presence } from \"../structures/presences/Presence.js\";\nimport { bindClient } from \"../structures/Structure.js\";\nimport { VoiceState } from \"../structures/voice/VoiceState.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { GuildMembersRateLimitError, GuildMembersTimeoutError } from \"../util/errors.js\";\nimport { GuildMemberFlagsBitField, type GuildMemberFlagsResolvable } from \"../util/flags.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\n\n/**\n * The options to edit a member with.\n */\nexport interface GuildMemberEditOptions {\n /**\n * The nickname, `null` to reset it.\n */\n nick?: string | null;\n /**\n * The IDs of the roles the member ends up with.\n */\n roles?: readonly string[];\n mute?: boolean;\n deaf?: boolean;\n /**\n * The voice channel to move the member to, `null` to disconnect them.\n */\n channel?: string | null;\n /**\n * When the timeout ends, `null` to lift it.\n */\n communicationDisabledUntil?: Date | number | null;\n flags?: GuildMemberFlagsResolvable;\n /**\n * The reason for the audit log.\n */\n reason?: string;\n}\n\n/**\n * The options to edit the bot's own member with. Images are data URIs, `null` removes them.\n */\nexport interface GuildMemberEditMeOptions {\n nick?: string | null;\n avatar?: string | null;\n banner?: string | null;\n bio?: string | null;\n reason?: string;\n}\n\n/**\n * The options to add a user to a guild with, through an OAuth2 access token with the `guilds.join` scope.\n */\nexport interface GuildMemberAddOptions {\n accessToken: string;\n nick?: string;\n roles?: readonly string[];\n mute?: boolean;\n deaf?: boolean;\n}\n\n/**\n * The options to ban users with.\n */\nexport interface BanOptions {\n /**\n * How many seconds of the users' messages to delete, up to 7 days.\n */\n deleteMessageSeconds?: number;\n reason?: string;\n}\n\n/**\n * The options to prune the inactive members of a guild with.\n */\nexport interface GuildPruneOptions {\n /**\n * How many days of inactivity make a member prunable.\n *\n * @default 7\n */\n days?: number;\n /**\n * The roles whose members are also prunable; members with roles are kept otherwise.\n */\n roles?: readonly string[];\n /**\n * Whether to only count the members that would be pruned.\n *\n * @default false\n */\n dry?: boolean;\n /**\n * Whether to return the count; turning it off is recommended for large guilds.\n *\n * @default true\n */\n count?: boolean;\n reason?: string;\n}\n\n/**\n * The options to request the members of a guild over the gateway with. Without `query` nor `userIds`, every member is\n * requested.\n */\nexport interface GuildMembersRequestOptions {\n /**\n * The prefix of the usernames and nicknames to match, `\"\"` for every member. Exclusive with `userIds`.\n *\n * @default \"\"\n */\n query?: string;\n /**\n * How many members to match with `query`, `0` for no limit (only with an empty `query`).\n *\n * @default 0\n */\n limit?: number;\n /**\n * The IDs of the users to request, up to 100. Exclusive with `query`. The ones that are not members are left out of\n * the result, and listed in the `not_found` of the `guildMembersChunk` data. An empty array is ignored, like omitting\n * it.\n */\n userIds?: readonly string[];\n /**\n * Whether to also receive (and cache) the members' presences. Needs the `GuildPresences` intent.\n *\n * @default false\n */\n presences?: boolean;\n /**\n * The nonce identifying the request's chunks, up to 32 bytes.\n *\n * @default A random one.\n */\n nonce?: string;\n /**\n * How long to wait for each chunk, in milliseconds, before rejecting with a `GuildMembersTimeoutError`.\n *\n * @default 120_000\n */\n time?: number;\n}\n\ninterface MembersRequest {\n guildId: string;\n members: GuildMember[];\n received: number;\n timer: NodeJS.Timeout | null;\n resolve(members: GuildMember[]): void;\n reject(error: Error): void;\n}\n\n/**\n * Manages the {@link GuildMember}s known to the client.\n */\nexport class GuildMemberManager extends CachedManager<\n \"members\",\n GuildMember,\n [guildId: string, userId: string]\n> {\n // The pending `request`s, by nonce.\n readonly #requests = new Map<string, MembersRequest>();\n\n public constructor(client: GatewayClient) {\n super(client, \"members\");\n }\n\n public createStructure(data: CacheEntityTypes[\"members\"]): GuildMember {\n return new GuildMember(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"members\"]): string {\n if (!data.user) throw new TypeError(\"Cannot key a member without its user\");\n return this.resolveKey(data.guild_id, data.user.id);\n }\n\n /**\n * Adds a member to the cache, and its user to `client.users`.\n *\n * @internal\n */\n public override async _add(\n data: CacheEntityTypes[\"members\"],\n cache = true,\n options?: AddOptions,\n ): Promise<GuildMember> {\n if (data.user) await this.client.users._add(data.user, cache);\n return super._add(data, cache, options);\n }\n\n /**\n * Builds a member, resolving its user, guild, voice state, and presence from the cache.\n *\n * @remarks\n * The voice state and presence are built from their raw cache entries rather than by their managers, which resolve\n * their member in turn: their `member` is this very structure.\n *\n * @internal\n */\n public override _hydrate(data: CacheEntityTypes[\"members\"]): Awaitable<GuildMember> {\n const { client } = this;\n const key = data.user ? memberKey(data.guild_id, data.user.id) : null;\n return whenAll(\n [\n data.user ? client.users._resolveData(data.user) : undefined,\n this.cachedGuild(data.guild_id),\n key ? client.cache?.voiceStates.get(key) : undefined,\n key ? client.cache?.presences.get(key) : undefined,\n ],\n ([user, guild, voiceData, presenceData]) => {\n const relations: GuildMemberRelations = { user, guild };\n const member = bindClient(new GuildMember(data, relations), client);\n return whenAll(\n [voiceData?.channel_id ? client.channels._get(voiceData.channel_id) : undefined],\n ([channel]) => {\n if (key && client.cache) {\n relations.voice = voiceData\n ? bindClient(\n new VoiceState(voiceData, { member, guild, channel: channel ?? null }),\n client,\n )\n : null;\n relations.presence = presenceData\n ? bindClient(\n new Presence(presenceData, { user: user ?? null, member, guild }),\n client,\n )\n : null;\n }\n\n return member;\n },\n );\n },\n );\n }\n\n public resolveKey(guildId: string, userId: string): string {\n return memberKey(guildId, userId);\n }\n\n /**\n * Fetches the bot's own member in a guild.\n *\n * @param guildId The ID of the guild.\n */\n public fetchMe(guildId: string): Promise<GuildMember> {\n return this.fetch(guildId, this.client.user?.id ?? this.client.id);\n }\n\n /**\n * Lists the members of a guild, in user ID order, and caches them.\n *\n * @param guildId The ID of the guild.\n * @param options How many members to list (up to 1000), and after which user ID.\n */\n public async list(\n guildId: string,\n options: { limit?: number; after?: string } = {},\n ): Promise<GuildMember[]> {\n const members = await this.client.api.guilds.getMembers(guildId, {\n limit: options.limit ?? 1,\n after: options.after,\n });\n return Promise.all(members.map((member) => this.store(guildId, member)));\n }\n\n /**\n * Searches the members of a guild whose username or nickname starts with a query, and caches them.\n *\n * @param guildId The ID of the guild.\n * @param options The query, and how many members to return (up to 1000).\n */\n public async search(\n guildId: string,\n options: { query: string; limit?: number },\n ): Promise<GuildMember[]> {\n const members = await this.client.api.guilds.searchForMembers(guildId, {\n query: options.query,\n limit: options.limit ?? 1,\n });\n return Promise.all(members.map((member) => this.store(guildId, member)));\n }\n\n /**\n * Requests the members of a guild over the gateway, every one of them by default, and caches them. discord.js:\n * `guild.members.fetch()` without a user.\n *\n * @remarks\n * Unlike {@link GuildMemberManager.list}, it gets the members of a large guild in one go, in chunks of up to 1000\n * that are also emitted as `guildMembersChunk`. Requesting every member or a `query` needs the `GuildMembers`\n * intent. The request is sent on the guild's shard, which must be one this client runs.\n *\n * @param guildId The ID of the guild.\n * @param options Which members to request.\n * @returns The members, once the last chunk is cached.\n */\n public async request(\n guildId: string,\n options: GuildMembersRequestOptions = {},\n ): Promise<GuildMember[]> {\n const { query, limit = 0, presences, time = 120_000 } = options;\n // An empty list of IDs (e.g. built dynamically) requests nothing, so it falls back to the default like no list at all.\n const userIds = options.userIds?.length ? options.userIds : undefined;\n const nonce = options.nonce ?? randomBytes(16).toString(\"hex\");\n if (query !== undefined && userIds !== undefined) {\n throw new TypeError(\"Cannot request members by both query and userIds\");\n }\n if (userIds && userIds.length > 100) {\n throw new RangeError(\"Cannot request more than 100 members by their IDs\");\n }\n if (Buffer.byteLength(nonce) > 32) {\n throw new RangeError(\"The nonce of a members request cannot exceed 32 bytes\");\n }\n\n const d: GatewayRequestGuildMembersData = userIds\n ? { guild_id: guildId, user_ids: [...userIds], presences, nonce }\n : { guild_id: guildId, query: query ?? \"\", limit, presences, nonce };\n const shardCount = BigInt(await this.client.gateway.getShardCount());\n const shardId = Number((BigInt(guildId) >> 22n) % shardCount);\n\n // The nonce is the only link between the request and its chunks, so it must be unique while pending.\n if (this.#requests.has(nonce)) {\n throw new Error(`A members request with the nonce \"${nonce}\" is pending already`);\n }\n let request!: MembersRequest;\n const promise = new Promise<GuildMember[]>((resolve, reject) => {\n request = { guildId, members: [], received: 0, timer: null, resolve, reject };\n });\n this.#requests.set(nonce, request);\n\n try {\n // `@discordjs/ws` rate limits every shard's payloads on its own: `send` waits for the shard to be ready, then\n // queues the payload once 115 were sent in the current minute (Discord closes the connection past 120).\n await this.client.gateway.send(shardId, { op: GatewayOpcodes.RequestGuildMembers, d });\n } catch (error) {\n this.settle(nonce, request);\n throw error;\n }\n\n // The timeout starts once the request is sent, not while it waits for the shard or its rate limit.\n if (this.#requests.get(nonce) === request) {\n request.timer = setTimeout(() => {\n this.settle(nonce, request);\n request.reject(new GuildMembersTimeoutError(guildId, nonce, time));\n }, time);\n request.timer.unref?.();\n }\n return promise;\n }\n\n /**\n * Adds a cached chunk of members to the request with its nonce, resolving it with the last chunk.\n *\n * @internal\n */\n public handleChunk(members: GuildMember[], data: GatewayGuildMembersChunkDispatchData): void {\n const request = data.nonce === undefined ? undefined : this.#requests.get(data.nonce);\n if (!request || request.guildId !== data.guild_id) return;\n\n request.members.push(...members);\n request.timer?.refresh();\n // Chunks of a guild are processed in order, so the last one to arrive has `chunk_index === chunk_count - 1`.\n if (++request.received < data.chunk_count) return;\n\n this.settle(data.nonce!, request);\n request.resolve(request.members);\n }\n\n /**\n * Rejects the request a `RATE_LIMITED` dispatch refers to, which gets no chunks at all.\n *\n * @internal\n */\n public handleRateLimited(data: GatewayRateLimitedDispatchData): void {\n const nonce = data.meta.nonce;\n if (data.opcode !== GatewayOpcodes.RequestGuildMembers || nonce === undefined) return;\n\n const request = this.#requests.get(nonce);\n if (!request) return;\n\n this.settle(nonce, request);\n request.reject(new GuildMembersRateLimitError(request.guildId, nonce, data.retry_after * 1000));\n }\n\n /**\n * Adds a user to a guild, or fetches their member when they are in it already.\n *\n * @param guildId The ID of the guild.\n * @param userId The ID of the user.\n * @param options The access token and the member's initial state.\n */\n public async add(\n guildId: string,\n userId: string,\n options: GuildMemberAddOptions,\n ): Promise<GuildMember> {\n const body: RESTPutAPIGuildMemberJSONBody = {\n access_token: options.accessToken,\n nick: options.nick,\n roles: options.roles ? [...options.roles] : undefined,\n mute: options.mute,\n deaf: options.deaf,\n };\n // The API answers 204 without a body when the user already is a member.\n const member = await this.client.api.guilds.addMember(guildId, userId, body);\n return member ? this.store(guildId, member) : this.fetch(guildId, userId);\n }\n\n /**\n * Edits a member.\n *\n * @param guildId The ID of the guild.\n * @param userId The ID of the member's user.\n * @param options The fields to edit.\n */\n public async edit(\n guildId: string,\n userId: string,\n options: GuildMemberEditOptions,\n ): Promise<GuildMember> {\n const until = options.communicationDisabledUntil;\n const body: RESTPatchAPIGuildMemberJSONBody = {\n nick: options.nick,\n roles: options.roles ? [...options.roles] : undefined,\n mute: options.mute,\n deaf: options.deaf,\n channel_id: options.channel,\n communication_disabled_until:\n until === undefined || until === null ? until : new Date(until).toISOString(),\n flags:\n options.flags === undefined\n ? undefined\n : Number(GuildMemberFlagsBitField.resolve(options.flags)),\n };\n const member = await this.client.api.guilds.editMember(guildId, userId, body, {\n reason: options.reason,\n });\n return this.store(guildId, member);\n }\n\n /**\n * Edits the bot's own member.\n *\n * @param guildId The ID of the guild.\n * @param options The fields to edit.\n */\n public async editMe(guildId: string, options: GuildMemberEditMeOptions): Promise<GuildMember> {\n const { reason, ...body } = options;\n const member = await this.client.api.users.editCurrentGuildMember(\n guildId,\n body satisfies RESTPatchAPICurrentGuildMemberJSONBody,\n { reason },\n );\n return this.store(guildId, member);\n }\n\n /**\n * Kicks a member.\n *\n * @param guildId The ID of the guild.\n * @param userId The ID of the member's user.\n * @param reason The reason for the audit log.\n */\n public async kick(guildId: string, userId: string, reason?: string): Promise<void> {\n await this.client.api.guilds.removeMember(guildId, userId, { reason });\n await this.cache?.delete(this.resolveKey(guildId, userId));\n }\n\n /**\n * Bans a user, member or not.\n *\n * @param guildId The ID of the guild.\n * @param userId The ID of the user.\n * @param options How many seconds of messages to delete, and the reason for the audit log.\n */\n public async ban(guildId: string, userId: string, options: BanOptions = {}): Promise<void> {\n const body: RESTPutAPIGuildBanJSONBody = {\n delete_message_seconds: options.deleteMessageSeconds,\n };\n await this.client.api.guilds.banUser(guildId, userId, body, { reason: options.reason });\n await this.cache?.delete(this.resolveKey(guildId, userId));\n }\n\n /**\n * Lifts a user's ban.\n *\n * @param guildId The ID of the guild.\n * @param userId The ID of the user.\n * @param reason The reason for the audit log.\n */\n public async unban(guildId: string, userId: string, reason?: string): Promise<void> {\n await this.client.api.guilds.unbanUser(guildId, userId, { reason });\n }\n\n /**\n * Bans up to 200 users at once.\n *\n * @param guildId The ID of the guild.\n * @param userIds The IDs of the users.\n * @param options How many seconds of messages to delete, and the reason for the audit log.\n * @returns The users that were banned, and the ones that could not be.\n */\n public async bulkBan(\n guildId: string,\n userIds: readonly string[],\n options: BanOptions = {},\n ): Promise<{ bannedUsers: string[]; failedUsers: string[] }> {\n const body: RESTPostAPIGuildBulkBanJSONBody = {\n user_ids: [...userIds],\n delete_message_seconds: options.deleteMessageSeconds,\n };\n const result = await this.client.api.guilds.bulkBanUsers(guildId, body, {\n reason: options.reason,\n });\n await Promise.all(\n result.banned_users.map((userId) => this.cache?.delete(this.resolveKey(guildId, userId))),\n );\n return { bannedUsers: result.banned_users, failedUsers: result.failed_users };\n }\n\n /**\n * Prunes the inactive members of a guild, or counts them with `dry`.\n *\n * @param guildId The ID of the guild.\n * @param options The inactivity threshold and the roles to include.\n * @returns How many members were (or would be) pruned, `null` when `count` is `false`.\n */\n public async prune(guildId: string, options: GuildPruneOptions = {}): Promise<number | null> {\n const days = options.days ?? 7;\n if (options.dry) {\n const result = await this.client.api.guilds.getPruneCount(guildId, {\n days,\n include_roles: options.roles?.length ? options.roles.join(\",\") : undefined,\n });\n return result.pruned;\n }\n\n const result = await this.client.api.guilds.beginPrune(\n guildId,\n {\n days,\n compute_prune_count: options.count ?? true,\n include_roles: options.roles ? [...options.roles] : undefined,\n },\n { reason: options.reason },\n );\n return result.pruned;\n }\n\n /**\n * Adds a role to a member.\n *\n * @param guildId The ID of the guild.\n * @param userId The ID of the member's user.\n * @param roleId The ID of the role.\n * @param reason The reason for the audit log.\n */\n public async addRole(\n guildId: string,\n userId: string,\n roleId: string,\n reason?: string,\n ): Promise<void> {\n await this.client.api.guilds.addRoleToMember(guildId, userId, roleId, { reason });\n await this.updateCachedRoles(guildId, userId, (roles) => [...new Set([...roles, roleId])]);\n }\n\n /**\n * Removes a role from a member.\n *\n * @param guildId The ID of the guild.\n * @param userId The ID of the member's user.\n * @param roleId The ID of the role.\n * @param reason The reason for the audit log.\n */\n public async removeRole(\n guildId: string,\n userId: string,\n roleId: string,\n reason?: string,\n ): Promise<void> {\n await this.client.api.guilds.removeRoleFromMember(guildId, userId, roleId, { reason });\n await this.updateCachedRoles(guildId, userId, (roles) => roles.filter((id) => id !== roleId));\n }\n\n protected async fetchRaw(guildId: string, userId: string) {\n const member = await this.client.api.guilds.getMember(guildId, userId);\n return { ...member, guild_id: guildId };\n }\n\n // Members without their user cannot be keyed, so they are built without being cached.\n private store(guildId: string, member: APIGuildMember): Promise<GuildMember> {\n const raw = { ...member, guild_id: guildId };\n return raw.user ? this._add(raw) : this.hydrate(raw);\n }\n\n // Drops a request that resolved, was rejected, or timed out.\n private settle(nonce: string, request: MembersRequest): void {\n if (request.timer) clearTimeout(request.timer);\n this.#requests.delete(nonce);\n }\n\n // The role endpoints answer 204 without the member, so the cached entry is patched instead of refetched.\n private async updateCachedRoles(\n guildId: string,\n userId: string,\n update: (roles: readonly string[]) => string[],\n ): Promise<void> {\n const key = this.resolveKey(guildId, userId);\n const cached = await this.cache?.get(key);\n if (cached) await this.cache!.set(key, { ...cached, roles: update(cached.roles) });\n }\n}\n","import type { ReactionType } from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { type User } from \"../structures/users/User.js\";\n\n/**\n * Manages the users who reacted to a message with one emoji.\n */\nexport class ReactionUserManager {\n public readonly client: GatewayClient;\n public readonly channelId: string;\n public readonly messageId: string;\n /**\n * The emoji, as the identifier reaction routes expect (`name:id` or the encoded Unicode emoji).\n */\n public readonly emoji: string;\n\n public constructor(client: GatewayClient, channelId: string, messageId: string, emoji: string) {\n this.client = client;\n this.channelId = channelId;\n this.messageId = messageId;\n this.emoji = emoji;\n }\n\n /**\n * Fetches the users who reacted, paginated by user ID, and caches them.\n *\n * @param options How many users to fetch (up to 100), after which user ID, and which kind of reaction.\n */\n public async fetch(\n options: { limit?: number; after?: string; type?: ReactionType } = {},\n ): Promise<User[]> {\n const users = await this.client.api.channels.getMessageReactions(\n this.channelId,\n this.messageId,\n this.emoji,\n { limit: options.limit ?? 100, after: options.after, type: options.type },\n );\n return Promise.all(users.map((user) => this.client.users._add(user)));\n }\n\n /**\n * Removes a user's reaction, the bot's by default.\n *\n * @param userId The ID of the user, `\"@me\"` for the bot.\n */\n public async remove(userId = \"@me\"): Promise<void> {\n if (userId === \"@me\" || userId === this.client.user?.id) {\n await this.client.api.channels.deleteOwnMessageReaction(\n this.channelId,\n this.messageId,\n this.emoji,\n );\n } else {\n await this.client.api.channels.deleteUserMessageReaction(\n this.channelId,\n this.messageId,\n this.emoji,\n userId,\n );\n }\n }\n}\n","import { Reaction as BaseReaction, Structure as BaseStructure } from \"@discordjs/structures\";\nimport type { APIReaction } from \"discord-api-types/v10\";\nimport { ReactionUserManager } from \"../../managers/ReactionUserManager.js\";\nimport { ReactionEmoji } from \"../emojis/ReactionEmoji.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport type { GuildEmoji } from \"../emojis/GuildEmoji.js\";\nimport { initStructure, kData, kPatch, kRelations, StructureMixin } from \"../Structure.js\";\nimport type { Message } from \"./Message.js\";\n\n/**\n * The raw data of a reaction, with the message it belongs to. The counts are absent when the reaction was built from\n * a gateway event on a message the cache did not hold.\n */\nexport type MessageReactionData = Omit<APIReaction, \"count\" | \"count_details\"> &\n Partial<Pick<APIReaction, \"count\" | \"count_details\">> & {\n channel_id: string;\n message_id: string;\n };\n\n/**\n * The relations of a {@link MessageReaction}: its message, and its cached custom emoji.\n */\nexport interface MessageReactionRelations {\n message?: Message | null;\n /**\n * The cached custom emoji, when it belongs to the message's guild.\n */\n emoji?: GuildEmoji | null;\n}\n\nexport interface MessageReaction extends StructureMixin<\n MessageReactionData,\n MessageReactionRelations\n> {}\n\n/**\n * A reaction on a message, an emoji, how many users reacted with it, and whether the bot did: `@discordjs/structures`'\n * `Reaction`, with the message it belongs to, its users, and actions through the client.\n *\n * @remarks\n * The counts are omitted from `@discordjs/structures`' data type, since a reaction built from a gateway event on an\n * uncached message has none.\n */\nexport class MessageReaction extends BaseReaction<\"count\" | \"count_details\"> {\n /**\n * Keeps the raw `burst_colors`, which `@discordjs/structures` strips and re-serializes, so that\n * {@link MessageReaction.toJSON} returns the reaction as received.\n */\n public static override DataTemplate: Partial<APIReaction> = {};\n\n /**\n * @param data The raw reaction, with the message it belongs to.\n * @param relations The related structures, resolved from the cache.\n */\n public constructor(data: MessageReactionData, relations: MessageReactionRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n public get channelId() {\n return this[kData].channel_id;\n }\n\n public get messageId() {\n return this[kData].message_id;\n }\n\n /**\n * The message the reaction is on, like discord.js's `MessageReaction#message`: the message it was read from, else\n * the cached one. `null` when the message is not cached.\n */\n public get message(): Message | null {\n return this[kRelations].message ?? null;\n }\n\n /**\n * The emoji, like discord.js's `MessageReaction#emoji`: the cached custom emoji of the message's guild, else the\n * emoji of the payload.\n */\n public get emoji(): GuildEmoji | ReactionEmoji {\n return this[kRelations].emoji ?? this.reactionEmoji;\n }\n\n /**\n * The emoji as the payload describes it, which the reaction routes are keyed by.\n */\n private get reactionEmoji(): ReactionEmoji {\n return new ReactionEmoji(this[kData].emoji);\n }\n\n /**\n * How many users reacted, super reactions included; `null` when unknown.\n */\n /**\n * Whether the reaction is partial: its message is not cached, so its counts are unknown. Only its emoji and IDs are\n * reliable then, and {@link MessageReaction.fetch} completes it.\n */\n public get partial(): boolean {\n return this[kData].count === undefined;\n }\n\n public override get count(): number | null {\n return this[kData].count ?? null;\n }\n\n /**\n * How many normal and super (burst) reactions there are; `null` when unknown.\n */\n public get countDetails(): { normal: number; burst: number } | null {\n return this[kData].count_details ?? null;\n }\n\n /**\n * The colors of the super reaction animation, as numbers.\n */\n public override get burstColors(): number[] {\n // `@discordjs/structures` parses the raw `#rrggbb` strings with their leading hash, which yields `NaN`.\n return this[kData].burst_colors.map((color) => Number.parseInt(color.replace(/^#/, \"\"), 16));\n }\n\n /**\n * The users who reacted.\n */\n public get users(): ReactionUserManager {\n return new ReactionUserManager(\n this.client,\n this.channelId,\n this.messageId,\n this.reactionEmoji.identifier,\n );\n }\n\n /**\n * Reacts with this emoji as the bot.\n */\n public async react(): Promise<this> {\n await this.client.messages.react(this.channelId, this.messageId, this.reactionEmoji.identifier);\n return this[kPatch]({ me: true });\n }\n\n /**\n * Removes every reaction with this emoji.\n */\n public async remove(): Promise<this> {\n await this.client.messages.removeReactionEmoji(\n this.channelId,\n this.messageId,\n this.reactionEmoji.identifier,\n );\n return this;\n }\n\n /**\n * Fetches the message and patches this reaction with its current counts.\n */\n public async fetch(): Promise<this> {\n const message = await this.client.messages.fetch(this.channelId, this.messageId, {\n force: true,\n });\n const identifier = this.reactionEmoji.identifier;\n const current = message.reactions.cache.find(\n (reaction) => ReactionEmoji.resolveIdentifier(reaction.toJSON().emoji) === identifier,\n );\n return current\n ? this[kPatch](current.toJSON())\n : this[kPatch]({\n count: 0,\n count_details: { normal: 0, burst: 0 },\n me: false,\n me_burst: false,\n burst_colors: [],\n });\n }\n\n public valueOf(): string {\n const { id, name } = this[kData].emoji;\n return id ?? name ?? \"\";\n }\n\n /**\n * Transforms this reaction into its raw data, as received.\n *\n * @remarks\n * Typed as `@discordjs/structures`' `APIReaction`, but the counts are absent when they are unknown, and the data\n * carries the IDs of the channel and the message.\n */\n public override toJSON(): APIReaction {\n return BaseStructure.prototype.toJSON.call(this) as APIReaction;\n }\n}\n\nMixin(MessageReaction, [StructureMixin]);\n","import type { APIReaction } from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport type { GuildEmoji } from \"../structures/emojis/GuildEmoji.js\";\nimport type { Message } from \"../structures/messages/Message.js\";\nimport { bindClient } from \"../structures/Structure.js\";\nimport { MessageReaction } from \"../structures/messages/MessageReaction.js\";\nimport {\n ReactionEmoji,\n type EmojiIdentifierResolvable,\n} from \"../structures/emojis/ReactionEmoji.js\";\n\n/**\n * Manages the reactions of one message, as they were in the message's payload.\n */\nexport class ReactionManager {\n public readonly client: GatewayClient;\n public readonly channelId: string;\n public readonly messageId: string;\n\n readonly #reactions: readonly APIReaction[];\n\n readonly #message: Message | null;\n\n readonly #emojis: ReadonlyMap<string, GuildEmoji> | undefined;\n\n /**\n * @param client The client.\n * @param channelId The ID of the channel of the message.\n * @param messageId The ID of the message.\n * @param reactions The raw reactions of the message.\n * @param message The message, which its reactions refer to.\n * @param emojis The cached custom emojis of the reactions, by ID.\n */\n public constructor(\n client: GatewayClient,\n channelId: string,\n messageId: string,\n reactions: readonly APIReaction[],\n message: Message | null = null,\n emojis?: ReadonlyMap<string, GuildEmoji>,\n ) {\n this.client = client;\n this.channelId = channelId;\n this.messageId = messageId;\n this.#reactions = reactions;\n this.#message = message;\n this.#emojis = emojis;\n }\n\n /**\n * The reactions of the message.\n */\n public get cache(): MessageReaction[] {\n return this.#reactions.map((reaction) =>\n bindClient(\n new MessageReaction(\n { ...reaction, channel_id: this.channelId, message_id: this.messageId },\n {\n message: this.#message,\n emoji: (reaction.emoji.id && this.#emojis?.get(reaction.emoji.id)) || null,\n },\n ),\n this.client,\n ),\n );\n }\n\n /**\n * Finds the reaction with an emoji, if the message has it.\n *\n * @param emoji The emoji.\n */\n public resolve(emoji: EmojiIdentifierResolvable): MessageReaction | null {\n const identifier = ReactionEmoji.resolveIdentifier(emoji);\n return (\n this.cache.find(\n (reaction) => ReactionEmoji.resolveIdentifier(reaction.toJSON().emoji) === identifier,\n ) ?? null\n );\n }\n\n /**\n * Removes every reaction of the message.\n */\n public removeAll(): Promise<void> {\n return this.client.messages.removeAllReactions(this.channelId, this.messageId);\n }\n}\n","/**\n * Compares two JSON-like values structurally, regardless of key order. `undefined` properties count as missing, like\n * they do once serialized.\n *\n * @param a The first value.\n * @param b The second value.\n */\nexport function isDeepEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n if (typeof a !== \"object\" || typeof b !== \"object\" || a === null || b === null) return false;\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n\n if (Array.isArray(a)) {\n const other = b as unknown[];\n return a.length === other.length && a.every((value, index) => isDeepEqual(value, other[index]));\n }\n\n const left = definedEntries(a as Record<string, unknown>);\n const right = new Map(definedEntries(b as Record<string, unknown>));\n return (\n left.length === right.size &&\n left.every(([key, value]) => right.has(key) && isDeepEqual(value, right.get(key)))\n );\n}\n\nfunction definedEntries(value: Record<string, unknown>): [string, unknown][] {\n return Object.entries(value).filter(([, entry]) => entry !== undefined);\n}\n","import { Attachment as BaseAttachment } from \"@discordjs/structures\";\nimport type { APIAttachment } from \"discord-api-types/v10\";\nimport { AttachmentFlagsBitField } from \"../../util/flags.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, snowflakeTimestamp, StructureMixin } from \"../Structure.js\";\n\nexport interface Attachment extends StructureMixin<APIAttachment> {}\n\n/**\n * A file attached to a message: `@discordjs/structures`' `Attachment`, with discord.js' aliases and helpers.\n */\nexport class Attachment extends BaseAttachment {\n /**\n * @param data The raw attachment.\n * @param relations The related structures, resolved from the cache.\n */\n public constructor(data: APIAttachment, relations: object = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n /**\n * The name of the file.\n */\n public get name() {\n return this.filename;\n }\n\n /**\n * Whether the attachment is ephemeral: it is deleted shortly after the message is, unless referenced elsewhere.\n */\n public override get ephemeral(): boolean {\n return this[kData].ephemeral ?? false;\n }\n\n /**\n * The duration of a voice message, in seconds.\n */\n public get duration(): number | null {\n return this[kData].duration_secs ?? null;\n }\n\n public override get flags(): Readonly<AttachmentFlagsBitField> {\n return new AttachmentFlagsBitField(this[kData].flags ?? 0).freeze();\n }\n\n /**\n * Whether the attachment is marked as a spoiler.\n */\n public get spoiler(): boolean {\n return this.flags.has(\"IsSpoiler\");\n }\n\n public get createdTimestamp() {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n}\n\nMixin(Attachment, [StructureMixin]);\n","import { Embed as BaseEmbed, Structure as BaseStructure } from \"@discordjs/structures\";\nimport type {\n APIEmbed,\n APIEmbedAuthor,\n APIEmbedField,\n APIEmbedFooter,\n APIEmbedImage,\n APIEmbedProvider,\n APIEmbedThumbnail,\n APIEmbedVideo,\n} from \"discord-api-types/v10\";\nimport { isDeepEqual } from \"../../util/equal.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, StructureMixin } from \"../Structure.js\";\n\nexport interface Embed extends StructureMixin<APIEmbed> {}\n\n/**\n * An embed of a received message: `@discordjs/structures`' `Embed`, with its nested parts and discord.js' helpers.\n * Use `@discordjs/builders`' `EmbedBuilder` to create embeds.\n */\nexport class Embed extends BaseEmbed<\"\"> {\n /**\n * Keeps the raw `timestamp`, which `@discordjs/structures` strips and re-serializes in its own format, so that\n * {@link Embed.toJSON} returns the embed as received.\n */\n public static override readonly DataTemplate: Partial<APIEmbed> = {};\n\n /**\n * @param data The raw embed.\n * @param relations The related structures, resolved from the cache.\n */\n public constructor(data: APIEmbed, relations: object = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n /**\n * The color as a `#rrggbb` string, `undefined` when the embed has none.\n */\n public override get hexColor(): `#${string}` | undefined {\n const { color } = this;\n return color === undefined ? undefined : `#${color.toString(16).padStart(6, \"0\")}`;\n }\n\n public get fields(): readonly APIEmbedField[] {\n return this[kData].fields ?? [];\n }\n\n public get thumbnail(): APIEmbedThumbnail | null {\n return this[kData].thumbnail ?? null;\n }\n\n public get image(): APIEmbedImage | null {\n return this[kData].image ?? null;\n }\n\n public get video(): APIEmbedVideo | null {\n return this[kData].video ?? null;\n }\n\n public get author(): APIEmbedAuthor | null {\n return this[kData].author ?? null;\n }\n\n public get provider(): APIEmbedProvider | null {\n return this[kData].provider ?? null;\n }\n\n public get footer(): APIEmbedFooter | null {\n return this[kData].footer ?? null;\n }\n\n /**\n * The number of characters counting towards Discord's 6000 characters limit.\n */\n public get length(): number {\n return (\n (this.title?.length ?? 0) +\n (this.description?.length ?? 0) +\n this.fields.reduce((sum, field) => sum + field.name.length + field.value.length, 0) +\n (this.footer?.text.length ?? 0) +\n (this.author?.name.length ?? 0)\n );\n }\n\n /**\n * Whether this embed has the same data as another one.\n * @param embed The embed, or raw embed data, to compare with.\n */\n public equals(embed: Embed | APIEmbed): boolean {\n return isDeepEqual(this.toJSON(), embed instanceof Embed ? embed.toJSON() : embed);\n }\n\n public override toJSON(): APIEmbed {\n return BaseStructure.prototype.toJSON.call(this) as APIEmbed;\n }\n}\n\nMixin(Embed, [StructureMixin]);\n","import type { APIChannelMention, APIGuildMember, APIMessage, APIUser } from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport { GuildMember } from \"../guilds/GuildMember.js\";\nimport type { Role } from \"../guilds/Role.js\";\nimport { User } from \"../users/User.js\";\nimport { pickCached as pick } from \"../../util/cache.js\";\n\n/**\n * The mentioned entities, resolved from the cache by `client.messages`, each by ID.\n */\nexport interface MessageMentionsRelations {\n /**\n * The mentioned users and the ones parsed from the content, and the author of the replied message.\n */\n users?: ReadonlyMap<string, User>;\n members?: ReadonlyMap<string, GuildMember>;\n roles?: ReadonlyMap<string, Role>;\n /**\n * The channels mentioned in the content.\n */\n channels?: ReadonlyMap<string, AnyChannel>;\n guild?: Guild | null;\n}\n\n/**\n * The raw fields of a message the mentions are read from.\n */\nexport type MessageMentionsData = Pick<\n APIMessage,\n \"content\" | \"mention_everyone\" | \"mention_roles\"\n> &\n Partial<Pick<APIMessage, \"mention_channels\" | \"referenced_message\">> & {\n guild_id?: string;\n /**\n * The mentioned users. In guilds, the gateway attaches each one's partial member.\n */\n mentions: (APIUser & { member?: Omit<APIGuildMember, \"user\"> })[];\n };\n\n/**\n * The options of {@link MessageMentions.has}.\n */\nexport interface MentionsHasOptions {\n /**\n * Whether to ignore direct mentions of the user, role, or channel.\n */\n ignoreDirect?: boolean;\n /**\n * Whether to ignore mentions of the member's roles.\n */\n ignoreRoles?: boolean;\n /**\n * Whether to ignore the author of the replied message.\n */\n ignoreRepliedUser?: boolean;\n /**\n * Whether to ignore `@everyone` and `@here`.\n */\n ignoreEveryone?: boolean;\n}\n\n/**\n * The users, roles, and channels a message mentions.\n *\n * @remarks\n * Users and members come with the message payload, and are replaced by their cached copies when the message was built\n * by `client.messages`, which also resolves the mentioned roles and channels from the cache, like discord.js.\n */\nexport class MessageMentions {\n /**\n * Matches `@everyone` and `@here`.\n */\n public static readonly EveryonePattern = /@(?<mention>everyone|here)/;\n\n /**\n * Matches user mentions, `<@id>` and the legacy `<@!id>`.\n */\n public static readonly UsersPattern = /<@!?(?<id>\\d{17,20})>/g;\n\n /**\n * Matches role mentions, `<@&id>`.\n */\n public static readonly RolesPattern = /<@&(?<id>\\d{17,20})>/g;\n\n /**\n * Matches channel mentions, `<#id>`.\n */\n public static readonly ChannelsPattern = /<#(?<id>\\d{17,20})>/g;\n\n readonly #data: MessageMentionsData;\n\n readonly #relations: MessageMentionsRelations;\n\n /**\n * @param data The raw fields of the message.\n * @param relations The mentioned entities, as resolved from the cache.\n */\n public constructor(data: MessageMentionsData, relations: MessageMentionsRelations = {}) {\n this.#data = data;\n this.#relations = relations;\n }\n\n /**\n * The guild of the message, from the cache, like discord.js's `MessageMentions#guild`.\n */\n public get guild(): Guild | null {\n return this.#relations.guild ?? null;\n }\n\n /**\n * The cached roles the message mentions, by ID, like discord.js's `MessageMentions#roles`.\n */\n public get roles(): Map<string, Role> {\n return pick(this.#data.mention_roles, this.#relations.roles);\n }\n\n /**\n * The cached channels the content mentions, by ID, like discord.js's `MessageMentions#channels`.\n */\n public get channels(): Map<string, AnyChannel> {\n return pick(this.parsedChannelIds, this.#relations.channels);\n }\n\n /**\n * The cached users the content mentions, by ID, like discord.js's `MessageMentions#parsedUsers`, which also\n * counts the users the message does not ping.\n */\n public get parsedUsers(): Map<string, User> {\n return pick(this.parsedUserIds, this.#relations.users);\n }\n\n /**\n * Whether the message mentions `@everyone` or `@here`.\n */\n public get everyone(): boolean {\n return this.#data.mention_everyone;\n }\n\n /**\n * The mentioned users: their cached copies, else the payload's.\n */\n public get users(): User[] {\n const cached = this.#relations.users;\n return this.#data.mentions.map((user) => cached?.get(user.id) ?? new User(user));\n }\n\n /**\n * The mentioned users as members, for messages sent in a guild.\n */\n public get members(): GuildMember[] {\n const guildId = this.#data.guild_id;\n if (!guildId) return [];\n\n const cached = this.#relations.members;\n return this.#data.mentions.flatMap(({ member, ...user }) => {\n if (!member) return [];\n return [cached?.get(user.id) ?? new GuildMember({ ...member, user, guild_id: guildId })];\n });\n }\n\n public get roleIds(): readonly string[] {\n return this.#data.mention_roles;\n }\n\n /**\n * The IDs of the channels mentioned in the content, and of the crossposted channels.\n */\n public get channelIds(): string[] {\n return [\n ...new Set([\n ...this.crosspostedChannels.map((channel) => channel.id),\n ...this.parsedChannelIds,\n ]),\n ];\n }\n\n /**\n * The IDs of the channels mentioned in the content.\n */\n public get parsedChannelIds(): string[] {\n return MessageMentions.parseIds(this.#data.content, MessageMentions.ChannelsPattern);\n }\n\n /**\n * The channels a crossposted message mentions, from other guilds.\n */\n public get crosspostedChannels(): readonly APIChannelMention[] {\n return this.#data.mention_channels ?? [];\n }\n\n /**\n * The author of the message this one replies to, if any.\n */\n public get repliedUser(): User | null {\n const author = this.#data.referenced_message?.author;\n return author ? (this.#relations.users?.get(author.id) ?? new User(author)) : null;\n }\n\n /**\n * The IDs of the users mentioned in the content, including the ones Discord did not resolve.\n */\n public get parsedUserIds(): string[] {\n return MessageMentions.parseIds(this.#data.content, MessageMentions.UsersPattern);\n }\n\n /**\n * Lists the unique IDs a mention pattern matches in a content.\n *\n * @param content The content.\n * @param pattern One of the global mention patterns, e.g. {@link MessageMentions.ChannelsPattern}.\n */\n public static parseIds(content: string, pattern: RegExp): string[] {\n return [...new Set([...content.matchAll(pattern)].map((match) => match.groups!.id!))];\n }\n\n /**\n * Whether the message mentions a user, member, role, or channel.\n *\n * @param target The ID, or a structure with an `id` (and `roleIds` for members).\n * @param options What kinds of mentions to ignore.\n */\n public has(\n target: string | { id: string | null; roleIds?: readonly string[] },\n options: MentionsHasOptions = {},\n ): boolean {\n const id = typeof target === \"string\" ? target : target.id;\n if (!id) return false;\n\n if (!options.ignoreEveryone && this.everyone) return true;\n if (!options.ignoreRepliedUser && this.repliedUser?.id === id) return true;\n\n if (!options.ignoreDirect) {\n if (this.#data.mentions.some((user) => user.id === id)) return true;\n if (this.roleIds.includes(id)) return true;\n if (this.channelIds.includes(id)) return true;\n }\n\n if (!options.ignoreRoles && typeof target !== \"string\" && target.roleIds) {\n return target.roleIds.some((roleId) => this.roleIds.includes(roleId));\n }\n\n return false;\n }\n}\n","import { PollAnswer as BasePollAnswer } from \"@discordjs/structures\";\nimport type { APIPollAnswer } from \"discord-api-types/v10\";\nimport { ReactionEmoji } from \"../emojis/ReactionEmoji.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport type { GuildEmoji } from \"../emojis/GuildEmoji.js\";\nimport { initStructure, kData, kRelations, StructureMixin } from \"../Structure.js\";\nimport type { Poll } from \"./Poll.js\";\nimport type { User } from \"../users/User.js\";\n\n/**\n * The raw data of a poll answer, with its vote count from the poll's results and the message it belongs to.\n */\nexport type PollAnswerData = APIPollAnswer & {\n channel_id: string;\n message_id: string;\n /**\n * The vote count from the poll's results, absent when Discord did not send them.\n */\n count?: number;\n me_voted?: boolean;\n};\n\n/**\n * The relations of a {@link PollAnswer}: its poll, and its cached custom emoji.\n */\nexport interface PollAnswerRelations {\n poll?: Poll | null;\n emoji?: GuildEmoji | null;\n}\n\nexport interface PollAnswer extends StructureMixin<PollAnswerData, PollAnswerRelations> {}\n\n/**\n * An answer of a {@link Poll}: `@discordjs/structures`' `PollAnswer`, with its vote count and the message it belongs to.\n */\nexport class PollAnswer extends BasePollAnswer {\n /**\n * @param data The raw answer, with its vote count and the message it belongs to.\n * @param relations The related structures, resolved from the cache.\n */\n public constructor(data: PollAnswerData, relations: PollAnswerRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n /**\n * The ID of the answer, an alias of `answerId`.\n */\n public get id() {\n return this.answerId;\n }\n\n public get channelId() {\n return this[kData].channel_id;\n }\n\n public get messageId() {\n return this[kData].message_id;\n }\n\n public get text(): string | null {\n return this[kData].poll_media?.text ?? null;\n }\n\n /**\n * Whether the answer is partial: its message is not cached, so only its ID is known, see `Partials.PollAnswer`.\n * Fetch its poll to complete it.\n */\n public get partial(): boolean {\n return (\n this[kData].poll_media?.text === undefined && this[kData].poll_media?.emoji === undefined\n );\n }\n\n /**\n * The poll the answer belongs to, like discord.js's `PollAnswer#poll`: `null` when the answer was not read from a\n * poll.\n */\n public get poll(): Poll | null {\n return this[kRelations].poll ?? null;\n }\n\n /**\n * The emoji of the answer, like discord.js's `PollAnswer#emoji`: the cached custom emoji of the message's guild,\n * else the payload's.\n */\n public get emoji(): GuildEmoji | ReactionEmoji | null {\n const { emoji } = this[kData].poll_media ?? {};\n return this[kRelations].emoji ?? (emoji?.id || emoji?.name ? new ReactionEmoji(emoji) : null);\n }\n\n /**\n * How many users voted for the answer, `0` when the results are unknown.\n */\n public get voteCount(): number {\n return this[kData].count ?? 0;\n }\n\n /**\n * Whether the bot voted for the answer.\n */\n public get meVoted(): boolean {\n return this[kData].me_voted ?? false;\n }\n\n /**\n * Fetches the users who voted for the answer, paginated by user ID.\n *\n * @param options How many voters to fetch (up to 100), and after which user ID.\n */\n public fetchVoters(options: { limit?: number; after?: string } = {}): Promise<User[]> {\n return this.client.messages.fetchPollAnswerVoters(\n this.channelId,\n this.messageId,\n this.id,\n options,\n );\n }\n}\n\nMixin(PollAnswer, [StructureMixin]);\n","import { Poll as BasePoll, Structure as BaseStructure } from \"@discordjs/structures\";\nimport type { APIPoll } from \"discord-api-types/v10\";\nimport type { Message } from \"../messages/Message.js\";\nimport { PollAnswer } from \"./PollAnswer.js\";\nimport { ReactionEmoji } from \"../emojis/ReactionEmoji.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { GuildEmoji } from \"../emojis/GuildEmoji.js\";\nimport {\n bindClient,\n initStructure,\n kData,\n kPatch,\n kRelations,\n StructureMixin,\n} from \"../Structure.js\";\n\n/**\n * The raw data of a poll, with the message it belongs to.\n */\nexport type PollData = APIPoll & { channel_id: string; message_id: string };\n\n/**\n * The relations of a {@link Poll}: the message it belongs to, and that message's channel and cached custom emojis.\n */\nexport interface PollRelations {\n message?: Message | null;\n channel?: AnyChannel | null;\n /**\n * The cached custom emojis of the answers, by ID, when they belong to the message's guild.\n */\n emojis?: ReadonlyMap<string, GuildEmoji>;\n}\n\nexport interface Poll extends StructureMixin<PollData, PollRelations> {}\n\n/**\n * The poll of a message: `@discordjs/structures`' `Poll`, with its answers, results, and the message it belongs to.\n */\nexport class Poll extends BasePoll<\"\"> {\n /**\n * Keeps the raw `expiry`, which `@discordjs/structures` strips and re-serializes in its own format, so that\n * {@link Poll.toJSON} returns the poll as received.\n */\n public static override DataTemplate: Partial<APIPoll> = {};\n\n /**\n * @param data The raw poll, with the message it belongs to.\n * @param relations The related structures, resolved from the cache.\n */\n public constructor(data: PollData, relations: PollRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n public get channelId() {\n return this[kData].channel_id;\n }\n\n public get messageId() {\n return this[kData].message_id;\n }\n\n /**\n * The message the poll belongs to, like discord.js's `Poll#message`: `null` when the poll was not read from a\n * message.\n */\n public get message(): Message | null {\n return this[kRelations].message ?? null;\n }\n\n /**\n * The channel of the poll's message, from the cache, like discord.js's `Poll#channel`.\n */\n public get channel(): AnyChannel | null {\n return this[kRelations].channel ?? null;\n }\n\n /**\n * Whether the poll is partial: built from its message's IDs alone for a vote on an uncached message, see\n * `Partials.Poll`. Only `channelId` and `messageId` are reliable then, and {@link Poll.fetch} completes it.\n */\n public get partial(): boolean {\n return this[kData].question === undefined;\n }\n\n /**\n * Fetches the poll's message from the API and patches this structure with its poll.\n */\n public async fetch(): Promise<this> {\n const message = await this.client.messages.fetch(this.channelId, this.messageId, {\n force: true,\n });\n const { poll } = message.toJSON();\n if (!poll) throw new Error(`Message ${this.messageId} has no poll`);\n return this[kPatch](poll as Partial<PollData>);\n }\n\n public get question(): { text: string | null; emoji: ReactionEmoji | null } {\n const { text, emoji } = this[kData].question ?? {};\n return { text: text ?? null, emoji: emoji ? new ReactionEmoji(emoji) : null };\n }\n\n /**\n * The answers, with their vote counts when Discord sent the results.\n */\n public get answers(): PollAnswer[] {\n const counts = new Map(\n (this[kData].results?.answer_counts ?? []).map((count) => [count.id, count]),\n );\n return (this[kData].answers ?? []).map((answer) => {\n const count = counts.get(answer.answer_id);\n const emojiId = answer.poll_media.emoji?.id;\n const relations = {\n poll: this,\n emoji: (emojiId && this[kRelations].emojis?.get(emojiId)) || null,\n };\n return bindClient(\n new PollAnswer(\n {\n ...answer,\n channel_id: this.channelId,\n message_id: this.messageId,\n count: count?.count,\n me_voted: count?.me_voted,\n },\n relations,\n ),\n this.client,\n );\n });\n }\n\n /**\n * Whether the votes are final, i.e. the poll ended and Discord counted them.\n */\n public get resultsFinalized(): boolean {\n return this[kData].results?.is_finalized ?? false;\n }\n\n /**\n * When the poll ends, `null` for polls that never do.\n */\n public get expiresAt(): Date | null {\n return this.expiresDate;\n }\n\n /**\n * Ends the poll now. Only the bot's own polls can be ended.\n *\n * @returns The message holding the ended poll.\n */\n public end(): Promise<Message> {\n return this.client.messages.endPoll(this.channelId, this.messageId);\n }\n\n public override toJSON(): PollData {\n return BaseStructure.prototype.toJSON.call(this) as PollData;\n }\n}\n\nMixin(Poll, [StructureMixin]);\n","import { Message as BaseMessage, Structure as BaseStructure } from \"@discordjs/structures\";\nimport type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n ChannelType,\n MessageFlags,\n MessageType,\n type APIMessage,\n type APIThreadChannel,\n} from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { MessageThreadCreateOptions } from \"../../managers/MessageManager.js\";\nimport { ReactionManager } from \"../../managers/ReactionManager.js\";\nimport type { AnyThreadChannel } from \"../../managers/ThreadManager.js\";\nimport { isDeepEqual } from \"../../util/equal.js\";\nimport { MessageFlagsBitField } from \"../../util/flags.js\";\nimport {\n MessagePayload,\n type MessageCreateOptions,\n type MessageEditOptions,\n type MessagePayloadResolvable,\n} from \"./MessagePayload.js\";\nimport type { PermissionsString } from \"../../util/PermissionsBitField.js\";\nimport { Attachment } from \"./Attachment.js\";\nimport { Embed } from \"./Embed.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport { GuildMember } from \"../guilds/GuildMember.js\";\nimport { MessageMentions, type MessageMentionsRelations } from \"./MessageMentions.js\";\nimport type { GuildEmoji } from \"../emojis/GuildEmoji.js\";\nimport { Poll } from \"../polls/Poll.js\";\nimport type { EmojiIdentifierResolvable } from \"../emojis/ReactionEmoji.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport {\n bindClient,\n initStructure,\n kData,\n kPatch,\n kRelations,\n snowflakeTimestamp,\n StructureMixin,\n} from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\nconst ZeroWidthSpace = String.fromCodePoint(0x20_0b);\n\n/**\n * The relations of a {@link Message}, resolved from the cache by `client.messages`.\n */\nexport interface MessageRelations {\n author?: User;\n /**\n * The author as a member, `null` outside of guilds.\n */\n member?: GuildMember | null;\n guild?: Guild | null;\n channel?: AnyChannel | null;\n /**\n * The thread started from the message, from the thread cache.\n */\n thread?: AnyThreadChannel | null;\n /**\n * The mentioned users, members, roles, and channels, from the cache.\n */\n mentions?: MessageMentionsRelations;\n /**\n * The cached custom emojis of the message's reactions and poll answers, by ID, when they belong to its guild.\n */\n emojis?: ReadonlyMap<string, GuildEmoji>;\n}\n\n// The message types a user can send; every other type is a system message.\nconst NonSystemTypes: readonly MessageType[] = [\n MessageType.Default,\n MessageType.Reply,\n MessageType.ChatInputCommand,\n MessageType.ContextMenuCommand,\n];\n\nexport interface Message extends StructureMixin<CacheEntityTypes[\"messages\"], MessageRelations> {}\n\n/**\n * A Discord message: `@discordjs/structures`' `Message`, with its relations, substructures, and actions through the\n * client.\n *\n * @remarks\n * Relations discord.js reads synchronously from its cache are asynchronous here: `fetchChannel()`, `fetchGuild()`,\n * `fetchReference()`, and the `fetch*able()` permission checks, which apply the channel's overwrites.\n */\nexport class Message extends BaseMessage<\"\"> {\n /**\n * Keeps the raw `timestamp` and `edited_timestamp`, which `@discordjs/structures` strips and re-serializes in its own\n * format, so that {@link Message.toJSON} returns the message as received.\n */\n public static override DataTemplate: Partial<APIMessage> = {};\n\n protected override optimizeData(data: Partial<CacheEntityTypes[\"messages\"]>): void {\n super.optimizeData(data);\n this.optimizeTimestamp(\"edited_timestamp\", data.edited_timestamp);\n }\n\n /**\n * @param data The raw message.\n * @param relations The author, member, guild, and channel as resolved from the cache, by `client.messages`.\n */\n public constructor(data: CacheEntityTypes[\"messages\"], relations: MessageRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n public [kPatch](data: Readonly<Partial<CacheEntityTypes[\"messages\"]>>): this {\n // A payload carrying the author is fresher than the one resolved when the message was built.\n if (data.author) this.dropRelations(\"author\", \"member\");\n else if (data.member) this.dropRelations(\"member\");\n if (data.content !== undefined || data.mentions || data.mention_roles) {\n this.dropRelations(\"mentions\");\n }\n\n if (data.reactions || data.poll) this.dropRelations(\"emojis\");\n if (\"thread\" in data) this.dropRelations(\"thread\");\n return StructureMixin.prototype[kPatch].call(this, data) as this;\n }\n\n public get guildId(): string | null {\n return this[kData].guild_id ?? null;\n }\n\n /**\n * Whether the message was sent by Discord, e.g. a member join or a pin notice.\n */\n public get system(): boolean {\n return !NonSystemTypes.includes(this.type);\n }\n\n /**\n * The author. Resolved from `client.users` when the message comes from a manager, so it has the latest known data of\n * the user, not only the copy embedded in the message.\n */\n public get author(): User {\n // Only a partial message lacks its author: it gets an empty user rather than a crash.\n return this[kRelations].author ?? new User(this[kData].author ?? ({} as never));\n }\n\n /**\n * The author as a guild member, or `null` for messages sent outside of a guild or by a webhook.\n */\n public get member(): GuildMember | null {\n const { member: resolved } = this[kRelations];\n if (resolved !== undefined) return resolved;\n const { member, guild_id: guildId, author } = this[kData];\n return member && guildId\n ? new GuildMember({ ...member, user: author, guild_id: guildId })\n : null;\n }\n\n /**\n * The guild the message was sent in, from the cache. `null` outside of guilds, when the guild is not cached, or when\n * the message was not built by a manager: use {@link Message.fetchGuild} to always get it.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * The channel the message was sent in, from the cache. `null` when the channel is not cached, or when the message\n * was not built by a manager: use {@link Message.fetchChannel} to always get it.\n */\n public get channel(): AnyChannel | null {\n return this[kRelations].channel ?? null;\n }\n\n public override get flags(): Readonly<MessageFlagsBitField> {\n return new MessageFlagsBitField(this[kData].flags ?? 0).freeze();\n }\n\n public get attachments(): Attachment[] {\n return (this[kData].attachments ?? []).map((attachment) => new Attachment(attachment));\n }\n\n public get embeds(): Embed[] {\n return (this[kData].embeds ?? []).map((embed) => new Embed(embed));\n }\n\n /**\n * The raw components of the message. Build components with `@discordjs/builders`.\n */\n public get components() {\n return this[kData].components ?? [];\n }\n\n /**\n * The raw sticker items of the message; fetch a full sticker with `client.fetchSticker(id)`.\n */\n public get stickers() {\n return this[kData].sticker_items ?? [];\n }\n\n /**\n * The users, members, roles, and channels the message mentions: their cached copies when the message was built by\n * `client.messages`, like discord.js.\n */\n public get mentions(): MessageMentions {\n return new MessageMentions(this[kData], {\n guild: this.guild,\n ...this[kRelations].mentions,\n });\n }\n\n /**\n * The reactions of the message, whose `message` is this one, and whose custom emojis are the cached ones.\n */\n public get reactions(): ReactionManager {\n return new ReactionManager(\n this.client,\n this.channelId,\n this.id,\n this[kData].reactions ?? [],\n this,\n this[kRelations].emojis,\n );\n }\n\n /**\n * The poll of the message, whose `message` is this one.\n */\n public get poll(): Poll | null {\n const { poll } = this[kData];\n if (!poll) return null;\n return bindClient(\n new Poll(\n { ...poll, channel_id: this.channelId, message_id: this.id },\n { message: this, channel: this.channel, emojis: this[kRelations].emojis },\n ),\n this.client,\n );\n }\n\n /**\n * The reference of a reply, crosspost, forward, or pin notice, if any.\n */\n public get reference() {\n return this[kData].message_reference ?? null;\n }\n\n /**\n * The snapshots of the messages this one forwards.\n */\n public get messageSnapshots() {\n return this[kData].message_snapshots ?? [];\n }\n\n /**\n * The rich presence activity the message was sent with, e.g. a game invite.\n */\n public get activity() {\n return this[kData].activity ?? null;\n }\n\n /**\n * The metadata of the interaction the message answers, if any.\n */\n public get interactionMetadata() {\n return this[kData].interaction_metadata ?? null;\n }\n\n /**\n * The call a call message is about.\n */\n public get call() {\n return this[kData].call ?? null;\n }\n\n /**\n * The subscription a role subscription purchase message is about.\n */\n public get roleSubscriptionData() {\n return this[kData].role_subscription_data ?? null;\n }\n\n /**\n * Whether a thread was started from the message.\n */\n public get hasThread(): boolean {\n return this.flags.has(MessageFlags.HasThread);\n }\n\n /**\n * The thread started from the message, like discord.js's `Message#thread`: the cached thread (its ID is the\n * message's), else the one of the payload.\n */\n public get thread(): AnyThreadChannel | null {\n const resolved = this[kRelations].thread;\n if (resolved) return resolved;\n const { thread } = this[kData] as APIMessage & { thread?: APIThreadChannel };\n return thread ? this.client.threads.createStructure(thread) : null;\n }\n\n /**\n * The content with user, role, and channel mentions replaced by names, and `@everyone`/`@here` defused, like\n * discord.js's `Message#cleanContent`. Mentions of entities that are not cached are kept.\n */\n public get cleanContent(): string {\n const { mentions } = this;\n const members = new Map(\n mentions.members.map((member) => [member.id, member.displayName] as const),\n );\n const users = new Map(\n [...mentions.users, ...mentions.parsedUsers.values()].map(\n (user) => [user.id, user.displayName] as const,\n ),\n );\n const { roles, channels } = mentions;\n return this.content\n .replaceAll(MessageMentions.UsersPattern, (match, id: string) => {\n const name = members.get(id) ?? users.get(id);\n return name ? `@${name}` : match;\n })\n .replaceAll(MessageMentions.RolesPattern, (match, id: string) => {\n const role = roles.get(id);\n return role ? `@${role.name}` : match;\n })\n .replaceAll(MessageMentions.ChannelsPattern, (match, id: string) => {\n const channel = channels.get(id) as { name?: string | null } | undefined;\n return channel?.name ? `#${channel.name}` : match;\n })\n .replaceAll(/@(everyone|here)/g, `@${ZeroWidthSpace}$1`);\n }\n\n public override get createdTimestamp() {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n\n /**\n * When the message was last edited, `null` if it never was.\n */\n public override get editedTimestamp(): number | null {\n return this.optimizedTimestamp(\"edited_timestamp\");\n }\n\n public get editedAt(): Date | null {\n const { editedTimestamp } = this;\n return editedTimestamp === null ? null : new Date(editedTimestamp);\n }\n\n /**\n * The URL to jump to this message.\n */\n public get url(): string {\n return `https://discord.com/channels/${this.guildId ?? \"@me\"}/${this.channelId}/${this.id}`;\n }\n\n /**\n * Whether the message was sent in a guild.\n */\n public inGuild(): boolean {\n return this.guildId !== null;\n }\n\n /**\n * Fetches the channel the message was sent in.\n */\n public fetchChannel(): Promise<AnyChannel> {\n return this.client.channels.fetch(this.channelId);\n }\n\n /**\n * Fetches the guild the message was sent in, `null` outside of guilds.\n */\n public async fetchGuild(): Promise<Guild | null> {\n const { guildId } = this;\n return guildId ? this.client.guilds.fetch(guildId) : null;\n }\n\n /**\n * Fetches the message this one replies to, crossposts, or forwards.\n */\n public async fetchReference(): Promise<Message> {\n const reference = this.reference;\n if (!reference?.message_id) throw new Error(`Message ${this.id} references no message`);\n return this.client.messages.fetch(reference.channel_id ?? this.channelId, reference.message_id);\n }\n\n /**\n * Whether the bot can edit the message: it is the author.\n */\n public async fetchEditable(): Promise<boolean> {\n const client = this.client;\n return this.author.id === (client.user?.id ?? client.id);\n }\n\n /**\n * Whether the bot can delete the message: it is the author, or it has `ManageMessages` in the guild.\n */\n public async fetchDeletable(): Promise<boolean> {\n return (await this.fetchEditable()) || this.hasPermission(\"ManageMessages\");\n }\n\n /**\n * Whether the bot can bulk delete the message: it can delete it, and it is newer than 14 days.\n */\n public async fetchBulkDeletable(): Promise<boolean> {\n return (\n Date.now() - this.createdTimestamp < 14 * 24 * 60 * 60 * 1000 &&\n (await this.hasPermission(\"ManageMessages\"))\n );\n }\n\n /**\n * Whether the bot can pin the message: it is not a system message, and the bot has `PinMessages`.\n */\n public async fetchPinnable(): Promise<boolean> {\n if (this.system) return false;\n return !this.inGuild() || this.hasPermission(\"PinMessages\");\n }\n\n /**\n * Whether the bot can publish the message: it is in an announcement channel, not crossposted yet, and the bot\n * authored it or has `ManageMessages`.\n */\n public async fetchCrosspostable(): Promise<boolean> {\n if (this.flags.has(MessageFlags.Crossposted) || this.system || !this.inGuild()) return false;\n const channel = await this.fetchChannel();\n if (channel.type !== ChannelType.GuildAnnouncement) return false;\n return (await this.fetchEditable()) || this.hasPermission(\"ManageMessages\");\n }\n\n /**\n * Whether the message is partial: built from its IDs alone for an event about an uncached message, see\n * `Partials.Message`. Only `id`, `channelId`, and `guildId` are reliable then, and {@link Message.fetch} completes\n * it.\n */\n public get partial(): boolean {\n return this[kData].author === undefined;\n }\n\n /**\n * Fetches the message from the API and patches this structure with the result.\n */\n public async fetch(): Promise<this> {\n const message = await this.client.messages.fetch(this.channelId, this.id, {\n force: true,\n });\n return this[kPatch](message.toJSON());\n }\n\n /**\n * Edits the message.\n *\n * @param options The changes, or the new content.\n */\n public async edit(options: MessagePayloadResolvable<MessageEditOptions>): Promise<this> {\n const message = await this.client.messages.edit(\n this.channelId,\n this.id,\n MessagePayload.create(this, options, { edit: true }),\n );\n return this[kPatch](message.toJSON());\n }\n\n /**\n * Replies to the message.\n *\n * @param options The reply, or its content.\n */\n public reply(options: MessagePayloadResolvable<MessageCreateOptions>): Promise<Message> {\n const payload = MessagePayload.create(this, options);\n return this.client.messages.send(\n this.channelId,\n MessagePayload.create(this, {\n ...payload.options,\n reply: { messageReference: this },\n }),\n );\n }\n\n /**\n * Forwards the message to another channel.\n *\n * @param channelId The ID of the channel to forward it to.\n */\n public forward(channelId: string): Promise<Message> {\n return this.client.messages.forward(this.channelId, this.id, channelId);\n }\n\n public async delete(reason?: string): Promise<this> {\n await this.client.messages.delete(this.channelId, this.id, reason);\n return this;\n }\n\n public async pin(reason?: string): Promise<this> {\n await this.client.messages.pin(this.channelId, this.id, reason);\n return this[kPatch]({ pinned: true });\n }\n\n public async unpin(reason?: string): Promise<this> {\n await this.client.messages.unpin(this.channelId, this.id, reason);\n return this[kPatch]({ pinned: false });\n }\n\n /**\n * Reacts to the message as the bot.\n *\n * @param emoji The emoji.\n */\n public async react(emoji: EmojiIdentifierResolvable): Promise<this> {\n await this.client.messages.react(this.channelId, this.id, emoji);\n return this;\n }\n\n /**\n * Publishes the message of an announcement channel to the channels following it.\n */\n public async crosspost(): Promise<this> {\n const message = await this.client.messages.crosspost(this.channelId, this.id);\n return this[kPatch](message.toJSON());\n }\n\n /**\n * Starts a thread from the message.\n *\n * @param options The thread's name and settings.\n */\n public startThread(options: MessageThreadCreateOptions): Promise<AnyThreadChannel> {\n return this.client.messages.startThread(this.channelId, this.id, options);\n }\n\n /**\n * Hides or shows the embeds of the message.\n *\n * @param suppress Whether to hide them.\n */\n public suppressEmbeds(suppress = true): Promise<this> {\n const flags = new MessageFlagsBitField(this.flags.bitField);\n if (suppress) flags.add(MessageFlags.SuppressEmbeds);\n else flags.remove(MessageFlags.SuppressEmbeds);\n return this.edit({ flags: Number(flags.bitField) });\n }\n\n /**\n * Removes every attachment of the message.\n */\n public removeAttachments(): Promise<this> {\n return this.edit({ attachments: [] });\n }\n\n /**\n * Whether this message has the same data as another one, or as a raw message.\n * @param message The message to compare with.\n */\n public equals(message: Message | APIMessage): boolean {\n const other = message instanceof Message ? message.toJSON() : message;\n return (\n this.id === other.id &&\n this.content === other.content &&\n this.author.id === other.author.id &&\n this.pinned === other.pinned &&\n this.tts === other.tts &&\n this.editedTimestamp ===\n (other.edited_timestamp ? Date.parse(other.edited_timestamp) : null) &&\n isDeepEqual(this[kData].embeds, other.embeds) &&\n isDeepEqual(this[kData].attachments, other.attachments)\n );\n }\n\n public override toJSON(): CacheEntityTypes[\"messages\"] {\n return BaseStructure.prototype.toJSON.call(this) as CacheEntityTypes[\"messages\"];\n }\n\n public toString(): string {\n return this.content;\n }\n\n // The bot's permissions in the message's channel, overwrites included.\n private async hasPermission(permission: PermissionsString): Promise<boolean> {\n const { guildId } = this;\n if (!guildId) return false;\n const me = await this.client.members.fetchMe(guildId);\n return (await me.fetchPermissionsIn(this.channelId)).has(permission);\n }\n}\n\nMixin(Message, [StructureMixin]);\n","import { messageKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n MessageFlags,\n Routes,\n type APIMessage,\n type RESTGetAPIChannelMessagesPinsResult,\n type RESTPatchAPIChannelMessageJSONBody,\n type RESTPostAPIChannelMessagesThreadsJSONBody,\n type ThreadAutoArchiveDuration,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { Message } from \"../structures/messages/Message.js\";\nimport {\n ReactionEmoji,\n type EmojiIdentifierResolvable,\n} from \"../structures/emojis/ReactionEmoji.js\";\nimport { type User } from \"../structures/users/User.js\";\nimport { whenAll, whenCachedMap } from \"../util/cache.js\";\nimport type { GuildEmoji } from \"../structures/emojis/GuildEmoji.js\";\nimport {\n MessageMentions,\n type MessageMentionsRelations,\n} from \"../structures/messages/MessageMentions.js\";\nimport {\n MessagePayload,\n type MessageCreateOptions,\n type MessageEditOptions,\n type MessagePayloadResolvable,\n} from \"../util/messages.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\nimport type { AnyThreadChannel } from \"./ThreadManager.js\";\n\n/**\n * The options to list the messages of a channel with. `before`, `after`, and `around` are exclusive.\n */\nexport interface MessageListOptions {\n /**\n * How many messages to fetch, up to 100.\n *\n * @default 50\n */\n limit?: number;\n before?: string;\n after?: string;\n around?: string;\n}\n\n/**\n * The options to start a thread from a message with.\n */\nexport interface MessageThreadCreateOptions {\n name: string;\n autoArchiveDuration?: ThreadAutoArchiveDuration;\n rateLimitPerUser?: number;\n reason?: string;\n}\n\n/**\n * A pinned message, with the time it was pinned at.\n */\nexport interface PinnedMessage {\n message: Message;\n pinnedTimestamp: number;\n}\n\n/**\n * The upper bound of the messages `bulkDelete` accepts: Discord refuses messages older than 14 days.\n */\nconst BulkDeleteMaxAge = 14 * 24 * 60 * 60 * 1000;\n\n/**\n * Manages the {@link Message}s known to the client.\n */\nexport class MessageManager extends CachedManager<\n \"messages\",\n Message,\n [channelId: string, messageId: string]\n> {\n public constructor(client: GatewayClient) {\n super(client, \"messages\");\n }\n\n public createStructure(data: CacheEntityTypes[\"messages\"]): Message {\n return new Message(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"messages\"]): string {\n return this.resolveKey(data.channel_id, data.id);\n }\n\n /**\n * Adds a message to the cache, its author to `client.users` (unless a webhook sent it), and its member to\n * `client.members`.\n *\n * @internal\n */\n public override async _add(\n data: CacheEntityTypes[\"messages\"],\n cache = true,\n options?: AddOptions,\n ): Promise<Message> {\n const { author, member, guild_id: guildId } = data;\n await this.client.users._add(author, cache && !data.webhook_id);\n if (member && guildId) {\n await this.client.members._add({ ...member, user: author, guild_id: guildId }, cache);\n }\n\n return super._add(data, cache, options);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"messages\"]): Awaitable<Message> {\n const { author, member, guild_id: guildId } = data;\n return whenAll(\n [\n // A webhook is not a user: its author only holds for this message.\n data.webhook_id\n ? this.client.users.createStructure(author)\n : this.client.users._resolveData(author),\n member && guildId\n ? this.client.members._resolveData({ ...member, user: author, guild_id: guildId })\n : null,\n this.cachedGuild(guildId),\n this.client.channels._get(data.channel_id),\n (data as { thread?: unknown }).thread !== undefined ||\n ((data.flags ?? 0) & MessageFlags.HasThread) !== 0\n ? this.client.threads._get(data.id)\n : undefined,\n this.resolveMentions(data),\n guildId ? this.resolveEmojis(guildId, data) : undefined,\n ],\n ([resolvedAuthor, resolvedMember, guild, channel, thread, mentions, emojis]) =>\n new Message(data, {\n author: resolvedAuthor,\n member: resolvedMember,\n guild,\n channel: channel ?? null,\n thread: thread ?? null,\n mentions,\n emojis,\n }),\n );\n }\n\n // The cached copies of the users, members, roles, and channels a message mentions, like discord.js's mentions.\n private resolveMentions(data: CacheEntityTypes[\"messages\"]): Awaitable<MessageMentionsRelations> {\n const { client } = this;\n const { guild_id: guildId, content = \"\" } = data;\n const users = [\n ...data.mentions.map((user) => user.id),\n ...MessageMentions.parseIds(content, MessageMentions.UsersPattern),\n ...(data.referenced_message ? [data.referenced_message.author.id] : []),\n ];\n const members = data.mentions.filter((user) => \"member\" in user).map((user) => user.id);\n return whenAll(\n [\n whenCachedMap(users, (id) => client.users._get(id)),\n guildId ? whenCachedMap(members, (id) => client.members._get(guildId, id)) : undefined,\n guildId\n ? whenCachedMap(data.mention_roles, (id) => client.roles._get(guildId, id))\n : undefined,\n whenCachedMap(MessageMentions.parseIds(content, MessageMentions.ChannelsPattern), (id) =>\n client.channels._get(id),\n ),\n ],\n ([resolvedUsers, resolvedMembers, roles, channels]) => ({\n users: resolvedUsers,\n members: resolvedMembers,\n roles,\n channels,\n }),\n );\n }\n\n // The cached custom emojis of a message's reactions and poll answers, from its own guild.\n private resolveEmojis(\n guildId: string,\n data: CacheEntityTypes[\"messages\"],\n ): Awaitable<Map<string, GuildEmoji>> {\n const ids = [\n ...(data.reactions ?? []).map((reaction) => reaction.emoji.id),\n ...(data.poll?.answers ?? []).map((answer) => answer.poll_media.emoji?.id),\n ].filter((id): id is string => Boolean(id));\n const emojis = this.client.guilds.emojis(guildId);\n return whenCachedMap(ids, (id) => emojis._get(id));\n }\n\n public resolveKey(channelId: string, messageId: string): string {\n return messageKey(channelId, messageId);\n }\n\n /**\n * Lists the messages of a channel, newest first, and caches them.\n *\n * @param channelId The ID of the channel.\n * @param options How many messages, and around which one.\n */\n public async list(channelId: string, options: MessageListOptions = {}): Promise<Message[]> {\n const messages = await this.client.api.channels.getMessages(channelId, {\n limit: options.limit ?? 50,\n before: options.before,\n after: options.after,\n around: options.around,\n });\n return Promise.all(messages.map((message) => this.store(message)));\n }\n\n /**\n * Sends a message to a channel.\n *\n * @param channelId The ID of the channel.\n * @param options The message, or its content.\n */\n public async send(\n channelId: string,\n options: MessagePayloadResolvable<MessageCreateOptions>,\n ): Promise<Message> {\n const { body, files } = await MessagePayload.create(this.client, options).resolve();\n const message = await this.client.api.channels.createMessage(channelId, {\n ...body,\n files,\n });\n return this.store(message);\n }\n\n /**\n * Forwards a message to another channel.\n *\n * @param channelId The ID of the channel of the message.\n * @param messageId The ID of the message.\n * @param targetChannelId The ID of the channel to forward it to.\n */\n public forward(channelId: string, messageId: string, targetChannelId: string): Promise<Message> {\n return this.send(targetChannelId, {\n forward: { message: messageId, channel: channelId },\n });\n }\n\n /**\n * Edits a message.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message.\n * @param options The changes, or the new content.\n */\n public async edit(\n channelId: string,\n messageId: string,\n options: MessagePayloadResolvable<MessageEditOptions>,\n ): Promise<Message> {\n const { body, files } = await MessagePayload.create(this.client, options, {\n edit: true,\n }).resolve<RESTPatchAPIChannelMessageJSONBody>();\n const message = await this.client.api.channels.editMessage(channelId, messageId, {\n ...body,\n files,\n });\n return this.store(message);\n }\n\n /**\n * Deletes a message.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message.\n * @param reason The reason for the audit log, when deleting someone else's message.\n */\n public async delete(channelId: string, messageId: string, reason?: string): Promise<void> {\n await this.client.api.channels.deleteMessage(channelId, messageId, { reason });\n await this.cache?.delete(this.resolveKey(channelId, messageId));\n }\n\n /**\n * Deletes up to 100 messages at once, skipping the ones older than 14 days that Discord refuses.\n *\n * @param channelId The ID of the channel.\n * @param messages The IDs of the messages, or how many of the latest ones to delete.\n * @param filterOld Whether to drop the messages older than 14 days instead of letting the request fail.\n * @returns The IDs of the deleted messages.\n */\n public async bulkDelete(\n channelId: string,\n messages: readonly string[] | number,\n filterOld = false,\n ): Promise<string[]> {\n let ids =\n typeof messages === \"number\"\n ? (await this.list(channelId, { limit: messages })).map((message) => message.id)\n : [...messages];\n\n if (filterOld) {\n const oldest = Date.now() - BulkDeleteMaxAge;\n ids = ids.filter((id) => Number((BigInt(id) >> 22n) + 1_420_070_400_000n) > oldest);\n }\n\n if (ids.length === 0) return [];\n if (ids.length === 1) {\n await this.delete(channelId, ids[0]!);\n } else {\n await this.client.api.channels.bulkDeleteMessages(channelId, ids);\n await Promise.all(ids.map((id) => this.cache?.delete(this.resolveKey(channelId, id))));\n }\n\n return ids;\n }\n\n /**\n * Fetches the pinned messages of a channel, most recently pinned first, and caches them.\n *\n * @param channelId The ID of the channel.\n * @param options How many pins to fetch (up to 50), and before which pin time.\n */\n public async fetchPins(\n channelId: string,\n options: { limit?: number; before?: Date | number } = {},\n ): Promise<{ items: PinnedMessage[]; hasMore: boolean }> {\n const query = new URLSearchParams();\n if (options.limit) query.set(\"limit\", String(options.limit));\n if (options.before !== undefined) query.set(\"before\", new Date(options.before).toISOString());\n\n const result = (await this.client.api.rest.get(Routes.channelMessagesPins(channelId), {\n query,\n })) as RESTGetAPIChannelMessagesPinsResult;\n const items = await Promise.all(\n result.items.map(async (item) => ({\n message: await this.store(item.message),\n pinnedTimestamp: Date.parse(item.pinned_at),\n })),\n );\n return { items, hasMore: result.has_more };\n }\n\n /**\n * Pins a message.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message.\n * @param reason The reason for the audit log.\n */\n public async pin(channelId: string, messageId: string, reason?: string): Promise<void> {\n await this.client.api.channels.pinMessage(channelId, messageId, { reason });\n await this.patchCached(channelId, messageId, { pinned: true });\n }\n\n /**\n * Unpins a message.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message.\n * @param reason The reason for the audit log.\n */\n public async unpin(channelId: string, messageId: string, reason?: string): Promise<void> {\n await this.client.api.channels.unpinMessage(channelId, messageId, { reason });\n await this.patchCached(channelId, messageId, { pinned: false });\n }\n\n /**\n * Publishes a message of an announcement channel to the channels following it.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message.\n */\n public async crosspost(channelId: string, messageId: string): Promise<Message> {\n const message = await this.client.api.channels.crosspostMessage(channelId, messageId);\n return this.store(message);\n }\n\n /**\n * Reacts to a message as the bot.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message.\n * @param emoji The emoji.\n */\n public async react(\n channelId: string,\n messageId: string,\n emoji: EmojiIdentifierResolvable,\n ): Promise<void> {\n await this.client.api.channels.addMessageReaction(\n channelId,\n messageId,\n ReactionEmoji.resolveIdentifier(emoji),\n );\n }\n\n /**\n * Removes every reaction with one emoji from a message.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message.\n * @param emoji The emoji.\n */\n public async removeReactionEmoji(\n channelId: string,\n messageId: string,\n emoji: EmojiIdentifierResolvable,\n ): Promise<void> {\n await this.client.api.channels.deleteAllMessageReactionsForEmoji(\n channelId,\n messageId,\n ReactionEmoji.resolveIdentifier(emoji),\n );\n }\n\n /**\n * Removes every reaction from a message.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message.\n */\n public async removeAllReactions(channelId: string, messageId: string): Promise<void> {\n await this.client.api.channels.deleteAllMessageReactions(channelId, messageId);\n await this.patchCached(channelId, messageId, { reactions: [] });\n }\n\n /**\n * Starts a thread from a message.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message.\n * @param options The thread's name and settings.\n */\n public async startThread(\n channelId: string,\n messageId: string,\n options: MessageThreadCreateOptions,\n ): Promise<AnyThreadChannel> {\n const body: RESTPostAPIChannelMessagesThreadsJSONBody = {\n name: options.name,\n auto_archive_duration: options.autoArchiveDuration,\n rate_limit_per_user: options.rateLimitPerUser,\n };\n const thread = await this.client.api.channels.createThread(channelId, body, messageId, {\n reason: options.reason,\n });\n return this.client.threads._add(thread);\n }\n\n /**\n * Ends a poll now. Only the bot's own polls can be ended.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message holding the poll.\n */\n public async endPoll(channelId: string, messageId: string): Promise<Message> {\n const message = await this.client.api.poll.expirePoll(channelId, messageId);\n return this.store(message);\n }\n\n /**\n * Fetches the users who voted for an answer of a poll, paginated by user ID.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message holding the poll.\n * @param answerId The ID of the answer.\n * @param options How many voters to fetch (up to 100), and after which user ID.\n */\n public async fetchPollAnswerVoters(\n channelId: string,\n messageId: string,\n answerId: number,\n options: { limit?: number; after?: string } = {},\n ): Promise<User[]> {\n const { users } = await this.client.api.poll.getAnswerVoters(\n channelId,\n messageId,\n answerId,\n options,\n );\n return Promise.all(users.map((user) => this.client.users._add(user)));\n }\n\n protected async fetchRaw(channelId: string, messageId: string) {\n return this.client.api.channels.getMessage(channelId, messageId);\n }\n\n private store(message: APIMessage): Promise<Message> {\n return this._add(message);\n }\n\n private async patchCached(\n channelId: string,\n messageId: string,\n patch: Partial<CacheEntityTypes[\"messages\"]>,\n ): Promise<void> {\n const key = this.resolveKey(channelId, messageId);\n const cached = await this.cache?.get(key);\n if (cached) await this.cache!.set(key, { ...cached, ...patch });\n }\n}\n","import type { ImageURLOptions } from \"@discordjs/rest\";\nimport type { Partialize } from \"@discordjs/structures\";\nimport type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { APIRoleTags } from \"discord-api-types/v10\";\nimport type { RoleEditOptions } from \"../../managers/RoleManager.js\";\nimport { cdn } from \"../../util/cdn.js\";\nimport { RoleFlagsBitField } from \"../../util/flags.js\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport { compareRolePositions, computePermissionsIn } from \"../../util/permissions.js\";\nimport { PermissionsBitField, type PermissionResolvable } from \"../../util/PermissionsBitField.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kPatch, kRelations, snowflakeTimestamp, Structure } from \"../Structure.js\";\n\n/**\n * The colors of a role: `primaryColor` alone for a solid color, with `secondaryColor` for a gradient, and with\n * `tertiaryColor` for the holographic style.\n */\nexport interface RoleColors {\n primaryColor: number;\n secondaryColor: number | null;\n tertiaryColor: number | null;\n}\nconst kOptimizedPermissions: unique symbol = Symbol(\"role.permissions\");\n\n/**\n * A Discord guild role.\n */\nexport class Role<Omitted extends keyof CacheEntityTypes[\"roles\"] | \"\" = \"\"> extends Structure<\n CacheEntityTypes[\"roles\"],\n Omitted\n> {\n declare public [kRelations]: { guild?: Guild | null };\n declare protected [kOptimizedPermissions]: bigint;\n\n protected override optimizeData(data: Partial<CacheEntityTypes[\"roles\"]>): void {\n if (data.permissions !== undefined) this[kOptimizedPermissions] = BigInt(data.permissions);\n }\n\n /**\n * The template used for removing data from the raw data stored for each role\n */\n public static override readonly DataTemplate: Partial<CacheEntityTypes[\"roles\"]> = {};\n\n /**\n * @param data - The raw data received from the API for the role\n * @param relations - The guild as resolved from the cache, by `client.roles`\n */\n public constructor(\n data: Partialize<CacheEntityTypes[\"roles\"], Omitted>,\n relations: { guild?: Guild | null } = {},\n ) {\n super(data, relations);\n }\n\n public get id() {\n return this[kData].id;\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n /**\n * The guild, from the cache. `null` when the guild is not cached, or when the role was not built by a manager: use\n * `fetchGuild()` to always get it.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * Fetches the guild, cache first.\n */\n public fetchGuild(): Promise<Guild> {\n return this.client.guilds.fetch(this.guildId);\n }\n\n public get name() {\n return this[kData].name;\n }\n\n /**\n * The primary color of the role, `0` when it has none.\n */\n public get color() {\n return this[kData].colors?.primary_color ?? this[kData].color;\n }\n\n /**\n * The primary color of the role as a `#rrggbb` string.\n */\n public get hexColor(): `#${string}` {\n return `#${this.color.toString(16).padStart(6, \"0\")}`;\n }\n\n public get colors(): RoleColors {\n const { colors } = this[kData];\n return {\n primaryColor: colors?.primary_color ?? this[kData].color,\n secondaryColor: colors?.secondary_color ?? null,\n tertiaryColor: colors?.tertiary_color ?? null,\n };\n }\n\n public get position() {\n return this[kData].position;\n }\n\n public get permissions(): Readonly<PermissionsBitField> {\n return new PermissionsBitField(this[kOptimizedPermissions] ?? 0n).freeze();\n }\n\n /**\n * Fetches the role's permissions in a channel: its permissions and `@everyone`'s, with the channel's `@everyone` and\n * role overwrites applied. discord.js: `role.permissionsIn(channel)`.\n *\n * @param channel The channel, or its ID. Threads use their parent's overwrites.\n */\n public fetchPermissionsIn(channel: AnyChannel | string): Promise<Readonly<PermissionsBitField>> {\n return computePermissionsIn(channel, this as unknown as Role);\n }\n\n public get hoist() {\n return this[kData].hoist;\n }\n\n public get managed() {\n return this[kData].managed;\n }\n\n public get mentionable() {\n return this[kData].mentionable;\n }\n\n public get icon(): string | null {\n return this[kData].icon ?? null;\n }\n\n public get unicodeEmoji(): string | null {\n return this[kData].unicode_emoji ?? null;\n }\n\n /**\n * What the role belongs to: a bot, an integration, the server boosters, or a subscription listing.\n */\n public get tags(): APIRoleTags | null {\n return this[kData].tags ?? null;\n }\n\n public get flags(): Readonly<RoleFlagsBitField> {\n return new RoleFlagsBitField(this[kData].flags ?? 0).freeze();\n }\n\n public get createdTimestamp() {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt(): Date {\n return new Date(this.createdTimestamp);\n }\n\n /**\n * Gets the URL of the role's icon, or `null` if it has none.\n * @param options The image options.\n */\n public iconURL(options?: ImageURLOptions): string | null {\n const { icon } = this;\n return icon ? cdn.roleIcon(this.id, icon, options) : null;\n }\n\n /**\n * Compares this role's position with another one's.\n *\n * @param role The role to compare with.\n * @returns A negative number when this role is lower, a positive one when it is higher, `0` when they are the same.\n */\n public comparePositionTo(role: Pick<Role, \"id\" | \"position\">): number {\n return compareRolePositions(this, role);\n }\n\n /**\n * Whether the client's member can edit this role, i.e. it has `ManageRoles` and a higher role.\n */\n public async fetchEditable(): Promise<boolean> {\n if (this.managed) return false;\n\n const client = this.client;\n const me = await client.members.fetchMe(this.guildId);\n const permissions = await me.fetchPermissions();\n if (!permissions.has(\"ManageRoles\")) return false;\n\n const highest = await me.roles.fetchHighest();\n return highest !== null && highest.comparePositionTo(this) > 0;\n }\n\n /**\n * Edits the role.\n *\n * @param options The fields to edit.\n * @returns This role, patched.\n */\n public async edit(options: RoleEditOptions): Promise<this> {\n const role = await this.client.roles.edit(this.guildId, this.id, options);\n return this[kPatch](role.toJSON());\n }\n\n public setName(name: string, reason?: string): Promise<this> {\n return this.edit({ name, reason });\n }\n\n public setColors(colors: Partial<RoleColors> & { primaryColor: number }, reason?: string) {\n return this.edit({ colors, reason });\n }\n\n public setHoist(hoist = true, reason?: string): Promise<this> {\n return this.edit({ hoist, reason });\n }\n\n public setPermissions(permissions: PermissionResolvable, reason?: string): Promise<this> {\n return this.edit({ permissions, reason });\n }\n\n public setMentionable(mentionable = true, reason?: string): Promise<this> {\n return this.edit({ mentionable, reason });\n }\n\n /**\n * Sets the role's icon, as a data URI (`data:image/png;base64,...`), or removes it with `null`.\n */\n public setIcon(icon: string | null, reason?: string): Promise<this> {\n return this.edit({ icon, reason });\n }\n\n public setUnicodeEmoji(unicodeEmoji: string | null, reason?: string): Promise<this> {\n return this.edit({ unicodeEmoji, reason });\n }\n\n /**\n * Moves the role.\n *\n * @param position The new position.\n * @param reason The reason for the audit log.\n */\n public async setPosition(position: number, reason?: string): Promise<this> {\n const roles = await this.client.roles.setPositions(\n this.guildId,\n [{ role: this.id, position }],\n reason,\n );\n // Discord may clamp or shift the requested position: keep what it actually applied.\n const updated = roles.find((role) => role.id === this.id);\n return updated ? this[kPatch](updated.toJSON()) : this;\n }\n\n /**\n * Deletes the role.\n *\n * @param reason The reason for the audit log.\n */\n public async delete(reason?: string): Promise<this> {\n await this.client.roles.delete(this.guildId, this.id, reason);\n return this;\n }\n\n /**\n * Whether this role has the same data as another one.\n * @param role The role to compare with.\n */\n public equals(role: Role): boolean {\n return (\n this.id === role.id &&\n this.name === role.name &&\n this.color === role.color &&\n this.hoist === role.hoist &&\n this.position === role.position &&\n this[kData].permissions === role[kData].permissions &&\n this.managed === role.managed &&\n this.icon === role.icon &&\n this.unicodeEmoji === role.unicodeEmoji\n );\n }\n\n public toString(): `<@&${string}>` | \"@everyone\" {\n // `@everyone` has the guild's ID and is written as is.\n return this.id === this.guildId ? \"@everyone\" : `<@&${this.id}>`;\n }\n}\n","import { roleKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n type APIRole,\n type RESTPatchAPIGuildRoleJSONBody,\n type RESTPatchAPIGuildRolePositionsJSONBody,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { Role, type RoleColors } from \"../structures/guilds/Role.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { PermissionsBitField, type PermissionResolvable } from \"../util/PermissionsBitField.js\";\nimport { CachedManager } from \"./CachedManager.js\";\n\n/**\n * The options to create or edit a role with.\n */\nexport interface RoleEditOptions {\n name?: string;\n /**\n * The primary color alone, see {@link RoleEditOptions.colors} for gradients.\n */\n color?: number;\n colors?: Partial<RoleColors> & { primaryColor: number };\n hoist?: boolean;\n permissions?: PermissionResolvable;\n mentionable?: boolean;\n /**\n * The icon as a data URI (`data:image/png;base64,...`), `null` to remove it.\n */\n icon?: string | null;\n unicodeEmoji?: string | null;\n /**\n * The reason for the audit log.\n */\n reason?: string;\n}\n\n/**\n * A role and the position to move it to.\n */\nexport interface RolePosition {\n role: string;\n position: number;\n}\n\n/**\n * Manages the {@link Role}s known to the client.\n */\nexport class RoleManager extends CachedManager<\"roles\", Role, [guildId: string, roleId: string]> {\n public constructor(client: GatewayClient) {\n super(client, \"roles\");\n }\n\n public createStructure(data: CacheEntityTypes[\"roles\"]): Role {\n return new Role(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"roles\"]): string {\n return this.resolveKey(data.guild_id, data.id);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"roles\"]): Awaitable<Role> {\n return whenAll([this.cachedGuild(data.guild_id)], ([guild]) => new Role(data, { guild }));\n }\n\n public resolveKey(guildId: string, roleId: string): string {\n return roleKey(guildId, roleId);\n }\n\n /**\n * Fetches every role of a guild from the API, and caches them.\n *\n * @param guildId The ID of the guild.\n * @returns The roles, highest first.\n */\n public async fetchAll(guildId: string): Promise<Role[]> {\n const roles = await this.client.api.guilds.getRoles(guildId);\n const structures = await Promise.all(roles.map((role) => this.store(guildId, role)));\n\n return structures.toSorted((a, b) => b.comparePositionTo(a));\n }\n\n /**\n * Fetches how many members each role of a guild has, `@everyone` excluded.\n *\n * @param guildId The ID of the guild.\n * @returns The member count of every role, by role ID.\n */\n public async fetchMemberCounts(guildId: string): Promise<Map<string, number>> {\n const counts = await this.client.api.guilds.getRoleMemberCounts(guildId);\n return new Map(Object.entries(counts));\n }\n\n /**\n * Creates a role.\n *\n * @param guildId The ID of the guild.\n * @param options The role's fields.\n */\n public async create(guildId: string, options: RoleEditOptions = {}): Promise<Role> {\n const role = await this.client.api.guilds.createRole(guildId, toRoleBody(options), {\n reason: options.reason,\n });\n return this.store(guildId, role);\n }\n\n /**\n * Edits a role.\n *\n * @param guildId The ID of the guild.\n * @param roleId The ID of the role.\n * @param options The fields to edit.\n */\n public async edit(guildId: string, roleId: string, options: RoleEditOptions): Promise<Role> {\n const role = await this.client.api.guilds.editRole(guildId, roleId, toRoleBody(options), {\n reason: options.reason,\n });\n return this.store(guildId, role);\n }\n\n /**\n * Deletes a role.\n *\n * @param guildId The ID of the guild.\n * @param roleId The ID of the role.\n * @param reason The reason for the audit log.\n */\n public async delete(guildId: string, roleId: string, reason?: string): Promise<void> {\n await this.client.api.guilds.deleteRole(guildId, roleId, { reason });\n await this.cache?.delete(this.resolveKey(guildId, roleId));\n }\n\n /**\n * Moves a role.\n *\n * @param guildId The ID of the guild.\n * @param roleId The ID of the role.\n * @param position The new position.\n * @param reason The reason for the audit log.\n */\n public async setPosition(\n guildId: string,\n roleId: string,\n position: number,\n reason?: string,\n ): Promise<Role[]> {\n return this.setPositions(guildId, [{ role: roleId, position }], reason);\n }\n\n /**\n * Moves several roles at once.\n *\n * @param guildId The ID of the guild.\n * @param positions The roles and their new positions.\n * @param reason The reason for the audit log.\n * @returns Every role of the guild, highest first.\n */\n public async setPositions(\n guildId: string,\n positions: readonly RolePosition[],\n reason?: string,\n ): Promise<Role[]> {\n const body: RESTPatchAPIGuildRolePositionsJSONBody = positions.map(({ role, position }) => ({\n id: role,\n position,\n }));\n const roles = await this.client.api.guilds.setRolePositions(guildId, body, { reason });\n const structures = await Promise.all(roles.map((role) => this.store(guildId, role)));\n return structures.toSorted((a, b) => b.comparePositionTo(a));\n }\n\n /**\n * Compares the positions of two roles.\n *\n * @returns A negative number when `a` is lower, a positive one when it is higher, `0` when they are the same.\n */\n public comparePositions(a: Role, b: Role): number {\n return a.comparePositionTo(b);\n }\n\n /**\n * Fetches the `@everyone` role of a guild, whose ID is the guild's.\n *\n * @param guildId The ID of the guild.\n */\n public everyone(guildId: string): Promise<Role> {\n return this.fetch(guildId, guildId);\n }\n\n /**\n * Fetches the highest role of a guild.\n *\n * @param guildId The ID of the guild.\n */\n public async highest(guildId: string): Promise<Role | null> {\n return (await this.fetchAll(guildId))[0] ?? null;\n }\n\n /**\n * Fetches the role Discord gives to the server boosters of a guild, if any.\n *\n * @param guildId The ID of the guild.\n */\n public async premiumSubscriberRole(guildId: string): Promise<Role | null> {\n const roles = await this.fetchAll(guildId);\n return roles.find((role) => role.tags?.premium_subscriber === null) ?? null;\n }\n\n /**\n * Fetches the role Discord manages for a bot in a guild, if any.\n *\n * @param guildId The ID of the guild.\n * @param botId The ID of the bot user.\n */\n public async botRoleFor(guildId: string, botId: string): Promise<Role | null> {\n const roles = await this.fetchAll(guildId);\n return roles.find((role) => role.tags?.bot_id === botId) ?? null;\n }\n\n protected async fetchRaw(guildId: string, roleId: string) {\n const role = await this.client.api.guilds.getRole(guildId, roleId);\n return { ...role, guild_id: guildId };\n }\n\n private store(guildId: string, role: APIRole): Promise<Role> {\n return this._add({ ...role, guild_id: guildId });\n }\n}\n\nfunction toRoleBody(options: RoleEditOptions): RESTPatchAPIGuildRoleJSONBody {\n const body: RESTPatchAPIGuildRoleJSONBody = {\n name: options.name,\n color: options.color,\n hoist: options.hoist,\n mentionable: options.mentionable,\n icon: options.icon,\n unicode_emoji: options.unicodeEmoji,\n };\n if (options.permissions !== undefined) {\n body.permissions = PermissionsBitField.resolve(options.permissions).toString();\n }\n\n if (options.colors) {\n body.colors = {\n primary_color: options.colors.primaryColor,\n secondary_color: options.colors.secondaryColor ?? null,\n tertiary_color: options.colors.tertiaryColor ?? null,\n };\n }\n\n return body;\n}\n","import {\n type APIWebhook,\n type RESTPatchAPIWebhookJSONBody,\n type RESTPatchAPIWebhookWithTokenMessageJSONBody,\n type RESTPostAPIChannelWebhookJSONBody,\n type RESTPostAPIWebhookWithTokenJSONBody,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport type { Message } from \"../structures/messages/Message.js\";\nimport { bindClient } from \"../structures/Structure.js\";\nimport { Webhook } from \"../structures/webhooks/Webhook.js\";\nimport { resolveId, type IdResolvable } from \"../util/channels.js\";\nimport {\n MessagePayload,\n type MessagePayloadResolvable,\n type WebhookMessageCreateOptions,\n type WebhookMessageEditOptions,\n type WebhookThreadOptions,\n} from \"../util/messages.js\";\n\nexport type { WebhookMessageCreateOptions, WebhookMessageEditOptions, WebhookThreadOptions };\n\n/**\n * The options to create a webhook with.\n */\nexport interface WebhookCreateOptions {\n name: string;\n /**\n * The avatar, as a data URI.\n */\n avatar?: string | null;\n reason?: string;\n}\n\n/**\n * The options to edit a webhook with.\n */\nexport interface WebhookEditOptions {\n name?: string;\n /**\n * The avatar, as a data URI, `null` to remove it.\n */\n avatar?: string | null;\n /**\n * The channel to move the webhook to. Needs the bot's authorization, not the webhook's token.\n */\n channel?: IdResolvable;\n reason?: string;\n}\n\n/**\n * Manages webhooks. Discord does not send them over the gateway, so they are never cached.\n *\n * @remarks\n * Methods taking a webhook's token call the API with it rather than with the bot's authorization, so they work for\n * webhooks of other applications too.\n */\nexport class WebhookManager {\n public readonly client: GatewayClient;\n\n public constructor(client: GatewayClient) {\n this.client = client;\n }\n\n /**\n * Fetches a webhook.\n *\n * @param webhookId The ID of the webhook.\n * @param token The webhook's token, to fetch it without the bot's authorization.\n */\n public async fetch(webhookId: string, token?: string): Promise<Webhook> {\n const webhook = await this.client.api.webhooks.get(webhookId, { token });\n return this.hydrate(webhook);\n }\n\n /**\n * Fetches the webhooks of a channel.\n *\n * @param channelId The ID of the channel.\n */\n public async fetchChannel(channelId: string): Promise<Webhook[]> {\n const webhooks = await this.client.api.channels.getWebhooks(channelId);\n return Promise.all(webhooks.map((webhook) => this.hydrate(webhook)));\n }\n\n /**\n * Fetches the webhooks of a guild.\n *\n * @param guildId The ID of the guild.\n */\n public async fetchGuild(guildId: string): Promise<Webhook[]> {\n const webhooks = await this.client.api.guilds.getWebhooks(guildId);\n return Promise.all(webhooks.map((webhook) => this.hydrate(webhook)));\n }\n\n /**\n * Creates a webhook in a channel.\n *\n * @param channelId The ID of the channel.\n * @param options The webhook's name and avatar, and the reason for the audit log.\n */\n public async create(channelId: string, options: WebhookCreateOptions): Promise<Webhook> {\n const body: RESTPostAPIChannelWebhookJSONBody = { name: options.name, avatar: options.avatar };\n const webhook = await this.client.api.channels.createWebhook(channelId, body, {\n reason: options.reason,\n });\n return this.hydrate(webhook);\n }\n\n /**\n * Edits a webhook.\n *\n * @param webhookId The ID of the webhook.\n * @param options The fields to edit, and the reason for the audit log.\n * @param token The webhook's token, to edit it without the bot's authorization (which cannot move it).\n */\n public async edit(\n webhookId: string,\n options: WebhookEditOptions,\n token?: string,\n ): Promise<Webhook> {\n const body: RESTPatchAPIWebhookJSONBody = {\n name: options.name,\n avatar: options.avatar,\n channel_id: options.channel === undefined ? undefined : resolveId(options.channel),\n };\n const webhook = await this.client.api.webhooks.edit(webhookId, body, {\n token,\n reason: options.reason,\n });\n return this.hydrate(webhook);\n }\n\n /**\n * Deletes a webhook.\n *\n * @param webhookId The ID of the webhook.\n * @param options The webhook's token, to delete it without the bot's authorization, and the reason for the audit log.\n */\n public async delete(\n webhookId: string,\n options: { token?: string; reason?: string } = {},\n ): Promise<void> {\n await this.client.api.webhooks.delete(webhookId, options);\n }\n\n /**\n * Sends a message through a webhook, and caches it.\n *\n * @param webhookId The ID of the webhook.\n * @param token The webhook's token.\n * @param options The message, or its content, and the thread to send it in.\n */\n public async send(\n webhookId: string,\n token: string,\n options: MessagePayloadResolvable<WebhookMessageCreateOptions>,\n ): Promise<Message> {\n const payload = MessagePayload.create(this.client, options, { webhook: true });\n const { threadId } = payload.options as WebhookThreadOptions;\n const { body, files } = await payload.resolve<RESTPostAPIWebhookWithTokenJSONBody>();\n const message = await this.client.api.webhooks.execute(webhookId, token, {\n ...body,\n files,\n thread_id: threadId,\n wait: true,\n });\n return this.client.messages._add(message);\n }\n\n /**\n * Fetches a message sent by a webhook.\n *\n * @param webhookId The ID of the webhook.\n * @param token The webhook's token.\n * @param messageId The ID of the message.\n * @param options The thread the message is in.\n */\n public async fetchMessage(\n webhookId: string,\n token: string,\n messageId: string,\n options: WebhookThreadOptions = {},\n ): Promise<Message> {\n const message = await this.client.api.webhooks.getMessage(webhookId, token, messageId, {\n thread_id: options.threadId,\n });\n return this.client.messages._add(message);\n }\n\n /**\n * Edits a message sent by a webhook.\n *\n * @param webhookId The ID of the webhook.\n * @param token The webhook's token.\n * @param messageId The ID of the message.\n * @param options The changes, or the new content, and the thread the message is in.\n */\n public async editMessage(\n webhookId: string,\n token: string,\n messageId: string,\n options: MessagePayloadResolvable<WebhookMessageEditOptions>,\n ): Promise<Message> {\n const payload = MessagePayload.create(this.client, options, { webhook: true, edit: true });\n const { threadId } = payload.options as WebhookThreadOptions;\n const { body, files } = await payload.resolve<RESTPatchAPIWebhookWithTokenMessageJSONBody>();\n const message = await this.client.api.webhooks.editMessage(webhookId, token, messageId, {\n ...body,\n files,\n thread_id: threadId,\n });\n return this.client.messages._add(message);\n }\n\n /**\n * Deletes a message sent by a webhook.\n *\n * @param webhookId The ID of the webhook.\n * @param token The webhook's token.\n * @param messageId The ID of the message.\n * @param options The thread the message is in.\n */\n public async deleteMessage(\n webhookId: string,\n token: string,\n messageId: string,\n options: WebhookThreadOptions = {},\n ): Promise<void> {\n await this.client.api.webhooks.deleteMessage(webhookId, token, messageId, {\n thread_id: options.threadId,\n });\n }\n\n /**\n * Builds the structure of a raw webhook, resolving its guild, channel, source guild, source channel, and owner from\n * the cache.\n *\n * @param data The raw webhook.\n */\n public async hydrate(data: APIWebhook): Promise<Webhook> {\n const [guild, channel, sourceGuild, sourceChannel, owner] = await Promise.all([\n data.guild_id ? this.client.guilds.get(data.guild_id) : undefined,\n data.channel_id ? this.client.channels.get(data.channel_id) : undefined,\n data.source_guild ? this.client.guilds.get(data.source_guild.id) : undefined,\n data.source_channel ? this.client.channels.get(data.source_channel.id) : undefined,\n data.user ? this.client.users.resolveData(data.user) : undefined,\n ]);\n return bindClient(\n new Webhook(data, {\n guild: guild ?? null,\n channel: channel ?? null,\n sourceGuild: sourceGuild ?? null,\n sourceChannel: sourceChannel ?? null,\n owner,\n }),\n this.client,\n );\n }\n}\n","import { RouteBases, type APITemplate } from \"discord-api-types/v10\";\nimport type {\n GuildTemplateCreateGuildOptions,\n GuildTemplateEditOptions,\n} from \"../../managers/GuildTemplateManager.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kPatch, kRelations, Structure } from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\n/**\n * The relations of a {@link GuildTemplate}: its source guild, when cached, and its creator.\n */\nexport interface GuildTemplateRelations {\n guild?: Guild | null;\n creator?: User;\n}\n\n/**\n * A guild template: a snapshot of a guild's channels, roles, and settings, to create guilds from.\n */\nexport class GuildTemplate extends Structure<APITemplate> {\n declare public [kRelations]: GuildTemplateRelations;\n\n protected override optimizeData(data: Partial<APITemplate>): void {\n this.optimizeTimestamp(\"created_at\", data.created_at);\n this.optimizeTimestamp(\"updated_at\", data.updated_at);\n }\n\n /**\n * @param data The raw template.\n * @param relations The source guild, as resolved from the cache.\n */\n public constructor(data: APITemplate, relations: GuildTemplateRelations = {}) {\n super(data, relations);\n }\n\n public override [kPatch](data: Readonly<Partial<APITemplate>>): this {\n if (data.creator) this.dropRelations(\"creator\");\n return super[kPatch](data);\n }\n\n public get code() {\n return this[kData].code;\n }\n\n public get name() {\n return this[kData].name;\n }\n\n public get description() {\n return this[kData].description;\n }\n\n public get usageCount() {\n return this[kData].usage_count;\n }\n\n public get creatorId() {\n return this[kData].creator_id;\n }\n\n /**\n * The user who created the template, from the cache, like discord.js, else from the payload.\n */\n public get creator(): User {\n return this[kRelations].creator ?? new User(this[kData].creator);\n }\n\n public get createdTimestamp() {\n return this.optimizedTimestamp(\"created_at\")!;\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n\n /**\n * When the template was last synced with its guild.\n */\n public get updatedTimestamp() {\n return this.optimizedTimestamp(\"updated_at\")!;\n }\n\n public get updatedAt() {\n return new Date(this.updatedTimestamp);\n }\n\n /**\n * The ID of the guild the template was made from.\n */\n public get guildId() {\n return this[kData].source_guild_id;\n }\n\n /**\n * The snapshot of the guild the template creates.\n */\n public get serializedGuild() {\n return this[kData].serialized_source_guild;\n }\n\n /**\n * Whether the guild changed since the template was last synced.\n */\n public get unSynced(): boolean | null {\n return this[kData].is_dirty;\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * The URL to create a guild from the template in the Discord app.\n */\n public get url(): string {\n return `${RouteBases.template}/${this.code}`;\n }\n\n /**\n * Creates a guild from the template, which Discord only allows to bots in fewer than 10 guilds.\n *\n * @param options The name and icon of the guild.\n */\n public createGuild(options: GuildTemplateCreateGuildOptions): Promise<Guild> {\n return this.client.templates.createGuild(this.code, options);\n }\n\n /**\n * Edits the template.\n *\n * @param options The name and description.\n */\n public async edit(options: GuildTemplateEditOptions): Promise<this> {\n const template = await this.client.templates.edit(this.guildId, this.code, options);\n return this[kPatch](template.toJSON());\n }\n\n /**\n * Syncs the template with the current state of its guild.\n */\n public async sync(): Promise<this> {\n const template = await this.client.templates.sync(this.guildId, this.code);\n return this[kPatch](template.toJSON());\n }\n\n public async delete(): Promise<this> {\n await this.client.templates.delete(this.guildId, this.code);\n return this;\n }\n\n public toString(): string {\n return this.code;\n }\n}\n","import {\n Routes,\n type APIGuild,\n type APITemplate,\n type RESTPatchAPIGuildTemplateJSONBody,\n type RESTPostAPIGuildTemplatesJSONBody,\n type RESTPostAPITemplateCreateGuildJSONBody,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport type { Guild } from \"../structures/guilds/Guild.js\";\nimport { GuildTemplate } from \"../structures/guilds/GuildTemplate.js\";\n\n/**\n * The options to create a template with.\n */\nexport interface GuildTemplateCreateOptions {\n name: string;\n description?: string | null;\n}\n\n/**\n * The options to edit a template with.\n */\nexport interface GuildTemplateEditOptions {\n name?: string;\n description?: string | null;\n}\n\n/**\n * The options to create a guild from a template with.\n */\nexport interface GuildTemplateCreateGuildOptions {\n name: string;\n /**\n * The icon, as a data URI.\n */\n icon?: string;\n}\n\n/**\n * Manages guild templates. Discord does not send them over the gateway, so they are never cached.\n */\nexport class GuildTemplateManager {\n public readonly client: GatewayClient;\n\n public constructor(client: GatewayClient) {\n this.client = client;\n }\n\n /**\n * Fetches a template by its code.\n *\n * @param code The code of the template, or its URL.\n */\n public async fetch(code: string): Promise<GuildTemplate> {\n // Accept `https://discord.new/code` as well as the bare code.\n const resolved = code.split(\"/\").pop()!;\n return this.build(await this.client.api.guilds.getTemplate(resolved));\n }\n\n /**\n * Fetches the templates of a guild.\n *\n * @param guildId The ID of the guild.\n */\n public async list(guildId: string): Promise<GuildTemplate[]> {\n const templates = await this.client.api.guilds.getTemplates(guildId);\n return Promise.all(templates.map((template) => this.build(template)));\n }\n\n /**\n * Creates a template of a guild.\n *\n * @param guildId The ID of the guild.\n * @param options The name and description of the template.\n */\n public async create(\n guildId: string,\n options: GuildTemplateCreateOptions,\n ): Promise<GuildTemplate> {\n const body: RESTPostAPIGuildTemplatesJSONBody = {\n name: options.name,\n description: options.description,\n };\n const template = await this.client.api.guilds.createTemplate(guildId, body);\n return this.build(template);\n }\n\n /**\n * Edits a template.\n *\n * @param guildId The ID of the template's guild.\n * @param code The code of the template.\n * @param options The name and description.\n */\n public async edit(\n guildId: string,\n code: string,\n options: GuildTemplateEditOptions,\n ): Promise<GuildTemplate> {\n const body: RESTPatchAPIGuildTemplateJSONBody = {\n name: options.name,\n description: options.description,\n };\n const template = await this.client.api.guilds.editTemplate(guildId, code, body);\n return this.build(template);\n }\n\n /**\n * Syncs a template with the current state of its guild.\n *\n * @param guildId The ID of the template's guild.\n * @param code The code of the template.\n */\n public async sync(guildId: string, code: string): Promise<GuildTemplate> {\n const template = await this.client.api.guilds.syncTemplate(guildId, code);\n return this.build(template);\n }\n\n /**\n * Deletes a template.\n *\n * @param guildId The ID of the template's guild.\n * @param code The code of the template.\n */\n public async delete(guildId: string, code: string): Promise<void> {\n await this.client.api.guilds.deleteTemplate(guildId, code);\n }\n\n /**\n * Creates a guild from a template, which Discord only allows to bots in fewer than 10 guilds.\n *\n * @param code The code of the template.\n * @param options The name and icon of the guild.\n */\n public async createGuild(code: string, options: GuildTemplateCreateGuildOptions): Promise<Guild> {\n const body: RESTPostAPITemplateCreateGuildJSONBody = { name: options.name, icon: options.icon };\n const guild = (await this.client.api.rest.post(Routes.template(code), {\n body,\n })) as APIGuild;\n return this.client.guilds._add(guild);\n }\n\n private async build(template: APITemplate): Promise<GuildTemplate> {\n const creator = await this.client.users._add(template.creator);\n const guild = (await this.client.guilds.get(template.source_guild_id)) ?? null;\n return new GuildTemplate(template, { guild, creator });\n }\n}\n","import { voiceStateKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { VoiceState } from \"../structures/voice/VoiceState.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { CachedManager } from \"./CachedManager.js\";\n\n/**\n * Manages the voice states of the members connected to voice channels.\n *\n * @remarks\n * The cache holds them when the bot has the `GuildVoiceStates` intent. `fetch` falls back to the API, which only\n * knows the voice states of connected members.\n */\nexport class VoiceStateManager extends CachedManager<\n \"voiceStates\",\n VoiceState,\n [guildId: string, userId: string]\n> {\n public constructor(client: GatewayClient) {\n super(client, \"voiceStates\");\n }\n\n public createStructure(data: CacheEntityTypes[\"voiceStates\"]): VoiceState {\n return new VoiceState(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"voiceStates\"]): string {\n if (!data.guild_id) throw new TypeError(\"Cannot key a voice state outside of a guild\");\n return this.resolveKey(data.guild_id, data.user_id);\n }\n\n public resolveKey(guildId: string, userId: string): string {\n return voiceStateKey(guildId, userId);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"voiceStates\"]): Awaitable<VoiceState> {\n const { member, guild_id: guildId, user_id: userId } = data;\n return whenAll(\n [\n member?.user && guildId\n ? this.client.members._resolveData({ ...member, guild_id: guildId })\n : guildId\n ? this.client.members._get(guildId, userId)\n : null,\n this.cachedGuild(guildId),\n data.channel_id ? this.client.channels._get(data.channel_id) : undefined,\n ],\n ([resolvedMember, guild, channel]) =>\n new VoiceState(data, { member: resolvedMember ?? null, guild, channel: channel ?? null }),\n );\n }\n\n /**\n * Lists the cached voice states of a guild.\n *\n * @param guildId The ID of the guild.\n */\n public async listCached(guildId: string): Promise<VoiceState[]> {\n const prefix = `${guildId}:`;\n const entries = (await this.cache?.entries()) ?? [];\n return Promise.all(\n entries.filter(([key]) => key.startsWith(prefix)).map(([, raw]) => this.hydrate(raw)),\n );\n }\n\n protected async fetchRaw(guildId: string, userId: string) {\n const client = this.client;\n // The bot's own voice state is only reachable as `@me`.\n const target = (client.user?.id ?? client.id) === userId ? \"@me\" : userId;\n const state =\n target === \"@me\"\n ? await client.api.voice.getVoiceState(guildId)\n : await client.api.voice.getUserVoiceState(guildId, target);\n return { ...state, guild_id: guildId };\n }\n}\n","import { presenceKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { Presence } from \"../structures/presences/Presence.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { CachedManager } from \"./CachedManager.js\";\n\n/**\n * Manages the presences of guild members.\n *\n * @remarks\n * Presences only come from the gateway, with the `GuildPresences` intent: there is no API to fetch them, so `fetch`\n * rejects on a cache miss. Use `get`, which resolves to `undefined` instead.\n */\nexport class PresenceManager extends CachedManager<\n \"presences\",\n Presence,\n [guildId: string, userId: string]\n> {\n public constructor(client: GatewayClient) {\n super(client, \"presences\");\n }\n\n public createStructure(data: CacheEntityTypes[\"presences\"]): Presence {\n return new Presence(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"presences\"]): string {\n return this.resolveKey(data.guild_id, data.user.id);\n }\n\n public resolveKey(guildId: string, userId: string): string {\n return presenceKey(guildId, userId);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"presences\"]): Awaitable<Presence> {\n return whenAll(\n [\n this.client.users._get(data.user.id),\n this.client.members._get(data.guild_id, data.user.id),\n this.cachedGuild(data.guild_id),\n ],\n ([user, member, guild]) =>\n new Presence(data, { user: user ?? null, member: member ?? null, guild }),\n );\n }\n\n /**\n * Lists the cached presences of a guild.\n *\n * @param guildId The ID of the guild.\n */\n public async listCached(guildId: string): Promise<Presence[]> {\n const prefix = `${guildId}:`;\n const entries = (await this.cache?.entries()) ?? [];\n return Promise.all(\n entries.filter(([key]) => key.startsWith(prefix)).map(([, raw]) => this.hydrate(raw)),\n );\n }\n\n protected fetchRaw(guildId: string, userId: string): Promise<CacheEntityTypes[\"presences\"]> {\n return Promise.reject(\n new Error(\n `Presences cannot be fetched from the API (user ${userId} of guild ${guildId} is not cached)`,\n ),\n );\n }\n}\n","import type { Awaitable, CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { RawFile } from \"@discordjs/rest\";\nimport {\n ChannelType,\n type ThreadChannelType,\n type APIMessage,\n type APIThreadChannel,\n type APIThreadMember,\n type RESTPostAPIChannelThreadsJSONBody,\n type RESTPostAPIGuildForumThreadsJSONBody,\n type ThreadAutoArchiveDuration,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport type { AnnouncementThreadChannel } from \"../structures/channels/AnnouncementThreadChannel.js\";\nimport type { PrivateThreadChannel } from \"../structures/channels/PrivateThreadChannel.js\";\nimport type { PublicThreadChannel } from \"../structures/channels/PublicThreadChannel.js\";\nimport type { ThreadMember } from \"../structures/channels/ThreadMember.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport {\n MessagePayload,\n type MessageCreateOptions,\n type MessagePayloadResolvable,\n} from \"../util/messages.js\";\nimport { CachedManager } from \"./CachedManager.js\";\nimport { createChannel } from \"./ChannelManager.js\";\n\n/**\n * Any of the thread structures {@link ThreadManager} builds.\n */\nexport type AnyThreadChannel =\n | AnnouncementThreadChannel\n | PrivateThreadChannel\n | PublicThreadChannel;\n\n/**\n * The options to create a thread with.\n */\nexport interface ThreadCreateOptions {\n name: string;\n autoArchiveDuration?: ThreadAutoArchiveDuration;\n rateLimitPerUser?: number;\n /**\n * The type of a thread without a message: public (the default; an announcement thread in announcement channels) or\n * private.\n */\n type?: ChannelType.PublicThread | ChannelType.PrivateThread | ChannelType.AnnouncementThread;\n /**\n * Whether non-moderators can add members to a private thread.\n */\n invitable?: boolean;\n /**\n * The first message of a forum or media post.\n */\n message?: MessagePayloadResolvable<MessageCreateOptions>;\n /**\n * The tags of a forum or media post.\n */\n appliedTags?: readonly string[];\n reason?: string;\n}\n\n/**\n * The options to fetch archived threads with.\n */\nexport interface FetchArchivedThreadsOptions {\n /**\n * Public (the default) or private archived threads.\n */\n type?: \"public\" | \"private\";\n /**\n * Whether to fetch the private archived threads the bot joined, which needs no `ManageThreads`.\n */\n joined?: boolean;\n /**\n * The archive time (or, with `joined`, the thread ID) to fetch threads before.\n */\n before?: Date | number | string;\n limit?: number;\n}\n\n/**\n * Threads fetched in bulk, with the bot's membership of each.\n */\nexport interface FetchedThreads {\n threads: AnyThreadChannel[];\n members: ThreadMember[];\n /**\n * Whether more archived threads are left to fetch.\n */\n hasMore: boolean;\n}\n\n/**\n * Manages the threads known to the client.\n */\nexport class ThreadManager extends CachedManager<\"threads\", AnyThreadChannel, [threadId: string]> {\n public constructor(client: GatewayClient) {\n super(client, \"threads\");\n }\n\n public createStructure(data: CacheEntityTypes[\"threads\"]): AnyThreadChannel {\n return createChannel(data) as AnyThreadChannel;\n }\n\n public keyOf(data: CacheEntityTypes[\"threads\"]): string {\n return data.id;\n }\n\n public override _hydrate(data: CacheEntityTypes[\"threads\"]): Awaitable<AnyThreadChannel> {\n return whenAll(\n [this.cachedGuild(data.guild_id)],\n ([guild]) => this.client.channels._hydrateInGuild(data, guild) as Awaitable<AnyThreadChannel>,\n );\n }\n\n public resolveKey(threadId: string): string {\n return threadId;\n }\n\n /**\n * Creates a thread in a channel. With `message`, creates a post of a forum or media channel.\n *\n * @param channelId The ID of the parent channel.\n * @param options The thread's name and settings, and the first message of a post.\n */\n public async create(channelId: string, options: ThreadCreateOptions): Promise<AnyThreadChannel> {\n const common = {\n name: options.name,\n auto_archive_duration: options.autoArchiveDuration,\n rate_limit_per_user: options.rateLimitPerUser,\n };\n let body: RESTPostAPIChannelThreadsJSONBody | RESTPostAPIGuildForumThreadsJSONBody;\n let files: RawFile[] | undefined;\n if (options.message === undefined) {\n // Discord defaults to a private thread: pick discord.js's default, public (or announcement), client-side.\n const type = options.type ?? (await this.defaultThreadType(channelId));\n body = { ...common, type, invitable: options.invitable };\n } else {\n const message = await MessagePayload.create(this.client, options.message).resolve();\n body = { ...common, message: message.body, applied_tags: options.appliedTags?.slice() };\n files = message.files;\n }\n\n const thread = (\n options.message === undefined\n ? await this.client.api.channels.createThread(\n channelId,\n body as RESTPostAPIChannelThreadsJSONBody,\n undefined,\n { reason: options.reason },\n )\n : await this.client.api.channels.createForumThread(\n channelId,\n {\n ...(body as RESTPostAPIGuildForumThreadsJSONBody),\n message: { ...(body as RESTPostAPIGuildForumThreadsJSONBody).message, files },\n },\n { reason: options.reason },\n )\n ) as APIThreadChannel & { message?: APIMessage };\n // A forum post comes with its first message.\n if (thread.message) await this.client.messages._add(thread.message);\n return this._add(thread);\n }\n\n /**\n * Fetches the active threads of a guild, with the bot's membership of each, and caches them.\n *\n * @param guildId The ID of the guild.\n */\n public async fetchActive(guildId: string): Promise<FetchedThreads> {\n const result = await this.client.api.guilds.getActiveThreads(guildId);\n return this.storeList(result.threads as APIThreadChannel[], result.members, guildId, false);\n }\n\n /**\n * Fetches the archived threads of a channel, most recently archived first, and caches them.\n *\n * @param channelId The ID of the parent channel.\n * @param options Public or private threads (only the joined ones with `joined`), and the page.\n */\n public async fetchArchived(\n channelId: string,\n options: FetchArchivedThreadsOptions = {},\n ): Promise<FetchedThreads> {\n const query = {\n limit: options.limit,\n before:\n options.before === undefined\n ? undefined\n : options.joined\n ? String(options.before)\n : new Date(options.before).toISOString(),\n };\n const result = options.joined\n ? await this.client.api.channels.getJoinedPrivateArchivedThreads(channelId, query)\n : await this.client.api.channels.getArchivedThreads(\n channelId,\n options.type ?? \"public\",\n query,\n );\n const guildId = (result.threads[0] as { guild_id?: string } | undefined)?.guild_id;\n return this.storeList(\n result.threads as APIThreadChannel[],\n result.members,\n guildId,\n result.has_more,\n );\n }\n\n private async defaultThreadType(channelId: string): Promise<ThreadChannelType> {\n const parent = await this.client.channels.fetch(channelId);\n return parent.type === ChannelType.GuildAnnouncement\n ? ChannelType.AnnouncementThread\n : ChannelType.PublicThread;\n }\n\n private async storeList(\n threads: readonly APIThreadChannel[],\n members: readonly APIThreadMember[],\n guildId: string | undefined,\n hasMore: boolean,\n ): Promise<FetchedThreads> {\n return {\n threads: await Promise.all(threads.map((thread) => this._add(thread))),\n members: await Promise.all(\n members.map((member) =>\n this.client.threadMembers._add(guildId ? { ...member, guild_id: guildId } : member),\n ),\n ),\n hasMore,\n };\n }\n\n protected async fetchRaw(threadId: string) {\n return this.client.api.channels.get(threadId) as Promise<APIThreadChannel>;\n }\n}\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { AnyThreadChannel } from \"../../managers/ThreadManager.js\";\nimport type { GuildMember } from \"../guilds/GuildMember.js\";\nimport type { User } from \"../users/User.js\";\nimport { kData, kPatch, kRelations, Structure } from \"../Structure.js\";\n\n/**\n * The relations of a {@link ThreadMember}, resolved from the cache by `client.threadMembers`.\n */\nexport interface ThreadMemberRelations {\n /**\n * The member of the thread's guild, when the payload included it or the cache holds it.\n */\n guildMember?: GuildMember | null;\n thread?: AnyThreadChannel | null;\n user?: User | null;\n}\n\n/**\n * A member of a thread: a user who joined it, or was added to it.\n */\nexport class ThreadMember extends Structure<CacheEntityTypes[\"threadMembers\"]> {\n declare public [kRelations]: ThreadMemberRelations;\n\n protected override optimizeData(data: Partial<CacheEntityTypes[\"threadMembers\"]>): void {\n this.optimizeTimestamp(\"join_timestamp\", data.join_timestamp);\n }\n\n /**\n * @param data The raw thread member.\n * @param relations The guild member, thread, and user as resolved from the cache, by `client.threadMembers`.\n */\n public constructor(\n data: CacheEntityTypes[\"threadMembers\"],\n relations: ThreadMemberRelations = {},\n ) {\n super(data, relations);\n }\n\n public override [kPatch](data: Readonly<Partial<CacheEntityTypes[\"threadMembers\"]>>): this {\n if (data.member) this.dropRelations(\"guildMember\");\n return super[kPatch](data);\n }\n\n /**\n * The ID of the user. Absent only from the thread member the gateway attaches to a thread payload for the bot.\n */\n public get id(): string | null {\n return this[kData].user_id ?? null;\n }\n\n public get threadId(): string | null {\n return this[kData].id ?? null;\n }\n\n /**\n * Whether the thread member is partial: built from its IDs alone for an event about an uncached thread member, see\n * `Partials.ThreadMember`. Only `id`, `threadId`, and `guildId` are reliable then, and {@link ThreadMember.fetch}\n * completes it.\n */\n public get partial(): boolean {\n return this[kData].flags === undefined;\n }\n\n /**\n * Fetches the thread member from the API and patches this structure with the result.\n */\n public async fetch(): Promise<this> {\n const { threadId, id } = this;\n if (!threadId || !id)\n throw new Error(\"A thread member without a thread or user ID cannot be fetched\");\n const member = await this.client.threadMembers.fetch(threadId, id, { force: true });\n return this[kPatch](member.toJSON());\n }\n\n public get joinedTimestamp(): number {\n return this.optimizedTimestamp(\"join_timestamp\")!;\n }\n\n public get joinedAt(): Date {\n return new Date(this.joinedTimestamp);\n }\n\n /**\n * The thread member's notification flags.\n */\n public get flags(): number {\n return this[kData].flags;\n }\n\n /**\n * The member of the thread's guild, when known.\n */\n public get guildMember(): GuildMember | null {\n return this[kRelations].guildMember ?? null;\n }\n\n /**\n * The thread, from the cache, like discord.js's `ThreadMember#thread`. `null` when it is not cached, or when the\n * thread member was not built by a manager.\n */\n public get thread(): AnyThreadChannel | null {\n return this[kRelations].thread ?? null;\n }\n\n /**\n * The user, from the cache, like discord.js's `ThreadMember#user`, else the user of the guild member.\n */\n public get user(): User | null {\n return this[kRelations].user ?? this.guildMember?.user ?? null;\n }\n\n /**\n * Removes the member from the thread.\n */\n public async remove(): Promise<this> {\n const { id, threadId } = this;\n if (!id || !threadId) throw new Error(\"Cannot remove a thread member without its IDs\");\n await this.client.threadMembers.remove(threadId, id);\n return this;\n }\n}\n","import { threadMemberKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport { Routes, type APIThreadMember } from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { ThreadMember } from \"../structures/channels/ThreadMember.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\n\n/**\n * The options to list the members of a thread with.\n */\nexport interface ThreadMemberListOptions {\n /**\n * Whether to include each member's guild member.\n */\n withMember?: boolean;\n /**\n * How many members to fetch, up to 100. Paginating requires `withMember`.\n */\n limit?: number;\n after?: string;\n}\n\n/**\n * Manages the members of every thread known to the client.\n */\nexport class ThreadMemberManager extends CachedManager<\n \"threadMembers\",\n ThreadMember,\n [threadId: string, userId: string]\n> {\n public constructor(client: GatewayClient) {\n super(client, \"threadMembers\");\n }\n\n public createStructure(data: CacheEntityTypes[\"threadMembers\"]): ThreadMember {\n return new ThreadMember(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"threadMembers\"]): string {\n if (!data.id || !data.user_id) {\n throw new TypeError(\"Cannot key a thread member without its IDs\");\n }\n\n return this.resolveKey(data.id, data.user_id);\n }\n\n public resolveKey(threadId: string, userId: string): string {\n return threadMemberKey(threadId, userId);\n }\n\n /**\n * Adds a thread member to the cache, and its guild member to `client.members`.\n *\n * @internal\n */\n public override async _add(\n data: CacheEntityTypes[\"threadMembers\"],\n cache = true,\n options?: AddOptions,\n ): Promise<ThreadMember> {\n const { member, guild_id: guildId } = data;\n if (member?.user && guildId) {\n await this.client.members._add({ ...member, guild_id: guildId }, cache);\n }\n\n return super._add(data, cache, options);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"threadMembers\"]): Awaitable<ThreadMember> {\n const { member, guild_id: guildId, user_id: userId } = data;\n return whenAll(\n [\n member?.user && guildId\n ? this.client.members._resolveData({ ...member, guild_id: guildId })\n : guildId && userId\n ? this.client.members._get(guildId, userId)\n : null,\n data.id ? this.client.threads._get(data.id) : undefined,\n userId ? this.client.users._get(userId) : undefined,\n ],\n ([guildMember, thread, user]) =>\n new ThreadMember(data, {\n guildMember: guildMember ?? null,\n thread: thread ?? null,\n user: user ?? null,\n }),\n );\n }\n\n /**\n * Fetches a member of a thread from the API, bypassing the cache, and caches it.\n *\n * @param threadId The ID of the thread.\n * @param userId The ID of the user.\n * @param options Whether to include the guild member.\n */\n public async fetchWithMember(\n threadId: string,\n userId: string,\n options: { withMember?: boolean } = {},\n ): Promise<ThreadMember> {\n const member = options.withMember\n ? ((await this.client.api.rest.get(Routes.threadMembers(threadId, userId), {\n query: new URLSearchParams({ with_member: \"true\" }),\n })) as APIThreadMember)\n : await this.client.api.threads.getMember(threadId, userId);\n return this._add(await this.withGuildId(threadId, member));\n }\n\n /**\n * Lists the members of a thread, and caches them.\n *\n * @param threadId The ID of the thread.\n * @param options Whether to include the guild members, and the page.\n */\n public async list(\n threadId: string,\n options: ThreadMemberListOptions = {},\n ): Promise<ThreadMember[]> {\n const members =\n options.withMember || options.limit || options.after\n ? ((await this.client.api.rest.get(Routes.threadMembers(threadId), {\n query: new URLSearchParams({\n with_member: String(options.withMember ?? false),\n ...(options.limit && { limit: String(options.limit) }),\n ...(options.after && { after: options.after }),\n }),\n })) as APIThreadMember[])\n : await this.client.api.threads.getAllMembers(threadId);\n const guildId = await this.guildIdOf(threadId);\n return Promise.all(\n members.map((member) => this._add(guildId ? { ...member, guild_id: guildId } : member)),\n );\n }\n\n /**\n * Adds a user to a thread.\n *\n * @param threadId The ID of the thread.\n * @param userId The ID of the user, `\"@me\"` (the default) to join it.\n */\n public async add(threadId: string, userId = \"@me\"): Promise<void> {\n if (userId === \"@me\") await this.client.api.threads.join(threadId);\n else await this.client.api.threads.addMember(threadId, userId);\n }\n\n /**\n * Removes a user from a thread, and from the cache.\n *\n * @param threadId The ID of the thread.\n * @param userId The ID of the user, `\"@me\"` (the default) to leave it.\n */\n public async remove(threadId: string, userId = \"@me\"): Promise<void> {\n if (userId === \"@me\") await this.client.api.threads.leave(threadId);\n else await this.client.api.threads.removeMember(threadId, userId);\n const cachedId = userId === \"@me\" ? (this.client.user?.id ?? this.client.id) : userId;\n await this.cache?.delete(this.resolveKey(threadId, cachedId));\n }\n\n protected async fetchRaw(threadId: string, userId: string) {\n const member = await this.client.api.threads.getMember(threadId, userId);\n return this.withGuildId(threadId, member);\n }\n\n // Thread members from REST lack the guild's ID, which resolving their guild member needs.\n private async withGuildId(\n threadId: string,\n member: APIThreadMember,\n ): Promise<CacheEntityTypes[\"threadMembers\"]> {\n const guildId = await this.guildIdOf(threadId);\n return guildId ? { ...member, guild_id: guildId } : member;\n }\n\n private async guildIdOf(threadId: string): Promise<string | undefined> {\n const thread = await this.client.threads.get(threadId);\n return (thread?.toJSON() as { guild_id?: string } | undefined)?.guild_id;\n }\n}\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport type { DMChannel } from \"../structures/channels/DMChannel.js\";\nimport type { Message } from \"../structures/messages/Message.js\";\nimport { User } from \"../structures/users/User.js\";\nimport type { MessageCreateOptions, MessagePayloadResolvable } from \"../util/messages.js\";\nimport { CachedManager } from \"./CachedManager.js\";\n\n/**\n * Manages the {@link User}s known to the client.\n */\nexport class UserManager extends CachedManager<\"users\", User, [userId: string]> {\n public constructor(client: GatewayClient) {\n super(client, \"users\");\n }\n\n public createStructure(data: CacheEntityTypes[\"users\"]): User {\n return new User(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"users\"]): string {\n return data.id;\n }\n\n public resolveKey(userId: string): string {\n return userId;\n }\n\n /**\n * Opens a direct message channel with a user, or gets the existing one, and caches it.\n *\n * @remarks\n * Discord returns the existing channel when there is one, so this always calls the API: unlike discord.js, there is\n * no synchronous `dmChannel` lookup to try first.\n *\n * @param userId The ID of the user.\n */\n public async createDM(userId: string): Promise<DMChannel> {\n const channel = await this.client.api.users.createDM(userId);\n return (await this.client.channels._add(channel)) as DMChannel;\n }\n\n /**\n * Closes the direct message channel with a user.\n *\n * @param userId The ID of the user.\n * @returns The closed channel.\n */\n public async deleteDM(userId: string): Promise<DMChannel> {\n const channel = await this.createDM(userId);\n await this.client.api.channels.delete(channel.id);\n await this.client.cache?.channels.delete(channel.id);\n return channel;\n }\n\n /**\n * Sends a direct message to a user.\n *\n * @param userId The ID of the user.\n * @param options The message, or its content.\n */\n public async send(\n userId: string,\n options: MessagePayloadResolvable<MessageCreateOptions>,\n ): Promise<Message> {\n const channel = await this.createDM(userId);\n return this.client.messages.send(channel.id, options);\n }\n\n protected async fetchRaw(userId: string) {\n return this.client.api.users.get(userId);\n }\n}\n","import { InviteType } from \"discord-api-types/v10\";\nimport { BaseInvite, type InviteData, type InviteRelations } from \"./BaseInvite.js\";\nimport { GuildInvite } from \"./GuildInvite.js\";\n\n/**\n * An invite to a group direct message. Its channel (name, icon, recipients) is exposed as `channel`.\n */\nexport class GroupDMInvite extends BaseInvite {}\n\n/**\n * Builds the invite structure matching the type of a raw invite.\n *\n * @param data The raw invite.\n * @param relations The related structures, resolved from the cache.\n */\nexport function createInvite(data: InviteData, relations: InviteRelations = {}): BaseInvite {\n switch (data.type ?? (data.guild_id || data.guild ? InviteType.Guild : InviteType.Friend)) {\n case InviteType.Guild:\n return new GuildInvite(data, relations);\n case InviteType.GroupDM:\n return new GroupDMInvite(data, relations);\n default:\n return new BaseInvite(data, relations);\n }\n}\n","import {\n GuildWidgetStyle,\n RouteBases,\n Routes,\n type APIGuildWidget,\n type APIGuildWidgetMember,\n} from \"discord-api-types/v10\";\nimport { kData, Structure } from \"../Structure.js\";\n\n/**\n * A member shown by a guild's widget. Its ID is only an index, not the user's: the widget hides who they are.\n */\nexport class WidgetMember extends Structure<APIGuildWidgetMember> {\n public get id() {\n return this[kData].id;\n }\n\n public get username() {\n return this[kData].username;\n }\n\n public get discriminator() {\n return this[kData].discriminator;\n }\n\n public get avatar() {\n return this[kData].avatar;\n }\n\n public get avatarURL() {\n return this[kData].avatar_url;\n }\n\n public get status() {\n return this[kData].status;\n }\n\n /**\n * The name of what the member is playing, if anything.\n */\n public get activity(): string | null {\n return this[kData].activity?.name ?? null;\n }\n}\n\n/**\n * The public widget of a guild: its online members and voice channels.\n */\nexport class Widget extends Structure<APIGuildWidget> {\n public get id() {\n return this[kData].id;\n }\n\n public get name() {\n return this[kData].name;\n }\n\n /**\n * The invite of the widget's channel, if it has one.\n */\n public get instantInvite() {\n return this[kData].instant_invite;\n }\n\n /**\n * The voice channels everyone can join.\n */\n public get channels() {\n return this[kData].channels;\n }\n\n /**\n * The online members, up to 100.\n */\n public get members(): WidgetMember[] {\n return this[kData].members.map((member) => new WidgetMember(member));\n }\n\n public get presenceCount() {\n return this[kData].presence_count;\n }\n\n /**\n * Gets the URL of the widget's image.\n *\n * @param style The style of the image.\n */\n public imageURL(style: GuildWidgetStyle = GuildWidgetStyle.Shield): string {\n return `${RouteBases.api}${Routes.guildWidgetImage(this.id)}?style=${style}`;\n }\n\n /**\n * Fetches the current state of the widget.\n */\n public fetch(): Promise<Widget> {\n return this.client.fetchGuildWidget(this.id);\n }\n}\n","import type { BaseImageURLOptions } from \"@discordjs/rest\";\nimport { StickerPack as BaseStickerPack } from \"@discordjs/structures\";\nimport type { APIStickerPack } from \"discord-api-types/v10\";\nimport { cdn } from \"../../util/cdn.js\";\nimport { Sticker } from \"./Sticker.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, snowflakeTimestamp, StructureMixin } from \"../Structure.js\";\n\nexport interface StickerPack extends StructureMixin<APIStickerPack> {}\n\n/**\n * A pack of standard stickers: `@discordjs/structures`' `StickerPack`, with its stickers and banner URL.\n */\nexport class StickerPack extends BaseStickerPack {\n /**\n * @param data The raw sticker pack.\n * @param relations The related structures, resolved from the cache.\n */\n public constructor(data: APIStickerPack, relations: object = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n /**\n * The ID of the pack's banner asset, `null` if it has none.\n */\n public get bannerId(): string | null {\n return this.bannerAssetId ?? null;\n }\n\n public get stickers(): Sticker[] {\n return this[kData].stickers.map((sticker) => new Sticker(sticker));\n }\n\n /**\n * The sticker shown as the pack's cover, if any.\n */\n public get coverSticker(): Sticker | null {\n const { coverStickerId } = this;\n return this.stickers.find((sticker) => sticker.id === coverStickerId) ?? null;\n }\n\n public override get createdTimestamp(): number {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n\n /**\n * Gets the URL of the pack's banner, or `null` if it has none.\n * @param options The image options.\n */\n public bannerURL(options?: BaseImageURLOptions): string | null {\n const { bannerId } = this;\n return bannerId ? cdn.stickerPackBanner(bannerId, options) : null;\n }\n}\n\nMixin(StickerPack, [StructureMixin]);\n","import type { GatewayAutoModerationActionExecutionDispatchData } from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { AutoModerationRule } from \"./AutoModerationRule.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport type { GuildMember } from \"../guilds/GuildMember.js\";\nimport { kData, kRelations, Structure } from \"../Structure.js\";\nimport type { User } from \"../users/User.js\";\n\n/**\n * The relations of an {@link AutoModerationActionExecution}, resolved from the cache.\n */\nexport interface AutoModerationActionExecutionRelations {\n guild?: Guild | null;\n user?: User | null;\n member?: GuildMember | null;\n channel?: AnyChannel | null;\n autoModerationRule?: AutoModerationRule | null;\n}\n\n/**\n * An action auto moderation took on a message or a member.\n */\nexport class AutoModerationActionExecution extends Structure<GatewayAutoModerationActionExecutionDispatchData> {\n declare public [kRelations]: AutoModerationActionExecutionRelations;\n\n /**\n * @param data The raw execution.\n * @param relations The guild and user as resolved from the cache.\n */\n public constructor(\n data: GatewayAutoModerationActionExecutionDispatchData,\n relations: AutoModerationActionExecutionRelations = {},\n ) {\n super(data, relations);\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n /**\n * The action taken: blocking the message, alerting a channel, or timing the member out.\n */\n public get action() {\n return this[kData].action;\n }\n\n public get ruleId() {\n return this[kData].rule_id;\n }\n\n public get ruleTriggerType() {\n return this[kData].rule_trigger_type;\n }\n\n public get userId() {\n return this[kData].user_id;\n }\n\n public get channelId(): string | null {\n return this[kData].channel_id ?? null;\n }\n\n /**\n * The ID of the message that triggered the rule. Absent when the message was blocked.\n */\n public get messageId(): string | null {\n return this[kData].message_id ?? null;\n }\n\n /**\n * The ID of the alert message sent to the alert channel, for `SendAlertMessage` actions.\n */\n public get alertSystemMessageId(): string | null {\n return this[kData].alert_system_message_id ?? null;\n }\n\n /**\n * The content that triggered the rule. Needs the `MessageContent` intent.\n */\n public get content() {\n return this[kData].content;\n }\n\n public get matchedKeyword(): string | null {\n return this[kData].matched_keyword;\n }\n\n public get matchedContent(): string | null {\n return this[kData].matched_content;\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n public get user(): User | null {\n return this[kRelations].user ?? null;\n }\n\n /**\n * The member who triggered the rule, from the cache, like discord.js's `AutoModerationActionExecution#member`.\n */\n public get member(): GuildMember | null {\n return this[kRelations].member ?? null;\n }\n\n /**\n * The channel the rule was triggered in, from the cache: `null` when there is none or it is not cached.\n */\n public get channel(): AnyChannel | null {\n return this[kRelations].channel ?? null;\n }\n\n /**\n * The rule that was triggered, from the cache: `null` when it is not cached.\n */\n public get autoModerationRule(): AutoModerationRule | null {\n return this[kRelations].autoModerationRule ?? null;\n }\n\n public fetchRule(): Promise<AutoModerationRule> {\n return this.client.guilds.autoModerationRules(this.guildId).fetch(this.ruleId);\n }\n\n public fetchMember(): Promise<GuildMember> {\n return this.client.members.fetch(this.guildId, this.userId);\n }\n\n public async fetchChannel(): Promise<AnyChannel | null> {\n const { channelId } = this;\n return channelId ? this.client.channels.fetch(channelId) : null;\n }\n}\n","import {\n ActivityType,\n GatewayOpcodes,\n PresenceUpdateStatus,\n type GatewayActivityUpdateData,\n type GatewayPresenceUpdateData,\n type RESTPatchAPICurrentUserJSONBody,\n} from \"discord-api-types/v10\";\nimport { kData, kPatch } from \"../Structure.js\";\nimport { User } from \"./User.js\";\n\n/**\n * The presence to set for the bot user. Omitted fields keep their current value.\n */\nexport interface PresenceData {\n status?: PresenceUpdateStatus;\n afk?: boolean;\n activities?: GatewayActivityUpdateData[];\n /**\n * The shards to update, every shard by default.\n */\n shardId?: number | readonly number[];\n}\n\n/**\n * An activity to set, with its type defaulting to `Playing`.\n */\nexport interface ActivityOptions extends Omit<GatewayActivityUpdateData, \"name\" | \"type\"> {\n type?: ActivityType;\n /**\n * The shards to update, every shard by default.\n */\n shardId?: number | readonly number[];\n}\n\n/**\n * The options to edit the bot user with. Images are data URIs (`data:image/png;base64,...`), `null` removes them.\n */\nexport interface ClientUserEditOptions {\n username?: string;\n avatar?: string | null;\n banner?: string | null;\n}\n\n/**\n * The bot user, as known to the {@link GatewayClient}: a {@link User} that can edit its profile and presence.\n */\nexport class ClientUser extends User {\n #presence: GatewayPresenceUpdateData = {\n since: null,\n activities: [],\n status: PresenceUpdateStatus.Online,\n afk: false,\n };\n\n /**\n * Whether the bot's owner account has two-factor authentication enabled.\n */\n public get mfaEnabled(): boolean {\n return this[kData].mfa_enabled ?? false;\n }\n\n /**\n * Whether the bot is verified.\n */\n public get verified(): boolean {\n return this[kData].verified ?? false;\n }\n\n /**\n * The presence last set through this structure.\n */\n public get presence(): Readonly<GatewayPresenceUpdateData> {\n return this.#presence;\n }\n\n /**\n * Edits the bot user's profile.\n *\n * @param options The fields to edit.\n */\n public async edit(options: ClientUserEditOptions): Promise<this> {\n const body: RESTPatchAPICurrentUserJSONBody = options;\n const user = await this.client.api.users.edit(body);\n await this.client.users._add(user);\n return this[kPatch](user);\n }\n\n public setUsername(username: string): Promise<this> {\n return this.edit({ username });\n }\n\n public setAvatar(avatar: string | null): Promise<this> {\n return this.edit({ avatar });\n }\n\n public setBanner(banner: string | null): Promise<this> {\n return this.edit({ banner });\n }\n\n /**\n * Sets the bot's presence on its shards.\n *\n * @param data The presence to set.\n */\n public async setPresence(data: PresenceData): Promise<Readonly<GatewayPresenceUpdateData>> {\n const { shardId, ...presence } = data;\n this.#presence = {\n ...this.#presence,\n ...presence,\n since: presence.afk ? Date.now() : this.#presence.since,\n };\n\n const gateway = this.client.gateway;\n const shards =\n shardId === undefined\n ? await gateway.getShardIds()\n : typeof shardId === \"number\"\n ? [shardId]\n : shardId;\n await Promise.all(\n shards.map((id) =>\n gateway.send(id, { op: GatewayOpcodes.PresenceUpdate, d: this.#presence }),\n ),\n );\n return this.#presence;\n }\n\n public setStatus(status: PresenceUpdateStatus, shardId?: number | readonly number[]) {\n return this.setPresence({ status, shardId });\n }\n\n /**\n * Sets the bot's activity, or clears it when called without a name.\n *\n * @param name The activity's name.\n * @param options The activity's type and other fields.\n */\n public setActivity(name?: string, options: ActivityOptions = {}) {\n const { shardId, type = ActivityType.Playing, ...activity } = options;\n return this.setPresence({\n activities: name === undefined ? [] : [{ ...activity, name, type }],\n shardId,\n });\n }\n\n public setAFK(afk = true, shardId?: number | readonly number[]) {\n return this.setPresence({ afk, shardId });\n }\n}\n","import type { GatewayTypingStartDispatchData } from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport { GuildMember } from \"../guilds/GuildMember.js\";\nimport { kData, kRelations, Structure } from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\n/**\n * The relations of a {@link Typing}, resolved from the cache by the `typingStart` event.\n */\nexport interface TypingRelations {\n channel?: AnyChannel | null;\n user?: User | null;\n guild?: Guild | null;\n member?: GuildMember | null;\n}\n\n/**\n * A user starting to type in a channel, carried by the `typingStart` event.\n */\nexport class Typing extends Structure<GatewayTypingStartDispatchData> {\n declare public [kRelations]: TypingRelations;\n\n /**\n * @param data The raw dispatch.\n * @param relations The channel, user, guild, and member as resolved from the cache.\n */\n public constructor(data: GatewayTypingStartDispatchData, relations: TypingRelations = {}) {\n super(data, relations);\n }\n public get channelId() {\n return this[kData].channel_id;\n }\n\n public get guildId(): string | null {\n return this[kData].guild_id ?? null;\n }\n\n public get userId() {\n return this[kData].user_id;\n }\n\n /**\n * The time the user started typing, in milliseconds.\n */\n public get startedTimestamp(): number {\n return this[kData].timestamp * 1000;\n }\n\n public get startedAt(): Date {\n return new Date(this.startedTimestamp);\n }\n\n /**\n * The channel the user typed in, from the cache, like discord.js's `Typing#channel`: `null` when it is not cached.\n */\n public get channel(): AnyChannel | null {\n return this[kRelations].channel ?? null;\n }\n\n /**\n * The typing user, from the cache, else the user of the payload's member: `null` in a direct message whose user is\n * not cached.\n */\n public get user(): User | null {\n const resolved = this[kRelations].user;\n if (resolved) return resolved;\n const user = this[kData].member?.user;\n return user ? new User(user) : null;\n }\n\n /**\n * The guild of the channel, from the cache: `null` outside of guilds or when it is not cached.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * The typing member, when the channel is in a guild: the cached member, else the one of the payload.\n */\n public get member(): GuildMember | null {\n const resolved = this[kRelations].member;\n if (resolved) return resolved;\n const { member, guild_id: guildId } = this[kData];\n return member && guildId ? new GuildMember({ ...member, guild_id: guildId }) : null;\n }\n\n /**\n * Whether the user typed in a guild channel.\n */\n public inGuild(): boolean {\n return this.guildId !== null;\n }\n\n /**\n * Fetches the channel the user typed in.\n */\n public fetchChannel(): Promise<AnyChannel> {\n return this.client.channels.fetch(this.channelId);\n }\n\n /**\n * Fetches the typing user.\n */\n public fetchUser(): Promise<User> {\n return this.client.users.fetch(this.userId);\n }\n}\n","import type {\n GatewayChannelPinsUpdateDispatchData,\n GatewayDispatchPayload,\n GatewayGuildDeleteDispatchData,\n GatewayGuildIntegrationsUpdateDispatchData,\n GatewayIntegrationDeleteDispatchData,\n GatewayGuildMemberRemoveDispatchData,\n GatewayGuildMembersChunkDispatchData,\n GatewayGuildRoleDeleteDispatchData,\n GatewayInviteDeleteDispatchData,\n GatewayMessageDeleteBulkDispatchData,\n GatewayMessageDeleteDispatchData,\n GatewayMessageReactionRemoveAllDispatchData,\n ReactionType,\n GatewayGuildScheduledEventUserAddDispatchData,\n GatewayGuildScheduledEventUserRemoveDispatchData,\n GatewayGuildSoundboardSoundDeleteDispatchData,\n GatewayThreadDeleteDispatchData,\n GatewayThreadListSync,\n GatewayThreadMembersUpdateDispatchData,\n GatewayVoiceServerUpdateDispatchData,\n GatewayWebhooksUpdateDispatchData,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport type { AnyChannel } from \"../managers/ChannelManager.js\";\nimport type { AnyThreadChannel } from \"../managers/ThreadManager.js\";\nimport type { AutoModerationActionExecution } from \"../structures/automoderation/AutoModerationActionExecution.js\";\nimport type { AutoModerationRule } from \"../structures/automoderation/AutoModerationRule.js\";\nimport type { Guild } from \"../structures/guilds/Guild.js\";\nimport type { GuildAuditLogsEntry } from \"../structures/guilds/GuildAuditLogsEntry.js\";\nimport type { GuildBan } from \"../structures/guilds/GuildBan.js\";\nimport type { GuildScheduledEvent } from \"../structures/guilds/GuildScheduledEvent.js\";\nimport type { Integration } from \"../structures/guilds/Integration.js\";\nimport type { SoundboardSound } from \"../structures/soundboards/SoundboardSound.js\";\nimport type { StageInstance } from \"../structures/stageInstances/StageInstance.js\";\nimport type { GuildEmoji } from \"../structures/emojis/GuildEmoji.js\";\nimport type { GuildInvite } from \"../structures/invites/GuildInvite.js\";\nimport type { GuildMember } from \"../structures/guilds/GuildMember.js\";\nimport type { Message } from \"../structures/messages/Message.js\";\nimport type { MessageReaction } from \"../structures/messages/MessageReaction.js\";\nimport type { PollAnswer } from \"../structures/polls/PollAnswer.js\";\nimport type { Role } from \"../structures/guilds/Role.js\";\nimport type { Presence } from \"../structures/presences/Presence.js\";\nimport type { Sticker } from \"../structures/stickers/Sticker.js\";\nimport type { ThreadMember } from \"../structures/channels/ThreadMember.js\";\nimport type { Typing } from \"../structures/channels/Typing.js\";\nimport type { User } from \"../structures/users/User.js\";\nimport type { VoiceState } from \"../structures/voice/VoiceState.js\";\n\n/**\n * What a reaction event says besides the reaction and the user.\n */\nexport interface MessageReactionEventDetails {\n /**\n * The ID of the user who reacted, known even when the user is not.\n */\n userId: string;\n type: ReactionType;\n /**\n * Whether the reaction is a super reaction.\n */\n burst: boolean;\n}\n\n/**\n * The events a {@link GatewayClient} emits on top of the base `Client`'s ones, and their arguments.\n *\n * @remarks\n * Update events receive the previous state of the entity as read from the cache before the dispatch was applied, or\n * `null` when it was not cached. Delete events receive the cached entity (or `null`) alongside the raw dispatch data,\n * which always identifies the deleted entity.\n *\n * With the matching `Partials` enabled, uncached messages, users, members, thread members, scheduled events,\n * soundboard sounds, polls, and direct messages are partial structures (`partial` is `true`) instead of `null`.\n */\nexport interface GatewayEventMap {\n /**\n * Emitted for every gateway dispatch, before any processing, with the raw payload.\n */\n raw: [payload: GatewayDispatchPayload, shardId: number];\n /**\n * Emitted for every gateway dispatch once it has been written to the cache (right away without one), before the\n * matching event, with the raw payload. Unlike `raw`, a listener reading the cache sees the dispatch applied, which\n * is what forwarding it to other processes sharing the cache needs.\n *\n * @remarks\n * Not emitted for `INTERACTION_CREATE`, served by the HTTP endpoint, nor for a dispatch dropped because its cache\n * write failed with {@link GatewayClientOptions.cacheFailure} set to `\"skip\"`.\n */\n dispatch: [payload: GatewayDispatchPayload, shardId: number];\n /**\n * Emitted when a shard receives `READY`.\n */\n shardReady: [shardId: number, user: User];\n /**\n * Emitted once, when every shard this client manages has connected and every guild `READY` listed as initially\n * unavailable became available, or {@link GatewayClientOptions.waitGuildTimeout} elapsed, like discord.js's\n * `Client#clientReady` (`ready` before discord.js deprecated it).\n */\n clientReady: [client: GatewayClient];\n /**\n * Emitted when a shard resumes its session.\n */\n shardResume: [shardId: number];\n /**\n * Emitted when a shard's connection closes, it reconnects on its own unless the close code is fatal.\n */\n shardClose: [shardId: number, code: number];\n /**\n * Emitted when a shard runs into an error.\n */\n shardError: [error: Error, shardId: number];\n\n guildCreate: [guild: Guild];\n guildUpdate: [oldGuild: Guild | null, newGuild: Guild];\n /**\n * Emitted when the client leaves a guild, or when it becomes unavailable because of an outage, in which case\n * `data.unavailable` is `true`.\n */\n guildDelete: [guild: Guild | null, data: GatewayGuildDeleteDispatchData];\n\n channelCreate: [channel: AnyChannel];\n channelUpdate: [oldChannel: AnyChannel | null, newChannel: AnyChannel];\n channelDelete: [channel: AnyChannel];\n /**\n * Emitted when a message is pinned or unpinned; `data.last_pin_timestamp` is the time of the last pin left.\n */\n channelPinsUpdate: [data: GatewayChannelPinsUpdateDispatchData];\n /**\n * Emitted when a webhook of a channel is created, updated, or deleted.\n */\n webhooksUpdate: [data: GatewayWebhooksUpdateDispatchData];\n\n threadCreate: [thread: AnyThreadChannel];\n threadUpdate: [oldThread: AnyThreadChannel | null, newThread: AnyThreadChannel];\n threadDelete: [thread: AnyThreadChannel | null, data: GatewayThreadDeleteDispatchData];\n /**\n * Emitted when the bot gains access to a channel's threads, with the active ones and the bot's membership of each.\n */\n threadListSync: [\n threads: AnyThreadChannel[],\n members: ThreadMember[],\n data: GatewayThreadListSync,\n ];\n /**\n * Emitted when the bot's own thread member changes, e.g. its notification settings.\n */\n threadMemberUpdate: [oldMember: ThreadMember | null, newMember: ThreadMember];\n /**\n * Emitted when members are added to or removed from a thread. The removed members are the ones the cache held.\n */\n threadMembersUpdate: [\n added: ThreadMember[],\n removed: ThreadMember[],\n thread: AnyThreadChannel | null,\n data: GatewayThreadMembersUpdateDispatchData,\n ];\n\n messageCreate: [message: Message];\n messageUpdate: [oldMessage: Message | null, newMessage: Message];\n messageDelete: [message: Message | null, data: GatewayMessageDeleteDispatchData];\n messageDeleteBulk: [messages: Message[], data: GatewayMessageDeleteBulkDispatchData];\n\n /**\n * Emitted when a user reacts to a message. The reaction has its counts when the message is cached (`count` is\n * `null` otherwise), and the user is `null` when neither the payload (outside of guilds) nor the cache has it.\n */\n messageReactionAdd: [\n reaction: MessageReaction,\n user: User | null,\n details: MessageReactionEventDetails,\n ];\n /**\n * Emitted when a user removes their reaction. Like `messageReactionAdd`, `count` is `null` only when the message is\n * not cached: removing the last reaction of an emoji from a cached message gives a count of `0`.\n */\n messageReactionRemove: [\n reaction: MessageReaction,\n user: User | null,\n details: MessageReactionEventDetails,\n ];\n /**\n * Emitted when every reaction is removed from a message, with the reactions the cache held.\n */\n messageReactionRemoveAll: [\n message: Message | null,\n reactions: MessageReaction[],\n data: GatewayMessageReactionRemoveAllDispatchData,\n ];\n /**\n * Emitted when every reaction with one emoji is removed from a message.\n */\n messageReactionRemoveEmoji: [reaction: MessageReaction];\n /**\n * Emitted when a user votes for a poll answer. The answer has its text and counts when the message is cached.\n */\n messagePollVoteAdd: [answer: PollAnswer, userId: string];\n messagePollVoteRemove: [answer: PollAnswer, userId: string];\n\n guildMemberAdd: [member: GuildMember];\n guildMemberUpdate: [oldMember: GuildMember | null, newMember: GuildMember];\n guildMemberRemove: [member: GuildMember | null, data: GatewayGuildMemberRemoveDispatchData];\n /**\n * Emitted for each chunk of members Discord sends in answer to `client.members.request`, once it is cached.\n * `data` has the chunk's index and count, its nonce, and the requested IDs that are not members (`not_found`).\n */\n guildMembersChunk: [\n members: GuildMember[],\n guild: Guild | null,\n data: GatewayGuildMembersChunkDispatchData,\n ];\n\n guildRoleCreate: [role: Role];\n guildRoleUpdate: [oldRole: Role | null, newRole: Role];\n guildRoleDelete: [role: Role | null, data: GatewayGuildRoleDeleteDispatchData];\n\n userUpdate: [oldUser: User | null, newUser: User];\n\n /**\n * Emitted for each emoji a `GUILD_EMOJIS_UPDATE` adds, compared with the cache. Without a cache, the emoji events\n * are not emitted: listen to `raw` instead.\n */\n emojiCreate: [emoji: GuildEmoji];\n emojiUpdate: [oldEmoji: GuildEmoji, newEmoji: GuildEmoji];\n emojiDelete: [emoji: GuildEmoji];\n\n /**\n * Emitted for each sticker a `GUILD_STICKERS_UPDATE` adds, compared with the cache, like the emoji events.\n */\n stickerCreate: [sticker: Sticker];\n stickerUpdate: [oldSticker: Sticker, newSticker: Sticker];\n stickerDelete: [sticker: Sticker];\n\n inviteCreate: [invite: GuildInvite];\n /**\n * Emitted when an invite is deleted or expires, with the cached invite if any.\n */\n inviteDelete: [invite: GuildInvite | null, data: GatewayInviteDeleteDispatchData];\n\n typingStart: [typing: Typing];\n /**\n * Emitted when a guild's voice server changes, e.g. to hand a voice connection a new endpoint.\n */\n voiceServerUpdate: [data: GatewayVoiceServerUpdateDispatchData];\n\n /**\n * Emitted when a user is banned. Bans from the gateway have no reason.\n */\n guildScheduledEventCreate: [event: GuildScheduledEvent];\n guildScheduledEventUpdate: [oldEvent: GuildScheduledEvent | null, newEvent: GuildScheduledEvent];\n guildScheduledEventDelete: [event: GuildScheduledEvent];\n /**\n * Emitted when a user subscribes to a scheduled event, with the cached event and user when there are.\n */\n guildScheduledEventUserAdd: [\n event: GuildScheduledEvent | null,\n user: User | null,\n data: GatewayGuildScheduledEventUserAddDispatchData,\n ];\n guildScheduledEventUserRemove: [\n event: GuildScheduledEvent | null,\n user: User | null,\n data: GatewayGuildScheduledEventUserRemoveDispatchData,\n ];\n stageInstanceCreate: [stageInstance: StageInstance];\n stageInstanceUpdate: [oldStageInstance: StageInstance | null, newStageInstance: StageInstance];\n stageInstanceDelete: [stageInstance: StageInstance];\n guildSoundboardSoundCreate: [sound: SoundboardSound];\n guildSoundboardSoundUpdate: [oldSound: SoundboardSound | null, newSound: SoundboardSound];\n /**\n * Emitted when a soundboard sound is deleted, with the cached sound when there is one.\n */\n guildSoundboardSoundDelete: [\n sound: SoundboardSound | null,\n data: GatewayGuildSoundboardSoundDeleteDispatchData,\n ];\n /**\n * Emitted when several soundboard sounds of a guild change at once.\n */\n guildSoundboardSoundsUpdate: [sounds: SoundboardSound[], guildId: string];\n /**\n * Emitted with the sounds of a guild, in answer to a request for them over the gateway.\n */\n soundboardSounds: [sounds: SoundboardSound[], guildId: string];\n\n guildBanAdd: [ban: GuildBan];\n /**\n * Emitted when a ban is lifted, with the cached ban (and its reason, if it was fetched) when there is one.\n */\n guildBanRemove: [ban: GuildBan];\n /**\n * Emitted when an entry is added to a guild's audit log. Needs the `GuildModeration` intent.\n */\n guildAuditLogEntryCreate: [entry: GuildAuditLogsEntry];\n autoModerationRuleCreate: [rule: AutoModerationRule];\n autoModerationRuleUpdate: [oldRule: AutoModerationRule | null, newRule: AutoModerationRule];\n autoModerationRuleDelete: [rule: AutoModerationRule];\n /**\n * Emitted when auto moderation takes an action. Needs the `AutoModerationExecution` intent.\n */\n autoModerationActionExecution: [execution: AutoModerationActionExecution];\n /**\n * Emitted when an integration of a guild is created, updated, or deleted.\n */\n guildIntegrationsUpdate: [guild: Guild | null, data: GatewayGuildIntegrationsUpdateDispatchData];\n integrationCreate: [integration: Integration];\n integrationUpdate: [oldIntegration: Integration | null, newIntegration: Integration];\n integrationDelete: [integration: Integration | null, data: GatewayIntegrationDeleteDispatchData];\n /**\n * Emitted when a member joins, leaves, or moves between voice channels, or changes their voice settings.\n */\n voiceStateUpdate: [oldState: VoiceState | null, newState: VoiceState];\n /**\n * Emitted when a member's status or activities change. Needs the `GuildPresences` intent.\n */\n presenceUpdate: [oldPresence: Presence | null, newPresence: Presence];\n}\n\n/**\n * The name of any of the events listed in {@link GatewayEventMap}.\n */\nexport type GatewayEventName = keyof GatewayEventMap;\n\n/**\n * The name of every event a {@link GatewayClient} emits, mirroring the keys of {@link GatewayEventMap}, like\n * `@wolfstar/http-framework`'s own `Events`.\n *\n * @remarks\n * Each member's value is the plain event name, so they are interchangeable with the string literals accepted by\n * `GatewayClient#on`, `GatewayClient#emit`, and `Listener.Options.event`.\n *\n * @example\n * ```typescript\n * client.on(GatewayEvents.MessageCreate, (message) => console.log(message.content));\n * ```\n */\nexport enum GatewayEvents {\n Raw = \"raw\",\n Dispatch = \"dispatch\",\n ShardReady = \"shardReady\",\n ClientReady = \"clientReady\",\n ShardResume = \"shardResume\",\n ShardClose = \"shardClose\",\n ShardError = \"shardError\",\n GuildCreate = \"guildCreate\",\n GuildUpdate = \"guildUpdate\",\n GuildDelete = \"guildDelete\",\n ChannelCreate = \"channelCreate\",\n ChannelUpdate = \"channelUpdate\",\n ChannelDelete = \"channelDelete\",\n ChannelPinsUpdate = \"channelPinsUpdate\",\n WebhooksUpdate = \"webhooksUpdate\",\n ThreadCreate = \"threadCreate\",\n ThreadUpdate = \"threadUpdate\",\n ThreadDelete = \"threadDelete\",\n ThreadListSync = \"threadListSync\",\n ThreadMemberUpdate = \"threadMemberUpdate\",\n ThreadMembersUpdate = \"threadMembersUpdate\",\n MessageCreate = \"messageCreate\",\n MessageUpdate = \"messageUpdate\",\n MessageDelete = \"messageDelete\",\n MessageDeleteBulk = \"messageDeleteBulk\",\n MessageReactionAdd = \"messageReactionAdd\",\n MessageReactionRemove = \"messageReactionRemove\",\n MessageReactionRemoveAll = \"messageReactionRemoveAll\",\n MessageReactionRemoveEmoji = \"messageReactionRemoveEmoji\",\n MessagePollVoteAdd = \"messagePollVoteAdd\",\n MessagePollVoteRemove = \"messagePollVoteRemove\",\n GuildMemberAdd = \"guildMemberAdd\",\n GuildMemberUpdate = \"guildMemberUpdate\",\n GuildMemberRemove = \"guildMemberRemove\",\n GuildMembersChunk = \"guildMembersChunk\",\n GuildRoleCreate = \"guildRoleCreate\",\n GuildRoleUpdate = \"guildRoleUpdate\",\n GuildRoleDelete = \"guildRoleDelete\",\n UserUpdate = \"userUpdate\",\n EmojiCreate = \"emojiCreate\",\n EmojiUpdate = \"emojiUpdate\",\n EmojiDelete = \"emojiDelete\",\n StickerCreate = \"stickerCreate\",\n StickerUpdate = \"stickerUpdate\",\n StickerDelete = \"stickerDelete\",\n InviteCreate = \"inviteCreate\",\n InviteDelete = \"inviteDelete\",\n TypingStart = \"typingStart\",\n VoiceServerUpdate = \"voiceServerUpdate\",\n GuildScheduledEventCreate = \"guildScheduledEventCreate\",\n GuildScheduledEventUpdate = \"guildScheduledEventUpdate\",\n GuildScheduledEventDelete = \"guildScheduledEventDelete\",\n GuildScheduledEventUserAdd = \"guildScheduledEventUserAdd\",\n GuildScheduledEventUserRemove = \"guildScheduledEventUserRemove\",\n StageInstanceCreate = \"stageInstanceCreate\",\n StageInstanceUpdate = \"stageInstanceUpdate\",\n StageInstanceDelete = \"stageInstanceDelete\",\n GuildSoundboardSoundCreate = \"guildSoundboardSoundCreate\",\n GuildSoundboardSoundUpdate = \"guildSoundboardSoundUpdate\",\n GuildSoundboardSoundDelete = \"guildSoundboardSoundDelete\",\n GuildSoundboardSoundsUpdate = \"guildSoundboardSoundsUpdate\",\n SoundboardSounds = \"soundboardSounds\",\n GuildBanAdd = \"guildBanAdd\",\n GuildBanRemove = \"guildBanRemove\",\n GuildAuditLogEntryCreate = \"guildAuditLogEntryCreate\",\n AutoModerationRuleCreate = \"autoModerationRuleCreate\",\n AutoModerationRuleUpdate = \"autoModerationRuleUpdate\",\n AutoModerationRuleDelete = \"autoModerationRuleDelete\",\n AutoModerationActionExecution = \"autoModerationActionExecution\",\n GuildIntegrationsUpdate = \"guildIntegrationsUpdate\",\n IntegrationCreate = \"integrationCreate\",\n IntegrationUpdate = \"integrationUpdate\",\n IntegrationDelete = \"integrationDelete\",\n VoiceStateUpdate = \"voiceStateUpdate\",\n PresenceUpdate = \"presenceUpdate\",\n}\n\ndeclare module \"@wolfstar/http-framework\" {\n interface ClientEvents extends GatewayEventMap {}\n}\n","/**\n * The structures a `GatewayClient` builds partially when an event concerns one it has not cached, like discord.js's\n * `Partials`. Pass them to `GatewayClientOptions.partials`.\n *\n * @remarks\n * Unlike discord.js, events are always emitted, even without the matching partial: an uncached entity is `null` then,\n * as it always was. With the partial enabled, it is a structure built from the IDs the dispatch carries instead, whose\n * `partial` is `true`: only its IDs are reliable, and `fetch()` completes it. Partial structures are never written to\n * the cache.\n *\n * `Reaction` and `PollAnswer` are accepted for parity only: the reaction and the poll answer of an uncached message\n * have always been emitted, and are partial whether or not they are enabled.\n */\nexport const Partials = {\n User: 0,\n Channel: 1,\n GuildMember: 2,\n Message: 3,\n Reaction: 4,\n GuildScheduledEvent: 5,\n ThreadMember: 6,\n Poll: 7,\n PollAnswer: 8,\n SoundboardSound: 9,\n} as const;\n\n/**\n * One of the {@link Partials}.\n */\nexport type Partials = (typeof Partials)[keyof typeof Partials];\n","import {\n ChannelType,\n GatewayDispatchEvents,\n type APIPartialEmoji,\n type APIUser,\n type GatewayDispatchPayload,\n type GatewayMessagePollVoteDispatchData,\n} from \"discord-api-types/v10\";\nimport type { Awaitable, CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { AutoModerationActionExecution } from \"../structures/automoderation/AutoModerationActionExecution.js\";\nimport { ClientUser } from \"../structures/users/ClientUser.js\";\nimport { GuildAuditLogsEntry } from \"../structures/guilds/GuildAuditLogsEntry.js\";\nimport { bindClient, kPatch } from \"../structures/Structure.js\";\nimport type { GuildEmoji } from \"../structures/emojis/GuildEmoji.js\";\nimport { createChannel } from \"../managers/ChannelManager.js\";\nimport type { DMChannel } from \"../structures/channels/DMChannel.js\";\nimport { GuildMember } from \"../structures/guilds/GuildMember.js\";\nimport { GuildScheduledEvent } from \"../structures/guilds/GuildScheduledEvent.js\";\nimport { GuildInvite } from \"../structures/invites/GuildInvite.js\";\nimport type { Sticker } from \"../structures/stickers/Sticker.js\";\nimport { Message } from \"../structures/messages/Message.js\";\nimport { MessageReaction } from \"../structures/messages/MessageReaction.js\";\nimport { Poll } from \"../structures/polls/Poll.js\";\nimport { PollAnswer } from \"../structures/polls/PollAnswer.js\";\nimport { SoundboardSound } from \"../structures/soundboards/SoundboardSound.js\";\nimport { ThreadMember } from \"../structures/channels/ThreadMember.js\";\nimport { User } from \"../structures/users/User.js\";\nimport { Typing } from \"../structures/channels/Typing.js\";\nimport { resolveAuditLogTarget } from \"./auditLogs.js\";\nimport { GatewayEvents, type GatewayEventMap, type GatewayEventName } from \"./events.js\";\nimport { Partials } from \"./Partials.js\";\n\n/**\n * The data of the dispatch of type `Type`.\n */\nexport type DispatchData<Type extends GatewayDispatchEvents> = Extract<\n GatewayDispatchPayload,\n { t: Type }\n>[\"d\"];\n\n/**\n * Describes how a gateway dispatch turns into a {@link GatewayEventMap} event.\n *\n * @typeParam Type The dispatch type.\n * @typeParam Event The event emitted for it.\n */\nexport interface DispatchHandler<\n Type extends GatewayDispatchEvents,\n Event extends GatewayEventName,\n> {\n /**\n * The event to emit.\n */\n event: Event;\n /**\n * Runs before the dispatch is written to the cache, used to read the previous state of the entity.\n */\n before?(client: GatewayClient, data: DispatchData<Type>): Promise<unknown>;\n /**\n * Runs after the dispatch is written to the cache, and builds the arguments of the event.\n *\n * @param state The value `before` resolved to, if any.\n */\n build(\n client: GatewayClient,\n data: DispatchData<Type>,\n state: any,\n shardId: number,\n ): Awaitable<GatewayEventMap[Event]>;\n}\n\n/**\n * An event with its arguments, as emitted by a {@link MultiDispatchHandler}.\n */\nexport type GatewayEventTuple = {\n [Event in GatewayEventName]: [event: Event, ...args: GatewayEventMap[Event]];\n}[GatewayEventName];\n\n/**\n * Describes how a gateway dispatch turns into any number of {@link GatewayEventMap} events, e.g. one per emoji a\n * `GUILD_EMOJIS_UPDATE` changes.\n */\nexport interface MultiDispatchHandler<Type extends GatewayDispatchEvents> {\n /**\n * Runs before the dispatch is written to the cache, used to read the previous state.\n */\n before?(client: GatewayClient, data: DispatchData<Type>): Promise<unknown>;\n /**\n * Runs after the dispatch is written to the cache, and lists the events to emit, in order.\n */\n emit(client: GatewayClient, data: DispatchData<Type>, state: any): Awaitable<GatewayEventTuple[]>;\n}\n\n/**\n * A {@link DispatchHandler} for the dispatch of type `Type`, emitting any event.\n */\nexport type AnyDispatchHandler<Type extends GatewayDispatchEvents> = {\n [Event in GatewayEventName]: DispatchHandler<Type, Event>;\n}[GatewayEventName];\n\n/**\n * The table mapping every supported dispatch to its event.\n *\n * @remarks\n * `INTERACTION_CREATE` is deliberately absent: interactions are served by the HTTP endpoint, and the gateway may\n * deliver some of them as well. Dispatches without an entry are still written to the cache and emitted as `raw`.\n */\nexport const DispatchHandlers: { [Type in GatewayDispatchEvents]?: AnyDispatchHandler<Type> } = {\n [GatewayDispatchEvents.Ready]: {\n event: GatewayEvents.ShardReady,\n build: (client, data, _state, shardId) => {\n const user = new ClientUser(data.user);\n client.user = user;\n return [shardId, user];\n },\n },\n\n [GatewayDispatchEvents.GuildCreate]: {\n event: GatewayEvents.GuildCreate,\n // The cached entry has the collections stripped, prefer it over the (much larger) payload.\n build: async (client, data) => [\n (await cachedOrUndefined(client.guilds.get(data.id))) ??\n (await client.guilds.hydrate(data as CacheEntityTypes[\"guilds\"])),\n ],\n },\n [GatewayDispatchEvents.GuildUpdate]: {\n event: GatewayEvents.GuildUpdate,\n before: (client, data) => client.guilds.get(data.id),\n build: async (client, data, previous) => [previous ?? null, await client.guilds.hydrate(data)],\n },\n [GatewayDispatchEvents.GuildDelete]: {\n event: GatewayEvents.GuildDelete,\n before: (client, data) => client.guilds.get(data.id),\n build: (_client, data, previous) => [previous ?? null, data],\n },\n\n [GatewayDispatchEvents.ChannelCreate]: {\n event: GatewayEvents.ChannelCreate,\n build: async (client, data) => [await client.channels.hydrate(data)],\n },\n [GatewayDispatchEvents.ChannelUpdate]: {\n event: GatewayEvents.ChannelUpdate,\n before: (client, data) => client.channels.get(data.id),\n build: async (client, data, previous) => [\n previous ?? null,\n await client.channels.hydrate(data),\n ],\n },\n [GatewayDispatchEvents.ChannelDelete]: {\n event: GatewayEvents.ChannelDelete,\n build: async (client, data) => [await client.channels.hydrate(data)],\n },\n\n [GatewayDispatchEvents.ChannelPinsUpdate]: {\n event: GatewayEvents.ChannelPinsUpdate,\n build: (_client, data) => [data],\n },\n [GatewayDispatchEvents.WebhooksUpdate]: {\n event: GatewayEvents.WebhooksUpdate,\n build: (_client, data) => [data],\n },\n\n [GatewayDispatchEvents.ThreadCreate]: {\n event: GatewayEvents.ThreadCreate,\n build: async (client, data) => [await client.threads.hydrate(data)],\n },\n [GatewayDispatchEvents.ThreadUpdate]: {\n event: GatewayEvents.ThreadUpdate,\n before: (client, data) => client.threads.get(data.id),\n build: async (client, data, previous) => [previous ?? null, await client.threads.hydrate(data)],\n },\n [GatewayDispatchEvents.ThreadDelete]: {\n event: GatewayEvents.ThreadDelete,\n before: (client, data) => client.threads.get(data.id),\n build: (_client, data, previous) => [previous ?? null, data],\n },\n\n [GatewayDispatchEvents.ThreadListSync]: {\n event: GatewayEvents.ThreadListSync,\n build: async (client, data) => [\n await Promise.all(data.threads.map((thread) => client.threads.hydrate(thread as never))),\n await Promise.all(\n data.members.map((member) =>\n client.threadMembers.hydrate({ ...member, guild_id: data.guild_id }),\n ),\n ),\n data,\n ],\n },\n [GatewayDispatchEvents.ThreadMemberUpdate]: {\n event: GatewayEvents.ThreadMemberUpdate,\n before: (client, data) =>\n data.id && data.user_id\n ? client.threadMembers.get(data.id, data.user_id)\n : Promise.resolve(undefined),\n build: async (client, data, previous) => [\n previous ??\n (data.id && data.user_id\n ? partialThreadMember(client, data.id, data.user_id, data.guild_id)\n : null),\n await client.threadMembers.hydrate(data),\n ],\n },\n [GatewayDispatchEvents.ThreadMembersUpdate]: {\n event: GatewayEvents.ThreadMembersUpdate,\n before: async (client, data) => {\n const removed = await Promise.all(\n (data.removed_member_ids ?? []).map((userId) => client.threadMembers.get(data.id, userId)),\n );\n return removed.filter((member) => member !== undefined);\n },\n build: async (client, data, previous: ThreadMember[] | undefined) => [\n await Promise.all(\n (data.added_members ?? []).map((member) =>\n client.threadMembers.hydrate({ ...member, id: data.id, guild_id: data.guild_id }),\n ),\n ),\n withPartials(previous ?? [], data.removed_member_ids ?? [], (userId) =>\n partialThreadMember(client, data.id, userId, data.guild_id),\n ),\n (await cachedOrUndefined(client.threads.get(data.id))) ?? null,\n data,\n ],\n },\n\n [GatewayDispatchEvents.MessageCreate]: {\n event: GatewayEvents.MessageCreate,\n build: async (client, data) => [await client.messages.hydrate(data)],\n },\n [GatewayDispatchEvents.MessageUpdate]: {\n event: GatewayEvents.MessageUpdate,\n before: (client, data) => client.messages.get(data.channel_id, data.id),\n build: async (client, data, previous) => [\n previous ?? partialMessage(client, data.channel_id, data.id, data.guild_id),\n await client.messages.hydrate(data),\n ],\n },\n [GatewayDispatchEvents.MessageDelete]: {\n event: GatewayEvents.MessageDelete,\n before: (client, data) => client.messages.get(data.channel_id, data.id),\n build: (client, data, previous) => [\n previous ?? partialMessage(client, data.channel_id, data.id, data.guild_id),\n data,\n ],\n },\n [GatewayDispatchEvents.MessageDeleteBulk]: {\n event: GatewayEvents.MessageDeleteBulk,\n before: async (client, data) => {\n const messages = await Promise.all(\n data.ids.map((id) => client.messages.get(data.channel_id, id)),\n );\n return messages.filter((message) => message !== undefined);\n },\n build: (client, data, previous: Message[] | undefined) => [\n withPartials(previous ?? [], data.ids, (id) =>\n partialMessage(client, data.channel_id, id, data.guild_id),\n ),\n data,\n ],\n },\n\n [GatewayDispatchEvents.MessageReactionAdd]: {\n event: GatewayEvents.MessageReactionAdd,\n build: async (client, data) => [\n await reactionOf(client, data),\n (await cachedOrUndefined(client.users.get(data.user_id))) ??\n partialUser(client, data.user_id),\n { userId: data.user_id, type: data.type, burst: data.burst },\n ],\n },\n [GatewayDispatchEvents.MessageReactionRemove]: {\n event: GatewayEvents.MessageReactionRemove,\n build: async (client, data) => [\n await reactionOf(client, data),\n (await cachedOrUndefined(client.users.get(data.user_id))) ??\n partialUser(client, data.user_id),\n { userId: data.user_id, type: data.type, burst: data.burst },\n ],\n },\n [GatewayDispatchEvents.MessageReactionRemoveAll]: {\n event: GatewayEvents.MessageReactionRemoveAll,\n before: async (client, data) =>\n (await client.messages.get(data.channel_id, data.message_id))?.reactions.cache ?? [],\n build: async (client, data, previous: MessageReaction[] | undefined) => [\n (await cachedOrUndefined(client.messages.get(data.channel_id, data.message_id))) ??\n partialMessage(client, data.channel_id, data.message_id, data.guild_id),\n previous ?? [],\n data,\n ],\n },\n [GatewayDispatchEvents.MessageReactionRemoveEmoji]: {\n event: GatewayEvents.MessageReactionRemoveEmoji,\n before: async (client, data) =>\n (await client.messages.get(data.channel_id, data.message_id))?.reactions.resolve(\n data.emoji,\n ) ?? undefined,\n build: async (client, data, previous: MessageReaction | undefined) => [\n previous ?? (await partialReaction(client, data)),\n ],\n },\n [GatewayDispatchEvents.MessagePollVoteAdd]: {\n event: GatewayEvents.MessagePollVoteAdd,\n build: async (client, data) => [await pollAnswerOf(client, data), data.user_id],\n },\n [GatewayDispatchEvents.MessagePollVoteRemove]: {\n event: GatewayEvents.MessagePollVoteRemove,\n build: async (client, data) => [await pollAnswerOf(client, data), data.user_id],\n },\n\n [GatewayDispatchEvents.GuildMemberAdd]: {\n event: GatewayEvents.GuildMemberAdd,\n build: async (client, data) => [await client.members.hydrate(data)],\n },\n [GatewayDispatchEvents.GuildMemberUpdate]: {\n event: GatewayEvents.GuildMemberUpdate,\n before: (client, data) => client.members.get(data.guild_id, data.user.id),\n // The payload is partial: prefer the cached entry, which it was merged into.\n build: async (client, data, previous) => [\n previous ?? partialMember(client, data.guild_id, { id: data.user.id }),\n (await cachedOrUndefined(client.members.get(data.guild_id, data.user.id))) ??\n (await client.members.hydrate(data as CacheEntityTypes[\"members\"])),\n ],\n },\n [GatewayDispatchEvents.GuildMemberRemove]: {\n event: GatewayEvents.GuildMemberRemove,\n before: (client, data) => client.members.get(data.guild_id, data.user.id),\n build: (client, data, previous) => [\n previous ?? partialMember(client, data.guild_id, data.user),\n data,\n ],\n },\n [GatewayDispatchEvents.GuildMembersChunk]: {\n event: GatewayEvents.GuildMembersChunk,\n build: async (client, data) => {\n const [members, guild] = await Promise.all([\n Promise.all(\n data.members.map((member) =>\n client.members.hydrate({ ...member, guild_id: data.guild_id }),\n ),\n ),\n cachedOrUndefined(client.guilds.get(data.guild_id)),\n ]);\n // The chunk is cached by now, so a request resolving with it is followed by reads that see it.\n client.members.handleChunk(members, data);\n return [members, guild ?? null, data];\n },\n },\n\n [GatewayDispatchEvents.GuildRoleCreate]: {\n event: GatewayEvents.GuildRoleCreate,\n build: async (client, data) => [\n await client.roles.hydrate({ ...data.role, guild_id: data.guild_id }),\n ],\n },\n [GatewayDispatchEvents.GuildRoleUpdate]: {\n event: GatewayEvents.GuildRoleUpdate,\n before: (client, data) => client.roles.get(data.guild_id, data.role.id),\n build: async (client, data, previous) => [\n previous ?? null,\n await client.roles.hydrate({ ...data.role, guild_id: data.guild_id }),\n ],\n },\n [GatewayDispatchEvents.GuildRoleDelete]: {\n event: GatewayEvents.GuildRoleDelete,\n before: (client, data) => client.roles.get(data.guild_id, data.role_id),\n build: (_client, data, previous) => [previous ?? null, data],\n },\n\n [GatewayDispatchEvents.InviteCreate]: {\n event: GatewayEvents.InviteCreate,\n build: async (client, data) => [\n data.guild_id\n ? await client.guilds.invites(data.guild_id).hydrate(data)\n : bindClient(\n new GuildInvite(data, {\n channel: (await cachedOrUndefined(client.channels.get(data.channel_id))) ?? null,\n }),\n client,\n ),\n ],\n },\n [GatewayDispatchEvents.InviteDelete]: {\n event: GatewayEvents.InviteDelete,\n before: async (client, data) =>\n data.guild_id ? client.guilds.invites(data.guild_id).get(data.code) : undefined,\n build: (_client, data, previous) => [previous ?? null, data],\n },\n\n [GatewayDispatchEvents.TypingStart]: {\n event: GatewayEvents.TypingStart,\n build: async (client, data) => [await typingOf(client, data)],\n },\n [GatewayDispatchEvents.VoiceStateUpdate]: {\n event: GatewayEvents.VoiceStateUpdate,\n before: async (client, data) =>\n data.guild_id ? client.voiceStates.get(data.guild_id, data.user_id) : undefined,\n build: async (client, data, previous) => [\n previous ?? null,\n await client.voiceStates.hydrate(data),\n ],\n },\n [GatewayDispatchEvents.PresenceUpdate]: {\n event: GatewayEvents.PresenceUpdate,\n before: (client, data) => client.presences.get(data.guild_id, data.user.id),\n // The payload may be partial: prefer the cached entry, which it was merged into.\n build: async (client, data, previous) => [\n previous ?? null,\n (await cachedOrUndefined(client.presences.get(data.guild_id, data.user.id))) ??\n (await client.presences.hydrate(data)),\n ],\n },\n [GatewayDispatchEvents.GuildScheduledEventCreate]: {\n event: GatewayEvents.GuildScheduledEventCreate,\n build: async (client, data) => [\n await client.guilds.scheduledEvents(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.GuildScheduledEventUpdate]: {\n event: GatewayEvents.GuildScheduledEventUpdate,\n before: (client, data) => client.guilds.scheduledEvents(data.guild_id).get(data.id),\n build: async (client, data, previous) => [\n previous ?? partialScheduledEvent(client, data.guild_id, data.id),\n await client.guilds.scheduledEvents(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.GuildScheduledEventDelete]: {\n event: GatewayEvents.GuildScheduledEventDelete,\n build: async (client, data) => [\n await client.guilds.scheduledEvents(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.GuildScheduledEventUserAdd]: {\n event: GatewayEvents.GuildScheduledEventUserAdd,\n build: async (client, data) => [\n (await cachedOrUndefined(\n client.guilds.scheduledEvents(data.guild_id).get(data.guild_scheduled_event_id),\n )) ?? partialScheduledEvent(client, data.guild_id, data.guild_scheduled_event_id),\n (await cachedOrUndefined(client.users.get(data.user_id))) ??\n partialUser(client, data.user_id),\n data,\n ],\n },\n [GatewayDispatchEvents.GuildScheduledEventUserRemove]: {\n event: GatewayEvents.GuildScheduledEventUserRemove,\n build: async (client, data) => [\n (await cachedOrUndefined(\n client.guilds.scheduledEvents(data.guild_id).get(data.guild_scheduled_event_id),\n )) ?? partialScheduledEvent(client, data.guild_id, data.guild_scheduled_event_id),\n (await cachedOrUndefined(client.users.get(data.user_id))) ??\n partialUser(client, data.user_id),\n data,\n ],\n },\n [GatewayDispatchEvents.StageInstanceCreate]: {\n event: GatewayEvents.StageInstanceCreate,\n build: async (client, data) => [\n await client.guilds.stageInstances(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.StageInstanceUpdate]: {\n event: GatewayEvents.StageInstanceUpdate,\n before: (client, data) => client.guilds.stageInstances(data.guild_id).get(data.channel_id),\n build: async (client, data, previous) => [\n previous ?? null,\n await client.guilds.stageInstances(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.StageInstanceDelete]: {\n event: GatewayEvents.StageInstanceDelete,\n build: async (client, data) => [\n await client.guilds.stageInstances(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.GuildSoundboardSoundCreate]: {\n event: GatewayEvents.GuildSoundboardSoundCreate,\n build: async (client, data) => [\n await client.guilds.soundboardSounds(data.guild_id!).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.GuildSoundboardSoundUpdate]: {\n event: GatewayEvents.GuildSoundboardSoundUpdate,\n before: (client, data) => client.guilds.soundboardSounds(data.guild_id!).get(data.sound_id),\n build: async (client, data, previous) => [\n previous ?? partialSoundboardSound(client, data.guild_id!, data.sound_id),\n await client.guilds.soundboardSounds(data.guild_id!).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.GuildSoundboardSoundDelete]: {\n event: GatewayEvents.GuildSoundboardSoundDelete,\n before: (client, data) => client.guilds.soundboardSounds(data.guild_id).get(data.sound_id),\n build: (client, data, previous) => [\n previous ?? partialSoundboardSound(client, data.guild_id, data.sound_id),\n data,\n ],\n },\n [GatewayDispatchEvents.GuildSoundboardSoundsUpdate]: {\n event: GatewayEvents.GuildSoundboardSoundsUpdate,\n build: async (client, data) => {\n const sounds = client.guilds.soundboardSounds(data.guild_id);\n return [\n await Promise.all(data.soundboard_sounds.map((sound) => sounds.hydrate(sound))),\n data.guild_id,\n ];\n },\n },\n [GatewayDispatchEvents.SoundboardSounds]: {\n event: GatewayEvents.SoundboardSounds,\n build: async (client, data) => {\n const sounds = client.guilds.soundboardSounds(data.guild_id);\n return [\n await Promise.all(data.soundboard_sounds.map((sound) => sounds.hydrate(sound))),\n data.guild_id,\n ];\n },\n },\n\n [GatewayDispatchEvents.GuildBanAdd]: {\n event: GatewayEvents.GuildBanAdd,\n build: async (client, data) => [await client.guilds.bans(data.guild_id).hydrate(data)],\n },\n [GatewayDispatchEvents.GuildBanRemove]: {\n event: GatewayEvents.GuildBanRemove,\n before: (client, data) => client.guilds.bans(data.guild_id).get(data.user.id),\n build: async (client, data, previous) => [\n previous ?? (await client.guilds.bans(data.guild_id).hydrate(data)),\n ],\n },\n [GatewayDispatchEvents.GuildAuditLogEntryCreate]: {\n event: GatewayEvents.GuildAuditLogEntryCreate,\n build: async (client, data) => {\n const [executor, guild, target] = await Promise.all([\n data.user_id ? cachedOrUndefined(client.users.get(data.user_id)) : undefined,\n cachedOrUndefined(client.guilds.get(data.guild_id)),\n resolveAuditLogTarget(client, data),\n ]);\n return [\n bindClient(\n new GuildAuditLogsEntry(data, {\n executor: executor ?? null,\n guild: guild ?? null,\n target,\n }),\n client,\n ),\n ];\n },\n },\n [GatewayDispatchEvents.AutoModerationRuleCreate]: {\n event: GatewayEvents.AutoModerationRuleCreate,\n build: async (client, data) => [\n await client.guilds.autoModerationRules(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.AutoModerationRuleUpdate]: {\n event: GatewayEvents.AutoModerationRuleUpdate,\n before: (client, data) => client.guilds.autoModerationRules(data.guild_id).get(data.id),\n build: async (client, data, previous) => [\n previous ?? null,\n await client.guilds.autoModerationRules(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.AutoModerationRuleDelete]: {\n event: GatewayEvents.AutoModerationRuleDelete,\n build: async (client, data) => [\n await client.guilds.autoModerationRules(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.GuildIntegrationsUpdate]: {\n event: GatewayEvents.GuildIntegrationsUpdate,\n build: async (client, data) => [\n (await cachedOrUndefined(client.guilds.get(data.guild_id))) ?? null,\n data,\n ],\n },\n [GatewayDispatchEvents.IntegrationCreate]: {\n event: GatewayEvents.IntegrationCreate,\n build: async (client, data) => [await client.guilds.integrations(data.guild_id).hydrate(data)],\n },\n [GatewayDispatchEvents.IntegrationUpdate]: {\n event: GatewayEvents.IntegrationUpdate,\n before: (client, data) => client.guilds.integrations(data.guild_id).get(data.id),\n build: async (client, data, previous) => [\n previous ?? null,\n await client.guilds.integrations(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.IntegrationDelete]: {\n event: GatewayEvents.IntegrationDelete,\n before: (client, data) => client.guilds.integrations(data.guild_id).get(data.id),\n build: (_client, data, previous) => [previous ?? null, data],\n },\n\n [GatewayDispatchEvents.AutoModerationActionExecution]: {\n event: GatewayEvents.AutoModerationActionExecution,\n build: async (client, data) => {\n const [user, guild, member, channel, autoModerationRule] = await Promise.all([\n cachedOrUndefined(client.users.get(data.user_id)),\n cachedOrUndefined(client.guilds.get(data.guild_id)),\n cachedOrUndefined(client.members.get(data.guild_id, data.user_id)),\n data.channel_id ? cachedOrUndefined(client.channels.get(data.channel_id)) : undefined,\n cachedOrUndefined(client.guilds.autoModerationRules(data.guild_id).get(data.rule_id)),\n ]);\n return [\n bindClient(\n new AutoModerationActionExecution(data, {\n user: user ?? null,\n guild: guild ?? null,\n member: member ?? null,\n channel: channel ?? null,\n autoModerationRule: autoModerationRule ?? null,\n }),\n client,\n ),\n ];\n },\n },\n [GatewayDispatchEvents.VoiceServerUpdate]: {\n event: GatewayEvents.VoiceServerUpdate,\n build: (_client, data) => [data],\n },\n\n [GatewayDispatchEvents.UserUpdate]: {\n event: GatewayEvents.UserUpdate,\n before: (client, data) => client.users.get(data.id),\n build: async (client, data, previous) => {\n // The bot's own updates keep `client.user` a `ClientUser`, with its presence.\n if (client.user?.id === data.id) {\n client.user[kPatch](data);\n return [previous ?? partialUser(client, data.id), client.user];\n }\n\n return [previous ?? partialUser(client, data.id), await client.users.hydrate(data)];\n },\n },\n};\n\n/**\n * The table of the dispatches that turn into several events, diffed against the cache.\n *\n * @remarks\n * Without a cache there is nothing to diff against, so these dispatches only reach `raw`.\n */\nexport const MultiDispatchHandlers: {\n [Type in GatewayDispatchEvents]?: MultiDispatchHandler<Type>;\n} = {\n [GatewayDispatchEvents.GuildEmojisUpdate]: {\n before: (client, data) => client.guilds.emojis(data.guild_id).listCached(),\n emit: async (client, data, previous: GuildEmoji[] | undefined) => {\n if (!client.cache || !previous) return [];\n const emojis = client.guilds.emojis(data.guild_id);\n const current = await Promise.all(\n data.emojis.map((emoji) => emojis.hydrate({ ...emoji, guild_id: data.guild_id })),\n );\n return diff(\n previous,\n current,\n GatewayEvents.EmojiCreate,\n GatewayEvents.EmojiUpdate,\n GatewayEvents.EmojiDelete,\n );\n },\n },\n [GatewayDispatchEvents.GuildStickersUpdate]: {\n before: (client, data) => client.guilds.stickers(data.guild_id).listCached(),\n emit: async (client, data, previous: Sticker[] | undefined) => {\n if (!client.cache || !previous) return [];\n const stickers = client.guilds.stickers(data.guild_id);\n const current = await Promise.all(\n data.stickers.map((sticker) => stickers.hydrate({ ...sticker, guild_id: data.guild_id })),\n );\n return diff(\n previous,\n current,\n GatewayEvents.StickerCreate,\n GatewayEvents.StickerUpdate,\n GatewayEvents.StickerDelete,\n );\n },\n },\n};\n\ntype Diffable = { id: string | null; equals(other: never): boolean };\n\n// Lists the create, update, and delete events turning `previous` into `current`, matched by ID.\nfunction diff<Value extends Diffable>(\n previous: readonly Value[],\n current: readonly Value[],\n create: GatewayEvents,\n update: GatewayEvents,\n remove: GatewayEvents,\n): GatewayEventTuple[] {\n const before = new Map(previous.map((value) => [value.id, value]));\n const events: unknown[][] = [];\n for (const value of current) {\n const old = before.get(value.id);\n if (!old) events.push([create, value]);\n else if (!old.equals(value as never)) events.push([update, old, value]);\n before.delete(value.id);\n }\n\n for (const value of before.values()) events.push([remove, value]);\n return events as GatewayEventTuple[];\n}\n\n/**\n * Resolves a cache read, or `undefined` when the cache cannot be read, so an event can still be built from its\n * payload. The failure itself was already reported while applying the dispatch.\n */\ntype ReactionData = {\n channel_id: string;\n message_id: string;\n guild_id?: string;\n emoji: APIPartialEmoji;\n burst_colors?: string[];\n};\n\n// The reaction as the cache holds it after the dispatch. When the message is cached but the reaction is gone (its\n// last user removed it), the counts are known to be zero; only an uncached message leaves them unknown.\nasync function reactionOf(client: GatewayClient, data: ReactionData): Promise<MessageReaction> {\n const message = await cachedOrUndefined(client.messages.get(data.channel_id, data.message_id));\n if (!message) return partialReaction(client, data);\n return message.reactions.resolve(data.emoji) ?? partialReaction(client, data, true, message);\n}\n\n// A reaction the cached message does not hold, with the message when it is cached, and the cached custom emoji of the\n// message's guild.\nasync function partialReaction(\n client: GatewayClient,\n data: ReactionData,\n emptied = false,\n message: Message | null = partialMessage(client, data.channel_id, data.message_id, data.guild_id),\n): Promise<MessageReaction> {\n const { guild_id: guildId, emoji } = data;\n const cachedEmoji =\n guildId && emoji.id\n ? await cachedOrUndefined(client.guilds.emojis(guildId).get(emoji.id))\n : undefined;\n return bindClient(\n new MessageReaction(\n {\n channel_id: data.channel_id,\n message_id: data.message_id,\n emoji,\n me: false,\n me_burst: false,\n burst_colors: data.burst_colors ?? [],\n ...(emptied && { count: 0, count_details: { normal: 0, burst: 0 } }),\n },\n { message, emoji: cachedEmoji ?? null },\n ),\n client,\n );\n}\n\n// The answer as the cache holds it after the dispatch, else one with only its ID.\nasync function pollAnswerOf(\n client: GatewayClient,\n data: GatewayMessagePollVoteDispatchData,\n): Promise<PollAnswer> {\n const message = await cachedOrUndefined(client.messages.get(data.channel_id, data.message_id));\n return (\n message?.poll?.answers.find((answer) => answer.id === data.answer_id) ??\n bindClient(\n new PollAnswer(\n {\n answer_id: data.answer_id,\n poll_media: {},\n channel_id: data.channel_id,\n message_id: data.message_id,\n },\n { poll: message?.poll ?? partialPoll(client, data.channel_id, data.message_id) },\n ),\n client,\n )\n );\n}\n\n// The typing user, as the cache knows them and their channel.\nasync function typingOf(\n client: GatewayClient,\n data: DispatchData<GatewayDispatchEvents.TypingStart>,\n): Promise<Typing> {\n const { guild_id: guildId, member, user_id: userId } = data;\n const [channel, user, guild, resolvedMember] = await Promise.all([\n cachedOrUndefined(client.channels.get(data.channel_id)),\n cachedOrUndefined(\n member?.user ? client.users.resolveData(member.user) : client.users.get(userId),\n ),\n guildId ? cachedOrUndefined(Promise.resolve(client.guilds._getShallow(guildId))) : undefined,\n guildId\n ? cachedOrUndefined(\n member?.user\n ? client.members.resolveData({ ...member, guild_id: guildId })\n : client.members.get(guildId, userId),\n )\n : undefined,\n ]);\n return bindClient(\n new Typing(data, {\n channel: channel ?? (guildId ? null : partialDMChannel(client, data.channel_id, userId)),\n user: user ?? partialUser(client, userId),\n guild: guild ?? null,\n member: resolvedMember ?? (guildId ? partialMember(client, guildId, { id: userId }) : null),\n }),\n client,\n );\n}\n\n// Whether the client builds partial structures of `partial`, see `GatewayClientOptions.partials`.\nfunction wants(client: GatewayClient, partial: Partials): boolean {\n return client.partials.includes(partial);\n}\n\n// The cached entities, in the dispatch's order, completed by partial ones for the uncached IDs when `build` returns\n// them (i.e. their partial is enabled): only the cached ones otherwise.\nfunction withPartials<Value extends { id: string | null }>(\n cached: readonly Value[],\n ids: readonly string[],\n build: (id: string) => Value | null,\n): Value[] {\n const byId = new Map(cached.map((value) => [value.id, value]));\n const values: Value[] = [];\n for (const id of ids) {\n const value = byId.get(id) ?? build(id);\n if (value) values.push(value);\n }\n\n return values;\n}\n\n// The partial structures, built from the IDs a dispatch carries when their partial is enabled, `null` otherwise. They\n// are never written to the cache.\n\nfunction partialMessage(\n client: GatewayClient,\n channelId: string,\n messageId: string,\n guildId?: string,\n): Message | null {\n if (!wants(client, Partials.Message)) return null;\n return bindClient(\n new Message({ id: messageId, channel_id: channelId, guild_id: guildId } as never),\n client,\n );\n}\n\nfunction partialUser(client: GatewayClient, userId: string): User | null {\n return wants(client, Partials.User)\n ? bindClient(new User({ id: userId } as never), client)\n : null;\n}\n\nfunction partialMember(\n client: GatewayClient,\n guildId: string,\n user: APIUser | { id: string },\n): GuildMember | null {\n if (!wants(client, Partials.GuildMember)) return null;\n return bindClient(new GuildMember({ guild_id: guildId, user } as never), client);\n}\n\nfunction partialThreadMember(\n client: GatewayClient,\n threadId: string,\n userId: string,\n guildId?: string,\n): ThreadMember | null {\n if (!wants(client, Partials.ThreadMember)) return null;\n return bindClient(\n new ThreadMember({ id: threadId, user_id: userId, guild_id: guildId } as never),\n client,\n );\n}\n\nfunction partialScheduledEvent(\n client: GatewayClient,\n guildId: string,\n eventId: string,\n): GuildScheduledEvent | null {\n if (!wants(client, Partials.GuildScheduledEvent)) return null;\n return bindClient(new GuildScheduledEvent({ id: eventId, guild_id: guildId } as never), client);\n}\n\nfunction partialSoundboardSound(\n client: GatewayClient,\n guildId: string,\n soundId: string,\n): SoundboardSound | null {\n if (!wants(client, Partials.SoundboardSound)) return null;\n return bindClient(new SoundboardSound({ sound_id: soundId, guild_id: guildId } as never), client);\n}\n\nfunction partialPoll(client: GatewayClient, channelId: string, messageId: string): Poll | null {\n if (!wants(client, Partials.Poll)) return null;\n return bindClient(new Poll({ channel_id: channelId, message_id: messageId } as never), client);\n}\n\n// Only direct messages can be partial channels, like discord.js's: a guild channel's type is unknown from its ID.\nfunction partialDMChannel(\n client: GatewayClient,\n channelId: string,\n recipientId: string,\n): DMChannel | null {\n if (!wants(client, Partials.Channel)) return null;\n return bindClient(\n createChannel({\n id: channelId,\n type: ChannelType.DM,\n recipients: [{ id: recipientId }],\n } as never) as DMChannel,\n client,\n );\n}\n\nfunction cachedOrUndefined<Value>(read: Promise<Value | undefined>): Promise<Value | undefined> {\n return read.catch(() => undefined);\n}\n","import type { GatewayDispatchPayload } from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport {\n DispatchHandlers,\n MultiDispatchHandlers,\n type DispatchHandler,\n type GatewayEventTuple,\n type MultiDispatchHandler,\n} from \"../util/dispatch.js\";\nimport type { GatewayEventName } from \"../util/events.js\";\n\n/** Processes one kind of gateway dispatch around the cache write. */\nexport abstract class Action {\n public constructor(protected readonly client: GatewayClient) {}\n\n /** Captures the state required to build the event before the cache changes. */\n public async before(_data: GatewayDispatchPayload[\"d\"]): Promise<unknown> {\n return undefined;\n }\n\n /** Builds and emits events after the cache has been updated. */\n public abstract handle(\n data: GatewayDispatchPayload[\"d\"],\n state: unknown,\n shardId: number,\n ): Promise<void>;\n\n protected emit([event, ...args]: GatewayEventTuple): void {\n this.client.emit(event, ...(args as never));\n }\n}\n\n/** An action producing one public event. */\nexport class DispatchAction extends Action {\n public constructor(\n client: GatewayClient,\n private readonly handler: DispatchHandler<GatewayDispatchPayload[\"t\"], GatewayEventName>,\n ) {\n super(client);\n }\n\n public override async before(data: GatewayDispatchPayload[\"d\"]): Promise<unknown> {\n return this.handler.before?.(this.client, data);\n }\n\n public async handle(\n data: GatewayDispatchPayload[\"d\"],\n state: unknown,\n shardId: number,\n ): Promise<void> {\n const args = await this.handler.build(this.client, data, state, shardId);\n this.emit([this.handler.event, ...args] as GatewayEventTuple);\n }\n}\n\n/** An action producing several public events from one dispatch. */\nexport class MultiDispatchAction extends Action {\n public constructor(\n client: GatewayClient,\n private readonly handler: MultiDispatchHandler<GatewayDispatchPayload[\"t\"]>,\n ) {\n super(client);\n }\n\n public override async before(data: GatewayDispatchPayload[\"d\"]): Promise<unknown> {\n return this.handler.before?.(this.client, data);\n }\n\n public async handle(data: GatewayDispatchPayload[\"d\"], state: unknown): Promise<void> {\n for (const event of await this.handler.emit(this.client, data, state)) this.emit(event);\n }\n}\n\n/** Holds one action per handled dispatch, like discord.js's ActionsManager. */\nexport class ActionsManager {\n readonly #actions = new Map<GatewayDispatchPayload[\"t\"], Action>();\n\n public constructor(client: GatewayClient) {\n for (const [event, handler] of Object.entries(DispatchHandlers)) {\n if (handler) {\n this.#actions.set(\n event as GatewayDispatchPayload[\"t\"],\n new DispatchAction(client, handler as never),\n );\n }\n }\n for (const [event, handler] of Object.entries(MultiDispatchHandlers)) {\n if (handler) {\n // An event holds a single action, so it may be registered in only one of the two handler tables.\n if (this.#actions.has(event as GatewayDispatchPayload[\"t\"])) {\n throw new Error(\n `Dispatch event \"${event}\" is registered in both DispatchHandlers and MultiDispatchHandlers`,\n );\n }\n this.#actions.set(\n event as GatewayDispatchPayload[\"t\"],\n new MultiDispatchAction(client, handler as never),\n );\n }\n }\n }\n\n public get(event: GatewayDispatchPayload[\"t\"]): Action | undefined {\n return this.#actions.get(event);\n }\n}\n","import { GatewayDispatchEvents, type GatewayDispatchPayload } from \"discord-api-types/v10\";\n\n/**\n * A snapshot of a {@link DispatchQueue}.\n */\nexport interface DispatchQueueStats {\n /**\n * The dispatches received but not processed yet, across every shard.\n */\n pending: number;\n /**\n * The partitions currently holding at least one pending dispatch.\n */\n partitions: number;\n}\n\ninterface ShardQueue {\n // The last dispatch every partition must wait for, e.g. `READY`.\n barrier: Promise<void>;\n partitions: Map<string, Promise<void>>;\n}\n\nconst GuildEvents: ReadonlySet<string> = new Set([\n GatewayDispatchEvents.GuildCreate,\n GatewayDispatchEvents.GuildUpdate,\n GatewayDispatchEvents.GuildDelete,\n]);\n\n/**\n * Gets the partition a dispatch is processed in: its guild, else its channel (direct messages), else `null`.\n *\n * @remarks\n * A `null` partition is a barrier: the dispatch waits for every pending dispatch of its shard, and every later one\n * waits for it. `READY`, `RESUMED`, and user-level dispatches such as `USER_UPDATE` are barriers.\n *\n * @param payload The dispatch payload.\n */\nexport function dispatchPartition(payload: GatewayDispatchPayload): string | null {\n const data = payload.d as { guild_id?: string; channel_id?: string; id?: string } | null;\n if (!data || typeof data !== \"object\") return null;\n if (data.guild_id) return `guild:${data.guild_id}`;\n if (GuildEvents.has(payload.t) && data.id) return `guild:${data.id}`;\n if (data.channel_id) return `channel:${data.channel_id}`;\n // Direct message channels are the only channels created or deleted without a guild.\n if (payload.t.startsWith(\"CHANNEL_\") && data.id) return `channel:${data.id}`;\n return null;\n}\n\n/**\n * Runs tasks in order within a partition, and partitions of the same shard concurrently.\n *\n * @remarks\n * An asynchronous cache (Redis) would otherwise let a later dispatch of a guild finish before an earlier one. Guilds\n * are independent, so a slow guild does not hold the others back. Tasks must never reject: the queue has no way to\n * report their errors.\n */\nexport class DispatchQueue {\n readonly #shards = new Map<number, ShardQueue>();\n // The shard each guild's dispatches come from, for the tasks the client queues on its own.\n readonly #guildShards = new Map<string, number>();\n #pending = 0;\n\n /**\n * Queues a task.\n *\n * @param shardId The shard the dispatch was received on.\n * @param partition The partition from {@link dispatchPartition}, `null` for a barrier.\n * @param task The task to run once the previous task of its partition is done.\n * @returns The task's completion.\n */\n public enqueue(\n shardId: number,\n partition: string | null,\n task: () => Promise<void>,\n ): Promise<void> {\n const shard = this.shard(shardId);\n this.#pending++;\n if (partition?.startsWith(\"guild:\")) this.#guildShards.set(partition, shardId);\n\n const previous =\n partition === null\n ? Promise.all([shard.barrier, ...shard.partitions.values()])\n : (shard.partitions.get(partition) ?? shard.barrier);\n const run = previous.then(task).finally(() => {\n this.#pending--;\n if (partition !== null && shard.partitions.get(partition) === run) {\n shard.partitions.delete(partition);\n }\n });\n\n if (partition === null) {\n // Every pending partition is covered by the barrier from now on.\n shard.barrier = run;\n shard.partitions.clear();\n } else {\n shard.partitions.set(partition, run);\n }\n\n return run;\n }\n\n /**\n * Queues a task in a guild's partition, on the shard the guild's dispatches come from: a cache write the client\n * makes on its own then stays in order with them. Before any dispatch of the guild, there is nothing to order it\n * with, and it runs on shard 0.\n *\n * @param guildId The ID of the guild.\n * @param task The task to run once the previous task of the guild is done.\n */\n public enqueueGuild(guildId: string, task: () => Promise<void>): Promise<void> {\n const partition = `guild:${guildId}`;\n return this.enqueue(this.#guildShards.get(partition) ?? 0, partition, task);\n }\n\n /**\n * Resolves once every task queued so far has run.\n */\n public async idle(): Promise<void> {\n await Promise.all(\n [...this.#shards.values()].flatMap((shard) => [shard.barrier, ...shard.partitions.values()]),\n );\n }\n\n /**\n * A snapshot of the pending work.\n */\n public get stats(): DispatchQueueStats {\n let partitions = 0;\n for (const shard of this.#shards.values()) partitions += shard.partitions.size;\n return { pending: this.#pending, partitions };\n }\n\n private shard(shardId: number): ShardQueue {\n let shard = this.#shards.get(shardId);\n if (!shard) {\n shard = { barrier: Promise.resolve(), partitions: new Map() };\n this.#shards.set(shardId, shard);\n }\n\n return shard;\n }\n}\n","import type { GatewaySessionInfo, GatewaySessionStore } from \"@wolfstar/plugin-cache\";\nimport { GatewaySessionStoreError } from \"./errors.js\";\n\n/**\n * Sits between `@discordjs/ws` and a {@link GatewaySessionStore}, which `@discordjs/ws` would otherwise read on every\n * dispatch and heartbeat, and write on every sequence change, while holding the dispatch back.\n *\n * @remarks\n * The session of a shard is read from the store once, when the shard first connects, then served from memory. Writes\n * never hold a dispatch back either: they run in the background, one at a time per shard, and the ones queued while a\n * write is in flight collapse into a single write of the latest session. A stored sequence is therefore slightly\n * behind after a crash, which Discord handles by replaying the dispatches since then.\n *\n * @internal\n */\nexport class GatewaySessionMirror {\n readonly #store: GatewaySessionStore;\n readonly #timeout: number | null;\n readonly #onError: (error: GatewaySessionStoreError) => void;\n readonly #sessions = new Map<number, GatewaySessionInfo | null>();\n // The shards with a write waiting for the one in flight, and the session it will write.\n readonly #pending = new Map<number, GatewaySessionInfo | null>();\n readonly #writes = new Map<number, Promise<void>>();\n\n public constructor(\n store: GatewaySessionStore,\n timeout: number | null,\n onError: (error: GatewaySessionStoreError) => void,\n ) {\n this.#store = store;\n this.#timeout = timeout;\n this.#onError = onError;\n }\n\n public async get(shardId: number): Promise<GatewaySessionInfo | null> {\n if (this.#sessions.has(shardId)) return this.#sessions.get(shardId)!;\n\n const session = await this.read(shardId);\n // A session written while reading is newer than the stored one.\n if (!this.#sessions.has(shardId)) this.#sessions.set(shardId, session);\n return this.#sessions.get(shardId)!;\n }\n\n public set(shardId: number, info: GatewaySessionInfo | null): void {\n this.#sessions.set(shardId, info);\n\n const queued = this.#pending.has(shardId);\n this.#pending.set(shardId, info);\n if (queued) return;\n\n const previous = this.#writes.get(shardId) ?? Promise.resolve();\n this.#writes.set(\n shardId,\n previous.then(() => this.write(shardId)),\n );\n }\n\n /**\n * Resolves once every session written so far reached the store.\n */\n public async flush(): Promise<void> {\n await Promise.all(this.#writes.values());\n }\n\n private async read(shardId: number): Promise<GatewaySessionInfo | null> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n const read = Promise.resolve(this.#store.get(shardId));\n if (this.#timeout === null) return await read;\n\n const timeout = this.#timeout;\n // A hanging store (e.g. a Redis client queueing commands while reconnecting) must not hold the shard back.\n return await Promise.race([\n read,\n new Promise<never>((_, reject) => {\n timer = setTimeout(() => reject(new Error(`Timed out after ${timeout}ms`)), timeout);\n }),\n ]);\n } catch (error) {\n // Identifying costs more than resuming, but a shard that cannot tell its session still connects.\n this.#onError(new GatewaySessionStoreError(\"get\", shardId, error));\n return null;\n } finally {\n if (timer) clearTimeout(timer);\n }\n }\n\n private async write(shardId: number): Promise<void> {\n const info = this.#pending.get(shardId)!;\n this.#pending.delete(shardId);\n try {\n await this.#store.set(shardId, info);\n } catch (error) {\n this.#onError(new GatewaySessionStoreError(\"set\", shardId, error));\n }\n }\n}\n","import {\n CloseCodes,\n DefaultWebSocketManagerOptions,\n WebSocketManager,\n WebSocketShardEvents,\n WebSocketShardStatus,\n type OptionalWebSocketManagerOptions,\n type SessionInfo,\n type ShardRange,\n} from \"@discordjs/ws\";\nimport { Client as DiscordCoreClient, type API } from \"@discordjs/core\";\nimport type { REST } from \"@discordjs/rest\";\nimport { Client, container, type ClientOptions } from \"@wolfstar/http-framework\";\nimport { applyGatewayDispatch, type Cache, type GatewaySessionStore } from \"@wolfstar/plugin-cache\";\nimport {\n GatewayDispatchEvents,\n GatewayIntentBits,\n GatewayOpcodes,\n type APIVoiceRegion,\n type GatewayDispatchPayload,\n type GatewayReadyDispatchData,\n} from \"discord-api-types/v10\";\nimport { ChannelManager } from \"./managers/ChannelManager.js\";\nimport { GuildManager } from \"./managers/GuildManager.js\";\nimport { GuildMemberManager } from \"./managers/GuildMemberManager.js\";\nimport { MessageManager } from \"./managers/MessageManager.js\";\nimport { RoleManager } from \"./managers/RoleManager.js\";\nimport { SoundboardSound } from \"./structures/soundboards/SoundboardSound.js\";\nimport { WebhookManager } from \"./managers/WebhookManager.js\";\nimport { GuildTemplateManager } from \"./managers/GuildTemplateManager.js\";\nimport { VoiceStateManager } from \"./managers/VoiceStateManager.js\";\nimport { PresenceManager } from \"./managers/PresenceManager.js\";\nimport { ThreadManager } from \"./managers/ThreadManager.js\";\nimport { ThreadMemberManager } from \"./managers/ThreadMemberManager.js\";\nimport { UserManager } from \"./managers/UserManager.js\";\nimport type { BaseInvite } from \"./structures/invites/BaseInvite.js\";\nimport type { ClientUser } from \"./structures/users/ClientUser.js\";\nimport { createInvite } from \"./structures/invites/GroupDMInvite.js\";\nimport { bindClient } from \"./structures/Structure.js\";\nimport { Sticker } from \"./structures/stickers/Sticker.js\";\nimport type { Webhook } from \"./structures/webhooks/Webhook.js\";\nimport type { GuildTemplate } from \"./structures/guilds/GuildTemplate.js\";\nimport { Widget } from \"./structures/guilds/Widget.js\";\nimport { StickerPack } from \"./structures/stickers/StickerPack.js\";\nimport { ActionsManager } from \"./actions/Action.js\";\nimport { dispatchPartition, DispatchQueue, type DispatchQueueStats } from \"./util/DispatchQueue.js\";\nimport { DispatchTimeoutError } from \"./util/errors.js\";\nimport type { GatewayClientMessageDefaults } from \"./structures/messages/MessagePayload.js\";\nimport type { Partials } from \"./util/Partials.js\";\nimport { GatewaySessionMirror } from \"./util/sessions.js\";\n\nexport interface GatewayClientOptions extends ClientOptions, GatewayClientMessageDefaults {\n /**\n * The gateway intents to identify with, e.g. `GatewayIntentBits.Guilds | GatewayIntentBits.GuildMessages`.\n */\n intents: GatewayIntentBits | number;\n /**\n * The total number of shards across every process, `null` to use the amount recommended by Discord.\n *\n * @default null\n */\n shardCount?: number | null;\n /**\n * The IDs of the shards this client manages, `null` to manage all of them.\n *\n * @default null\n */\n shardIds?: number[] | ShardRange | null;\n /**\n * The cache to write every dispatch into, see `@wolfstar/plugin-cache`. Without one, the managers' `get` always\n * resolve to `undefined`, update events receive `null` as their previous state, and `fetch` always hits the API.\n *\n * @default undefined\n */\n cache?: Cache;\n /**\n * Additional options for the underlying `@discordjs/ws` `WebSocketManager`, e.g. `compression` or\n * `initialPresence`.\n */\n gateway?: Partial<Omit<OptionalWebSocketManagerOptions, \"token\" | \"shardCount\" | \"shardIds\">>;\n /**\n * Where to keep the shards' sessions, e.g. `createRedisSessionStore` from `@wolfstar/plugin-cache`, so a restarted\n * process resumes them instead of identifying again: no identify quota spent, the dispatches missed meanwhile\n * replayed, and no `GUILD_CREATE` burst. Pair it with a persistent cache, since a resumed session does not refill an\n * empty one. Use {@link GatewayClient.destroy}'s `resumable` option to keep the sessions on a graceful shutdown.\n *\n * @remarks\n * The store is read once per shard when it first connects, then mirrored in memory, and written in the background\n * on every sequence change, see {@link GatewayClientOptions.sessionStoreTimeout}. Its failures are reported as\n * `GatewaySessionStoreError`s through the `error` event and never stop a shard: a failed read identifies.\n *\n * It replaces `gateway.retrieveSessionInfo` and `gateway.updateSessionInfo`, passing either alongside it throws.\n *\n * @default undefined\n */\n sessionStore?: GatewaySessionStore;\n /**\n * The time, in milliseconds, after which a shard stops waiting for {@link GatewayClientOptions.sessionStore} to read\n * its session, and identifies instead. `null` waits forever.\n *\n * @default 5_000\n */\n sessionStoreTimeout?: number | null;\n /**\n * What to do with a dispatch whose cache read or write fails, e.g. while Redis is unreachable. The error is always\n * reported through the `error` event (or the logger when nobody listens to it).\n *\n * - `\"skip\"`: drop the dispatch's event, so listeners never see state the cache does not hold.\n * - `\"emitUncached\"`: still emit the event, built from the payload alone, with `null` as the previous state.\n *\n * @default \"skip\"\n */\n cacheFailure?: \"skip\" | \"emitUncached\";\n /**\n * The time, in milliseconds, after which a dispatch still being processed is reported as a `DispatchTimeoutError`\n * through the `error` event. The dispatch is not cancelled. `null` disables the check.\n *\n * @default 30_000\n */\n dispatchTimeout?: number | null;\n /**\n * The structures to build partially when an event concerns one that is not cached, like discord.js's `partials`,\n * e.g. `[Partials.Message, Partials.User]`. See {@link Partials}.\n *\n * @default []\n */\n partials?: readonly Partials[];\n /**\n * How long, in milliseconds, the client waits for every guild `READY` listed as initially unavailable to become\n * available (its `GUILD_CREATE`) before emitting `clientReady` anyway, like discord.js's `waitGuildTimeout`.\n *\n * @remarks\n * It only bounds the wait on guild availability: `clientReady` still never fires before every shard this client\n * manages has connected, however long that takes, even past this timeout.\n *\n * Skipped (waits `0` ms) when `intents` does not include `GatewayIntentBits.Guilds`, since without it Discord never\n * sends the guilds' data, so no `GUILD_CREATE` for them ever arrives.\n *\n * @default 15_000\n */\n waitGuildTimeout?: number;\n}\n\n/** Options for loading pieces and starting both transports. */\nexport interface GatewayClientStartOptions {\n /** HTTP interaction server options. */\n listen: Client.ServerListenOptions;\n /** Piece loading options. */\n load?: Client.PieceLoadOptions;\n}\n\n/** Options for disconnecting the gateway shards. */\nexport interface GatewayClientDestroyOptions {\n /**\n * Whether to keep the shards' sessions resumable, for the next process to resume them (e.g. during a deploy): the\n * shards close with a code Discord does not invalidate the session on, and their sessions stay stored. Only\n * meaningful with {@link GatewayClientOptions.sessionStore}, or with `gateway.updateSessionInfo`.\n *\n * @default false\n */\n resumable?: boolean;\n}\n\n/**\n * A {@link Client} that, on top of serving HTTP interactions, connects to the Discord gateway, writes every dispatch\n * into an optional {@link Cache}, and emits {@link GatewayEventMap} events carrying structures.\n *\n * @example\n * ```typescript\n * import { GatewayClient } from '@wolfstar/plugin-gateway';\n * import { createInMemoryCache } from '@wolfstar/plugin-cache';\n * import { GatewayIntentBits } from 'discord-api-types/v10';\n *\n * const client = new GatewayClient({\n * intents: GatewayIntentBits.Guilds | GatewayIntentBits.GuildMessages,\n * cache: createInMemoryCache(),\n * });\n *\n * client.on('messageCreate', (message) => console.log(`${message.author.username}: ${message.content}`));\n *\n * await client.start({ listen: { port: 8080 } });\n * ```\n */\nexport class GatewayClient extends Client {\n /**\n * The cache every dispatch is written into, if any.\n */\n public readonly cache: Cache | undefined;\n\n /**\n * The REST manager the gateway (for its gateway bot info) and every manager's API calls go through, like\n * discord.js's `Client#rest`.\n */\n public readonly rest: REST;\n\n /**\n * The underlying `@discordjs/ws` manager, handling the shards' connections, resumes, and identify rate limits.\n */\n public readonly gateway: WebSocketManager;\n\n /**\n * The typed REST API every manager's calls go through, `@discordjs/core`'s `API` built from {@link GatewayClient.rest}.\n */\n public readonly api: API;\n\n /**\n * The discord.js core client, sharing this client's REST and gateway transports, like the RFC `next` `Client`'s\n * own `core`.\n *\n * @remarks\n * Kept protected: managers and structures reach its typed REST calls through {@link GatewayClient.api} instead, and\n * its gateway and REST manager are already {@link GatewayClient.gateway} and {@link GatewayClient.rest}. It is only\n * needed to build the discord.js core client's own event listeners, if this class ever wraps them.\n */\n protected readonly core: DiscordCoreClient;\n\n /** The actions that turn gateway dispatches into public client events. */\n public readonly actions: ActionsManager;\n\n /**\n * The bot user, set once the first shard receives `READY`.\n */\n public user: ClientUser | null = null;\n\n public readonly users: UserManager;\n public readonly guilds: GuildManager;\n public readonly channels: ChannelManager;\n public readonly threads: ThreadManager;\n public readonly threadMembers: ThreadMemberManager;\n public readonly messages: MessageManager;\n public readonly members: GuildMemberManager;\n public readonly roles: RoleManager;\n public readonly webhooks: WebhookManager;\n public readonly templates: GuildTemplateManager;\n public readonly voiceStates: VoiceStateManager;\n public readonly presences: PresenceManager;\n\n /**\n * What happens to a dispatch whose cache read or write fails, see {@link GatewayClientOptions.cacheFailure}.\n */\n public readonly cacheFailure: \"skip\" | \"emitUncached\";\n\n /**\n * See {@link GatewayClientOptions.dispatchTimeout}.\n */\n public readonly dispatchTimeout: number | null;\n\n /**\n * The structures built partially for uncached entities, see {@link GatewayClientOptions.partials}.\n */\n public readonly partials: readonly Partials[];\n\n /**\n * See {@link GatewayClientOptions.waitGuildTimeout}.\n */\n public readonly waitGuildTimeout: number;\n\n /**\n * The timestamp the client last became ready, like discord.js's `Client#readyTimestamp`. `null` until\n * `clientReady` is first emitted, see {@link GatewayClient.clientReadyAt}.\n */\n public clientReadyTimestamp: number | null = null;\n\n // Dispatches of a guild are processed in order, so an asynchronous cache never reorders them, while different\n // guilds proceed concurrently.\n readonly #queue = new DispatchQueue();\n\n readonly #shardCount: number | null;\n\n readonly #intents: number;\n\n // Resolved once from the options (or the environment) and kept private, rather than read again from `this.options`,\n // which the base client scrubs it from.\n readonly #token: string;\n\n // The guilds `READY` listed as initially unavailable, whose `GUILD_CREATE` or `GUILD_DELETE` the client waits for\n // before emitting `clientReady`, like discord.js's `Client#expectedGuilds`.\n readonly #expectedGuilds = new Set<string>();\n\n // The fallback timer emitting `clientReady` even with guilds still unavailable, like discord.js's own\n // `readyTimeout`. Cleared and rescheduled every time `#checkClientReady` runs short of triggering it.\n #clientReadyTimer: ReturnType<typeof setTimeout> | null = null;\n\n #sessions: GatewaySessionMirror | null = null;\n\n // Set while a resumable `destroy` runs, see `sessionCallbacks`.\n #keepSessions = false;\n\n // The `destroy` in progress, which a concurrent call joins instead of changing `#keepSessions` under it.\n #destroying: Promise<void> | null = null;\n\n public constructor(options: GatewayClientOptions) {\n super(options);\n container.gatewayClient = this;\n\n // Set by the base client's constructor, which validated the token and built the REST manager already.\n this.rest = container.rest;\n this.cache = options.cache;\n this.cacheFailure = options.cacheFailure ?? \"skip\";\n this.dispatchTimeout = options.dispatchTimeout === undefined ? 30_000 : options.dispatchTimeout;\n this.partials = Object.freeze([...(options.partials ?? [])]);\n this.waitGuildTimeout = options.waitGuildTimeout ?? 15_000;\n this.#shardCount = options.shardCount ?? null;\n this.#intents = Number(options.intents);\n // The base client validated it already, and scrubs it from `this.options`.\n this.#token = (options.discordToken ?? process.env.DISCORD_TOKEN)!;\n this.users = new UserManager(this);\n this.guilds = new GuildManager(this);\n this.channels = new ChannelManager(this);\n this.threads = new ThreadManager(this);\n this.threadMembers = new ThreadMemberManager(this);\n this.messages = new MessageManager(this);\n this.members = new GuildMemberManager(this);\n this.roles = new RoleManager(this);\n this.webhooks = new WebhookManager(this);\n this.templates = new GuildTemplateManager(this);\n this.voiceStates = new VoiceStateManager(this);\n this.presences = new PresenceManager(this);\n\n this.gateway = new WebSocketManager({\n ...options.gateway,\n ...this.sessionCallbacks(options),\n token: this.#token,\n intents: options.intents as GatewayIntentBits,\n rest: this.rest,\n shardCount: options.shardCount ?? null,\n shardIds: options.shardIds ?? null,\n });\n this.core = new DiscordCoreClient({ gateway: this.gateway, rest: this.rest });\n this.api = this.core.api;\n this.actions = new ActionsManager(this);\n\n this.gateway.on(WebSocketShardEvents.Dispatch, (payload, shardId) => {\n const partition = dispatchPartition(payload);\n void this.#queue.enqueue(shardId, partition, () =>\n this.runDispatch(payload, shardId, partition),\n );\n });\n this.gateway.on(WebSocketShardEvents.Resumed, (shardId) => this.emit(\"shardResume\", shardId));\n this.gateway.on(WebSocketShardEvents.Closed, (code, shardId) =>\n this.emit(\"shardClose\", shardId, code),\n );\n this.gateway.on(WebSocketShardEvents.Error, (error, shardId) =>\n this.emit(\"shardError\", error, shardId),\n );\n this.gateway.on(WebSocketShardEvents.Debug, (message, shardId) =>\n this.logger.debug(`[Gateway] [Shard ${shardId}] ${message}`),\n );\n }\n\n /**\n * Connects every configured shard to the gateway.\n */\n public async connect(): Promise<void> {\n await this.gateway.connect();\n }\n\n /** Loads pieces, starts the interaction endpoint, then connects gateway shards. */\n public async start({ listen, load }: GatewayClientStartOptions): Promise<void> {\n await this.load(load);\n await this.listen(listen);\n await this.connect();\n }\n\n /**\n * Disconnects every shard from the gateway. The HTTP server, if listening, is left untouched.\n *\n * @remarks\n * By default, the shards close their sessions, which Discord invalidates. Pass `resumable: true` to keep them\n * resumable instead, e.g. on a graceful shutdown before a deploy. Either way, it waits for the sessions to be\n * written to {@link GatewayClientOptions.sessionStore}.\n *\n * A call made while another one is still disconnecting the shards joins it, keeping the first call's `resumable`.\n *\n * @param options Whether to keep the sessions resumable.\n */\n public destroy(options: GatewayClientDestroyOptions = {}): Promise<void> {\n this.#destroying ??= this.disconnect(options.resumable ?? false).finally(() => {\n this.#destroying = null;\n });\n return this.#destroying;\n }\n\n private async disconnect(resumable: boolean): Promise<void> {\n this.#keepSessions = resumable;\n try {\n // Discord invalidates the session of a connection closed with 1000 or 1001, the default is 1000.\n await this.gateway.destroy(\n this.#keepSessions ? { code: CloseCodes.Resuming, reason: \"Resumable shutdown\" } : {},\n );\n } finally {\n this.#keepSessions = false;\n }\n\n await this.#sessions?.flush();\n await this.idle();\n }\n\n /**\n * Runs a cache write of the client's own (e.g. after leaving a guild) in order with the guild's dispatches.\n *\n * @param guildId The ID of the guild.\n * @param task The cache write.\n * @internal\n */\n public async runInGuildOrder<Value>(guildId: string, task: () => Promise<Value>): Promise<Value> {\n let outcome: { value: Value } | { error: unknown } | undefined;\n // Queued tasks must never reject: the outcome is carried out of the queue instead.\n await this.#queue.enqueueGuild(guildId, async () => {\n try {\n outcome = { value: await task() };\n } catch (error) {\n outcome = { error };\n }\n });\n\n if (\"error\" in outcome!) throw outcome.error;\n return outcome!.value;\n }\n\n /**\n * Resolves once every dispatch received so far has been processed.\n */\n public async idle(): Promise<void> {\n await this.#queue.idle();\n }\n\n /**\n * Fetches Discord's default soundboard sounds, which every guild can play.\n */\n public async fetchDefaultSoundboardSounds(): Promise<SoundboardSound[]> {\n const sounds = await this.api.soundboardSounds.getSoundboardDefaultSounds();\n return sounds.map((sound) => new SoundboardSound(sound));\n }\n\n /**\n * Fetches a webhook. discord.js: `client.fetchWebhook(id, token)`.\n *\n * @param webhookId The ID of the webhook.\n * @param token The webhook's token, to fetch it without the bot's authorization.\n */\n public fetchWebhook(webhookId: string, token?: string): Promise<Webhook> {\n return this.webhooks.fetch(webhookId, token);\n }\n\n /**\n * Fetches a guild template by its code. discord.js: `client.fetchGuildTemplate(code)`.\n *\n * @param code The code of the template, or its URL.\n */\n public fetchGuildTemplate(code: string): Promise<GuildTemplate> {\n return this.templates.fetch(code);\n }\n\n /**\n * Fetches the public widget of a guild, which must be enabled. Needs no membership of the guild.\n *\n * @param guildId The ID of the guild.\n */\n public async fetchGuildWidget(guildId: string): Promise<Widget> {\n return new Widget(await this.api.guilds.getWidget(guildId));\n }\n\n /**\n * Fetches an invite by its code.\n *\n * @param code The code of the invite, or its URL.\n * @param options Whether to include the approximate counts (default), and a scheduled event to attach.\n */\n public async fetchInvite(\n code: string,\n options: { withCounts?: boolean; guildScheduledEventId?: string } = {},\n ): Promise<BaseInvite> {\n // Accept `https://discord.gg/code` and `discord.com/invite/code` as well as the bare code.\n const resolved = code.split(\"/\").pop()!;\n const invite = await this.api.invites.get(resolved, {\n with_counts: options.withCounts ?? true,\n guild_scheduled_event_id: options.guildScheduledEventId,\n });\n const [guild, channel, inviter, targetUser] = await Promise.all([\n invite.guild ? this.guilds.get(invite.guild.id) : undefined,\n invite.channel ? this.channels.get(invite.channel.id) : undefined,\n invite.inviter ? this.users.resolveData(invite.inviter) : undefined,\n invite.target_user ? this.users.resolveData(invite.target_user) : undefined,\n ]);\n return bindClient(\n createInvite(invite, { guild: guild ?? null, channel: channel ?? null, inviter, targetUser }),\n this,\n );\n }\n\n /**\n * Fetches a sticker, standard or from a guild.\n *\n * @param stickerId The ID of the sticker.\n */\n public async fetchSticker(stickerId: string): Promise<Sticker> {\n return new Sticker(await this.api.stickers.get(stickerId));\n }\n\n /**\n * Fetches the packs of standard stickers.\n */\n public async fetchStickerPacks(): Promise<StickerPack[]> {\n const { sticker_packs: packs } = await this.api.stickers.getStickers();\n return packs.map((pack) => new StickerPack(pack));\n }\n\n /**\n * Fetches the voice regions available to the bot.\n */\n public async fetchVoiceRegions(): Promise<APIVoiceRegion[]> {\n return this.api.voice.getVoiceRegions();\n }\n\n /**\n * The dispatches received but not processed yet, and the partitions (guilds, direct message channels) they are\n * queued in. A growing `pending` count usually means a slow or unreachable cache.\n */\n public get queueStats(): DispatchQueueStats {\n return this.#queue.stats;\n }\n\n /**\n * The time the client last became ready, like discord.js's `Client#readyAt`. `null` until `clientReady` is first\n * emitted.\n */\n public get clientReadyAt(): Date | null {\n return this.clientReadyTimestamp === null ? null : new Date(this.clientReadyTimestamp);\n }\n\n /**\n * Whether the client already emitted `clientReady`, like discord.js's `Client#isReady()`.\n */\n public isClientReady(): boolean {\n return this.clientReadyTimestamp !== null;\n }\n\n /**\n * Processes a gateway dispatch: emits it as `raw`, writes it into the cache, emits it as `dispatch`, and emits the\n * matching {@link GatewayEventMap} event, if any.\n *\n * @param payload The dispatch payload.\n * @param shardId The ID of the shard that received it.\n */\n protected async handleDispatch(payload: GatewayDispatchPayload, shardId: number): Promise<void> {\n this.emit(\"raw\", payload, shardId);\n\n // Interactions are served by the HTTP endpoint, see the `DispatchHandlers` remarks.\n if (payload.t === GatewayDispatchEvents.InteractionCreate) return;\n // A rate limited members request gets no chunks: fail it now rather than at its timeout.\n if (payload.t === GatewayDispatchEvents.RateLimited) this.members.handleRateLimited(payload.d);\n\n const action = this.actions.get(payload.t);\n // `READY` is never dropped: it sets `client.user` and `shardReady` from the payload alone, and a shard without it\n // looks dead to the bot. Reconciling the cache with it is best effort, see `reconcileGuilds`.\n const isReady = payload.t === GatewayDispatchEvents.Ready;\n if (isReady) {\n await this.reconcileGuilds(payload.d, shardId);\n // The guilds this shard's `READY` listed as initially unavailable, awaited by `clientReady`.\n for (const guild of payload.d.guilds) this.#expectedGuilds.add(guild.id);\n }\n\n let state: unknown;\n try {\n state = await action?.before(payload.d);\n if (this.cache) {\n await applyGatewayDispatch(this.cache, payload, { clientUserId: this.user?.id ?? this.id });\n }\n } catch (error) {\n if (this.cacheFailure === \"skip\" && !isReady) throw error;\n this.reportError(error, payload.t, shardId);\n state = undefined;\n }\n\n this.emit(\"dispatch\", payload, shardId);\n await action?.handle(payload.d, state, shardId);\n\n if (this.clientReadyTimestamp === null) {\n if (isReady) {\n await this.#checkClientReady();\n } else if (\n (payload.t === GatewayDispatchEvents.GuildCreate ||\n payload.t === GatewayDispatchEvents.GuildDelete) &&\n this.#expectedGuilds.delete(payload.d.id)\n ) {\n await this.#checkClientReady();\n }\n }\n }\n\n /**\n * Emits `clientReady` once every shard this client manages has connected and every guild `READY` listed as\n * initially unavailable became available, or {@link GatewayClientOptions.waitGuildTimeout} elapses, like\n * discord.js's `Client#_checkReady`.\n *\n * @remarks\n * `waitGuildTimeout` bounds the wait on guild availability only: once it elapses, the still-unavailable guilds are\n * forgotten (so a later `GUILD_CREATE`/`GUILD_DELETE` for one of them does not spuriously re-run this), but every\n * shard connecting is never skipped, however long that takes — there is no such timeout for it, matching\n * `@discordjs/ws`, which waits for the network rather than giving up.\n *\n * Unlike discord.js, `clientReady` only ever fires once: subsequent guild or shard activity does not re-trigger it.\n */\n async #checkClientReady(): Promise<void> {\n // A concurrent shard's call already triggered it.\n if (this.clientReadyTimestamp !== null) return;\n\n if (this.#clientReadyTimer) {\n clearTimeout(this.#clientReadyTimer);\n this.#clientReadyTimer = null;\n }\n\n if (this.#expectedGuilds.size > 0) {\n // Without the `Guilds` intent, Discord never sends the unavailable guilds' data, so no `GUILD_CREATE` for them\n // ever arrives: there is nothing to wait for.\n const hasGuildsIntent = (this.#intents & GatewayIntentBits.Guilds) !== 0;\n this.#clientReadyTimer = setTimeout(\n () => {\n this.#clientReadyTimer = null;\n this.#expectedGuilds.clear();\n void this.#checkClientReady();\n },\n hasGuildsIntent ? this.waitGuildTimeout : 0,\n );\n this.#clientReadyTimer.unref?.();\n return;\n }\n\n const statuses = await this.gateway.fetchStatus();\n // Re-check: a concurrent call may have triggered it, or a shard may have disconnected, while this one awaited\n // the shards' statuses.\n if (this.clientReadyTimestamp !== null || this.#expectedGuilds.size > 0) return;\n\n const everyShardReady = [...statuses.values()].every(\n (status) => status === WebSocketShardStatus.Ready,\n );\n if (everyShardReady) this.#triggerClientReady();\n // Otherwise, nothing left to bound with a timer: the next shard to connect re-enters here through its own\n // `READY`.\n }\n\n // Sets `clientReadyTimestamp` and emits `clientReady`, guarding against a concurrent call (a racing shard, or the\n // fallback timer) doing it first: this is always called synchronously, with no `await` before it, so the guard\n // cannot itself be raced.\n #triggerClientReady(): void {\n if (this.clientReadyTimestamp !== null) return;\n this.clientReadyTimestamp = Date.now();\n this.emit(\"clientReady\", this);\n }\n\n /**\n * Drops the cached guilds of a shard its `READY` no longer lists, and emits `guildDelete` for each of them.\n *\n * @remarks\n * They are the guilds the bot left while it was disconnected, or while the process was down with a persistent\n * cache. Discord does not replay those removals on a new session, so the cache would otherwise keep them forever.\n *\n * It is best effort: any failure (cache unreachable, unknown shard count) is reported through `error` and stops the\n * reconciliation, keeping the remaining guilds, but never fails `READY` itself.\n *\n * @param data The `READY` data.\n * @param shardId The shard that received it.\n */\n protected async reconcileGuilds(data: GatewayReadyDispatchData, shardId: number): Promise<void> {\n try {\n await this.dropUnlistedGuilds(data, shardId);\n } catch (error) {\n this.reportError(error, GatewayDispatchEvents.Ready, shardId);\n }\n }\n\n private async dropUnlistedGuilds(data: GatewayReadyDispatchData, shardId: number): Promise<void> {\n if (!this.cache) return;\n\n const cached = await this.cache.guilds.keys();\n if (cached.length === 0) return;\n\n // Without the shard count, the guilds of this shard cannot be told apart from the others'.\n const count = data.shard?.[1] ?? this.#shardCount ?? (await this.gateway.getShardCount());\n const listed = new Set(data.guilds.map((guild) => guild.id));\n const shardCount = BigInt(count);\n for (const id of cached) {\n if (listed.has(id) || Number((BigInt(id) >> 22n) % shardCount) !== shardId) continue;\n\n const guild = (await this.guilds.get(id)) ?? null;\n await applyGatewayDispatch(this.cache, {\n op: GatewayOpcodes.Dispatch,\n s: 0,\n t: GatewayDispatchEvents.GuildDelete,\n d: { id },\n });\n this.emit(\"guildDelete\", guild, { id });\n }\n }\n\n private async runDispatch(\n payload: GatewayDispatchPayload,\n shardId: number,\n partition: string | null,\n ): Promise<void> {\n const timeout = this.dispatchTimeout;\n const timer =\n timeout === null\n ? null\n : setTimeout(() => {\n this.reportError(\n new DispatchTimeoutError(payload.t, shardId, partition, timeout),\n payload.t,\n shardId,\n );\n }, timeout);\n timer?.unref?.();\n\n try {\n await this.handleDispatch(payload, shardId);\n } catch (error) {\n this.reportError(error, payload.t, shardId);\n } finally {\n if (timer) clearTimeout(timer);\n }\n }\n\n private sessionCallbacks(\n options: GatewayClientOptions,\n ): Pick<OptionalWebSocketManagerOptions, \"retrieveSessionInfo\" | \"updateSessionInfo\"> {\n const { sessionStore, gateway } = options;\n if (sessionStore && (gateway?.retrieveSessionInfo || gateway?.updateSessionInfo)) {\n throw new TypeError(\n \"sessionStore replaces gateway.retrieveSessionInfo and gateway.updateSessionInfo, pass one or the other\",\n );\n }\n\n let retrieve =\n gateway?.retrieveSessionInfo ?? DefaultWebSocketManagerOptions.retrieveSessionInfo;\n let update = gateway?.updateSessionInfo ?? DefaultWebSocketManagerOptions.updateSessionInfo;\n if (sessionStore) {\n const timeout =\n options.sessionStoreTimeout === undefined ? 5_000 : options.sessionStoreTimeout;\n const sessions = new GatewaySessionMirror(sessionStore, timeout, (error) =>\n this.reportError(error, `the session store ${error.operation}`, error.shardId),\n );\n this.#sessions = sessions;\n // Both directions keep `GatewaySessionInfo` assignable to and from `@discordjs/ws`'s `SessionInfo`.\n retrieve = (shardId): Promise<SessionInfo | null> => sessions.get(shardId);\n update = (shardId, info) => sessions.set(shardId, info);\n }\n\n return {\n retrieveSessionInfo: retrieve,\n // `@discordjs/ws` drops the session of every shard destroyed without resuming, a resumable shutdown included:\n // the session must stay stored for the next process to resume it.\n updateSessionInfo: (shardId, info) =>\n info === null && this.#keepSessions ? undefined : update(shardId, info),\n };\n }\n\n // Emitting \"error\" without listeners throws, which would reject the queue and stall the partition.\n private reportError(error: unknown, type: string, shardId: number): void {\n if (this.listenerCount(\"error\") > 0) this.emit(\"error\", error);\n else this.logger.error(`[Gateway] [Shard ${shardId}] Failed to process ${type}:`, error);\n }\n}\n","import type { GatewayEventName } from \"./events.js\";\nimport type { EventGatewayListener } from \"../EventGatewayListener.js\";\n\ntype ListenerConstructor = new (...args: any[]) => EventGatewayListener<any>;\n\n/**\n * Class decorator that binds the decorated {@link EventGatewayListener} to a gateway event, so it does not need to\n * declare a constructor.\n *\n * @example\n * ```typescript\n * import { EventGatewayListener, RegisterAsGatewayListener, type Message } from '@wolfstar/plugin-gateway';\n *\n * @RegisterAsGatewayListener('messageCreate')\n * export class LogMessagesListener extends EventGatewayListener<'messageCreate'> {\n * public override run(message: Message) {\n * console.log(`${message.author.username}: ${message.content}`);\n * }\n * }\n * ```\n *\n * @param event The event to listen to.\n * @param options The additional listener options.\n */\nexport function RegisterAsGatewayListener<Event extends GatewayEventName>(\n event: Event,\n options: Omit<EventGatewayListener.Options<Event>, \"event\"> = {},\n) {\n return function decorate<T extends ListenerConstructor>(target: T): T {\n // Seen through its instance type, the target is abstract (`run`), even though the decorated class implements it.\n const base = target as unknown as new (...args: any[]) => object;\n return class extends base {\n public constructor(...args: any[]) {\n const [context, baseOptions = {}] = args as [\n EventGatewayListener.LoaderContext,\n Partial<EventGatewayListener.Options<Event>>?,\n ];\n super(context, { ...baseOptions, ...options, event });\n }\n } as unknown as T;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,IAAsB,uBAAtB,cAEU,SAAsD;;;;CAI9D,AAAgB;CAEhB,AAAO,YACL,SACA,SACA;EACA,MAAM,SAAS;GAAE,GAAG;GAAS,SAAS;EAAS,CAAC;EAChD,KAAK,OAAO,QAAQ,QAAQ;EAE5B,IAAI,KAAK,MAAM;GAIb,MAAM,WAAW,KAAK;GAEtB,KAAK,YAAY,OAAO,GAAG,SAA6B;IACtD,MAAM,KAAK,OAAO;IAClB,OAAO,SAAS,GAAG,IAAI;GACzB;EACF;CACF;AAGF;;;;;;;;;ACvBA,SAAgB,UAAU,OAA6B;CACrD,MAAM,KAAK,OAAO,UAAU,WAAW,QAAQ,MAAM;CACrD,IAAI,CAAC,IAAI,MAAM,IAAI,UAAU,mDAAmD;CAChF,OAAO;AACT;;;;AA0BA,SAAgB,eAAe,WAAwC;CACrE,OAAO;EACL,IAAI,UAAU,UAAU,EAAE;EAC1B,MAAM,UAAU;EAChB,OAAO,OAAO,oBAAoB,QAAQ,UAAU,SAAS,EAAE,CAAC;EAChE,MAAM,OAAO,oBAAoB,QAAQ,UAAU,QAAQ,EAAE,CAAC;CAChE;AACF;;;;;;;AAQA,SAAgB,wBACd,SACA,UAA6C,CAAC,GACb;CACjC,IAAI,QAAQ,QAAQ,SAAS;CAC7B,IAAI,OAAO,QAAQ,QAAQ;CAC3B,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,OAAO,GAAG;EACnD,MAAM,MAAM,oBAAoB;EAChC,IAAI,UAAU,UAAa,QAAQ,QAAW;EAC9C,SAAS,CAAC;EACV,QAAQ,CAAC;EACT,IAAI,UAAU,MAAM,SAAS;O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B,SAAY,OAAO,SAAS,IAAI;EAC1E;CACF;CAGA,AAAQ,YAAY,OAAgB,MAAc,SAAuB;EACvE,IAAI,KAAK,cAAc,OAAO,IAAI,GAAG,KAAK,KAAK,SAAS,KAAK;OACxD,KAAK,OAAO,MAAM,oBAAoB,QAAQ,sBAAsB,KAAK,IAAI,KAAK;CACzF;AACF;;;;;;;;;;;;;;;;;;;;;;;ACluBA,SAAgB,0BACd,OACA,UAA8D,CAAC,GAC/D;CACA,OAAO,SAAS,SAAwC,QAAc;EAEpE,MAAM,OAAO;EACb,OAAO,cAAc,KAAK;GACxB,AAAO,YAAY,GAAG,MAAa;IACjC,MAAM,CAAC,SAAS,cAAc,CAAC,KAAK;IAIpC,MAAM,SAAS;KAAE,GAAG;KAAa,GAAG;KAAS;IAAM,CAAC;GACtD;EACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["BaseStructure","BitField","BaseActivityFlagsBitField","BaseAttachmentFlagsBitField","BaseChannelFlagsBitField","BaseMessageFlagsBitField","BaseAnnouncementChannel","BaseAnnouncementThreadChannel","BaseChannelStructure","BaseCategoryChannel","BaseUser","BaseDMChannel","BaseForumChannel","BaseGroupDMChannel","BaseMediaChannel","BasePrivateThreadChannel","BasePublicThreadChannel","BaseStageChannel","BaseTextChannel","BaseVoiceChannel","BaseStageInstance","BaseAutoModerationRule","BaseEmoji","pick","BaseStructure","BaseSticker","BaseWebhook","toISO","BaseSoundboardSound","BaseActivity","BasePresence","BaseVoiceState","BaseReaction","BaseStructure","BaseAttachment","BaseEmbed","BaseStructure","pick","BasePollAnswer","BasePoll","BaseStructure","BaseMessage","BaseStructure","BaseStickerPack","DiscordCoreClient"],"sources":["../../src/EventGatewayListener.ts","../../src/util/channels.ts","../../src/structures/Mixin.ts","../../src/util/container.ts","../../src/structures/Structure.ts","../../src/util/flags.ts","../../src/structures/channels/mixins/BaseChannelMixin.ts","../../src/structures/channels/mixins/ChannelParentMixin.ts","../../src/structures/channels/PermissionOverwrites.ts","../../src/managers/PermissionOverwriteManager.ts","../../src/util/permissions.ts","../../src/structures/channels/mixins/edit.ts","../../src/structures/channels/mixins/ChannelPermissionMixin.ts","../../src/structures/channels/mixins/ChannelSlowmodeMixin.ts","../../src/managers/ChannelThreadManager.ts","../../src/structures/channels/mixins/ChannelThreadsMixin.ts","../../src/structures/channels/mixins/ChannelWebhooksMixin.ts","../../src/structures/channels/mixins/ChannelTopicMixin.ts","../../src/structures/channels/mixins/GuildChannelMixin.ts","../../src/managers/ChannelMessageManager.ts","../../src/structures/messages/MessagePayload.ts","../../src/structures/channels/mixins/TextChannelMixin.ts","../../src/structures/channels/AnnouncementChannel.ts","../../src/structures/channels/mixins/ChannelOwnerMixin.ts","../../src/managers/ThreadChannelMemberManager.ts","../../src/structures/channels/mixins/ThreadChannelMixin.ts","../../src/structures/channels/AnnouncementThreadChannel.ts","../../src/structures/channels/Channel.ts","../../src/structures/channels/BaseChannel.ts","../../src/structures/channels/CategoryChannel.ts","../../src/util/cdn.ts","../../src/structures/users/User.ts","../../src/structures/channels/mixins/DMChannelMixin.ts","../../src/structures/channels/DMChannel.ts","../../src/structures/channels/mixins/ThreadOnlyChannelMixin.ts","../../src/structures/channels/ForumChannel.ts","../../src/structures/channels/mixins/GroupDMMixin.ts","../../src/structures/channels/GroupDMChannel.ts","../../src/structures/channels/MediaChannel.ts","../../src/structures/channels/PrivateThreadChannel.ts","../../src/structures/channels/mixins/AppliedTagsMixin.ts","../../src/structures/channels/PublicThreadChannel.ts","../../src/structures/channels/mixins/VoiceChannelMixin.ts","../../src/structures/channels/StageChannel.ts","../../src/structures/channels/TextChannel.ts","../../src/structures/channels/VoiceChannel.ts","../../src/structures/stageInstances/StageInstance.ts","../../src/util/cache.ts","../../src/managers/CachedManager.ts","../../src/managers/ChannelManager.ts","../../src/structures/guilds/AnonymousGuild.ts","../../src/structures/guilds/Guild.ts","../../src/structures/automoderation/AutoModerationRule.ts","../../src/structures/emojis/Emoji.ts","../../src/structures/emojis/ReactionEmoji.ts","../../src/structures/guilds/GuildOnboarding.ts","../../src/structures/guilds/GuildScheduledEvent.ts","../../src/structures/guilds/Integration.ts","../../src/structures/invites/BaseInvite.ts","../../src/structures/guilds/InviteGuild.ts","../../src/structures/invites/GuildInvite.ts","../../src/structures/stickers/Sticker.ts","../../src/structures/webhooks/WebhookMixin.ts","../../src/structures/webhooks/Webhook.ts","../../src/util/auditLogs.ts","../../src/managers/GuildEmojiRoleManager.ts","../../src/structures/emojis/GuildEmoji.ts","../../src/structures/guilds/GuildPreview.ts","../../src/structures/guilds/GuildAuditLogsEntry.ts","../../src/structures/guilds/WelcomeScreen.ts","../../src/managers/AutoModerationRuleManager.ts","../../src/structures/guilds/GuildBan.ts","../../src/managers/GuildBanManager.ts","../../src/managers/GuildChannelManager.ts","../../src/managers/GuildIntegrationManager.ts","../../src/managers/GuildScheduledEventManager.ts","../../src/structures/soundboards/SoundboardSound.ts","../../src/managers/GuildSoundboardSoundManager.ts","../../src/managers/StageInstanceManager.ts","../../src/managers/GuildEmojiManager.ts","../../src/managers/GuildInviteManager.ts","../../src/managers/GuildStickerManager.ts","../../src/managers/GuildManager.ts","../../src/managers/GuildMemberRoleManager.ts","../../src/structures/guilds/GuildMember.ts","../../src/structures/presences/RichPresenceAssets.ts","../../src/structures/presences/Activity.ts","../../src/structures/presences/Presence.ts","../../src/structures/voice/VoiceState.ts","../../src/util/errors.ts","../../src/managers/GuildMemberManager.ts","../../src/managers/ReactionUserManager.ts","../../src/structures/messages/MessageReaction.ts","../../src/managers/ReactionManager.ts","../../src/util/equal.ts","../../src/structures/messages/Attachment.ts","../../src/structures/messages/Embed.ts","../../src/structures/messages/MessageMentions.ts","../../src/structures/polls/PollAnswer.ts","../../src/structures/polls/Poll.ts","../../src/structures/messages/Message.ts","../../src/managers/MessageManager.ts","../../src/structures/guilds/Role.ts","../../src/managers/RoleManager.ts","../../src/managers/WebhookManager.ts","../../src/structures/guilds/GuildTemplate.ts","../../src/managers/GuildTemplateManager.ts","../../src/managers/VoiceStateManager.ts","../../src/managers/PresenceManager.ts","../../src/managers/ThreadManager.ts","../../src/structures/channels/ThreadMember.ts","../../src/managers/ThreadMemberManager.ts","../../src/managers/UserManager.ts","../../src/structures/invites/GroupDMInvite.ts","../../src/structures/guilds/Widget.ts","../../src/structures/stickers/StickerPack.ts","../../src/structures/automoderation/AutoModerationActionExecution.ts","../../src/structures/users/ClientUser.ts","../../src/structures/channels/Typing.ts","../../src/util/events.ts","../../src/util/Partials.ts","../../src/util/dispatch.ts","../../src/actions/Action.ts","../../src/util/DispatchQueue.ts","../../src/util/sessions.ts","../../src/GatewayClient.ts","../../src/util/decorators.ts"],"sourcesContent":["import { Listener } from \"@wolfstar/http-framework\";\nimport type { Awaitable } from \"@wolfstar/plugin-cache\";\nimport type { GatewayEventMap, GatewayEventName } from \"./util/events.js\";\n\n/**\n * A {@link Listener} bound to one of the {@link GatewayEventMap} events of the {@link GatewayClient}, with strongly\n * typed arguments. It is loaded from the `listeners` directory by `client.load()` like any other listener.\n *\n * @example\n * ```typescript\n * // listeners/log-messages.ts\n * import { EventGatewayListener, type Message } from '@wolfstar/plugin-gateway';\n *\n * export class LogMessagesListener extends EventGatewayListener<'messageCreate'> {\n * public constructor(context: EventGatewayListener.LoaderContext) {\n * super(context, { event: 'messageCreate' });\n * }\n *\n * public override run(message: Message) {\n * console.log(`${message.author.username}: ${message.content}`);\n * }\n * }\n * ```\n */\nexport abstract class EventGatewayListener<\n Event extends GatewayEventName = GatewayEventName,\n> extends Listener<EventGatewayListener.ResolvedOptions<Event>> {\n /**\n * Whether this listener unloads itself after its first run.\n */\n public readonly once: boolean;\n\n public constructor(\n context: EventGatewayListener.LoaderContext,\n options: EventGatewayListener.Options<Event>,\n ) {\n super(context, { ...options, emitter: \"client\" });\n this.once = options.once ?? false;\n\n if (this.once) {\n // `_listener` is what the framework's loader strategy attaches to the emitter, wrapping it is the only way to\n // unload the piece on its first run while keeping `run` overridable.\n // oxlint-disable-next-line no-underscore-dangle\n const listener = this._listener;\n // oxlint-disable-next-line no-underscore-dangle\n this._listener = async (...args: readonly unknown[]) => {\n await this.unload();\n return listener(...args);\n };\n }\n }\n\n public abstract override run(...args: GatewayEventMap[Event]): Awaitable<unknown>;\n}\n\nexport namespace EventGatewayListener {\n export type LoaderContext = Listener.LoaderContext;\n\n export interface Options<Event extends GatewayEventName = GatewayEventName> extends Omit<\n Listener.Options,\n \"emitter\" | \"event\"\n > {\n /**\n * The event to listen to.\n */\n event: Event;\n /**\n * Whether to unload the listener after its first run.\n *\n * @default false\n */\n once?: boolean;\n }\n\n export interface ResolvedOptions<Event extends GatewayEventName = GatewayEventName>\n extends Listener.Options {\n event: Event;\n once?: boolean;\n }\n}\n","import {\n type OverwriteType,\n PermissionFlagsBits,\n type APIGuildForumDefaultReactionEmoji,\n type APIGuildForumTag,\n type APIOverwrite,\n type ChannelFlags,\n type ChannelType,\n type ForumLayoutType,\n type RESTPatchAPIChannelJSONBody,\n type SortOrderType,\n type ThreadAutoArchiveDuration,\n type VideoQualityMode,\n} from \"discord-api-types/v10\";\nimport {\n PermissionsBitField,\n type PermissionResolvable,\n type PermissionsString,\n} from \"./PermissionsBitField.js\";\n\n/**\n * Something with an ID: a structure, or the ID itself.\n */\nexport type IdResolvable = string | { id: string | null };\n\n/**\n * Gets the ID of an {@link IdResolvable}.\n *\n * @param value The ID, or something with one.\n */\nexport function resolveId(value: IdResolvable): string {\n const id = typeof value === \"string\" ? value : value.id;\n if (!id) throw new TypeError(\"Cannot resolve an ID from a structure without one\");\n return id;\n}\n\n/**\n * A permission overwrite to set on a channel: whom it targets, and what it allows and denies.\n */\nexport interface OverwriteData {\n /**\n * The role or member the overwrite targets.\n */\n id: IdResolvable;\n /**\n * Whether `id` is a role or a member. Required when `id` is a plain ID.\n */\n type: OverwriteType;\n allow?: PermissionResolvable;\n deny?: PermissionResolvable;\n}\n\n/**\n * Permissions to change in an overwrite: `true` allows, `false` denies, `null` falls back to the role or `@everyone`.\n */\nexport type PermissionOverwriteOptions = Partial<Record<PermissionsString, boolean | null>>;\n\n/**\n * Converts an {@link OverwriteData} to the API's shape.\n */\nexport function toAPIOverwrite(overwrite: OverwriteData): APIOverwrite {\n return {\n id: resolveId(overwrite.id),\n type: overwrite.type,\n allow: String(PermissionsBitField.resolve(overwrite.allow ?? 0n)),\n deny: String(PermissionsBitField.resolve(overwrite.deny ?? 0n)),\n };\n}\n\n/**\n * Applies {@link PermissionOverwriteOptions} to an overwrite's allowed and denied permissions.\n *\n * @param options The permissions to change.\n * @param initial The overwrite's current permissions, none by default.\n */\nexport function resolveOverwriteOptions(\n options: PermissionOverwriteOptions,\n initial: { allow?: bigint; deny?: bigint } = {},\n): { allow: bigint; deny: bigint } {\n let allow = initial.allow ?? 0n;\n let deny = initial.deny ?? 0n;\n for (const [name, value] of Object.entries(options)) {\n const bit = PermissionFlagsBits[name as PermissionsString];\n if (value === undefined || bit === undefined) continue;\n allow &= ~bit;\n deny &= ~bit;\n if (value === true) allow |= bit;\n else if (value === false) deny |= bit;\n }\n\n return { allow, deny };\n}\n\n/**\n * A forum tag to set: an existing one (with its ID) or a new one.\n */\nexport type GuildForumTagData = Omit<APIGuildForumTag, \"id\" | \"moderated\"> &\n Partial<Pick<APIGuildForumTag, \"id\" | \"moderated\">>;\n\n/**\n * The fields of a guild channel that can be edited. Each applies to the channel types that have it.\n */\nexport interface GuildChannelEditOptions {\n name?: string;\n /**\n * Converts a text channel to an announcement channel, or back.\n */\n type?: ChannelType.GuildText | ChannelType.GuildAnnouncement;\n position?: number;\n topic?: string | null;\n nsfw?: boolean;\n rateLimitPerUser?: number;\n bitrate?: number;\n userLimit?: number;\n permissionOverwrites?: readonly OverwriteData[];\n /**\n * The category, `null` to move the channel out of its category.\n */\n parent?: IdResolvable | null;\n /**\n * Whether to copy the category's overwrites: the new one with `parent`, else the current one. Exclusive with\n * `permissionOverwrites`.\n */\n lockPermissions?: boolean;\n rtcRegion?: string | null;\n videoQualityMode?: VideoQualityMode;\n defaultAutoArchiveDuration?: ThreadAutoArchiveDuration;\n availableTags?: readonly GuildForumTagData[];\n defaultReactionEmoji?: APIGuildForumDefaultReactionEmoji | null;\n defaultThreadRateLimitPerUser?: number;\n defaultSortOrder?: SortOrderType | null;\n defaultForumLayout?: ForumLayoutType;\n flags?: ChannelFlags;\n /**\n * Whether a thread is archived.\n */\n archived?: boolean;\n /**\n * Whether a thread is locked: only moderators can unarchive it.\n */\n locked?: boolean;\n /**\n * Whether non-moderators can add members to a private thread.\n */\n invitable?: boolean;\n /**\n * The minutes of inactivity after which a thread is archived.\n */\n autoArchiveDuration?: ThreadAutoArchiveDuration;\n /**\n * The IDs of the tags of a thread of a forum or media channel.\n */\n appliedTags?: readonly string[];\n reason?: string;\n}\n\n/**\n * Converts {@link GuildChannelEditOptions} to the API's body, without `lockPermissions` which needs the parent.\n */\nexport function toChannelBody(\n options: GuildChannelEditOptions | GuildChannelCreateOptions,\n): RESTPatchAPIChannelJSONBody {\n const body: Record<string, unknown> = {\n name: options.name,\n type: options.type,\n position: options.position,\n topic: options.topic,\n nsfw: options.nsfw,\n rate_limit_per_user: options.rateLimitPerUser,\n bitrate: options.bitrate,\n user_limit: options.userLimit,\n permission_overwrites: options.permissionOverwrites?.map(toAPIOverwrite),\n parent_id:\n options.parent === undefined\n ? undefined\n : options.parent === null\n ? null\n : resolveId(options.parent),\n rtc_region: options.rtcRegion,\n video_quality_mode: options.videoQualityMode,\n default_auto_archive_duration: options.defaultAutoArchiveDuration,\n available_tags: options.availableTags,\n default_reaction_emoji: options.defaultReactionEmoji,\n default_thread_rate_limit_per_user: options.defaultThreadRateLimitPerUser,\n default_sort_order: options.defaultSortOrder,\n default_forum_layout: options.defaultForumLayout,\n flags: \"flags\" in options ? options.flags : undefined,\n archived: \"archived\" in options ? options.archived : undefined,\n locked: \"locked\" in options ? options.locked : undefined,\n invitable: \"invitable\" in options ? options.invitable : undefined,\n auto_archive_duration:\n \"autoArchiveDuration\" in options ? options.autoArchiveDuration : undefined,\n applied_tags: \"appliedTags\" in options ? options.appliedTags : undefined,\n };\n for (const key of Object.keys(body)) if (body[key] === undefined) delete body[key];\n return body as RESTPatchAPIChannelJSONBody;\n}\n\n/**\n * The options to create a guild channel with.\n */\nexport interface GuildChannelCreateOptions extends Omit<\n GuildChannelEditOptions,\n | \"type\"\n | \"lockPermissions\"\n | \"flags\"\n | \"archived\"\n | \"locked\"\n | \"invitable\"\n | \"autoArchiveDuration\"\n | \"appliedTags\"\n> {\n name: string;\n type?: ChannelType;\n}\n","import type { StructureMixin } from \"./Structure.js\";\n\n/**\n * Any class, abstract or not.\n */\nexport type MixinBase = abstract new (...args: any[]) => object;\n\ntype UnionToIntersection<Union> = (Union extends unknown ? (value: Union) => void : never) extends (\n value: infer Intersection,\n) => void\n ? Intersection\n : never;\n\n/**\n * The members `Mixins` add to a class extending `Base`, for the interface declaring them.\n *\n * @remarks\n * Following `@discordjs/structures`' `MixinTypes`, the members `Base` already declares are left out: `Base` keeps typing\n * them, even though the mixins' implementations win at runtime, which must therefore stay assignable to `Base`'s types.\n * {@link StructureMixin}'s members are left out too: the interface extends it directly, so they keep their `this` type.\n *\n * ```typescript\n * export interface TextChannel\n * extends\n * StructureMixin<ChannelDataType<ChannelType.GuildText>>,\n * MixinTypes<BaseTextChannel, [TextChannelMixin<ChannelType.GuildText>]> {}\n * export class TextChannel extends BaseTextChannel {}\n * Mixin(TextChannel, [TextChannelMixin]);\n * ```\n *\n * @typeParam Base The class the mixins are mixed into.\n * @typeParam Mixins The instance types of the mixins.\n */\nexport type MixinTypes<Base extends object, Mixins extends readonly object[]> = Omit<\n UnionToIntersection<Mixins[number]>,\n keyof Base | keyof StructureMixin<object>\n>;\n\n/**\n * Copies the members of every mixin onto the prototype of `target`, the way `@discordjs/structures`' `Mixin` does.\n *\n * @remarks\n * Prototype members are copied. Static `DataTemplate`, `optimizeData`, and `enrichToJSON` hooks are\n * combined with the target's behavior, following `@discordjs/structures`.\n * Mixins must not rely on their constructor running. Declare an interface with the same name as `target`, extending\n * every mixin, so the members are visible to the type system as well:\n *\n * ```typescript\n * export interface TextChannel extends TextChannelMixin<ChannelType.GuildText> {}\n * export class TextChannel extends Channel<ChannelType.GuildText> {}\n * Mixin(TextChannel, [TextChannelMixin]);\n * ```\n *\n * Members already defined on `target` itself win over the mixins', and earlier mixins win over later ones.\n *\n * @param target The class to mix into.\n * @param mixins The classes whose members are copied.\n */\nexport function Mixin(target: MixinBase, mixins: readonly MixinBase[]): void {\n const prototype = target.prototype as object;\n const optimizations: Array<(this: object, data: object) => void> = [];\n const enrichments: Array<(this: object, data: object) => void> = [];\n const templates: object[] = [];\n const jsonKey = Symbol.for(\"djs.structures.mixin.toJSON\");\n const inheritedOptimization = Reflect.get(prototype, \"optimizeData\") as\n | ((this: object, data: object) => void)\n | undefined;\n if (inheritedOptimization) optimizations.push(inheritedOptimization);\n const inheritedEnrichment = Reflect.get(prototype, jsonKey) as\n | ((this: object, data: object) => void)\n | undefined;\n if (inheritedEnrichment) enrichments.push(inheritedEnrichment);\n\n for (const mixin of mixins) {\n const template = Reflect.get(mixin, \"DataTemplate\") as object | undefined;\n if (template) templates.push(template);\n const optimize = Reflect.get(mixin, \"optimizeData\") as\n | ((this: object, data: object) => void)\n | undefined;\n if (optimize) optimizations.push(optimize);\n const enrich = Reflect.get(mixin, \"enrichToJSON\") as\n | ((this: object, data: object) => void)\n | undefined;\n if (enrich) enrichments.push(enrich);\n for (const key of Reflect.ownKeys(mixin.prototype as object)) {\n if (key === \"constructor\") continue;\n\n const descriptor = Reflect.getOwnPropertyDescriptor(mixin.prototype as object, key)!;\n if (Object.hasOwn(prototype, key)) continue;\n Reflect.defineProperty(prototype, key, descriptor);\n }\n }\n\n if (optimizations.length > 1) {\n Reflect.defineProperty(prototype, \"optimizeData\", {\n configurable: true,\n value(this: object, data: object) {\n for (const optimize of optimizations) optimize.call(this, data);\n },\n });\n }\n\n if (templates.length > 0) {\n const base = Reflect.get(target, \"DataTemplate\") as object | undefined;\n const template = Object.defineProperties({}, Object.getOwnPropertyDescriptors(base ?? {}));\n for (const addition of templates) {\n Object.defineProperties(template, Object.getOwnPropertyDescriptors(addition));\n }\n Reflect.defineProperty(target, \"DataTemplate\", {\n configurable: true,\n value: template,\n });\n }\n\n if (enrichments.length > 0) {\n Reflect.defineProperty(prototype, jsonKey, {\n configurable: true,\n value(this: object, data: object) {\n for (const enrich of enrichments) enrich.call(this, data);\n },\n });\n }\n}\n","import { container } from \"@wolfstar/http-framework\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\n\n/**\n * Gets the {@link GatewayClient} registered in the framework's container.\n *\n * @remarks\n * The framework's `Client` registers itself as `container.client` on construction, so this is the most recently\n * constructed `GatewayClient`. It throws when that client is a plain `Client`.\n */\nexport function getGatewayClient(): GatewayClient {\n const { client } = container;\n if (!client || !(\"gateway\" in client)) {\n throw new Error(\"No GatewayClient has been constructed yet\");\n }\n\n return client as GatewayClient;\n}\n\ndeclare module \"@sapphire/pieces\" {\n interface Container {\n /**\n * The most recently constructed {@link GatewayClient}, which registers itself here on construction next to\n * `container.client`, so pieces reach its managers without {@link getGatewayClient} or a cast.\n *\n * @remarks\n * `container.client` keeps the framework's `Client` type: a module augmentation cannot redeclare a property with\n * another type (TS2717), and under `skipLibCheck` the framework's declaration silently wins.\n */\n gatewayClient: GatewayClient;\n }\n}\n","import { Structure as BaseStructure } from \"@discordjs/structures\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport { Mixin } from \"./Mixin.js\";\n\n// `@discordjs/structures` keys a structure's data and its patch/clone methods with symbols it does not export. They\n// are created with `Symbol.for`, in the global registry, so the same key yields the very same symbols here. Each is\n// typed as a `unique symbol` of our own, which lets the structures declare typed members keyed by them.\n\n/**\n * The symbol under which a {@link Structure} stores its raw API data, shared with `@discordjs/structures`.\n */\nexport const kData: unique symbol = Symbol.for(\"djs.structures.data\") as never;\n\n/**\n * The symbol of the method patching a {@link Structure}'s raw data in place, shared with `@discordjs/structures`.\n */\nexport const kPatch: unique symbol = Symbol.for(\"djs.structures.patch\") as never;\n\n/**\n * The symbol of the method cloning a {@link Structure}, shared with `@discordjs/structures`.\n */\nexport const kClone: unique symbol = Symbol.for(\"djs.structures.clone\") as never;\n\n/**\n * The symbol under which a {@link Structure} stores its relations: the structures its manager resolved from the cache,\n * like a message's author or a channel's guild.\n */\nexport const kRelations: unique symbol = Symbol.for(\"wolfstar.structures.relations\") as never;\n\n/**\n * The symbol under which a {@link Structure} stores the client that built it, see {@link StructureMixin.client}.\n */\nexport const kClient: unique symbol = Symbol.for(\"wolfstar.structures.client\") as never;\n\n/**\n * The symbol of the optional method a mixin defines to drop the relations a patch invalidates, called by\n * {@link StructureMixin}'s patch before the data is patched. Mixins cannot override the patch itself: the first mixin\n * defining a member wins, and {@link StructureMixin} comes first.\n *\n * @internal\n */\nexport const kPatchRelations: unique symbol = Symbol.for(\n \"wolfstar.structures.patchRelations\",\n) as never;\n\n/**\n * The Discord epoch, used to extract timestamps from snowflakes.\n */\nconst DiscordEpoch = 1_420_070_400_000n;\n\ntype Patch<Data> = (this: object, data: Readonly<Partial<Data>>) => unknown;\n\nconst kTimestamps: unique symbol = Symbol(\"wolfstar.structures.timestamps\") as never;\n\n/**\n * The members every structure of this package has on top of `@discordjs/structures`' own: relations resolved from the\n * cache, public patch/clone methods, and parsed timestamps.\n *\n * @remarks\n * It is mixed into {@link Structure} and into every class extending one of `@discordjs/structures`' structures, which\n * also have to call {@link initStructure} from their constructor:\n *\n * ```typescript\n * export interface User extends StructureMixin<APIUser> {}\n * export class User extends BaseUser {\n * public constructor(data: Partial<APIUser>, relations: object = {}) {\n * super(data);\n * initStructure(this, data, relations);\n * }\n * }\n * Mixin(User, [StructureMixin]);\n * ```\n *\n * @typeParam Data The raw API data the structure wraps.\n * @typeParam Relations The relations of the structure, resolved from the cache by its manager.\n */\nexport class StructureMixin<Data extends object, Relations extends object = object> {\n /**\n * The raw API data of this structure.\n */\n declare protected [kData]: Readonly<Data>;\n\n /**\n * The relations of this structure, resolved from the cache by its manager. Public only so that\n * {@link StructureMixin.dropRelations} can check relation names against it.\n *\n * @internal\n */\n declare public [kRelations]: Relations;\n\n declare private [kTimestamps]?: Map<string, number | null>;\n\n /**\n * The client that built this structure, set by its manager.\n *\n * @internal\n */\n declare public [kClient]?: GatewayClient;\n\n /**\n * The client that instantiated this structure, like discord.js's `Base#client`: the one whose manager built it, or\n * the most recently constructed {@link GatewayClient} for structures built by hand from a raw payload.\n *\n * @remarks\n * It is not part of the structure's data, so it is neither serialized by `toJSON` nor stored in the cache.\n */\n public get client(): GatewayClient {\n return this[kClient] ?? getGatewayClient();\n }\n\n /**\n * Patches the raw data of this structure in place, with a shallow merge.\n *\n * @param data The updated data.\n * @returns This structure.\n */\n public [kPatch](data: Readonly<Partial<Data>>): this {\n (this as { [kPatchRelations]?: (data: object) => void })[kPatchRelations]?.(data);\n (BaseStructure.prototype as unknown as Record<typeof kPatch, Patch<Data>>)[kPatch].call(\n this,\n data,\n );\n return this;\n }\n\n /**\n * Creates a copy of this structure, optionally patching the copy.\n *\n * @param patch The data to patch the copy with.\n * @returns The copy.\n */\n public [kClone](patch?: Readonly<Partial<Data>>): this {\n const clone = (BaseStructure.prototype as unknown as Record<typeof kClone, Patch<Data>>)[\n kClone\n ].call(this, patch ?? ({} as Readonly<Partial<Data>>)) as this;\n clone[kRelations] = { ...this[kRelations] };\n if (this[kClient]) clone[kClient] = this[kClient];\n return clone;\n }\n\n /** Parses a timestamp once when constructing or patching a structure. */\n protected optimizeTimestamp(key: string, value: string | null | undefined): void {\n if (value !== undefined) {\n (this[kTimestamps] ??= new Map()).set(key, value ? Date.parse(value) : null);\n }\n }\n\n /** Gets a timestamp previously parsed by `optimizeData`. */\n protected optimizedTimestamp(key: string): number | null {\n return this[kTimestamps]?.get(key) ?? null;\n }\n\n /**\n * Forgets resolved relations, e.g. when a patch carries fresher data for them.\n *\n * @param names The names of the relations.\n */\n protected dropRelations(...names: (keyof this[typeof kRelations] & string)[]): void {\n const relations: Record<string, unknown> = { ...(this[kRelations] as object) };\n for (const name of names) delete relations[name];\n this[kRelations] = relations as Relations;\n }\n\n /**\n * Forgets the relations whose ID a patch changes, e.g. a channel's parent when the patch moves it to another\n * category. A patch carrying the same ID keeps the relation.\n *\n * @param data The patch.\n * @param fields The names of the relations, mapped to the raw field holding their ID.\n */\n protected dropChangedRelations(\n data: object,\n fields: Partial<Record<keyof Relations & string, string>>,\n ): void {\n const current = this[kData] as Record<string, unknown>;\n const patch = data as Record<string, unknown>;\n const names = Object.entries(fields as Record<string, string>)\n .filter(([, key]) => key in patch && patch[key] !== current[key])\n .map(([name]) => name);\n if (names.length > 0) this.dropRelations(...(names as never[]));\n }\n}\n\n/**\n * Sets up the members {@link StructureMixin} adds, from the constructor of a structure extending one of\n * `@discordjs/structures`'.\n *\n * @param structure The structure being constructed.\n * @param data The raw API data it was constructed with.\n * @param relations The related structures, resolved from the cache by the structure's manager.\n */\nexport function initStructure(structure: object, data: object, relations: object): void {\n (structure as StructureMixin<object>)[kRelations] = relations;\n // `@discordjs/structures` only runs `optimizeData` from the constructors of the classes implementing it, which the\n // mixins' optimizations are not part of. Running it again is harmless: it only (re)parses fields.\n (structure as unknown as { optimizeData(data: object): void }).optimizeData(data);\n}\n\nexport interface Structure<\n Data extends object,\n Omitted extends keyof Data | \"\" = \"\",\n> extends StructureMixin<Data> {}\n\n/**\n * The base class of the structures `@discordjs/structures` has no counterpart for: its `Structure`, with\n * {@link StructureMixin} mixed in.\n *\n * @remarks\n * Structures can be built from any raw payload, be it a gateway dispatch, a cache hit, or a REST response. Their\n * {@link StructureMixin.client | client} is the one whose manager built them, the most recently constructed one\n * otherwise.\n *\n * @typeParam Data The raw API data this structure wraps.\n * @typeParam Omitted The keys the structure's `DataTemplate` strips from the stored data.\n */\nexport abstract class Structure<\n Data extends object,\n Omitted extends keyof Data | \"\" = \"\",\n> extends BaseStructure<Data, Omitted> {\n /**\n * @param data The raw API data.\n * @param relations The related structures, resolved from the cache by the structure's manager.\n */\n public constructor(data: Readonly<Partial<Data>>, relations: object = {}) {\n super(data as never);\n initStructure(this, data, relations);\n }\n}\n\nMixin(Structure, [StructureMixin]);\n\n/**\n * Binds a structure to the client that built it, see {@link StructureMixin.client}.\n *\n * @param structure The structure.\n * @param client The client.\n * @returns The structure.\n * @internal\n */\nexport function bindClient<Value extends object>(structure: Value, client: GatewayClient): Value {\n (structure as StructureMixin<object>)[kClient] = client;\n return structure;\n}\n\n/**\n * Gets the timestamp, in milliseconds, a snowflake was created at.\n *\n * @param id The snowflake.\n */\nexport function snowflakeTimestamp(id: string): number {\n return Number((BigInt(id) >> 22n) + DiscordEpoch);\n}\n","import {\n ActivityFlagsBitField as BaseActivityFlagsBitField,\n AttachmentFlagsBitField as BaseAttachmentFlagsBitField,\n BitField,\n ChannelFlagsBitField as BaseChannelFlagsBitField,\n MessageFlagsBitField as BaseMessageFlagsBitField,\n type BitFieldResolvable,\n} from \"@discordjs/structures\";\nimport {\n GatewayIntentBits,\n GuildMemberFlags,\n GuildSystemChannelFlags,\n RoleFlags,\n UserFlags,\n type ActivityFlags,\n type AttachmentFlags,\n type ChannelFlags,\n type MessageFlags,\n} from \"discord-api-types/v10\";\n\n// `@discordjs/structures`' `BitField.resolve` returns a flag's enum value as is, which is a `number` for the 32-bit\n// flag enums: combining it with the `bigint` bits then throws \"Cannot mix BigInt and other types\". Every flags bitfield\n// below overrides `resolve` to always return a `bigint`, including the ones `@discordjs/structures` ships.\n\n/**\n * A 32-bit flags bitfield, resolving flag names to `bigint`s and serializing to a `number`.\n */\nexport abstract class NumberFlagsBitField<Flags extends string> extends BitField<Flags> {\n public static override resolve<Flags extends string = string>(\n bit: BitFieldResolvable<Flags>,\n ): bigint {\n return BigInt(super.resolve(bit));\n }\n\n public override toJSON(): number {\n return super.toJSON(true) as number;\n }\n}\n\nexport type ActivityFlagsString = keyof typeof ActivityFlags;\nexport type ActivityFlagsResolvable = BitFieldResolvable<ActivityFlagsString>;\n\n/**\n * The flags of a presence activity.\n */\nexport class ActivityFlagsBitField extends BaseActivityFlagsBitField {\n public static override resolve<Flags extends string = string>(\n bit: BitFieldResolvable<Flags>,\n ): bigint {\n return BigInt(super.resolve(bit));\n }\n}\n\nexport type AttachmentFlagsString = keyof typeof AttachmentFlags;\nexport type AttachmentFlagsResolvable = BitFieldResolvable<AttachmentFlagsString>;\n\n/**\n * The flags of a message attachment.\n */\nexport class AttachmentFlagsBitField extends BaseAttachmentFlagsBitField {\n public static override resolve<Flags extends string = string>(\n bit: BitFieldResolvable<Flags>,\n ): bigint {\n return BigInt(super.resolve(bit));\n }\n}\n\nexport type ChannelFlagsString = keyof typeof ChannelFlags;\nexport type ChannelFlagsResolvable = BitFieldResolvable<ChannelFlagsString>;\n\n/**\n * The flags of a channel.\n */\nexport class ChannelFlagsBitField extends BaseChannelFlagsBitField {\n public static override resolve<Flags extends string = string>(\n bit: BitFieldResolvable<Flags>,\n ): bigint {\n return BigInt(super.resolve(bit));\n }\n}\n\nexport type MessageFlagsString = keyof typeof MessageFlags;\nexport type MessageFlagsResolvable = BitFieldResolvable<MessageFlagsString>;\n\n/**\n * The flags of a message.\n */\nexport class MessageFlagsBitField extends BaseMessageFlagsBitField {\n public static override resolve<Flags extends string = string>(\n bit: BitFieldResolvable<Flags>,\n ): bigint {\n return BigInt(super.resolve(bit));\n }\n}\n\nexport type GuildMemberFlagsString = keyof typeof GuildMemberFlags;\nexport type GuildMemberFlagsResolvable = BitFieldResolvable<GuildMemberFlagsString>;\n\n/**\n * The flags of a guild member.\n */\nexport class GuildMemberFlagsBitField extends NumberFlagsBitField<GuildMemberFlagsString> {\n public static override readonly Flags = GuildMemberFlags;\n}\n\nexport type IntentsString = keyof typeof GatewayIntentBits;\nexport type IntentsResolvable = BitFieldResolvable<IntentsString>;\n\n/**\n * The gateway intents to identify with.\n */\nexport class IntentsBitField extends NumberFlagsBitField<IntentsString> {\n public static override readonly Flags = GatewayIntentBits;\n}\n\nexport type RoleFlagsString = keyof typeof RoleFlags;\nexport type RoleFlagsResolvable = BitFieldResolvable<RoleFlagsString>;\n\n/**\n * The flags of a role.\n */\nexport class RoleFlagsBitField extends NumberFlagsBitField<RoleFlagsString> {\n public static override readonly Flags = RoleFlags;\n}\n\nexport type SystemChannelFlagsString = keyof typeof GuildSystemChannelFlags;\nexport type SystemChannelFlagsResolvable = BitFieldResolvable<SystemChannelFlagsString>;\n\n/**\n * The flags of a guild's system channel, deciding which system messages are suppressed.\n */\nexport class SystemChannelFlagsBitField extends NumberFlagsBitField<SystemChannelFlagsString> {\n public static override readonly Flags = GuildSystemChannelFlags;\n}\n\nexport type UserFlagsString = keyof typeof UserFlags;\nexport type UserFlagsResolvable = BitFieldResolvable<UserFlagsString>;\n\n/**\n * The flags (badges) of a user.\n */\nexport class UserFlagsBitField extends NumberFlagsBitField<UserFlagsString> {\n public static override readonly Flags = UserFlags;\n}\n","import type { Channel as BaseChannelStructure } from \"@discordjs/structures\";\nimport { type ChannelType } from \"discord-api-types/v10\";\nimport { ChannelFlagsBitField } from \"../../../util/flags.js\";\nimport type { ChannelDataType, ChannelRelations } from \"../Channel.js\";\nimport {\n kData,\n kPatch,\n kPatchRelations,\n snowflakeTimestamp,\n type StructureMixin,\n} from \"../../Structure.js\";\n\nexport interface BaseChannelMixin<Type extends ChannelType = ChannelType>\n extends BaseChannelStructure<Type>, StructureMixin<ChannelDataType<Type>, ChannelRelations> {}\n\n/**\n * Adds what every channel shares on top of `@discordjs/structures`' `Channel`: its relations, and the REST actions\n * every channel supports.\n */\nexport class BaseChannelMixin<Type extends ChannelType = ChannelType> {\n /**\n * Forgets the parent when a patch moves the channel.\n *\n * @internal\n */\n public [kPatchRelations](data: object): void {\n this.dropChangedRelations(data, { parent: \"parent_id\" });\n }\n\n /**\n * Whether the channel is partial, like discord.js's `BaseChannel#partial`: only direct messages can be, see\n * `Partials.Channel`.\n */\n public get partial(): boolean {\n return false;\n }\n\n /**\n * The flags of the channel.\n */\n public get flags(): Readonly<ChannelFlagsBitField> {\n return new ChannelFlagsBitField(this[kData].flags ?? 0).freeze();\n }\n\n public get createdTimestamp(): number {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt(): Date {\n return new Date(this.createdTimestamp);\n }\n\n public toString(): `<#${string}>` {\n return `<#${this.id}>`;\n }\n\n /**\n * Deletes the channel, or closes it for a direct message, and drops it from the cache.\n *\n * @param reason The reason for the audit log.\n */\n public async delete(reason?: string): Promise<this> {\n await this.client.channels.delete(this.id, reason);\n return this;\n }\n\n /**\n * Fetches the channel from the API and patches this structure with the result.\n */\n public async fetch(): Promise<this> {\n const data = await this.client.api.channels.get(this.id);\n if (data.type !== this.type) {\n throw new TypeError(`Channel ${this.id} changed type from ${this.type} to ${data.type}`);\n }\n\n return this[kPatch](data as ChannelDataType<Type>);\n }\n}\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../../../managers/ChannelManager.js\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData, kRelations } from \"../../Structure.js\";\n\ntype Data = { parent_id?: string | null; nsfw?: boolean };\n\nexport interface ChannelParentMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the parent (a category, or a channel for threads) and the age restriction of guild channels.\n */\nexport class ChannelParentMixin<Type extends ChannelType = ChannelType> {\n public get parentId(): string | null {\n return (this[kData] as Data).parent_id ?? null;\n }\n\n /**\n * The parent of the channel, from the cache, like discord.js's `parent`: the category of a guild channel, or the\n * channel a thread belongs to. `null` when it has none, when it is not cached, or when the channel was not built by\n * a manager.\n */\n public get parent(): AnyChannel | null {\n return this[kRelations].parent ?? null;\n }\n\n public get nsfw(): boolean {\n return (this[kData] as Data).nsfw ?? false;\n }\n}\n","import type { APIOverwrite } from \"discord-api-types/v10\";\nimport type { PermissionOverwriteOptions } from \"../../util/channels.js\";\nimport { PermissionsBitField } from \"../../util/PermissionsBitField.js\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport { kData, kPatch, kRelations, Structure } from \"../Structure.js\";\n\n/**\n * The relations of a {@link PermissionOverwrites}: the channel it belongs to.\n */\nexport interface PermissionOverwritesRelations {\n channel?: AnyChannel | null;\n}\n\n/**\n * The raw data of a permission overwrite, with the channel it belongs to.\n */\nexport type PermissionOverwritesData = APIOverwrite & { channel_id: string };\nconst kOptimizedAllow: unique symbol = Symbol(\"overwrite.allow\");\nconst kOptimizedDeny: unique symbol = Symbol(\"overwrite.deny\");\n\n/**\n * A permission overwrite of a channel: what it allows and denies to a role or a member.\n */\nexport class PermissionOverwrites extends Structure<PermissionOverwritesData> {\n declare public [kRelations]: PermissionOverwritesRelations;\n\n declare protected [kOptimizedAllow]: bigint;\n declare protected [kOptimizedDeny]: bigint;\n\n protected override optimizeData(data: Partial<PermissionOverwritesData>): void {\n if (data.allow !== undefined) this[kOptimizedAllow] = BigInt(data.allow);\n if (data.deny !== undefined) this[kOptimizedDeny] = BigInt(data.deny);\n }\n\n /**\n * The ID of the role or member the overwrite targets.\n */\n public get id() {\n return this[kData].id;\n }\n\n public get channelId() {\n return this[kData].channel_id;\n }\n\n /**\n * The channel the overwrite belongs to, like discord.js's `PermissionOverwrites#channel`: `null` when the overwrite\n * was not read from a channel.\n */\n public get channel(): AnyChannel | null {\n return this[kRelations].channel ?? null;\n }\n\n /**\n * Whether the overwrite targets a role or a member.\n */\n public get type() {\n return this[kData].type;\n }\n\n public get allow(): Readonly<PermissionsBitField> {\n return new PermissionsBitField(this[kOptimizedAllow] ?? 0n).freeze();\n }\n\n public get deny(): Readonly<PermissionsBitField> {\n return new PermissionsBitField(this[kOptimizedDeny] ?? 0n).freeze();\n }\n\n /**\n * Changes some permissions of the overwrite, keeping the others.\n *\n * @param options The permissions to change.\n * @param reason The reason for the audit log.\n */\n public async edit(options: PermissionOverwriteOptions, reason?: string): Promise<this> {\n const overwrites = await this.client.channels.permissionOverwrites(this.channelId);\n const edited = await overwrites.edit(this.id, options, { type: this.type, reason });\n return this[kPatch](edited.toJSON());\n }\n\n /**\n * Deletes the overwrite.\n *\n * @param reason The reason for the audit log.\n */\n public async delete(reason?: string): Promise<this> {\n const overwrites = await this.client.channels.permissionOverwrites(this.channelId);\n await overwrites.delete(this.id, reason);\n return this;\n }\n}\n","import { OverwriteType, type APIOverwrite } from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { bindClient } from \"../structures/Structure.js\";\nimport type { AnyChannel } from \"./ChannelManager.js\";\nimport { PermissionOverwrites } from \"../structures/channels/PermissionOverwrites.js\";\nimport {\n resolveId,\n resolveOverwriteOptions,\n type IdResolvable,\n type OverwriteData,\n type PermissionOverwriteOptions,\n} from \"../util/channels.js\";\n\n/**\n * The options of {@link PermissionOverwriteManager.create} and {@link PermissionOverwriteManager.edit}.\n */\nexport interface PermissionOverwriteEditOptions {\n /**\n * Whether the target is a role or a member. Guessed from the cache when absent: a cached role of the guild with\n * that ID makes it a role, anything else a member.\n */\n type?: OverwriteType;\n reason?: string;\n}\n\n/**\n * Manages the permission overwrites of one channel, as they were in the channel's payload.\n */\nexport class PermissionOverwriteManager {\n public readonly client: GatewayClient;\n public readonly channelId: string;\n public readonly guildId: string | null;\n\n readonly #overwrites: readonly APIOverwrite[];\n\n readonly #channel: AnyChannel | null;\n\n /**\n * @param client The client.\n * @param channelId The ID of the channel.\n * @param guildId The ID of the channel's guild, if known.\n * @param overwrites The raw overwrites of the channel.\n * @param channel The channel, which the overwrites refer to.\n */\n public constructor(\n client: GatewayClient,\n channelId: string,\n guildId: string | null,\n overwrites: readonly APIOverwrite[],\n channel: AnyChannel | null = null,\n ) {\n this.client = client;\n this.channelId = channelId;\n this.guildId = guildId;\n this.#overwrites = overwrites;\n this.#channel = channel;\n }\n\n /**\n * The overwrites of the channel.\n */\n public get cache(): PermissionOverwrites[] {\n return this.#overwrites.map((overwrite) =>\n bindClient(\n new PermissionOverwrites(\n { ...overwrite, channel_id: this.channelId },\n { channel: this.#channel },\n ),\n this.client,\n ),\n );\n }\n\n /**\n * Finds the overwrite of a role or member, if the channel has one.\n *\n * @param target The role or member, or its ID.\n */\n public resolve(target: IdResolvable): PermissionOverwrites | null {\n const id = resolveId(target);\n return this.cache.find((overwrite) => overwrite.id === id) ?? null;\n }\n\n /**\n * Replaces every overwrite of the channel.\n *\n * @param overwrites The new overwrites.\n * @param reason The reason for the audit log.\n */\n public async set(overwrites: readonly OverwriteData[], reason?: string): Promise<void> {\n await this.client.channels.edit(this.channelId, { permissionOverwrites: overwrites, reason });\n }\n\n /**\n * Creates the overwrite of a role or member, replacing any existing one.\n *\n * @param target The role or member, or its ID.\n * @param options The permissions to allow (`true`) or deny (`false`).\n * @param editOptions The target's type and the reason for the audit log.\n */\n public create(\n target: IdResolvable,\n options: PermissionOverwriteOptions,\n editOptions: PermissionOverwriteEditOptions = {},\n ): Promise<PermissionOverwrites> {\n return this.upsert(target, options, editOptions, false);\n }\n\n /**\n * Changes some permissions of the overwrite of a role or member, creating it if needed.\n *\n * @param target The role or member, or its ID.\n * @param options The permissions to allow (`true`), deny (`false`), or reset (`null`).\n * @param editOptions The target's type and the reason for the audit log.\n */\n public edit(\n target: IdResolvable,\n options: PermissionOverwriteOptions,\n editOptions: PermissionOverwriteEditOptions = {},\n ): Promise<PermissionOverwrites> {\n return this.upsert(target, options, editOptions, true);\n }\n\n /**\n * Deletes the overwrite of a role or member.\n *\n * @param target The role or member, or its ID.\n * @param reason The reason for the audit log.\n */\n public async delete(target: IdResolvable, reason?: string): Promise<void> {\n const id = resolveId(target);\n await this.client.api.channels.deletePermissionOverwrite(this.channelId, id, { reason });\n await this.patchCached((overwrites) => overwrites.filter((overwrite) => overwrite.id !== id));\n }\n\n private async upsert(\n target: IdResolvable,\n options: PermissionOverwriteOptions,\n editOptions: PermissionOverwriteEditOptions,\n keepExisting: boolean,\n ): Promise<PermissionOverwrites> {\n const id = resolveId(target);\n const existing = keepExisting ? this.resolve(id) : null;\n const type = editOptions.type ?? existing?.type ?? (await this.guessType(target, id));\n const { allow, deny } = resolveOverwriteOptions(options, {\n allow: existing?.allow.bitField,\n deny: existing?.deny.bitField,\n });\n\n const overwrite: APIOverwrite = { id, type, allow: String(allow), deny: String(deny) };\n await this.client.api.channels.editPermissionOverwrite(\n this.channelId,\n id,\n {\n type,\n allow: overwrite.allow,\n deny: overwrite.deny,\n },\n {\n reason: editOptions.reason,\n },\n );\n await this.patchCached((overwrites) => [\n ...overwrites.filter((current) => current.id !== id),\n overwrite,\n ]);\n return new PermissionOverwrites({ ...overwrite, channel_id: this.channelId });\n }\n\n private async guessType(target: IdResolvable, id: string): Promise<OverwriteType> {\n if (typeof target !== \"string\") {\n // Roles have a `hoist` flag, members and users do not.\n return \"hoist\" in target ? OverwriteType.Role : OverwriteType.Member;\n }\n\n if (id === this.guildId || !this.guildId) return OverwriteType.Role;\n // With a roles cache, an uncached ID is a member's; without one, only the guild's roles tell.\n if (this.client.roles.cache) {\n return (await this.client.roles.get(this.guildId, id))\n ? OverwriteType.Role\n : OverwriteType.Member;\n }\n\n const roles = await this.client.roles.fetchAll(this.guildId);\n return roles.some((role) => role.id === id) ? OverwriteType.Role : OverwriteType.Member;\n }\n\n // The overwrite endpoints answer 204 without the channel, so the cached entry is patched instead of refetched.\n private async patchCached(\n update: (overwrites: readonly APIOverwrite[]) => APIOverwrite[],\n ): Promise<void> {\n const cache = this.client.cache?.channels;\n const cached = await cache?.get(this.channelId);\n if (!cached || !(\"permission_overwrites\" in cached)) return;\n await cache!.set(this.channelId, {\n ...cached,\n permission_overwrites: update(cached.permission_overwrites ?? []),\n } as typeof cached);\n }\n}\n","import {\n OverwriteType,\n PermissionFlagsBits,\n type APIOverwrite,\n type APIRole,\n type Snowflake,\n} from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../managers/ChannelManager.js\";\nimport type { GuildMember } from \"../structures/guilds/GuildMember.js\";\nimport type { Role } from \"../structures/guilds/Role.js\";\nimport { getGatewayClient } from \"./container.js\";\nimport { PermissionsBitField } from \"./PermissionsBitField.js\";\n\n/**\n * What {@link computeGuildPermissions} needs to know about a member of a guild.\n */\nexport interface GuildPermissionsContext {\n guildId: Snowflake;\n ownerId: Snowflake;\n userId: Snowflake;\n /**\n * The IDs of the member's roles, without `@everyone`.\n */\n memberRoleIds: readonly Snowflake[];\n /**\n * Every role of the guild, `@everyone` (whose ID is the guild's) included.\n */\n roles: readonly Pick<APIRole, \"id\" | \"permissions\">[];\n}\n\n/**\n * Computes a member's guild-wide permissions, the way Discord does before channel overwrites apply: the owner and\n * administrators get every permission, everyone else gets `@everyone`'s permissions combined with their roles'.\n *\n * @param context The member and the guild's roles.\n */\nexport function computeGuildPermissions(context: GuildPermissionsContext): PermissionsBitField {\n if (context.userId === context.ownerId) {\n return new PermissionsBitField(PermissionsBitField.All).freeze();\n }\n\n const granted = new Set([context.guildId, ...context.memberRoleIds]);\n let bits = 0n;\n for (const role of context.roles) {\n if (granted.has(role.id)) bits |= BigInt(role.permissions);\n }\n\n if ((bits & PermissionFlagsBits.Administrator) === PermissionFlagsBits.Administrator) {\n bits = PermissionsBitField.All;\n }\n\n return new PermissionsBitField(bits).freeze();\n}\n\n/**\n * Compares two roles the way Discord orders them: by position, then by ID for equal positions (older first).\n *\n * @returns A negative number when `a` is lower than `b`, a positive one when it is higher, `0` when they are the same.\n */\nexport function compareRolePositions(\n a: Pick<APIRole, \"id\" | \"position\">,\n b: Pick<APIRole, \"id\" | \"position\">,\n): number {\n if (a.position !== b.position) return a.position - b.position;\n // Among equal positions, the older (lower ID) role is the higher one.\n return Number(BigInt(b.id) - BigInt(a.id));\n}\n\n/**\n * What {@link computeChannelPermissions} needs to know about a channel and whom the permissions are for.\n */\nexport interface ChannelPermissionsContext {\n guildId: Snowflake;\n /**\n * The ID of the member, whose own overwrite applies last. Absent when computing a role's permissions.\n */\n userId?: Snowflake;\n /**\n * The IDs of the roles whose overwrites apply, without `@everyone`.\n */\n roleIds: readonly Snowflake[];\n overwrites: readonly APIOverwrite[];\n}\n\n/**\n * Applies a channel's permission overwrites to guild-wide permissions, the way Discord does: administrators keep\n * every permission, then the `@everyone` overwrite applies, then the roles' overwrites (combined), then the member's.\n *\n * @param base The guild-wide permissions, from {@link computeGuildPermissions}.\n * @param context The channel's overwrites, and the member or role.\n */\nexport function computeChannelPermissions(\n base: Readonly<PermissionsBitField>,\n context: ChannelPermissionsContext,\n): PermissionsBitField {\n if (base.has(PermissionFlagsBits.Administrator)) {\n return new PermissionsBitField(PermissionsBitField.All).freeze();\n }\n\n let bits = base.bitField;\n const apply = (allow: bigint, deny: bigint) => {\n bits = (bits & ~deny) | allow;\n };\n\n const everyone = context.overwrites.find((overwrite) => overwrite.id === context.guildId);\n if (everyone) apply(BigInt(everyone.allow), BigInt(everyone.deny));\n\n let allow = 0n;\n let deny = 0n;\n for (const overwrite of context.overwrites) {\n if (overwrite.type === OverwriteType.Role && context.roleIds.includes(overwrite.id)) {\n allow |= BigInt(overwrite.allow);\n deny |= BigInt(overwrite.deny);\n }\n }\n apply(allow, deny);\n\n const member = context.userId\n ? context.overwrites.find(\n (overwrite) => overwrite.type === OverwriteType.Member && overwrite.id === context.userId,\n )\n : undefined;\n if (member) apply(BigInt(member.allow), BigInt(member.deny));\n\n return new PermissionsBitField(bits).freeze();\n}\n\n/**\n * Computes the permissions of a member or role in a channel, given the channel's overwrites.\n *\n * @param guildId The ID of the channel's guild.\n * @param overwrites The channel's permission overwrites.\n * @param target A member, a role, or the ID of a member.\n */\nexport async function computeTargetPermissions(\n guildId: Snowflake,\n overwrites: readonly APIOverwrite[],\n target: GuildMember | Role | Snowflake,\n): Promise<PermissionsBitField> {\n const client = getGatewayClient();\n if (typeof target !== \"string\" && \"hoist\" in target) {\n // A role gets `@everyone`'s permissions and its own, then the `@everyone` and role overwrites.\n const everyone = await client.roles.everyone(guildId);\n const base = new PermissionsBitField(\n target.permissions.bitField | everyone.permissions.bitField,\n );\n if (base.has(PermissionFlagsBits.Administrator)) {\n return new PermissionsBitField(PermissionsBitField.All).freeze();\n }\n\n return computeChannelPermissions(base, { guildId, roleIds: [target.id], overwrites });\n }\n\n const member = typeof target === \"string\" ? await client.members.fetch(guildId, target) : target;\n return computeChannelPermissions(await member.fetchPermissions(), {\n guildId,\n userId: member.id ?? undefined,\n roleIds: member.roleIds,\n overwrites,\n });\n}\n\n/**\n * Computes the permissions of a member or role in a channel, fetching the channel if needed. Threads use their parent\n * channel's overwrites, like Discord does.\n *\n * @param channel The channel, or its ID.\n * @param target A member, a role, or the ID of a member.\n */\nexport async function computePermissionsIn(\n channel: AnyChannel | Snowflake,\n target: GuildMember | Role | Snowflake,\n): Promise<PermissionsBitField> {\n const client = getGatewayClient();\n let resolved = typeof channel === \"string\" ? await client.channels.fetch(channel) : channel;\n let data = resolved.toJSON() as OverwriteHolder;\n if (resolved.isThread() && data.parent_id) {\n resolved = await client.channels.fetch(data.parent_id);\n data = resolved.toJSON() as OverwriteHolder;\n }\n\n if (!data.guild_id) throw new Error(`Channel ${resolved.id} has no known guild`);\n return computeTargetPermissions(data.guild_id, data.permission_overwrites ?? [], target);\n}\n\ntype OverwriteHolder = {\n guild_id?: string;\n parent_id?: string | null;\n permission_overwrites?: APIOverwrite[];\n};\n","import type { GuildChannelEditOptions } from \"../../../util/channels.js\";\nimport { kPatch, type StructureMixin } from \"../../Structure.js\";\n\n/**\n * Edits a channel through `client.channels` and patches the structure with the result. Shared by the mixins' setters.\n *\n * @param channel The channel structure.\n * @param options The fields to edit.\n */\nexport async function editChannel<Value extends StructureMixin<object> & { id: string }>(\n channel: Value,\n options: GuildChannelEditOptions,\n): Promise<Value> {\n const edited = await channel.client.channels.edit(channel.id, options);\n return channel[kPatch](edited.toJSON() as never);\n}\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData, kPatch, kRelations } from \"../../Structure.js\";\nimport type { APIOverwrite } from \"discord-api-types/v10\";\nimport { PermissionOverwriteManager } from \"../../../managers/PermissionOverwriteManager.js\";\nimport type { IdResolvable } from \"../../../util/channels.js\";\nimport { computeTargetPermissions } from \"../../../util/permissions.js\";\nimport type { PermissionsBitField } from \"../../../util/PermissionsBitField.js\";\nimport type { GuildMember } from \"../../guilds/GuildMember.js\";\nimport type { Role } from \"../../guilds/Role.js\";\nimport { editChannel } from \"./edit.js\";\n\ntype Data = {\n guild_id?: string;\n parent_id?: string | null;\n position?: number;\n permission_overwrites?: APIOverwrite[];\n};\n\n// Whether two channels have the same permission overwrites, in any order.\nfunction sameOverwrites(channel: Data, parent: Data): boolean {\n const own = channel.permission_overwrites ?? [];\n const theirs = parent.permission_overwrites ?? [];\n return (\n own.length === theirs.length &&\n own.every((overwrite) =>\n theirs.some(\n (other) =>\n other.id === overwrite.id &&\n other.type === overwrite.type &&\n other.allow === overwrite.allow &&\n other.deny === overwrite.deny,\n ),\n )\n );\n}\n\nexport interface ChannelPermissionMixin<\n Type extends ChannelType = ChannelType,\n> extends Channel<Type> {}\n\n/**\n * Adds the position and permission overwrites of guild channels other than threads.\n */\nexport class ChannelPermissionMixin<Type extends ChannelType = ChannelType> {\n public get position(): number {\n return (this[kData] as Data).position ?? 0;\n }\n\n /**\n * The permission overwrites of the channel.\n */\n public get permissionOverwrites(): PermissionOverwriteManager {\n const data = this[kData] as Data;\n return new PermissionOverwriteManager(\n this.client,\n this.id,\n data.guild_id ?? null,\n data.permission_overwrites ?? [],\n this as never,\n );\n }\n\n /**\n * Whether the channel's overwrites are the same as its category's, like discord.js's\n * `GuildChannel#permissionsLocked`: `null` when it has no category, or when the category is not cached (see\n * {@link ChannelPermissionMixin.fetchPermissionsLocked}).\n */\n public get permissionsLocked(): boolean | null {\n const { parent } = this[kRelations];\n if (!parent) return null;\n return sameOverwrites(this[kData] as Data, parent.toJSON() as Data);\n }\n\n /**\n * Moves the channel.\n *\n * @param position The new position, or the offset from the current one with `relative`.\n * @param options Whether the position is relative, and the reason for the audit log.\n */\n public async setPosition(\n position: number,\n options: { relative?: boolean; reason?: string } = {},\n ): Promise<this> {\n const { guild_id: guildId } = this[kData] as Data;\n if (!guildId) throw new Error(`Channel ${this.id} has no known guild`);\n\n const target = options.relative ? this.position + position : position;\n await this.client.guilds\n .channels(guildId)\n .setPositions([{ channel: this.id, position: target }], options.reason);\n return this[kPatch]({ position: target } as never);\n }\n\n /**\n * Moves the channel into a category, or out of its category.\n *\n * @param parent The category, `null` to move the channel out.\n * @param options Whether to copy the category's overwrites (the default), and the reason for the audit log.\n */\n public setParent(\n parent: IdResolvable | null,\n options: { lockPermissions?: boolean; reason?: string } = {},\n ): Promise<this> {\n return editChannel(this, {\n parent,\n lockPermissions: options.lockPermissions ?? true,\n reason: options.reason,\n });\n }\n\n public setNSFW(nsfw = true, reason?: string): Promise<this> {\n return editChannel(this, { nsfw, reason });\n }\n\n /**\n * Replaces the channel's overwrites with its category's.\n *\n * @param reason The reason for the audit log.\n */\n public lockPermissions(reason?: string): Promise<this> {\n if (!(this[kData] as Data).parent_id) {\n throw new Error(`Channel ${this.id} has no category to sync its permissions with`);\n }\n\n return editChannel(this, { lockPermissions: true, reason });\n }\n\n /**\n * Fetches whether the channel's overwrites are the same as its category's. `null` without a category.\n */\n public async fetchPermissionsLocked(): Promise<boolean | null> {\n const { parent_id: parentId } = this[kData] as Data;\n if (!parentId) return null;\n\n const parent = (await this.client.channels.fetch(parentId)).toJSON() as Data;\n return sameOverwrites(this[kData] as Data, parent);\n }\n\n /**\n * Fetches the permissions of a member or role in the channel: their guild permissions with the channel's overwrites\n * applied. discord.js: `channel.permissionsFor(memberOrRole)`.\n *\n * @param target A member, a role, or the ID of a member.\n */\n public async fetchPermissionsFor(\n target: GuildMember | Role | string,\n ): Promise<Readonly<PermissionsBitField>> {\n const { guild_id: guildId, permission_overwrites: overwrites = [] } = this[kData] as Data;\n if (!guildId) throw new Error(`Channel ${this.id} has no known guild`);\n return computeTargetPermissions(guildId, overwrites, target);\n }\n}\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData } from \"../../Structure.js\";\nimport { editChannel } from \"./edit.js\";\n\ntype Data = { rate_limit_per_user?: number };\n\nexport interface ChannelSlowmodeMixin<\n Type extends ChannelType = ChannelType,\n> extends Channel<Type> {}\n\n/**\n * Adds the slowmode of channels users can send messages in.\n */\nexport class ChannelSlowmodeMixin<Type extends ChannelType = ChannelType> {\n /**\n * The slowmode, in seconds. `0` when disabled.\n */\n public get rateLimitPerUser(): number {\n return (this[kData] as Data).rate_limit_per_user ?? 0;\n }\n\n /**\n * Sets the slowmode.\n *\n * @param rateLimitPerUser The slowmode, in seconds, `0` to disable it.\n * @param reason The reason for the audit log.\n */\n public setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise<this> {\n return editChannel(this, { rateLimitPerUser, reason });\n }\n}\n","import type { GatewayClient } from \"../GatewayClient.js\";\nimport type {\n AnyThreadChannel,\n FetchArchivedThreadsOptions,\n FetchedThreads,\n ThreadCreateOptions,\n} from \"./ThreadManager.js\";\n\n/**\n * Manages the threads of one channel: `client.threads`, with the channel's ID filled in.\n */\nexport class ChannelThreadManager {\n public readonly client: GatewayClient;\n public readonly channelId: string;\n public readonly guildId: string | null;\n\n public constructor(client: GatewayClient, channelId: string, guildId: string | null) {\n this.client = client;\n this.channelId = channelId;\n this.guildId = guildId;\n }\n\n /**\n * Creates a thread in the channel, or a post in a forum or media channel (with `message`).\n *\n * @param options The thread's name and settings.\n */\n public create(options: ThreadCreateOptions): Promise<AnyThreadChannel> {\n return this.client.threads.create(this.channelId, options);\n }\n\n /**\n * Fetches the active threads of the channel, and caches them.\n */\n public async fetchActive(): Promise<FetchedThreads> {\n if (!this.guildId) throw new Error(`Channel ${this.channelId} has no known guild`);\n\n // Discord only lists the active threads of a whole guild.\n const { threads, members } = await this.client.threads.fetchActive(this.guildId);\n const own = threads.filter((thread) => thread.parentId === this.channelId);\n const ids = new Set(own.map((thread) => thread.id));\n return {\n threads: own,\n members: members.filter((member) => member.threadId && ids.has(member.threadId)),\n hasMore: false,\n };\n }\n\n /**\n * Fetches the archived threads of the channel, and caches them.\n *\n * @param options Public or private threads, and the page.\n */\n public fetchArchived(options?: FetchArchivedThreadsOptions): Promise<FetchedThreads> {\n return this.client.threads.fetchArchived(this.channelId, options);\n }\n}\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport { ChannelThreadManager } from \"../../../managers/ChannelThreadManager.js\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData } from \"../../Structure.js\";\n\ntype Data = { guild_id?: string };\n\nexport interface ChannelThreadsMixin<\n Type extends ChannelType = ChannelType,\n> extends Channel<Type> {}\n\n/**\n * Adds the threads of the channels that can have threads.\n */\nexport class ChannelThreadsMixin<Type extends ChannelType = ChannelType> {\n /**\n * The threads of the channel.\n */\n public get threads(): ChannelThreadManager {\n return new ChannelThreadManager(this.client, this.id, (this[kData] as Data).guild_id ?? null);\n }\n}\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { WebhookCreateOptions } from \"../../../managers/WebhookManager.js\";\nimport type { Channel } from \"../Channel.js\";\nimport type { Webhook } from \"../../webhooks/Webhook.js\";\n\nexport interface ChannelWebhooksMixin<\n Type extends ChannelType = ChannelType,\n> extends Channel<Type> {}\n\n/**\n * Adds the webhook actions of the channels that can have webhooks.\n */\nexport class ChannelWebhooksMixin<Type extends ChannelType = ChannelType> {\n /**\n * Fetches the webhooks of the channel.\n */\n public fetchWebhooks(): Promise<Webhook[]> {\n return this.client.webhooks.fetchChannel(this.id);\n }\n\n /**\n * Creates a webhook in the channel.\n *\n * @param options The webhook's name and avatar, and the reason for the audit log.\n */\n public createWebhook(options: WebhookCreateOptions): Promise<Webhook> {\n return this.client.webhooks.create(this.id, options);\n }\n}\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData } from \"../../Structure.js\";\nimport { editChannel } from \"./edit.js\";\n\ntype Data = { topic?: string | null };\n\nexport interface ChannelTopicMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the topic of text, announcement, forum, and media channels.\n */\nexport class ChannelTopicMixin<Type extends ChannelType = ChannelType> {\n public get topic(): string | null {\n return (this[kData] as Data).topic ?? null;\n }\n\n public setTopic(topic: string | null, reason?: string): Promise<this> {\n return editChannel(this, { topic, reason });\n }\n}\n","import type {\n APIGuildForumDefaultReactionEmoji,\n APIGuildForumTag,\n APIOverwrite,\n ChannelType,\n ForumLayoutType,\n SortOrderType,\n ThreadAutoArchiveDuration,\n VideoQualityMode,\n} from \"discord-api-types/v10\";\nimport type { Channel } from \"../Channel.js\";\nimport type { Guild } from \"../../guilds/Guild.js\";\nimport { kData, kRelations } from \"../../Structure.js\";\nimport type { GuildChannelCreateOptions, GuildChannelEditOptions } from \"../../../util/channels.js\";\nimport type { AnyChannel } from \"../../../managers/ChannelManager.js\";\nimport { editChannel } from \"./edit.js\";\n\ntype Data = { guild_id?: string; name?: string | null };\n\n// Every field `clone` copies, whichever the channel type.\ntype CloneableData = Data & {\n topic?: string | null;\n nsfw?: boolean;\n bitrate?: number;\n user_limit?: number;\n rate_limit_per_user?: number;\n parent_id?: string | null;\n position?: number;\n rtc_region?: string | null;\n video_quality_mode?: VideoQualityMode;\n default_auto_archive_duration?: ThreadAutoArchiveDuration;\n available_tags?: APIGuildForumTag[];\n default_reaction_emoji?: APIGuildForumDefaultReactionEmoji | null;\n default_thread_rate_limit_per_user?: number;\n default_sort_order?: SortOrderType | null;\n default_forum_layout?: ForumLayoutType;\n permission_overwrites?: APIOverwrite[];\n};\n\nexport interface GuildChannelMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the fields every guild channel has, threads included.\n */\nexport class GuildChannelMixin<Type extends ChannelType = ChannelType> {\n /**\n * The ID of the guild, when the payload included it.\n */\n public get guildId(): string | null {\n return (this[kData] as Data).guild_id ?? null;\n }\n\n /**\n * The guild, from the cache. `null` when the guild is not cached, or when the channel was not built by a manager: use\n * `fetchGuild()` to always get it.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * Fetches the guild, cache first. `null` when the payload did not include the guild's ID.\n */\n public async fetchGuild(): Promise<Guild | null> {\n const { guildId } = this;\n return guildId ? this.client.guilds.fetch(guildId) : null;\n }\n\n public get name(): string {\n return (this[kData] as Data).name ?? \"\";\n }\n\n /**\n * Edits the channel.\n *\n * @param options The fields to edit, and the reason for the audit log.\n */\n public edit(options: GuildChannelEditOptions): Promise<this> {\n return editChannel(this, options);\n }\n\n public setName(name: string, reason?: string): Promise<this> {\n return editChannel(this, { name, reason });\n }\n\n /**\n * Creates a copy of the channel in its guild: same type, name, settings, and overwrites.\n *\n * @param options The fields to change on the copy.\n */\n public async clone(options: Partial<GuildChannelCreateOptions> = {}): Promise<AnyChannel> {\n const { guildId } = this;\n if (!guildId) throw new Error(`Channel ${this.id} has no known guild`);\n\n const data = this[kData] as CloneableData;\n return this.client.guilds.channels(guildId).create({\n name: data.name ?? \"\",\n type: this.type,\n topic: data.topic,\n nsfw: data.nsfw,\n bitrate: data.bitrate,\n userLimit: data.user_limit,\n rateLimitPerUser: data.rate_limit_per_user,\n parent: data.parent_id,\n position: data.position,\n rtcRegion: data.rtc_region,\n videoQualityMode: data.video_quality_mode,\n defaultAutoArchiveDuration: data.default_auto_archive_duration,\n availableTags: data.available_tags,\n defaultReactionEmoji: data.default_reaction_emoji,\n defaultThreadRateLimitPerUser: data.default_thread_rate_limit_per_user,\n defaultSortOrder: data.default_sort_order,\n defaultForumLayout: data.default_forum_layout,\n permissionOverwrites: data.permission_overwrites?.map((overwrite) => ({\n id: overwrite.id,\n type: overwrite.type,\n allow: BigInt(overwrite.allow),\n deny: BigInt(overwrite.deny),\n })),\n ...options,\n });\n }\n}\n","import type { GatewayClient } from \"../GatewayClient.js\";\nimport type { Message } from \"../structures/messages/Message.js\";\nimport type { FetchOptions } from \"./CachedManager.js\";\nimport type { EmojiIdentifierResolvable } from \"../structures/emojis/ReactionEmoji.js\";\nimport type { User } from \"../structures/users/User.js\";\nimport type {\n MessageListOptions,\n MessageThreadCreateOptions,\n PinnedMessage,\n} from \"./MessageManager.js\";\nimport type { AnyThreadChannel } from \"./ThreadManager.js\";\nimport type {\n MessageCreateOptions,\n MessageEditOptions,\n MessagePayloadResolvable,\n} from \"../util/messages.js\";\n\n/**\n * Manages the messages of one channel: `client.messages`, with the channel's ID filled in.\n */\nexport class ChannelMessageManager {\n public readonly client: GatewayClient;\n public readonly channelId: string;\n\n public constructor(client: GatewayClient, channelId: string) {\n this.client = client;\n this.channelId = channelId;\n }\n\n /**\n * Gets a message of the channel from the cache.\n */\n public get(messageId: string): Promise<Message | undefined> {\n return this.client.messages.get(this.channelId, messageId);\n }\n\n /**\n * Gets a message of the channel from the cache, falling back to the API.\n */\n public fetch(messageId: string, options?: FetchOptions): Promise<Message> {\n return options\n ? this.client.messages.fetch(this.channelId, messageId, options)\n : this.client.messages.fetch(this.channelId, messageId);\n }\n\n /**\n * Lists the messages of the channel, newest first.\n */\n public list(options?: MessageListOptions): Promise<Message[]> {\n return this.client.messages.list(this.channelId, options);\n }\n\n public send(options: MessagePayloadResolvable<MessageCreateOptions>): Promise<Message> {\n return this.client.messages.send(this.channelId, options);\n }\n\n public edit(\n messageId: string,\n options: MessagePayloadResolvable<MessageEditOptions>,\n ): Promise<Message> {\n return this.client.messages.edit(this.channelId, messageId, options);\n }\n\n public delete(messageId: string, reason?: string): Promise<void> {\n return this.client.messages.delete(this.channelId, messageId, reason);\n }\n\n public fetchPins(options?: { limit?: number; before?: Date | number }): Promise<{\n items: PinnedMessage[];\n hasMore: boolean;\n }> {\n return this.client.messages.fetchPins(this.channelId, options);\n }\n\n public pin(messageId: string, reason?: string): Promise<void> {\n return this.client.messages.pin(this.channelId, messageId, reason);\n }\n\n public unpin(messageId: string, reason?: string): Promise<void> {\n return this.client.messages.unpin(this.channelId, messageId, reason);\n }\n\n public crosspost(messageId: string): Promise<Message> {\n return this.client.messages.crosspost(this.channelId, messageId);\n }\n\n public bulkDelete(messages: readonly string[] | number, filterOld = false): Promise<string[]> {\n return this.client.messages.bulkDelete(this.channelId, messages, filterOld);\n }\n\n public forward(messageId: string, targetChannelId: string): Promise<Message> {\n return this.client.messages.forward(this.channelId, messageId, targetChannelId);\n }\n\n public react(messageId: string, emoji: EmojiIdentifierResolvable): Promise<void> {\n return this.client.messages.react(this.channelId, messageId, emoji);\n }\n\n public removeReactionEmoji(messageId: string, emoji: EmojiIdentifierResolvable): Promise<void> {\n return this.client.messages.removeReactionEmoji(this.channelId, messageId, emoji);\n }\n\n public removeAllReactions(messageId: string): Promise<void> {\n return this.client.messages.removeAllReactions(this.channelId, messageId);\n }\n\n public startThread(\n messageId: string,\n options: MessageThreadCreateOptions,\n ): Promise<AnyThreadChannel> {\n return this.client.messages.startThread(this.channelId, messageId, options);\n }\n\n public endPoll(messageId: string): Promise<Message> {\n return this.client.messages.endPoll(this.channelId, messageId);\n }\n\n public fetchPollAnswerVoters(\n messageId: string,\n answerId: number,\n options?: { limit?: number; after?: string },\n ): Promise<User[]> {\n return this.client.messages.fetchPollAnswerVoters(this.channelId, messageId, answerId, options);\n }\n}\n","import { readFile } from \"node:fs/promises\";\nimport { basename } from \"node:path\";\nimport type { RawFile } from \"@discordjs/rest\";\nimport {\n MessageReferenceType,\n type APIAllowedMentions,\n type APIAttachment,\n type APIEmbed,\n type RESTAPIMessageReference,\n type APIMessageTopLevelComponent,\n type APIPollAnswer,\n type AllowedMentionsTypes,\n type PollLayoutType,\n type RESTAPIPoll,\n type RESTPostAPIChannelMessageJSONBody,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../../GatewayClient.js\";\nimport { MessageFlagsBitField, type MessageFlagsResolvable } from \"../../util/flags.js\";\n\n/**\n * Anything with a `toJSON` method, like the builders of `@discordjs/builders` and the structures of this package.\n */\nexport interface JSONEncodable<Value> {\n toJSON(): Value;\n}\n\n/**\n * Data a file can be resolved from: its contents, a path on disk, a URL, a stream, or a blob.\n */\nexport type BufferResolvable =\n | Uint8Array\n | ArrayBuffer\n | string\n | Blob\n | AsyncIterable<Uint8Array | string>;\n\n/**\n * A file described along with its attachment metadata, like discord.js's `AttachmentPayload`.\n */\nexport interface AttachmentPayload {\n /**\n * The contents of the file.\n */\n attachment: BufferResolvable;\n /**\n * The name of the file, inferred from a path or URL when omitted.\n */\n name?: string;\n /**\n * The description (alt text) of the file.\n */\n description?: string;\n /**\n * The title of the file.\n */\n title?: string;\n /**\n * Whether to mark the file as a spoiler, by prefixing its name with `SPOILER_`.\n */\n spoiler?: boolean;\n /**\n * The duration of a voice message, in seconds.\n */\n duration?: number;\n /**\n * The waveform of a voice message, base64-encoded.\n */\n waveform?: string;\n}\n\n/**\n * A file to attach to a message: a {@link RawFile} of `@discordjs/rest`, an {@link AttachmentPayload}, anything with\n * a `toJSON` returning one (e.g. an attachment builder), or its raw contents.\n */\nexport type AttachmentResolvable =\n | RawFile\n | AttachmentPayload\n | JSONEncodable<AttachmentPayload>\n | BufferResolvable;\n\n/**\n * The mentions a message may ping, in camel case like discord.js's `MessageMentionOptions`, or the raw API object.\n */\nexport type MessageMentionOptions =\n | APIAllowedMentions\n | {\n parse?: readonly AllowedMentionsTypes[];\n roles?: readonly string[];\n users?: readonly string[];\n /**\n * Whether to ping the author of the message replied to.\n */\n repliedUser?: boolean;\n };\n\n/**\n * The message a message replies to.\n */\nexport interface ReplyOptions {\n /**\n * The message, or its ID.\n */\n messageReference: string | { readonly id: string; readonly channelId?: string };\n /**\n * Whether to fail when the message no longer exists, rather than sending a regular message.\n *\n * @default GatewayClientOptions.failIfNotExists ?? true\n */\n failIfNotExists?: boolean;\n}\n\n/**\n * The message a message forwards.\n */\nexport interface ForwardOptions {\n /**\n * The message, or its ID along with `channel`.\n */\n message:\n | string\n | { readonly id: string; readonly channelId: string; readonly guildId?: string | null };\n /**\n * The channel of the message, or its ID, needed when `message` is an ID.\n */\n channel?: string | { readonly id: string };\n /**\n * The guild of the message, or its ID.\n */\n guild?: string | { readonly id: string };\n}\n\n/**\n * A poll to create, in camel case like discord.js's `PollCreateData`.\n */\nexport interface PollCreateData {\n question: { text: string };\n answers: readonly {\n text?: string;\n emoji?: string | { id?: string | null; name?: string | null };\n }[];\n /**\n * How long the poll lasts, in hours.\n */\n duration: number;\n allowMultiselect?: boolean;\n layoutType?: PollLayoutType;\n}\n\n/**\n * The options every message payload accepts, when creating and editing.\n *\n * @remarks\n * The keys of the raw REST body (`allowed_mentions`, `message_reference`, `sticker_ids`...) are accepted too, and are\n * sent as they are: the camel case ones win when both are set.\n */\nexport interface BaseMessageOptions {\n content?: string | null;\n embeds?: readonly (APIEmbed | JSONEncodable<APIEmbed>)[] | null;\n components?:\n | readonly (APIMessageTopLevelComponent | JSONEncodable<APIMessageTopLevelComponent>)[]\n | null;\n /**\n * The files to upload.\n */\n files?: readonly AttachmentResolvable[];\n /**\n * The attachments to keep, when editing, or their metadata.\n */\n attachments?: readonly (Partial<APIAttachment> | JSONEncodable<Partial<APIAttachment>>)[];\n allowedMentions?: MessageMentionOptions;\n flags?: MessageFlagsResolvable;\n poll?: PollCreateData | RESTAPIPoll | JSONEncodable<RESTAPIPoll>;\n}\n\n/**\n * The options to send a message with.\n */\nexport interface MessageCreateOptions\n extends\n BaseMessageOptions,\n Omit<Partial<RESTPostAPIChannelMessageJSONBody>, keyof BaseMessageOptions> {\n tts?: boolean;\n nonce?: string | number;\n /**\n * Whether to refuse sending a message whose nonce was used recently, deduplicating retries.\n */\n enforceNonce?: boolean;\n /**\n * The message to reply to.\n */\n reply?: ReplyOptions;\n /**\n * The message to forward.\n */\n forward?: ForwardOptions;\n /**\n * The stickers to send, or their IDs.\n */\n stickers?: readonly (string | { readonly id: string })[];\n}\n\n/**\n * The options to edit a message with.\n */\nexport interface MessageEditOptions extends BaseMessageOptions {}\n\n/**\n * The options only webhooks accept.\n */\nexport interface WebhookMessageOptions {\n username?: string;\n avatarURL?: string;\n /**\n * The name of the post to create, for webhooks of forum and media channels.\n */\n threadName?: string;\n /**\n * The tags of the post to create, for webhooks of forum and media channels.\n */\n appliedTags?: readonly string[];\n /**\n * Whether to allow components on a message of a webhook not owned by an application.\n */\n withComponents?: boolean;\n}\n\n/**\n * The thread a webhook message is in, for webhooks of forum and media channels, or of a thread's parent.\n */\nexport interface WebhookThreadOptions {\n threadId?: string;\n}\n\n/**\n * The options to send a message through a webhook with.\n */\nexport interface WebhookMessageCreateOptions\n extends BaseMessageOptions, WebhookMessageOptions, WebhookThreadOptions {\n tts?: boolean;\n}\n\n/**\n * The options to edit a message sent by a webhook with.\n */\nexport interface WebhookMessageEditOptions extends MessageEditOptions, WebhookThreadOptions {}\n\n/**\n * Anything with a client, e.g. a structure, which a {@link MessagePayload} reads its defaults from.\n */\nexport type MessageTarget = { readonly client: GatewayClient } | GatewayClient;\n\n/**\n * The extra flags telling a {@link MessagePayload} what its target accepts.\n */\nexport interface MessagePayloadContext {\n /**\n * Whether the message is sent through a webhook, which accepts {@link WebhookMessageOptions}.\n */\n webhook?: boolean;\n /**\n * Whether the message is edited rather than created: `null` clears fields instead of leaving them out.\n */\n edit?: boolean;\n}\n\n/**\n * The options of any message payload.\n */\nexport type MessagePayloadOptions = MessageCreateOptions & WebhookMessageOptions;\n\n/**\n * Anything accepted where a message payload is expected: its content, its options, or a {@link MessagePayload}.\n */\nexport type MessagePayloadResolvable<Options extends object = MessageCreateOptions> =\n | string\n | Options\n | MessagePayload;\n\n/**\n * The body and files a {@link MessagePayload} resolved to, ready for `@discordjs/core`.\n */\nexport interface ResolvedMessagePayload<Body = RESTPostAPIChannelMessageJSONBody> {\n body: Body;\n files: RawFile[] | undefined;\n}\n\nconst kOptionKeys = new Set([\n \"content\",\n \"embeds\",\n \"components\",\n \"files\",\n \"attachments\",\n \"allowedMentions\",\n \"flags\",\n \"poll\",\n \"tts\",\n \"nonce\",\n \"enforceNonce\",\n \"reply\",\n \"forward\",\n \"stickers\",\n \"username\",\n \"avatarURL\",\n \"threadName\",\n \"appliedTags\",\n \"withComponents\",\n \"threadId\",\n]);\n\n/**\n * Normalizes the options of a message into the REST body and files Discord expects, like discord.js's\n * `MessagePayload`: camel case options, builders, reply and forward shortcuts, stickers, polls, and files from paths,\n * URLs, streams, or buffers.\n *\n * @example\n * ```typescript\n * const payload = MessagePayload.create(channel, {\n * content: \"Awoo\",\n * reply: { messageReference: message },\n * files: [\"./wolf.png\", { attachment: buffer, name: \"howl.ogg\", description: \"A howl\" }],\n * });\n * await channel.send(payload);\n * ```\n */\nexport class MessagePayload {\n /**\n * What the message is sent to: the structure it is sent through, or the client.\n */\n public readonly target: MessageTarget;\n\n /**\n * The options the payload was created with.\n */\n public readonly options: MessagePayloadOptions;\n\n /**\n * What the target accepts.\n */\n public readonly context: Readonly<MessagePayloadContext>;\n\n /**\n * The resolved REST body, set by {@link MessagePayload.resolveBody}.\n */\n public body: RESTPostAPIChannelMessageJSONBody | null = null;\n\n /**\n * The resolved files, set by {@link MessagePayload.resolveFiles}.\n */\n public files: RawFile[] | null = null;\n\n public constructor(\n target: MessageTarget,\n options: MessagePayloadOptions,\n context: MessagePayloadContext = {},\n ) {\n this.target = target;\n this.options = options;\n this.context = context;\n }\n\n /**\n * The client the target belongs to.\n */\n public get client(): GatewayClient {\n return \"gateway\" in this.target ? (this.target as GatewayClient) : this.target.client;\n }\n\n /**\n * Whether the message is sent through a webhook.\n */\n public get isWebhook(): boolean {\n return this.context.webhook === true;\n }\n\n /**\n * Whether the message is edited rather than created.\n */\n public get isEdit(): boolean {\n return this.context.edit === true;\n }\n\n /**\n * Resolves the content of the message: `null` clears it when editing, and is left out otherwise.\n */\n public makeContent(): string | null | undefined {\n const { content } = this.options;\n if (content === null) return this.isEdit ? \"\" : undefined;\n if (content === undefined) return undefined;\n if (typeof content !== \"string\")\n throw new TypeError(\"The content of a message must be a string\");\n return content;\n }\n\n /**\n * Resolves the REST body of the message.\n */\n public resolveBody(): this {\n if (this.body) return this;\n\n const { options } = this;\n const raw: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(options)) {\n if (!kOptionKeys.has(key)) raw[key] = value;\n }\n\n const body: Record<string, unknown> = { ...raw };\n const set = (key: string, value: unknown) => {\n if (value !== undefined) body[key] = value;\n };\n\n set(\"content\", this.makeContent());\n set(\"tts\", options.tts);\n set(\"nonce\", this.resolveNonce(options.nonce));\n set(\"enforce_nonce\", options.enforceNonce);\n set(\"embeds\", this.resolveList(options.embeds));\n set(\"components\", this.resolveList(options.components));\n set(\n \"flags\",\n options.flags === undefined ? undefined : Number(MessageFlagsBitField.resolve(options.flags)),\n );\n set(\"allowed_mentions\", this.resolveAllowedMentions());\n set(\"message_reference\", this.resolveReference());\n set(\n \"sticker_ids\",\n options.stickers?.map((sticker) => (typeof sticker === \"string\" ? sticker : sticker.id)),\n );\n set(\"poll\", this.resolvePoll());\n set(\"attachments\", this.resolveAttachments());\n\n if (this.isWebhook) {\n set(\"username\", options.username);\n set(\"avatar_url\", options.avatarURL);\n set(\"thread_name\", options.threadName);\n set(\"applied_tags\", options.appliedTags?.slice());\n set(\"with_components\", options.withComponents);\n }\n\n this.body = body as unknown as RESTPostAPIChannelMessageJSONBody;\n return this;\n }\n\n /**\n * Resolves the files of the message, reading them from disk, the network, or streams.\n */\n public async resolveFiles(): Promise<this> {\n if (this.files) return this;\n this.files = await Promise.all(\n (this.options.files ?? []).map((file) => MessagePayload.resolveFile(file)),\n );\n return this;\n }\n\n /**\n * Resolves both the body and the files, for `@discordjs/core`.\n */\n public async resolve<Body = RESTPostAPIChannelMessageJSONBody>(): Promise<\n ResolvedMessagePayload<Body>\n > {\n await this.resolveBody().resolveFiles();\n return {\n body: this.body as unknown as Body,\n files: this.files!.length > 0 ? this.files! : undefined,\n };\n }\n\n private resolveNonce(nonce: string | number | undefined): string | number | undefined {\n if (nonce === undefined) return undefined;\n if (typeof nonce === \"string\" && nonce.length > 25) {\n throw new RangeError(\"A message nonce must be at most 25 characters long\");\n }\n if (typeof nonce === \"number\" && !Number.isInteger(nonce)) {\n throw new RangeError(\"A message nonce must be an integer\");\n }\n return nonce;\n }\n\n private resolveList<Value extends object>(\n values: readonly (Value | JSONEncodable<Value>)[] | null | undefined,\n ): Value[] | undefined {\n if (values === null) return this.isEdit ? [] : undefined;\n return values?.map((value) => MessagePayload.toJSON(value));\n }\n\n private resolveAllowedMentions(): APIAllowedMentions | undefined {\n const mentions = this.options.allowedMentions ?? this.clientOption(\"allowedMentions\");\n if (mentions === undefined) return undefined;\n\n const { repliedUser, ...rest } = mentions as { repliedUser?: boolean } & APIAllowedMentions;\n const resolved: APIAllowedMentions = { ...rest };\n if (rest.parse) resolved.parse = [...rest.parse];\n if (rest.roles) resolved.roles = [...rest.roles];\n if (rest.users) resolved.users = [...rest.users];\n if (repliedUser !== undefined) resolved.replied_user = repliedUser;\n return resolved;\n }\n\n private resolveReference(): RESTAPIMessageReference | undefined {\n const { reply, forward } = this.options as MessageCreateOptions;\n if (forward) {\n const { message, channel, guild } = forward;\n const channelId =\n typeof message === \"string\" ? MessagePayload.id(channel) : message.channelId;\n if (!channelId) throw new TypeError(\"Forwarding a message by ID needs its channel\");\n return {\n type: MessageReferenceType.Forward,\n message_id: typeof message === \"string\" ? message : message.id,\n channel_id: channelId,\n guild_id:\n MessagePayload.id(guild) ??\n (typeof message === \"string\" ? undefined : (message.guildId ?? undefined)),\n };\n }\n\n if (reply) {\n const { messageReference, failIfNotExists = this.clientOption(\"failIfNotExists\") ?? true } =\n reply;\n const reference: RESTAPIMessageReference = {\n type: MessageReferenceType.Default,\n message_id: typeof messageReference === \"string\" ? messageReference : messageReference.id,\n fail_if_not_exists: failIfNotExists,\n };\n if (typeof messageReference !== \"string\" && messageReference.channelId) {\n reference.channel_id = messageReference.channelId;\n }\n return reference;\n }\n\n return undefined;\n }\n\n private resolvePoll(): RESTAPIPoll | undefined {\n const { poll } = this.options;\n if (poll === undefined) return undefined;\n if (\"toJSON\" in poll && typeof poll.toJSON === \"function\") return poll.toJSON();\n if (!(\"allowMultiselect\" in poll || \"layoutType\" in poll || isCamelPoll(poll)))\n return poll as RESTAPIPoll;\n\n const data = poll as PollCreateData;\n return {\n question: { text: data.question.text },\n answers: data.answers.map(\n ({ text, emoji }) =>\n ({\n poll_media: {\n text,\n emoji: typeof emoji === \"string\" ? resolvePartialEmoji(emoji) : (emoji ?? undefined),\n },\n }) as Omit<APIPollAnswer, \"answer_id\">,\n ),\n duration: data.duration,\n allow_multiselect: data.allowMultiselect ?? false,\n layout_type: data.layoutType,\n } as RESTAPIPoll;\n }\n\n private resolveAttachments(): Partial<APIAttachment>[] | undefined {\n const { files, attachments } = this.options;\n if (files === undefined && attachments === undefined) return undefined;\n\n const resolved: Partial<APIAttachment>[] = (attachments ?? []).map((attachment) =>\n MessagePayload.toJSON(attachment),\n );\n for (const [index, file] of (files ?? []).entries()) {\n const payload = MessagePayload.attachmentPayload(file);\n const attachment: Record<string, unknown> = { id: index.toString() };\n if (payload?.description !== undefined) attachment.description = payload.description;\n if (payload?.title !== undefined) attachment.title = payload.title;\n if (payload?.duration !== undefined) attachment.duration_secs = payload.duration;\n if (payload?.waveform !== undefined) attachment.waveform = payload.waveform;\n resolved.push(attachment as Partial<APIAttachment>);\n }\n return resolved;\n }\n\n private clientOption<Key extends \"allowedMentions\" | \"failIfNotExists\">(\n key: Key,\n ): GatewayClientMessageDefaults[Key] {\n try {\n return (this.client.options as GatewayClientMessageDefaults)[key];\n } catch {\n return undefined;\n }\n }\n\n /**\n * Creates a payload, or returns it when it already is one.\n *\n * @param target What the message is sent to.\n * @param options The message, its content, or a payload.\n * @param context What the target accepts.\n */\n public static create(\n target: MessageTarget,\n options: MessagePayloadResolvable<MessagePayloadOptions | MessageEditOptions>,\n context?: MessagePayloadContext,\n ): MessagePayload {\n if (options instanceof MessagePayload) return options;\n return new MessagePayload(\n target,\n typeof options === \"string\" ? { content: options } : (options as MessagePayloadOptions),\n context,\n );\n }\n\n /**\n * Resolves a file to upload, reading paths from disk and downloading URLs.\n *\n * @param file The file.\n */\n public static async resolveFile(file: AttachmentResolvable): Promise<RawFile> {\n if (isRawFile(file)) return file;\n\n const payload = MessagePayload.attachmentPayload(file)!;\n const { attachment } = payload;\n let name = payload.name ?? (typeof attachment === \"string\" ? nameOf(attachment) : \"file.jpg\");\n if (payload.spoiler && !name.startsWith(\"SPOILER_\")) name = `SPOILER_${name}`;\n\n const { data, contentType } = await resolveBuffer(attachment);\n return contentType ? { name, data, contentType } : { name, data };\n }\n\n private static attachmentPayload(file: AttachmentResolvable): AttachmentPayload | null {\n if (isRawFile(file)) return null;\n if (isBufferResolvable(file)) return { attachment: file };\n if (\"toJSON\" in file && typeof file.toJSON === \"function\") return file.toJSON();\n return file as AttachmentPayload;\n }\n\n private static toJSON<Value extends object>(value: Value | JSONEncodable<Value>): Value {\n return \"toJSON\" in value && typeof value.toJSON === \"function\"\n ? value.toJSON()\n : (value as Value);\n }\n\n private static id(value: string | { readonly id: string } | undefined): string | undefined {\n return typeof value === \"string\" ? value : value?.id;\n }\n}\n\n/**\n * The message defaults read from the client's options.\n */\nexport interface GatewayClientMessageDefaults {\n /**\n * The mentions every message may ping, unless it sets its own.\n */\n allowedMentions?: MessageMentionOptions;\n /**\n * Whether replies fail when the message they reply to no longer exists, unless they set it themselves.\n *\n * @default true\n */\n failIfNotExists?: boolean;\n}\n\nfunction isCamelPoll(poll: object): boolean {\n const answers = (poll as { answers?: readonly object[] }).answers;\n return answers?.some((answer) => !(\"poll_media\" in answer)) ?? false;\n}\n\nfunction resolvePartialEmoji(emoji: string): { id?: string; name?: string } {\n const match = /<?(?:a?:)?(\\w{2,32}):(\\d{17,20})>?/.exec(emoji);\n return match ? { name: match[1], id: match[2] } : { name: emoji };\n}\n\nfunction isRawFile(file: AttachmentResolvable): file is RawFile {\n return (\n typeof file === \"object\" &&\n file !== null &&\n \"data\" in file &&\n \"name\" in file &&\n !(\"attachment\" in file)\n );\n}\n\nfunction isBufferResolvable(file: AttachmentResolvable): file is BufferResolvable {\n return (\n typeof file === \"string\" ||\n file instanceof Uint8Array ||\n file instanceof ArrayBuffer ||\n file instanceof Blob ||\n (typeof file === \"object\" && file !== null && Symbol.asyncIterator in file)\n );\n}\n\nfunction nameOf(path: string): string {\n if (/^https?:\\/\\//.test(path)) {\n const name = basename(new URL(path).pathname);\n return name || \"file.jpg\";\n }\n return basename(path);\n}\n\nasync function resolveBuffer(\n attachment: BufferResolvable,\n): Promise<{ data: Uint8Array; contentType?: string }> {\n if (attachment instanceof Uint8Array) return { data: attachment };\n if (attachment instanceof ArrayBuffer) return { data: new Uint8Array(attachment) };\n if (attachment instanceof Blob) {\n return {\n data: new Uint8Array(await attachment.arrayBuffer()),\n contentType: attachment.type || undefined,\n };\n }\n if (typeof attachment === \"string\") {\n if (/^https?:\\/\\//.test(attachment)) {\n const response = await fetch(attachment);\n if (!response.ok) throw new Error(`Could not download ${attachment}: ${response.status}`);\n return {\n data: new Uint8Array(await response.arrayBuffer()),\n contentType: response.headers.get(\"content-type\") ?? undefined,\n };\n }\n return { data: await readFile(attachment) };\n }\n\n const chunks: Uint8Array[] = [];\n for await (const chunk of attachment) {\n chunks.push(typeof chunk === \"string\" ? new TextEncoder().encode(chunk) : chunk);\n }\n return { data: Buffer.concat(chunks) };\n}\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport { ChannelMessageManager } from \"../../../managers/ChannelMessageManager.js\";\nimport {\n MessagePayload,\n type MessageCreateOptions,\n type MessagePayloadResolvable,\n} from \"../../messages/MessagePayload.js\";\nimport type { Channel, ChannelDataType } from \"../Channel.js\";\nimport type { Message } from \"../../messages/Message.js\";\nimport { kData } from \"../../Structure.js\";\n\ntype Data = { last_message_id?: string | null; last_pin_timestamp?: string | null };\nconst kLastPinTimestamp: unique symbol = Symbol.for(\n \"wolfstar.structures.lastPinTimestamp\",\n) as never;\nconst kLastPinRaw: unique symbol = Symbol.for(\"wolfstar.structures.lastPinRaw\") as never;\n\nexport interface TextChannelMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the fields and message actions of channels holding messages.\n */\nexport class TextChannelMixin<Type extends ChannelType = ChannelType> {\n public static DataTemplate = {\n set last_pin_timestamp(_value: string | null | undefined) {},\n };\n\n declare protected [kLastPinTimestamp]: number | null | undefined;\n declare protected [kLastPinRaw]: string | null | undefined;\n\n public static optimizeData(this: Channel, data: Partial<ChannelDataType>): void {\n const { last_pin_timestamp: timestamp } = data as Data;\n if (timestamp !== undefined) {\n (this as TextChannelMixin)[kLastPinTimestamp] = timestamp ? Date.parse(timestamp) : null;\n (this as TextChannelMixin)[kLastPinRaw] = timestamp;\n }\n }\n\n public static enrichToJSON(this: Channel, data: object): void {\n const raw = (this as TextChannelMixin)[kLastPinRaw];\n if (raw !== undefined) (data as Data).last_pin_timestamp = raw;\n }\n\n public get lastMessageId(): string | null {\n return (this[kData] as Data).last_message_id ?? null;\n }\n\n public get lastPinTimestamp(): number | null {\n return this[kLastPinTimestamp] ?? null;\n }\n\n public get lastPinAt(): Date | null {\n const { lastPinTimestamp } = this;\n return lastPinTimestamp === null ? null : new Date(lastPinTimestamp);\n }\n\n /**\n * The messages of the channel.\n */\n public get messages(): ChannelMessageManager {\n return new ChannelMessageManager(this.client, this.id);\n }\n\n /**\n * Sends a message to the channel.\n *\n * @param options The message, or its content.\n */\n public send(options: MessagePayloadResolvable<MessageCreateOptions>): Promise<Message> {\n return this.client.messages.send(this.id, MessagePayload.create(this, options));\n }\n\n /**\n * Shows the bot as typing in the channel, for about 10 seconds or until it sends a message.\n */\n public async sendTyping(): Promise<void> {\n await this.client.api.channels.showTyping(this.id);\n }\n\n /**\n * Deletes up to 100 messages at once.\n *\n * @param messages The IDs of the messages, or how many of the latest ones to delete.\n * @param filterOld Whether to drop the messages older than 14 days, which Discord refuses.\n * @returns The IDs of the deleted messages.\n */\n public bulkDelete(messages: readonly string[] | number, filterOld = false): Promise<string[]> {\n return this.client.messages.bulkDelete(this.id, messages, filterOld);\n }\n\n /**\n * Fetches the last message of the channel, cache first.\n */\n public async fetchLastMessage(): Promise<Message | null> {\n const { lastMessageId } = this;\n return lastMessageId ? this.client.messages.fetch(this.id, lastMessageId) : null;\n }\n}\n","import { AnnouncementChannel as BaseAnnouncementChannel } from \"@discordjs/structures\";\nimport { type ChannelType } from \"discord-api-types/v10\";\nimport { resolveId, type IdResolvable } from \"../../util/channels.js\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\nimport { ChannelPermissionMixin } from \"./mixins/ChannelPermissionMixin.js\";\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\nimport { ChannelThreadsMixin } from \"./mixins/ChannelThreadsMixin.js\";\nimport { ChannelWebhooksMixin } from \"./mixins/ChannelWebhooksMixin.js\";\nimport { ChannelTopicMixin } from \"./mixins/ChannelTopicMixin.js\";\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\n\nexport interface AnnouncementChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.GuildAnnouncement>, ChannelRelations>,\n MixinTypes<\n BaseAnnouncementChannel,\n [\n BaseChannelMixin<ChannelType.GuildAnnouncement>,\n TextChannelMixin<ChannelType.GuildAnnouncement>,\n GuildChannelMixin<ChannelType.GuildAnnouncement>,\n ChannelParentMixin<ChannelType.GuildAnnouncement>,\n ChannelPermissionMixin<ChannelType.GuildAnnouncement>,\n ChannelSlowmodeMixin<ChannelType.GuildAnnouncement>,\n ChannelTopicMixin<ChannelType.GuildAnnouncement>,\n ChannelWebhooksMixin<ChannelType.GuildAnnouncement>,\n ChannelThreadsMixin<ChannelType.GuildAnnouncement>,\n ]\n > {}\n\n/**\n * A guild announcement channel.\n */\nexport class AnnouncementChannel extends BaseAnnouncementChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(\n data: ChannelDataType<ChannelType.GuildAnnouncement>,\n relations: ChannelRelations = {},\n ) {\n super(data);\n initStructure(this, data, relations);\n }\n\n /**\n * Makes another channel follow this one: messages published here are crossposted there by a webhook.\n *\n * @param channel The channel to post to, or its ID.\n * @param reason The reason for the audit log.\n * @returns The ID of the follower webhook created in the target channel.\n */\n public async addFollower(channel: IdResolvable, reason?: string): Promise<string> {\n const result = await this.client.api.channels.followAnnouncements(this.id, resolveId(channel), {\n reason,\n });\n return result.webhook_id;\n }\n}\n\nMixin(AnnouncementChannel, [\n StructureMixin,\n BaseChannelMixin,\n TextChannelMixin,\n GuildChannelMixin,\n ChannelParentMixin,\n ChannelPermissionMixin,\n ChannelSlowmodeMixin,\n ChannelTopicMixin,\n ChannelWebhooksMixin,\n ChannelThreadsMixin,\n]);\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData } from \"../../Structure.js\";\n\ntype Data = { owner_id?: string };\n\nexport interface ChannelOwnerMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the owner of threads and group direct messages.\n */\nexport class ChannelOwnerMixin<Type extends ChannelType = ChannelType> {\n public get ownerId(): string | null {\n return (this[kData] as Data).owner_id ?? null;\n }\n}\n","import type { GatewayClient } from \"../GatewayClient.js\";\nimport type { ThreadMember } from \"../structures/channels/ThreadMember.js\";\nimport type { FetchOptions } from \"./CachedManager.js\";\nimport type { ThreadMemberListOptions } from \"./ThreadMemberManager.js\";\n\n/**\n * Manages the members of one thread: `client.threadMembers`, with the thread's ID filled in.\n */\nexport class ThreadChannelMemberManager {\n public readonly client: GatewayClient;\n public readonly threadId: string;\n\n public constructor(client: GatewayClient, threadId: string) {\n this.client = client;\n this.threadId = threadId;\n }\n\n /**\n * Gets a member of the thread from the cache.\n */\n public get(userId: string): Promise<ThreadMember | undefined> {\n return this.client.threadMembers.get(this.threadId, userId);\n }\n\n /**\n * Gets a member of the thread from the cache, falling back to the API.\n *\n * @param userId The ID of the user.\n * @param options The cache options, and whether to include the guild member (which always calls the API).\n */\n public fetch(\n userId: string,\n options: FetchOptions & { withMember?: boolean } = {},\n ): Promise<ThreadMember> {\n const { withMember, ...fetchOptions } = options;\n return withMember\n ? this.client.threadMembers.fetchWithMember(this.threadId, userId, { withMember })\n : this.client.threadMembers.fetch(this.threadId, userId, fetchOptions);\n }\n\n /**\n * Lists the members of the thread.\n */\n public list(options?: ThreadMemberListOptions): Promise<ThreadMember[]> {\n return this.client.threadMembers.list(this.threadId, options);\n }\n\n /**\n * Adds a user to the thread, the bot by default.\n */\n public add(userId = \"@me\"): Promise<void> {\n return this.client.threadMembers.add(this.threadId, userId);\n }\n\n /**\n * Removes a user from the thread, the bot by default.\n */\n public remove(userId = \"@me\"): Promise<void> {\n return this.client.threadMembers.remove(this.threadId, userId);\n }\n}\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { Channel, ChannelDataType } from \"../Channel.js\";\nimport type { ThreadAutoArchiveDuration } from \"discord-api-types/v10\";\nimport { ThreadChannelMemberManager } from \"../../../managers/ThreadChannelMemberManager.js\";\nimport type { Message } from \"../../messages/Message.js\";\nimport type { ThreadMember } from \"../ThreadMember.js\";\nimport { kData, kRelations } from \"../../Structure.js\";\nimport { editChannel } from \"./edit.js\";\nimport type { APIThreadMetadata } from \"discord-api-types/v10\";\n\ntype Data = {\n parent_id?: string | null;\n owner_id?: string;\n thread_metadata?: APIThreadMetadata;\n message_count?: number;\n member_count?: number;\n member?: object;\n};\nconst kArchiveTimestamp: unique symbol = Symbol.for(\n \"wolfstar.structures.archiveTimestamp\",\n) as never;\n\nexport interface ThreadChannelMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the metadata of threads.\n */\nexport class ThreadChannelMixin<Type extends ChannelType = ChannelType> {\n declare protected [kArchiveTimestamp]: number | null | undefined;\n\n public static optimizeData(this: Channel, data: Partial<ChannelDataType>): void {\n const metadata = (data as Data).thread_metadata;\n if (metadata !== undefined) {\n (this as ThreadChannelMixin)[kArchiveTimestamp] = metadata.archive_timestamp\n ? Date.parse(metadata.archive_timestamp)\n : null;\n }\n }\n\n public get archived(): boolean {\n return (this[kData] as Data).thread_metadata?.archived ?? false;\n }\n\n public get locked(): boolean {\n return (this[kData] as Data).thread_metadata?.locked ?? false;\n }\n\n public get archiveTimestamp(): number | null {\n return this[kArchiveTimestamp] ?? null;\n }\n\n /**\n * The minutes of inactivity after which the thread is archived.\n */\n public get autoArchiveDuration(): number | null {\n return (this[kData] as Data).thread_metadata?.auto_archive_duration ?? null;\n }\n\n public get messageCount(): number {\n return (this[kData] as Data).message_count ?? 0;\n }\n\n public get memberCount(): number {\n return (this[kData] as Data).member_count ?? 0;\n }\n\n /**\n * Whether non-moderators can add members, for private threads.\n */\n public get invitable(): boolean | null {\n return (this[kData] as Data).thread_metadata?.invitable ?? null;\n }\n\n /**\n * Whether the bot is a member of the thread, like discord.js's `ThreadChannel#joined`: from the thread member cache\n * when the thread was built by a manager, else `true` when the payload carries the bot's thread member.\n *\n * @returns `null` when it cannot be told: no thread member cache, and no thread member in the payload.\n */\n public get joined(): boolean | null {\n return this[kRelations].joined ?? ((this[kData] as Data).member === undefined ? null : true);\n }\n\n /**\n * The members of the thread.\n */\n public get members(): ThreadChannelMemberManager {\n return new ThreadChannelMemberManager(this.client, this.id);\n }\n\n public setArchived(archived = true, reason?: string): Promise<this> {\n return editChannel(this, { archived, reason });\n }\n\n public setLocked(locked = true, reason?: string): Promise<this> {\n return editChannel(this, { locked, reason });\n }\n\n /**\n * Sets whether non-moderators can add members to the private thread.\n */\n public setInvitable(invitable = true, reason?: string): Promise<this> {\n return editChannel(this, { invitable, reason });\n }\n\n public setAutoArchiveDuration(\n autoArchiveDuration: ThreadAutoArchiveDuration,\n reason?: string,\n ): Promise<this> {\n return editChannel(this, { autoArchiveDuration, reason });\n }\n\n /**\n * Joins the thread.\n */\n public async join(): Promise<this> {\n await this.client.threadMembers.add(this.id);\n return this;\n }\n\n /**\n * Leaves the thread.\n */\n public async leave(): Promise<this> {\n await this.client.threadMembers.remove(this.id);\n return this;\n }\n\n /**\n * Fetches the message the thread was started from, in its parent channel. Its ID is the thread's.\n */\n public fetchStarterMessage(): Promise<Message> {\n const { parent_id: parentId } = this[kData] as Data;\n if (!parentId) throw new Error(`Thread ${this.id} has no known parent`);\n return this.client.messages.fetch(parentId, this.id);\n }\n\n /**\n * Fetches the thread member of the thread's owner.\n */\n public fetchOwner(): Promise<ThreadMember> {\n const { owner_id: ownerId } = this[kData] as Data;\n if (!ownerId) throw new Error(`Thread ${this.id} has no known owner`);\n return this.client.threadMembers.fetch(this.id, ownerId);\n }\n}\n","import { AnnouncementThreadChannel as BaseAnnouncementThreadChannel } from \"@discordjs/structures\";\nimport type { ChannelType } from \"discord-api-types/v10\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelOwnerMixin } from \"./mixins/ChannelOwnerMixin.js\";\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\nimport { ThreadChannelMixin } from \"./mixins/ThreadChannelMixin.js\";\n\nexport interface AnnouncementThreadChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.AnnouncementThread>, ChannelRelations>,\n MixinTypes<\n BaseAnnouncementThreadChannel,\n [\n BaseChannelMixin<ChannelType.AnnouncementThread>,\n TextChannelMixin<ChannelType.AnnouncementThread>,\n GuildChannelMixin<ChannelType.AnnouncementThread>,\n ChannelOwnerMixin<ChannelType.AnnouncementThread>,\n ChannelParentMixin<ChannelType.AnnouncementThread>,\n ChannelSlowmodeMixin<ChannelType.AnnouncementThread>,\n ThreadChannelMixin<ChannelType.AnnouncementThread>,\n ]\n > {}\n\n/**\n * A thread of an announcement channel.\n */\nexport class AnnouncementThreadChannel extends BaseAnnouncementThreadChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(\n data: ChannelDataType<ChannelType.AnnouncementThread>,\n relations: ChannelRelations = {},\n ) {\n super(data);\n initStructure(this, data, relations);\n }\n}\n\nMixin(AnnouncementThreadChannel, [\n StructureMixin,\n BaseChannelMixin,\n TextChannelMixin,\n GuildChannelMixin,\n ChannelOwnerMixin,\n ChannelParentMixin,\n ChannelSlowmodeMixin,\n ThreadChannelMixin,\n]);\n","import { Channel as BaseChannelStructure } from \"@discordjs/structures\";\nimport { ChannelType, type APIChannel, type Snowflake } from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport type { StageInstance } from \"../stageInstances/StageInstance.js\";\nimport type { User } from \"../users/User.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, kRelations, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\n\n/**\n * The raw data of a channel of type `Type`. Channels sent within a guild payload carry their `guild_id` too.\n */\nexport type ChannelDataType<Type extends ChannelType = ChannelType> = Extract<\n APIChannel,\n { type: Type }\n> & { guild_id?: Snowflake };\n\n/**\n * The relations of a channel, resolved from the cache by `client.channels` and `client.threads`.\n */\nexport interface ChannelRelations {\n guild?: Guild | null;\n /**\n * The parent of a guild channel: its category, or the channel a thread belongs to.\n */\n parent?: AnyChannel | null;\n /**\n * The user a direct message is with.\n */\n recipient?: User | null;\n /**\n * The live stage of a stage channel.\n */\n stageInstance?: StageInstance | null;\n /**\n * Whether the bot is a member of a thread, as the thread member cache knows it.\n */\n joined?: boolean;\n}\n\nconst ThreadTypes: readonly ChannelType[] = [\n ChannelType.AnnouncementThread,\n ChannelType.PublicThread,\n ChannelType.PrivateThread,\n];\n\n/** Whether a raw channel type belongs in the thread cache. */\nexport function isThreadChannelType(type: ChannelType): boolean {\n return ThreadTypes.includes(type);\n}\n\nexport interface Channel<Type extends ChannelType = ChannelType>\n extends\n StructureMixin<ChannelDataType<Type>, ChannelRelations>,\n MixinTypes<BaseChannelStructure<Type>, [BaseChannelMixin<Type>]> {}\n\n/**\n * A channel: `@discordjs/structures`' `Channel`, with what every channel type shares.\n *\n * @remarks\n * Concrete channels (`TextChannel`, `DMChannel`, ...) extend `@discordjs/structures`' own and add their fields through\n * mixins, following its design. `ChannelManager` picks the right one for a raw channel.\n *\n * @typeParam Type The type of the channel.\n */\nexport class Channel<Type extends ChannelType = ChannelType> extends BaseChannelStructure<Type> {\n /**\n * Whether a value is a channel of this package. The concrete channels extend `@discordjs/structures`' own rather than\n * this class, so `instanceof Channel` matches any `@discordjs/structures` channel carrying {@link StructureMixin}.\n * Subclasses keep the default `instanceof` behavior.\n *\n * @param value The value to check.\n */\n public static override [Symbol.hasInstance](value: unknown): boolean {\n if (this !== Channel) return Function.prototype[Symbol.hasInstance].call(this, value);\n return value instanceof BaseChannelStructure && kRelations in value;\n }\n\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(data: ChannelDataType<Type>, relations: ChannelRelations = {}) {\n super(data as never);\n initStructure(this, data, relations);\n }\n}\n\nMixin(Channel, [StructureMixin, BaseChannelMixin]);\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport { Channel } from \"./Channel.js\";\n\n/**\n * A channel of a type no other structure covers yet.\n */\nexport class BaseChannel extends Channel<ChannelType> {}\n","import { CategoryChannel as BaseCategoryChannel } from \"@discordjs/structures\";\nimport type { ChannelType } from \"discord-api-types/v10\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelPermissionMixin } from \"./mixins/ChannelPermissionMixin.js\";\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\n\nexport interface CategoryChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.GuildCategory>, ChannelRelations>,\n MixinTypes<\n BaseCategoryChannel,\n [\n BaseChannelMixin<ChannelType.GuildCategory>,\n GuildChannelMixin<ChannelType.GuildCategory>,\n ChannelPermissionMixin<ChannelType.GuildCategory>,\n ]\n > {}\n\n/**\n * A guild category.\n */\nexport class CategoryChannel extends BaseCategoryChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(\n data: ChannelDataType<ChannelType.GuildCategory>,\n relations: ChannelRelations = {},\n ) {\n super(data);\n initStructure(this, data, relations);\n }\n}\n\nMixin(CategoryChannel, [\n StructureMixin,\n BaseChannelMixin,\n GuildChannelMixin,\n ChannelPermissionMixin,\n]);\n","import { CDN } from \"@discordjs/rest\";\n\n/**\n * @internal The CDN URL builder shared by the structures. Structures never hold a client, so they cannot use\n * `container.rest.cdn`.\n */\nexport const cdn = new CDN();\n","import type { BaseImageURLOptions, ImageURLOptions } from \"@discordjs/rest\";\nimport { User as BaseUser } from \"@discordjs/structures\";\nimport type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type {\n APIAvatarDecorationData,\n APICollectibles,\n APIUserPrimaryGuild,\n} from \"discord-api-types/v10\";\nimport { cdn } from \"../../util/cdn.js\";\nimport { UserFlagsBitField } from \"../../util/flags.js\";\nimport {\n MessagePayload,\n type MessageCreateOptions,\n type MessagePayloadResolvable,\n} from \"../messages/MessagePayload.js\";\nimport type { DMChannel } from \"../channels/DMChannel.js\";\nimport type { Message } from \"../messages/Message.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, kPatch, snowflakeTimestamp, StructureMixin } from \"../Structure.js\";\n\nexport interface User extends StructureMixin<CacheEntityTypes[\"users\"]> {}\n\n/**\n * A Discord user: `@discordjs/structures`' `User`, with CDN URLs and actions through the client.\n */\nexport class User extends BaseUser {\n /**\n * @param data The raw user.\n * @param relations The related structures, resolved from the cache.\n */\n public constructor(data: CacheEntityTypes[\"users\"], relations: object = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n /**\n * The user's tag: their username for migrated users, `username#discriminator` for legacy ones.\n */\n public get tag(): string {\n return this.discriminator === \"0\" ? this.username : `${this.username}#${this.discriminator}`;\n }\n\n /**\n * The user's accent color as a `#rrggbb` string, with the same `undefined`/`null` semantics.\n */\n public get hexAccentColor(): `#${string}` | null | undefined {\n const { accentColor } = this;\n if (typeof accentColor !== \"number\") return accentColor;\n return `#${accentColor.toString(16).padStart(6, \"0\")}`;\n }\n\n public get avatarDecorationData(): APIAvatarDecorationData | null {\n return this[kData].avatar_decoration_data ?? null;\n }\n\n public get collectibles(): APICollectibles | null {\n return this[kData].collectibles ?? null;\n }\n\n /**\n * The guild whose tag the user displays, if any.\n */\n public get primaryGuild(): APIUserPrimaryGuild | null {\n return this[kData].primary_guild ?? null;\n }\n\n /**\n * The user's public flags (badges).\n */\n public get flags(): Readonly<UserFlagsBitField> {\n return new UserFlagsBitField(this[kData].public_flags ?? this[kData].flags ?? 0).freeze();\n }\n\n public get createdTimestamp() {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n\n /**\n * Gets the URL of the user's avatar, or `null` if they have none.\n * @param options The image options.\n */\n public avatarURL(options?: ImageURLOptions): string | null {\n const { avatar } = this[kData];\n return avatar ? cdn.avatar(this.id, avatar, options) : null;\n }\n\n /**\n * The URL of the user's default avatar.\n */\n public get defaultAvatarURL(): string {\n return cdn.defaultAvatar(this.defaultAvatarIndex);\n }\n\n /**\n * Gets the URL of the user's avatar, falling back to their default avatar.\n * @param options The image options.\n */\n public displayAvatarURL(options?: ImageURLOptions): string {\n return this.avatarURL(options) ?? this.defaultAvatarURL;\n }\n\n /**\n * The index of the user's default avatar: migrated users (discriminator `\"0\"`) derive it from their ID, legacy ones\n * from their discriminator.\n */\n public get defaultAvatarIndex(): number {\n return this.discriminator === \"0\"\n ? Number((BigInt(this.id) >> 22n) % 6n)\n : Number(this.discriminator) % 5;\n }\n\n /**\n * Gets the URL of the user's avatar decoration, or `null` if they have none.\n */\n public avatarDecorationURL(): string | null {\n const asset = this.avatarDecorationData?.asset;\n return asset ? cdn.avatarDecoration(asset) : null;\n }\n\n /**\n * Gets the URL of the user's banner: `undefined` when unknown (not fetched), `null` when they have none.\n * @param options The image options.\n */\n public bannerURL(options?: ImageURLOptions): string | null | undefined {\n const { banner } = this;\n return banner ? cdn.banner(this.id, banner, options) : banner;\n }\n\n /**\n * Gets the URL of the badge of the guild tag the user displays, or `null` if they display none.\n * @param options The image options.\n */\n public guildTagBadgeURL(options?: BaseImageURLOptions): string | null {\n const guild = this.primaryGuild;\n return guild?.identity_guild_id && guild.badge\n ? cdn.guildTagBadge(guild.identity_guild_id, guild.badge, options)\n : null;\n }\n\n /**\n * Opens a direct message channel with the user, or gets the existing one.\n */\n public createDM(): Promise<DMChannel> {\n return this.client.users.createDM(this.id);\n }\n\n /**\n * Closes the direct message channel with the user.\n */\n public deleteDM(): Promise<DMChannel> {\n return this.client.users.deleteDM(this.id);\n }\n\n /**\n * Sends a direct message to the user.\n *\n * @param options The message, or its content.\n */\n public send(options: MessagePayloadResolvable<MessageCreateOptions>): Promise<Message> {\n return this.client.users.send(this.id, MessagePayload.create(this, options));\n }\n\n /**\n * Whether the user is partial: built from its ID alone for an event about an uncached user, see `Partials.User`.\n * Only its ID is reliable then, and {@link User.fetch} completes it.\n */\n public get partial(): boolean {\n return this[kData].username === undefined;\n }\n\n /**\n * Fetches the user from the API and patches this structure with the result.\n */\n public async fetch(): Promise<this> {\n const user = await this.client.users.fetch(this.id, { force: true });\n return this[kPatch](user.toJSON());\n }\n\n /**\n * Whether this user has the same data as another one.\n * @param user The user to compare with.\n */\n public equals(user: User): boolean {\n return (\n this.id === user.id &&\n this.username === user.username &&\n this.discriminator === user.discriminator &&\n this.globalName === user.globalName &&\n this.avatar === user.avatar &&\n this.flags.bitField === user.flags.bitField &&\n this.banner === user.banner &&\n this.accentColor === user.accentColor &&\n this.avatarDecorationData?.asset === user.avatarDecorationData?.asset\n );\n }\n\n public toString(): `<@${string}>` {\n return `<@${this.id}>`;\n }\n}\nMixin(User, [StructureMixin]);\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData } from \"../../Structure.js\";\nimport type { APIUser } from \"discord-api-types/v10\";\nimport { User } from \"../../users/User.js\";\n\ntype Data = { recipients?: APIUser[] };\n\nexport interface DMChannelMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the recipients of direct messages.\n */\nexport class DMChannelMixin<Type extends ChannelType = ChannelType> {\n public get recipients(): User[] {\n return ((this[kData] as Data).recipients ?? []).map((user) => new User(user));\n }\n}\n","import { DMChannel as BaseDMChannel } from \"@discordjs/structures\";\nimport type { ChannelType } from \"discord-api-types/v10\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, kData, kRelations, StructureMixin } from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { DMChannelMixin } from \"./mixins/DMChannelMixin.js\";\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\n\nexport interface DMChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.DM>, ChannelRelations>,\n MixinTypes<\n BaseDMChannel,\n [\n BaseChannelMixin<ChannelType.DM>,\n DMChannelMixin<ChannelType.DM>,\n TextChannelMixin<ChannelType.DM>,\n ]\n > {}\n\n/**\n * A direct message channel.\n */\nexport class DMChannel extends BaseDMChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(data: ChannelDataType<ChannelType.DM>, relations: ChannelRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n /**\n * Whether the direct message is partial: built from its ID alone for an event in an uncached direct message, see\n * `Partials.Channel`. Only its ID (and its recipient, when the event carried them) is reliable then, and `fetch()`\n * completes it.\n */\n public get partial(): boolean {\n return this[kData].last_message_id === undefined;\n }\n\n /**\n * The ID of the user the direct message is with, when the payload included them.\n */\n public get recipientId(): string | null {\n return this[kData].recipients?.[0]?.id ?? null;\n }\n\n /**\n * The user the direct message is with, like discord.js's `DMChannel#recipient`: the cached user, else the one of the\n * payload. `null` when the payload did not include them.\n */\n public get recipient(): User | null {\n const recipient = this[kData].recipients?.[0];\n return this[kRelations].recipient ?? (recipient ? new User(recipient) : null);\n }\n}\n\nMixin(DMChannel, [StructureMixin, BaseChannelMixin, DMChannelMixin, TextChannelMixin]);\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData } from \"../../Structure.js\";\nimport type { GuildForumTagData } from \"../../../util/channels.js\";\nimport { editChannel } from \"./edit.js\";\nimport type {\n APIGuildForumDefaultReactionEmoji,\n APIGuildForumTag,\n ForumLayoutType,\n SortOrderType,\n} from \"discord-api-types/v10\";\n\ntype Data = {\n available_tags?: APIGuildForumTag[];\n default_reaction_emoji?: APIGuildForumDefaultReactionEmoji | null;\n default_thread_rate_limit_per_user?: number;\n};\n\nexport interface ThreadOnlyChannelMixin<\n Type extends ChannelType = ChannelType,\n> extends Channel<Type> {}\n\n/**\n * Adds the fields of forum and media channels, which only hold threads.\n */\nexport class ThreadOnlyChannelMixin<Type extends ChannelType = ChannelType> {\n public get availableTags(): readonly APIGuildForumTag[] {\n return (this[kData] as Data).available_tags ?? [];\n }\n\n public get defaultReactionEmoji(): APIGuildForumDefaultReactionEmoji | null {\n return (this[kData] as Data).default_reaction_emoji ?? null;\n }\n\n public get defaultThreadRateLimitPerUser(): number {\n return (this[kData] as Data).default_thread_rate_limit_per_user ?? 0;\n }\n\n public setAvailableTags(\n availableTags: readonly GuildForumTagData[],\n reason?: string,\n ): Promise<this> {\n return editChannel(this, { availableTags, reason });\n }\n\n public setDefaultReactionEmoji(\n defaultReactionEmoji: APIGuildForumDefaultReactionEmoji | null,\n reason?: string,\n ): Promise<this> {\n return editChannel(this, { defaultReactionEmoji, reason });\n }\n\n public setDefaultThreadRateLimitPerUser(\n defaultThreadRateLimitPerUser: number,\n reason?: string,\n ): Promise<this> {\n return editChannel(this, { defaultThreadRateLimitPerUser, reason });\n }\n\n public setDefaultSortOrder(\n defaultSortOrder: SortOrderType | null,\n reason?: string,\n ): Promise<this> {\n return editChannel(this, { defaultSortOrder, reason });\n }\n\n public setDefaultForumLayout(\n defaultForumLayout: ForumLayoutType,\n reason?: string,\n ): Promise<this> {\n return editChannel(this, { defaultForumLayout, reason });\n }\n}\n","import { ForumChannel as BaseForumChannel } from \"@discordjs/structures\";\nimport type { ChannelType } from \"discord-api-types/v10\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\nimport { ChannelPermissionMixin } from \"./mixins/ChannelPermissionMixin.js\";\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\nimport { ChannelThreadsMixin } from \"./mixins/ChannelThreadsMixin.js\";\nimport { ChannelWebhooksMixin } from \"./mixins/ChannelWebhooksMixin.js\";\nimport { ChannelTopicMixin } from \"./mixins/ChannelTopicMixin.js\";\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\nimport { ThreadOnlyChannelMixin } from \"./mixins/ThreadOnlyChannelMixin.js\";\n\nexport interface ForumChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.GuildForum>, ChannelRelations>,\n MixinTypes<\n BaseForumChannel,\n [\n BaseChannelMixin<ChannelType.GuildForum>,\n GuildChannelMixin<ChannelType.GuildForum>,\n ChannelParentMixin<ChannelType.GuildForum>,\n ChannelPermissionMixin<ChannelType.GuildForum>,\n ChannelSlowmodeMixin<ChannelType.GuildForum>,\n ChannelTopicMixin<ChannelType.GuildForum>,\n ThreadOnlyChannelMixin<ChannelType.GuildForum>,\n ChannelWebhooksMixin<ChannelType.GuildForum>,\n ChannelThreadsMixin<ChannelType.GuildForum>,\n ]\n > {}\n\n/**\n * A guild forum channel.\n */\nexport class ForumChannel extends BaseForumChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(\n data: ChannelDataType<ChannelType.GuildForum>,\n relations: ChannelRelations = {},\n ) {\n super(data);\n initStructure(this, data, relations);\n }\n}\n\nMixin(ForumChannel, [\n StructureMixin,\n BaseChannelMixin,\n GuildChannelMixin,\n ChannelParentMixin,\n ChannelPermissionMixin,\n ChannelSlowmodeMixin,\n ChannelTopicMixin,\n ThreadOnlyChannelMixin,\n ChannelWebhooksMixin,\n ChannelThreadsMixin,\n]);\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData } from \"../../Structure.js\";\nimport type { ImageURLOptions } from \"@discordjs/rest\";\nimport { cdn } from \"../../../util/cdn.js\";\n\ntype Data = { name?: string | null; icon?: string | null; application_id?: string };\n\nexport interface GroupDMMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the fields of group direct messages.\n */\nexport class GroupDMMixin<Type extends ChannelType = ChannelType> {\n public get name(): string | null {\n return (this[kData] as Data).name ?? null;\n }\n\n public get icon(): string | null {\n return (this[kData] as Data).icon ?? null;\n }\n\n /**\n * The ID of the application that created the group, if any.\n */\n public get applicationId(): string | null {\n return (this[kData] as Data).application_id ?? null;\n }\n\n /**\n * Gets the URL of the group's icon, or `null` if it has none.\n * @param options The image options.\n */\n public iconURL(options?: ImageURLOptions): string | null {\n const { icon } = this[kData] as Data;\n return icon ? cdn.channelIcon(this.id, icon, options) : null;\n }\n}\n","import { GroupDMChannel as BaseGroupDMChannel } from \"@discordjs/structures\";\nimport type { ChannelType } from \"discord-api-types/v10\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelOwnerMixin } from \"./mixins/ChannelOwnerMixin.js\";\nimport { DMChannelMixin } from \"./mixins/DMChannelMixin.js\";\nimport { GroupDMMixin } from \"./mixins/GroupDMMixin.js\";\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\n\nexport interface GroupDMChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.GroupDM>, ChannelRelations>,\n MixinTypes<\n BaseGroupDMChannel,\n [\n BaseChannelMixin<ChannelType.GroupDM>,\n DMChannelMixin<ChannelType.GroupDM>,\n TextChannelMixin<ChannelType.GroupDM>,\n ChannelOwnerMixin<ChannelType.GroupDM>,\n GroupDMMixin<ChannelType.GroupDM>,\n ]\n > {}\n\n/**\n * A group direct message channel.\n */\nexport class GroupDMChannel extends BaseGroupDMChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(data: ChannelDataType<ChannelType.GroupDM>, relations: ChannelRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n}\n\nMixin(GroupDMChannel, [\n StructureMixin,\n BaseChannelMixin,\n DMChannelMixin,\n TextChannelMixin,\n ChannelOwnerMixin,\n GroupDMMixin,\n]);\n","import { MediaChannel as BaseMediaChannel } from \"@discordjs/structures\";\nimport type { ChannelType } from \"discord-api-types/v10\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\nimport { ChannelPermissionMixin } from \"./mixins/ChannelPermissionMixin.js\";\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\nimport { ChannelThreadsMixin } from \"./mixins/ChannelThreadsMixin.js\";\nimport { ChannelWebhooksMixin } from \"./mixins/ChannelWebhooksMixin.js\";\nimport { ChannelTopicMixin } from \"./mixins/ChannelTopicMixin.js\";\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\nimport { ThreadOnlyChannelMixin } from \"./mixins/ThreadOnlyChannelMixin.js\";\n\nexport interface MediaChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.GuildMedia>, ChannelRelations>,\n MixinTypes<\n BaseMediaChannel,\n [\n BaseChannelMixin<ChannelType.GuildMedia>,\n GuildChannelMixin<ChannelType.GuildMedia>,\n ChannelParentMixin<ChannelType.GuildMedia>,\n ChannelPermissionMixin<ChannelType.GuildMedia>,\n ChannelSlowmodeMixin<ChannelType.GuildMedia>,\n ChannelTopicMixin<ChannelType.GuildMedia>,\n ThreadOnlyChannelMixin<ChannelType.GuildMedia>,\n ChannelWebhooksMixin<ChannelType.GuildMedia>,\n ChannelThreadsMixin<ChannelType.GuildMedia>,\n ]\n > {}\n\n/**\n * A guild media channel.\n */\nexport class MediaChannel extends BaseMediaChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(\n data: ChannelDataType<ChannelType.GuildMedia>,\n relations: ChannelRelations = {},\n ) {\n super(data);\n initStructure(this, data, relations);\n }\n}\n\nMixin(MediaChannel, [\n StructureMixin,\n BaseChannelMixin,\n GuildChannelMixin,\n ChannelParentMixin,\n ChannelPermissionMixin,\n ChannelSlowmodeMixin,\n ChannelTopicMixin,\n ThreadOnlyChannelMixin,\n ChannelWebhooksMixin,\n ChannelThreadsMixin,\n]);\n","import { PrivateThreadChannel as BasePrivateThreadChannel } from \"@discordjs/structures\";\nimport type { ChannelType } from \"discord-api-types/v10\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelOwnerMixin } from \"./mixins/ChannelOwnerMixin.js\";\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\nimport { ThreadChannelMixin } from \"./mixins/ThreadChannelMixin.js\";\n\nexport interface PrivateThreadChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.PrivateThread>, ChannelRelations>,\n MixinTypes<\n BasePrivateThreadChannel,\n [\n BaseChannelMixin<ChannelType.PrivateThread>,\n TextChannelMixin<ChannelType.PrivateThread>,\n GuildChannelMixin<ChannelType.PrivateThread>,\n ChannelOwnerMixin<ChannelType.PrivateThread>,\n ChannelParentMixin<ChannelType.PrivateThread>,\n ChannelSlowmodeMixin<ChannelType.PrivateThread>,\n ThreadChannelMixin<ChannelType.PrivateThread>,\n ]\n > {}\n\n/**\n * A private thread.\n */\nexport class PrivateThreadChannel extends BasePrivateThreadChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(\n data: ChannelDataType<ChannelType.PrivateThread>,\n relations: ChannelRelations = {},\n ) {\n super(data);\n initStructure(this, data, relations);\n }\n}\n\nMixin(PrivateThreadChannel, [\n StructureMixin,\n BaseChannelMixin,\n TextChannelMixin,\n GuildChannelMixin,\n ChannelOwnerMixin,\n ChannelParentMixin,\n ChannelSlowmodeMixin,\n ThreadChannelMixin,\n]);\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData } from \"../../Structure.js\";\nimport { editChannel } from \"./edit.js\";\n\ntype Data = { applied_tags?: string[] };\n\nexport interface AppliedTagsMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the tags applied to a thread of a forum or media channel.\n */\nexport class AppliedTagsMixin<Type extends ChannelType = ChannelType> {\n public get appliedTagIds(): readonly string[] {\n return (this[kData] as Data).applied_tags ?? [];\n }\n\n /**\n * Sets the tags of the thread.\n *\n * @param appliedTags The IDs of the tags.\n * @param reason The reason for the audit log.\n */\n public setAppliedTags(appliedTags: readonly string[], reason?: string): Promise<this> {\n return editChannel(this, { appliedTags, reason });\n }\n}\n","import { PublicThreadChannel as BasePublicThreadChannel } from \"@discordjs/structures\";\nimport type { ChannelType } from \"discord-api-types/v10\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, StructureMixin } from \"../Structure.js\";\nimport { AppliedTagsMixin } from \"./mixins/AppliedTagsMixin.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelOwnerMixin } from \"./mixins/ChannelOwnerMixin.js\";\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\nimport { ThreadChannelMixin } from \"./mixins/ThreadChannelMixin.js\";\n\nexport interface PublicThreadChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.PublicThread>, ChannelRelations>,\n MixinTypes<\n BasePublicThreadChannel,\n [\n BaseChannelMixin<ChannelType.PublicThread>,\n TextChannelMixin<ChannelType.PublicThread>,\n GuildChannelMixin<ChannelType.PublicThread>,\n ChannelOwnerMixin<ChannelType.PublicThread>,\n ChannelParentMixin<ChannelType.PublicThread>,\n ChannelSlowmodeMixin<ChannelType.PublicThread>,\n ThreadChannelMixin<ChannelType.PublicThread>,\n AppliedTagsMixin<ChannelType.PublicThread>,\n ]\n > {}\n\n/**\n * A public thread.\n */\nexport class PublicThreadChannel extends BasePublicThreadChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(\n data: ChannelDataType<ChannelType.PublicThread>,\n relations: ChannelRelations = {},\n ) {\n super(data);\n initStructure(this, data, relations);\n }\n}\n\nMixin(PublicThreadChannel, [\n StructureMixin,\n BaseChannelMixin,\n TextChannelMixin,\n GuildChannelMixin,\n ChannelOwnerMixin,\n ChannelParentMixin,\n ChannelSlowmodeMixin,\n ThreadChannelMixin,\n AppliedTagsMixin,\n]);\n","import type { ChannelType, VideoQualityMode } from \"discord-api-types/v10\";\nimport type { Channel } from \"../Channel.js\";\nimport { kData } from \"../../Structure.js\";\nimport { editChannel } from \"./edit.js\";\n\ntype Data = {\n bitrate?: number;\n user_limit?: number;\n rtc_region?: string | null;\n video_quality_mode?: number;\n};\n\nexport interface VoiceChannelMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the fields of voice and stage channels.\n */\nexport class VoiceChannelMixin<Type extends ChannelType = ChannelType> {\n public get bitrate(): number {\n return (this[kData] as Data).bitrate ?? 0;\n }\n\n /**\n * The user limit, `0` when unlimited.\n */\n public get userLimit(): number {\n return (this[kData] as Data).user_limit ?? 0;\n }\n\n /**\n * The voice region, `null` for automatic.\n */\n public get rtcRegion(): string | null {\n return (this[kData] as Data).rtc_region ?? null;\n }\n\n public get videoQualityMode(): number | null {\n return (this[kData] as Data).video_quality_mode ?? null;\n }\n\n public setBitrate(bitrate: number, reason?: string): Promise<this> {\n return editChannel(this, { bitrate, reason });\n }\n\n /**\n * Sets the user limit.\n *\n * @param userLimit The user limit, `0` for none.\n * @param reason The reason for the audit log.\n */\n public setUserLimit(userLimit: number, reason?: string): Promise<this> {\n return editChannel(this, { userLimit, reason });\n }\n\n /**\n * Sets the voice region.\n *\n * @param rtcRegion The region, `null` for automatic.\n * @param reason The reason for the audit log.\n */\n public setRTCRegion(rtcRegion: string | null, reason?: string): Promise<this> {\n return editChannel(this, { rtcRegion, reason });\n }\n\n public setVideoQualityMode(videoQualityMode: VideoQualityMode, reason?: string): Promise<this> {\n return editChannel(this, { videoQualityMode, reason });\n }\n}\n","import { StageChannel as BaseStageChannel } from \"@discordjs/structures\";\nimport { DiscordAPIError } from \"@discordjs/rest\";\nimport type { ChannelType } from \"discord-api-types/v10\";\nimport type { StageInstanceCreateOptions } from \"../../managers/StageInstanceManager.js\";\nimport type { StageInstance } from \"../stageInstances/StageInstance.js\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, kRelations, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\nimport { ChannelPermissionMixin } from \"./mixins/ChannelPermissionMixin.js\";\nimport { ChannelWebhooksMixin } from \"./mixins/ChannelWebhooksMixin.js\";\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\nimport { VoiceChannelMixin } from \"./mixins/VoiceChannelMixin.js\";\n\nexport interface StageChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.GuildStageVoice>, ChannelRelations>,\n MixinTypes<\n BaseStageChannel,\n [\n BaseChannelMixin<ChannelType.GuildStageVoice>,\n TextChannelMixin<ChannelType.GuildStageVoice>,\n GuildChannelMixin<ChannelType.GuildStageVoice>,\n ChannelParentMixin<ChannelType.GuildStageVoice>,\n ChannelPermissionMixin<ChannelType.GuildStageVoice>,\n ChannelSlowmodeMixin<ChannelType.GuildStageVoice>,\n VoiceChannelMixin<ChannelType.GuildStageVoice>,\n ChannelWebhooksMixin<ChannelType.GuildStageVoice>,\n ]\n > {}\n\n/**\n * A guild stage channel.\n */\nexport class StageChannel extends BaseStageChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(\n data: ChannelDataType<ChannelType.GuildStageVoice>,\n relations: ChannelRelations = {},\n ) {\n super(data);\n initStructure(this, data, relations);\n }\n\n /**\n * The live stage of the channel, from the cache, like discord.js's `StageChannel#stageInstance`: `null` when the\n * stage is not live, when it is not cached, or when the channel was not built by a manager.\n *\n * @remarks\n * Its own `channel` is this channel, and its scheduled event is not resolved: use\n * {@link StageChannel.fetchStageInstance} for the stage with every relation.\n */\n public get stageInstance(): StageInstance | null {\n return this[kRelations].stageInstance ?? null;\n }\n\n /**\n * Fetches the live stage of the channel, `null` when the stage is not live.\n */\n public async fetchStageInstance(): Promise<StageInstance | null> {\n const { guildId } = this;\n if (!guildId) return null;\n try {\n return await this.client.guilds.stageInstances(guildId).fetch(this.id);\n } catch (error) {\n // Discord answers 404 (Unknown Stage Instance) when the stage is not live.\n if (error instanceof DiscordAPIError && error.status === 404) return null;\n throw error;\n }\n }\n\n /**\n * Starts a stage in the channel.\n *\n * @param options The topic and privacy level, and whether to notify the guild.\n */\n public createStageInstance(options: StageInstanceCreateOptions): Promise<StageInstance> {\n const { guildId } = this;\n if (!guildId) return Promise.reject(new Error(`Channel ${this.id} has no known guild`));\n return this.client.guilds.stageInstances(guildId).create(this.id, options);\n }\n}\n\nMixin(StageChannel, [\n StructureMixin,\n BaseChannelMixin,\n TextChannelMixin,\n GuildChannelMixin,\n ChannelParentMixin,\n ChannelPermissionMixin,\n ChannelSlowmodeMixin,\n VoiceChannelMixin,\n ChannelWebhooksMixin,\n]);\n","import { TextChannel as BaseTextChannel } from \"@discordjs/structures\";\nimport type { ChannelType } from \"discord-api-types/v10\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\nimport { ChannelPermissionMixin } from \"./mixins/ChannelPermissionMixin.js\";\nimport { ChannelThreadsMixin } from \"./mixins/ChannelThreadsMixin.js\";\nimport { ChannelWebhooksMixin } from \"./mixins/ChannelWebhooksMixin.js\";\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\nimport { ChannelTopicMixin } from \"./mixins/ChannelTopicMixin.js\";\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\n\nexport interface TextChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.GuildText>, ChannelRelations>,\n MixinTypes<\n BaseTextChannel,\n [\n BaseChannelMixin<ChannelType.GuildText>,\n TextChannelMixin<ChannelType.GuildText>,\n GuildChannelMixin<ChannelType.GuildText>,\n ChannelParentMixin<ChannelType.GuildText>,\n ChannelPermissionMixin<ChannelType.GuildText>,\n ChannelSlowmodeMixin<ChannelType.GuildText>,\n ChannelTopicMixin<ChannelType.GuildText>,\n ChannelWebhooksMixin<ChannelType.GuildText>,\n ChannelThreadsMixin<ChannelType.GuildText>,\n ]\n > {}\n\n/**\n * A guild text channel.\n */\nexport class TextChannel extends BaseTextChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(\n data: ChannelDataType<ChannelType.GuildText>,\n relations: ChannelRelations = {},\n ) {\n super(data);\n initStructure(this, data, relations);\n }\n}\n\nMixin(TextChannel, [\n StructureMixin,\n BaseChannelMixin,\n TextChannelMixin,\n GuildChannelMixin,\n ChannelParentMixin,\n ChannelPermissionMixin,\n ChannelSlowmodeMixin,\n ChannelTopicMixin,\n ChannelWebhooksMixin,\n ChannelThreadsMixin,\n]);\n","import { VoiceChannel as BaseVoiceChannel } from \"@discordjs/structures\";\nimport {\n type ChannelType,\n type RESTPostAPISoundboardSendSoundJSONBody,\n} from \"discord-api-types/v10\";\nimport type { SoundboardSound } from \"../soundboards/SoundboardSound.js\";\nimport type { ChannelDataType, ChannelRelations } from \"./Channel.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport { initStructure, StructureMixin } from \"../Structure.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\nimport { ChannelPermissionMixin } from \"./mixins/ChannelPermissionMixin.js\";\nimport { ChannelWebhooksMixin } from \"./mixins/ChannelWebhooksMixin.js\";\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\nimport { VoiceChannelMixin } from \"./mixins/VoiceChannelMixin.js\";\n\nexport interface VoiceChannel\n extends\n StructureMixin<ChannelDataType<ChannelType.GuildVoice>, ChannelRelations>,\n MixinTypes<\n BaseVoiceChannel,\n [\n BaseChannelMixin<ChannelType.GuildVoice>,\n TextChannelMixin<ChannelType.GuildVoice>,\n GuildChannelMixin<ChannelType.GuildVoice>,\n ChannelParentMixin<ChannelType.GuildVoice>,\n ChannelPermissionMixin<ChannelType.GuildVoice>,\n ChannelSlowmodeMixin<ChannelType.GuildVoice>,\n VoiceChannelMixin<ChannelType.GuildVoice>,\n ChannelWebhooksMixin<ChannelType.GuildVoice>,\n ]\n > {}\n\n/**\n * A guild voice channel.\n */\nexport class VoiceChannel extends BaseVoiceChannel {\n /**\n * @param data The raw channel.\n * @param relations The guild as resolved from the cache, by `client.channels` or `client.threads`.\n */\n public constructor(\n data: ChannelDataType<ChannelType.GuildVoice>,\n relations: ChannelRelations = {},\n ) {\n super(data);\n initStructure(this, data, relations);\n }\n\n /**\n * Plays a soundboard sound in the channel. The bot must be connected to it.\n *\n * @param sound The sound, or its ID with the ID of its guild (none for a default sound).\n */\n public async sendSoundboardSound(\n sound: SoundboardSound | { soundId: string; guildId?: string | null },\n ): Promise<void> {\n const body: RESTPostAPISoundboardSendSoundJSONBody = {\n sound_id: sound.soundId,\n source_guild_id: sound.guildId ?? undefined,\n };\n await this.client.api.channels.sendSoundboardSound(this.id, body);\n }\n}\n\nMixin(VoiceChannel, [\n StructureMixin,\n BaseChannelMixin,\n TextChannelMixin,\n GuildChannelMixin,\n ChannelParentMixin,\n ChannelPermissionMixin,\n ChannelSlowmodeMixin,\n VoiceChannelMixin,\n ChannelWebhooksMixin,\n]);\n","import { StageInstance as BaseStageInstance } from \"@discordjs/structures\";\nimport type { APIStageInstance, StageInstancePrivacyLevel } from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { StageInstanceEditOptions } from \"../../managers/StageInstanceManager.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport type { GuildScheduledEvent } from \"../guilds/GuildScheduledEvent.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport {\n initStructure,\n kPatch,\n kPatchRelations,\n kRelations,\n snowflakeTimestamp,\n StructureMixin,\n} from \"../Structure.js\";\n\n/**\n * The relations of a {@link StageInstance}, resolved from the cache by the guild's stage instance manager.\n */\nexport interface StageInstanceRelations {\n guild?: Guild | null;\n channel?: AnyChannel | null;\n guildScheduledEvent?: GuildScheduledEvent | null;\n}\n\nexport interface StageInstance extends StructureMixin<APIStageInstance, StageInstanceRelations> {}\n\n/**\n * A live stage, the topic of a stage channel while it is open: `@discordjs/structures`' `StageInstance`, with its\n * guild and channel, and actions through the client.\n */\nexport class StageInstance extends BaseStageInstance {\n /**\n * @param data The raw stage instance.\n * @param relations The guild and channel as resolved from the cache, by the guild's stage instance manager.\n */\n public constructor(data: APIStageInstance, relations: StageInstanceRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n public get channel(): AnyChannel | null {\n return this[kRelations].channel ?? null;\n }\n\n /**\n * The scheduled event the stage belongs to, from the cache, like discord.js's\n * `StageInstance#guildScheduledEvent`: `null` when it has none, when it is not cached, or when the stage was not\n * built by its guild's stage instance manager.\n */\n public get guildScheduledEvent(): GuildScheduledEvent | null {\n return this[kRelations].guildScheduledEvent ?? null;\n }\n\n public [kPatchRelations](data: object): void {\n this.dropChangedRelations(data, { guildScheduledEvent: \"guild_scheduled_event_id\" });\n }\n\n public override get createdTimestamp(): number {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n\n /**\n * Fetches the scheduled event the stage belongs to, if any.\n */\n public async fetchGuildScheduledEvent(): Promise<GuildScheduledEvent | null> {\n const { guildScheduledEventId } = this;\n return guildScheduledEventId\n ? this.client.guilds.scheduledEvents(this.guildId).fetch(guildScheduledEventId)\n : null;\n }\n\n /**\n * Edits the stage.\n *\n * @param options The topic and privacy level, and the reason for the audit log.\n */\n public async edit(options: StageInstanceEditOptions): Promise<this> {\n const instance = await this.client.guilds\n .stageInstances(this.guildId)\n .edit(this.channelId, options);\n return this[kPatch](instance.toJSON());\n }\n\n public setTopic(topic: string, reason?: string): Promise<this> {\n return this.edit({ topic, reason });\n }\n\n public setPrivacyLevel(privacyLevel: StageInstancePrivacyLevel, reason?: string): Promise<this> {\n return this.edit({ privacyLevel, reason });\n }\n\n /**\n * Ends the stage.\n *\n * @param reason The reason for the audit log.\n */\n public async delete(reason?: string): Promise<this> {\n await this.client.guilds.stageInstances(this.guildId).delete(this.channelId, reason);\n return this;\n }\n}\n\nMixin(StageInstance, [StructureMixin]);\n","import type { Awaitable } from \"@wolfstar/plugin-cache\";\nimport type { StructureMixin } from \"../structures/Structure.js\";\n\n/**\n * The raw API data a {@link StructureMixin | structure} wraps.\n */\nexport type RawAPIType<Value extends StructureMixin<object>> =\n Value extends StructureMixin<infer Type> ? Type : never;\n\n/**\n * A function building a {@link StructureMixin | structure} out of its raw API data.\n */\nexport type StructureCreator<\n Value extends StructureMixin<object>,\n Raw extends RawAPIType<Value> = RawAPIType<Value>,\n> = (data: Raw) => Value;\n\n/**\n * Whether an {@link Awaitable} is a promise, rather than the value itself.\n *\n * @internal\n */\nexport function isPromiseLike<T>(value: Awaitable<T>): value is Promise<T> {\n return typeof (value as { then?: unknown } | null | undefined)?.then === \"function\";\n}\n\n/**\n * Waits for a list of {@link Awaitable}s like `Promise.all`, then calls a function with their values. Unlike\n * `Promise.all`, it stays synchronous when none of them is a promise, which is what lets a synchronous cache build\n * structures without awaiting them.\n *\n * @param values The values, some of which may be promises.\n * @param callback The function to call with the values.\n * @internal\n */\nexport function whenAll<const T extends readonly unknown[], R>(\n values: T,\n callback: (values: { -readonly [Index in keyof T]: Awaited<T[Index]> }) => Awaitable<R>,\n): Awaitable<R> {\n return values.some(isPromiseLike)\n ? Promise.all(values).then(callback)\n : callback(values as { -readonly [Index in keyof T]: Awaited<T[Index]> });\n}\n\n/**\n * Picks the cached structures of some IDs, in their order, skipping the ones that are not cached: the equivalent of\n * the collections discord.js fills from its caches, e.g. `MessageMentions#channels`.\n *\n * @param ids The IDs.\n * @param cached The cached structures, by ID.\n * @internal\n */\nexport function pickCached<Value>(\n ids: readonly string[],\n cached: ReadonlyMap<string, Value> | undefined,\n): Map<string, Value> {\n const picked = new Map<string, Value>();\n for (const id of ids) {\n const value = cached?.get(id);\n if (value) picked.set(id, value);\n }\n\n return picked;\n}\n\n/**\n * Reads the cached structures of some IDs, synchronously when every read is, skipping duplicates and the IDs that\n * are not cached. The {@link Awaitable} counterpart of discord.js's collections filled from its caches.\n *\n * @param ids The IDs.\n * @param get Reads the structure of an ID.\n * @internal\n */\nexport function whenCachedMap<Value>(\n ids: Iterable<string>,\n get: (id: string) => Awaitable<Value | null | undefined>,\n): Awaitable<Map<string, Value>> {\n const unique = [...new Set(ids)];\n return whenAll(unique.map(get), (values) => {\n const map = new Map<string, Value>();\n for (const [index, value] of values.entries()) if (value) map.set(unique[index]!, value);\n return map;\n });\n}\n","import {\n isIterableCache,\n mergeValues,\n type Awaitable,\n type CacheEntityName,\n type CacheEntityTypes,\n type EntityCache,\n type IterableEntityCache,\n} from \"@wolfstar/plugin-cache\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport type { Guild } from \"../structures/guilds/Guild.js\";\nimport { bindClient, type StructureMixin } from \"../structures/Structure.js\";\nimport { isPromiseLike, whenAll } from \"../util/cache.js\";\nimport type { CacheErrorContext } from \"../util/events.js\";\n\n/**\n * The options to fetch an entity with.\n */\nexport interface FetchOptions {\n /**\n * Whether to skip the cache lookup and always hit the API.\n *\n * @default false\n */\n force?: boolean;\n /**\n * Whether to store the entity fetched from the API in the cache.\n *\n * @default true\n */\n cache?: boolean;\n}\n\n/**\n * The options of {@link CachedManager._add}.\n */\nexport interface AddOptions {\n /**\n * The cache key of the entity, when it cannot be derived from its data.\n */\n key?: string;\n}\n\n/**\n * The base class of every manager, the `BaseManager` of the discord.js RFC #11426: it reads raw data from one of the\n * client's entity caches, falls back to the REST API when asked to, and wraps the result in a\n * {@link StructureMixin | structure} with {@link CachedManager.construct}.\n *\n * @remarks\n * The cache only ever holds raw API data, building structures is always the manager's job. Without a store for its\n * entity (see the client's `makeCache`), `get` always resolves to `undefined` and `fetch` always hits the API.\n *\n * A failing store (e.g. Redis being unreachable) emits `cacheError` and, with the client's default\n * `cacheErrors: \"miss\"`, is treated as a cache miss.\n *\n * Every method is asynchronous since the cache can be Redis, except {@link CachedManager.cached}, which reads a\n * synchronous cache (`createInMemoryCache`) without awaiting it.\n *\n * Like discord.js's `CachedManager`, every payload coming from the API goes through {@link CachedManager._add}, which\n * patches the cached entry and builds the structure. Structures are built by {@link CachedManager.hydrate}, which\n * resolves their relations (a message's author, a member's user, ...) from the cache, so they carry the latest known\n * data rather than the copy embedded in the payload.\n *\n * @typeParam Name The name of the entity cache this manager reads from.\n * @typeParam Value The structure this manager builds.\n * @typeParam Args The arguments identifying an entity, e.g. `[id]` or `[guildId, userId]`.\n */\nexport abstract class CachedManager<\n Name extends CacheEntityName,\n Value extends StructureMixin<object>,\n Args extends readonly string[],\n> {\n /**\n * The client this manager belongs to.\n */\n public readonly client: GatewayClient;\n\n /**\n * The name of the entity cache this manager reads from.\n */\n public readonly entity: Name;\n\n public constructor(client: GatewayClient, entity: Name) {\n this.client = client;\n this.entity = entity;\n }\n\n /**\n * The entity cache this manager reads from, or `undefined` when the client has no cache.\n */\n public get cache(): EntityCache<CacheEntityTypes[Name]> | undefined {\n return this.client.cache?.[this.entity] as EntityCache<CacheEntityTypes[Name]> | undefined;\n }\n\n /**\n * Gets an entity from the cache.\n *\n * @param args The arguments identifying the entity.\n * @returns The entity, or `undefined` if it is not cached.\n */\n public async get(...args: Args): Promise<Value | undefined> {\n return this._get(...args);\n }\n\n /**\n * Gets an entity from a synchronous cache, without awaiting it: the synchronous counterpart of\n * {@link CachedManager.get}, for hot paths such as message filters.\n *\n * @remarks\n * It builds the same structure as `get`, relations included, so the entity caches they are read from must be\n * synchronous too, which they all are with `createInMemoryCache`. `manager.cache?.synchronous` tells whether it can\n * be called.\n *\n * An asynchronous cache throws rather than returning `undefined`: it cannot tell whether the entity is cached, and\n * reporting a miss would silently skip whatever the caller does with cached entities, e.g. a filter.\n *\n * @example\n * ```typescript\n * const member = client.members.cached(guildId, userId);\n * ```\n *\n * @param args The arguments identifying the entity.\n * @returns The entity, or `undefined` if it is not cached or the client has no cache.\n * @throws {TypeError} When the entity cache, or one of the caches its relations are read from, is asynchronous.\n */\n public cached(...args: Args): Value | undefined {\n const { cache } = this;\n if (cache === undefined) return undefined;\n if (cache.synchronous !== true) {\n throw new TypeError(`The ${this.entity} cache is asynchronous, use get instead of cached`);\n }\n\n const value = this._get(...args);\n if (isPromiseLike(value)) {\n // Nothing awaits the promise anymore, so its rejection must not go unhandled.\n value.catch(() => undefined);\n throw new TypeError(\n `The relations of the ${this.entity} cache are read from an asynchronous cache, use get instead of cached`,\n );\n }\n\n return value;\n }\n\n /**\n * Gets an entity from the cache, synchronously when every cache it reads is: the {@link Awaitable} counterpart of\n * {@link CachedManager.get}, which both `get` and {@link CachedManager.cached} rely on.\n *\n * @param args The arguments identifying the entity.\n * @internal\n */\n public _get(...args: Args): Awaitable<Value | undefined> {\n return this.getByKey(this.resolveKey(...args));\n }\n\n /**\n * Resolves a structure or a cache key to a structure, like discord.js's `DataManager#resolve`.\n *\n * @param value A structure, returned as is, or the cache key of an entity (its ID, for managers keyed by ID).\n * @returns The structure, or `null` if the key is not cached.\n */\n public async resolve(value: Value | string): Promise<Value | null> {\n if (typeof value !== \"string\") return value;\n return (await this.getByKey(value)) ?? null;\n }\n\n /**\n * Adds an API payload to the cache, patching the cached entry with it, and builds its structure. The counterpart of\n * discord.js's `CachedManager#_add`, asynchronous since the cache can be remote.\n *\n * @remarks\n * Like discord.js's `_patch`, the payload is shallowly merged into the cached entry, so the fields a partial payload\n * lacks keep their cached value. With `cache` set to `false`, the merged entry is built but not written.\n *\n * The merge is a read followed by a write, not an atomic operation: on a shared cache, a write landing in between\n * (another process, or a dispatch outside the guild's queue) is overwritten. `@wolfstar/plugin-cache` merges partial\n * dispatches the same way, and the fields at stake are refreshed by the next payload of the entity.\n *\n * @param data The raw data.\n * @param cache Whether to write the merged entry to the cache.\n * @param options The cache key, when it cannot be derived from the data.\n * @internal\n */\n public async _add(\n data: CacheEntityTypes[Name],\n cache = true,\n { key = this.keyOf(data) }: AddOptions = {},\n ): Promise<Value> {\n const store = this.cache;\n if (store === undefined) return this.hydrate(data);\n\n if (!cache) {\n const existing = await this.guard(\"get\", key, () => store.get(key), undefined);\n return this.hydrate(mergeValues(existing, data));\n }\n\n const { added } = await this.guard(\"upsert\", key, () => store.upsert(key, data), {\n added: data,\n });\n return this.hydrate(added);\n }\n\n /**\n * Gets the cached structure of the entity raw data describes, or builds one from the data when it is not cached.\n * Used to resolve the relations of other structures, e.g. a message's author.\n *\n * @param data The raw data.\n */\n public async resolveData(data: CacheEntityTypes[Name]): Promise<Value> {\n return this._resolveData(data);\n }\n\n /**\n * The {@link Awaitable} counterpart of {@link CachedManager.resolveData}, synchronous when every cache it reads is.\n *\n * @param data The raw data.\n * @internal\n */\n public _resolveData(data: CacheEntityTypes[Name]): Awaitable<Value> {\n return whenAll([this.getByKey(this.keyOf(data))], ([cached]) => cached ?? this.build(data));\n }\n\n /**\n * Gets a guild from the cache, to resolve the `guild` of a structure. Synchronous when the guild cache is.\n *\n * @param guildId The ID of the guild, if the structure belongs to one.\n * @remarks\n * The guild does not resolve its own channel relations, see `GuildManager._getShallow`.\n *\n * @returns The guild, or `null` when there is no ID or the guild is not cached.\n */\n protected cachedGuild(guildId: string | null | undefined): Awaitable<Guild | null> {\n return guildId\n ? whenAll([this.client.guilds._getShallow(guildId)], ([guild]) => guild ?? null)\n : null;\n }\n\n /**\n * Builds the structure of raw data, resolving its relations from the cache. Without relations to resolve, the same\n * as {@link CachedManager.construct}.\n *\n * @param data The raw data.\n */\n public async hydrate(data: CacheEntityTypes[Name]): Promise<Value> {\n return this.build(data);\n }\n\n /**\n * The {@link Awaitable} counterpart of {@link CachedManager.hydrate}, synchronous when every cache the relations\n * are read from is. Managers resolving relations override this one, so `hydrate` and\n * {@link CachedManager.cached} build the same structures.\n *\n * @param data The raw data.\n * @internal\n */\n public _hydrate(data: CacheEntityTypes[Name]): Awaitable<Value> {\n return this.construct(data);\n }\n\n /**\n * Gets an entity from the cache, fetching it from the API (and caching it) on a cache miss.\n *\n * @example\n * ```typescript\n * await client.users.fetch(userId); // cache first\n * await client.users.fetch(userId, { force: true }); // always the API\n * await client.users.fetch(userId, { force: true, cache: false }); // the API, without storing the result\n * ```\n *\n * @param args The arguments identifying the entity, optionally followed by {@link FetchOptions}.\n */\n public async fetch(...args: [...Args] | [...Args, FetchOptions]): Promise<Value> {\n const ids = args.slice(0, this.resolveKey.length) as unknown as Args;\n const { force = false, cache = true } = (args[this.resolveKey.length] ?? {}) as FetchOptions;\n\n if (!force) {\n const cached = await this.get(...ids);\n if (cached) return cached;\n }\n\n const raw = await this.fetchRaw(...ids);\n return this._add(raw, cache, { key: this.resolveKey(...ids) });\n }\n\n /**\n * Fetches an entity from the API, bypassing and then updating the cache. Same as `fetch(...args, { force: true })`.\n *\n * @param args The arguments identifying the entity.\n */\n public refresh(...args: Args): Promise<Value> {\n return this.fetch(...args, { force: true });\n }\n\n /**\n * Wraps raw data in this manager's structure: the RFC's `StructureCreator`, which lives on the manager since the\n * cache only holds raw data.\n *\n * @param data The raw data.\n */\n public abstract construct(data: CacheEntityTypes[Name]): Value;\n\n /**\n * Wraps raw data in this manager's structure.\n *\n * @param data The raw data.\n * @deprecated Use {@link CachedManager.construct}.\n */\n public createStructure(data: CacheEntityTypes[Name]): Value {\n return this.construct(data);\n }\n\n /**\n * Gets the cache key of raw data.\n *\n * @param data The raw data.\n */\n public abstract keyOf(data: CacheEntityTypes[Name]): string;\n\n /**\n * Gets the cache key of an entity.\n *\n * @param args The arguments identifying the entity.\n */\n public abstract resolveKey(...args: Args): string;\n\n /**\n * Fetches the raw data of an entity from the API.\n *\n * @param args The arguments identifying the entity.\n */\n protected abstract fetchRaw(...args: Args): Promise<CacheEntityTypes[Name]>;\n\n /**\n * Writes raw data to the cache.\n *\n * @param key The cache key of the entity.\n * @param raw The raw data of the entity.\n */\n protected async storeRaw(key: string, raw: CacheEntityTypes[Name]): Promise<void> {\n const { cache } = this;\n if (cache) await this.guard(\"set\", key, () => cache.set(key, raw), undefined);\n }\n\n /**\n * Gets this manager's store when it can enumerate its entries, for the `listCached` methods.\n *\n * @returns The store, or `undefined` when this entity is not cached.\n * @throws {TypeError} When the store cannot enumerate its entries.\n */\n protected iterableCache(): IterableEntityCache<CacheEntityTypes[Name]> | undefined {\n const { cache } = this;\n if (cache === undefined) return undefined;\n if (!isIterableCache(cache)) {\n throw new TypeError(\n `The ${this.entity} cache cannot enumerate its entries (it has no keys/values/entries)`,\n );\n }\n\n return cache;\n }\n\n /**\n * Gets an entity from the cache by its key, synchronously when every cache it reads is.\n *\n * @param key The cache key of the entity.\n */\n protected getByKey(key: string): Awaitable<Value | undefined> {\n const { cache } = this;\n return whenAll(\n [cache ? this.guard(\"get\", key, () => cache.get(key), undefined) : undefined],\n ([raw]) => (raw === undefined ? undefined : this.build(raw)),\n );\n }\n\n /**\n * Runs a cache operation, reporting its failure through `cacheError`. With the client's `cacheErrors: \"miss\"`, a\n * failure resolves to `fallback`, otherwise it is rethrown. Synchronous when the operation is.\n *\n * @param operation The operation, for `cacheError`.\n * @param key The key of the entry, for `cacheError`.\n * @param run Runs the operation.\n * @param fallback What a failure resolves to under `cacheErrors: \"miss\"`.\n */\n protected guard<T>(\n operation: CacheErrorContext[\"operation\"],\n key: string | null,\n run: () => Awaitable<T>,\n fallback: T,\n ): Awaitable<T> {\n const fail = (error: unknown): T => {\n this.client.emit(\"cacheError\", error, { entity: this.entity, key, operation });\n if (this.client.cacheErrors === \"throw\") throw error;\n return fallback;\n };\n\n try {\n const result = run();\n return isPromiseLike(result) ? result.catch(fail) : result;\n } catch (error) {\n return fail(error);\n }\n }\n\n /**\n * Builds the structure of raw data with {@link CachedManager._hydrate}, bound to this manager's client.\n *\n * @param data The raw data.\n */\n protected build(data: CacheEntityTypes[Name]): Awaitable<Value> {\n return whenAll([this._hydrate(data)], ([value]) => bindClient(value, this.client));\n }\n}\n\nexport {\n /**\n * The name of {@link CachedManager} in the discord.js RFC #11426.\n */\n CachedManager as BaseManager,\n};\n","import type { Awaitable, CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport { applyGatewayDispatch, stageInstanceKey, threadMemberKey } from \"@wolfstar/plugin-cache\";\nimport {\n ChannelType,\n GatewayDispatchEvents,\n GatewayOpcodes,\n type APIOverwrite,\n type GatewayDispatchPayload,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { AnnouncementChannel } from \"../structures/channels/AnnouncementChannel.js\";\nimport { AnnouncementThreadChannel } from \"../structures/channels/AnnouncementThreadChannel.js\";\nimport { BaseChannel } from \"../structures/channels/BaseChannel.js\";\nimport { isThreadChannelType, type ChannelRelations } from \"../structures/channels/Channel.js\";\nimport { CategoryChannel } from \"../structures/channels/CategoryChannel.js\";\nimport { DMChannel } from \"../structures/channels/DMChannel.js\";\nimport { ForumChannel } from \"../structures/channels/ForumChannel.js\";\nimport { GroupDMChannel } from \"../structures/channels/GroupDMChannel.js\";\nimport { MediaChannel } from \"../structures/channels/MediaChannel.js\";\nimport { PrivateThreadChannel } from \"../structures/channels/PrivateThreadChannel.js\";\nimport { PublicThreadChannel } from \"../structures/channels/PublicThreadChannel.js\";\nimport { StageChannel } from \"../structures/channels/StageChannel.js\";\nimport { TextChannel } from \"../structures/channels/TextChannel.js\";\nimport { VoiceChannel } from \"../structures/channels/VoiceChannel.js\";\nimport type { Guild } from \"../structures/guilds/Guild.js\";\nimport { StageInstance } from \"../structures/stageInstances/StageInstance.js\";\nimport { bindClient } from \"../structures/Structure.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { resolveId, toChannelBody, type GuildChannelEditOptions } from \"../util/channels.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\nimport { PermissionOverwriteManager } from \"./PermissionOverwriteManager.js\";\n\n/**\n * Any of the channel structures {@link ChannelManager} builds.\n */\nexport type AnyChannel =\n | AnnouncementChannel\n | AnnouncementThreadChannel\n | BaseChannel\n | CategoryChannel\n | DMChannel\n | ForumChannel\n | GroupDMChannel\n | MediaChannel\n | PrivateThreadChannel\n | PublicThreadChannel\n | StageChannel\n | TextChannel\n | VoiceChannel;\n\n/**\n * Builds the channel structure matching the type of a raw channel, {@link BaseChannel} for unknown types.\n *\n * @param data The raw channel.\n */\nexport function createChannel(\n data: CacheEntityTypes[\"channels\"],\n relations: ChannelRelations = {},\n): AnyChannel {\n switch (data.type) {\n case ChannelType.AnnouncementThread:\n return new AnnouncementThreadChannel(data, relations);\n case ChannelType.DM:\n return new DMChannel(data, relations);\n case ChannelType.GroupDM:\n return new GroupDMChannel(data, relations);\n case ChannelType.GuildAnnouncement:\n return new AnnouncementChannel(data, relations);\n case ChannelType.GuildCategory:\n return new CategoryChannel(data, relations);\n case ChannelType.GuildForum:\n return new ForumChannel(data, relations);\n case ChannelType.GuildMedia:\n return new MediaChannel(data, relations);\n case ChannelType.GuildStageVoice:\n return new StageChannel(data, relations);\n case ChannelType.GuildText:\n return new TextChannel(data, relations);\n case ChannelType.GuildVoice:\n return new VoiceChannel(data, relations);\n case ChannelType.PrivateThread:\n return new PrivateThreadChannel(data, relations);\n case ChannelType.PublicThread:\n return new PublicThreadChannel(data, relations);\n default:\n return new BaseChannel(data, relations);\n }\n}\n\n// The raw fields of a guild channel the managers read, whichever its type.\nfunction overwriteHolder(channel: AnyChannel): {\n guild_id?: string;\n parent_id?: string | null;\n permission_overwrites?: APIOverwrite[];\n} {\n return channel.toJSON() as never;\n}\n\n// A thread, its channel, and the channel's category: no parent chain is any longer.\nconst MaxParentDepth = 2;\n\n// Guild channels carry their guild's ID, except inside a `GUILD_CREATE`, where the cache adds it.\nfunction channelGuildId(data: CacheEntityTypes[\"channels\"]): string | undefined {\n return \"guild_id\" in data ? (data.guild_id ?? undefined) : undefined;\n}\n\n/**\n * Manages the channels known to the client, threads included.\n *\n * @remarks\n * Threads live in their own entity cache, managed by `client.threads`, which {@link ChannelManager.get} falls back\n * to, so a thread ID resolves like any other channel ID.\n */\nexport class ChannelManager extends CachedManager<\"channels\", AnyChannel, [channelId: string]> {\n public constructor(client: GatewayClient) {\n super(client, \"channels\");\n }\n\n public construct(data: CacheEntityTypes[\"channels\"]): AnyChannel {\n return createChannel(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"channels\"]): string {\n return data.id;\n }\n\n public override _hydrate(data: CacheEntityTypes[\"channels\"]): Awaitable<AnyChannel> {\n return whenAll([this.cachedGuild(channelGuildId(data))], ([guild]) =>\n this._hydrateInGuild(data, guild),\n );\n }\n\n /**\n * Builds a channel (or a thread) whose guild is already resolved, resolving its other relations from the cache: its\n * parent, within the same guild, the recipient of a direct message, the live stage of a stage channel, and whether\n * the bot joined a thread. Used by\n * `client.threads` and by the guild's own channel relations, which must not resolve the guild again.\n *\n * @param data The raw channel.\n * @param guild The guild of the channel, `null` outside of guilds or when it is not cached.\n * @param depth How many parents deep the channel is, which bounds the parent chain (a thread, its channel, and its\n * category) against a corrupted cache.\n * @internal\n */\n public _hydrateInGuild(\n data: CacheEntityTypes[\"channels\"],\n guild: Guild | null,\n depth = 0,\n ): Awaitable<AnyChannel> {\n const { client } = this;\n const parentId = \"parent_id\" in data ? data.parent_id : null;\n const recipient = data.type === ChannelType.DM ? data.recipients?.[0] : undefined;\n const guildId = channelGuildId(data) ?? guild?.id;\n const thread = isThreadChannelType(data.type);\n return whenAll(\n [\n parentId && depth < MaxParentDepth ? this.cache?.get(parentId) : undefined,\n recipient ? client.users._resolveData(recipient) : undefined,\n data.type === ChannelType.GuildStageVoice && guildId\n ? client.cache?.stageInstances?.get(stageInstanceKey(guildId, data.id))\n : undefined,\n thread\n ? client.cache?.threadMembers?.get(threadMemberKey(data.id, client.user?.id ?? client.id))\n : undefined,\n ],\n ([parentData, resolvedRecipient, stageData, me]) =>\n whenAll(\n [parentData ? this._hydrateInGuild(parentData, guild, depth + 1) : null],\n ([parent]) => {\n const relations: ChannelRelations = { guild, parent };\n if (recipient) relations.recipient = resolvedRecipient ?? null;\n if (thread && client.cache?.threadMembers) relations.joined = me !== undefined;\n const channel = bindClient(createChannel(data, relations), client);\n if (data.type === ChannelType.GuildStageVoice) {\n // Built here rather than by the stage instance manager, whose relations lead back to this channel.\n relations.stageInstance = stageData\n ? bindClient(new StageInstance(stageData, { guild, channel }), client)\n : null;\n }\n\n return channel;\n },\n ),\n );\n }\n\n /**\n * Gets a channel of a guild whose structure is already built, for the guild's own channel relations.\n *\n * @param channelId The ID of the channel.\n * @param guild The guild.\n * @internal\n */\n public _getInGuild(channelId: string, guild: Guild): Awaitable<AnyChannel | null> {\n return whenAll([this.cache?.get(channelId)], ([data]) =>\n data ? this._hydrateInGuild(data, guild) : null,\n );\n }\n\n public resolveKey(channelId: string): string {\n return channelId;\n }\n\n /**\n * Adds a channel to the cache, handing threads to `client.threads`, whose cache holds them.\n *\n * @internal\n */\n public override _add(\n data: CacheEntityTypes[\"channels\"],\n cache = true,\n options?: AddOptions,\n ): Promise<AnyChannel> {\n return isThreadChannelType(data.type)\n ? this.client.threads._add(data as CacheEntityTypes[\"threads\"], cache, options)\n : super._add(data, cache, options);\n }\n\n /**\n * Gets a channel from the cache, looking it up in the thread cache as well, which `get` and `cached` rely on.\n *\n * @param channelId The ID of the channel.\n * @internal\n */\n public override _get(channelId: string): Awaitable<AnyChannel | undefined> {\n return whenAll(\n [super._get(channelId)],\n ([channel]) => channel ?? this.client.threads._get(channelId),\n );\n }\n\n /**\n * Writes a channel to the cache, threads to the thread cache.\n *\n * @param channelId The ID of the channel.\n * @param raw The raw channel.\n */\n protected override async storeRaw(\n channelId: string,\n raw: CacheEntityTypes[\"channels\"],\n ): Promise<void> {\n if (isThreadChannelType(raw.type)) {\n await this.client.cache?.threads?.set(channelId, raw as CacheEntityTypes[\"threads\"]);\n } else {\n await this.cache?.set(channelId, raw);\n }\n }\n\n /**\n * Edits a channel.\n *\n * @param channelId The ID of the channel.\n * @param options The fields to edit, and the reason for the audit log.\n */\n public async edit(channelId: string, options: GuildChannelEditOptions): Promise<AnyChannel> {\n if (options.lockPermissions && options.permissionOverwrites) {\n throw new TypeError(\"Pass either lockPermissions or permissionOverwrites, not both\");\n }\n\n const body = toChannelBody(options);\n if (options.lockPermissions) {\n const parentId =\n options.parent === undefined\n ? (overwriteHolder(await this.fetch(channelId)).parent_id ?? null)\n : options.parent && resolveId(options.parent);\n if (parentId) {\n body.permission_overwrites = overwriteHolder(\n await this.fetch(parentId),\n ).permission_overwrites;\n }\n }\n\n const channel = await this.client.api.channels.edit(channelId, body, {\n reason: options.reason,\n });\n return this._add(channel);\n }\n\n /**\n * Deletes a channel, or closes a direct message, and drops it from the cache with its messages.\n *\n * @param channelId The ID of the channel.\n * @param reason The reason for the audit log.\n */\n public async delete(channelId: string, reason?: string): Promise<void> {\n const channel = await this.client.api.channels.delete(channelId, {\n reason,\n });\n if (!this.client.cache) return;\n\n // The same cascade as the `CHANNEL_DELETE` (or `THREAD_DELETE`) that follows.\n await applyGatewayDispatch(this.client.cache, {\n op: GatewayOpcodes.Dispatch,\n s: 0,\n t: isThreadChannelType(channel.type)\n ? GatewayDispatchEvents.ThreadDelete\n : GatewayDispatchEvents.ChannelDelete,\n d: channel,\n } as GatewayDispatchPayload);\n }\n\n /**\n * Gets the permission overwrites of a channel, cache first.\n *\n * @param channelId The ID of the channel.\n */\n public async permissionOverwrites(channelId: string): Promise<PermissionOverwriteManager> {\n const data = overwriteHolder(await this.fetch(channelId));\n return new PermissionOverwriteManager(\n this.client,\n channelId,\n data.guild_id ?? null,\n data.permission_overwrites ?? [],\n );\n }\n\n protected async fetchRaw(channelId: string) {\n return this.client.api.channels.get(channelId);\n }\n}\n","import type { BaseImageURLOptions, ImageURLOptions } from \"@discordjs/rest\";\nimport { GuildFeature, type APIGuild } from \"discord-api-types/v10\";\nimport { cdn } from \"../../util/cdn.js\";\nimport { kData, snowflakeTimestamp, Structure } from \"../Structure.js\";\n\n/**\n * The raw fields every guild-like payload carries, from the partial guilds of invites to full guilds.\n */\nexport type AnonymousGuildData = Pick<APIGuild, \"features\" | \"icon\" | \"id\" | \"name\"> &\n Partial<\n Pick<\n APIGuild,\n | \"banner\"\n | \"description\"\n | \"nsfw_level\"\n | \"premium_subscription_count\"\n | \"splash\"\n | \"vanity_url_code\"\n | \"verification_level\"\n >\n >;\n\n/**\n * The public attributes shared by {@link Guild} and {@link InviteGuild}, i.e. what an anonymous user can see of a\n * guild.\n *\n * @remarks\n * Merges discord.js's `BaseGuild` and `AnonymousGuild`, there being no `OAuth2Guild` here to justify the split.\n *\n * @typeParam Data The raw guild data this structure wraps.\n */\nexport class AnonymousGuild<\n Data extends AnonymousGuildData = AnonymousGuildData,\n> extends Structure<Data> {\n public get id() {\n return this[kData].id;\n }\n\n public get name() {\n return this[kData].name;\n }\n\n public get icon() {\n return this[kData].icon;\n }\n\n public get features() {\n return this[kData].features;\n }\n\n public get splash(): string | null {\n return this[kData].splash ?? null;\n }\n\n public get banner(): string | null {\n return this[kData].banner ?? null;\n }\n\n public get description(): string | null {\n return this[kData].description ?? null;\n }\n\n public get verificationLevel() {\n return this[kData].verification_level ?? null;\n }\n\n /**\n * The vanity invite code of the guild, if any.\n */\n public get vanityURLCode(): string | null {\n return this[kData].vanity_url_code ?? null;\n }\n\n public get nsfwLevel() {\n return this[kData].nsfw_level ?? null;\n }\n\n /**\n * The total number of boosts of the guild, or `null` if unknown.\n */\n public get premiumSubscriptionCount(): number | null {\n return this[kData].premium_subscription_count ?? null;\n }\n\n public get createdTimestamp() {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n\n /**\n * The acronym shown in place of the guild's icon when it has none.\n */\n public get nameAcronym(): string {\n return this.name\n .replaceAll(\"'s \", \" \")\n .replaceAll(/\\w+/g, (word) => word[0]!)\n .replaceAll(/\\s/g, \"\");\n }\n\n /**\n * Whether the guild is partnered.\n */\n public get partnered(): boolean {\n return this.features.includes(GuildFeature.Partnered);\n }\n\n /**\n * Whether the guild is verified.\n */\n public get verified(): boolean {\n return this.features.includes(GuildFeature.Verified);\n }\n\n /**\n * Gets the URL of the guild's icon, or `null` if it has none.\n * @param options The image options.\n */\n public iconURL(options?: ImageURLOptions): string | null {\n const { icon } = this[kData];\n return icon ? cdn.icon(this.id, icon, options) : null;\n }\n\n /**\n * Gets the URL of the guild's banner, or `null` if it has none.\n * @param options The image options.\n */\n public bannerURL(options?: ImageURLOptions): string | null {\n const { banner } = this[kData];\n return banner ? cdn.banner(this.id, banner, options) : null;\n }\n\n /**\n * Gets the URL of the guild's invite splash image, or `null` if it has none.\n * @param options The image options.\n */\n public splashURL(options?: BaseImageURLOptions): string | null {\n const { splash } = this[kData];\n return splash ? cdn.splash(this.id, splash, options) : null;\n }\n\n public toString(): string {\n return this.name;\n }\n}\n","import type { BaseImageURLOptions } from \"@discordjs/rest\";\nimport type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n GuildFeature,\n GuildPremiumTier,\n type APIGuild,\n type APIIncidentsData,\n type APIVoiceRegion,\n type GuildDefaultMessageNotifications,\n type GuildExplicitContentFilter,\n type GuildVerificationLevel,\n type Locale,\n type RESTGetAPIGuildVanityUrlResult,\n type RESTPatchAPIGuildJSONBody,\n} from \"discord-api-types/v10\";\nimport type { AutoModerationRuleManager } from \"../../managers/AutoModerationRuleManager.js\";\nimport type { GuildBanManager } from \"../../managers/GuildBanManager.js\";\nimport type { GuildScheduledEventManager } from \"../../managers/GuildScheduledEventManager.js\";\nimport type { GuildSoundboardSoundManager } from \"../../managers/GuildSoundboardSoundManager.js\";\nimport type { StageInstanceManager } from \"../../managers/StageInstanceManager.js\";\nimport type { GuildChannelManager } from \"../../managers/GuildChannelManager.js\";\nimport type { FetchedThreads } from \"../../managers/ThreadManager.js\";\nimport type { GuildEmojiManager } from \"../../managers/GuildEmojiManager.js\";\nimport type { GuildIntegrationManager } from \"../../managers/GuildIntegrationManager.js\";\nimport type { GuildMembersRequestOptions } from \"../../managers/GuildMemberManager.js\";\nimport type {\n GuildAuditLogs,\n GuildAuditLogsFetchOptions,\n GuildIncidentActionsOptions,\n GuildOnboardingEditOptions,\n GuildWelcomeScreenEditOptions,\n GuildWidgetSettings,\n GuildWidgetSettingsEditOptions,\n} from \"../../managers/GuildManager.js\";\nimport type { GuildTemplateCreateOptions } from \"../../managers/GuildTemplateManager.js\";\nimport type { GuildInviteManager } from \"../../managers/GuildInviteManager.js\";\nimport type { GuildStickerManager } from \"../../managers/GuildStickerManager.js\";\nimport { cdn } from \"../../util/cdn.js\";\nimport type { Webhook } from \"../webhooks/Webhook.js\";\nimport { SystemChannelFlagsBitField, type SystemChannelFlagsResolvable } from \"../../util/flags.js\";\nimport { AnonymousGuild } from \"./AnonymousGuild.js\";\nimport type { GuildInvite } from \"../invites/GuildInvite.js\";\nimport type { GuildMember } from \"./GuildMember.js\";\nimport type { GuildOnboarding } from \"./GuildOnboarding.js\";\nimport type { GuildPreview } from \"./GuildPreview.js\";\nimport type { GuildTemplate } from \"./GuildTemplate.js\";\nimport type { Integration } from \"./Integration.js\";\nimport type { WelcomeScreen } from \"./WelcomeScreen.js\";\nimport type { Widget } from \"./Widget.js\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport { kData, kPatch, kPatchRelations, kRelations } from \"../Structure.js\";\n\n/**\n * The relations of a {@link Guild}: its special channels, resolved from the cache by `client.guilds`.\n */\nexport interface GuildRelations {\n afkChannel?: AnyChannel | null;\n systemChannel?: AnyChannel | null;\n widgetChannel?: AnyChannel | null;\n rulesChannel?: AnyChannel | null;\n publicUpdatesChannel?: AnyChannel | null;\n safetyAlertsChannel?: AnyChannel | null;\n}\n\n/**\n * The raw field holding the ID of each channel of {@link GuildRelations}.\n *\n * @internal\n */\nexport const GuildChannelFields = {\n afkChannel: \"afk_channel_id\",\n systemChannel: \"system_channel_id\",\n widgetChannel: \"widget_channel_id\",\n rulesChannel: \"rules_channel_id\",\n publicUpdatesChannel: \"public_updates_channel_id\",\n safetyAlertsChannel: \"safety_alerts_channel_id\",\n} as const satisfies Record<keyof GuildRelations, string>;\n\n/**\n * The options to edit a guild with. Images are data URIs (`data:image/png;base64,...`), channels are IDs.\n */\nexport interface GuildEditOptions {\n afkChannel?: string | null;\n afkTimeout?: RESTPatchAPIGuildJSONBody[\"afk_timeout\"];\n banner?: string | null;\n defaultMessageNotifications?: GuildDefaultMessageNotifications | null;\n description?: string | null;\n discoverySplash?: string | null;\n explicitContentFilter?: GuildExplicitContentFilter | null;\n features?: APIGuild[\"features\"];\n icon?: string | null;\n name?: string;\n /**\n * The ID of the member to transfer the ownership to.\n */\n owner?: string;\n preferredLocale?: Locale | null;\n premiumProgressBarEnabled?: boolean;\n publicUpdatesChannel?: string | null;\n reason?: string;\n rulesChannel?: string | null;\n safetyAlertsChannel?: string | null;\n splash?: string | null;\n systemChannel?: string | null;\n systemChannelFlags?: SystemChannelFlagsResolvable;\n verificationLevel?: GuildVerificationLevel | null;\n}\n\n/**\n * A Discord guild.\n *\n * @remarks\n * The collections sent in `GUILD_CREATE` (channels, members, roles, ...) are not kept on the guild: they are stored in\n * their own entity caches and exposed by the client's managers, e.g. `client.members.fetch(guild.id, userId)`. The\n * guild-scoped ones discord.js exposes on the guild itself (`emojis`, `stickers`, `invites`) are here too.\n */\nexport class Guild extends AnonymousGuild<CacheEntityTypes[\"guilds\"]> {\n declare public [kRelations]: GuildRelations;\n\n /**\n * @param data The raw guild.\n * @param relations The channels of the guild, as resolved from the cache by `client.guilds`.\n */\n public constructor(data: CacheEntityTypes[\"guilds\"], relations: GuildRelations = {}) {\n super(data, relations);\n }\n\n protected override optimizeData(data: Partial<CacheEntityTypes[\"guilds\"]>): void {\n super.optimizeData(data);\n this.optimizeTimestamp(\"joined_at\", data.joined_at);\n }\n\n public get ownerId() {\n return this[kData].owner_id;\n }\n\n public get discoverySplash() {\n return this[kData].discovery_splash;\n }\n\n public get afkChannelId() {\n return this[kData].afk_channel_id;\n }\n\n /**\n * The time, in seconds, before a member is moved to the AFK channel.\n */\n public get afkTimeout() {\n return this[kData].afk_timeout;\n }\n\n public get widgetEnabled(): boolean {\n return this[kData].widget_enabled ?? false;\n }\n\n public get widgetChannelId(): string | null {\n return this[kData].widget_channel_id ?? null;\n }\n\n public override get verificationLevel(): GuildVerificationLevel {\n return this[kData].verification_level;\n }\n\n public get defaultMessageNotifications() {\n return this[kData].default_message_notifications;\n }\n\n public get explicitContentFilter() {\n return this[kData].explicit_content_filter;\n }\n\n public get mfaLevel() {\n return this[kData].mfa_level;\n }\n\n /**\n * The ID of the application that created the guild, for bot-created guilds.\n */\n public get applicationId() {\n return this[kData].application_id;\n }\n\n public get systemChannelId() {\n return this[kData].system_channel_id;\n }\n\n /**\n * The flags deciding which system messages are suppressed in the system channel.\n */\n public get systemChannelFlags(): Readonly<SystemChannelFlagsBitField> {\n return new SystemChannelFlagsBitField(this[kData].system_channel_flags ?? 0).freeze();\n }\n\n public get rulesChannelId() {\n return this[kData].rules_channel_id;\n }\n\n public get publicUpdatesChannelId() {\n return this[kData].public_updates_channel_id;\n }\n\n public get safetyAlertsChannelId() {\n return this[kData].safety_alerts_channel_id;\n }\n\n /**\n * The channel members are moved to when idle, from the cache, like discord.js's `Guild#afkChannel`. `null` when\n * the guild has none, when it is not cached, or when the guild was not built by a manager.\n */\n public get afkChannel(): AnyChannel | null {\n return this.relatedChannel(\"afkChannel\");\n }\n\n /**\n * The channel system messages are sent to, from the cache.\n */\n public get systemChannel(): AnyChannel | null {\n return this.relatedChannel(\"systemChannel\");\n }\n\n /**\n * The channel the widget's invite leads to, from the cache.\n */\n public get widgetChannel(): AnyChannel | null {\n return this.relatedChannel(\"widgetChannel\");\n }\n\n /**\n * The rules channel of a community guild, from the cache.\n */\n public get rulesChannel(): AnyChannel | null {\n return this.relatedChannel(\"rulesChannel\");\n }\n\n /**\n * The channel Discord sends community updates to, from the cache.\n */\n public get publicUpdatesChannel(): AnyChannel | null {\n return this.relatedChannel(\"publicUpdatesChannel\");\n }\n\n /**\n * The channel Discord sends safety alerts to, from the cache.\n */\n public get safetyAlertsChannel(): AnyChannel | null {\n return this.relatedChannel(\"safetyAlertsChannel\");\n }\n\n /**\n * Gets one of the channels of {@link GuildRelations}: the one `client.guilds` resolved, else, for guilds built\n * without their channels (e.g. `message.guild`), a lookup in a synchronous cache.\n */\n private relatedChannel(name: keyof GuildRelations): AnyChannel | null {\n const resolved = this[kRelations][name];\n if (resolved !== undefined) return resolved;\n\n const channelId = (this[kData] as unknown as Record<string, string | null | undefined>)[\n GuildChannelFields[name]\n ];\n if (!channelId || this.client.cache?.channels?.synchronous !== true) return null;\n try {\n return this.client.channels.cached(channelId) ?? null;\n } catch {\n // A relation of the channel is read from an asynchronous cache.\n return null;\n }\n }\n\n /**\n * Forgets the channels a patch changes.\n *\n * @internal\n */\n public [kPatchRelations](data: object): void {\n this.dropChangedRelations(data, GuildChannelFields);\n }\n\n /**\n * The maximum number of presences of the guild, `null` for the default limit.\n */\n public get maximumPresences(): number | null {\n return this[kData].max_presences ?? null;\n }\n\n public get maximumMembers(): number | null {\n return this[kData].max_members ?? null;\n }\n\n /**\n * The maximum number of users in a video channel.\n */\n public get maxVideoChannelUsers(): number | null {\n return this[kData].max_video_channel_users ?? null;\n }\n\n /**\n * The maximum number of users in a stage video channel.\n */\n public get maxStageVideoChannelUsers(): number | null {\n return this[kData].max_stage_video_channel_users ?? null;\n }\n\n public override get nsfwLevel() {\n return this[kData].nsfw_level;\n }\n\n public get premiumTier() {\n return this[kData].premium_tier;\n }\n\n public get premiumProgressBarEnabled(): boolean {\n return this[kData].premium_progress_bar_enabled ?? false;\n }\n\n public get preferredLocale() {\n return this[kData].preferred_locale;\n }\n\n /**\n * Until when invites or direct messages are paused because of raid activity, as set with `setIncidentActions`.\n */\n public get incidentsData(): APIIncidentsData | null {\n return this[kData].incidents_data ?? null;\n }\n\n /**\n * Whether the guild is considered large by the gateway, `false` if unknown.\n */\n public get large(): boolean {\n return this[kData].large ?? false;\n }\n\n /**\n * The member count, as sent in `GUILD_CREATE` or by the API, or `null` if unknown.\n */\n public get memberCount(): number | null {\n return this[kData].member_count ?? this[kData].approximate_member_count ?? null;\n }\n\n /**\n * The approximate member count, only present when fetched with counts.\n */\n public get approximateMemberCount(): number | null {\n return this[kData].approximate_member_count ?? null;\n }\n\n /**\n * The approximate number of online members, only present when fetched with counts.\n */\n public get approximatePresenceCount(): number | null {\n return this[kData].approximate_presence_count ?? null;\n }\n\n /**\n * The timestamp the client user joined the guild at, as sent in `GUILD_CREATE`, or `null` if unknown.\n */\n public get joinedTimestamp(): number | null {\n return this.optimizedTimestamp(\"joined_at\");\n }\n\n public get joinedAt(): Date | null {\n const { joinedTimestamp } = this;\n return joinedTimestamp === null ? null : new Date(joinedTimestamp);\n }\n\n /**\n * Whether the guild is available, `false` during a Discord outage.\n */\n public get available(): boolean {\n return !this[kData].unavailable;\n }\n\n /**\n * The maximum bitrate, in bits per second, voice channels of the guild can use.\n */\n public get maximumBitrate(): number {\n if (this.features.includes(GuildFeature.VIPRegions)) return 384_000;\n return this.maximumStageBitrate;\n }\n\n /**\n * The maximum bitrate, in bits per second, stage channels of the guild can use.\n */\n public get maximumStageBitrate(): number {\n switch (this.premiumTier) {\n case GuildPremiumTier.Tier1:\n return 128_000;\n case GuildPremiumTier.Tier2:\n return 256_000;\n case GuildPremiumTier.Tier3:\n return 384_000;\n default:\n return 96_000;\n }\n }\n\n /**\n * The custom emojis of the guild.\n */\n public get emojis(): GuildEmojiManager {\n return this.client.guilds.emojis(this.id);\n }\n\n /**\n * The custom stickers of the guild.\n */\n public get stickers(): GuildStickerManager {\n return this.client.guilds.stickers(this.id);\n }\n\n /**\n * Fetches the active threads of the guild, and caches them.\n */\n public fetchActiveThreads(): Promise<FetchedThreads> {\n return this.client.threads.fetchActive(this.id);\n }\n\n /**\n * Fetches the webhooks of the guild.\n */\n public fetchWebhooks(): Promise<Webhook[]> {\n return this.client.webhooks.fetchGuild(this.id);\n }\n\n /**\n * The scheduled events of the guild.\n */\n public get scheduledEvents(): GuildScheduledEventManager {\n return this.client.guilds.scheduledEvents(this.id);\n }\n\n /**\n * The live stages of the guild.\n */\n public get stageInstances(): StageInstanceManager {\n return this.client.guilds.stageInstances(this.id);\n }\n\n /**\n * The soundboard sounds of the guild.\n */\n public get soundboardSounds(): GuildSoundboardSoundManager {\n return this.client.guilds.soundboardSounds(this.id);\n }\n\n /**\n * The integrations of the guild.\n */\n public get integrations(): GuildIntegrationManager {\n return this.client.guilds.integrations(this.id);\n }\n\n /**\n * Fetches every integration of the guild.\n */\n public fetchIntegrations(): Promise<Integration[]> {\n return this.integrations.fetchAll();\n }\n\n /**\n * Fetches the templates of the guild.\n */\n public fetchTemplates(): Promise<GuildTemplate[]> {\n return this.client.templates.list(this.id);\n }\n\n /**\n * Creates a template of the guild.\n *\n * @param name The name of the template.\n * @param description The description of the template.\n */\n public createTemplate(name: string, description?: string | null): Promise<GuildTemplate> {\n const options: GuildTemplateCreateOptions = { name, description };\n return this.client.templates.create(this.id, options);\n }\n\n /**\n * Fetches the welcome screen of the guild.\n */\n public fetchWelcomeScreen(): Promise<WelcomeScreen> {\n return this.client.guilds.fetchWelcomeScreen(this.id);\n }\n\n /**\n * Edits the welcome screen of the guild.\n *\n * @param options The changes to apply.\n */\n public editWelcomeScreen(options: GuildWelcomeScreenEditOptions): Promise<WelcomeScreen> {\n return this.client.guilds.editWelcomeScreen(this.id, options);\n }\n\n /**\n * Fetches the public widget of the guild, which must be enabled.\n */\n public fetchWidget(): Promise<Widget> {\n return this.client.fetchGuildWidget(this.id);\n }\n\n /**\n * Fetches whether the widget of the guild is enabled, and its channel.\n */\n public fetchWidgetSettings(): Promise<GuildWidgetSettings> {\n return this.client.guilds.fetchWidgetSettings(this.id);\n }\n\n /**\n * Edits the widget settings of the guild, and patches {@link Guild.widgetEnabled} and\n * {@link Guild.widgetChannelId} in place.\n *\n * @param options Whether to enable the widget, and its channel.\n */\n public async setWidgetSettings(options: GuildWidgetSettingsEditOptions): Promise<this> {\n const settings = await this.client.guilds.editWidgetSettings(this.id, options);\n return this[kPatch]({\n widget_enabled: settings.enabled,\n widget_channel_id: settings.channelId,\n });\n }\n\n /**\n * Fetches the onboarding of the guild.\n */\n public fetchOnboarding(): Promise<GuildOnboarding> {\n return this.client.guilds.fetchOnboarding(this.id);\n }\n\n /**\n * Edits the onboarding of the guild.\n *\n * @param options The changes to apply. The prompts replace every existing one.\n */\n public editOnboarding(options: GuildOnboardingEditOptions): Promise<GuildOnboarding> {\n return this.client.guilds.editOnboarding(this.id, options);\n }\n\n /**\n * The bans of the guild.\n */\n public get bans(): GuildBanManager {\n return this.client.guilds.bans(this.id);\n }\n\n /**\n * The auto moderation rules of the guild.\n */\n public get autoModerationRules(): AutoModerationRuleManager {\n return this.client.guilds.autoModerationRules(this.id);\n }\n\n /**\n * Fetches a page of the guild's audit log.\n *\n * @param options Which user and action to filter by, and the page.\n */\n public fetchAuditLogs(options?: GuildAuditLogsFetchOptions): Promise<GuildAuditLogs> {\n return this.client.guilds.fetchAuditLogs(this.id, options);\n }\n\n /**\n * The channels of the guild.\n */\n public get channels(): GuildChannelManager {\n return this.client.guilds.channels(this.id);\n }\n\n /**\n * The invites of the guild.\n */\n public get invites(): GuildInviteManager {\n return this.client.guilds.invites(this.id);\n }\n\n /**\n * Gets the URL of the guild's discovery splash image, or `null` if it has none.\n * @param options The image options.\n */\n public discoverySplashURL(options?: BaseImageURLOptions): string | null {\n const { discovery_splash: discoverySplash } = this[kData];\n return discoverySplash ? cdn.discoverySplash(this.id, discoverySplash, options) : null;\n }\n\n /**\n * Fetches this guild from the API, with its approximate counts, and patches it in place.\n */\n public async fetch(): Promise<this> {\n const guild = await this.client.guilds.fetch(this.id, { force: true });\n return this[kPatch](guild.toJSON());\n }\n\n /**\n * Fetches the member owning this guild.\n */\n public fetchOwner(): Promise<GuildMember> {\n return this.client.members.fetch(this.id, this.ownerId);\n }\n\n /**\n * Requests the members of this guild over the gateway, every one of them by default, and caches them. discord.js:\n * `guild.members.fetch()`. See `client.members.request`.\n *\n * @param options Which members to request.\n */\n public requestMembers(options?: GuildMembersRequestOptions): Promise<GuildMember[]> {\n return this.client.members.request(this.id, options);\n }\n\n /**\n * Fetches every invite of this guild.\n */\n public fetchInvites(): Promise<GuildInvite[]> {\n return this.invites.fetchAll();\n }\n\n /**\n * Fetches the public preview of this guild.\n */\n public fetchPreview(): Promise<GuildPreview> {\n return this.client.guilds.fetchPreview(this.id);\n }\n\n /**\n * Fetches the voice regions available to this guild.\n */\n public fetchVoiceRegions(): Promise<APIVoiceRegion[]> {\n return this.client.guilds.fetchVoiceRegions(this.id);\n }\n\n /**\n * Fetches the vanity URL of this guild, patching {@link AnonymousGuild.vanityURLCode} in place.\n */\n public async fetchVanityData(): Promise<RESTGetAPIGuildVanityUrlResult> {\n const data = await this.client.guilds.fetchVanityData(this.id);\n this[kPatch]({ vanity_url_code: data.code });\n return data;\n }\n\n /**\n * Edits this guild.\n *\n * @param options The changes to apply.\n */\n public async edit(options: GuildEditOptions): Promise<this> {\n const guild = await this.client.guilds.edit(this.id, options);\n return this[kPatch](guild.toJSON());\n }\n\n public setName(name: string, reason?: string): Promise<this> {\n return this.edit({ name, reason });\n }\n\n /**\n * Sets the icon of this guild, as a data URI, `null` to remove it.\n */\n public setIcon(icon: string | null, reason?: string): Promise<this> {\n return this.edit({ icon, reason });\n }\n\n /**\n * Sets the banner of this guild, as a data URI, `null` to remove it.\n */\n public setBanner(banner: string | null, reason?: string): Promise<this> {\n return this.edit({ banner, reason });\n }\n\n /**\n * Sets the invite splash image of this guild, as a data URI, `null` to remove it.\n */\n public setSplash(splash: string | null, reason?: string): Promise<this> {\n return this.edit({ splash, reason });\n }\n\n /**\n * Sets the discovery splash image of this guild, as a data URI, `null` to remove it.\n */\n public setDiscoverySplash(discoverySplash: string | null, reason?: string): Promise<this> {\n return this.edit({ discoverySplash, reason });\n }\n\n public setSystemChannel(systemChannel: string | null, reason?: string): Promise<this> {\n return this.edit({ systemChannel, reason });\n }\n\n public setSystemChannelFlags(\n systemChannelFlags: SystemChannelFlagsResolvable,\n reason?: string,\n ): Promise<this> {\n return this.edit({ systemChannelFlags, reason });\n }\n\n public setAFKChannel(afkChannel: string | null, reason?: string): Promise<this> {\n return this.edit({ afkChannel, reason });\n }\n\n /**\n * Sets the AFK timeout of this guild, in seconds.\n */\n public setAFKTimeout(\n afkTimeout: RESTPatchAPIGuildJSONBody[\"afk_timeout\"],\n reason?: string,\n ): Promise<this> {\n return this.edit({ afkTimeout, reason });\n }\n\n public setRulesChannel(rulesChannel: string | null, reason?: string): Promise<this> {\n return this.edit({ rulesChannel, reason });\n }\n\n public setPublicUpdatesChannel(\n publicUpdatesChannel: string | null,\n reason?: string,\n ): Promise<this> {\n return this.edit({ publicUpdatesChannel, reason });\n }\n\n public setSafetyAlertsChannel(\n safetyAlertsChannel: string | null,\n reason?: string,\n ): Promise<this> {\n return this.edit({ safetyAlertsChannel, reason });\n }\n\n public setVerificationLevel(\n verificationLevel: GuildVerificationLevel | null,\n reason?: string,\n ): Promise<this> {\n return this.edit({ verificationLevel, reason });\n }\n\n public setExplicitContentFilter(\n explicitContentFilter: GuildExplicitContentFilter | null,\n reason?: string,\n ): Promise<this> {\n return this.edit({ explicitContentFilter, reason });\n }\n\n public setDefaultMessageNotifications(\n defaultMessageNotifications: GuildDefaultMessageNotifications | null,\n reason?: string,\n ): Promise<this> {\n return this.edit({ defaultMessageNotifications, reason });\n }\n\n public setPreferredLocale(preferredLocale: Locale | null, reason?: string): Promise<this> {\n return this.edit({ preferredLocale, reason });\n }\n\n public setPremiumProgressBarEnabled(enabled = true, reason?: string): Promise<this> {\n return this.edit({ premiumProgressBarEnabled: enabled, reason });\n }\n\n /**\n * Transfers the ownership of this guild to another member. The client user must own the guild.\n *\n * @param owner The ID of the new owner.\n */\n public setOwner(owner: string, reason?: string): Promise<this> {\n return this.edit({ owner, reason });\n }\n\n /**\n * Pauses or resumes invites to this guild, through the `INVITES_DISABLED` feature.\n *\n * @param disabled Whether to pause invites.\n */\n public disableInvites(disabled = true): Promise<this> {\n const features: GuildFeature[] = this.features.filter(\n (feature) => feature !== GuildFeature.InvitesDisabled,\n );\n if (disabled) features.push(GuildFeature.InvitesDisabled);\n return this.edit({ features });\n }\n\n /**\n * Pauses invites or direct messages for up to a day, e.g. during a raid.\n *\n * @param options Until when to pause each, `null` to resume.\n */\n public async setIncidentActions(options: GuildIncidentActionsOptions): Promise<APIIncidentsData> {\n const incidents = await this.client.guilds.setIncidentActions(this.id, options);\n this[kPatch]({ incidents_data: incidents });\n return incidents;\n }\n\n /**\n * Makes the client user leave this guild.\n */\n public async leave(): Promise<this> {\n await this.client.guilds.leave(this.id);\n return this;\n }\n\n /**\n * Deletes this guild. The client user must own it.\n */\n public async delete(): Promise<this> {\n await this.client.guilds.delete(this.id);\n return this;\n }\n\n /**\n * Whether this guild has the same data as another one.\n * @param guild The guild to compare with.\n */\n public equals(guild: Guild): boolean {\n return (\n this.id === guild.id &&\n this.name === guild.name &&\n this.icon === guild.icon &&\n this.splash === guild.splash &&\n this.discoverySplash === guild.discoverySplash &&\n this.ownerId === guild.ownerId &&\n this.afkTimeout === guild.afkTimeout &&\n this.afkChannelId === guild.afkChannelId &&\n this.systemChannelId === guild.systemChannelId &&\n this.verificationLevel === guild.verificationLevel &&\n this.explicitContentFilter === guild.explicitContentFilter &&\n this.mfaLevel === guild.mfaLevel &&\n this.banner === guild.banner &&\n this.description === guild.description &&\n this.vanityURLCode === guild.vanityURLCode &&\n this.features.length === guild.features.length &&\n this.features.every((feature) => guild.features.includes(feature))\n );\n }\n}\n","import { AutoModerationRule as BaseAutoModerationRule } from \"@discordjs/structures\";\nimport type {\n APIAutoModerationAction,\n APIAutoModerationRule,\n APIAutoModerationRuleTriggerMetadata,\n AutoModerationRuleEventType,\n AutoModerationRuleKeywordPresetType,\n} from \"discord-api-types/v10\";\nimport type { AutoModerationRuleEditOptions } from \"../../managers/AutoModerationRuleManager.js\";\nimport type { IdResolvable } from \"../../util/channels.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, kPatch, kRelations, StructureMixin } from \"../Structure.js\";\n\n/**\n * The relations of an {@link AutoModerationRule}, resolved from the cache by the guild's rule manager.\n */\nexport interface AutoModerationRuleRelations {\n guild?: Guild | null;\n}\n\nexport interface AutoModerationRule extends StructureMixin<\n APIAutoModerationRule,\n AutoModerationRuleRelations\n> {}\n\n/**\n * An auto moderation rule of a guild: `@discordjs/structures`' `AutoModerationRule`, with its trigger, actions, and\n * exemptions, and actions through the client.\n */\nexport class AutoModerationRule extends BaseAutoModerationRule {\n /**\n * @param data The raw rule.\n * @param relations The guild as resolved from the cache, by the guild's rule manager.\n */\n public constructor(data: APIAutoModerationRule, relations: AutoModerationRuleRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n public get triggerMetadata(): Readonly<APIAutoModerationRuleTriggerMetadata> {\n return this[kData].trigger_metadata;\n }\n\n public get actions(): readonly APIAutoModerationAction[] {\n return this[kData].actions;\n }\n\n public get exemptRoles(): readonly string[] {\n return this[kData].exempt_roles;\n }\n\n public get exemptChannels(): readonly string[] {\n return this[kData].exempt_channels;\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * Edits the rule.\n *\n * @param options The fields to edit, and the reason for the audit log.\n */\n public async edit(options: AutoModerationRuleEditOptions): Promise<this> {\n const rule = await this.client.guilds.autoModerationRules(this.guildId).edit(this.id, options);\n return this[kPatch](rule.toJSON());\n }\n\n public setName(name: string, reason?: string): Promise<this> {\n return this.edit({ name, reason });\n }\n\n public setEventType(eventType: AutoModerationRuleEventType, reason?: string): Promise<this> {\n return this.edit({ eventType, reason });\n }\n\n public setEnabled(enabled = true, reason?: string): Promise<this> {\n return this.edit({ enabled, reason });\n }\n\n public setActions(actions: readonly APIAutoModerationAction[], reason?: string): Promise<this> {\n return this.edit({ actions, reason });\n }\n\n public setExemptRoles(roles: readonly IdResolvable[], reason?: string): Promise<this> {\n return this.edit({ exemptRoles: roles, reason });\n }\n\n public setExemptChannels(channels: readonly IdResolvable[], reason?: string): Promise<this> {\n return this.edit({ exemptChannels: channels, reason });\n }\n\n /**\n * Sets the keywords of a keyword rule, keeping the rest of its trigger.\n */\n public setKeywordFilter(keywordFilter: readonly string[], reason?: string): Promise<this> {\n return this.editTrigger({ keyword_filter: [...keywordFilter] }, reason);\n }\n\n /**\n * Sets the regular expressions of a keyword rule, keeping the rest of its trigger.\n */\n public setRegexPatterns(regexPatterns: readonly string[], reason?: string): Promise<this> {\n return this.editTrigger({ regex_patterns: [...regexPatterns] }, reason);\n }\n\n /**\n * Sets the keyword presets of a keyword preset rule, keeping the rest of its trigger.\n */\n public setPresets(\n presets: readonly AutoModerationRuleKeywordPresetType[],\n reason?: string,\n ): Promise<this> {\n return this.editTrigger({ presets: [...presets] }, reason);\n }\n\n /**\n * Sets the keywords exempt from the rule, keeping the rest of its trigger.\n */\n public setAllowList(allowList: readonly string[], reason?: string): Promise<this> {\n return this.editTrigger({ allow_list: [...allowList] }, reason);\n }\n\n /**\n * Sets how many mentions a message may have, for a mention spam rule.\n */\n public setMentionTotalLimit(mentionTotalLimit: number, reason?: string): Promise<this> {\n return this.editTrigger({ mention_total_limit: mentionTotalLimit }, reason);\n }\n\n /**\n * Sets whether a mention spam rule detects mention raids.\n */\n public setMentionRaidProtectionEnabled(enabled = true, reason?: string): Promise<this> {\n return this.editTrigger({ mention_raid_protection_enabled: enabled }, reason);\n }\n\n /**\n * Deletes the rule.\n *\n * @param reason The reason for the audit log.\n */\n public async delete(reason?: string): Promise<this> {\n await this.client.guilds.autoModerationRules(this.guildId).delete(this.id, reason);\n return this;\n }\n\n // Discord replaces the whole trigger metadata, so the setters merge their field into the current one.\n private editTrigger(patch: APIAutoModerationRuleTriggerMetadata, reason?: string): Promise<this> {\n return this.edit({ triggerMetadata: { ...this.triggerMetadata, ...patch }, reason });\n }\n}\n\nMixin(AutoModerationRule, [StructureMixin]);\n","import type { EmojiURLOptions } from \"@discordjs/rest\";\nimport { Emoji as BaseEmoji } from \"@discordjs/structures\";\nimport type { APIEmoji } from \"discord-api-types/v10\";\nimport { cdn } from \"../../util/cdn.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, StructureMixin } from \"../Structure.js\";\n\n/**\n * The raw fields any emoji carries: a custom emoji has an ID, a Unicode one only a name.\n */\nexport type EmojiData = Pick<APIEmoji, \"id\" | \"name\"> & Partial<Pick<APIEmoji, \"animated\">>;\n\nexport interface Emoji<\n Data extends EmojiData = EmojiData,\n Relations extends object = object,\n> extends StructureMixin<Data, Relations> {}\n\n/**\n * An emoji, a custom one (with an ID) or a Unicode one: `@discordjs/structures`' `Emoji`, with its identifier, image\n * URL, and mention.\n *\n * @typeParam Data The raw emoji data this structure wraps.\n * @typeParam Relations The related structures, resolved from the cache.\n */\nexport class Emoji<\n Data extends EmojiData = EmojiData,\n Relations extends object = object,\n> extends BaseEmoji {\n /**\n * @param data The raw emoji.\n * @param relations The related structures, resolved from the cache.\n */\n public constructor(data: Data, relations: Relations = {} as Relations) {\n super(data);\n initStructure(this, data, relations);\n }\n\n public override get animated(): boolean {\n return this[kData].animated ?? false;\n }\n\n /**\n * The form reactions routes expect: `name:id` for custom emojis, the URL-encoded emoji for Unicode ones.\n */\n public get identifier(): string {\n const { id, name } = this;\n if (id) return `${this.animated ? \"a:\" : \"\"}${name ?? \"_\"}:${id}`;\n return encodeURIComponent(name ?? \"\");\n }\n\n public get createdAt(): Date | null {\n return this.createdDate;\n }\n\n /**\n * Gets the URL of the custom emoji's image, `null` for a Unicode emoji. Animated emojis default to a GIF.\n * @param options The image options.\n */\n public imageURL(options?: EmojiURLOptions): string | null {\n const { id } = this;\n if (!id) return null;\n return cdn.emoji(id, options ?? (this.animated ? { extension: \"gif\" } : undefined));\n }\n\n /**\n * The emoji as it is written in a message: `<:name:id>`, `<a:name:id>`, or the Unicode emoji itself.\n */\n public toString(): string {\n const { id, name } = this;\n return id ? `<${this.animated ? \"a\" : \"\"}:${name ?? \"_\"}:${id}>` : (name ?? \"\");\n }\n}\n\nMixin(Emoji, [StructureMixin]);\n","import { FormattingPatterns, type APIPartialEmoji } from \"discord-api-types/v10\";\nimport { Emoji } from \"./Emoji.js\";\n\n/**\n * Anything identifying an emoji: a Unicode emoji, a custom emoji mention (`<a:name:id>`), a `name:id` pair, a bare\n * emoji ID, or any object carrying `id`/`name`/`animated` (an {@link Emoji}, a raw `APIPartialEmoji`, ...).\n */\nexport type EmojiIdentifierResolvable =\n | string\n | { id?: string | null; name?: string | null; animated?: boolean | null };\n\n/**\n * Matches a `name:id` or `a:name:id` pair without the mention brackets.\n */\nconst CustomEmojiPattern = /^(?:(?<animated>a):)?(?<name>\\w{2,32}):(?<id>\\d{17,20})$/;\n\n/**\n * The emoji of a reaction or of a poll answer: a Unicode emoji, or a custom one known only by its ID and name.\n */\nexport class ReactionEmoji extends Emoji<APIPartialEmoji> {\n /**\n * Resolves anything {@link EmojiIdentifierResolvable} to the identifier reaction routes expect.\n *\n * @param emoji The emoji to resolve.\n * @throws A `TypeError` when the value identifies no emoji.\n */\n public static resolveIdentifier(emoji: EmojiIdentifierResolvable): string {\n if (typeof emoji === \"string\") {\n const decoded = emoji.includes(\"%\") ? decodeURIComponent(emoji) : emoji;\n if (/^\\d{17,20}$/.test(decoded)) return `_:${decoded}`;\n\n const custom = FormattingPatterns.Emoji.exec(decoded) ?? CustomEmojiPattern.exec(decoded);\n if (custom?.groups) {\n const { animated, name, id } = custom.groups;\n return `${animated ? \"a:\" : \"\"}${name}:${id}`;\n }\n\n if (!decoded) throw new TypeError(\"Cannot resolve an empty string to an emoji\");\n return encodeURIComponent(decoded);\n }\n\n const { id, name, animated } = emoji;\n if (id) return `${animated ? \"a:\" : \"\"}${name ?? \"_\"}:${id}`;\n if (name) return encodeURIComponent(name);\n throw new TypeError(\"Cannot resolve an emoji without an ID nor a name\");\n }\n\n /**\n * Resolves anything {@link EmojiIdentifierResolvable} to the ID and name pair of welcome screens and onboarding.\n *\n * @param emoji The emoji to resolve.\n */\n public static resolvePartial(emoji: EmojiIdentifierResolvable): {\n id: string | null;\n name: string | null;\n animated: boolean;\n } {\n if (typeof emoji !== \"string\") {\n return { id: emoji.id ?? null, name: emoji.name ?? null, animated: emoji.animated ?? false };\n }\n\n if (/^\\d{17,20}$/.test(emoji)) return { id: emoji, name: null, animated: false };\n const custom = FormattingPatterns.Emoji.exec(emoji) ?? CustomEmojiPattern.exec(emoji);\n if (custom?.groups) {\n const { animated, name, id } = custom.groups;\n return { id: id!, name: name!, animated: Boolean(animated) };\n }\n\n return { id: null, name: emoji, animated: false };\n }\n}\n","import type {\n APIGuildOnboarding,\n APIGuildOnboardingPrompt,\n APIGuildOnboardingPromptOption,\n} from \"discord-api-types/v10\";\nimport type { GuildOnboardingEditOptions } from \"../../managers/GuildManager.js\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { GuildEmoji } from \"../emojis/GuildEmoji.js\";\nimport type { Guild } from \"./Guild.js\";\nimport type { Role } from \"./Role.js\";\nimport { ReactionEmoji } from \"../emojis/ReactionEmoji.js\";\nimport { pickCached as pick } from \"../../util/cache.js\";\nimport { bindClient, kData, kPatch, kRelations, Structure } from \"../Structure.js\";\n\n/**\n * The relations of a {@link GuildOnboarding}, shared with its prompts and their options: its guild, and the channels,\n * roles, and custom emojis its prompts refer to, resolved from the cache by `client.guilds`.\n */\nexport interface GuildOnboardingRelations {\n guild?: Guild | null;\n channels?: ReadonlyMap<string, AnyChannel>;\n roles?: ReadonlyMap<string, Role>;\n emojis?: ReadonlyMap<string, GuildEmoji>;\n}\n\n/**\n * An answer of an onboarding prompt, with the channels and roles it gives.\n */\nexport class GuildOnboardingPromptOption extends Structure<APIGuildOnboardingPromptOption> {\n declare public [kRelations]: GuildOnboardingRelations;\n\n /**\n * The guild, from the cache, like discord.js's `GuildOnboardingPromptOption#guild`.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * The cached channels the option gives access to, by ID, like discord.js's `GuildOnboardingPromptOption#channels`.\n */\n public get channels(): Map<string, AnyChannel> {\n return pick(this[kData].channel_ids, this[kRelations].channels);\n }\n\n /**\n * The cached roles the option gives, by ID, like discord.js's `GuildOnboardingPromptOption#roles`.\n */\n public get roles(): Map<string, Role> {\n return pick(this[kData].role_ids, this[kRelations].roles);\n }\n public get id() {\n return this[kData].id;\n }\n\n public get title() {\n return this[kData].title;\n }\n\n public get description() {\n return this[kData].description;\n }\n\n public get channelIds() {\n return this[kData].channel_ids;\n }\n\n public get roleIds() {\n return this[kData].role_ids;\n }\n\n /**\n * The emoji of the option: the cached custom emoji of the guild, like discord.js, else the payload's.\n */\n public get emoji(): GuildEmoji | ReactionEmoji | null {\n const { emoji } = this[kData];\n const cached = emoji?.id ? this[kRelations].emojis?.get(emoji.id) : undefined;\n return cached ?? (emoji?.id || emoji?.name ? new ReactionEmoji(emoji) : null);\n }\n}\n\n/**\n * A question of a guild's onboarding.\n */\nexport class GuildOnboardingPrompt extends Structure<APIGuildOnboardingPrompt> {\n declare public [kRelations]: GuildOnboardingRelations;\n\n /**\n * The guild, from the cache, like discord.js's `GuildOnboardingPrompt#guild`.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n public get id() {\n return this[kData].id;\n }\n\n public get title() {\n return this[kData].title;\n }\n\n public get type() {\n return this[kData].type;\n }\n\n public get singleSelect() {\n return this[kData].single_select;\n }\n\n public get required() {\n return this[kData].required;\n }\n\n /**\n * Whether the prompt is asked during onboarding, rather than only in the channels & roles page.\n */\n public get inOnboarding() {\n return this[kData].in_onboarding;\n }\n\n public get options(): GuildOnboardingPromptOption[] {\n return this[kData].options.map((option) =>\n bindClient(new GuildOnboardingPromptOption(option, this[kRelations]), this.client),\n );\n }\n}\n\n/**\n * The onboarding of a guild: the prompts new members answer, and the channels they start in.\n */\nexport class GuildOnboarding extends Structure<APIGuildOnboarding> {\n declare public [kRelations]: GuildOnboardingRelations;\n\n /**\n * @param data The raw onboarding.\n * @param relations The guild, as resolved from the cache.\n */\n public constructor(data: APIGuildOnboarding, relations: GuildOnboardingRelations = {}) {\n super(data, relations);\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n public get prompts(): GuildOnboardingPrompt[] {\n return this[kData].prompts.map((prompt) =>\n bindClient(new GuildOnboardingPrompt(prompt, this[kRelations]), this.client),\n );\n }\n\n /**\n * The channels members are in by default.\n */\n public get defaultChannelIds() {\n return this[kData].default_channel_ids;\n }\n\n /**\n * The cached channels members are added to by default, by ID, like discord.js's\n * `GuildOnboarding#defaultChannels`.\n */\n public get defaultChannels(): Map<string, AnyChannel> {\n return pick(this[kData].default_channel_ids, this[kRelations].channels);\n }\n\n public get enabled() {\n return this[kData].enabled;\n }\n\n public get mode() {\n return this[kData].mode;\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * Edits the onboarding.\n *\n * @param options The changes to apply.\n */\n public async edit(options: GuildOnboardingEditOptions): Promise<this> {\n const onboarding = await this.client.guilds.editOnboarding(this.guildId, options);\n return this[kPatch](onboarding.toJSON());\n }\n}\n","import type { ImageURLOptions } from \"@discordjs/rest\";\nimport {\n GuildScheduledEventStatus,\n type APIGuildScheduledEvent,\n type APIGuildScheduledEventRecurrenceRule,\n} from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type {\n GuildScheduledEventEditOptions,\n GuildScheduledEventSubscriber,\n GuildScheduledEventSubscribersOptions,\n} from \"../../managers/GuildScheduledEventManager.js\";\nimport { cdn } from \"../../util/cdn.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kPatch, kRelations, snowflakeTimestamp, Structure } from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\n/**\n * The relations of a {@link GuildScheduledEvent}, resolved from the cache by the guild's event manager.\n */\nexport interface GuildScheduledEventRelations {\n creator?: User | null;\n guild?: Guild | null;\n channel?: AnyChannel | null;\n}\n\n/**\n * An event scheduled in a guild: in a stage or voice channel, or somewhere else.\n */\nexport class GuildScheduledEvent extends Structure<APIGuildScheduledEvent> {\n declare public [kRelations]: GuildScheduledEventRelations;\n\n protected override optimizeData(data: Partial<APIGuildScheduledEvent>): void {\n this.optimizeTimestamp(\"scheduled_start_time\", data.scheduled_start_time);\n this.optimizeTimestamp(\"scheduled_end_time\", data.scheduled_end_time);\n }\n\n /**\n * @param data The raw event.\n * @param relations The creator, guild, and channel as resolved from the cache, by the guild's event manager.\n */\n public constructor(data: APIGuildScheduledEvent, relations: GuildScheduledEventRelations = {}) {\n super(data, relations);\n }\n\n public override [kPatch](data: Readonly<Partial<APIGuildScheduledEvent>>): this {\n if (data.creator) this.dropRelations(\"creator\");\n if (data.channel_id !== undefined) this.dropRelations(\"channel\");\n return super[kPatch](data);\n }\n\n public get id() {\n return this[kData].id;\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n public get channelId(): string | null {\n return this[kData].channel_id;\n }\n\n public get creatorId(): string | null {\n return this[kData].creator_id ?? null;\n }\n\n public get name() {\n return this[kData].name;\n }\n\n /**\n * Whether the event is partial: built from its IDs alone for an event about an uncached scheduled event, see\n * `Partials.GuildScheduledEvent`. Only `id` and `guildId` are reliable then, and {@link GuildScheduledEvent.fetch}\n * completes it.\n */\n public get partial(): boolean {\n return this[kData].name === undefined;\n }\n\n /**\n * Fetches the event from the API and patches this structure with the result.\n */\n public async fetch(): Promise<this> {\n const event = await this.client.guilds\n .scheduledEvents(this.guildId)\n .fetch(this.id, { force: true });\n return this[kPatch](event.toJSON());\n }\n\n public get description(): string | null {\n return this[kData].description ?? null;\n }\n\n public get scheduledStartTimestamp(): number {\n return this.optimizedTimestamp(\"scheduled_start_time\")!;\n }\n\n public get scheduledStartAt(): Date {\n return new Date(this.scheduledStartTimestamp);\n }\n\n public get scheduledEndTimestamp(): number | null {\n return this.optimizedTimestamp(\"scheduled_end_time\");\n }\n\n public get scheduledEndAt(): Date | null {\n const { scheduledEndTimestamp } = this;\n return scheduledEndTimestamp === null ? null : new Date(scheduledEndTimestamp);\n }\n\n public get privacyLevel() {\n return this[kData].privacy_level;\n }\n\n public get status() {\n return this[kData].status;\n }\n\n public get entityType() {\n return this[kData].entity_type;\n }\n\n public get entityId(): string | null {\n return this[kData].entity_id;\n }\n\n /**\n * Where an external event takes place.\n */\n public get location(): string | null {\n return this[kData].entity_metadata?.location ?? null;\n }\n\n /**\n * How many users subscribed, when the payload includes it.\n */\n public get userCount(): number | null {\n return this[kData].user_count ?? null;\n }\n\n public get image(): string | null {\n return this[kData].image ?? null;\n }\n\n public get recurrenceRule(): APIGuildScheduledEventRecurrenceRule | null {\n return this[kData].recurrence_rule;\n }\n\n /**\n * The creator, from the payload or the cache.\n */\n public get creator(): User | null {\n const { creator } = this[kData];\n return this[kRelations].creator ?? (creator ? new User(creator) : null);\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n public get channel(): AnyChannel | null {\n return this[kRelations].channel ?? null;\n }\n\n /**\n * The URL of the event.\n */\n public get url(): string {\n return `https://discord.com/events/${this.guildId}/${this.id}`;\n }\n\n public get createdTimestamp() {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n\n public coverImageURL(options?: Readonly<ImageURLOptions>): string | null {\n const { image } = this;\n return image ? cdn.guildScheduledEventCover(this.id, image, options) : null;\n }\n\n public isScheduled(): boolean {\n return this.status === GuildScheduledEventStatus.Scheduled;\n }\n\n public isActive(): boolean {\n return this.status === GuildScheduledEventStatus.Active;\n }\n\n public isCompleted(): boolean {\n return this.status === GuildScheduledEventStatus.Completed;\n }\n\n public isCanceled(): boolean {\n return this.status === GuildScheduledEventStatus.Canceled;\n }\n\n /**\n * Edits the event.\n *\n * @param options The fields to edit, and the reason for the audit log.\n */\n public async edit(options: GuildScheduledEventEditOptions): Promise<this> {\n const event = await this.client.guilds.scheduledEvents(this.guildId).edit(this.id, options);\n return this[kPatch](event.toJSON());\n }\n\n public setName(name: string, reason?: string): Promise<this> {\n return this.edit({ name, reason });\n }\n\n public setDescription(description: string | null, reason?: string): Promise<this> {\n return this.edit({ description, reason });\n }\n\n public setScheduledStartTime(scheduledStartTime: Date | number, reason?: string): Promise<this> {\n return this.edit({ scheduledStartTime, reason });\n }\n\n public setScheduledEndTime(\n scheduledEndTime: Date | number | null,\n reason?: string,\n ): Promise<this> {\n return this.edit({ scheduledEndTime, reason });\n }\n\n public setStatus(status: GuildScheduledEventStatus, reason?: string): Promise<this> {\n return this.edit({ status, reason });\n }\n\n /**\n * Sets where an external event takes place.\n */\n public setLocation(location: string, reason?: string): Promise<this> {\n return this.edit({ entityMetadata: { location }, reason });\n }\n\n /**\n * Fetches the users who subscribed to the event, paginated by user ID.\n *\n * @param options How many users, around which user ID, and whether to include their members.\n */\n public fetchSubscribers(\n options?: GuildScheduledEventSubscribersOptions,\n ): Promise<GuildScheduledEventSubscriber[]> {\n return this.client.guilds.scheduledEvents(this.guildId).fetchSubscribers(this.id, options);\n }\n\n public async delete(reason?: string): Promise<this> {\n await this.client.guilds.scheduledEvents(this.guildId).delete(this.id, reason);\n return this;\n }\n}\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { Guild } from \"./Guild.js\";\nimport type { Role } from \"./Role.js\";\nimport { kData, kPatch, kRelations, Structure } from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\n/**\n * The relations of an {@link Integration}, resolved from the cache by the guild's integration manager.\n */\nexport interface IntegrationRelations {\n user?: User | null;\n guild?: Guild | null;\n role?: Role | null;\n}\n\n/**\n * An integration of a guild: a bot, a Twitch or YouTube subscription, or a guild subscription.\n */\nexport class Integration extends Structure<CacheEntityTypes[\"integrations\"]> {\n declare public [kRelations]: IntegrationRelations;\n\n protected override optimizeData(data: Partial<CacheEntityTypes[\"integrations\"]>): void {\n this.optimizeTimestamp(\"synced_at\", data.synced_at);\n }\n\n /**\n * @param data The raw integration.\n * @param relations The user and guild as resolved from the cache, by the guild's integration manager.\n */\n public constructor(data: CacheEntityTypes[\"integrations\"], relations: IntegrationRelations = {}) {\n super(data, relations);\n }\n\n public get id() {\n return this[kData].id;\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n public get name() {\n return this[kData].name;\n }\n\n public get type() {\n return this[kData].type;\n }\n\n public get enabled(): boolean | null {\n return this[kData].enabled ?? null;\n }\n\n /**\n * Whether the integration is syncing. Bot integrations have none.\n */\n public get syncing(): boolean | null {\n return this[kData].syncing ?? null;\n }\n\n /**\n * The role given to the integration's subscribers.\n */\n public get roleId(): string | null {\n return this[kData].role_id ?? null;\n }\n\n /**\n * The role given to the integration's subscribers, from the cache, like discord.js's `Integration#role`: `null`\n * when it has none, when it is not cached, or when the integration was not built by a manager.\n */\n public get role(): Role | null {\n return this[kRelations].role ?? null;\n }\n\n public override [kPatch](data: Readonly<Partial<CacheEntityTypes[\"integrations\"]>>): this {\n if (data.user) this.dropRelations(\"user\");\n this.dropChangedRelations(data, { role: \"role_id\" });\n return super[kPatch](data);\n }\n\n public get enableEmoticons(): boolean | null {\n return this[kData].enable_emoticons ?? null;\n }\n\n public get expireBehavior() {\n return this[kData].expire_behavior ?? null;\n }\n\n /**\n * The grace period, in days, before expiring subscribers.\n */\n public get expireGracePeriod(): number | null {\n return this[kData].expire_grace_period ?? null;\n }\n\n /**\n * The user who added the integration.\n */\n public get user(): User | null {\n const { user } = this[kData];\n return this[kRelations].user ?? (user ? new User(user) : null);\n }\n\n /**\n * The account on the integration's service.\n */\n public get account() {\n return this[kData].account;\n }\n\n public get syncedTimestamp(): number | null {\n return this.optimizedTimestamp(\"synced_at\");\n }\n\n public get syncedAt(): Date | null {\n const { syncedTimestamp } = this;\n return syncedTimestamp === null ? null : new Date(syncedTimestamp);\n }\n\n public get subscriberCount(): number | null {\n return this[kData].subscriber_count ?? null;\n }\n\n public get revoked(): boolean | null {\n return this[kData].revoked ?? null;\n }\n\n /**\n * The application of a bot integration.\n */\n public get application() {\n return this[kData].application ?? null;\n }\n\n /**\n * The OAuth2 scopes the application was authorized with.\n */\n public get scopes() {\n return this[kData].scopes ?? [];\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * Removes the integration from the guild, kicking its bot if it has one.\n *\n * @param reason The reason for the audit log.\n */\n public async delete(reason?: string): Promise<this> {\n await this.client.guilds.integrations(this.guildId).delete(this.id, reason);\n return this;\n }\n}\n","import { Invite, Structure as BaseStructure, type APIActualInvite } from \"@discordjs/structures\";\nimport {\n InviteType,\n type APIApplication,\n type APIExtendedInvite,\n type APIInviteChannel,\n type GatewayInviteCreateDispatchData,\n} from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, kPatch, kRelations, StructureMixin } from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\n/**\n * The raw data of an invite, from the REST API (`APIExtendedInvite`, with a nested `channel` and `guild`) or from an\n * `INVITE_CREATE` dispatch (with `channel_id` and `guild_id`).\n */\nexport type InviteData = { code: string } & Partial<Omit<APIExtendedInvite, \"code\" | \"uses\">> &\n Partial<Omit<GatewayInviteCreateDispatchData, \"code\" | \"uses\">> & { uses?: number };\n\n/**\n * The relations of an invite, resolved from the cache by `client.guilds.invites()`.\n */\nexport interface InviteRelations {\n inviter?: User;\n targetUser?: User;\n guild?: Guild | null;\n channel?: AnyChannel | null;\n}\n\nexport interface BaseInvite<Data extends InviteData = InviteData> extends StructureMixin<\n Data,\n InviteRelations\n> {}\n\n/**\n * The base of every invite, to a guild, to a group direct message, or a friend invite: `@discordjs/structures`'\n * `Invite`, with its channel, inviter, target user, and discord.js' helpers.\n *\n * @typeParam Data The raw invite data this structure wraps.\n */\nexport class BaseInvite<Data extends InviteData = InviteData> extends Invite<\"\"> {\n /**\n * Keeps the raw `created_at` and `expires_at`, which `@discordjs/structures` strips and re-serializes in its own\n * format, so that {@link BaseInvite.toJSON} returns the invite as received.\n */\n public static override readonly DataTemplate: Partial<APIActualInvite> = {};\n\n protected override optimizeData(data: Partial<Data>): void {\n super.optimizeData(data as Partial<APIActualInvite>);\n this.optimizeTimestamp(\"created_at\", data.created_at);\n this.optimizeTimestamp(\"expires_at\", data.expires_at);\n }\n\n /**\n * @param data The raw invite.\n * @param relations The inviter, target user, and guild as resolved from the cache, by `client.guilds.invites()`.\n */\n public constructor(data: Data, relations: InviteRelations = {}) {\n // An `INVITE_CREATE` dispatch has neither the `type` nor the `channel` `@discordjs/structures` expects.\n super(data as unknown as APIActualInvite);\n initStructure(this, data, relations);\n }\n\n public [kPatch](data: Readonly<Partial<Data>>): this {\n if (data.inviter) this.dropRelations(\"inviter\");\n if (data.target_user) this.dropRelations(\"targetUser\");\n return StructureMixin.prototype[kPatch].call(this, data) as this;\n }\n\n /**\n * The URL of the invite.\n */\n public override get url(): string {\n return `https://discord.gg/${this.code}`;\n }\n\n public override get type(): InviteType {\n return this[kData].type ?? (this[kData].guild_id ? InviteType.Guild : InviteType.Friend);\n }\n\n public get channelId(): string | null {\n return this[kData].channel?.id ?? this[kData].channel_id ?? null;\n }\n\n /**\n * The channel the invite leads to, like discord.js's `BaseInvite#channel`: the cached channel, else the partial\n * channel the API returns with the invite, if any.\n */\n public get channel(): AnyChannel | APIInviteChannel | null {\n return this[kRelations].channel ?? this[kData].channel ?? null;\n }\n\n /**\n * The user who created the invite, if known.\n */\n public get inviter(): User | null {\n const { inviter } = this[kData];\n return this[kRelations].inviter ?? (inviter ? new User(inviter) : null);\n }\n\n public get inviterId(): string | null {\n return this[kData].inviter?.id ?? null;\n }\n\n public get targetUser(): User | null {\n const { target_user: targetUser } = this[kData];\n return this[kRelations].targetUser ?? (targetUser ? new User(targetUser) : null);\n }\n\n public get targetApplication(): Partial<APIApplication> | null {\n return this[kData].target_application ?? null;\n }\n\n public override get createdTimestamp(): number | null {\n return this.optimizedTimestamp(\"created_at\");\n }\n\n public get createdAt(): Date | null {\n const { createdTimestamp } = this;\n return createdTimestamp === null ? null : new Date(createdTimestamp);\n }\n\n /**\n * When the invite expires, `null` when it never does or it is unknown.\n */\n public override get expiresTimestamp(): number | null {\n const expiresAt = this.optimizedTimestamp(\"expires_at\");\n if (expiresAt !== null) return expiresAt;\n\n const { createdTimestamp, maxAge } = this;\n return createdTimestamp !== null && maxAge ? createdTimestamp + maxAge * 1000 : null;\n }\n\n public get expiresAt(): Date | null {\n const { expiresTimestamp } = this;\n return expiresTimestamp === null ? null : new Date(expiresTimestamp);\n }\n\n /**\n * Transforms this invite into its raw data, as received.\n *\n * @remarks\n * Typed as `@discordjs/structures`' `APIActualInvite`, but an invite built from an `INVITE_CREATE` dispatch has the\n * dispatch's fields instead.\n */\n public override toJSON(): APIActualInvite {\n return BaseStructure.prototype.toJSON.call(this) as APIActualInvite;\n }\n\n public override valueOf(): string {\n return this.code;\n }\n}\n\nMixin(BaseInvite, [StructureMixin]);\n","import type { APIInviteGuild } from \"discord-api-types/v10\";\nimport { AnonymousGuild } from \"./AnonymousGuild.js\";\n\n/**\n * The partial guild carried by a {@link GuildInvite}.\n *\n * @remarks\n * The welcome screen discord.js attaches here comes with the admin phase (see #54).\n */\nexport class InviteGuild extends AnonymousGuild<APIInviteGuild> {}\n","import { BaseInvite } from \"./BaseInvite.js\";\nimport { InviteGuild } from \"../guilds/InviteGuild.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport { kData, kRelations } from \"../Structure.js\";\n\n/**\n * An invite to a guild.\n */\nexport class GuildInvite extends BaseInvite {\n public get guildId(): string | null {\n return this[kData].guild?.id ?? this[kData].guild_id ?? null;\n }\n\n /**\n * The guild the invite leads to: the cached guild when the invite comes from a manager, like discord.js, else the\n * partial guild the API returns with the invite, if any.\n */\n public get guild(): Guild | InviteGuild | null {\n const { guild } = this[kData];\n return this[kRelations].guild ?? (guild ? new InviteGuild(guild) : null);\n }\n\n /**\n * Whether the bot can delete the invite: it created it, or it has `ManageGuild` (or `ManageChannels`).\n */\n public async fetchDeletable(): Promise<boolean> {\n const client = this.client;\n const { guildId } = this;\n if (!guildId) return false;\n if (this.inviterId === (client.user?.id ?? client.id)) return true;\n\n const me = await client.members.fetchMe(guildId);\n const permissions = await me.fetchPermissions();\n return permissions.any([\"ManageGuild\", \"ManageChannels\"]);\n }\n\n /**\n * Deletes the invite.\n *\n * @param reason The reason for the audit log.\n */\n public async delete(reason?: string): Promise<this> {\n const { guildId } = this;\n if (!guildId) throw new Error(`Invite ${this.code} has no known guild`);\n await this.client.guilds.invites(guildId).delete(this.code, reason);\n return this;\n }\n}\n","import type { StickerExtension } from \"@discordjs/rest\";\nimport { Sticker as BaseSticker } from \"@discordjs/structures\";\nimport { StickerFormatType, type APISticker } from \"discord-api-types/v10\";\nimport type { GuildStickerEditOptions } from \"../../managers/GuildStickerManager.js\";\nimport { cdn } from \"../../util/cdn.js\";\nimport type { StickerPack } from \"./StickerPack.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport {\n initStructure,\n kData,\n kPatch,\n kRelations,\n snowflakeTimestamp,\n StructureMixin,\n} from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\n/**\n * The relations of a {@link Sticker}, resolved from the cache by the guild's sticker manager.\n */\nexport interface StickerRelations {\n user?: User;\n guild?: Guild | null;\n}\n\nexport interface Sticker extends StructureMixin<APISticker, StickerRelations> {}\n\n/**\n * A sticker, a standard one from a sticker pack or a custom one of a guild: `@discordjs/structures`' `Sticker`, with\n * its guild, uploader, and URL, and actions through the client.\n */\nexport class Sticker extends BaseSticker {\n /**\n * @param data The raw sticker.\n * @param relations The uploader and guild as resolved from the cache, by the guild's sticker manager.\n */\n public constructor(data: APISticker, relations: StickerRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n public [kPatch](data: Readonly<Partial<APISticker>>): this {\n if (data.user) this.dropRelations(\"user\");\n return StructureMixin.prototype[kPatch].call(this, data) as this;\n }\n\n /**\n * The format of the sticker's image, an alias of `formatType`.\n */\n public get format() {\n return this.formatType;\n }\n\n /**\n * Whether the sticker can be used, `false` when its guild lost the boosts it needs.\n */\n public override get available(): boolean {\n return this[kData].available ?? true;\n }\n\n public get guildId(): string | null {\n return this[kData].guild_id ?? null;\n }\n\n /**\n * The guild, from the cache. `null` outside of guilds, when the guild is not cached, or when the sticker was not built by\n * a manager: use `fetchGuild()` to always get it.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * Fetches the guild, cache first. `null` outside of guilds.\n */\n public async fetchGuild(): Promise<Guild | null> {\n const { guildId } = this;\n return guildId ? this.client.guilds.fetch(guildId) : null;\n }\n\n /**\n * The ID of the pack of a standard sticker.\n */\n public get packId(): string | null {\n return this[kData].pack_id ?? null;\n }\n\n /**\n * The position of a standard sticker in its pack.\n */\n public get sortValue(): number | null {\n return this[kData].sort_value ?? null;\n }\n\n /**\n * The user who uploaded a guild sticker, when the payload includes it (it needs `ManageGuildExpressions`).\n */\n public get user(): User | null {\n const { user } = this[kData];\n return this[kRelations].user ?? (user ? new User(user) : null);\n }\n\n public override get createdTimestamp(): number {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n\n /**\n * The URL of the sticker's image: a GIF for GIF stickers, a JSON file for Lottie ones, a PNG otherwise.\n */\n public get url(): string {\n const extension: StickerExtension =\n this.formatType === StickerFormatType.GIF\n ? \"gif\"\n : this.formatType === StickerFormatType.Lottie\n ? \"json\"\n : \"png\";\n return cdn.sticker(this.id, extension);\n }\n\n /**\n * Fetches the sticker from the API and patches this structure with the result.\n */\n public async fetch(): Promise<this> {\n const sticker = await this.client.fetchSticker(this.id);\n return this[kPatch](sticker.toJSON());\n }\n\n /**\n * Fetches the pack of a standard sticker, `null` for a guild sticker.\n */\n public async fetchPack(): Promise<StickerPack | null> {\n const { packId } = this;\n if (!packId) return null;\n const packs = await this.client.fetchStickerPacks();\n return packs.find((pack) => pack.id === packId) ?? null;\n }\n\n /**\n * Fetches the user who uploaded a guild sticker, `null` for a standard one or without `ManageGuildExpressions`.\n */\n public async fetchUser(): Promise<User | null> {\n const { guildId } = this;\n if (!guildId) return null;\n return this.client.guilds.stickers(guildId).fetchUser(this.id);\n }\n\n /**\n * Edits a guild sticker.\n *\n * @param options The changes to apply.\n */\n public async edit(options: GuildStickerEditOptions): Promise<this> {\n const sticker = await this.client.guilds.stickers(this.requireGuildId()).edit(this.id, options);\n return this[kPatch](sticker.toJSON());\n }\n\n /**\n * Deletes a guild sticker.\n *\n * @param reason The reason for the audit log.\n */\n public async delete(reason?: string): Promise<this> {\n await this.client.guilds.stickers(this.requireGuildId()).delete(this.id, reason);\n return this;\n }\n\n /**\n * Whether this sticker has the same data as another one.\n * @param sticker The sticker to compare with.\n */\n public equals(sticker: Sticker): boolean {\n return (\n this.id === sticker.id &&\n this.name === sticker.name &&\n this.description === sticker.description &&\n this.tags === sticker.tags &&\n this.formatType === sticker.formatType &&\n this.available === sticker.available &&\n this.guildId === sticker.guildId\n );\n }\n\n private requireGuildId(): string {\n const { guildId } = this;\n if (!guildId) throw new Error(\"Only guild stickers can be edited or deleted\");\n return guildId;\n }\n}\n\nMixin(Sticker, [StructureMixin]);\n","import type { GatewayClient } from \"../../GatewayClient.js\";\nimport type { Message } from \"../messages/Message.js\";\nimport {\n MessagePayload,\n type MessagePayloadResolvable,\n type WebhookMessageCreateOptions,\n type WebhookMessageEditOptions,\n type WebhookThreadOptions,\n} from \"../messages/MessagePayload.js\";\nimport { snowflakeTimestamp } from \"../Structure.js\";\n\n/**\n * What {@link WebhookMixin} needs from the class it is mixed into.\n */\nexport interface WebhookMixin {\n readonly id: string;\n readonly token: string | null | undefined;\n readonly client: GatewayClient;\n}\n\n/**\n * The members shared by everything posting through a webhook's token, like discord.js's `Webhook.applyToClass`.\n *\n * @remarks\n * Every method calls the API with the webhook's token rather than with the bot's authorization, so they work for\n * webhooks of other applications too.\n */\nexport class WebhookMixin {\n /**\n * The URL to post to, built from the webhook's ID and token.\n */\n public get url(): string | undefined {\n const { token } = this;\n return token ? `https://discord.com/api/webhooks/${this.id}/${token}` : undefined;\n }\n\n public get createdTimestamp(): number {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt(): Date {\n return new Date(this.createdTimestamp);\n }\n\n /**\n * Sends a message through the webhook.\n *\n * @param options The message, its content, or a {@link MessagePayload}, and the thread to send it in.\n */\n public send(options: MessagePayloadResolvable<WebhookMessageCreateOptions>): Promise<Message> {\n return this.client.webhooks.send(\n this.id,\n this.requireToken(),\n MessagePayload.create(this, options, { webhook: true }),\n );\n }\n\n /**\n * Sends a Slack-compatible message through the webhook.\n *\n * @param body The Slack message.\n * @param options The thread to send it in.\n */\n public async sendSlackMessage(body: unknown, options: WebhookThreadOptions = {}): Promise<void> {\n await this.client.api.webhooks.executeSlack(this.id, this.requireToken(), body, {\n thread_id: options.threadId,\n });\n }\n\n /**\n * Fetches a message sent by the webhook.\n *\n * @param messageId The ID of the message.\n * @param options The thread the message is in.\n */\n public fetchMessage(messageId: string, options?: WebhookThreadOptions): Promise<Message> {\n return this.client.webhooks.fetchMessage(this.id, this.requireToken(), messageId, options);\n }\n\n /**\n * Edits a message sent by the webhook.\n *\n * @param messageId The ID of the message.\n * @param options The changes, the new content, or a {@link MessagePayload}, and the thread the message is in.\n */\n public editMessage(\n messageId: string,\n options: MessagePayloadResolvable<WebhookMessageEditOptions>,\n ): Promise<Message> {\n return this.client.webhooks.editMessage(\n this.id,\n this.requireToken(),\n messageId,\n MessagePayload.create(this, options, { webhook: true, edit: true }),\n );\n }\n\n /**\n * Deletes a message sent by the webhook.\n *\n * @param messageId The ID of the message.\n * @param options The thread the message is in.\n */\n public deleteMessage(messageId: string, options?: WebhookThreadOptions): Promise<void> {\n return this.client.webhooks.deleteMessage(this.id, this.requireToken(), messageId, options);\n }\n\n /**\n * Gets the webhook's token, throwing when it has none.\n *\n * @internal\n */\n public requireToken(): string {\n const { token } = this;\n if (!token) throw new Error(`Webhook ${this.id} has no token to post with`);\n return token;\n }\n}\n","import type { ImageURLOptions } from \"@discordjs/rest\";\nimport { Webhook as BaseWebhook } from \"@discordjs/structures\";\nimport { WebhookType, type APIWebhook } from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { WebhookEditOptions } from \"../../managers/WebhookManager.js\";\nimport { cdn } from \"../../util/cdn.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport { Mixin, type MixinTypes } from \"../Mixin.js\";\nimport {\n initStructure,\n kData,\n kPatch,\n kRelations,\n snowflakeTimestamp,\n StructureMixin,\n} from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\nimport { WebhookMixin } from \"./WebhookMixin.js\";\n\n/**\n * The relations of a {@link Webhook}, resolved from the cache by `client.webhooks`.\n */\nexport interface WebhookRelations {\n guild?: Guild | null;\n channel?: AnyChannel | null;\n sourceGuild?: Guild | null;\n sourceChannel?: AnyChannel | null;\n owner?: User;\n}\n\nexport interface Webhook\n extends StructureMixin<APIWebhook, WebhookRelations>, MixinTypes<BaseWebhook, [WebhookMixin]> {}\n\n/**\n * A webhook, an incoming one posting to a channel, a channel follower, or an application's: `@discordjs/structures`'\n * `Webhook`, with its owner, source, and URLs, and actions through the client.\n *\n * @remarks\n * `token` is only set for incoming webhooks, and only their creator (or the guild's managers) see it.\n */\nexport class Webhook extends BaseWebhook {\n /**\n * @param data The raw webhook.\n * @param relations The related structures, resolved from the cache.\n */\n public constructor(data: APIWebhook, relations: object = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n declare public [kRelations]: WebhookRelations;\n\n public override get guildId(): string | null {\n return this[kData].guild_id ?? null;\n }\n\n /**\n * The guild of the webhook, from the cache, like discord.js's `Webhook#guild`: `null` when it is not cached.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * The channel the webhook posts to, from the cache: `null` when it is not cached.\n */\n public get channel(): AnyChannel | null {\n return this[kRelations].channel ?? null;\n }\n\n /**\n * The user who created the webhook, from the cache, else from the payload.\n */\n public get owner(): User | null {\n const { user } = this[kData];\n return this[kRelations].owner ?? (user ? new User(user) : null);\n }\n\n /**\n * The guild a channel follower webhook posts from: the cached guild, else the partial one of the payload.\n */\n public get sourceGuild(): Guild | NonNullable<APIWebhook[\"source_guild\"]> | null {\n return this[kRelations].sourceGuild ?? this[kData].source_guild ?? null;\n }\n\n /**\n * The channel a channel follower webhook posts from: the cached channel, else the partial one of the payload.\n */\n public get sourceChannel(): AnyChannel | NonNullable<APIWebhook[\"source_channel\"]> | null {\n return this[kRelations].sourceChannel ?? this[kData].source_channel ?? null;\n }\n\n /**\n * The URL to post to, for webhooks with a token: the one Discord sent, or one built from the token.\n */\n public override get url(): string | undefined {\n const { token } = this;\n return (\n this[kData].url ??\n (token ? `https://discord.com/api/webhooks/${this.id}/${token}` : undefined)\n );\n }\n\n public override get createdTimestamp(): number {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n\n public avatarURL(options?: Readonly<ImageURLOptions>): string | null {\n const { avatar } = this;\n return avatar ? cdn.avatar(this.id, avatar, options) : null;\n }\n\n public isIncoming(): boolean {\n return this.type === WebhookType.Incoming;\n }\n\n public isChannelFollower(): boolean {\n return this.type === WebhookType.ChannelFollower;\n }\n\n public isApplicationCreated(): boolean {\n return this.type === WebhookType.Application;\n }\n\n /**\n * Edits the webhook, with its token when it has one (then it cannot be moved to another channel).\n *\n * @param options The fields to edit, and the reason for the audit log.\n */\n public async edit(options: WebhookEditOptions): Promise<this> {\n const token = options.channel === undefined ? this.token : undefined;\n const webhook = await this.client.webhooks.edit(this.id, options, token);\n return this[kPatch](webhook.toJSON());\n }\n\n /**\n * Deletes the webhook.\n *\n * @param reason The reason for the audit log.\n */\n public async delete(reason?: string): Promise<this> {\n await this.client.webhooks.delete(this.id, { token: this.token, reason });\n return this;\n }\n}\n\nMixin(Webhook, [StructureMixin, WebhookMixin]);\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n AuditLogEvent,\n type APIApplicationCommand,\n type APIAuditLogChange,\n type APIWebhook,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport type { AnyChannel } from \"../managers/ChannelManager.js\";\nimport { AutoModerationRule } from \"../structures/automoderation/AutoModerationRule.js\";\nimport type { GuildEmoji } from \"../structures/emojis/GuildEmoji.js\";\nimport type { Guild } from \"../structures/guilds/Guild.js\";\nimport { GuildOnboardingPrompt } from \"../structures/guilds/GuildOnboarding.js\";\nimport { GuildScheduledEvent } from \"../structures/guilds/GuildScheduledEvent.js\";\nimport { Integration } from \"../structures/guilds/Integration.js\";\nimport type { Role } from \"../structures/guilds/Role.js\";\nimport { GuildInvite } from \"../structures/invites/GuildInvite.js\";\nimport type { SoundboardSound } from \"../structures/soundboards/SoundboardSound.js\";\nimport { StageInstance } from \"../structures/stageInstances/StageInstance.js\";\nimport { Sticker } from \"../structures/stickers/Sticker.js\";\nimport { bindClient } from \"../structures/Structure.js\";\nimport type { User } from \"../structures/users/User.js\";\nimport { Webhook } from \"../structures/webhooks/Webhook.js\";\n\n/**\n * The kind of entity an audit log entry targets, like discord.js's `GuildAuditLogs.Targets`.\n */\nexport type AuditLogTargetType =\n | \"ApplicationCommand\"\n | \"AutoModeration\"\n | \"Channel\"\n | \"Emoji\"\n | \"Guild\"\n | \"GuildOnboardingPrompt\"\n | \"GuildScheduledEvent\"\n | \"Integration\"\n | \"Invite\"\n | \"Message\"\n | \"Role\"\n | \"SoundboardSound\"\n | \"StageInstance\"\n | \"Sticker\"\n | \"Thread\"\n | \"Unknown\"\n | \"User\"\n | \"Webhook\";\n\n/**\n * The entity an audit log entry targets, like discord.js's `AuditLogEntryTarget`: the cached structure, else a\n * structure (or an object) built from the entry's changes, at least holding the target's ID.\n */\nexport type AuditLogEntryTarget =\n | AnyChannel\n | APIApplicationCommand\n | AutoModerationRule\n | Guild\n | GuildEmoji\n | GuildInvite\n | GuildOnboardingPrompt\n | GuildScheduledEvent\n | Integration\n | Role\n | SoundboardSound\n | StageInstance\n | Sticker\n | User\n | Webhook\n | AuditLogPartialTarget;\n\n/**\n * A target known only by the entry: its ID, and the fields the entry changed.\n */\ninterface AuditLogPartialTarget {\n id: string | null;\n [key: string]: unknown;\n}\n\n/**\n * The entities of an audit log page, which the targets are looked up in before the cache.\n *\n * @internal\n */\nexport interface AuditLogEntities {\n users?: ReadonlyMap<string, User>;\n webhooks?: ReadonlyMap<string, Webhook>;\n integrations?: ReadonlyMap<string, Integration>;\n applicationCommands?: ReadonlyMap<string, APIApplicationCommand>;\n}\n\n/**\n * Gets the kind of entity an audit log action targets, like discord.js's `GuildAuditLogsEntry.targetType`.\n *\n * @param action The action.\n */\nexport function auditLogTargetType(action: AuditLogEvent): AuditLogTargetType {\n if (action < 10) return \"Guild\";\n if (action < 20) return \"Channel\";\n if (action < 30) return \"User\";\n if (action < 40) return \"Role\";\n if (action < 50) return \"Invite\";\n if (action < 60) return \"Webhook\";\n if (action < 70) return \"Emoji\";\n if (action < 80) return \"Message\";\n if (action < 83) return \"Integration\";\n if (action < 86) return \"StageInstance\";\n if (action < 100) return \"Sticker\";\n if (action < 110) return \"GuildScheduledEvent\";\n if (action < 120) return \"Thread\";\n if (action < 130) return \"ApplicationCommand\";\n if (action < 140) return \"SoundboardSound\";\n if (action < 143) return \"AutoModeration\";\n if (action < 146) return \"User\";\n if (action >= 163 && action <= 165) return \"GuildOnboardingPrompt\";\n return \"Unknown\";\n}\n\n/**\n * Folds the changes of an entry into the target's data, their new value else their old one, like discord.js.\n */\nfunction changesReduce(\n changes: readonly APIAuditLogChange[] | undefined,\n initial: Record<string, unknown> = {},\n): AuditLogPartialTarget {\n const data: AuditLogPartialTarget = { id: null, ...initial };\n for (const change of changes ?? []) {\n const {\n key,\n new_value: newValue,\n old_value: oldValue,\n } = change as {\n key: string;\n new_value?: unknown;\n old_value?: unknown;\n };\n data[key] = newValue ?? oldValue;\n }\n\n return data;\n}\n\n// A cache read that never rejects, so a failing cache degrades to the fallback target.\nasync function read<Value>(value: Promise<Value | undefined>): Promise<Value | undefined> {\n return value.catch(() => undefined);\n}\n\n/**\n * Resolves the target of an audit log entry from the cache, like discord.js's `GuildAuditLogsEntry#target`.\n *\n * @param client The client.\n * @param entry The raw entry, with its guild's ID.\n * @param entities The entities of the audit log page the entry comes from, if any.\n * @returns The target, `null` for user targets that are not cached (like discord.js without the `User` partial) and\n * for entries without a target.\n * @internal\n */\nexport async function resolveAuditLogTarget(\n client: GatewayClient,\n entry: CacheEntityTypes[\"auditLogEntries\"],\n entities: AuditLogEntities = {},\n): Promise<AuditLogEntryTarget | null> {\n const { guild_id: guildId, target_id: targetId, changes, options } = entry;\n const type = auditLogTargetType(entry.action_type);\n const { guilds } = client;\n const built = <Value extends object>(value: Value) => bindClient(value, client);\n\n if (type === \"Unknown\") return changesReduce(changes, { id: targetId });\n const user = async (userId: string) =>\n entities.users?.get(userId) ?? (await read(client.users.get(userId))) ?? null;\n if (type === \"User\") return targetId ? user(targetId) : null;\n if (!targetId && type !== \"Invite\") return null;\n const id = targetId!;\n\n switch (type) {\n case \"Guild\":\n return (await read(guilds.get(id))) ?? { id };\n case \"Channel\":\n case \"Thread\":\n return (await read(client.channels.get(id))) ?? changesReduce(changes, { id });\n case \"Role\":\n return (await read(client.roles.get(guildId, id))) ?? { id };\n case \"Invite\": {\n const { id: _id, ...changed } = changesReduce(changes);\n const code = changed.code as string | undefined;\n const cached = code ? await read(guilds.invites(guildId).get(code)) : undefined;\n return cached ?? built(new GuildInvite({ ...changed, code: code ?? \"\", guild_id: guildId }));\n }\n case \"Webhook\":\n return (\n entities.webhooks?.get(id) ??\n built(\n new Webhook(changesReduce(changes, { id, guild_id: guildId }) as unknown as APIWebhook),\n )\n );\n case \"Emoji\":\n return (await read(guilds.emojis(guildId).get(id))) ?? { id };\n case \"Message\":\n // Discord sends the channel's ID for bulk deletions, the author's otherwise.\n return entry.action_type === AuditLogEvent.MessageBulkDelete\n ? ((await read(client.channels.get(id))) ?? { id })\n : user(id);\n case \"Integration\":\n return (\n entities.integrations?.get(id) ??\n (await read(guilds.integrations(guildId).get(id))) ??\n built(new Integration(changesReduce(changes, { id, guild_id: guildId }) as never))\n );\n case \"StageInstance\": {\n const channelId = options?.channel_id;\n const cached = channelId\n ? await read(guilds.stageInstances(guildId).get(channelId))\n : undefined;\n return (\n cached ??\n built(\n new StageInstance(\n changesReduce(changes, { id, channel_id: channelId, guild_id: guildId }) as never,\n ),\n )\n );\n }\n case \"Sticker\":\n return (\n (await read(guilds.stickers(guildId).get(id))) ??\n built(new Sticker(changesReduce(changes, { id }) as never))\n );\n case \"GuildScheduledEvent\":\n return (\n (await read(guilds.scheduledEvents(guildId).get(id))) ??\n built(new GuildScheduledEvent(changesReduce(changes, { id, guild_id: guildId }) as never))\n );\n case \"ApplicationCommand\":\n return entities.applicationCommands?.get(id) ?? { id };\n case \"SoundboardSound\":\n return (await read(guilds.soundboardSounds(guildId).get(id))) ?? { id };\n case \"AutoModeration\":\n return (\n (await read(guilds.autoModerationRules(guildId).get(id))) ??\n built(new AutoModerationRule(changesReduce(changes, { id, guild_id: guildId }) as never))\n );\n case \"GuildOnboardingPrompt\":\n return entry.action_type === AuditLogEvent.OnboardingPromptCreate\n ? built(new GuildOnboardingPrompt(changesReduce(changes, { id }) as never))\n : changesReduce(changes, { id });\n default:\n return { id };\n }\n}\n","import type { GatewayClient } from \"../GatewayClient.js\";\nimport type { GuildEmoji } from \"../structures/emojis/GuildEmoji.js\";\nimport type { Role } from \"../structures/guilds/Role.js\";\n\n/**\n * Manages the roles allowed to use one custom emoji. When it has none, everyone can use it.\n */\nexport class GuildEmojiRoleManager {\n public readonly client: GatewayClient;\n public readonly guildId: string;\n public readonly emojiId: string;\n\n readonly #roleIds: readonly string[];\n\n public constructor(\n client: GatewayClient,\n guildId: string,\n emojiId: string,\n roleIds: readonly string[],\n ) {\n this.client = client;\n this.guildId = guildId;\n this.emojiId = emojiId;\n this.#roleIds = roleIds;\n }\n\n /**\n * The IDs of the allowed roles.\n */\n public get ids(): readonly string[] {\n return this.#roleIds;\n }\n\n /**\n * Fetches the allowed roles, cache first.\n */\n public fetch(): Promise<Role[]> {\n return Promise.all(this.#roleIds.map((id) => this.client.roles.fetch(this.guildId, id)));\n }\n\n /**\n * Allows more roles to use the emoji.\n *\n * @param roles The ID of the role, or several IDs.\n */\n public add(roles: string | readonly string[]): Promise<GuildEmoji> {\n const added = typeof roles === \"string\" ? [roles] : roles;\n return this.set([...new Set([...this.#roleIds, ...added])]);\n }\n\n /**\n * Stops allowing roles to use the emoji.\n *\n * @param roles The ID of the role, or several IDs.\n */\n public remove(roles: string | readonly string[]): Promise<GuildEmoji> {\n const removed = new Set(typeof roles === \"string\" ? [roles] : roles);\n return this.set(this.#roleIds.filter((id) => !removed.has(id)));\n }\n\n /**\n * Replaces the allowed roles, everyone when empty.\n *\n * @param roles The IDs of the roles.\n */\n public set(roles: readonly string[]): Promise<GuildEmoji> {\n return this.client.guilds.emojis(this.guildId).edit(this.emojiId, { roles });\n }\n}\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { GuildEmojiEditOptions } from \"../../managers/GuildEmojiManager.js\";\nimport { GuildEmojiRoleManager } from \"../../managers/GuildEmojiRoleManager.js\";\nimport { Emoji } from \"./Emoji.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport { kData, kPatch, kRelations } from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\n/**\n * The relations of a {@link GuildEmoji}, resolved from the cache by the guild's emoji manager.\n */\nexport interface GuildEmojiRelations {\n author?: User;\n guild?: Guild | null;\n}\n\n/**\n * A custom emoji of a guild.\n */\nexport class GuildEmoji extends Emoji<CacheEntityTypes[\"emojis\"], GuildEmojiRelations> {\n /**\n * @param data The raw emoji.\n * @param relations The uploader and guild as resolved from the cache, by the guild's emoji manager.\n */\n public constructor(data: CacheEntityTypes[\"emojis\"], relations: GuildEmojiRelations = {}) {\n super(data, relations);\n }\n\n public override [kPatch](data: Readonly<Partial<CacheEntityTypes[\"emojis\"]>>): this {\n if (data.user) this.dropRelations(\"author\");\n return super[kPatch](data);\n }\n\n public override get id(): string {\n return this[kData].id!;\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n /**\n * The guild, from the cache. `null` when the guild is not cached, or when the emoji was not built by a manager: use\n * `fetchGuild()` to always get it.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * Fetches the guild, cache first.\n */\n public fetchGuild(): Promise<Guild> {\n return this.client.guilds.fetch(this.guildId);\n }\n\n /**\n * Whether the emoji is managed by an integration, e.g. Twitch.\n */\n public override get managed(): boolean {\n return this[kData].managed ?? false;\n }\n\n public get requiresColons(): boolean {\n return this[kData].require_colons ?? true;\n }\n\n /**\n * Whether the emoji can be used, `false` when the guild lost the boosts it needs.\n */\n public override get available(): boolean {\n return this[kData].available ?? true;\n }\n\n /**\n * The IDs of the roles allowed to use the emoji, everyone when empty.\n */\n public get roleIds(): readonly string[] {\n return this[kData].roles ?? [];\n }\n\n /**\n * The roles allowed to use the emoji.\n */\n public get roles(): GuildEmojiRoleManager {\n return new GuildEmojiRoleManager(this.client, this.guildId, this.id, this.roleIds);\n }\n\n /**\n * The user who uploaded the emoji, when the payload includes it (it needs `ManageGuildExpressions`).\n */\n public get author(): User | null {\n const { user } = this[kData];\n return this[kRelations].author ?? (user ? new User(user) : null);\n }\n\n /**\n * Whether the bot can delete the emoji: it is not managed, and the bot has `ManageGuildExpressions`.\n */\n public async fetchDeletable(): Promise<boolean> {\n if (this.managed) return false;\n const me = await this.client.members.fetchMe(this.guildId);\n return (await me.fetchPermissions()).has(\"ManageGuildExpressions\");\n }\n\n /**\n * Fetches the user who uploaded the emoji.\n */\n public fetchAuthor(): Promise<User | null> {\n return this.client.guilds.emojis(this.guildId).fetchAuthor(this.id);\n }\n\n public async edit(options: GuildEmojiEditOptions): Promise<this> {\n const emoji = await this.client.guilds.emojis(this.guildId).edit(this.id, options);\n return this[kPatch](emoji.toJSON());\n }\n\n public setName(name: string, reason?: string): Promise<this> {\n return this.edit({ name, reason });\n }\n\n public async delete(reason?: string): Promise<this> {\n await this.client.guilds.emojis(this.guildId).delete(this.id, reason);\n return this;\n }\n\n /**\n * Whether this emoji has the same data as another one.\n * @param emoji The emoji to compare with.\n */\n public equals(emoji: GuildEmoji): boolean {\n return (\n this.id === emoji.id &&\n this.name === emoji.name &&\n this.managed === emoji.managed &&\n this.available === emoji.available &&\n this.requiresColons === emoji.requiresColons &&\n this.roleIds.length === emoji.roleIds.length &&\n this.roleIds.every((id) => emoji.roleIds.includes(id))\n );\n }\n}\n","import type { BaseImageURLOptions, ImageURLOptions } from \"@discordjs/rest\";\nimport type { APIGuildPreview } from \"discord-api-types/v10\";\nimport { cdn } from \"../../util/cdn.js\";\nimport { GuildEmoji } from \"../emojis/GuildEmoji.js\";\nimport { Sticker } from \"../stickers/Sticker.js\";\nimport { kData, snowflakeTimestamp, Structure } from \"../Structure.js\";\n\n/**\n * The public preview of a guild, available for discoverable guilds and the ones the bot is in.\n */\nexport class GuildPreview extends Structure<APIGuildPreview> {\n public get id() {\n return this[kData].id;\n }\n\n public get name() {\n return this[kData].name;\n }\n\n public get icon() {\n return this[kData].icon;\n }\n\n public get splash() {\n return this[kData].splash;\n }\n\n public get discoverySplash() {\n return this[kData].discovery_splash;\n }\n\n public get description() {\n return this[kData].description;\n }\n\n public get features() {\n return this[kData].features;\n }\n\n public get approximateMemberCount() {\n return this[kData].approximate_member_count;\n }\n\n public get approximatePresenceCount() {\n return this[kData].approximate_presence_count;\n }\n\n public get emojis(): GuildEmoji[] {\n return this[kData].emojis.map((emoji) => new GuildEmoji({ ...emoji, guild_id: this.id }));\n }\n\n public get stickers(): Sticker[] {\n return this[kData].stickers.map((sticker) => new Sticker(sticker));\n }\n\n public get createdTimestamp() {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n\n public iconURL(options?: ImageURLOptions): string | null {\n const { icon } = this;\n return icon ? cdn.icon(this.id, icon, options) : null;\n }\n\n public splashURL(options?: BaseImageURLOptions): string | null {\n const { splash } = this;\n return splash ? cdn.splash(this.id, splash, options) : null;\n }\n\n public discoverySplashURL(options?: BaseImageURLOptions): string | null {\n const { discoverySplash } = this;\n return discoverySplash ? cdn.discoverySplash(this.id, discoverySplash, options) : null;\n }\n\n public toString(): string {\n return this.name;\n }\n}\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport { AuditLogEvent, type APIAuditLogChange } from \"discord-api-types/v10\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kRelations, snowflakeTimestamp, Structure } from \"../Structure.js\";\nimport type { User } from \"../users/User.js\";\nimport {\n auditLogTargetType,\n type AuditLogEntryTarget,\n type AuditLogTargetType,\n} from \"../../util/auditLogs.js\";\n\n/**\n * Whether an audit log action created, deleted, or updated something, like discord.js's `actionType`.\n */\nexport type AuditLogActionType = \"Create\" | \"Delete\" | \"Update\";\n\nconst CreateActions = new Set<AuditLogEvent>([\n AuditLogEvent.ChannelCreate,\n AuditLogEvent.ChannelOverwriteCreate,\n AuditLogEvent.MemberBanRemove,\n AuditLogEvent.BotAdd,\n AuditLogEvent.RoleCreate,\n AuditLogEvent.InviteCreate,\n AuditLogEvent.WebhookCreate,\n AuditLogEvent.EmojiCreate,\n AuditLogEvent.MessagePin,\n AuditLogEvent.IntegrationCreate,\n AuditLogEvent.StageInstanceCreate,\n AuditLogEvent.StickerCreate,\n AuditLogEvent.GuildScheduledEventCreate,\n AuditLogEvent.ThreadCreate,\n AuditLogEvent.SoundboardSoundCreate,\n AuditLogEvent.AutoModerationRuleCreate,\n AuditLogEvent.OnboardingPromptCreate,\n]);\n\nconst DeleteActions = new Set<AuditLogEvent>([\n AuditLogEvent.ChannelDelete,\n AuditLogEvent.ChannelOverwriteDelete,\n AuditLogEvent.MemberKick,\n AuditLogEvent.MemberPrune,\n AuditLogEvent.MemberBanAdd,\n AuditLogEvent.MemberDisconnect,\n AuditLogEvent.RoleDelete,\n AuditLogEvent.InviteDelete,\n AuditLogEvent.WebhookDelete,\n AuditLogEvent.EmojiDelete,\n AuditLogEvent.MessageDelete,\n AuditLogEvent.MessageBulkDelete,\n AuditLogEvent.MessageUnpin,\n AuditLogEvent.IntegrationDelete,\n AuditLogEvent.StageInstanceDelete,\n AuditLogEvent.StickerDelete,\n AuditLogEvent.GuildScheduledEventDelete,\n AuditLogEvent.ThreadDelete,\n AuditLogEvent.SoundboardSoundDelete,\n AuditLogEvent.AutoModerationRuleDelete,\n AuditLogEvent.OnboardingPromptDelete,\n]);\n\n/**\n * The relations of a {@link GuildAuditLogsEntry}: the users of the audit log page, or of the cache.\n */\nexport interface GuildAuditLogsEntryRelations {\n executor?: User | null;\n guild?: Guild | null;\n /**\n * The entity the entry targets, see {@link GuildAuditLogsEntry.target}.\n */\n target?: AuditLogEntryTarget | null;\n}\n\n/**\n * An entry of a guild's audit log.\n */\nexport class GuildAuditLogsEntry extends Structure<CacheEntityTypes[\"auditLogEntries\"]> {\n declare public [kRelations]: GuildAuditLogsEntryRelations;\n\n /**\n * @param data The raw entry, with its guild's ID.\n * @param relations The executor and guild, resolved by `guild.fetchAuditLogs()` or the event.\n */\n public constructor(\n data: CacheEntityTypes[\"auditLogEntries\"],\n relations: GuildAuditLogsEntryRelations = {},\n ) {\n super(data, relations);\n }\n\n public get id() {\n return this[kData].id;\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n public get action(): AuditLogEvent {\n return this[kData].action_type;\n }\n\n public get actionType(): AuditLogActionType {\n if (CreateActions.has(this.action)) return \"Create\";\n if (DeleteActions.has(this.action)) return \"Delete\";\n return \"Update\";\n }\n\n /**\n * The ID of the user or application that made the change.\n */\n public get executorId(): string | null {\n return this[kData].user_id;\n }\n\n /**\n * The ID of the affected entity: a user, role, channel, webhook, ...\n */\n public get targetId(): string | null {\n return this[kData].target_id;\n }\n\n /**\n * The kind of entity the entry targets, like discord.js's `GuildAuditLogsEntry#targetType`.\n */\n public get targetType(): AuditLogTargetType {\n return auditLogTargetType(this.action);\n }\n\n /**\n * The entity the entry targets, like discord.js's `GuildAuditLogsEntry#target`: the cached structure, else one (or\n * an object) built from the entry's changes, holding at least the target's ID. `null` for users that are not\n * cached, and for entries without a target. Without a manager, only `{ id }`.\n */\n public get target(): AuditLogEntryTarget | null {\n const resolved = this[kRelations].target;\n if (resolved !== undefined) return resolved;\n const { targetId } = this;\n return targetId ? { id: targetId } : null;\n }\n\n public get reason(): string | null {\n return this[kData].reason ?? null;\n }\n\n /**\n * The changed fields, with their old and new values.\n */\n public get changes(): readonly APIAuditLogChange[] {\n return this[kData].changes ?? [];\n }\n\n /**\n * The extra details of some actions, e.g. the channel of a message deletion.\n */\n public get extra() {\n return this[kData].options ?? null;\n }\n\n public get executor(): User | null {\n return this[kRelations].executor ?? null;\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n public get createdTimestamp() {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n}\n","import { GuildFeature, type APIGuildWelcomeScreen } from \"discord-api-types/v10\";\nimport type { GuildWelcomeScreenEditOptions } from \"../../managers/GuildManager.js\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { GuildEmoji } from \"../emojis/GuildEmoji.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { ReactionEmoji } from \"../emojis/ReactionEmoji.js\";\nimport { kData, kPatch, kRelations, Structure } from \"../Structure.js\";\n\n/**\n * The raw data of a welcome screen, with the ID of its guild.\n */\nexport type WelcomeScreenData = APIGuildWelcomeScreen & { guild_id: string };\n\n/**\n * A channel suggested by a welcome screen.\n */\nexport interface WelcomeChannel {\n channelId: string;\n /**\n * The channel, from the cache, like discord.js's `WelcomeChannel#channel`: `null` when it is not cached, or when\n * the welcome screen was not built by `client.guilds`.\n */\n channel: AnyChannel | null;\n description: string;\n /**\n * The emoji shown next to the channel, if any: the cached custom emoji of the guild, else the payload's.\n */\n emoji: GuildEmoji | ReactionEmoji | null;\n}\n\n/**\n * The relations of a {@link WelcomeScreen}: its guild, and the channels and emojis of its welcome channels, when\n * cached.\n */\nexport interface WelcomeScreenRelations {\n guild?: Guild | null;\n /**\n * The cached channels of the welcome channels, by ID.\n */\n channels?: ReadonlyMap<string, AnyChannel>;\n /**\n * The cached custom emojis of the welcome channels, by ID.\n */\n emojis?: ReadonlyMap<string, GuildEmoji>;\n}\n\n/**\n * The screen new members of a community guild see, suggesting channels to start with.\n */\nexport class WelcomeScreen extends Structure<WelcomeScreenData> {\n declare public [kRelations]: WelcomeScreenRelations;\n\n /**\n * @param data The raw welcome screen.\n * @param relations The guild, as resolved from the cache.\n */\n public constructor(data: WelcomeScreenData, relations: WelcomeScreenRelations = {}) {\n super(data, relations);\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n public get description() {\n return this[kData].description;\n }\n\n public get welcomeChannels(): WelcomeChannel[] {\n const { channels, emojis } = this[kRelations];\n return this[kData].welcome_channels.map((channel) => ({\n channelId: channel.channel_id,\n channel: channels?.get(channel.channel_id) ?? null,\n description: channel.description,\n emoji:\n (channel.emoji_id && emojis?.get(channel.emoji_id)) ||\n (channel.emoji_id || channel.emoji_name\n ? new ReactionEmoji({ id: channel.emoji_id, name: channel.emoji_name })\n : null),\n }));\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * Whether the welcome screen is shown, from the features of the cached guild; `null` when it is not cached.\n */\n public get enabled(): boolean | null {\n return this.guild?.features.includes(GuildFeature.WelcomeScreenEnabled) ?? null;\n }\n\n /**\n * Edits the welcome screen.\n *\n * @param options The changes to apply.\n */\n public async edit(options: GuildWelcomeScreenEditOptions): Promise<this> {\n const screen = await this.client.guilds.editWelcomeScreen(this.guildId, options);\n return this[kPatch](screen.toJSON());\n }\n}\n","import {\n autoModerationRuleKey,\n type Awaitable,\n type CacheEntityTypes,\n} from \"@wolfstar/plugin-cache\";\nimport {\n type APIAutoModerationAction,\n type APIAutoModerationRuleTriggerMetadata,\n type AutoModerationRuleEventType,\n type AutoModerationRuleTriggerType,\n type RESTPatchAPIAutoModerationRuleJSONBody,\n type RESTPostAPIAutoModerationRuleJSONBody,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { AutoModerationRule } from \"../structures/automoderation/AutoModerationRule.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { resolveId, type IdResolvable } from \"../util/channels.js\";\nimport { CachedManager } from \"./CachedManager.js\";\n\n/**\n * The fields of an auto moderation rule that can be edited.\n */\nexport interface AutoModerationRuleEditOptions {\n name?: string;\n eventType?: AutoModerationRuleEventType;\n /**\n * The trigger's settings. Discord replaces them as a whole.\n */\n triggerMetadata?: APIAutoModerationRuleTriggerMetadata;\n actions?: readonly APIAutoModerationAction[];\n enabled?: boolean;\n exemptRoles?: readonly IdResolvable[];\n exemptChannels?: readonly IdResolvable[];\n reason?: string;\n}\n\n/**\n * The options to create an auto moderation rule with.\n */\nexport interface AutoModerationRuleCreateOptions extends AutoModerationRuleEditOptions {\n name: string;\n eventType: AutoModerationRuleEventType;\n triggerType: AutoModerationRuleTriggerType;\n actions: readonly APIAutoModerationAction[];\n}\n\n/**\n * Manages the auto moderation rules of one guild.\n */\nexport class AutoModerationRuleManager extends CachedManager<\n \"autoModerationRules\",\n AutoModerationRule,\n [ruleId: string]\n> {\n public readonly guildId: string;\n\n public constructor(client: GatewayClient, guildId: string) {\n super(client, \"autoModerationRules\");\n this.guildId = guildId;\n }\n\n public construct(data: CacheEntityTypes[\"autoModerationRules\"]): AutoModerationRule {\n return new AutoModerationRule(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"autoModerationRules\"]): string {\n return this.resolveKey(data.id);\n }\n\n public resolveKey(ruleId: string): string {\n return autoModerationRuleKey(this.guildId, ruleId);\n }\n\n public override _hydrate(\n data: CacheEntityTypes[\"autoModerationRules\"],\n ): Awaitable<AutoModerationRule> {\n return whenAll(\n [this.cachedGuild(data.guild_id)],\n ([guild]) => new AutoModerationRule(data, { guild }),\n );\n }\n\n /**\n * Fetches every rule of the guild, and caches them.\n */\n public async fetchAll(): Promise<AutoModerationRule[]> {\n const rules = await this.client.api.guilds.getAutoModerationRules(this.guildId);\n return Promise.all(rules.map((rule) => this._add(rule)));\n }\n\n /**\n * Creates a rule.\n *\n * @param options The rule's name, trigger, actions, and exemptions.\n */\n public async create(options: AutoModerationRuleCreateOptions): Promise<AutoModerationRule> {\n const body: RESTPostAPIAutoModerationRuleJSONBody = {\n ...toRuleBody(options),\n name: options.name,\n event_type: options.eventType,\n trigger_type: options.triggerType,\n actions: [...options.actions],\n };\n const rule = await this.client.api.guilds.createAutoModerationRule(this.guildId, body, {\n reason: options.reason,\n });\n return this._add(rule);\n }\n\n /**\n * Edits a rule.\n *\n * @param ruleId The ID of the rule.\n * @param options The fields to edit, and the reason for the audit log.\n */\n public async edit(\n ruleId: string,\n options: AutoModerationRuleEditOptions,\n ): Promise<AutoModerationRule> {\n const rule = await this.client.api.guilds.editAutoModerationRule(\n this.guildId,\n ruleId,\n toRuleBody(options),\n {\n reason: options.reason,\n },\n );\n return this._add(rule);\n }\n\n /**\n * Deletes a rule.\n *\n * @param ruleId The ID of the rule.\n * @param reason The reason for the audit log.\n */\n public async delete(ruleId: string, reason?: string): Promise<void> {\n await this.client.api.guilds.deleteAutoModerationRule(this.guildId, ruleId, { reason });\n await this.cache?.delete(this.resolveKey(ruleId));\n }\n\n protected async fetchRaw(ruleId: string) {\n return this.client.api.guilds.getAutoModerationRule(this.guildId, ruleId);\n }\n}\n\nfunction toRuleBody(\n options: AutoModerationRuleEditOptions,\n): RESTPatchAPIAutoModerationRuleJSONBody {\n const body: RESTPatchAPIAutoModerationRuleJSONBody = {\n name: options.name,\n event_type: options.eventType,\n trigger_metadata: options.triggerMetadata,\n actions: options.actions && [...options.actions],\n enabled: options.enabled,\n exempt_roles: options.exemptRoles?.map(resolveId),\n exempt_channels: options.exemptChannels?.map(resolveId),\n };\n for (const key of Object.keys(body) as (keyof typeof body)[]) {\n if (body[key] === undefined) delete body[key];\n }\n\n return body;\n}\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kRelations, Structure } from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\n/**\n * The raw data of a ban: the banned user, the guild, and the reason when it came from the API.\n */\nexport type GuildBanData = CacheEntityTypes[\"bans\"] & { reason?: string | null };\n\n/**\n * The relations of a {@link GuildBan}, resolved from the cache by the guild's ban manager.\n */\nexport interface GuildBanRelations {\n user?: User;\n guild?: Guild | null;\n}\n\n/**\n * A ban of a user from a guild.\n */\nexport class GuildBan extends Structure<GuildBanData> {\n declare public [kRelations]: GuildBanRelations;\n\n /**\n * @param data The raw ban.\n * @param relations The user and guild as resolved from the cache, by the guild's ban manager.\n */\n public constructor(data: GuildBanData, relations: GuildBanRelations = {}) {\n super(data, relations);\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n public get user(): User {\n return this[kRelations].user ?? new User(this[kData].user);\n }\n\n /**\n * The reason of the ban. Only bans fetched from the API have it: the gateway does not send it.\n */\n public get reason(): string | null {\n return this[kData].reason ?? null;\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * Fetches the ban from the API, which knows its reason.\n */\n public fetch(): Promise<GuildBan> {\n return this.client.guilds.bans(this.guildId).fetch(this.user.id, { force: true });\n }\n\n /**\n * Lifts the ban.\n *\n * @param reason The reason for the audit log.\n */\n public async remove(reason?: string): Promise<this> {\n await this.client.guilds.bans(this.guildId).remove(this.user.id, reason);\n return this;\n }\n}\n","import { banKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { APIBan } from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { GuildBan, type GuildBanData } from \"../structures/guilds/GuildBan.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { resolveId, type IdResolvable } from \"../util/channels.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\nimport type { BanOptions } from \"./GuildMemberManager.js\";\n\n/**\n * The options to list the bans of a guild with. `before` and `after` are user IDs.\n */\nexport interface GuildBanListOptions {\n /**\n * How many bans to fetch, up to 1000.\n */\n limit?: number;\n before?: string;\n after?: string;\n}\n\n/**\n * Manages the bans of one guild.\n *\n * @remarks\n * The gateway does not send ban reasons, so bans cached from `guildBanAdd` have none. `fetch` with `force` gets it.\n */\nexport class GuildBanManager extends CachedManager<\"bans\", GuildBan, [userId: string]> {\n public readonly guildId: string;\n\n public constructor(client: GatewayClient, guildId: string) {\n super(client, \"bans\");\n this.guildId = guildId;\n }\n\n public construct(data: CacheEntityTypes[\"bans\"]): GuildBan {\n return new GuildBan(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"bans\"]): string {\n return this.resolveKey(data.user.id);\n }\n\n public resolveKey(userId: string): string {\n return banKey(this.guildId, userId);\n }\n\n /**\n * Adds a ban to the cache, and its user to `client.users`.\n *\n * @internal\n */\n public override async _add(\n data: CacheEntityTypes[\"bans\"],\n cache = true,\n options?: AddOptions,\n ): Promise<GuildBan> {\n await this.client.users._add(data.user, cache);\n return super._add(data, cache, options);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"bans\"]): Awaitable<GuildBan> {\n return whenAll(\n [this.client.users._resolveData(data.user), this.cachedGuild(data.guild_id)],\n ([user, guild]) => new GuildBan(data, { user, guild }),\n );\n }\n\n /**\n * Lists the bans of the guild, paginated by user ID, and caches them.\n *\n * @param options How many bans, and around which user ID.\n */\n public async list(options: GuildBanListOptions = {}): Promise<GuildBan[]> {\n const bans = await this.client.api.guilds.getMemberBans(this.guildId, options);\n return Promise.all(bans.map((ban) => this._add(this.toData(ban))));\n }\n\n /**\n * Bans a user, member or not. The same as `client.members.ban`.\n *\n * @param user The user, or its ID.\n * @param options The reason, and how many seconds of the user's messages to delete.\n */\n public create(user: IdResolvable, options?: BanOptions): Promise<void> {\n return this.client.members.ban(this.guildId, resolveId(user), options);\n }\n\n /**\n * Lifts a ban, and drops it from the cache.\n *\n * @param user The user, or its ID.\n * @param reason The reason for the audit log.\n */\n public async remove(user: IdResolvable, reason?: string): Promise<void> {\n const userId = resolveId(user);\n await this.client.members.unban(this.guildId, userId, reason);\n await this.cache?.delete(this.resolveKey(userId));\n }\n\n /**\n * Bans up to 200 users at once.\n *\n * @param users The users, or their IDs.\n * @param options The reason, and how many seconds of the users' messages to delete.\n */\n public bulkCreate(\n users: readonly IdResolvable[],\n options?: BanOptions,\n ): Promise<{ bannedUsers: string[]; failedUsers: string[] }> {\n return this.client.members.bulkBan(this.guildId, users.map(resolveId), options);\n }\n\n protected async fetchRaw(userId: string) {\n const ban = await this.client.api.guilds.getMemberBan(this.guildId, userId);\n return this.toData(ban);\n }\n\n private toData(ban: APIBan): CacheEntityTypes[\"bans\"] {\n const data: GuildBanData = { ...ban, guild_id: this.guildId };\n return data;\n }\n}\n","import type { APIChannel, RESTPostAPIGuildChannelJSONBody } from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport {\n resolveId,\n toChannelBody,\n type GuildChannelCreateOptions,\n type GuildChannelEditOptions,\n type IdResolvable,\n} from \"../util/channels.js\";\nimport type { AnyChannel } from \"./ChannelManager.js\";\n\n/**\n * A channel's new position, for {@link GuildChannelManager.setPositions}.\n */\nexport interface ChannelPosition {\n channel: IdResolvable;\n position?: number;\n /**\n * The new category, `null` to move the channel out of its category.\n */\n parent?: IdResolvable | null;\n /**\n * Whether to copy the new category's overwrites, when `parent` is set.\n */\n lockPermissions?: boolean;\n}\n\n/**\n * Manages the channels of one guild. Channels are cached by `client.channels`, which this manager writes to.\n */\nexport class GuildChannelManager {\n public readonly client: GatewayClient;\n public readonly guildId: string;\n\n public constructor(client: GatewayClient, guildId: string) {\n this.client = client;\n this.guildId = guildId;\n }\n\n /**\n * Fetches every channel of the guild, threads excluded, and caches them.\n */\n public async fetch(): Promise<AnyChannel[]> {\n const channels = (await this.client.api.guilds.getChannels(this.guildId)) as APIChannel[];\n return Promise.all(\n channels.map((channel) => this.client.channels._add({ ...channel, guild_id: this.guildId })),\n );\n }\n\n /**\n * Creates a channel in the guild.\n *\n * @param options The channel's name, type, and settings.\n */\n public async create(options: GuildChannelCreateOptions): Promise<AnyChannel> {\n const body = {\n ...toChannelBody(options),\n type: options.type,\n } as RESTPostAPIGuildChannelJSONBody;\n const channel = await this.client.api.guilds.createChannel(this.guildId, body, {\n reason: options.reason,\n });\n return this.client.channels._add(channel);\n }\n\n /**\n * Edits a channel of the guild.\n *\n * @param channel The channel, or its ID.\n * @param options The fields to edit, and the reason for the audit log.\n */\n public edit(channel: IdResolvable, options: GuildChannelEditOptions): Promise<AnyChannel> {\n return this.client.channels.edit(resolveId(channel), options);\n }\n\n /**\n * Deletes a channel of the guild.\n *\n * @param channel The channel, or its ID.\n * @param reason The reason for the audit log.\n */\n public delete(channel: IdResolvable, reason?: string): Promise<void> {\n return this.client.channels.delete(resolveId(channel), reason);\n }\n\n /**\n * Moves several channels at once.\n *\n * @param positions The channels and their new positions or categories.\n * @param reason The reason for the audit log.\n */\n public async setPositions(positions: readonly ChannelPosition[], reason?: string): Promise<void> {\n const body = positions.map((position) => ({\n id: resolveId(position.channel),\n position: position.position,\n parent_id:\n position.parent === undefined\n ? undefined\n : position.parent === null\n ? null\n : resolveId(position.parent),\n lock_permissions: position.lockPermissions,\n }));\n await this.client.api.guilds.setChannelPositions(this.guildId, body, { reason });\n\n // The endpoint answers 204: refetch the moved channels rather than guessing the positions Discord shifted.\n await this.fetch();\n }\n}\n","import { integrationKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { Integration } from \"../structures/guilds/Integration.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\n\n/**\n * Manages the integrations of one guild.\n *\n * @remarks\n * Discord has no route to fetch a single integration: `fetch` lists them all, and rejects when the ID is not among\n * them.\n */\nexport class GuildIntegrationManager extends CachedManager<\n \"integrations\",\n Integration,\n [integrationId: string]\n> {\n public readonly guildId: string;\n\n public constructor(client: GatewayClient, guildId: string) {\n super(client, \"integrations\");\n this.guildId = guildId;\n }\n\n public construct(data: CacheEntityTypes[\"integrations\"]): Integration {\n return new Integration(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"integrations\"]): string {\n return this.resolveKey(data.id);\n }\n\n public resolveKey(integrationId: string): string {\n return integrationKey(this.guildId, integrationId);\n }\n\n /**\n * Adds an integration to the cache, and its user to `client.users`.\n *\n * @internal\n */\n public override async _add(\n data: CacheEntityTypes[\"integrations\"],\n cache = true,\n options?: AddOptions,\n ): Promise<Integration> {\n if (data.user) await this.client.users._add(data.user, cache);\n return super._add(data, cache, options);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"integrations\"]): Awaitable<Integration> {\n return whenAll(\n [\n data.user ? this.client.users._resolveData(data.user) : null,\n this.cachedGuild(data.guild_id),\n data.role_id ? this.client.roles._get(data.guild_id, data.role_id) : undefined,\n ],\n ([user, guild, role]) => new Integration(data, { user, guild, role: role ?? null }),\n );\n }\n\n /**\n * Fetches every integration of the guild, and caches them.\n */\n public async fetchAll(): Promise<Integration[]> {\n const integrations = await this.list();\n return Promise.all(integrations.map((integration) => this._add(integration)));\n }\n\n /**\n * Removes an integration from the guild, kicking its bot if it has one, and drops it from the cache.\n *\n * @param integrationId The ID of the integration.\n * @param reason The reason for the audit log.\n */\n public async delete(integrationId: string, reason?: string): Promise<void> {\n await this.client.api.guilds.deleteIntegration(this.guildId, integrationId, { reason });\n await this.cache?.delete(this.resolveKey(integrationId));\n }\n\n protected async fetchRaw(integrationId: string) {\n const integration = (await this.list()).find(({ id }) => id === integrationId);\n if (!integration) {\n throw new RangeError(`The guild ${this.guildId} has no integration ${integrationId}`);\n }\n\n return integration;\n }\n\n private async list(): Promise<CacheEntityTypes[\"integrations\"][]> {\n const integrations = await this.client.api.guilds.getIntegrations(this.guildId);\n return integrations.map((integration) => ({ ...integration, guild_id: this.guildId }));\n }\n}\n","import { scheduledEventKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n type APIGuildScheduledEventEntityMetadata,\n type APIGuildScheduledEventRecurrenceRule,\n type GuildScheduledEventEntityType,\n type GuildScheduledEventPrivacyLevel,\n type GuildScheduledEventStatus,\n type RESTPatchAPIGuildScheduledEventJSONBody,\n type RESTPostAPIGuildScheduledEventJSONBody,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { GuildScheduledEvent } from \"../structures/guilds/GuildScheduledEvent.js\";\nimport type { GuildMember } from \"../structures/guilds/GuildMember.js\";\nimport type { User } from \"../structures/users/User.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { resolveId, type IdResolvable } from \"../util/channels.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\n\n/**\n * The fields of a scheduled event that can be edited.\n */\nexport interface GuildScheduledEventEditOptions {\n name?: string;\n description?: string | null;\n /**\n * The stage or voice channel, `null` for an external event.\n */\n channel?: IdResolvable | null;\n scheduledStartTime?: Date | number;\n scheduledEndTime?: Date | number | null;\n privacyLevel?: GuildScheduledEventPrivacyLevel;\n entityType?: GuildScheduledEventEntityType;\n /**\n * Where an external event takes place.\n */\n entityMetadata?: APIGuildScheduledEventEntityMetadata | null;\n /**\n * Starts, ends, or cancels the event.\n */\n status?: GuildScheduledEventStatus;\n /**\n * The cover image, as a data URI.\n */\n image?: string | null;\n recurrenceRule?: APIGuildScheduledEventRecurrenceRule | null;\n reason?: string;\n}\n\n/**\n * The options to create a scheduled event with.\n */\nexport interface GuildScheduledEventCreateOptions extends Omit<\n GuildScheduledEventEditOptions,\n \"status\"\n> {\n name: string;\n scheduledStartTime: Date | number;\n privacyLevel: GuildScheduledEventPrivacyLevel;\n entityType: GuildScheduledEventEntityType;\n}\n\n/**\n * The options to fetch the subscribers of an event with. `before` and `after` are user IDs.\n */\nexport interface GuildScheduledEventSubscribersOptions {\n /**\n * How many users to fetch, up to 100.\n */\n limit?: number;\n before?: string;\n after?: string;\n /**\n * Whether to include each user's guild member.\n */\n withMember?: boolean;\n}\n\n/**\n * A user subscribed to a scheduled event.\n */\nexport interface GuildScheduledEventSubscriber {\n user: User;\n member: GuildMember | null;\n}\n\n/**\n * Manages the scheduled events of one guild.\n */\nexport class GuildScheduledEventManager extends CachedManager<\n \"scheduledEvents\",\n GuildScheduledEvent,\n [eventId: string]\n> {\n public readonly guildId: string;\n\n public constructor(client: GatewayClient, guildId: string) {\n super(client, \"scheduledEvents\");\n this.guildId = guildId;\n }\n\n public construct(data: CacheEntityTypes[\"scheduledEvents\"]): GuildScheduledEvent {\n return new GuildScheduledEvent(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"scheduledEvents\"]): string {\n return this.resolveKey(data.id);\n }\n\n public resolveKey(eventId: string): string {\n return scheduledEventKey(this.guildId, eventId);\n }\n\n /**\n * Adds an event to the cache, and its creator to `client.users`.\n *\n * @internal\n */\n public override async _add(\n data: CacheEntityTypes[\"scheduledEvents\"],\n cache = true,\n options?: AddOptions,\n ): Promise<GuildScheduledEvent> {\n if (data.creator) await this.client.users._add(data.creator, cache);\n return super._add(data, cache, options);\n }\n\n public override _hydrate(\n data: CacheEntityTypes[\"scheduledEvents\"],\n ): Awaitable<GuildScheduledEvent> {\n return whenAll(\n [\n data.creator\n ? this.client.users._resolveData(data.creator)\n : data.creator_id\n ? this.client.users._get(data.creator_id)\n : undefined,\n this.cachedGuild(data.guild_id),\n data.channel_id ? this.client.channels._get(data.channel_id) : undefined,\n ],\n ([creator, guild, channel]) =>\n new GuildScheduledEvent(data, {\n creator: creator ?? null,\n guild,\n channel: channel ?? null,\n }),\n );\n }\n\n /**\n * Fetches every scheduled event of the guild, and caches them.\n *\n * @param options Whether to include how many users subscribed to each.\n */\n public async fetchAll(options: { withUserCount?: boolean } = {}): Promise<GuildScheduledEvent[]> {\n const events = await this.client.api.guilds.getScheduledEvents(this.guildId, {\n with_user_count: options.withUserCount ?? true,\n });\n return Promise.all(events.map((event) => this._add(event)));\n }\n\n /**\n * Creates a scheduled event.\n *\n * @param options The event's name, time, place, and privacy.\n */\n public async create(options: GuildScheduledEventCreateOptions): Promise<GuildScheduledEvent> {\n const event = await this.client.api.guilds.createScheduledEvent(\n this.guildId,\n toEventBody(options) as RESTPostAPIGuildScheduledEventJSONBody,\n {\n reason: options.reason,\n },\n );\n return this._add(event);\n }\n\n /**\n * Edits a scheduled event.\n *\n * @param eventId The ID of the event.\n * @param options The fields to edit, and the reason for the audit log.\n */\n public async edit(\n eventId: string,\n options: GuildScheduledEventEditOptions,\n ): Promise<GuildScheduledEvent> {\n const event = await this.client.api.guilds.editScheduledEvent(\n this.guildId,\n eventId,\n toEventBody(options),\n {\n reason: options.reason,\n },\n );\n return this._add(event);\n }\n\n /**\n * Deletes a scheduled event.\n *\n * @param eventId The ID of the event.\n * @param reason The reason for the audit log.\n */\n public async delete(eventId: string, reason?: string): Promise<void> {\n await this.client.api.guilds.deleteScheduledEvent(this.guildId, eventId, { reason });\n await this.cache?.delete(this.resolveKey(eventId));\n }\n\n /**\n * Fetches the users who subscribed to an event, and caches them.\n *\n * @param eventId The ID of the event.\n * @param options How many users, around which user ID, and whether to include their members.\n */\n public async fetchSubscribers(\n eventId: string,\n options: GuildScheduledEventSubscribersOptions = {},\n ): Promise<GuildScheduledEventSubscriber[]> {\n const subscribers = await this.client.api.guilds.getScheduledEventUsers(this.guildId, eventId, {\n with_member: options.withMember ?? false,\n limit: options.limit,\n before: options.before,\n after: options.after,\n });\n return Promise.all(\n subscribers.map(async (subscriber) => ({\n user: await this.client.users._add(subscriber.user),\n member: subscriber.member\n ? await this.client.members._add({\n ...subscriber.member,\n user: subscriber.user,\n guild_id: this.guildId,\n })\n : null,\n })),\n );\n }\n\n protected async fetchRaw(eventId: string) {\n return this.client.api.guilds.getScheduledEvent(this.guildId, eventId, {\n with_user_count: true,\n });\n }\n}\n\nfunction toISO(value: Date | number | null | undefined): string | null | undefined {\n return value === undefined || value === null ? value : new Date(value).toISOString();\n}\n\nfunction toEventBody(\n options: GuildScheduledEventEditOptions,\n): RESTPatchAPIGuildScheduledEventJSONBody {\n const body: Record<string, unknown> = {\n name: options.name,\n description: options.description,\n channel_id:\n options.channel === undefined\n ? undefined\n : options.channel === null\n ? null\n : resolveId(options.channel),\n scheduled_start_time: toISO(options.scheduledStartTime),\n scheduled_end_time: toISO(options.scheduledEndTime),\n privacy_level: options.privacyLevel,\n entity_type: options.entityType,\n entity_metadata: options.entityMetadata,\n status: options.status,\n image: options.image,\n recurrence_rule: options.recurrenceRule,\n };\n for (const key of Object.keys(body)) if (body[key] === undefined) delete body[key];\n return body as RESTPatchAPIGuildScheduledEventJSONBody;\n}\n","import { SoundboardSound as BaseSoundboardSound } from \"@discordjs/structures\";\nimport type { APISoundboardSound } from \"discord-api-types/v10\";\nimport type { SoundboardSoundEditOptions } from \"../../managers/GuildSoundboardSoundManager.js\";\nimport { cdn } from \"../../util/cdn.js\";\nimport type { GuildEmoji } from \"../emojis/GuildEmoji.js\";\nimport { ReactionEmoji } from \"../emojis/ReactionEmoji.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, kPatch, kRelations, StructureMixin } from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\n/**\n * The relations of a {@link SoundboardSound}, resolved from the cache by the guild's soundboard manager.\n */\nexport interface SoundboardSoundRelations {\n user?: User | null;\n guild?: Guild | null;\n /**\n * The custom emoji of the sound, when it belongs to the sound's guild and is cached.\n */\n emoji?: GuildEmoji | null;\n}\n\nexport interface SoundboardSound extends StructureMixin<\n APISoundboardSound,\n SoundboardSoundRelations\n> {}\n\n/**\n * A soundboard sound, one of Discord's defaults or a guild's: `@discordjs/structures`' `SoundboardSound`, with its\n * uploader, guild, and URL, and actions through the client.\n */\nexport class SoundboardSound extends BaseSoundboardSound {\n /**\n * @param data The raw sound.\n * @param relations The uploader and guild as resolved from the cache, by the guild's soundboard manager.\n */\n public constructor(data: APISoundboardSound, relations: SoundboardSoundRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n public [kPatch](data: Readonly<Partial<APISoundboardSound>>): this {\n if (data.user) this.dropRelations(\"user\");\n this.dropChangedRelations(data, { emoji: \"emoji_id\" });\n return StructureMixin.prototype[kPatch].call(this, data) as this;\n }\n\n /**\n * The user who uploaded a guild sound, when the payload includes it.\n */\n public get user(): User | null {\n const { user } = this[kData];\n return this[kRelations].user ?? (user ? new User(user) : null);\n }\n\n /**\n * The emoji of the sound, like discord.js's `SoundboardSound#emoji`: the cached custom emoji of the sound's guild,\n * else the emoji of the payload. `null` when the sound has none.\n */\n public get emoji(): GuildEmoji | ReactionEmoji | null {\n const resolved = this[kRelations].emoji;\n if (resolved) return resolved;\n const { emoji_id: id, emoji_name: name } = this[kData];\n return id || name ? new ReactionEmoji({ id, name }) : null;\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * The URL of the sound file.\n */\n public get url(): string {\n return cdn.soundboardSound(this.soundId);\n }\n\n /**\n * Whether the sound is partial: built from its IDs alone for an event about an uncached sound, see\n * `Partials.SoundboardSound`. Only `soundId` and `guildId` are reliable then, and {@link SoundboardSound.fetch}\n * completes it.\n */\n public get partial(): boolean {\n return this[kData].name === undefined;\n }\n\n /**\n * Fetches the guild sound from the API and patches this structure with the result.\n */\n public fetch(): Promise<this> {\n return this.withGuild(async (guildId) => {\n const sound = await this.client.guilds\n .soundboardSounds(guildId)\n .fetch(this.soundId, { force: true });\n return this[kPatch](sound.toJSON());\n });\n }\n\n public edit(options: SoundboardSoundEditOptions): Promise<this> {\n return this.withGuild(async (guildId) => {\n const sound = await this.client.guilds.soundboardSounds(guildId).edit(this.soundId, options);\n return this[kPatch](sound.toJSON());\n });\n }\n\n public delete(reason?: string): Promise<this> {\n return this.withGuild(async (guildId) => {\n await this.client.guilds.soundboardSounds(guildId).delete(this.soundId, reason);\n return this;\n });\n }\n\n private withGuild(action: (guildId: string) => Promise<this>): Promise<this> {\n const { guildId } = this;\n if (!guildId) return Promise.reject(new Error(\"Default soundboard sounds cannot be changed\"));\n return action(guildId);\n }\n}\n\nMixin(SoundboardSound, [StructureMixin]);\n","import { soundboardSoundKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n type APISoundboardSound,\n type RESTPatchAPIGuildSoundboardSoundJSONBody,\n type RESTPostAPIGuildSoundboardSoundJSONBody,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { SoundboardSound } from \"../structures/soundboards/SoundboardSound.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\n\n/**\n * The fields of a soundboard sound that can be edited.\n */\nexport interface SoundboardSoundEditOptions {\n name?: string;\n /**\n * The volume, from 0 to 1.\n */\n volume?: number | null;\n emojiId?: string | null;\n emojiName?: string | null;\n reason?: string;\n}\n\n/**\n * The options to upload a soundboard sound with.\n */\nexport interface SoundboardSoundCreateOptions extends SoundboardSoundEditOptions {\n name: string;\n /**\n * The MP3 or OGG sound, as a data URI.\n */\n sound: string;\n}\n\n/**\n * Manages the soundboard sounds of one guild.\n */\nexport class GuildSoundboardSoundManager extends CachedManager<\n \"soundboardSounds\",\n SoundboardSound,\n [soundId: string]\n> {\n public readonly guildId: string;\n\n public constructor(client: GatewayClient, guildId: string) {\n super(client, \"soundboardSounds\");\n this.guildId = guildId;\n }\n\n public construct(data: CacheEntityTypes[\"soundboardSounds\"]): SoundboardSound {\n return new SoundboardSound(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"soundboardSounds\"]): string {\n return this.resolveKey(data.sound_id);\n }\n\n public resolveKey(soundId: string): string {\n return soundboardSoundKey(this.guildId, soundId);\n }\n\n /**\n * Adds a sound to the cache, and its uploader to `client.users`.\n *\n * @internal\n */\n public override async _add(\n data: CacheEntityTypes[\"soundboardSounds\"],\n cache = true,\n options?: AddOptions,\n ): Promise<SoundboardSound> {\n if (data.user) await this.client.users._add(data.user, cache);\n return super._add(data, cache, options);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"soundboardSounds\"]): Awaitable<SoundboardSound> {\n return whenAll(\n [\n data.user ? this.client.users._resolveData(data.user) : null,\n this.cachedGuild(data.guild_id),\n data.emoji_id && data.guild_id\n ? this.client.guilds.emojis(data.guild_id)._get(data.emoji_id)\n : undefined,\n ],\n ([user, guild, emoji]) => new SoundboardSound(data, { user, guild, emoji: emoji ?? null }),\n );\n }\n\n /**\n * Fetches every soundboard sound of the guild, and caches them.\n */\n public async fetchAll(): Promise<SoundboardSound[]> {\n const { items } = await this.client.api.guilds.getSoundboardSounds(this.guildId);\n return Promise.all(items.map((sound) => this._add(this.withGuildId(sound))));\n }\n\n /**\n * Uploads a soundboard sound.\n *\n * @param options The sound file, its name, volume, and emoji.\n */\n public async create(options: SoundboardSoundCreateOptions): Promise<SoundboardSound> {\n const body: RESTPostAPIGuildSoundboardSoundJSONBody = {\n ...toSoundBody(options),\n name: options.name,\n sound: options.sound,\n };\n const sound = await this.client.api.guilds.createSoundboardSound(this.guildId, body, {\n reason: options.reason,\n });\n return this._add(this.withGuildId(sound));\n }\n\n /**\n * Edits a soundboard sound.\n *\n * @param soundId The ID of the sound.\n * @param options The fields to edit, and the reason for the audit log.\n */\n public async edit(\n soundId: string,\n options: SoundboardSoundEditOptions,\n ): Promise<SoundboardSound> {\n const sound = await this.client.api.guilds.editSoundboardSound(\n this.guildId,\n soundId,\n toSoundBody(options),\n {\n reason: options.reason,\n },\n );\n return this._add(this.withGuildId(sound));\n }\n\n /**\n * Deletes a soundboard sound.\n *\n * @param soundId The ID of the sound.\n * @param reason The reason for the audit log.\n */\n public async delete(soundId: string, reason?: string): Promise<void> {\n await this.client.api.guilds.deleteSoundboardSound(this.guildId, soundId, { reason });\n await this.cache?.delete(this.resolveKey(soundId));\n }\n\n protected async fetchRaw(soundId: string) {\n const sound = await this.client.api.guilds.getSoundboardSound(this.guildId, soundId);\n return this.withGuildId(sound);\n }\n\n private withGuildId(sound: APISoundboardSound): APISoundboardSound {\n return { ...sound, guild_id: sound.guild_id ?? this.guildId };\n }\n}\n\nfunction toSoundBody(\n options: SoundboardSoundEditOptions,\n): RESTPatchAPIGuildSoundboardSoundJSONBody {\n const body: RESTPatchAPIGuildSoundboardSoundJSONBody = {\n name: options.name,\n volume: options.volume,\n emoji_id: options.emojiId,\n emoji_name: options.emojiName,\n };\n for (const key of Object.keys(body) as (keyof typeof body)[]) {\n if (body[key] === undefined) delete body[key];\n }\n\n return body;\n}\n","import { stageInstanceKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n type RESTPatchAPIStageInstanceJSONBody,\n type RESTPostAPIStageInstanceJSONBody,\n type StageInstancePrivacyLevel,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { StageInstance } from \"../structures/stageInstances/StageInstance.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { resolveId, type IdResolvable } from \"../util/channels.js\";\nimport { CachedManager } from \"./CachedManager.js\";\n\n/**\n * The fields of a stage instance that can be edited.\n */\nexport interface StageInstanceEditOptions {\n topic?: string;\n privacyLevel?: StageInstancePrivacyLevel;\n reason?: string;\n}\n\n/**\n * The options to start a stage with.\n */\nexport interface StageInstanceCreateOptions extends StageInstanceEditOptions {\n topic: string;\n /**\n * Whether to notify the members of the guild that the stage started.\n */\n sendStartNotification?: boolean;\n /**\n * The scheduled event the stage belongs to.\n */\n guildScheduledEvent?: IdResolvable;\n}\n\n/**\n * Manages the stage instances of one guild, keyed by the ID of their stage channel.\n */\nexport class StageInstanceManager extends CachedManager<\n \"stageInstances\",\n StageInstance,\n [channelId: string]\n> {\n public readonly guildId: string;\n\n public constructor(client: GatewayClient, guildId: string) {\n super(client, \"stageInstances\");\n this.guildId = guildId;\n }\n\n public construct(data: CacheEntityTypes[\"stageInstances\"]): StageInstance {\n return new StageInstance(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"stageInstances\"]): string {\n return this.resolveKey(data.channel_id);\n }\n\n public resolveKey(channelId: string): string {\n return stageInstanceKey(this.guildId, channelId);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"stageInstances\"]): Awaitable<StageInstance> {\n return whenAll(\n [\n this.cachedGuild(data.guild_id),\n this.client.channels._get(data.channel_id),\n data.guild_scheduled_event_id\n ? this.client.guilds.scheduledEvents(data.guild_id)._get(data.guild_scheduled_event_id)\n : undefined,\n ],\n ([guild, channel, guildScheduledEvent]) =>\n new StageInstance(data, {\n guild,\n channel: channel ?? null,\n guildScheduledEvent: guildScheduledEvent ?? null,\n }),\n );\n }\n\n /**\n * Starts a stage in a stage channel.\n *\n * @param channel The stage channel, or its ID.\n * @param options The topic and privacy level, and whether to notify the guild.\n */\n public async create(\n channel: IdResolvable,\n options: StageInstanceCreateOptions,\n ): Promise<StageInstance> {\n const body: RESTPostAPIStageInstanceJSONBody = {\n channel_id: resolveId(channel),\n topic: options.topic,\n privacy_level: options.privacyLevel,\n send_start_notification: options.sendStartNotification,\n guild_scheduled_event_id:\n options.guildScheduledEvent && resolveId(options.guildScheduledEvent),\n };\n const instance = await this.client.api.stageInstances.create(body, {\n reason: options.reason,\n });\n return this._add(instance);\n }\n\n /**\n * Edits the stage of a channel.\n *\n * @param channelId The ID of the stage channel.\n * @param options The topic and privacy level, and the reason for the audit log.\n */\n public async edit(channelId: string, options: StageInstanceEditOptions): Promise<StageInstance> {\n const body: RESTPatchAPIStageInstanceJSONBody = {\n topic: options.topic,\n privacy_level: options.privacyLevel,\n };\n const instance = await this.client.api.stageInstances.edit(channelId, body, {\n reason: options.reason,\n });\n return this._add(instance);\n }\n\n /**\n * Ends the stage of a channel.\n *\n * @param channelId The ID of the stage channel.\n * @param reason The reason for the audit log.\n */\n public async delete(channelId: string, reason?: string): Promise<void> {\n await this.client.api.stageInstances.delete(channelId, { reason });\n await this.cache?.delete(this.resolveKey(channelId));\n }\n\n protected async fetchRaw(channelId: string) {\n return this.client.api.stageInstances.get(channelId);\n }\n}\n","import { emojiKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n type APIEmoji,\n type RESTPatchAPIGuildEmojiJSONBody,\n type RESTPostAPIGuildEmojiJSONBody,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { GuildEmoji } from \"../structures/emojis/GuildEmoji.js\";\nimport type { User } from \"../structures/users/User.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\n\n/**\n * The options to create an emoji with.\n */\nexport interface GuildEmojiCreateOptions {\n /**\n * The image, as a data URI (`data:image/png;base64,...`), up to 256 KiB.\n */\n attachment: string;\n name: string;\n /**\n * The IDs of the roles allowed to use the emoji, everyone when omitted.\n */\n roles?: readonly string[];\n reason?: string;\n}\n\n/**\n * The options to edit an emoji with.\n */\nexport interface GuildEmojiEditOptions {\n name?: string;\n /**\n * The IDs of the roles allowed to use the emoji, `null` or empty for everyone.\n */\n roles?: readonly string[] | null;\n reason?: string;\n}\n\n/**\n * Manages the custom emojis of one guild.\n */\nexport class GuildEmojiManager extends CachedManager<\"emojis\", GuildEmoji, [emojiId: string]> {\n /**\n * The ID of the guild.\n */\n public readonly guildId: string;\n\n public constructor(client: GatewayClient, guildId: string) {\n super(client, \"emojis\");\n this.guildId = guildId;\n }\n\n public construct(data: CacheEntityTypes[\"emojis\"]): GuildEmoji {\n return new GuildEmoji(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"emojis\"]): string {\n return this.resolveKey(data.id!);\n }\n\n /**\n * Adds an emoji to the cache, and its uploader to `client.users`.\n *\n * @internal\n */\n public override async _add(\n data: CacheEntityTypes[\"emojis\"],\n cache = true,\n options?: AddOptions,\n ): Promise<GuildEmoji> {\n if (data.user) await this.client.users._add(data.user, cache);\n return super._add(data, cache, options);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"emojis\"]): Awaitable<GuildEmoji> {\n return whenAll(\n [\n data.user ? this.client.users._resolveData(data.user) : undefined,\n this.cachedGuild(data.guild_id),\n ],\n ([author, guild]) => new GuildEmoji(data, { author, guild }),\n );\n }\n\n public resolveKey(emojiId: string): string {\n return emojiKey(this.guildId, emojiId);\n }\n\n /**\n * Fetches every emoji of the guild, and caches them.\n */\n public async fetchAll(): Promise<GuildEmoji[]> {\n const emojis = await this.client.api.guilds.getEmojis(this.guildId);\n return Promise.all(emojis.map((emoji) => this.store(emoji)));\n }\n\n /**\n * Uploads an emoji.\n *\n * @param options The image, name, and allowed roles.\n */\n public async create(options: GuildEmojiCreateOptions): Promise<GuildEmoji> {\n const body: RESTPostAPIGuildEmojiJSONBody = {\n image: options.attachment,\n name: options.name,\n roles: options.roles ? [...options.roles] : undefined,\n };\n const emoji = await this.client.api.guilds.createEmoji(this.guildId, body, {\n reason: options.reason,\n });\n return this.store(emoji);\n }\n\n /**\n * Edits an emoji.\n *\n * @param emojiId The ID of the emoji.\n * @param options The changes to apply.\n */\n public async edit(emojiId: string, options: GuildEmojiEditOptions): Promise<GuildEmoji> {\n const body: RESTPatchAPIGuildEmojiJSONBody = {\n name: options.name,\n roles:\n options.roles === undefined || options.roles === null ? options.roles : [...options.roles],\n };\n const emoji = await this.client.api.guilds.editEmoji(this.guildId, emojiId, body, {\n reason: options.reason,\n });\n return this.store(emoji);\n }\n\n /**\n * Deletes an emoji.\n *\n * @param emojiId The ID of the emoji.\n * @param reason The reason for the audit log.\n */\n public async delete(emojiId: string, reason?: string): Promise<void> {\n await this.client.api.guilds.deleteEmoji(this.guildId, emojiId, { reason });\n await this.cache?.delete(this.resolveKey(emojiId));\n }\n\n /**\n * Fetches the user who uploaded an emoji, which the API only returns with `ManageGuildExpressions`.\n *\n * @param emojiId The ID of the emoji.\n */\n public async fetchAuthor(emojiId: string): Promise<User | null> {\n const emoji = await this.fetch(emojiId, { force: true });\n return emoji.author;\n }\n\n /**\n * Lists the emojis of the guild held in the cache, without calling the API.\n *\n * @remarks\n * It enumerates the whole entity cache, which a Redis store answers from its index: prefer `fetchAll` when the\n * cache may be incomplete.\n *\n * @returns The cached entries, `[]` when this entity is not cached.\n * @throws {TypeError} When the store cannot enumerate its entries.\n */\n public async listCached(): Promise<GuildEmoji[]> {\n const cache = this.iterableCache();\n if (!cache) return [];\n\n const prefix = `${this.guildId}:`;\n const keys = (await cache.keys()).filter((key) => key.startsWith(prefix));\n const values = await Promise.all(keys.map((key) => cache.get(key)));\n return Promise.all(\n values.filter((value) => value !== undefined).map((value) => this.hydrate(value)),\n );\n }\n\n protected async fetchRaw(emojiId: string) {\n const emoji = await this.client.api.guilds.getEmoji(this.guildId, emojiId);\n return { ...emoji, guild_id: this.guildId };\n }\n\n private store(emoji: APIEmoji): Promise<GuildEmoji> {\n return this._add({ ...emoji, guild_id: this.guildId });\n }\n}\n","import { inviteKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n type APIExtendedInvite,\n type APIInvite,\n type InviteTargetType,\n type RESTPostAPIChannelInviteJSONBody,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport type { InviteData } from \"../structures/invites/BaseInvite.js\";\nimport { GuildInvite } from \"../structures/invites/GuildInvite.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\n\n/**\n * The options to create an invite with.\n */\nexport interface InviteCreateOptions {\n /**\n * How long the invite lasts, in seconds, up to 7 days. `0` never expires.\n *\n * @default 86_400\n */\n maxAge?: number;\n /**\n * How many times the invite can be used, `0` for unlimited.\n */\n maxUses?: number;\n /**\n * Whether the invite only grants temporary membership.\n */\n temporary?: boolean;\n /**\n * Whether to always create a new invite, instead of reusing a similar one.\n */\n unique?: boolean;\n targetType?: InviteTargetType;\n targetUserId?: string;\n targetApplicationId?: string;\n reason?: string;\n}\n\n/**\n * Manages the invites of one guild.\n */\nexport class GuildInviteManager extends CachedManager<\"invites\", GuildInvite, [code: string]> {\n /**\n * The ID of the guild.\n */\n public readonly guildId: string;\n\n public constructor(client: GatewayClient, guildId: string) {\n super(client, \"invites\");\n this.guildId = guildId;\n }\n\n public construct(data: CacheEntityTypes[\"invites\"]): GuildInvite {\n return new GuildInvite(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"invites\"]): string {\n return this.resolveKey(data.code);\n }\n\n /**\n * Adds an invite to the cache, and its inviter and target user to `client.users`.\n *\n * @internal\n */\n public override async _add(\n data: CacheEntityTypes[\"invites\"],\n cache = true,\n options?: AddOptions,\n ): Promise<GuildInvite> {\n if (data.inviter) await this.client.users._add(data.inviter, cache);\n if (data.target_user) await this.client.users._add(data.target_user, cache);\n return super._add(data, cache, options);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"invites\"]): Awaitable<GuildInvite> {\n const { users } = this.client;\n return whenAll(\n [\n data.inviter ? users._resolveData(data.inviter) : undefined,\n data.target_user ? users._resolveData(data.target_user) : undefined,\n this.cachedGuild(this.guildId),\n data.channel_id ? this.client.channels._get(data.channel_id) : undefined,\n ],\n ([inviter, targetUser, guild, channel]) =>\n new GuildInvite(data, { inviter, targetUser, guild, channel: channel ?? null }),\n );\n }\n\n public resolveKey(code: string): string {\n return inviteKey(this.guildId, code);\n }\n\n /**\n * Fetches every invite of the guild, with their metadata, and caches them.\n */\n public async fetchAll(): Promise<GuildInvite[]> {\n const invites = await this.client.api.guilds.getInvites(this.guildId);\n return Promise.all(invites.map((invite) => this.store(invite)));\n }\n\n /**\n * Fetches every invite of a channel of the guild, and caches them.\n *\n * @param channelId The ID of the channel.\n */\n public async fetchChannel(channelId: string): Promise<GuildInvite[]> {\n const invites = await this.client.api.channels.getInvites(channelId);\n return Promise.all(invites.map((invite) => this.store(invite)));\n }\n\n /**\n * Creates an invite to a channel of the guild.\n *\n * @param channelId The ID of the channel.\n * @param options The invite's limits and target.\n */\n public async create(channelId: string, options: InviteCreateOptions = {}): Promise<GuildInvite> {\n const body: RESTPostAPIChannelInviteJSONBody = {\n max_age: options.maxAge,\n max_uses: options.maxUses,\n temporary: options.temporary,\n unique: options.unique,\n target_type: options.targetType,\n target_user_id: options.targetUserId,\n target_application_id: options.targetApplicationId,\n };\n const invite = await this.client.api.channels.createInvite(channelId, body, {\n reason: options.reason,\n });\n return this.store(invite);\n }\n\n /**\n * Deletes an invite.\n *\n * @param code The code of the invite.\n * @param reason The reason for the audit log.\n */\n public async delete(code: string, reason?: string): Promise<void> {\n await this.client.api.invites.delete(code, { reason });\n await this.cache?.delete(this.resolveKey(code));\n }\n\n protected async fetchRaw(code: string) {\n const invite = await this.client.api.invites.get(code, { with_counts: true });\n return this.toCached(invite);\n }\n\n private store(invite: APIInvite | APIExtendedInvite): Promise<GuildInvite> {\n return this._add(this.toCached(invite));\n }\n\n // The cache holds the `INVITE_CREATE` shape: REST invites keep their nested objects, plus the flat IDs it needs.\n private toCached(invite: APIInvite | APIExtendedInvite): CacheEntityTypes[\"invites\"] {\n const data: InviteData = {\n ...invite,\n guild_id: invite.guild?.id ?? this.guildId,\n channel_id: invite.channel?.id,\n };\n return data as CacheEntityTypes[\"invites\"];\n }\n}\n","import type { RawFile } from \"@discordjs/rest\";\nimport { stickerKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport { type APISticker, type RESTPatchAPIGuildStickerJSONBody } from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { Sticker } from \"../structures/stickers/Sticker.js\";\nimport type { User } from \"../structures/users/User.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\n\n/**\n * The options to upload a sticker with.\n */\nexport interface GuildStickerCreateOptions {\n /**\n * The PNG, APNG, GIF, or Lottie JSON file, up to 512 KiB.\n */\n file: RawFile;\n name: string;\n /**\n * The name of the Unicode emoji the sticker relates to, used for suggestions.\n */\n tags: string;\n description?: string;\n reason?: string;\n}\n\n/**\n * The options to edit a sticker with.\n */\nexport interface GuildStickerEditOptions {\n name?: string;\n description?: string | null;\n tags?: string;\n reason?: string;\n}\n\n/**\n * Manages the custom stickers of one guild.\n */\nexport class GuildStickerManager extends CachedManager<\"stickers\", Sticker, [stickerId: string]> {\n /**\n * The ID of the guild.\n */\n public readonly guildId: string;\n\n public constructor(client: GatewayClient, guildId: string) {\n super(client, \"stickers\");\n this.guildId = guildId;\n }\n\n public construct(data: CacheEntityTypes[\"stickers\"]): Sticker {\n return new Sticker(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"stickers\"]): string {\n return this.resolveKey(data.id);\n }\n\n /**\n * Adds a sticker to the cache, and its uploader to `client.users`.\n *\n * @internal\n */\n public override async _add(\n data: CacheEntityTypes[\"stickers\"],\n cache = true,\n options?: AddOptions,\n ): Promise<Sticker> {\n if (data.user) await this.client.users._add(data.user, cache);\n return super._add(data, cache, options);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"stickers\"]): Awaitable<Sticker> {\n return whenAll(\n [\n data.user ? this.client.users._resolveData(data.user) : undefined,\n this.cachedGuild(data.guild_id),\n ],\n ([user, guild]) => new Sticker(data, { user, guild }),\n );\n }\n\n public resolveKey(stickerId: string): string {\n return stickerKey(this.guildId, stickerId);\n }\n\n /**\n * Fetches every sticker of the guild, and caches them.\n */\n public async fetchAll(): Promise<Sticker[]> {\n const stickers = await this.client.api.guilds.getStickers(this.guildId);\n return Promise.all(stickers.map((sticker) => this.store(sticker)));\n }\n\n /**\n * Uploads a sticker.\n *\n * @param options The file, name, and tags.\n */\n public async create(options: GuildStickerCreateOptions): Promise<Sticker> {\n const sticker = await this.client.api.guilds.createSticker(\n this.guildId,\n {\n name: options.name,\n tags: options.tags,\n description: options.description ?? \"\",\n file: options.file,\n },\n { reason: options.reason },\n );\n return this.store(sticker);\n }\n\n /**\n * Edits a sticker.\n *\n * @param stickerId The ID of the sticker.\n * @param options The changes to apply.\n */\n public async edit(stickerId: string, options: GuildStickerEditOptions): Promise<Sticker> {\n const body: RESTPatchAPIGuildStickerJSONBody = {\n name: options.name,\n description: options.description,\n tags: options.tags,\n };\n const sticker = await this.client.api.guilds.editSticker(this.guildId, stickerId, body, {\n reason: options.reason,\n });\n return this.store(sticker);\n }\n\n /**\n * Deletes a sticker.\n *\n * @param stickerId The ID of the sticker.\n * @param reason The reason for the audit log.\n */\n public async delete(stickerId: string, reason?: string): Promise<void> {\n await this.client.api.guilds.deleteSticker(this.guildId, stickerId, { reason });\n await this.cache?.delete(this.resolveKey(stickerId));\n }\n\n /**\n * Fetches the user who uploaded a sticker, which the API only returns with `ManageGuildExpressions`.\n *\n * @param stickerId The ID of the sticker.\n */\n public async fetchUser(stickerId: string): Promise<User | null> {\n const sticker = await this.fetch(stickerId, { force: true });\n return sticker.user;\n }\n\n /**\n * Lists the stickers of the guild held in the cache, without calling the API.\n *\n * @remarks\n * It enumerates the whole entity cache, which a Redis store answers from its index: prefer `fetchAll` when the\n * cache may be incomplete.\n *\n * @returns The cached entries, `[]` when this entity is not cached.\n * @throws {TypeError} When the store cannot enumerate its entries.\n */\n public async listCached(): Promise<Sticker[]> {\n const cache = this.iterableCache();\n if (!cache) return [];\n\n const prefix = `${this.guildId}:`;\n const keys = (await cache.keys()).filter((key) => key.startsWith(prefix));\n const values = await Promise.all(keys.map((key) => cache.get(key)));\n return Promise.all(\n values.filter((value) => value !== undefined).map((value) => this.hydrate(value)),\n );\n }\n\n protected async fetchRaw(stickerId: string) {\n const sticker = await this.client.api.guilds.getSticker(this.guildId, stickerId);\n return { ...sticker, guild_id: this.guildId };\n }\n\n private store(sticker: APISticker): Promise<Sticker> {\n return this._add({ ...sticker, guild_id: this.guildId });\n }\n}\n","import type { Awaitable, CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n GatewayDispatchEvents,\n GatewayOpcodes,\n type APIGuild,\n type APIIncidentsData,\n type APIVoiceRegion,\n type RESTGetAPIGuildVanityUrlResult,\n type RESTPatchAPIGuildJSONBody,\n type RESTPostAPIGuildsJSONBody,\n type RESTPutAPIGuildIncidentActionsJSONBody,\n type APIApplicationCommand,\n type APIGuildScheduledEvent,\n type APIThreadChannel,\n type AuditLogEvent,\n type GuildOnboardingMode,\n type GuildOnboardingPromptType,\n type APIGuildWelcomeScreen,\n type APIGuildOnboarding,\n type RESTPatchAPIGuildWelcomeScreenJSONBody,\n type RESTPatchAPIGuildWidgetSettingsJSONBody,\n type RESTPutAPIGuildOnboardingJSONBody,\n} from \"discord-api-types/v10\";\nimport { applyGatewayDispatch } from \"@wolfstar/plugin-cache\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { AnonymousGuild } from \"../structures/guilds/AnonymousGuild.js\";\nimport {\n Guild,\n GuildChannelFields,\n type GuildEditOptions,\n type GuildRelations,\n} from \"../structures/guilds/Guild.js\";\nimport { bindClient } from \"../structures/Structure.js\";\nimport { resolveAuditLogTarget, type AuditLogEntities } from \"../util/auditLogs.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { GuildPreview } from \"../structures/guilds/GuildPreview.js\";\nimport { GuildAuditLogsEntry } from \"../structures/guilds/GuildAuditLogsEntry.js\";\nimport { GuildOnboarding } from \"../structures/guilds/GuildOnboarding.js\";\nimport type { Integration } from \"../structures/guilds/Integration.js\";\nimport {\n ReactionEmoji,\n type EmojiIdentifierResolvable,\n} from \"../structures/emojis/ReactionEmoji.js\";\nimport { WelcomeScreen } from \"../structures/guilds/WelcomeScreen.js\";\nimport type { AutoModerationRule } from \"../structures/automoderation/AutoModerationRule.js\";\nimport type { User } from \"../structures/users/User.js\";\nimport type { Webhook } from \"../structures/webhooks/Webhook.js\";\nimport { resolveId, type IdResolvable } from \"../util/channels.js\";\nimport { SystemChannelFlagsBitField } from \"../util/flags.js\";\nimport { CachedManager } from \"./CachedManager.js\";\nimport { AutoModerationRuleManager } from \"./AutoModerationRuleManager.js\";\nimport { GuildBanManager } from \"./GuildBanManager.js\";\nimport { GuildChannelManager } from \"./GuildChannelManager.js\";\nimport { GuildIntegrationManager } from \"./GuildIntegrationManager.js\";\nimport { GuildScheduledEventManager } from \"./GuildScheduledEventManager.js\";\nimport { GuildSoundboardSoundManager } from \"./GuildSoundboardSoundManager.js\";\nimport { StageInstanceManager } from \"./StageInstanceManager.js\";\nimport type { AnyThreadChannel } from \"./ThreadManager.js\";\nimport { GuildEmojiManager } from \"./GuildEmojiManager.js\";\nimport { GuildInviteManager } from \"./GuildInviteManager.js\";\nimport { GuildStickerManager } from \"./GuildStickerManager.js\";\n\n/**\n * Until when to pause invites and direct messages in a guild, at most 24 hours ahead; `null` resumes them.\n */\nexport interface GuildIncidentActionsOptions {\n invitesDisabledUntil?: Date | number | null;\n dmsDisabledUntil?: Date | number | null;\n}\n\n/**\n * The options to fetch a page of a guild's audit log with.\n */\nexport interface GuildAuditLogsFetchOptions {\n /**\n * Only the entries of this user's actions.\n */\n user?: IdResolvable;\n /**\n * Only the entries of this action.\n */\n type?: AuditLogEvent;\n /**\n * The entry (or ID) to fetch entries before.\n */\n before?: IdResolvable;\n after?: IdResolvable;\n /**\n * How many entries to fetch, up to 100.\n */\n limit?: number;\n}\n\n/**\n * A page of a guild's audit log, with the entities its entries refer to.\n */\nexport interface GuildAuditLogs {\n entries: GuildAuditLogsEntry[];\n users: User[];\n webhooks: Webhook[];\n autoModerationRules: AutoModerationRule[];\n threads: AnyThreadChannel[];\n /**\n * The integrations the entries refer to, partial: an ID, a name, a type, and an account.\n */\n integrations: Integration[];\n applicationCommands: APIApplicationCommand[];\n guildScheduledEvents: APIGuildScheduledEvent[];\n}\n\n/**\n * A channel to suggest in a welcome screen.\n */\nexport interface WelcomeChannelData {\n channel: IdResolvable;\n description: string;\n emoji?: EmojiIdentifierResolvable | null;\n}\n\n/**\n * The options to edit a welcome screen with.\n */\nexport interface GuildWelcomeScreenEditOptions {\n enabled?: boolean;\n description?: string | null;\n welcomeChannels?: readonly WelcomeChannelData[];\n reason?: string;\n}\n\n/**\n * The widget settings of a guild.\n */\nexport interface GuildWidgetSettings {\n enabled: boolean;\n /**\n * The channel the widget's invite leads to.\n */\n channelId: string | null;\n}\n\n/**\n * The options to edit the widget settings of a guild with.\n */\nexport interface GuildWidgetSettingsEditOptions {\n enabled?: boolean;\n channel?: IdResolvable | null;\n reason?: string;\n}\n\n/**\n * An answer of an onboarding prompt. Without an ID, it is a new one.\n */\nexport interface GuildOnboardingPromptOptionData {\n id?: string;\n title: string;\n description?: string | null;\n channels?: readonly IdResolvable[];\n roles?: readonly IdResolvable[];\n emoji?: EmojiIdentifierResolvable | null;\n}\n\n/**\n * A question of an onboarding. Without an ID, it is a new one.\n */\nexport interface GuildOnboardingPromptData {\n id?: string;\n title: string;\n options: readonly GuildOnboardingPromptOptionData[];\n type?: GuildOnboardingPromptType;\n singleSelect?: boolean;\n required?: boolean;\n inOnboarding?: boolean;\n}\n\n/**\n * The options to edit an onboarding with. The prompts replace every existing one.\n */\nexport interface GuildOnboardingEditOptions {\n prompts?: readonly GuildOnboardingPromptData[];\n defaultChannels?: readonly IdResolvable[];\n enabled?: boolean;\n mode?: GuildOnboardingMode;\n reason?: string;\n}\n\n/**\n * Manages the {@link Guild}s known to the client.\n */\nexport class GuildManager extends CachedManager<\"guilds\", Guild, [guildId: string]> {\n public constructor(client: GatewayClient) {\n super(client, \"guilds\");\n }\n\n public construct(data: CacheEntityTypes[\"guilds\"]): Guild {\n return new Guild(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"guilds\"]): string {\n return data.id;\n }\n\n /**\n * Builds a guild, resolving its AFK, system, widget, rules, public updates, and safety alerts channels from the\n * cache.\n *\n * @internal\n */\n public override _hydrate(data: CacheEntityTypes[\"guilds\"]): Awaitable<Guild> {\n const relations: GuildRelations = {};\n // The channels resolve their guild to this very structure, rather than reading it again.\n const guild = bindClient(new Guild(data, relations), this.client);\n const fields = Object.entries(GuildChannelFields) as [keyof GuildRelations, string][];\n return whenAll(\n fields.map(([, key]) => {\n const channelId = (data as unknown as Record<string, string | null | undefined>)[key];\n return channelId ? this.client.channels._getInGuild(channelId, guild) : null;\n }),\n (channels) => {\n for (const [index, [name]] of fields.entries()) relations[name] = channels[index] ?? null;\n return guild;\n },\n );\n }\n\n /**\n * Gets a guild from the cache without resolving its channels, for the relations of other structures: a message\n * resolving its guild should not read six more channels. Its channel getters fall back to a synchronous cache.\n *\n * @param guildId The ID of the guild.\n * @internal\n */\n public _getShallow(guildId: string): Awaitable<Guild | undefined> {\n return whenAll([this.cache?.get(guildId)], ([raw]) =>\n raw === undefined ? undefined : bindClient(this.construct(raw), this.client),\n );\n }\n\n public resolveKey(guildId: string): string {\n return guildId;\n }\n\n /**\n * Gets the manager of a guild's scheduled events.\n *\n * @param guildId The ID of the guild.\n */\n public scheduledEvents(guildId: string): GuildScheduledEventManager {\n return new GuildScheduledEventManager(this.client, guildId);\n }\n\n /**\n * Gets the manager of a guild's stage instances.\n *\n * @param guildId The ID of the guild.\n */\n public stageInstances(guildId: string): StageInstanceManager {\n return new StageInstanceManager(this.client, guildId);\n }\n\n /**\n * Gets the manager of a guild's soundboard sounds.\n *\n * @param guildId The ID of the guild.\n */\n public soundboardSounds(guildId: string): GuildSoundboardSoundManager {\n return new GuildSoundboardSoundManager(this.client, guildId);\n }\n\n /**\n * Gets the manager of a guild's integrations.\n *\n * @param guildId The ID of the guild.\n */\n public integrations(guildId: string): GuildIntegrationManager {\n return new GuildIntegrationManager(this.client, guildId);\n }\n\n /**\n * Fetches the welcome screen of a guild.\n *\n * @param guildId The ID of the guild.\n */\n public async fetchWelcomeScreen(guildId: string): Promise<WelcomeScreen> {\n const screen = await this.client.api.guilds.getWelcomeScreen(guildId);\n return this.welcomeScreen(guildId, screen);\n }\n\n /**\n * Edits the welcome screen of a guild.\n *\n * @param guildId The ID of the guild.\n * @param options The changes to apply.\n */\n public async editWelcomeScreen(\n guildId: string,\n options: GuildWelcomeScreenEditOptions,\n ): Promise<WelcomeScreen> {\n const body: RESTPatchAPIGuildWelcomeScreenJSONBody = {\n enabled: options.enabled,\n description: options.description,\n welcome_channels: options.welcomeChannels?.map((channel) => {\n const emoji = channel.emoji ? ReactionEmoji.resolvePartial(channel.emoji) : null;\n return {\n channel_id: resolveId(channel.channel),\n description: channel.description,\n emoji_id: emoji?.id ?? null,\n emoji_name: emoji?.name ?? null,\n };\n }),\n };\n const screen = await this.client.api.guilds.editWelcomeScreen(guildId, body, {\n reason: options.reason,\n });\n return this.welcomeScreen(guildId, screen);\n }\n\n /**\n * Fetches whether the widget of a guild is enabled, and its channel.\n *\n * @param guildId The ID of the guild.\n */\n public async fetchWidgetSettings(guildId: string): Promise<GuildWidgetSettings> {\n const settings = await this.client.api.guilds.getWidgetSettings(guildId);\n return { enabled: settings.enabled, channelId: settings.channel_id };\n }\n\n /**\n * Edits the widget settings of a guild, and patches the cached guild.\n *\n * @param guildId The ID of the guild.\n * @param options Whether to enable the widget, and its channel.\n */\n public async editWidgetSettings(\n guildId: string,\n options: GuildWidgetSettingsEditOptions,\n ): Promise<GuildWidgetSettings> {\n const body: RESTPatchAPIGuildWidgetSettingsJSONBody = {\n enabled: options.enabled,\n channel_id:\n options.channel === undefined ? undefined : options.channel && resolveId(options.channel),\n };\n const settings = await this.client.api.guilds.editWidgetSettings(guildId, body, {\n reason: options.reason,\n });\n const cached = await this.cache?.get(guildId);\n if (cached) {\n await this.cache!.set(guildId, {\n ...cached,\n widget_enabled: settings.enabled,\n widget_channel_id: settings.channel_id,\n });\n }\n\n return { enabled: settings.enabled, channelId: settings.channel_id };\n }\n\n /**\n * Fetches the onboarding of a guild.\n *\n * @param guildId The ID of the guild.\n */\n public async fetchOnboarding(guildId: string): Promise<GuildOnboarding> {\n const onboarding = await this.client.api.guilds.getOnboarding(guildId);\n return this.onboarding(guildId, onboarding);\n }\n\n /**\n * Edits the onboarding of a guild.\n *\n * @param guildId The ID of the guild.\n * @param options The changes to apply. The prompts replace every existing one.\n */\n public async editOnboarding(\n guildId: string,\n options: GuildOnboardingEditOptions,\n ): Promise<GuildOnboarding> {\n const body: RESTPutAPIGuildOnboardingJSONBody = {\n prompts: options.prompts?.map((prompt) => ({\n id: prompt.id ?? placeholderId(),\n title: prompt.title,\n type: prompt.type,\n single_select: prompt.singleSelect,\n required: prompt.required,\n in_onboarding: prompt.inOnboarding,\n options: prompt.options.map((option) => {\n const emoji = option.emoji ? ReactionEmoji.resolvePartial(option.emoji) : null;\n return {\n id: option.id ?? placeholderId(),\n title: option.title,\n description: option.description,\n channel_ids: option.channels?.map(resolveId),\n role_ids: option.roles?.map(resolveId),\n emoji_id: emoji?.id,\n emoji_name: emoji?.name,\n emoji_animated: emoji?.animated,\n };\n }),\n })),\n default_channel_ids: options.defaultChannels?.map(resolveId),\n enabled: options.enabled,\n mode: options.mode,\n };\n const onboarding = await this.client.api.guilds.editOnboarding(guildId, body, {\n reason: options.reason,\n });\n return this.onboarding(guildId, onboarding);\n }\n\n /**\n * Gets the manager of a guild's bans.\n *\n * @param guildId The ID of the guild.\n */\n public bans(guildId: string): GuildBanManager {\n return new GuildBanManager(this.client, guildId);\n }\n\n /**\n * Gets the manager of a guild's auto moderation rules.\n *\n * @param guildId The ID of the guild.\n */\n public autoModerationRules(guildId: string): AutoModerationRuleManager {\n return new AutoModerationRuleManager(this.client, guildId);\n }\n\n /**\n * Fetches a page of a guild's audit log, newest first, and caches its users.\n *\n * @param guildId The ID of the guild.\n * @param options Which user and action to filter by, and the page.\n */\n public async fetchAuditLogs(\n guildId: string,\n options: GuildAuditLogsFetchOptions = {},\n ): Promise<GuildAuditLogs> {\n const log = await this.client.api.guilds.getAuditLogs(guildId, {\n user_id: options.user && resolveId(options.user),\n action_type: options.type,\n before: options.before && resolveId(options.before),\n after: options.after && resolveId(options.after),\n limit: options.limit,\n });\n const [users, guild] = await Promise.all([\n Promise.all(log.users.map((user) => this.client.users._add(user))),\n this.cachedGuild(guildId),\n ]);\n const usersById = new Map(users.map((user) => [user.id, user]));\n const rules = this.autoModerationRules(guildId);\n const integrations = this.integrations(guildId);\n const [webhooks, autoModerationRules, threads, pageIntegrations] = await Promise.all([\n Promise.all(log.webhooks.map((webhook) => this.client.webhooks.hydrate(webhook))),\n Promise.all(log.auto_moderation_rules.map((rule) => rules.hydrate(rule))),\n Promise.all(\n log.threads.map((thread) => this.client.threads.hydrate(thread as APIThreadChannel)),\n ),\n // Partial: the page only holds an ID, a name, a type, and an account.\n Promise.all(\n log.integrations.map((integration) =>\n integrations.hydrate({ ...integration, guild_id: guildId } as never),\n ),\n ),\n ]);\n const entities: AuditLogEntities = {\n users: usersById,\n webhooks: new Map(webhooks.map((webhook) => [webhook.id, webhook])),\n integrations: new Map(pageIntegrations.map((integration) => [integration.id, integration])),\n applicationCommands: new Map(\n log.application_commands.map((command) => [command.id, command]),\n ),\n };\n\n return {\n entries: await Promise.all(\n log.audit_log_entries.map(async (raw) => {\n const entry = { ...raw, guild_id: guildId };\n return bindClient(\n new GuildAuditLogsEntry(entry, {\n executor: (entry.user_id && usersById.get(entry.user_id)) || null,\n guild,\n target: await resolveAuditLogTarget(this.client, entry, entities),\n }),\n this.client,\n );\n }),\n ),\n users,\n webhooks,\n autoModerationRules,\n threads,\n integrations: pageIntegrations,\n applicationCommands: log.application_commands,\n guildScheduledEvents: log.guild_scheduled_events,\n };\n }\n\n /**\n * Gets the manager of a guild's channels.\n *\n * @param guildId The ID of the guild.\n */\n public channels(guildId: string): GuildChannelManager {\n return new GuildChannelManager(this.client, guildId);\n }\n\n /**\n * Gets the manager of a guild's custom emojis.\n *\n * @param guildId The ID of the guild.\n */\n public emojis(guildId: string): GuildEmojiManager {\n return new GuildEmojiManager(this.client, guildId);\n }\n\n /**\n * Gets the manager of a guild's custom stickers.\n *\n * @param guildId The ID of the guild.\n */\n public stickers(guildId: string): GuildStickerManager {\n return new GuildStickerManager(this.client, guildId);\n }\n\n /**\n * Gets the manager of a guild's invites.\n *\n * @param guildId The ID of the guild.\n */\n public invites(guildId: string): GuildInviteManager {\n return new GuildInviteManager(this.client, guildId);\n }\n\n /**\n * Lists the guilds the bot is in, as the partial guilds the API returns, paginated by guild ID.\n *\n * @param options How many guilds to list (up to 200), around which guild ID, and whether to include counts.\n */\n public async fetchPartials(\n options: { limit?: number; before?: string; after?: string; withCounts?: boolean } = {},\n ): Promise<AnonymousGuild[]> {\n const guilds = await this.client.api.users.getGuilds({\n limit: options.limit,\n before: options.before,\n after: options.after,\n with_counts: options.withCounts,\n });\n return guilds.map((guild) => new AnonymousGuild(guild));\n }\n\n /**\n * Creates a guild owned by the bot, which Discord only allows to bots in fewer than 10 guilds.\n *\n * @param options The guild's name and initial setup.\n */\n public async create(options: RESTPostAPIGuildsJSONBody): Promise<Guild> {\n const guild = await this.client.api.guilds.create(options);\n return this.store(guild);\n }\n\n /**\n * Edits a guild.\n *\n * @param guildId The ID of the guild.\n * @param options The changes to apply.\n */\n public async edit(guildId: string, options: GuildEditOptions): Promise<Guild> {\n const body: RESTPatchAPIGuildJSONBody = {\n name: options.name,\n description: options.description,\n features: options.features,\n owner_id: options.owner,\n verification_level: options.verificationLevel,\n default_message_notifications: options.defaultMessageNotifications,\n explicit_content_filter: options.explicitContentFilter,\n afk_channel_id: options.afkChannel,\n afk_timeout: options.afkTimeout,\n icon: options.icon,\n splash: options.splash,\n discovery_splash: options.discoverySplash,\n banner: options.banner,\n system_channel_id: options.systemChannel,\n system_channel_flags:\n options.systemChannelFlags === undefined\n ? undefined\n : Number(SystemChannelFlagsBitField.resolve(options.systemChannelFlags)),\n rules_channel_id: options.rulesChannel,\n public_updates_channel_id: options.publicUpdatesChannel,\n preferred_locale: options.preferredLocale,\n premium_progress_bar_enabled: options.premiumProgressBarEnabled,\n safety_alerts_channel_id: options.safetyAlertsChannel,\n };\n const guild = await this.client.api.guilds.edit(guildId, body, {\n reason: options.reason,\n });\n return this.store(guild);\n }\n\n /**\n * Makes the bot leave a guild, and drops it from the cache with everything it scopes.\n *\n * @param guildId The ID of the guild.\n */\n public async leave(guildId: string): Promise<void> {\n await this.client.api.users.leaveGuild(guildId);\n await this.forget(guildId);\n }\n\n /**\n * Deletes a guild the bot owns, and drops it from the cache with everything it scopes.\n *\n * @param guildId The ID of the guild.\n */\n public async delete(guildId: string): Promise<void> {\n await this.client.api.guilds.delete(guildId);\n await this.forget(guildId);\n }\n\n /**\n * Fetches the public preview of a guild.\n *\n * @param guildId The ID of the guild.\n */\n public async fetchPreview(guildId: string): Promise<GuildPreview> {\n return new GuildPreview(await this.client.api.guilds.getPreview(guildId));\n }\n\n /**\n * Fetches the voice regions available to a guild.\n *\n * @param guildId The ID of the guild.\n */\n public async fetchVoiceRegions(guildId: string): Promise<APIVoiceRegion[]> {\n return this.client.api.guilds.getVoiceRegions(guildId);\n }\n\n /**\n * Fetches the vanity invite code of a guild and how many times it was used.\n *\n * @param guildId The ID of the guild.\n */\n public async fetchVanityData(guildId: string): Promise<RESTGetAPIGuildVanityUrlResult> {\n return this.client.api.guilds.getVanityURL(guildId);\n }\n\n /**\n * Pauses invites or direct messages in a guild for up to a day.\n *\n * @param guildId The ID of the guild.\n * @param options Until when to pause each, `null` to resume.\n */\n public async setIncidentActions(\n guildId: string,\n options: GuildIncidentActionsOptions,\n ): Promise<APIIncidentsData> {\n const body: RESTPutAPIGuildIncidentActionsJSONBody = {\n invites_disabled_until: toISO(options.invitesDisabledUntil),\n dms_disabled_until: toISO(options.dmsDisabledUntil),\n };\n const incidents = await this.client.api.guilds.editIncidentActions(guildId, body);\n const cached = await this.cache?.get(guildId);\n if (cached) await this.cache!.set(guildId, { ...cached, incidents_data: incidents });\n return incidents;\n }\n\n protected async fetchRaw(guildId: string) {\n return this.client.api.guilds.get(guildId, { with_counts: true });\n }\n\n private store(guild: APIGuild): Promise<Guild> {\n return this._add(guild);\n }\n\n // Resolves the guild of a welcome screen, and the channels and custom emojis of its welcome channels.\n private async welcomeScreen(\n guildId: string,\n screen: APIGuildWelcomeScreen,\n ): Promise<WelcomeScreen> {\n const channels = screen.welcome_channels;\n const [guild, cachedChannels, emojis] = await Promise.all([\n this.cachedGuild(guildId),\n cachedMap(\n channels.map((channel) => channel.channel_id),\n (id) => this.client.channels.get(id),\n ),\n cachedMap(\n channels.flatMap((channel) => (channel.emoji_id ? [channel.emoji_id] : [])),\n (id) => this.emojis(guildId).get(id),\n ),\n ]);\n return bindClient(\n new WelcomeScreen(\n { ...screen, guild_id: guildId },\n { guild, channels: cachedChannels, emojis },\n ),\n this.client,\n );\n }\n\n // Resolves the guild of an onboarding, and the channels, roles, and custom emojis its prompts refer to.\n private async onboarding(\n guildId: string,\n onboarding: APIGuildOnboarding,\n ): Promise<GuildOnboarding> {\n const options = onboarding.prompts.flatMap((prompt) => prompt.options);\n const [guild, channels, roles, emojis] = await Promise.all([\n this.cachedGuild(guildId),\n cachedMap(\n [...onboarding.default_channel_ids, ...options.flatMap((option) => option.channel_ids)],\n (id) => this.client.channels.get(id),\n ),\n cachedMap(\n options.flatMap((option) => option.role_ids),\n (id) => this.client.roles.get(guildId, id),\n ),\n cachedMap(\n options.flatMap((option) => (option.emoji?.id ? [option.emoji.id] : [])),\n (id) => this.emojis(guildId).get(id),\n ),\n ]);\n return bindClient(\n new GuildOnboarding(onboarding, { guild, channels, roles, emojis }),\n this.client,\n );\n }\n\n // The same cascade as a `GUILD_DELETE`, so no channel, member, or role of the guild outlives it. It is queued with\n // the guild's dispatches, so it never interleaves with one still being written.\n private async forget(guildId: string): Promise<void> {\n const { cache } = this.client;\n if (!cache) return;\n await this.client.runInGuildOrder(guildId, () =>\n applyGatewayDispatch(cache, {\n op: GatewayOpcodes.Dispatch,\n s: 0,\n t: GatewayDispatchEvents.GuildDelete,\n d: { id: guildId },\n }),\n );\n }\n}\n\n// Reads the cached structures of some IDs, skipping the ones that are not cached (or whose read fails).\nasync function cachedMap<Value>(\n ids: readonly string[],\n get: (id: string) => Promise<Value | undefined>,\n): Promise<Map<string, Value>> {\n const unique = [...new Set(ids)];\n const values = await Promise.all(unique.map((id) => get(id).catch(() => undefined)));\n const map = new Map<string, Value>();\n for (const [index, value] of values.entries()) if (value) map.set(unique[index]!, value);\n return map;\n}\n\n// Discord requires an ID on every prompt and option, and takes any snowflake for the new ones.\nlet placeholderSequence = 0;\nfunction placeholderId(): string {\n placeholderSequence = (placeholderSequence + 1) % 4096;\n return String(((BigInt(Date.now()) - 1_420_070_400_000n) << 22n) | BigInt(placeholderSequence));\n}\n\nfunction toISO(value: Date | number | null | undefined): string | null | undefined {\n return value === undefined || value === null ? value : new Date(value).toISOString();\n}\n","import type { GatewayClient } from \"../GatewayClient.js\";\nimport type { Role } from \"../structures/guilds/Role.js\";\n\n/**\n * Manages the roles of one {@link GuildMember}, reading them through the client's role manager.\n *\n * @remarks\n * discord.js's synchronous `member.roles.cache`, `highest`, `color`, ... become the `fetch*` methods here: the roles\n * are read from the (possibly asynchronous) cache, falling back to the API.\n */\nexport class GuildMemberRoleManager {\n public readonly client: GatewayClient;\n public readonly guildId: string;\n public readonly userId: string;\n\n readonly #roleIds: readonly string[];\n\n /**\n * @param client The client.\n * @param guildId The ID of the guild.\n * @param userId The ID of the member's user.\n * @param roleIds The IDs of the member's roles, as known to the member structure.\n */\n public constructor(\n client: GatewayClient,\n guildId: string,\n userId: string,\n roleIds: readonly string[],\n ) {\n this.client = client;\n this.guildId = guildId;\n this.userId = userId;\n this.#roleIds = roleIds;\n }\n\n /**\n * The IDs of the member's roles, `@everyone` excluded.\n */\n public get ids(): readonly string[] {\n return this.#roleIds;\n }\n\n /**\n * Fetches the member's roles, `@everyone` included, highest first.\n */\n public async fetch(): Promise<Role[]> {\n const ids = [...this.#roleIds, this.guildId];\n const cached = await Promise.all(ids.map((id) => this.client.roles.get(this.guildId, id)));\n let roles = cached.filter((role) => role !== undefined);\n if (roles.length !== ids.length) {\n // One request for every role of the guild, rather than one per missing role.\n const wanted = new Set(ids);\n roles = (await this.client.roles.fetchAll(this.guildId)).filter((role) =>\n wanted.has(role.id),\n );\n }\n\n return roles.toSorted((a, b) => b.comparePositionTo(a));\n }\n\n /**\n * Fetches the member's highest role, `@everyone` when they have no other.\n */\n public async fetchHighest(): Promise<Role | null> {\n return (await this.fetch())[0] ?? null;\n }\n\n /**\n * Fetches the role the member is displayed under in the member list, if any.\n */\n public async fetchHoist(): Promise<Role | null> {\n return (await this.fetch()).find((role) => role.hoist) ?? null;\n }\n\n /**\n * Fetches the highest role giving the member a color, if any.\n */\n public async fetchColor(): Promise<Role | null> {\n return (await this.fetch()).find((role) => role.color !== 0) ?? null;\n }\n\n /**\n * Fetches the highest role giving the member an icon, if any.\n */\n public async fetchIcon(): Promise<Role | null> {\n return (await this.fetch()).find((role) => role.icon ?? role.unicodeEmoji) ?? null;\n }\n\n /**\n * Fetches the server booster role, if the member has it.\n */\n public async fetchPremiumSubscriberRole(): Promise<Role | null> {\n return (await this.fetch()).find((role) => role.tags?.premium_subscriber === null) ?? null;\n }\n\n /**\n * Fetches the role Discord manages for the member, when the member is a bot.\n */\n public async fetchBotRole(): Promise<Role | null> {\n return (await this.fetch()).find((role) => role.tags?.bot_id === this.userId) ?? null;\n }\n\n /**\n * Adds roles to the member.\n *\n * @param roles The ID of the role, or several IDs.\n * @param reason The reason for the audit log.\n */\n public async add(roles: string | readonly string[], reason?: string) {\n if (typeof roles === \"string\") {\n return this.client.members.addRole(this.guildId, this.userId, roles, reason);\n }\n\n return this.set([...new Set([...this.#roleIds, ...roles])], reason);\n }\n\n /**\n * Removes roles from the member.\n *\n * @param roles The ID of the role, or several IDs.\n * @param reason The reason for the audit log.\n */\n public async remove(roles: string | readonly string[], reason?: string) {\n if (typeof roles === \"string\") {\n return this.client.members.removeRole(this.guildId, this.userId, roles, reason);\n }\n\n const removed = new Set(roles);\n return this.set(\n this.#roleIds.filter((id) => !removed.has(id)),\n reason,\n );\n }\n\n /**\n * Replaces the member's roles.\n *\n * @param roles The IDs of the roles the member ends up with.\n * @param reason The reason for the audit log.\n */\n public set(roles: readonly string[], reason?: string) {\n return this.client.members.edit(this.guildId, this.userId, { roles, reason });\n }\n}\n","import { DiscordAPIError, type ImageURLOptions } from \"@discordjs/rest\";\nimport type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { APIAvatarDecorationData } from \"discord-api-types/v10\";\nimport type { BanOptions, GuildMemberEditOptions } from \"../../managers/GuildMemberManager.js\";\nimport { GuildMemberRoleManager } from \"../../managers/GuildMemberRoleManager.js\";\nimport { cdn } from \"../../util/cdn.js\";\nimport { GuildMemberFlagsBitField, type GuildMemberFlagsResolvable } from \"../../util/flags.js\";\nimport {\n MessagePayload,\n type MessageCreateOptions,\n type MessagePayloadResolvable,\n} from \"../messages/MessagePayload.js\";\nimport { computeGuildPermissions, computePermissionsIn } from \"../../util/permissions.js\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { PermissionsBitField } from \"../../util/PermissionsBitField.js\";\nimport type { DMChannel } from \"../channels/DMChannel.js\";\nimport type { Message } from \"../messages/Message.js\";\nimport type { Presence } from \"../presences/Presence.js\";\nimport type { VoiceState } from \"../voice/VoiceState.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kPatch, kRelations, Structure } from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\n/**\n * The relations of a {@link GuildMember}, resolved from the cache by `client.members`.\n */\nexport interface GuildMemberRelations {\n user?: User;\n guild?: Guild | null;\n /**\n * The member's voice state, `null` when they are not connected.\n */\n voice?: VoiceState | null;\n presence?: Presence | null;\n}\n\n/**\n * A member of a Discord guild.\n *\n * @remarks\n * Relations are asynchronous, unlike discord.js: `member.roles` reads roles through the (possibly asynchronous)\n * cache, and discord.js's `permissions`, `manageable`, `kickable`, ... are the `fetch*` methods below.\n */\nexport class GuildMember extends Structure<CacheEntityTypes[\"members\"]> {\n declare public [kRelations]: GuildMemberRelations;\n\n protected override optimizeData(data: Partial<CacheEntityTypes[\"members\"]>): void {\n this.optimizeTimestamp(\"joined_at\", data.joined_at);\n this.optimizeTimestamp(\"premium_since\", data.premium_since);\n this.optimizeTimestamp(\"communication_disabled_until\", data.communication_disabled_until);\n }\n\n /**\n * @param data The raw member.\n * @param relations The member's user and guild as resolved from the cache, by `client.members`.\n */\n public constructor(data: CacheEntityTypes[\"members\"], relations: GuildMemberRelations = {}) {\n super(data, relations);\n }\n\n /**\n * The ID of the member's user, or `null` if the payload did not include it.\n */\n public get id(): string | null {\n return this[kData].user?.id ?? null;\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n /**\n * The guild, from the cache. `null` when the guild is not cached, or when the member was not built by a manager: use\n * `fetchGuild()` to always get it.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * Fetches the guild, cache first.\n */\n public fetchGuild(): Promise<Guild> {\n return this.client.guilds.fetch(this.guildId);\n }\n\n public override [kPatch](data: Readonly<Partial<CacheEntityTypes[\"members\"]>>): this {\n // A payload carrying the user is fresher than the one resolved when the member was built.\n if (data.user) this.dropRelations(\"user\");\n return super[kPatch](data);\n }\n\n /**\n * The member's user, or `null` if the payload did not include it. Resolved from `client.users` when the member\n * comes from a manager.\n */\n public get user(): User | null {\n const { user } = this[kData];\n return this[kRelations].user ?? (user ? new User(user) : null);\n }\n\n public get nickname(): string | null {\n return this[kData].nick ?? null;\n }\n\n /**\n * The name to show for this member: their nickname, falling back to their user's display name.\n */\n public get displayName(): string | null {\n return this.nickname ?? this.user?.displayName ?? null;\n }\n\n /**\n * The IDs of the member's roles, excluding the implicit `@everyone` role.\n */\n public get roleIds(): readonly string[] {\n return this[kData].roles;\n }\n\n /**\n * The member's roles. It needs the member's user ID, which every payload but some partial ones carries.\n */\n public get roles(): GuildMemberRoleManager {\n return new GuildMemberRoleManager(this.client, this.guildId, this.requireId(), this.roleIds);\n }\n\n public get joinedTimestamp(): number | null {\n return this.optimizedTimestamp(\"joined_at\");\n }\n\n public get joinedAt(): Date | null {\n const { joinedTimestamp } = this;\n return joinedTimestamp === null ? null : new Date(joinedTimestamp);\n }\n\n /**\n * When the member started boosting the guild, `null` if they are not boosting it.\n */\n public get premiumSinceTimestamp(): number | null {\n return this.optimizedTimestamp(\"premium_since\");\n }\n\n public get premiumSince(): Date | null {\n const { premiumSinceTimestamp } = this;\n return premiumSinceTimestamp === null ? null : new Date(premiumSinceTimestamp);\n }\n\n public get communicationDisabledUntilTimestamp(): number | null {\n return this.optimizedTimestamp(\"communication_disabled_until\");\n }\n\n public get communicationDisabledUntil(): Date | null {\n const { communicationDisabledUntilTimestamp } = this;\n return communicationDisabledUntilTimestamp === null\n ? null\n : new Date(communicationDisabledUntilTimestamp);\n }\n\n public get pending(): boolean {\n return this[kData].pending ?? false;\n }\n\n /**\n * Whether the member is deafened in voice channels, by a moderator.\n */\n public get deaf(): boolean {\n return this[kData].deaf ?? false;\n }\n\n /**\n * Whether the member is muted in voice channels, by a moderator.\n */\n public get mute(): boolean {\n return this[kData].mute ?? false;\n }\n\n public get flags(): Readonly<GuildMemberFlagsBitField> {\n return new GuildMemberFlagsBitField(this[kData].flags ?? 0).freeze();\n }\n\n /**\n * The member's guild avatar hash, if any.\n */\n public get avatar(): string | null {\n return this[kData].avatar ?? null;\n }\n\n /**\n * The member's guild banner hash, if any.\n */\n public get banner(): string | null {\n return this[kData].banner ?? null;\n }\n\n /**\n * The member's guild avatar decoration, if any.\n */\n public get avatarDecorationData(): APIAvatarDecorationData | null {\n return this[kData].avatar_decoration_data ?? null;\n }\n\n /**\n * Whether the member is timed out right now.\n */\n public isCommunicationDisabled(): boolean {\n const until = this.communicationDisabledUntilTimestamp;\n return until !== null && until > Date.now();\n }\n\n /**\n * Gets the URL of the member's guild avatar, or `null` if they have none.\n * @param options The image options.\n */\n public avatarURL(options?: ImageURLOptions): string | null {\n const { avatar, id } = this;\n return avatar && id ? cdn.guildMemberAvatar(this.guildId, id, avatar, options) : null;\n }\n\n /**\n * Gets the URL of the member's guild avatar, falling back to their user's avatar.\n * @param options The image options.\n */\n public displayAvatarURL(options?: ImageURLOptions): string | null {\n return this.avatarURL(options) ?? this.user?.displayAvatarURL(options) ?? null;\n }\n\n /**\n * Gets the URL of the member's guild banner, or `null` if they have none.\n * @param options The image options.\n */\n public bannerURL(options?: ImageURLOptions): string | null {\n const { banner, id } = this;\n return banner && id ? cdn.guildMemberBanner(this.guildId, id, banner, options) : null;\n }\n\n /**\n * Gets the URL of the member's guild banner, falling back to their user's banner when known.\n * @param options The image options.\n */\n public displayBannerURL(options?: ImageURLOptions): string | null {\n return this.bannerURL(options) ?? this.user?.bannerURL(options) ?? null;\n }\n\n /**\n * Gets the URL of the member's guild avatar decoration, or `null` if they have none.\n */\n public avatarDecorationURL(): string | null {\n const asset = this.avatarDecorationData?.asset;\n return asset ? cdn.avatarDecoration(asset) : null;\n }\n\n /**\n * Gets the URL of the member's guild avatar decoration, falling back to their user's.\n */\n public displayAvatarDecorationURL(): string | null {\n return this.avatarDecorationURL() ?? this.user?.avatarDecorationURL() ?? null;\n }\n\n /**\n * Computes the member's guild-wide permissions, before channel overwrites.\n */\n public async fetchPermissions(): Promise<Readonly<PermissionsBitField>> {\n const client = this.client;\n const guild = await client.guilds.fetch(this.guildId);\n const roles = await this.roles.fetch();\n return computeGuildPermissions({\n guildId: this.guildId,\n ownerId: guild.ownerId,\n userId: this.requireId(),\n memberRoleIds: this.roleIds,\n roles: roles.map((role) => role.toJSON()),\n });\n }\n\n /**\n * Fetches the member's permissions in a channel: their guild permissions with the channel's overwrites applied.\n * discord.js: `member.permissionsIn(channel)`.\n *\n * @param channel The channel, or its ID. Threads use their parent's overwrites.\n */\n public fetchPermissionsIn(channel: AnyChannel | string): Promise<Readonly<PermissionsBitField>> {\n return computePermissionsIn(channel, this);\n }\n\n /**\n * The member's voice state, from the cache, like discord.js's `GuildMember#voice`: `null` when they are not\n * connected, when the voice state is not cached (it needs the `GuildVoiceStates` intent), or when the member was not\n * built by a manager. Use {@link GuildMember.fetchVoiceState} to ask the API.\n */\n public get voice(): VoiceState | null {\n return this[kRelations].voice ?? null;\n }\n\n /**\n * The member's presence, from the cache, like discord.js's `GuildMember#presence`: `null` when it is not cached\n * (it needs the `GuildPresences` intent), or when the member was not built by a manager.\n */\n public get presence(): Presence | null {\n return this[kRelations].presence ?? null;\n }\n\n /**\n * Fetches the member's voice state, cache first. discord.js: `member.voice`.\n *\n * @returns The voice state, or `null` when the member is not connected to voice.\n */\n public async fetchVoiceState(): Promise<VoiceState | null> {\n try {\n return await this.client.voiceStates.fetch(this.guildId, this.requireId());\n } catch (error) {\n // Discord answers 404 (Unknown Voice State) for members who are not connected.\n if (error instanceof DiscordAPIError && error.status === 404) return null;\n throw error;\n }\n }\n\n /**\n * Gets the member's presence from the cache. discord.js: `member.presence`.\n *\n * @returns The presence, or `null` when it is not cached (the bot needs the `GuildPresences` intent).\n */\n public async fetchPresence(): Promise<Presence | null> {\n return (await this.client.presences.get(this.guildId, this.requireId())) ?? null;\n }\n\n /**\n * Fetches the color the member's name is displayed in, `0` when none of their roles has one.\n */\n public async fetchDisplayColor(): Promise<number> {\n return (await this.roles.fetchColor())?.color ?? 0;\n }\n\n /**\n * Fetches the color the member's name is displayed in, as a `#rrggbb` string.\n */\n public async fetchDisplayHexColor(): Promise<`#${string}`> {\n return `#${(await this.fetchDisplayColor()).toString(16).padStart(6, \"0\")}`;\n }\n\n /**\n * Whether the bot ranks above the member: it is not the guild owner, not the bot itself, and the bot's highest\n * role is higher than theirs (or the bot owns the guild).\n */\n public async fetchManageable(): Promise<boolean> {\n const client = this.client;\n const id = this.requireId();\n const guild = await client.guilds.fetch(this.guildId);\n const meId = client.user?.id ?? client.id;\n if (id === guild.ownerId || id === meId) return false;\n if (meId === guild.ownerId) return true;\n\n const me = await client.members.fetchMe(this.guildId);\n const [mine, theirs] = await Promise.all([me.roles.fetchHighest(), this.roles.fetchHighest()]);\n return mine !== null && theirs !== null && mine.comparePositionTo(theirs) > 0;\n }\n\n /**\n * Whether the bot can kick the member: it outranks them and has `KickMembers`.\n */\n public fetchKickable(): Promise<boolean> {\n return this.managedWith(\"KickMembers\");\n }\n\n /**\n * Whether the bot can ban the member: it outranks them and has `BanMembers`.\n */\n public fetchBannable(): Promise<boolean> {\n return this.managedWith(\"BanMembers\");\n }\n\n /**\n * Whether the bot can time the member out: it outranks them, has `ModerateMembers`, and they are no administrator.\n */\n public async fetchModeratable(): Promise<boolean> {\n if (!(await this.managedWith(\"ModerateMembers\"))) return false;\n return !(await this.fetchPermissions()).has(\"Administrator\");\n }\n\n /**\n * Edits the member.\n *\n * @param options The fields to edit.\n * @returns This member, patched.\n */\n public async edit(options: GuildMemberEditOptions): Promise<this> {\n const member = await this.client.members.edit(this.guildId, this.requireId(), options);\n return this[kPatch](member.toJSON());\n }\n\n public setNickname(nick: string | null, reason?: string): Promise<this> {\n return this.edit({ nick, reason });\n }\n\n public setFlags(flags: GuildMemberFlagsResolvable, reason?: string): Promise<this> {\n return this.edit({ flags, reason });\n }\n\n /**\n * Times the member out until a given time, or lifts the timeout with `null`.\n */\n public disableCommunicationUntil(\n communicationDisabledUntil: Date | number | null,\n reason?: string,\n ): Promise<this> {\n return this.edit({ communicationDisabledUntil, reason });\n }\n\n /**\n * Times the member out for a duration in milliseconds, or lifts the timeout with `null`.\n */\n public timeout(duration: number | null, reason?: string): Promise<this> {\n return this.disableCommunicationUntil(duration === null ? null : Date.now() + duration, reason);\n }\n\n public async kick(reason?: string): Promise<this> {\n await this.client.members.kick(this.guildId, this.requireId(), reason);\n return this;\n }\n\n public async ban(options?: BanOptions): Promise<this> {\n await this.client.members.ban(this.guildId, this.requireId(), options);\n return this;\n }\n\n public createDM(): Promise<DMChannel> {\n return this.client.users.createDM(this.requireId());\n }\n\n public deleteDM(): Promise<DMChannel> {\n return this.client.users.deleteDM(this.requireId());\n }\n\n public send(options: MessagePayloadResolvable<MessageCreateOptions>): Promise<Message> {\n return this.client.users.send(this.requireId(), MessagePayload.create(this, options));\n }\n\n /**\n * Whether the member is partial: built from its IDs alone for an event about an uncached member, see\n * `Partials.GuildMember`. Only its IDs (and the user a removal carries) are reliable then, and\n * {@link GuildMember.fetch} completes it.\n */\n public get partial(): boolean {\n return this[kData].joined_at === undefined;\n }\n\n /**\n * Fetches the member from the API and patches this structure with the result.\n */\n public async fetch(): Promise<this> {\n const member = await this.client.members.fetch(this.guildId, this.requireId(), {\n force: true,\n });\n return this[kPatch](member.toJSON());\n }\n\n /**\n * Fetches the member's user, cache first.\n */\n public fetchUser(): Promise<User> {\n return this.client.users.fetch(this.requireId());\n }\n\n /**\n * Whether this member has the same data as another one.\n * @param member The member to compare with.\n */\n public equals(member: GuildMember): boolean {\n return (\n this.id === member.id &&\n this.guildId === member.guildId &&\n this.nickname === member.nickname &&\n this.avatar === member.avatar &&\n this.joinedTimestamp === member.joinedTimestamp &&\n this.premiumSinceTimestamp === member.premiumSinceTimestamp &&\n this.communicationDisabledUntilTimestamp === member.communicationDisabledUntilTimestamp &&\n this.flags.bitField === member.flags.bitField &&\n this.roleIds.length === member.roleIds.length &&\n this.roleIds.every((id) => member.roleIds.includes(id))\n );\n }\n\n public toString(): string {\n return this.id ? `<@${this.id}>` : \"\";\n }\n\n private async managedWith(permission: \"KickMembers\" | \"BanMembers\" | \"ModerateMembers\") {\n if (!(await this.fetchManageable())) return false;\n const me = await this.client.members.fetchMe(this.guildId);\n return (await me.fetchPermissions()).has(permission);\n }\n\n private requireId(): string {\n const { id } = this;\n if (id === null) throw new Error(\"This member has no user data: its ID is unknown\");\n return id;\n }\n}\n","import type { ImageURLOptions } from \"@discordjs/rest\";\nimport type { GatewayActivityAssets } from \"discord-api-types/v10\";\nimport { cdn } from \"../../util/cdn.js\";\nimport { kData, Structure } from \"../Structure.js\";\n\n/**\n * The raw assets of an activity, with the ID of the activity's application.\n */\nexport type RichPresenceAssetsData = GatewayActivityAssets & { application_id?: string | null };\n\n/**\n * The assets (images and their hover texts) of a rich presence activity.\n */\nexport class RichPresenceAssets extends Structure<RichPresenceAssetsData> {\n /**\n * The ID of the application the assets belong to, needed to build the URLs of application assets.\n */\n public get applicationId(): string | null {\n return this[kData].application_id ?? null;\n }\n\n /**\n * The hover text of the large image.\n */\n public get largeText(): string | null {\n return this[kData].large_text ?? null;\n }\n\n /**\n * The hover text of the small image.\n */\n public get smallText(): string | null {\n return this[kData].small_text ?? null;\n }\n\n /**\n * The ID of the large image asset, or an external asset in the `platform:id` form.\n */\n public get largeImage(): string | null {\n return this[kData].large_image ?? null;\n }\n\n /**\n * The ID of the small image asset, or an external asset in the `platform:id` form.\n */\n public get smallImage(): string | null {\n return this[kData].small_image ?? null;\n }\n\n /**\n * Gets the URL of the small image, or `null` if there is none or it comes from an unsupported platform.\n *\n * @param options The image options, ignored for external assets.\n */\n public smallImageURL(options?: ImageURLOptions): string | null {\n const { smallImage } = this;\n if (!smallImage) return null;\n if (smallImage.includes(\":\")) {\n const [platform, id] = smallImage.split(\":\") as [string, string];\n switch (platform) {\n case \"mp\":\n return `https://media.discordapp.net/${id}`;\n default:\n return null;\n }\n }\n\n return this.applicationId ? cdn.appAsset(this.applicationId, smallImage, options) : null;\n }\n\n /**\n * Gets the URL of the large image, or `null` if there is none or it comes from an unsupported platform.\n *\n * @param options The image options, ignored for external assets.\n */\n public largeImageURL(options?: ImageURLOptions): string | null {\n const { largeImage } = this;\n if (!largeImage) return null;\n if (largeImage.includes(\":\")) {\n const [platform, id] = largeImage.split(\":\") as [string, string];\n switch (platform) {\n case \"mp\":\n return `https://media.discordapp.net/${id}`;\n case \"spotify\":\n return `https://i.scdn.co/image/${id}`;\n case \"youtube\":\n return `https://i.ytimg.com/vi/${id}/hqdefault_live.jpg`;\n case \"twitch\":\n return `https://static-cdn.jtvnw.net/previews-ttv/live_user_${id}.png`;\n default:\n return null;\n }\n }\n\n return this.applicationId ? cdn.appAsset(this.applicationId, largeImage, options) : null;\n }\n}\n","import { Activity as BaseActivity } from \"@discordjs/structures\";\nimport type { GatewayActivity } from \"discord-api-types/v10\";\nimport { ActivityFlagsBitField } from \"../../util/flags.js\";\nimport { RichPresenceAssets } from \"./RichPresenceAssets.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, StructureMixin } from \"../Structure.js\";\n\n/**\n * The start and end of an activity.\n */\nexport interface ActivityTimestamps {\n /**\n * When the activity started, if known.\n */\n start: Date | null;\n /**\n * When the activity ends, if known.\n */\n end: Date | null;\n}\n\n/**\n * The party of an activity.\n */\nexport interface ActivityParty {\n /**\n * The ID of the party.\n */\n id: string | null;\n /**\n * The size of the party, as `[current, max]`.\n */\n size: readonly [current: number, max: number] | null;\n}\n\n/**\n * The emoji of a custom status activity.\n */\nexport interface ActivityEmoji {\n /**\n * The ID of the emoji, or `null` for a unicode emoji.\n */\n id: string | null;\n /**\n * The name of the emoji, or the unicode character.\n */\n name: string | null;\n /**\n * Whether the emoji is animated.\n */\n animated: boolean;\n}\n\nexport interface Activity extends StructureMixin<GatewayActivity> {}\n\n/**\n * An activity of a user's presence: `@discordjs/structures`' `Activity`, with its timestamps, party, assets, emoji,\n * and buttons.\n */\nexport class Activity extends BaseActivity {\n /**\n * @param data The raw activity.\n * @param relations The related structures, resolved from the cache.\n */\n public constructor(data: GatewayActivity, relations: object = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n /**\n * The URL of the stream, when the activity is being streamed.\n */\n public override get url(): string | null {\n return this[kData].url ?? null;\n }\n\n /**\n * What the user is currently doing.\n */\n public override get details(): string | null {\n return this[kData].details ?? null;\n }\n\n /**\n * The user's current party status, or the text of a custom status.\n */\n public override get state(): string | null {\n return this[kData].state ?? null;\n }\n\n /**\n * When the activity started and ends, if known.\n */\n public get timestamps(): ActivityTimestamps | null {\n const { timestamps } = this[kData];\n if (!timestamps) return null;\n return {\n start: timestamps.start ? new Date(Number(timestamps.start)) : null,\n end: timestamps.end ? new Date(Number(timestamps.end)) : null,\n };\n }\n\n /**\n * The party of the activity.\n */\n public get party(): ActivityParty | null {\n const { party } = this[kData];\n if (!party) return null;\n return { id: party.id ?? null, size: party.size ?? null };\n }\n\n /**\n * The sync ID of the activity, which is the track ID for Spotify activities.\n *\n * @remarks This field is not documented by Discord.\n */\n public get syncId(): string | null {\n return this[kData].sync_id ?? null;\n }\n\n /**\n * The assets of the activity, when it is a rich presence.\n */\n public get assets(): RichPresenceAssets | null {\n const { assets } = this[kData];\n return assets\n ? new RichPresenceAssets({ ...assets, application_id: this.applicationId })\n : null;\n }\n\n /**\n * The flags describing the activity.\n */\n public override get flags(): Readonly<ActivityFlagsBitField> {\n return new ActivityFlagsBitField(this[kData].flags ?? 0).freeze();\n }\n\n /**\n * The emoji of a custom status activity.\n */\n public get emoji(): ActivityEmoji | null {\n const { emoji } = this[kData];\n if (!emoji) return null;\n return { id: emoji.id ?? null, name: emoji.name, animated: emoji.animated ?? false };\n }\n\n /**\n * The labels of the buttons of a rich presence activity.\n */\n public get buttons(): string[] {\n return (this[kData].buttons ?? []).map((button) =>\n typeof button === \"string\" ? button : button.label,\n );\n }\n\n /**\n * The time at which the activity was added to the user's session.\n */\n public get createdAt(): Date {\n return new Date(this.createdTimestamp);\n }\n\n /**\n * Whether this activity equals another: same name, type, URL, state, details and emoji.\n *\n * @param activity The activity to compare with.\n */\n public equals(activity: Activity | null | undefined): boolean {\n if (this === activity) return true;\n if (!activity) return false;\n return (\n this.name === activity.name &&\n this.type === activity.type &&\n this.url === activity.url &&\n this.state === activity.state &&\n this.details === activity.details &&\n this.emoji?.id === activity.emoji?.id &&\n this.emoji?.name === activity.emoji?.name\n );\n }\n\n public toString(): string {\n return this.name;\n }\n}\n\nMixin(Activity, [StructureMixin]);\n","import { Presence as BasePresence } from \"@discordjs/structures\";\nimport type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n PresenceUpdateStatus,\n type GatewayPresenceClientStatus,\n type PresenceUpdateReceiveStatus,\n} from \"discord-api-types/v10\";\nimport { Activity } from \"./Activity.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport type { GuildMember } from \"../guilds/GuildMember.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, kRelations, StructureMixin } from \"../Structure.js\";\nimport type { User } from \"../users/User.js\";\n\n/**\n * The status of a presence on each of the user's platforms; a missing platform means the user is offline there.\n */\nexport type ClientStatus = GatewayPresenceClientStatus;\n\n/**\n * The relations of a {@link Presence}, resolved from the cache by `client.presences`.\n */\nexport interface PresenceRelations {\n user?: User | null;\n member?: GuildMember | null;\n guild?: Guild | null;\n}\n\nexport interface Presence extends StructureMixin<\n CacheEntityTypes[\"presences\"],\n PresenceRelations\n> {}\n\n/**\n * The presence of a user in a guild, their status and activities: `@discordjs/structures`' `Presence`, with its user,\n * member, and guild, and actions through the client.\n */\nexport class Presence extends BasePresence {\n /**\n * @param data The raw presence.\n * @param relations The user, member, and guild as resolved from the cache, by `client.presences`.\n */\n public constructor(data: CacheEntityTypes[\"presences\"], relations: PresenceRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n public get userId() {\n return this[kData].user.id;\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n /**\n * The status of the user, `offline` when the payload did not include it.\n */\n public override get status(): PresenceUpdateReceiveStatus {\n return this[kData].status ?? PresenceUpdateStatus.Offline;\n }\n\n public get activities(): Activity[] {\n return (this[kData].activities ?? []).map((activity) => new Activity(activity));\n }\n\n /**\n * The status of the user on each of their platforms, `null` when the payload did not include it.\n */\n public get clientStatus(): ClientStatus | null {\n return this[kData].client_status ?? null;\n }\n\n /**\n * The user, from the cache. Presence payloads only carry the user's changed fields.\n */\n public get user(): User | null {\n return this[kRelations].user ?? null;\n }\n\n public get member(): GuildMember | null {\n return this[kRelations].member ?? null;\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n public fetchMember(): Promise<GuildMember> {\n return this.client.members.fetch(this.guildId, this.userId);\n }\n\n public fetchUser(): Promise<User> {\n return this.client.users.fetch(this.userId);\n }\n\n /**\n * Whether this presence has the same status, client status, and activities as another.\n *\n * @param presence The presence to compare with.\n */\n public equals(presence: Presence | null | undefined): boolean {\n if (this === presence) return true;\n if (!presence) return false;\n\n const activities = this.activities;\n const otherActivities = presence.activities;\n return (\n this.status === presence.status &&\n this.clientStatus?.web === presence.clientStatus?.web &&\n this.clientStatus?.mobile === presence.clientStatus?.mobile &&\n this.clientStatus?.desktop === presence.clientStatus?.desktop &&\n activities.length === otherActivities.length &&\n activities.every((activity, index) => activity.equals(otherActivities[index]))\n );\n }\n}\n\nMixin(Presence, [StructureMixin]);\n","import { VoiceState as BaseVoiceState } from \"@discordjs/structures\";\nimport type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport type { GuildMember } from \"../guilds/GuildMember.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, kPatch, kRelations, StructureMixin } from \"../Structure.js\";\nimport type { User } from \"../users/User.js\";\n\n/**\n * The options to edit a voice state with, only applicable in stage channels.\n */\nexport interface VoiceStateEditOptions {\n /**\n * Whether the bot requests to become a speaker. Only available on the bot's own voice state.\n */\n requestToSpeak?: boolean;\n /**\n * Whether the user is suppressed, i.e. moved to the audience.\n */\n suppressed?: boolean;\n}\n\n/**\n * The relations of a {@link VoiceState}, resolved from the cache by `client.voiceStates`.\n */\nexport interface VoiceStateRelations {\n member?: GuildMember | null;\n guild?: Guild | null;\n channel?: AnyChannel | null;\n}\n\nexport interface VoiceState extends StructureMixin<\n CacheEntityTypes[\"voiceStates\"],\n VoiceStateRelations\n> {}\n\n/**\n * The voice state of a guild member: `@discordjs/structures`' `VoiceState`, with its member and guild, and actions\n * through the client.\n *\n * @remarks\n * Unlike `@discordjs/structures`', `deaf` and `mute` also account for the member's own deafen and mute; `serverDeaf`\n * and `serverMute` are the server-wide ones.\n */\nexport class VoiceState extends BaseVoiceState {\n protected override optimizeData(data: Partial<CacheEntityTypes[\"voiceStates\"]>): void {\n this.optimizeTimestamp(\"request_to_speak_timestamp\", data.request_to_speak_timestamp);\n }\n\n /**\n * @param data The raw voice state.\n * @param relations The member and guild as resolved from the cache, by `client.voiceStates`.\n */\n public constructor(data: CacheEntityTypes[\"voiceStates\"], relations: VoiceStateRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n public [kPatch](data: Readonly<Partial<CacheEntityTypes[\"voiceStates\"]>>): this {\n if (data.member) this.dropRelations(\"member\");\n this.dropChangedRelations(data, { channel: \"channel_id\" });\n return StructureMixin.prototype[kPatch].call(this, data) as this;\n }\n\n /**\n * Whether the member is deafened server-wide.\n */\n public get serverDeaf() {\n return this[kData].deaf;\n }\n\n /**\n * Whether the member is muted server-wide.\n */\n public get serverMute() {\n return this[kData].mute;\n }\n\n /**\n * Whether the member is streaming using \"Screen Share\", `false` when the payload did not include it.\n */\n public get streaming() {\n return this[kData].self_stream ?? false;\n }\n\n /**\n * The time at which the member requested to speak, or `null` if they did not. Only meaningful in stage channels.\n */\n public get requestToSpeakAt(): Date | null {\n const timestamp = this.optimizedTimestamp(\"request_to_speak_timestamp\");\n return timestamp === null ? null : new Date(timestamp);\n }\n\n /**\n * Whether the member is deafened, either by themselves or server-wide.\n */\n public override get deaf() {\n return this.serverDeaf || this.selfDeaf;\n }\n\n /**\n * Whether the member is muted, either by themselves or server-wide.\n */\n public override get mute() {\n return this.serverMute || this.selfMute;\n }\n\n /**\n * The member, from the payload or the cache. `null` when neither has it, or when the voice state was not built by a\n * manager.\n */\n public get member(): GuildMember | null {\n return this[kRelations].member ?? null;\n }\n\n /**\n * The guild, from the cache.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * The channel the member is connected to, from the cache, like discord.js's `VoiceState#channel`. `null` when they\n * are disconnected, when the channel is not cached, or when the voice state was not built by a manager.\n */\n public get channel(): AnyChannel | null {\n return this[kRelations].channel ?? null;\n }\n\n public fetchMember(): Promise<GuildMember> {\n return this.client.members.fetch(this.requireGuildId(), this.userId);\n }\n\n public fetchUser(): Promise<User> {\n return this.client.users.fetch(this.userId);\n }\n\n /**\n * Fetches the channel the member is connected to, `null` when they are disconnected.\n */\n public async fetchChannel(): Promise<AnyChannel | null> {\n const { channelId } = this;\n return channelId ? this.client.channels.fetch(channelId) : null;\n }\n\n /**\n * Fetches the voice state from the API, and patches this structure with the result.\n */\n public async fetch(): Promise<this> {\n const state = await this.client.voiceStates.fetch(this.requireGuildId(), this.userId, {\n force: true,\n });\n return this[kPatch](state.toJSON());\n }\n\n /**\n * Mutes or unmutes the member server-wide.\n */\n public setMute(mute = true, reason?: string): Promise<GuildMember> {\n return this.client.members.edit(this.requireGuildId(), this.userId, { mute, reason });\n }\n\n /**\n * Deafens or undeafens the member server-wide.\n */\n public setDeaf(deaf = true, reason?: string): Promise<GuildMember> {\n return this.client.members.edit(this.requireGuildId(), this.userId, { deaf, reason });\n }\n\n /**\n * Moves the member to another voice channel, or disconnects them with `null`.\n */\n public setChannel(channel: string | null, reason?: string): Promise<GuildMember> {\n return this.client.members.edit(this.requireGuildId(), this.userId, {\n channel,\n reason,\n });\n }\n\n public disconnect(reason?: string): Promise<GuildMember> {\n return this.setChannel(null, reason);\n }\n\n /**\n * Edits the voice state in a stage channel.\n *\n * @param options Whether to request to speak (the bot only), and whether the member is suppressed.\n */\n public async edit(options: VoiceStateEditOptions): Promise<this> {\n const target = this.resolveTarget();\n if (target !== \"@me\" && options.requestToSpeak !== undefined) {\n throw new Error(\"Only the bot's own voice state can request to speak\");\n }\n\n const requestToSpeakTimestamp = options.requestToSpeak\n ? new Date().toISOString()\n : options.requestToSpeak === false\n ? null\n : undefined;\n const body = {\n channel_id: this.channelId ?? undefined,\n request_to_speak_timestamp: requestToSpeakTimestamp,\n suppress: options.suppressed,\n };\n if (target === \"@me\") {\n await this.client.api.voice.editVoiceState(this.requireGuildId(), body);\n } else {\n await this.client.api.voice.editUserVoiceState(this.requireGuildId(), target, body);\n }\n\n return this[kPatch]({\n ...(requestToSpeakTimestamp !== undefined && {\n request_to_speak_timestamp: requestToSpeakTimestamp,\n }),\n ...(options.suppressed !== undefined && { suppress: options.suppressed }),\n });\n }\n\n /**\n * Requests to speak in a stage channel, or withdraws the request. The bot's own voice state only.\n */\n public setRequestToSpeak(requestToSpeak = true): Promise<this> {\n return this.edit({ requestToSpeak });\n }\n\n /**\n * Moves the member to the audience of a stage channel, or invites them to speak.\n */\n public setSuppressed(suppressed = true): Promise<this> {\n return this.edit({ suppressed });\n }\n\n private requireGuildId(): string {\n const { guildId } = this;\n if (!guildId) throw new Error(\"This voice state does not belong to a guild\");\n return guildId;\n }\n\n // The bot's own voice state is addressed as `@me`, the only one allowed to request to speak.\n private resolveTarget(): string {\n const client = this.client;\n return (client.user?.id ?? client.id) === this.userId ? \"@me\" : this.userId;\n }\n}\n\nMixin(VoiceState, [StructureMixin]);\n","/**\n * Emitted as an `error` when a dispatch takes longer than `GatewayClientOptions.dispatchTimeout` to process.\n *\n * @remarks\n * The dispatch is not cancelled: it keeps running, and later dispatches of its partition keep waiting for it, so the\n * event order is preserved. The error only reports that the partition is stuck, usually on a slow or unreachable\n * cache.\n */\nexport class DispatchTimeoutError extends Error {\n /**\n * The type of the slow dispatch, e.g. `MESSAGE_CREATE`.\n */\n public readonly type: string;\n\n /**\n * The shard the dispatch was received on.\n */\n public readonly shardId: number;\n\n /**\n * The partition the dispatch runs in, `null` for a barrier.\n */\n public readonly partition: string | null;\n\n /**\n * The timeout that was exceeded, in milliseconds.\n */\n public readonly timeout: number;\n\n public constructor(type: string, shardId: number, partition: string | null, timeout: number) {\n super(\n `Processing ${type} on shard ${shardId} (${partition ?? \"barrier\"}) took longer than ${timeout}ms`,\n );\n this.name = \"DispatchTimeoutError\";\n this.type = type;\n this.shardId = shardId;\n this.partition = partition;\n this.timeout = timeout;\n }\n}\n\n/**\n * Thrown by `GuildMemberManager#request` when Discord stops sending the chunks of the requested members.\n *\n * @remarks\n * The request is dropped: chunks arriving later still update the cache and emit `guildMembersChunk`.\n */\nexport class GuildMembersTimeoutError extends Error {\n /**\n * The ID of the guild whose members were requested.\n */\n public readonly guildId: string;\n\n /**\n * The nonce of the request.\n */\n public readonly nonce: string;\n\n /**\n * The timeout that was exceeded, in milliseconds.\n */\n public readonly timeout: number;\n\n public constructor(guildId: string, nonce: string, timeout: number) {\n super(`Requesting the members of guild ${guildId} (${nonce}) took longer than ${timeout}ms`);\n this.name = \"GuildMembersTimeoutError\";\n this.guildId = guildId;\n this.nonce = nonce;\n this.timeout = timeout;\n }\n}\n\n/**\n * Thrown by `GuildMemberManager#request` when Discord answers with `RATE_LIMITED` instead of the members' chunks.\n */\nexport class GuildMembersRateLimitError extends Error {\n /**\n * The ID of the guild whose members were requested.\n */\n public readonly guildId: string;\n\n /**\n * The nonce of the request.\n */\n public readonly nonce: string;\n\n /**\n * How long to wait before requesting the members again, in milliseconds.\n */\n public readonly retryAfter: number;\n\n public constructor(guildId: string, nonce: string, retryAfter: number) {\n super(\n `Requesting the members of guild ${guildId} (${nonce}) is rate limited, retry after ${retryAfter}ms`,\n );\n this.name = \"GuildMembersRateLimitError\";\n this.guildId = guildId;\n this.nonce = nonce;\n this.retryAfter = retryAfter;\n }\n}\n\n/**\n * Emitted as an `error` when `GatewayClientOptions.sessionStore` fails to read or write the session of a shard.\n *\n * @remarks\n * Neither failure stops the shard: a failed (or timed out) read identifies instead of resuming, and a failed write\n * only means the session may not be resumed after a restart. The store's error is the `cause`.\n */\nexport class GatewaySessionStoreError extends Error {\n /**\n * Whether the store failed to read (`\"get\"`) or write (`\"set\"`) the session.\n */\n public readonly operation: \"get\" | \"set\";\n\n /**\n * The shard whose session was read or written.\n */\n public readonly shardId: number;\n\n public constructor(operation: \"get\" | \"set\", shardId: number, cause: unknown) {\n super(\n `Cannot ${operation === \"get\" ? \"read\" : \"write\"} the session of shard ${shardId} in the session store`,\n { cause },\n );\n this.name = \"GatewaySessionStoreError\";\n this.operation = operation;\n this.shardId = shardId;\n }\n}\n","import { randomBytes } from \"node:crypto\";\nimport { memberKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n GatewayOpcodes,\n type APIGuildMember,\n type GatewayGuildMembersChunkDispatchData,\n type GatewayRateLimitedDispatchData,\n type GatewayRequestGuildMembersData,\n type RESTPatchAPICurrentGuildMemberJSONBody,\n type RESTPatchAPIGuildMemberJSONBody,\n type RESTPostAPIGuildBulkBanJSONBody,\n type RESTPutAPIGuildBanJSONBody,\n type RESTPutAPIGuildMemberJSONBody,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { GuildMember, type GuildMemberRelations } from \"../structures/guilds/GuildMember.js\";\nimport { Presence } from \"../structures/presences/Presence.js\";\nimport { bindClient } from \"../structures/Structure.js\";\nimport { VoiceState } from \"../structures/voice/VoiceState.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { GuildMembersRateLimitError, GuildMembersTimeoutError } from \"../util/errors.js\";\nimport { GuildMemberFlagsBitField, type GuildMemberFlagsResolvable } from \"../util/flags.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\n\n/**\n * The options to edit a member with.\n */\nexport interface GuildMemberEditOptions {\n /**\n * The nickname, `null` to reset it.\n */\n nick?: string | null;\n /**\n * The IDs of the roles the member ends up with.\n */\n roles?: readonly string[];\n mute?: boolean;\n deaf?: boolean;\n /**\n * The voice channel to move the member to, `null` to disconnect them.\n */\n channel?: string | null;\n /**\n * When the timeout ends, `null` to lift it.\n */\n communicationDisabledUntil?: Date | number | null;\n flags?: GuildMemberFlagsResolvable;\n /**\n * The reason for the audit log.\n */\n reason?: string;\n}\n\n/**\n * The options to edit the bot's own member with. Images are data URIs, `null` removes them.\n */\nexport interface GuildMemberEditMeOptions {\n nick?: string | null;\n avatar?: string | null;\n banner?: string | null;\n bio?: string | null;\n reason?: string;\n}\n\n/**\n * The options to add a user to a guild with, through an OAuth2 access token with the `guilds.join` scope.\n */\nexport interface GuildMemberAddOptions {\n accessToken: string;\n nick?: string;\n roles?: readonly string[];\n mute?: boolean;\n deaf?: boolean;\n}\n\n/**\n * The options to ban users with.\n */\nexport interface BanOptions {\n /**\n * How many seconds of the users' messages to delete, up to 7 days.\n */\n deleteMessageSeconds?: number;\n reason?: string;\n}\n\n/**\n * The options to prune the inactive members of a guild with.\n */\nexport interface GuildPruneOptions {\n /**\n * How many days of inactivity make a member prunable.\n *\n * @default 7\n */\n days?: number;\n /**\n * The roles whose members are also prunable; members with roles are kept otherwise.\n */\n roles?: readonly string[];\n /**\n * Whether to only count the members that would be pruned.\n *\n * @default false\n */\n dry?: boolean;\n /**\n * Whether to return the count; turning it off is recommended for large guilds.\n *\n * @default true\n */\n count?: boolean;\n reason?: string;\n}\n\n/**\n * The options to request the members of a guild over the gateway with. Without `query` nor `userIds`, every member is\n * requested.\n */\nexport interface GuildMembersRequestOptions {\n /**\n * The prefix of the usernames and nicknames to match, `\"\"` for every member. Exclusive with `userIds`.\n *\n * @default \"\"\n */\n query?: string;\n /**\n * How many members to match with `query`, `0` for no limit (only with an empty `query`).\n *\n * @default 0\n */\n limit?: number;\n /**\n * The IDs of the users to request, up to 100. Exclusive with `query`. The ones that are not members are left out of\n * the result, and listed in the `not_found` of the `guildMembersChunk` data. An empty array is ignored, like omitting\n * it.\n */\n userIds?: readonly string[];\n /**\n * Whether to also receive (and cache) the members' presences. Needs the `GuildPresences` intent.\n *\n * @default false\n */\n presences?: boolean;\n /**\n * The nonce identifying the request's chunks, up to 32 bytes.\n *\n * @default A random one.\n */\n nonce?: string;\n /**\n * How long to wait for each chunk, in milliseconds, before rejecting with a `GuildMembersTimeoutError`.\n *\n * @default 120_000\n */\n time?: number;\n}\n\ninterface MembersRequest {\n guildId: string;\n members: GuildMember[];\n received: number;\n timer: NodeJS.Timeout | null;\n resolve(members: GuildMember[]): void;\n reject(error: Error): void;\n}\n\n/**\n * Manages the {@link GuildMember}s known to the client.\n */\nexport class GuildMemberManager extends CachedManager<\n \"members\",\n GuildMember,\n [guildId: string, userId: string]\n> {\n // The pending `request`s, by nonce.\n readonly #requests = new Map<string, MembersRequest>();\n\n public constructor(client: GatewayClient) {\n super(client, \"members\");\n }\n\n public construct(data: CacheEntityTypes[\"members\"]): GuildMember {\n return new GuildMember(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"members\"]): string {\n if (!data.user) throw new TypeError(\"Cannot key a member without its user\");\n return this.resolveKey(data.guild_id, data.user.id);\n }\n\n /**\n * Adds a member to the cache, and its user to `client.users`.\n *\n * @internal\n */\n public override async _add(\n data: CacheEntityTypes[\"members\"],\n cache = true,\n options?: AddOptions,\n ): Promise<GuildMember> {\n if (data.user) await this.client.users._add(data.user, cache);\n return super._add(data, cache, options);\n }\n\n /**\n * Builds a member, resolving its user, guild, voice state, and presence from the cache.\n *\n * @remarks\n * The voice state and presence are built from their raw cache entries rather than by their managers, which resolve\n * their member in turn: their `member` is this very structure.\n *\n * @internal\n */\n public override _hydrate(data: CacheEntityTypes[\"members\"]): Awaitable<GuildMember> {\n const { client } = this;\n const key = data.user ? memberKey(data.guild_id, data.user.id) : null;\n return whenAll(\n [\n data.user ? client.users._resolveData(data.user) : undefined,\n this.cachedGuild(data.guild_id),\n key ? client.cache?.voiceStates?.get(key) : undefined,\n key ? client.cache?.presences?.get(key) : undefined,\n ],\n ([user, guild, voiceData, presenceData]) => {\n const relations: GuildMemberRelations = { user, guild };\n const member = bindClient(new GuildMember(data, relations), client);\n return whenAll(\n [voiceData?.channel_id ? client.channels._get(voiceData.channel_id) : undefined],\n ([channel]) => {\n // Only a cached relation is known to be absent, otherwise it stays unknown (`undefined`).\n if (key && client.cache?.voiceStates) {\n relations.voice = voiceData\n ? bindClient(\n new VoiceState(voiceData, { member, guild, channel: channel ?? null }),\n client,\n )\n : null;\n }\n if (key && client.cache?.presences) {\n relations.presence = presenceData\n ? bindClient(\n new Presence(presenceData, { user: user ?? null, member, guild }),\n client,\n )\n : null;\n }\n\n return member;\n },\n );\n },\n );\n }\n\n public resolveKey(guildId: string, userId: string): string {\n return memberKey(guildId, userId);\n }\n\n /**\n * Fetches the bot's own member in a guild.\n *\n * @param guildId The ID of the guild.\n */\n public fetchMe(guildId: string): Promise<GuildMember> {\n return this.fetch(guildId, this.client.user?.id ?? this.client.id);\n }\n\n /**\n * Lists the members of a guild, in user ID order, and caches them.\n *\n * @param guildId The ID of the guild.\n * @param options How many members to list (up to 1000), and after which user ID.\n */\n public async list(\n guildId: string,\n options: { limit?: number; after?: string } = {},\n ): Promise<GuildMember[]> {\n const members = await this.client.api.guilds.getMembers(guildId, {\n limit: options.limit ?? 1,\n after: options.after,\n });\n return Promise.all(members.map((member) => this.store(guildId, member)));\n }\n\n /**\n * Searches the members of a guild whose username or nickname starts with a query, and caches them.\n *\n * @param guildId The ID of the guild.\n * @param options The query, and how many members to return (up to 1000).\n */\n public async search(\n guildId: string,\n options: { query: string; limit?: number },\n ): Promise<GuildMember[]> {\n const members = await this.client.api.guilds.searchForMembers(guildId, {\n query: options.query,\n limit: options.limit ?? 1,\n });\n return Promise.all(members.map((member) => this.store(guildId, member)));\n }\n\n /**\n * Requests the members of a guild over the gateway, every one of them by default, and caches them. discord.js:\n * `guild.members.fetch()` without a user.\n *\n * @remarks\n * Unlike {@link GuildMemberManager.list}, it gets the members of a large guild in one go, in chunks of up to 1000\n * that are also emitted as `guildMembersChunk`. Requesting every member or a `query` needs the `GuildMembers`\n * intent. The request is sent on the guild's shard, which must be one this client runs.\n *\n * @param guildId The ID of the guild.\n * @param options Which members to request.\n * @returns The members, once the last chunk is cached.\n */\n public async request(\n guildId: string,\n options: GuildMembersRequestOptions = {},\n ): Promise<GuildMember[]> {\n const { query, limit = 0, presences, time = 120_000 } = options;\n // An empty list of IDs (e.g. built dynamically) requests nothing, so it falls back to the default like no list at all.\n const userIds = options.userIds?.length ? options.userIds : undefined;\n const nonce = options.nonce ?? randomBytes(16).toString(\"hex\");\n if (query !== undefined && userIds !== undefined) {\n throw new TypeError(\"Cannot request members by both query and userIds\");\n }\n if (userIds && userIds.length > 100) {\n throw new RangeError(\"Cannot request more than 100 members by their IDs\");\n }\n if (Buffer.byteLength(nonce) > 32) {\n throw new RangeError(\"The nonce of a members request cannot exceed 32 bytes\");\n }\n\n const d: GatewayRequestGuildMembersData = userIds\n ? { guild_id: guildId, user_ids: [...userIds], presences, nonce }\n : { guild_id: guildId, query: query ?? \"\", limit, presences, nonce };\n const shardCount = BigInt(await this.client.gateway.getShardCount());\n const shardId = Number((BigInt(guildId) >> 22n) % shardCount);\n\n // The nonce is the only link between the request and its chunks, so it must be unique while pending.\n if (this.#requests.has(nonce)) {\n throw new Error(`A members request with the nonce \"${nonce}\" is pending already`);\n }\n let request!: MembersRequest;\n const promise = new Promise<GuildMember[]>((resolve, reject) => {\n request = { guildId, members: [], received: 0, timer: null, resolve, reject };\n });\n this.#requests.set(nonce, request);\n\n try {\n // `@discordjs/ws` rate limits every shard's payloads on its own: `send` waits for the shard to be ready, then\n // queues the payload once 115 were sent in the current minute (Discord closes the connection past 120).\n await this.client.gateway.send(shardId, { op: GatewayOpcodes.RequestGuildMembers, d });\n } catch (error) {\n this.settle(nonce, request);\n throw error;\n }\n\n // The timeout starts once the request is sent, not while it waits for the shard or its rate limit.\n if (this.#requests.get(nonce) === request) {\n request.timer = setTimeout(() => {\n this.settle(nonce, request);\n request.reject(new GuildMembersTimeoutError(guildId, nonce, time));\n }, time);\n request.timer.unref?.();\n }\n return promise;\n }\n\n /**\n * Adds a cached chunk of members to the request with its nonce, resolving it with the last chunk.\n *\n * @internal\n */\n public handleChunk(members: GuildMember[], data: GatewayGuildMembersChunkDispatchData): void {\n const request = data.nonce === undefined ? undefined : this.#requests.get(data.nonce);\n if (!request || request.guildId !== data.guild_id) return;\n\n request.members.push(...members);\n request.timer?.refresh();\n // Chunks of a guild are processed in order, so the last one to arrive has `chunk_index === chunk_count - 1`.\n if (++request.received < data.chunk_count) return;\n\n this.settle(data.nonce!, request);\n request.resolve(request.members);\n }\n\n /**\n * Rejects the request a `RATE_LIMITED` dispatch refers to, which gets no chunks at all.\n *\n * @internal\n */\n public handleRateLimited(data: GatewayRateLimitedDispatchData): void {\n const nonce = data.meta.nonce;\n if (data.opcode !== GatewayOpcodes.RequestGuildMembers || nonce === undefined) return;\n\n const request = this.#requests.get(nonce);\n if (!request) return;\n\n this.settle(nonce, request);\n request.reject(new GuildMembersRateLimitError(request.guildId, nonce, data.retry_after * 1000));\n }\n\n /**\n * Adds a user to a guild, or fetches their member when they are in it already.\n *\n * @param guildId The ID of the guild.\n * @param userId The ID of the user.\n * @param options The access token and the member's initial state.\n */\n public async add(\n guildId: string,\n userId: string,\n options: GuildMemberAddOptions,\n ): Promise<GuildMember> {\n const body: RESTPutAPIGuildMemberJSONBody = {\n access_token: options.accessToken,\n nick: options.nick,\n roles: options.roles ? [...options.roles] : undefined,\n mute: options.mute,\n deaf: options.deaf,\n };\n // The API answers 204 without a body when the user already is a member.\n const member = await this.client.api.guilds.addMember(guildId, userId, body);\n return member ? this.store(guildId, member) : this.fetch(guildId, userId);\n }\n\n /**\n * Edits a member.\n *\n * @param guildId The ID of the guild.\n * @param userId The ID of the member's user.\n * @param options The fields to edit.\n */\n public async edit(\n guildId: string,\n userId: string,\n options: GuildMemberEditOptions,\n ): Promise<GuildMember> {\n const until = options.communicationDisabledUntil;\n const body: RESTPatchAPIGuildMemberJSONBody = {\n nick: options.nick,\n roles: options.roles ? [...options.roles] : undefined,\n mute: options.mute,\n deaf: options.deaf,\n channel_id: options.channel,\n communication_disabled_until:\n until === undefined || until === null ? until : new Date(until).toISOString(),\n flags:\n options.flags === undefined\n ? undefined\n : Number(GuildMemberFlagsBitField.resolve(options.flags)),\n };\n const member = await this.client.api.guilds.editMember(guildId, userId, body, {\n reason: options.reason,\n });\n return this.store(guildId, member);\n }\n\n /**\n * Edits the bot's own member.\n *\n * @param guildId The ID of the guild.\n * @param options The fields to edit.\n */\n public async editMe(guildId: string, options: GuildMemberEditMeOptions): Promise<GuildMember> {\n const { reason, ...body } = options;\n const member = await this.client.api.users.editCurrentGuildMember(\n guildId,\n body satisfies RESTPatchAPICurrentGuildMemberJSONBody,\n { reason },\n );\n return this.store(guildId, member);\n }\n\n /**\n * Kicks a member.\n *\n * @param guildId The ID of the guild.\n * @param userId The ID of the member's user.\n * @param reason The reason for the audit log.\n */\n public async kick(guildId: string, userId: string, reason?: string): Promise<void> {\n await this.client.api.guilds.removeMember(guildId, userId, { reason });\n await this.cache?.delete(this.resolveKey(guildId, userId));\n }\n\n /**\n * Bans a user, member or not.\n *\n * @param guildId The ID of the guild.\n * @param userId The ID of the user.\n * @param options How many seconds of messages to delete, and the reason for the audit log.\n */\n public async ban(guildId: string, userId: string, options: BanOptions = {}): Promise<void> {\n const body: RESTPutAPIGuildBanJSONBody = {\n delete_message_seconds: options.deleteMessageSeconds,\n };\n await this.client.api.guilds.banUser(guildId, userId, body, { reason: options.reason });\n await this.cache?.delete(this.resolveKey(guildId, userId));\n }\n\n /**\n * Lifts a user's ban.\n *\n * @param guildId The ID of the guild.\n * @param userId The ID of the user.\n * @param reason The reason for the audit log.\n */\n public async unban(guildId: string, userId: string, reason?: string): Promise<void> {\n await this.client.api.guilds.unbanUser(guildId, userId, { reason });\n }\n\n /**\n * Bans up to 200 users at once.\n *\n * @param guildId The ID of the guild.\n * @param userIds The IDs of the users.\n * @param options How many seconds of messages to delete, and the reason for the audit log.\n * @returns The users that were banned, and the ones that could not be.\n */\n public async bulkBan(\n guildId: string,\n userIds: readonly string[],\n options: BanOptions = {},\n ): Promise<{ bannedUsers: string[]; failedUsers: string[] }> {\n const body: RESTPostAPIGuildBulkBanJSONBody = {\n user_ids: [...userIds],\n delete_message_seconds: options.deleteMessageSeconds,\n };\n const result = await this.client.api.guilds.bulkBanUsers(guildId, body, {\n reason: options.reason,\n });\n await Promise.all(\n result.banned_users.map((userId) => this.cache?.delete(this.resolveKey(guildId, userId))),\n );\n return { bannedUsers: result.banned_users, failedUsers: result.failed_users };\n }\n\n /**\n * Prunes the inactive members of a guild, or counts them with `dry`.\n *\n * @param guildId The ID of the guild.\n * @param options The inactivity threshold and the roles to include.\n * @returns How many members were (or would be) pruned, `null` when `count` is `false`.\n */\n public async prune(guildId: string, options: GuildPruneOptions = {}): Promise<number | null> {\n const days = options.days ?? 7;\n if (options.dry) {\n const result = await this.client.api.guilds.getPruneCount(guildId, {\n days,\n include_roles: options.roles?.length ? options.roles.join(\",\") : undefined,\n });\n return result.pruned;\n }\n\n const result = await this.client.api.guilds.beginPrune(\n guildId,\n {\n days,\n compute_prune_count: options.count ?? true,\n include_roles: options.roles ? [...options.roles] : undefined,\n },\n { reason: options.reason },\n );\n return result.pruned;\n }\n\n /**\n * Adds a role to a member.\n *\n * @param guildId The ID of the guild.\n * @param userId The ID of the member's user.\n * @param roleId The ID of the role.\n * @param reason The reason for the audit log.\n */\n public async addRole(\n guildId: string,\n userId: string,\n roleId: string,\n reason?: string,\n ): Promise<void> {\n await this.client.api.guilds.addRoleToMember(guildId, userId, roleId, { reason });\n await this.updateCachedRoles(guildId, userId, (roles) => [...new Set([...roles, roleId])]);\n }\n\n /**\n * Removes a role from a member.\n *\n * @param guildId The ID of the guild.\n * @param userId The ID of the member's user.\n * @param roleId The ID of the role.\n * @param reason The reason for the audit log.\n */\n public async removeRole(\n guildId: string,\n userId: string,\n roleId: string,\n reason?: string,\n ): Promise<void> {\n await this.client.api.guilds.removeRoleFromMember(guildId, userId, roleId, { reason });\n await this.updateCachedRoles(guildId, userId, (roles) => roles.filter((id) => id !== roleId));\n }\n\n protected async fetchRaw(guildId: string, userId: string) {\n const member = await this.client.api.guilds.getMember(guildId, userId);\n return { ...member, guild_id: guildId };\n }\n\n // Members without their user cannot be keyed, so they are built without being cached.\n private store(guildId: string, member: APIGuildMember): Promise<GuildMember> {\n const raw = { ...member, guild_id: guildId };\n return raw.user ? this._add(raw) : this.hydrate(raw);\n }\n\n // Drops a request that resolved, was rejected, or timed out.\n private settle(nonce: string, request: MembersRequest): void {\n if (request.timer) clearTimeout(request.timer);\n this.#requests.delete(nonce);\n }\n\n // The role endpoints answer 204 without the member, so the cached entry is patched instead of refetched.\n private async updateCachedRoles(\n guildId: string,\n userId: string,\n update: (roles: readonly string[]) => string[],\n ): Promise<void> {\n const key = this.resolveKey(guildId, userId);\n const cached = await this.cache?.get(key);\n if (cached) await this.cache!.set(key, { ...cached, roles: update(cached.roles) });\n }\n}\n","import type { ReactionType } from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { type User } from \"../structures/users/User.js\";\n\n/**\n * Manages the users who reacted to a message with one emoji.\n */\nexport class ReactionUserManager {\n public readonly client: GatewayClient;\n public readonly channelId: string;\n public readonly messageId: string;\n /**\n * The emoji, as the identifier reaction routes expect (`name:id` or the encoded Unicode emoji).\n */\n public readonly emoji: string;\n\n public constructor(client: GatewayClient, channelId: string, messageId: string, emoji: string) {\n this.client = client;\n this.channelId = channelId;\n this.messageId = messageId;\n this.emoji = emoji;\n }\n\n /**\n * Fetches the users who reacted, paginated by user ID, and caches them.\n *\n * @param options How many users to fetch (up to 100), after which user ID, and which kind of reaction.\n */\n public async fetch(\n options: { limit?: number; after?: string; type?: ReactionType } = {},\n ): Promise<User[]> {\n const users = await this.client.api.channels.getMessageReactions(\n this.channelId,\n this.messageId,\n this.emoji,\n { limit: options.limit ?? 100, after: options.after, type: options.type },\n );\n return Promise.all(users.map((user) => this.client.users._add(user)));\n }\n\n /**\n * Removes a user's reaction, the bot's by default.\n *\n * @param userId The ID of the user, `\"@me\"` for the bot.\n */\n public async remove(userId = \"@me\"): Promise<void> {\n if (userId === \"@me\" || userId === this.client.user?.id) {\n await this.client.api.channels.deleteOwnMessageReaction(\n this.channelId,\n this.messageId,\n this.emoji,\n );\n } else {\n await this.client.api.channels.deleteUserMessageReaction(\n this.channelId,\n this.messageId,\n this.emoji,\n userId,\n );\n }\n }\n}\n","import { Reaction as BaseReaction, Structure as BaseStructure } from \"@discordjs/structures\";\nimport type { APIReaction } from \"discord-api-types/v10\";\nimport { ReactionUserManager } from \"../../managers/ReactionUserManager.js\";\nimport { ReactionEmoji } from \"../emojis/ReactionEmoji.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport type { GuildEmoji } from \"../emojis/GuildEmoji.js\";\nimport { initStructure, kData, kPatch, kRelations, StructureMixin } from \"../Structure.js\";\nimport type { Message } from \"./Message.js\";\n\n/**\n * The raw data of a reaction, with the message it belongs to. The counts are absent when the reaction was built from\n * a gateway event on a message the cache did not hold.\n */\nexport type MessageReactionData = Omit<APIReaction, \"count\" | \"count_details\"> &\n Partial<Pick<APIReaction, \"count\" | \"count_details\">> & {\n channel_id: string;\n message_id: string;\n };\n\n/**\n * The relations of a {@link MessageReaction}: its message, and its cached custom emoji.\n */\nexport interface MessageReactionRelations {\n message?: Message | null;\n /**\n * The cached custom emoji, when it belongs to the message's guild.\n */\n emoji?: GuildEmoji | null;\n}\n\nexport interface MessageReaction extends StructureMixin<\n MessageReactionData,\n MessageReactionRelations\n> {}\n\n/**\n * A reaction on a message, an emoji, how many users reacted with it, and whether the bot did: `@discordjs/structures`'\n * `Reaction`, with the message it belongs to, its users, and actions through the client.\n *\n * @remarks\n * The counts are omitted from `@discordjs/structures`' data type, since a reaction built from a gateway event on an\n * uncached message has none.\n */\nexport class MessageReaction extends BaseReaction<\"count\" | \"count_details\"> {\n /**\n * Keeps the raw `burst_colors`, which `@discordjs/structures` strips and re-serializes, so that\n * {@link MessageReaction.toJSON} returns the reaction as received.\n */\n public static override DataTemplate: Partial<APIReaction> = {};\n\n /**\n * @param data The raw reaction, with the message it belongs to.\n * @param relations The related structures, resolved from the cache.\n */\n public constructor(data: MessageReactionData, relations: MessageReactionRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n public get channelId() {\n return this[kData].channel_id;\n }\n\n public get messageId() {\n return this[kData].message_id;\n }\n\n /**\n * The message the reaction is on, like discord.js's `MessageReaction#message`: the message it was read from, else\n * the cached one. `null` when the message is not cached.\n */\n public get message(): Message | null {\n return this[kRelations].message ?? null;\n }\n\n /**\n * The emoji, like discord.js's `MessageReaction#emoji`: the cached custom emoji of the message's guild, else the\n * emoji of the payload.\n */\n public get emoji(): GuildEmoji | ReactionEmoji {\n return this[kRelations].emoji ?? this.reactionEmoji;\n }\n\n /**\n * The emoji as the payload describes it, which the reaction routes are keyed by.\n */\n private get reactionEmoji(): ReactionEmoji {\n return new ReactionEmoji(this[kData].emoji);\n }\n\n /**\n * How many users reacted, super reactions included; `null` when unknown.\n */\n /**\n * Whether the reaction is partial: its message is not cached, so its counts are unknown. Only its emoji and IDs are\n * reliable then, and {@link MessageReaction.fetch} completes it.\n */\n public get partial(): boolean {\n return this[kData].count === undefined;\n }\n\n public override get count(): number | null {\n return this[kData].count ?? null;\n }\n\n /**\n * How many normal and super (burst) reactions there are; `null` when unknown.\n */\n public get countDetails(): { normal: number; burst: number } | null {\n return this[kData].count_details ?? null;\n }\n\n /**\n * The colors of the super reaction animation, as numbers.\n */\n public override get burstColors(): number[] {\n // `@discordjs/structures` parses the raw `#rrggbb` strings with their leading hash, which yields `NaN`.\n return this[kData].burst_colors.map((color) => Number.parseInt(color.replace(/^#/, \"\"), 16));\n }\n\n /**\n * The users who reacted.\n */\n public get users(): ReactionUserManager {\n return new ReactionUserManager(\n this.client,\n this.channelId,\n this.messageId,\n this.reactionEmoji.identifier,\n );\n }\n\n /**\n * Reacts with this emoji as the bot.\n */\n public async react(): Promise<this> {\n await this.client.messages.react(this.channelId, this.messageId, this.reactionEmoji.identifier);\n return this[kPatch]({ me: true });\n }\n\n /**\n * Removes every reaction with this emoji.\n */\n public async remove(): Promise<this> {\n await this.client.messages.removeReactionEmoji(\n this.channelId,\n this.messageId,\n this.reactionEmoji.identifier,\n );\n return this;\n }\n\n /**\n * Fetches the message and patches this reaction with its current counts.\n */\n public async fetch(): Promise<this> {\n const message = await this.client.messages.fetch(this.channelId, this.messageId, {\n force: true,\n });\n const identifier = this.reactionEmoji.identifier;\n const current = message.reactions.cache.find(\n (reaction) => ReactionEmoji.resolveIdentifier(reaction.toJSON().emoji) === identifier,\n );\n return current\n ? this[kPatch](current.toJSON())\n : this[kPatch]({\n count: 0,\n count_details: { normal: 0, burst: 0 },\n me: false,\n me_burst: false,\n burst_colors: [],\n });\n }\n\n public valueOf(): string {\n const { id, name } = this[kData].emoji;\n return id ?? name ?? \"\";\n }\n\n /**\n * Transforms this reaction into its raw data, as received.\n *\n * @remarks\n * Typed as `@discordjs/structures`' `APIReaction`, but the counts are absent when they are unknown, and the data\n * carries the IDs of the channel and the message.\n */\n public override toJSON(): APIReaction {\n return BaseStructure.prototype.toJSON.call(this) as APIReaction;\n }\n}\n\nMixin(MessageReaction, [StructureMixin]);\n","import type { APIReaction } from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport type { GuildEmoji } from \"../structures/emojis/GuildEmoji.js\";\nimport type { Message } from \"../structures/messages/Message.js\";\nimport { bindClient } from \"../structures/Structure.js\";\nimport { MessageReaction } from \"../structures/messages/MessageReaction.js\";\nimport {\n ReactionEmoji,\n type EmojiIdentifierResolvable,\n} from \"../structures/emojis/ReactionEmoji.js\";\n\n/**\n * Manages the reactions of one message, as they were in the message's payload.\n */\nexport class ReactionManager {\n public readonly client: GatewayClient;\n public readonly channelId: string;\n public readonly messageId: string;\n\n readonly #reactions: readonly APIReaction[];\n\n readonly #message: Message | null;\n\n readonly #emojis: ReadonlyMap<string, GuildEmoji> | undefined;\n\n /**\n * @param client The client.\n * @param channelId The ID of the channel of the message.\n * @param messageId The ID of the message.\n * @param reactions The raw reactions of the message.\n * @param message The message, which its reactions refer to.\n * @param emojis The cached custom emojis of the reactions, by ID.\n */\n public constructor(\n client: GatewayClient,\n channelId: string,\n messageId: string,\n reactions: readonly APIReaction[],\n message: Message | null = null,\n emojis?: ReadonlyMap<string, GuildEmoji>,\n ) {\n this.client = client;\n this.channelId = channelId;\n this.messageId = messageId;\n this.#reactions = reactions;\n this.#message = message;\n this.#emojis = emojis;\n }\n\n /**\n * The reactions of the message.\n */\n public get cache(): MessageReaction[] {\n return this.#reactions.map((reaction) =>\n bindClient(\n new MessageReaction(\n { ...reaction, channel_id: this.channelId, message_id: this.messageId },\n {\n message: this.#message,\n emoji: (reaction.emoji.id && this.#emojis?.get(reaction.emoji.id)) || null,\n },\n ),\n this.client,\n ),\n );\n }\n\n /**\n * Finds the reaction with an emoji, if the message has it.\n *\n * @param emoji The emoji.\n */\n public resolve(emoji: EmojiIdentifierResolvable): MessageReaction | null {\n const identifier = ReactionEmoji.resolveIdentifier(emoji);\n return (\n this.cache.find(\n (reaction) => ReactionEmoji.resolveIdentifier(reaction.toJSON().emoji) === identifier,\n ) ?? null\n );\n }\n\n /**\n * Removes every reaction of the message.\n */\n public removeAll(): Promise<void> {\n return this.client.messages.removeAllReactions(this.channelId, this.messageId);\n }\n}\n","/**\n * Compares two JSON-like values structurally, regardless of key order. `undefined` properties count as missing, like\n * they do once serialized.\n *\n * @param a The first value.\n * @param b The second value.\n */\nexport function isDeepEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n if (typeof a !== \"object\" || typeof b !== \"object\" || a === null || b === null) return false;\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n\n if (Array.isArray(a)) {\n const other = b as unknown[];\n return a.length === other.length && a.every((value, index) => isDeepEqual(value, other[index]));\n }\n\n const left = definedEntries(a as Record<string, unknown>);\n const right = new Map(definedEntries(b as Record<string, unknown>));\n return (\n left.length === right.size &&\n left.every(([key, value]) => right.has(key) && isDeepEqual(value, right.get(key)))\n );\n}\n\nfunction definedEntries(value: Record<string, unknown>): [string, unknown][] {\n return Object.entries(value).filter(([, entry]) => entry !== undefined);\n}\n","import { Attachment as BaseAttachment } from \"@discordjs/structures\";\nimport type { APIAttachment } from \"discord-api-types/v10\";\nimport { AttachmentFlagsBitField } from \"../../util/flags.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, snowflakeTimestamp, StructureMixin } from \"../Structure.js\";\n\nexport interface Attachment extends StructureMixin<APIAttachment> {}\n\n/**\n * A file attached to a message: `@discordjs/structures`' `Attachment`, with discord.js' aliases and helpers.\n */\nexport class Attachment extends BaseAttachment {\n /**\n * @param data The raw attachment.\n * @param relations The related structures, resolved from the cache.\n */\n public constructor(data: APIAttachment, relations: object = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n /**\n * The name of the file.\n */\n public get name() {\n return this.filename;\n }\n\n /**\n * Whether the attachment is ephemeral: it is deleted shortly after the message is, unless referenced elsewhere.\n */\n public override get ephemeral(): boolean {\n return this[kData].ephemeral ?? false;\n }\n\n /**\n * The duration of a voice message, in seconds.\n */\n public get duration(): number | null {\n return this[kData].duration_secs ?? null;\n }\n\n public override get flags(): Readonly<AttachmentFlagsBitField> {\n return new AttachmentFlagsBitField(this[kData].flags ?? 0).freeze();\n }\n\n /**\n * Whether the attachment is marked as a spoiler.\n */\n public get spoiler(): boolean {\n return this.flags.has(\"IsSpoiler\");\n }\n\n public get createdTimestamp() {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n}\n\nMixin(Attachment, [StructureMixin]);\n","import { Embed as BaseEmbed, Structure as BaseStructure } from \"@discordjs/structures\";\nimport type {\n APIEmbed,\n APIEmbedAuthor,\n APIEmbedField,\n APIEmbedFooter,\n APIEmbedImage,\n APIEmbedProvider,\n APIEmbedThumbnail,\n APIEmbedVideo,\n} from \"discord-api-types/v10\";\nimport { isDeepEqual } from \"../../util/equal.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, StructureMixin } from \"../Structure.js\";\n\nexport interface Embed extends StructureMixin<APIEmbed> {}\n\n/**\n * An embed of a received message: `@discordjs/structures`' `Embed`, with its nested parts and discord.js' helpers.\n * Use `@discordjs/builders`' `EmbedBuilder` to create embeds.\n */\nexport class Embed extends BaseEmbed<\"\"> {\n /**\n * Keeps the raw `timestamp`, which `@discordjs/structures` strips and re-serializes in its own format, so that\n * {@link Embed.toJSON} returns the embed as received.\n */\n public static override readonly DataTemplate: Partial<APIEmbed> = {};\n\n /**\n * @param data The raw embed.\n * @param relations The related structures, resolved from the cache.\n */\n public constructor(data: APIEmbed, relations: object = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n /**\n * The color as a `#rrggbb` string, `undefined` when the embed has none.\n */\n public override get hexColor(): `#${string}` | undefined {\n const { color } = this;\n return color === undefined ? undefined : `#${color.toString(16).padStart(6, \"0\")}`;\n }\n\n public get fields(): readonly APIEmbedField[] {\n return this[kData].fields ?? [];\n }\n\n public get thumbnail(): APIEmbedThumbnail | null {\n return this[kData].thumbnail ?? null;\n }\n\n public get image(): APIEmbedImage | null {\n return this[kData].image ?? null;\n }\n\n public get video(): APIEmbedVideo | null {\n return this[kData].video ?? null;\n }\n\n public get author(): APIEmbedAuthor | null {\n return this[kData].author ?? null;\n }\n\n public get provider(): APIEmbedProvider | null {\n return this[kData].provider ?? null;\n }\n\n public get footer(): APIEmbedFooter | null {\n return this[kData].footer ?? null;\n }\n\n /**\n * The number of characters counting towards Discord's 6000 characters limit.\n */\n public get length(): number {\n return (\n (this.title?.length ?? 0) +\n (this.description?.length ?? 0) +\n this.fields.reduce((sum, field) => sum + field.name.length + field.value.length, 0) +\n (this.footer?.text.length ?? 0) +\n (this.author?.name.length ?? 0)\n );\n }\n\n /**\n * Whether this embed has the same data as another one.\n * @param embed The embed, or raw embed data, to compare with.\n */\n public equals(embed: Embed | APIEmbed): boolean {\n return isDeepEqual(this.toJSON(), embed instanceof Embed ? embed.toJSON() : embed);\n }\n\n public override toJSON(): APIEmbed {\n return BaseStructure.prototype.toJSON.call(this) as APIEmbed;\n }\n}\n\nMixin(Embed, [StructureMixin]);\n","import type { APIChannelMention, APIGuildMember, APIMessage, APIUser } from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport { GuildMember } from \"../guilds/GuildMember.js\";\nimport type { Role } from \"../guilds/Role.js\";\nimport { User } from \"../users/User.js\";\nimport { pickCached as pick } from \"../../util/cache.js\";\n\n/**\n * The mentioned entities, resolved from the cache by `client.messages`, each by ID.\n */\nexport interface MessageMentionsRelations {\n /**\n * The mentioned users and the ones parsed from the content, and the author of the replied message.\n */\n users?: ReadonlyMap<string, User>;\n members?: ReadonlyMap<string, GuildMember>;\n roles?: ReadonlyMap<string, Role>;\n /**\n * The channels mentioned in the content.\n */\n channels?: ReadonlyMap<string, AnyChannel>;\n guild?: Guild | null;\n}\n\n/**\n * The raw fields of a message the mentions are read from.\n */\nexport type MessageMentionsData = Pick<\n APIMessage,\n \"content\" | \"mention_everyone\" | \"mention_roles\"\n> &\n Partial<Pick<APIMessage, \"mention_channels\" | \"referenced_message\">> & {\n guild_id?: string;\n /**\n * The mentioned users. In guilds, the gateway attaches each one's partial member.\n */\n mentions: (APIUser & { member?: Omit<APIGuildMember, \"user\"> })[];\n };\n\n/**\n * The options of {@link MessageMentions.has}.\n */\nexport interface MentionsHasOptions {\n /**\n * Whether to ignore direct mentions of the user, role, or channel.\n */\n ignoreDirect?: boolean;\n /**\n * Whether to ignore mentions of the member's roles.\n */\n ignoreRoles?: boolean;\n /**\n * Whether to ignore the author of the replied message.\n */\n ignoreRepliedUser?: boolean;\n /**\n * Whether to ignore `@everyone` and `@here`.\n */\n ignoreEveryone?: boolean;\n}\n\n/**\n * The users, roles, and channels a message mentions.\n *\n * @remarks\n * Users and members come with the message payload, and are replaced by their cached copies when the message was built\n * by `client.messages`, which also resolves the mentioned roles and channels from the cache, like discord.js.\n */\nexport class MessageMentions {\n /**\n * Matches `@everyone` and `@here`.\n */\n public static readonly EveryonePattern = /@(?<mention>everyone|here)/;\n\n /**\n * Matches user mentions, `<@id>` and the legacy `<@!id>`.\n */\n public static readonly UsersPattern = /<@!?(?<id>\\d{17,20})>/g;\n\n /**\n * Matches role mentions, `<@&id>`.\n */\n public static readonly RolesPattern = /<@&(?<id>\\d{17,20})>/g;\n\n /**\n * Matches channel mentions, `<#id>`.\n */\n public static readonly ChannelsPattern = /<#(?<id>\\d{17,20})>/g;\n\n readonly #data: MessageMentionsData;\n\n readonly #relations: MessageMentionsRelations;\n\n /**\n * @param data The raw fields of the message.\n * @param relations The mentioned entities, as resolved from the cache.\n */\n public constructor(data: MessageMentionsData, relations: MessageMentionsRelations = {}) {\n this.#data = data;\n this.#relations = relations;\n }\n\n /**\n * The guild of the message, from the cache, like discord.js's `MessageMentions#guild`.\n */\n public get guild(): Guild | null {\n return this.#relations.guild ?? null;\n }\n\n /**\n * The cached roles the message mentions, by ID, like discord.js's `MessageMentions#roles`.\n */\n public get roles(): Map<string, Role> {\n return pick(this.#data.mention_roles, this.#relations.roles);\n }\n\n /**\n * The cached channels the content mentions, by ID, like discord.js's `MessageMentions#channels`.\n */\n public get channels(): Map<string, AnyChannel> {\n return pick(this.parsedChannelIds, this.#relations.channels);\n }\n\n /**\n * The cached users the content mentions, by ID, like discord.js's `MessageMentions#parsedUsers`, which also\n * counts the users the message does not ping.\n */\n public get parsedUsers(): Map<string, User> {\n return pick(this.parsedUserIds, this.#relations.users);\n }\n\n /**\n * Whether the message mentions `@everyone` or `@here`.\n */\n public get everyone(): boolean {\n return this.#data.mention_everyone;\n }\n\n /**\n * The mentioned users: their cached copies, else the payload's.\n */\n public get users(): User[] {\n const cached = this.#relations.users;\n return this.#data.mentions.map((user) => cached?.get(user.id) ?? new User(user));\n }\n\n /**\n * The mentioned users as members, for messages sent in a guild.\n */\n public get members(): GuildMember[] {\n const guildId = this.#data.guild_id;\n if (!guildId) return [];\n\n const cached = this.#relations.members;\n return this.#data.mentions.flatMap(({ member, ...user }) => {\n if (!member) return [];\n return [cached?.get(user.id) ?? new GuildMember({ ...member, user, guild_id: guildId })];\n });\n }\n\n public get roleIds(): readonly string[] {\n return this.#data.mention_roles;\n }\n\n /**\n * The IDs of the channels mentioned in the content, and of the crossposted channels.\n */\n public get channelIds(): string[] {\n return [\n ...new Set([\n ...this.crosspostedChannels.map((channel) => channel.id),\n ...this.parsedChannelIds,\n ]),\n ];\n }\n\n /**\n * The IDs of the channels mentioned in the content.\n */\n public get parsedChannelIds(): string[] {\n return MessageMentions.parseIds(this.#data.content, MessageMentions.ChannelsPattern);\n }\n\n /**\n * The channels a crossposted message mentions, from other guilds.\n */\n public get crosspostedChannels(): readonly APIChannelMention[] {\n return this.#data.mention_channels ?? [];\n }\n\n /**\n * The author of the message this one replies to, if any.\n */\n public get repliedUser(): User | null {\n const author = this.#data.referenced_message?.author;\n return author ? (this.#relations.users?.get(author.id) ?? new User(author)) : null;\n }\n\n /**\n * The IDs of the users mentioned in the content, including the ones Discord did not resolve.\n */\n public get parsedUserIds(): string[] {\n return MessageMentions.parseIds(this.#data.content, MessageMentions.UsersPattern);\n }\n\n /**\n * Lists the unique IDs a mention pattern matches in a content.\n *\n * @param content The content.\n * @param pattern One of the global mention patterns, e.g. {@link MessageMentions.ChannelsPattern}.\n */\n public static parseIds(content: string, pattern: RegExp): string[] {\n return [...new Set([...content.matchAll(pattern)].map((match) => match.groups!.id!))];\n }\n\n /**\n * Whether the message mentions a user, member, role, or channel.\n *\n * @param target The ID, or a structure with an `id` (and `roleIds` for members).\n * @param options What kinds of mentions to ignore.\n */\n public has(\n target: string | { id: string | null; roleIds?: readonly string[] },\n options: MentionsHasOptions = {},\n ): boolean {\n const id = typeof target === \"string\" ? target : target.id;\n if (!id) return false;\n\n if (!options.ignoreEveryone && this.everyone) return true;\n if (!options.ignoreRepliedUser && this.repliedUser?.id === id) return true;\n\n if (!options.ignoreDirect) {\n if (this.#data.mentions.some((user) => user.id === id)) return true;\n if (this.roleIds.includes(id)) return true;\n if (this.channelIds.includes(id)) return true;\n }\n\n if (!options.ignoreRoles && typeof target !== \"string\" && target.roleIds) {\n return target.roleIds.some((roleId) => this.roleIds.includes(roleId));\n }\n\n return false;\n }\n}\n","import { PollAnswer as BasePollAnswer } from \"@discordjs/structures\";\nimport type { APIPollAnswer } from \"discord-api-types/v10\";\nimport { ReactionEmoji } from \"../emojis/ReactionEmoji.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport type { GuildEmoji } from \"../emojis/GuildEmoji.js\";\nimport { initStructure, kData, kRelations, StructureMixin } from \"../Structure.js\";\nimport type { Poll } from \"./Poll.js\";\nimport type { User } from \"../users/User.js\";\n\n/**\n * The raw data of a poll answer, with its vote count from the poll's results and the message it belongs to.\n */\nexport type PollAnswerData = APIPollAnswer & {\n channel_id: string;\n message_id: string;\n /**\n * The vote count from the poll's results, absent when Discord did not send them.\n */\n count?: number;\n me_voted?: boolean;\n};\n\n/**\n * The relations of a {@link PollAnswer}: its poll, and its cached custom emoji.\n */\nexport interface PollAnswerRelations {\n poll?: Poll | null;\n emoji?: GuildEmoji | null;\n}\n\nexport interface PollAnswer extends StructureMixin<PollAnswerData, PollAnswerRelations> {}\n\n/**\n * An answer of a {@link Poll}: `@discordjs/structures`' `PollAnswer`, with its vote count and the message it belongs to.\n */\nexport class PollAnswer extends BasePollAnswer {\n /**\n * @param data The raw answer, with its vote count and the message it belongs to.\n * @param relations The related structures, resolved from the cache.\n */\n public constructor(data: PollAnswerData, relations: PollAnswerRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n /**\n * The ID of the answer, an alias of `answerId`.\n */\n public get id() {\n return this.answerId;\n }\n\n public get channelId() {\n return this[kData].channel_id;\n }\n\n public get messageId() {\n return this[kData].message_id;\n }\n\n public get text(): string | null {\n return this[kData].poll_media?.text ?? null;\n }\n\n /**\n * Whether the answer is partial: its message is not cached, so only its ID is known, see `Partials.PollAnswer`.\n * Fetch its poll to complete it.\n */\n public get partial(): boolean {\n return (\n this[kData].poll_media?.text === undefined && this[kData].poll_media?.emoji === undefined\n );\n }\n\n /**\n * The poll the answer belongs to, like discord.js's `PollAnswer#poll`: `null` when the answer was not read from a\n * poll.\n */\n public get poll(): Poll | null {\n return this[kRelations].poll ?? null;\n }\n\n /**\n * The emoji of the answer, like discord.js's `PollAnswer#emoji`: the cached custom emoji of the message's guild,\n * else the payload's.\n */\n public get emoji(): GuildEmoji | ReactionEmoji | null {\n const { emoji } = this[kData].poll_media ?? {};\n return this[kRelations].emoji ?? (emoji?.id || emoji?.name ? new ReactionEmoji(emoji) : null);\n }\n\n /**\n * How many users voted for the answer, `0` when the results are unknown.\n */\n public get voteCount(): number {\n return this[kData].count ?? 0;\n }\n\n /**\n * Whether the bot voted for the answer.\n */\n public get meVoted(): boolean {\n return this[kData].me_voted ?? false;\n }\n\n /**\n * Fetches the users who voted for the answer, paginated by user ID.\n *\n * @param options How many voters to fetch (up to 100), and after which user ID.\n */\n public fetchVoters(options: { limit?: number; after?: string } = {}): Promise<User[]> {\n return this.client.messages.fetchPollAnswerVoters(\n this.channelId,\n this.messageId,\n this.id,\n options,\n );\n }\n}\n\nMixin(PollAnswer, [StructureMixin]);\n","import { Poll as BasePoll, Structure as BaseStructure } from \"@discordjs/structures\";\nimport type { APIPoll } from \"discord-api-types/v10\";\nimport type { Message } from \"../messages/Message.js\";\nimport { PollAnswer } from \"./PollAnswer.js\";\nimport { ReactionEmoji } from \"../emojis/ReactionEmoji.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { GuildEmoji } from \"../emojis/GuildEmoji.js\";\nimport {\n bindClient,\n initStructure,\n kData,\n kPatch,\n kRelations,\n StructureMixin,\n} from \"../Structure.js\";\n\n/**\n * The raw data of a poll, with the message it belongs to.\n */\nexport type PollData = APIPoll & { channel_id: string; message_id: string };\n\n/**\n * The relations of a {@link Poll}: the message it belongs to, and that message's channel and cached custom emojis.\n */\nexport interface PollRelations {\n message?: Message | null;\n channel?: AnyChannel | null;\n /**\n * The cached custom emojis of the answers, by ID, when they belong to the message's guild.\n */\n emojis?: ReadonlyMap<string, GuildEmoji>;\n}\n\nexport interface Poll extends StructureMixin<PollData, PollRelations> {}\n\n/**\n * The poll of a message: `@discordjs/structures`' `Poll`, with its answers, results, and the message it belongs to.\n */\nexport class Poll extends BasePoll<\"\"> {\n /**\n * Keeps the raw `expiry`, which `@discordjs/structures` strips and re-serializes in its own format, so that\n * {@link Poll.toJSON} returns the poll as received.\n */\n public static override DataTemplate: Partial<APIPoll> = {};\n\n /**\n * @param data The raw poll, with the message it belongs to.\n * @param relations The related structures, resolved from the cache.\n */\n public constructor(data: PollData, relations: PollRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n public get channelId() {\n return this[kData].channel_id;\n }\n\n public get messageId() {\n return this[kData].message_id;\n }\n\n /**\n * The message the poll belongs to, like discord.js's `Poll#message`: `null` when the poll was not read from a\n * message.\n */\n public get message(): Message | null {\n return this[kRelations].message ?? null;\n }\n\n /**\n * The channel of the poll's message, from the cache, like discord.js's `Poll#channel`.\n */\n public get channel(): AnyChannel | null {\n return this[kRelations].channel ?? null;\n }\n\n /**\n * Whether the poll is partial: built from its message's IDs alone for a vote on an uncached message, see\n * `Partials.Poll`. Only `channelId` and `messageId` are reliable then, and {@link Poll.fetch} completes it.\n */\n public get partial(): boolean {\n return this[kData].question === undefined;\n }\n\n /**\n * Fetches the poll's message from the API and patches this structure with its poll.\n */\n public async fetch(): Promise<this> {\n const message = await this.client.messages.fetch(this.channelId, this.messageId, {\n force: true,\n });\n const { poll } = message.toJSON();\n if (!poll) throw new Error(`Message ${this.messageId} has no poll`);\n return this[kPatch](poll as Partial<PollData>);\n }\n\n public get question(): { text: string | null; emoji: ReactionEmoji | null } {\n const { text, emoji } = this[kData].question ?? {};\n return { text: text ?? null, emoji: emoji ? new ReactionEmoji(emoji) : null };\n }\n\n /**\n * The answers, with their vote counts when Discord sent the results.\n */\n public get answers(): PollAnswer[] {\n const counts = new Map(\n (this[kData].results?.answer_counts ?? []).map((count) => [count.id, count]),\n );\n return (this[kData].answers ?? []).map((answer) => {\n const count = counts.get(answer.answer_id);\n const emojiId = answer.poll_media.emoji?.id;\n const relations = {\n poll: this,\n emoji: (emojiId && this[kRelations].emojis?.get(emojiId)) || null,\n };\n return bindClient(\n new PollAnswer(\n {\n ...answer,\n channel_id: this.channelId,\n message_id: this.messageId,\n count: count?.count,\n me_voted: count?.me_voted,\n },\n relations,\n ),\n this.client,\n );\n });\n }\n\n /**\n * Whether the votes are final, i.e. the poll ended and Discord counted them.\n */\n public get resultsFinalized(): boolean {\n return this[kData].results?.is_finalized ?? false;\n }\n\n /**\n * When the poll ends, `null` for polls that never do.\n */\n public get expiresAt(): Date | null {\n return this.expiresDate;\n }\n\n /**\n * Ends the poll now. Only the bot's own polls can be ended.\n *\n * @returns The message holding the ended poll.\n */\n public end(): Promise<Message> {\n return this.client.messages.endPoll(this.channelId, this.messageId);\n }\n\n public override toJSON(): PollData {\n return BaseStructure.prototype.toJSON.call(this) as PollData;\n }\n}\n\nMixin(Poll, [StructureMixin]);\n","import { Message as BaseMessage, Structure as BaseStructure } from \"@discordjs/structures\";\nimport type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n ChannelType,\n MessageFlags,\n MessageType,\n type APIMessage,\n type APIThreadChannel,\n} from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { MessageThreadCreateOptions } from \"../../managers/MessageManager.js\";\nimport { ReactionManager } from \"../../managers/ReactionManager.js\";\nimport type { AnyThreadChannel } from \"../../managers/ThreadManager.js\";\nimport { isDeepEqual } from \"../../util/equal.js\";\nimport { MessageFlagsBitField } from \"../../util/flags.js\";\nimport {\n MessagePayload,\n type MessageCreateOptions,\n type MessageEditOptions,\n type MessagePayloadResolvable,\n} from \"./MessagePayload.js\";\nimport type { PermissionsString } from \"../../util/PermissionsBitField.js\";\nimport { Attachment } from \"./Attachment.js\";\nimport { Embed } from \"./Embed.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport { GuildMember } from \"../guilds/GuildMember.js\";\nimport { MessageMentions, type MessageMentionsRelations } from \"./MessageMentions.js\";\nimport type { GuildEmoji } from \"../emojis/GuildEmoji.js\";\nimport { Poll } from \"../polls/Poll.js\";\nimport type { EmojiIdentifierResolvable } from \"../emojis/ReactionEmoji.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport {\n bindClient,\n initStructure,\n kData,\n kPatch,\n kRelations,\n snowflakeTimestamp,\n StructureMixin,\n} from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\nconst ZeroWidthSpace = String.fromCodePoint(0x20_0b);\n\n/**\n * The relations of a {@link Message}, resolved from the cache by `client.messages`.\n */\nexport interface MessageRelations {\n author?: User;\n /**\n * The author as a member, `null` outside of guilds.\n */\n member?: GuildMember | null;\n guild?: Guild | null;\n channel?: AnyChannel | null;\n /**\n * The thread started from the message, from the thread cache.\n */\n thread?: AnyThreadChannel | null;\n /**\n * The mentioned users, members, roles, and channels, from the cache.\n */\n mentions?: MessageMentionsRelations;\n /**\n * The cached custom emojis of the message's reactions and poll answers, by ID, when they belong to its guild.\n */\n emojis?: ReadonlyMap<string, GuildEmoji>;\n}\n\n// The message types a user can send; every other type is a system message.\nconst NonSystemTypes: readonly MessageType[] = [\n MessageType.Default,\n MessageType.Reply,\n MessageType.ChatInputCommand,\n MessageType.ContextMenuCommand,\n];\n\nexport interface Message extends StructureMixin<CacheEntityTypes[\"messages\"], MessageRelations> {}\n\n/**\n * A Discord message: `@discordjs/structures`' `Message`, with its relations, substructures, and actions through the\n * client.\n *\n * @remarks\n * Relations discord.js reads synchronously from its cache are asynchronous here: `fetchChannel()`, `fetchGuild()`,\n * `fetchReference()`, and the `fetch*able()` permission checks, which apply the channel's overwrites.\n */\nexport class Message extends BaseMessage<\"\"> {\n /**\n * Keeps the raw `timestamp` and `edited_timestamp`, which `@discordjs/structures` strips and re-serializes in its own\n * format, so that {@link Message.toJSON} returns the message as received.\n */\n public static override DataTemplate: Partial<APIMessage> = {};\n\n protected override optimizeData(data: Partial<CacheEntityTypes[\"messages\"]>): void {\n super.optimizeData(data);\n this.optimizeTimestamp(\"edited_timestamp\", data.edited_timestamp);\n }\n\n /**\n * @param data The raw message.\n * @param relations The author, member, guild, and channel as resolved from the cache, by `client.messages`.\n */\n public constructor(data: CacheEntityTypes[\"messages\"], relations: MessageRelations = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n public [kPatch](data: Readonly<Partial<CacheEntityTypes[\"messages\"]>>): this {\n // A payload carrying the author is fresher than the one resolved when the message was built.\n if (data.author) this.dropRelations(\"author\", \"member\");\n else if (data.member) this.dropRelations(\"member\");\n if (data.content !== undefined || data.mentions || data.mention_roles) {\n this.dropRelations(\"mentions\");\n }\n\n if (data.reactions || data.poll) this.dropRelations(\"emojis\");\n if (\"thread\" in data) this.dropRelations(\"thread\");\n return StructureMixin.prototype[kPatch].call(this, data) as this;\n }\n\n public get guildId(): string | null {\n return this[kData].guild_id ?? null;\n }\n\n /**\n * Whether the message was sent by Discord, e.g. a member join or a pin notice.\n */\n public get system(): boolean {\n return !NonSystemTypes.includes(this.type);\n }\n\n /**\n * The author. Resolved from `client.users` when the message comes from a manager, so it has the latest known data of\n * the user, not only the copy embedded in the message.\n */\n public get author(): User {\n // Only a partial message lacks its author: it gets an empty user rather than a crash.\n return this[kRelations].author ?? new User(this[kData].author ?? ({} as never));\n }\n\n /**\n * The author as a guild member, or `null` for messages sent outside of a guild or by a webhook.\n */\n public get member(): GuildMember | null {\n const { member: resolved } = this[kRelations];\n if (resolved !== undefined) return resolved;\n const { member, guild_id: guildId, author } = this[kData];\n return member && guildId\n ? new GuildMember({ ...member, user: author, guild_id: guildId })\n : null;\n }\n\n /**\n * The guild the message was sent in, from the cache. `null` outside of guilds, when the guild is not cached, or when\n * the message was not built by a manager: use {@link Message.fetchGuild} to always get it.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * The channel the message was sent in, from the cache. `null` when the channel is not cached, or when the message\n * was not built by a manager: use {@link Message.fetchChannel} to always get it.\n */\n public get channel(): AnyChannel | null {\n return this[kRelations].channel ?? null;\n }\n\n public override get flags(): Readonly<MessageFlagsBitField> {\n return new MessageFlagsBitField(this[kData].flags ?? 0).freeze();\n }\n\n public get attachments(): Attachment[] {\n return (this[kData].attachments ?? []).map((attachment) => new Attachment(attachment));\n }\n\n public get embeds(): Embed[] {\n return (this[kData].embeds ?? []).map((embed) => new Embed(embed));\n }\n\n /**\n * The raw components of the message. Build components with `@discordjs/builders`.\n */\n public get components() {\n return this[kData].components ?? [];\n }\n\n /**\n * The raw sticker items of the message; fetch a full sticker with `client.fetchSticker(id)`.\n */\n public get stickers() {\n return this[kData].sticker_items ?? [];\n }\n\n /**\n * The users, members, roles, and channels the message mentions: their cached copies when the message was built by\n * `client.messages`, like discord.js.\n */\n public get mentions(): MessageMentions {\n return new MessageMentions(this[kData], {\n guild: this.guild,\n ...this[kRelations].mentions,\n });\n }\n\n /**\n * The reactions of the message, whose `message` is this one, and whose custom emojis are the cached ones.\n */\n public get reactions(): ReactionManager {\n return new ReactionManager(\n this.client,\n this.channelId,\n this.id,\n this[kData].reactions ?? [],\n this,\n this[kRelations].emojis,\n );\n }\n\n /**\n * The poll of the message, whose `message` is this one.\n */\n public get poll(): Poll | null {\n const { poll } = this[kData];\n if (!poll) return null;\n return bindClient(\n new Poll(\n { ...poll, channel_id: this.channelId, message_id: this.id },\n { message: this, channel: this.channel, emojis: this[kRelations].emojis },\n ),\n this.client,\n );\n }\n\n /**\n * The reference of a reply, crosspost, forward, or pin notice, if any.\n */\n public get reference() {\n return this[kData].message_reference ?? null;\n }\n\n /**\n * The snapshots of the messages this one forwards.\n */\n public get messageSnapshots() {\n return this[kData].message_snapshots ?? [];\n }\n\n /**\n * The rich presence activity the message was sent with, e.g. a game invite.\n */\n public get activity() {\n return this[kData].activity ?? null;\n }\n\n /**\n * The metadata of the interaction the message answers, if any.\n */\n public get interactionMetadata() {\n return this[kData].interaction_metadata ?? null;\n }\n\n /**\n * The call a call message is about.\n */\n public get call() {\n return this[kData].call ?? null;\n }\n\n /**\n * The subscription a role subscription purchase message is about.\n */\n public get roleSubscriptionData() {\n return this[kData].role_subscription_data ?? null;\n }\n\n /**\n * Whether a thread was started from the message.\n */\n public get hasThread(): boolean {\n return this.flags.has(MessageFlags.HasThread);\n }\n\n /**\n * The thread started from the message, like discord.js's `Message#thread`: the cached thread (its ID is the\n * message's), else the one of the payload.\n */\n public get thread(): AnyThreadChannel | null {\n const resolved = this[kRelations].thread;\n if (resolved) return resolved;\n const { thread } = this[kData] as APIMessage & { thread?: APIThreadChannel };\n return thread ? this.client.threads.construct(thread) : null;\n }\n\n /**\n * The content with user, role, and channel mentions replaced by names, and `@everyone`/`@here` defused, like\n * discord.js's `Message#cleanContent`. Mentions of entities that are not cached are kept.\n */\n public get cleanContent(): string {\n const { mentions } = this;\n const members = new Map(\n mentions.members.map((member) => [member.id, member.displayName] as const),\n );\n const users = new Map(\n [...mentions.users, ...mentions.parsedUsers.values()].map(\n (user) => [user.id, user.displayName] as const,\n ),\n );\n const { roles, channels } = mentions;\n return this.content\n .replaceAll(MessageMentions.UsersPattern, (match, id: string) => {\n const name = members.get(id) ?? users.get(id);\n return name ? `@${name}` : match;\n })\n .replaceAll(MessageMentions.RolesPattern, (match, id: string) => {\n const role = roles.get(id);\n return role ? `@${role.name}` : match;\n })\n .replaceAll(MessageMentions.ChannelsPattern, (match, id: string) => {\n const channel = channels.get(id) as { name?: string | null } | undefined;\n return channel?.name ? `#${channel.name}` : match;\n })\n .replaceAll(/@(everyone|here)/g, `@${ZeroWidthSpace}$1`);\n }\n\n public override get createdTimestamp() {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n\n /**\n * When the message was last edited, `null` if it never was.\n */\n public override get editedTimestamp(): number | null {\n return this.optimizedTimestamp(\"edited_timestamp\");\n }\n\n public get editedAt(): Date | null {\n const { editedTimestamp } = this;\n return editedTimestamp === null ? null : new Date(editedTimestamp);\n }\n\n /**\n * The URL to jump to this message.\n */\n public get url(): string {\n return `https://discord.com/channels/${this.guildId ?? \"@me\"}/${this.channelId}/${this.id}`;\n }\n\n /**\n * Whether the message was sent in a guild.\n */\n public inGuild(): boolean {\n return this.guildId !== null;\n }\n\n /**\n * Fetches the channel the message was sent in.\n */\n public fetchChannel(): Promise<AnyChannel> {\n return this.client.channels.fetch(this.channelId);\n }\n\n /**\n * Fetches the guild the message was sent in, `null` outside of guilds.\n */\n public async fetchGuild(): Promise<Guild | null> {\n const { guildId } = this;\n return guildId ? this.client.guilds.fetch(guildId) : null;\n }\n\n /**\n * Fetches the message this one replies to, crossposts, or forwards.\n */\n public async fetchReference(): Promise<Message> {\n const reference = this.reference;\n if (!reference?.message_id) throw new Error(`Message ${this.id} references no message`);\n return this.client.messages.fetch(reference.channel_id ?? this.channelId, reference.message_id);\n }\n\n /**\n * Whether the bot can edit the message: it is the author.\n */\n public async fetchEditable(): Promise<boolean> {\n const client = this.client;\n return this.author.id === (client.user?.id ?? client.id);\n }\n\n /**\n * Whether the bot can delete the message: it is the author, or it has `ManageMessages` in the guild.\n */\n public async fetchDeletable(): Promise<boolean> {\n return (await this.fetchEditable()) || this.hasPermission(\"ManageMessages\");\n }\n\n /**\n * Whether the bot can bulk delete the message: it can delete it, and it is newer than 14 days.\n */\n public async fetchBulkDeletable(): Promise<boolean> {\n return (\n Date.now() - this.createdTimestamp < 14 * 24 * 60 * 60 * 1000 &&\n (await this.hasPermission(\"ManageMessages\"))\n );\n }\n\n /**\n * Whether the bot can pin the message: it is not a system message, and the bot has `PinMessages`.\n */\n public async fetchPinnable(): Promise<boolean> {\n if (this.system) return false;\n return !this.inGuild() || this.hasPermission(\"PinMessages\");\n }\n\n /**\n * Whether the bot can publish the message: it is in an announcement channel, not crossposted yet, and the bot\n * authored it or has `ManageMessages`.\n */\n public async fetchCrosspostable(): Promise<boolean> {\n if (this.flags.has(MessageFlags.Crossposted) || this.system || !this.inGuild()) return false;\n const channel = await this.fetchChannel();\n if (channel.type !== ChannelType.GuildAnnouncement) return false;\n return (await this.fetchEditable()) || this.hasPermission(\"ManageMessages\");\n }\n\n /**\n * Whether the message is partial: built from its IDs alone for an event about an uncached message, see\n * `Partials.Message`. Only `id`, `channelId`, and `guildId` are reliable then, and {@link Message.fetch} completes\n * it.\n */\n public get partial(): boolean {\n return this[kData].author === undefined;\n }\n\n /**\n * Fetches the message from the API and patches this structure with the result.\n */\n public async fetch(): Promise<this> {\n const message = await this.client.messages.fetch(this.channelId, this.id, {\n force: true,\n });\n return this[kPatch](message.toJSON());\n }\n\n /**\n * Edits the message.\n *\n * @param options The changes, or the new content.\n */\n public async edit(options: MessagePayloadResolvable<MessageEditOptions>): Promise<this> {\n const message = await this.client.messages.edit(\n this.channelId,\n this.id,\n MessagePayload.create(this, options, { edit: true }),\n );\n return this[kPatch](message.toJSON());\n }\n\n /**\n * Replies to the message.\n *\n * @param options The reply, or its content.\n */\n public reply(options: MessagePayloadResolvable<MessageCreateOptions>): Promise<Message> {\n const payload = MessagePayload.create(this, options);\n return this.client.messages.send(\n this.channelId,\n MessagePayload.create(this, {\n ...payload.options,\n reply: { messageReference: this },\n }),\n );\n }\n\n /**\n * Forwards the message to another channel.\n *\n * @param channelId The ID of the channel to forward it to.\n */\n public forward(channelId: string): Promise<Message> {\n return this.client.messages.forward(this.channelId, this.id, channelId);\n }\n\n public async delete(reason?: string): Promise<this> {\n await this.client.messages.delete(this.channelId, this.id, reason);\n return this;\n }\n\n public async pin(reason?: string): Promise<this> {\n await this.client.messages.pin(this.channelId, this.id, reason);\n return this[kPatch]({ pinned: true });\n }\n\n public async unpin(reason?: string): Promise<this> {\n await this.client.messages.unpin(this.channelId, this.id, reason);\n return this[kPatch]({ pinned: false });\n }\n\n /**\n * Reacts to the message as the bot.\n *\n * @param emoji The emoji.\n */\n public async react(emoji: EmojiIdentifierResolvable): Promise<this> {\n await this.client.messages.react(this.channelId, this.id, emoji);\n return this;\n }\n\n /**\n * Publishes the message of an announcement channel to the channels following it.\n */\n public async crosspost(): Promise<this> {\n const message = await this.client.messages.crosspost(this.channelId, this.id);\n return this[kPatch](message.toJSON());\n }\n\n /**\n * Starts a thread from the message.\n *\n * @param options The thread's name and settings.\n */\n public startThread(options: MessageThreadCreateOptions): Promise<AnyThreadChannel> {\n return this.client.messages.startThread(this.channelId, this.id, options);\n }\n\n /**\n * Hides or shows the embeds of the message.\n *\n * @param suppress Whether to hide them.\n */\n public suppressEmbeds(suppress = true): Promise<this> {\n const flags = new MessageFlagsBitField(this.flags.bitField);\n if (suppress) flags.add(MessageFlags.SuppressEmbeds);\n else flags.remove(MessageFlags.SuppressEmbeds);\n return this.edit({ flags: Number(flags.bitField) });\n }\n\n /**\n * Removes every attachment of the message.\n */\n public removeAttachments(): Promise<this> {\n return this.edit({ attachments: [] });\n }\n\n /**\n * Whether this message has the same data as another one, or as a raw message.\n * @param message The message to compare with.\n */\n public equals(message: Message | APIMessage): boolean {\n const other = message instanceof Message ? message.toJSON() : message;\n return (\n this.id === other.id &&\n this.content === other.content &&\n this.author.id === other.author.id &&\n this.pinned === other.pinned &&\n this.tts === other.tts &&\n this.editedTimestamp ===\n (other.edited_timestamp ? Date.parse(other.edited_timestamp) : null) &&\n isDeepEqual(this[kData].embeds, other.embeds) &&\n isDeepEqual(this[kData].attachments, other.attachments)\n );\n }\n\n public override toJSON(): CacheEntityTypes[\"messages\"] {\n return BaseStructure.prototype.toJSON.call(this) as CacheEntityTypes[\"messages\"];\n }\n\n public toString(): string {\n return this.content;\n }\n\n // The bot's permissions in the message's channel, overwrites included.\n private async hasPermission(permission: PermissionsString): Promise<boolean> {\n const { guildId } = this;\n if (!guildId) return false;\n const me = await this.client.members.fetchMe(guildId);\n return (await me.fetchPermissionsIn(this.channelId)).has(permission);\n }\n}\n\nMixin(Message, [StructureMixin]);\n","import { messageKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n MessageFlags,\n Routes,\n type APIMessage,\n type RESTGetAPIChannelMessagesPinsResult,\n type RESTPatchAPIChannelMessageJSONBody,\n type RESTPostAPIChannelMessagesThreadsJSONBody,\n type ThreadAutoArchiveDuration,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { Message } from \"../structures/messages/Message.js\";\nimport {\n ReactionEmoji,\n type EmojiIdentifierResolvable,\n} from \"../structures/emojis/ReactionEmoji.js\";\nimport { type User } from \"../structures/users/User.js\";\nimport { whenAll, whenCachedMap } from \"../util/cache.js\";\nimport type { GuildEmoji } from \"../structures/emojis/GuildEmoji.js\";\nimport {\n MessageMentions,\n type MessageMentionsRelations,\n} from \"../structures/messages/MessageMentions.js\";\nimport {\n MessagePayload,\n type MessageCreateOptions,\n type MessageEditOptions,\n type MessagePayloadResolvable,\n} from \"../util/messages.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\nimport type { AnyThreadChannel } from \"./ThreadManager.js\";\n\n/**\n * The options to list the messages of a channel with. `before`, `after`, and `around` are exclusive.\n */\nexport interface MessageListOptions {\n /**\n * How many messages to fetch, up to 100.\n *\n * @default 50\n */\n limit?: number;\n before?: string;\n after?: string;\n around?: string;\n}\n\n/**\n * The options to start a thread from a message with.\n */\nexport interface MessageThreadCreateOptions {\n name: string;\n autoArchiveDuration?: ThreadAutoArchiveDuration;\n rateLimitPerUser?: number;\n reason?: string;\n}\n\n/**\n * A pinned message, with the time it was pinned at.\n */\nexport interface PinnedMessage {\n message: Message;\n pinnedTimestamp: number;\n}\n\n/**\n * The upper bound of the messages `bulkDelete` accepts: Discord refuses messages older than 14 days.\n */\nconst BulkDeleteMaxAge = 14 * 24 * 60 * 60 * 1000;\n\n/**\n * Manages the {@link Message}s known to the client.\n */\nexport class MessageManager extends CachedManager<\n \"messages\",\n Message,\n [channelId: string, messageId: string]\n> {\n public constructor(client: GatewayClient) {\n super(client, \"messages\");\n }\n\n public construct(data: CacheEntityTypes[\"messages\"]): Message {\n return new Message(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"messages\"]): string {\n return this.resolveKey(data.channel_id, data.id);\n }\n\n /**\n * Adds a message to the cache, its author to `client.users` (unless a webhook sent it), and its member to\n * `client.members`.\n *\n * @internal\n */\n public override async _add(\n data: CacheEntityTypes[\"messages\"],\n cache = true,\n options?: AddOptions,\n ): Promise<Message> {\n const { author, member, guild_id: guildId } = data;\n await this.client.users._add(author, cache && !data.webhook_id);\n if (member && guildId) {\n await this.client.members._add({ ...member, user: author, guild_id: guildId }, cache);\n }\n\n return super._add(data, cache, options);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"messages\"]): Awaitable<Message> {\n const { author, member, guild_id: guildId } = data;\n return whenAll(\n [\n // A webhook is not a user: its author only holds for this message.\n data.webhook_id\n ? this.client.users.construct(author)\n : this.client.users._resolveData(author),\n member && guildId\n ? this.client.members._resolveData({ ...member, user: author, guild_id: guildId })\n : null,\n this.cachedGuild(guildId),\n this.client.channels._get(data.channel_id),\n (data as { thread?: unknown }).thread !== undefined ||\n ((data.flags ?? 0) & MessageFlags.HasThread) !== 0\n ? this.client.threads._get(data.id)\n : undefined,\n this.resolveMentions(data),\n guildId ? this.resolveEmojis(guildId, data) : undefined,\n ],\n ([resolvedAuthor, resolvedMember, guild, channel, thread, mentions, emojis]) =>\n new Message(data, {\n author: resolvedAuthor,\n member: resolvedMember,\n guild,\n channel: channel ?? null,\n thread: thread ?? null,\n mentions,\n emojis,\n }),\n );\n }\n\n // The cached copies of the users, members, roles, and channels a message mentions, like discord.js's mentions.\n private resolveMentions(data: CacheEntityTypes[\"messages\"]): Awaitable<MessageMentionsRelations> {\n const { client } = this;\n const { guild_id: guildId, content = \"\" } = data;\n const users = [\n ...data.mentions.map((user) => user.id),\n ...MessageMentions.parseIds(content, MessageMentions.UsersPattern),\n ...(data.referenced_message ? [data.referenced_message.author.id] : []),\n ];\n const members = data.mentions.filter((user) => \"member\" in user).map((user) => user.id);\n return whenAll(\n [\n whenCachedMap(users, (id) => client.users._get(id)),\n guildId ? whenCachedMap(members, (id) => client.members._get(guildId, id)) : undefined,\n guildId\n ? whenCachedMap(data.mention_roles, (id) => client.roles._get(guildId, id))\n : undefined,\n whenCachedMap(MessageMentions.parseIds(content, MessageMentions.ChannelsPattern), (id) =>\n client.channels._get(id),\n ),\n ],\n ([resolvedUsers, resolvedMembers, roles, channels]) => ({\n users: resolvedUsers,\n members: resolvedMembers,\n roles,\n channels,\n }),\n );\n }\n\n // The cached custom emojis of a message's reactions and poll answers, from its own guild.\n private resolveEmojis(\n guildId: string,\n data: CacheEntityTypes[\"messages\"],\n ): Awaitable<Map<string, GuildEmoji>> {\n const ids = [\n ...(data.reactions ?? []).map((reaction) => reaction.emoji.id),\n ...(data.poll?.answers ?? []).map((answer) => answer.poll_media.emoji?.id),\n ].filter((id): id is string => Boolean(id));\n const emojis = this.client.guilds.emojis(guildId);\n return whenCachedMap(ids, (id) => emojis._get(id));\n }\n\n public resolveKey(channelId: string, messageId: string): string {\n return messageKey(channelId, messageId);\n }\n\n /**\n * Lists the messages of a channel, newest first, and caches them.\n *\n * @param channelId The ID of the channel.\n * @param options How many messages, and around which one.\n */\n public async list(channelId: string, options: MessageListOptions = {}): Promise<Message[]> {\n const messages = await this.client.api.channels.getMessages(channelId, {\n limit: options.limit ?? 50,\n before: options.before,\n after: options.after,\n around: options.around,\n });\n return Promise.all(messages.map((message) => this.store(message)));\n }\n\n /**\n * Sends a message to a channel.\n *\n * @param channelId The ID of the channel.\n * @param options The message, or its content.\n */\n public async send(\n channelId: string,\n options: MessagePayloadResolvable<MessageCreateOptions>,\n ): Promise<Message> {\n const { body, files } = await MessagePayload.create(this.client, options).resolve();\n const message = await this.client.api.channels.createMessage(channelId, {\n ...body,\n files,\n });\n return this.store(message);\n }\n\n /**\n * Forwards a message to another channel.\n *\n * @param channelId The ID of the channel of the message.\n * @param messageId The ID of the message.\n * @param targetChannelId The ID of the channel to forward it to.\n */\n public forward(channelId: string, messageId: string, targetChannelId: string): Promise<Message> {\n return this.send(targetChannelId, {\n forward: { message: messageId, channel: channelId },\n });\n }\n\n /**\n * Edits a message.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message.\n * @param options The changes, or the new content.\n */\n public async edit(\n channelId: string,\n messageId: string,\n options: MessagePayloadResolvable<MessageEditOptions>,\n ): Promise<Message> {\n const { body, files } = await MessagePayload.create(this.client, options, {\n edit: true,\n }).resolve<RESTPatchAPIChannelMessageJSONBody>();\n const message = await this.client.api.channels.editMessage(channelId, messageId, {\n ...body,\n files,\n });\n return this.store(message);\n }\n\n /**\n * Deletes a message.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message.\n * @param reason The reason for the audit log, when deleting someone else's message.\n */\n public async delete(channelId: string, messageId: string, reason?: string): Promise<void> {\n await this.client.api.channels.deleteMessage(channelId, messageId, { reason });\n await this.cache?.delete(this.resolveKey(channelId, messageId));\n }\n\n /**\n * Deletes up to 100 messages at once, skipping the ones older than 14 days that Discord refuses.\n *\n * @param channelId The ID of the channel.\n * @param messages The IDs of the messages, or how many of the latest ones to delete.\n * @param filterOld Whether to drop the messages older than 14 days instead of letting the request fail.\n * @returns The IDs of the deleted messages.\n */\n public async bulkDelete(\n channelId: string,\n messages: readonly string[] | number,\n filterOld = false,\n ): Promise<string[]> {\n let ids =\n typeof messages === \"number\"\n ? (await this.list(channelId, { limit: messages })).map((message) => message.id)\n : [...messages];\n\n if (filterOld) {\n const oldest = Date.now() - BulkDeleteMaxAge;\n ids = ids.filter((id) => Number((BigInt(id) >> 22n) + 1_420_070_400_000n) > oldest);\n }\n\n if (ids.length === 0) return [];\n if (ids.length === 1) {\n await this.delete(channelId, ids[0]!);\n } else {\n await this.client.api.channels.bulkDeleteMessages(channelId, ids);\n await Promise.all(ids.map((id) => this.cache?.delete(this.resolveKey(channelId, id))));\n }\n\n return ids;\n }\n\n /**\n * Fetches the pinned messages of a channel, most recently pinned first, and caches them.\n *\n * @param channelId The ID of the channel.\n * @param options How many pins to fetch (up to 50), and before which pin time.\n */\n public async fetchPins(\n channelId: string,\n options: { limit?: number; before?: Date | number } = {},\n ): Promise<{ items: PinnedMessage[]; hasMore: boolean }> {\n const query = new URLSearchParams();\n if (options.limit) query.set(\"limit\", String(options.limit));\n if (options.before !== undefined) query.set(\"before\", new Date(options.before).toISOString());\n\n const result = (await this.client.api.rest.get(Routes.channelMessagesPins(channelId), {\n query,\n })) as RESTGetAPIChannelMessagesPinsResult;\n const items = await Promise.all(\n result.items.map(async (item) => ({\n message: await this.store(item.message),\n pinnedTimestamp: Date.parse(item.pinned_at),\n })),\n );\n return { items, hasMore: result.has_more };\n }\n\n /**\n * Pins a message.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message.\n * @param reason The reason for the audit log.\n */\n public async pin(channelId: string, messageId: string, reason?: string): Promise<void> {\n await this.client.api.channels.pinMessage(channelId, messageId, { reason });\n await this.patchCached(channelId, messageId, { pinned: true });\n }\n\n /**\n * Unpins a message.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message.\n * @param reason The reason for the audit log.\n */\n public async unpin(channelId: string, messageId: string, reason?: string): Promise<void> {\n await this.client.api.channels.unpinMessage(channelId, messageId, { reason });\n await this.patchCached(channelId, messageId, { pinned: false });\n }\n\n /**\n * Publishes a message of an announcement channel to the channels following it.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message.\n */\n public async crosspost(channelId: string, messageId: string): Promise<Message> {\n const message = await this.client.api.channels.crosspostMessage(channelId, messageId);\n return this.store(message);\n }\n\n /**\n * Reacts to a message as the bot.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message.\n * @param emoji The emoji.\n */\n public async react(\n channelId: string,\n messageId: string,\n emoji: EmojiIdentifierResolvable,\n ): Promise<void> {\n await this.client.api.channels.addMessageReaction(\n channelId,\n messageId,\n ReactionEmoji.resolveIdentifier(emoji),\n );\n }\n\n /**\n * Removes every reaction with one emoji from a message.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message.\n * @param emoji The emoji.\n */\n public async removeReactionEmoji(\n channelId: string,\n messageId: string,\n emoji: EmojiIdentifierResolvable,\n ): Promise<void> {\n await this.client.api.channels.deleteAllMessageReactionsForEmoji(\n channelId,\n messageId,\n ReactionEmoji.resolveIdentifier(emoji),\n );\n }\n\n /**\n * Removes every reaction from a message.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message.\n */\n public async removeAllReactions(channelId: string, messageId: string): Promise<void> {\n await this.client.api.channels.deleteAllMessageReactions(channelId, messageId);\n await this.patchCached(channelId, messageId, { reactions: [] });\n }\n\n /**\n * Starts a thread from a message.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message.\n * @param options The thread's name and settings.\n */\n public async startThread(\n channelId: string,\n messageId: string,\n options: MessageThreadCreateOptions,\n ): Promise<AnyThreadChannel> {\n const body: RESTPostAPIChannelMessagesThreadsJSONBody = {\n name: options.name,\n auto_archive_duration: options.autoArchiveDuration,\n rate_limit_per_user: options.rateLimitPerUser,\n };\n const thread = await this.client.api.channels.createThread(channelId, body, messageId, {\n reason: options.reason,\n });\n return this.client.threads._add(thread);\n }\n\n /**\n * Ends a poll now. Only the bot's own polls can be ended.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message holding the poll.\n */\n public async endPoll(channelId: string, messageId: string): Promise<Message> {\n const message = await this.client.api.poll.expirePoll(channelId, messageId);\n return this.store(message);\n }\n\n /**\n * Fetches the users who voted for an answer of a poll, paginated by user ID.\n *\n * @param channelId The ID of the channel.\n * @param messageId The ID of the message holding the poll.\n * @param answerId The ID of the answer.\n * @param options How many voters to fetch (up to 100), and after which user ID.\n */\n public async fetchPollAnswerVoters(\n channelId: string,\n messageId: string,\n answerId: number,\n options: { limit?: number; after?: string } = {},\n ): Promise<User[]> {\n const { users } = await this.client.api.poll.getAnswerVoters(\n channelId,\n messageId,\n answerId,\n options,\n );\n return Promise.all(users.map((user) => this.client.users._add(user)));\n }\n\n protected async fetchRaw(channelId: string, messageId: string) {\n return this.client.api.channels.getMessage(channelId, messageId);\n }\n\n private store(message: APIMessage): Promise<Message> {\n return this._add(message);\n }\n\n private async patchCached(\n channelId: string,\n messageId: string,\n patch: Partial<CacheEntityTypes[\"messages\"]>,\n ): Promise<void> {\n const key = this.resolveKey(channelId, messageId);\n const cached = await this.cache?.get(key);\n if (cached) await this.cache!.set(key, { ...cached, ...patch });\n }\n}\n","import type { ImageURLOptions } from \"@discordjs/rest\";\nimport type { Partialize } from \"@discordjs/structures\";\nimport type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { APIRoleTags } from \"discord-api-types/v10\";\nimport type { RoleEditOptions } from \"../../managers/RoleManager.js\";\nimport { cdn } from \"../../util/cdn.js\";\nimport { RoleFlagsBitField } from \"../../util/flags.js\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport { compareRolePositions, computePermissionsIn } from \"../../util/permissions.js\";\nimport { PermissionsBitField, type PermissionResolvable } from \"../../util/PermissionsBitField.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kPatch, kRelations, snowflakeTimestamp, Structure } from \"../Structure.js\";\n\n/**\n * The colors of a role: `primaryColor` alone for a solid color, with `secondaryColor` for a gradient, and with\n * `tertiaryColor` for the holographic style.\n */\nexport interface RoleColors {\n primaryColor: number;\n secondaryColor: number | null;\n tertiaryColor: number | null;\n}\nconst kOptimizedPermissions: unique symbol = Symbol(\"role.permissions\");\n\n/**\n * A Discord guild role.\n */\nexport class Role<Omitted extends keyof CacheEntityTypes[\"roles\"] | \"\" = \"\"> extends Structure<\n CacheEntityTypes[\"roles\"],\n Omitted\n> {\n declare public [kRelations]: { guild?: Guild | null };\n declare protected [kOptimizedPermissions]: bigint;\n\n protected override optimizeData(data: Partial<CacheEntityTypes[\"roles\"]>): void {\n if (data.permissions !== undefined) this[kOptimizedPermissions] = BigInt(data.permissions);\n }\n\n /**\n * The template used for removing data from the raw data stored for each role\n */\n public static override readonly DataTemplate: Partial<CacheEntityTypes[\"roles\"]> = {};\n\n /**\n * @param data - The raw data received from the API for the role\n * @param relations - The guild as resolved from the cache, by `client.roles`\n */\n public constructor(\n data: Partialize<CacheEntityTypes[\"roles\"], Omitted>,\n relations: { guild?: Guild | null } = {},\n ) {\n super(data, relations);\n }\n\n public get id() {\n return this[kData].id;\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n /**\n * The guild, from the cache. `null` when the guild is not cached, or when the role was not built by a manager: use\n * `fetchGuild()` to always get it.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * Fetches the guild, cache first.\n */\n public fetchGuild(): Promise<Guild> {\n return this.client.guilds.fetch(this.guildId);\n }\n\n public get name() {\n return this[kData].name;\n }\n\n /**\n * The primary color of the role, `0` when it has none.\n */\n public get color() {\n return this[kData].colors?.primary_color ?? this[kData].color;\n }\n\n /**\n * The primary color of the role as a `#rrggbb` string.\n */\n public get hexColor(): `#${string}` {\n return `#${this.color.toString(16).padStart(6, \"0\")}`;\n }\n\n public get colors(): RoleColors {\n const { colors } = this[kData];\n return {\n primaryColor: colors?.primary_color ?? this[kData].color,\n secondaryColor: colors?.secondary_color ?? null,\n tertiaryColor: colors?.tertiary_color ?? null,\n };\n }\n\n public get position() {\n return this[kData].position;\n }\n\n public get permissions(): Readonly<PermissionsBitField> {\n return new PermissionsBitField(this[kOptimizedPermissions] ?? 0n).freeze();\n }\n\n /**\n * Fetches the role's permissions in a channel: its permissions and `@everyone`'s, with the channel's `@everyone` and\n * role overwrites applied. discord.js: `role.permissionsIn(channel)`.\n *\n * @param channel The channel, or its ID. Threads use their parent's overwrites.\n */\n public fetchPermissionsIn(channel: AnyChannel | string): Promise<Readonly<PermissionsBitField>> {\n return computePermissionsIn(channel, this as unknown as Role);\n }\n\n public get hoist() {\n return this[kData].hoist;\n }\n\n public get managed() {\n return this[kData].managed;\n }\n\n public get mentionable() {\n return this[kData].mentionable;\n }\n\n public get icon(): string | null {\n return this[kData].icon ?? null;\n }\n\n public get unicodeEmoji(): string | null {\n return this[kData].unicode_emoji ?? null;\n }\n\n /**\n * What the role belongs to: a bot, an integration, the server boosters, or a subscription listing.\n */\n public get tags(): APIRoleTags | null {\n return this[kData].tags ?? null;\n }\n\n public get flags(): Readonly<RoleFlagsBitField> {\n return new RoleFlagsBitField(this[kData].flags ?? 0).freeze();\n }\n\n public get createdTimestamp() {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt(): Date {\n return new Date(this.createdTimestamp);\n }\n\n /**\n * Gets the URL of the role's icon, or `null` if it has none.\n * @param options The image options.\n */\n public iconURL(options?: ImageURLOptions): string | null {\n const { icon } = this;\n return icon ? cdn.roleIcon(this.id, icon, options) : null;\n }\n\n /**\n * Compares this role's position with another one's.\n *\n * @param role The role to compare with.\n * @returns A negative number when this role is lower, a positive one when it is higher, `0` when they are the same.\n */\n public comparePositionTo(role: Pick<Role, \"id\" | \"position\">): number {\n return compareRolePositions(this, role);\n }\n\n /**\n * Whether the client's member can edit this role, i.e. it has `ManageRoles` and a higher role.\n */\n public async fetchEditable(): Promise<boolean> {\n if (this.managed) return false;\n\n const client = this.client;\n const me = await client.members.fetchMe(this.guildId);\n const permissions = await me.fetchPermissions();\n if (!permissions.has(\"ManageRoles\")) return false;\n\n const highest = await me.roles.fetchHighest();\n return highest !== null && highest.comparePositionTo(this) > 0;\n }\n\n /**\n * Edits the role.\n *\n * @param options The fields to edit.\n * @returns This role, patched.\n */\n public async edit(options: RoleEditOptions): Promise<this> {\n const role = await this.client.roles.edit(this.guildId, this.id, options);\n return this[kPatch](role.toJSON());\n }\n\n public setName(name: string, reason?: string): Promise<this> {\n return this.edit({ name, reason });\n }\n\n public setColors(colors: Partial<RoleColors> & { primaryColor: number }, reason?: string) {\n return this.edit({ colors, reason });\n }\n\n public setHoist(hoist = true, reason?: string): Promise<this> {\n return this.edit({ hoist, reason });\n }\n\n public setPermissions(permissions: PermissionResolvable, reason?: string): Promise<this> {\n return this.edit({ permissions, reason });\n }\n\n public setMentionable(mentionable = true, reason?: string): Promise<this> {\n return this.edit({ mentionable, reason });\n }\n\n /**\n * Sets the role's icon, as a data URI (`data:image/png;base64,...`), or removes it with `null`.\n */\n public setIcon(icon: string | null, reason?: string): Promise<this> {\n return this.edit({ icon, reason });\n }\n\n public setUnicodeEmoji(unicodeEmoji: string | null, reason?: string): Promise<this> {\n return this.edit({ unicodeEmoji, reason });\n }\n\n /**\n * Moves the role.\n *\n * @param position The new position.\n * @param reason The reason for the audit log.\n */\n public async setPosition(position: number, reason?: string): Promise<this> {\n const roles = await this.client.roles.setPositions(\n this.guildId,\n [{ role: this.id, position }],\n reason,\n );\n // Discord may clamp or shift the requested position: keep what it actually applied.\n const updated = roles.find((role) => role.id === this.id);\n return updated ? this[kPatch](updated.toJSON()) : this;\n }\n\n /**\n * Deletes the role.\n *\n * @param reason The reason for the audit log.\n */\n public async delete(reason?: string): Promise<this> {\n await this.client.roles.delete(this.guildId, this.id, reason);\n return this;\n }\n\n /**\n * Whether this role has the same data as another one.\n * @param role The role to compare with.\n */\n public equals(role: Role): boolean {\n return (\n this.id === role.id &&\n this.name === role.name &&\n this.color === role.color &&\n this.hoist === role.hoist &&\n this.position === role.position &&\n this[kData].permissions === role[kData].permissions &&\n this.managed === role.managed &&\n this.icon === role.icon &&\n this.unicodeEmoji === role.unicodeEmoji\n );\n }\n\n public toString(): `<@&${string}>` | \"@everyone\" {\n // `@everyone` has the guild's ID and is written as is.\n return this.id === this.guildId ? \"@everyone\" : `<@&${this.id}>`;\n }\n}\n","import { roleKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n type APIRole,\n type RESTPatchAPIGuildRoleJSONBody,\n type RESTPatchAPIGuildRolePositionsJSONBody,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { Role, type RoleColors } from \"../structures/guilds/Role.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { PermissionsBitField, type PermissionResolvable } from \"../util/PermissionsBitField.js\";\nimport { CachedManager } from \"./CachedManager.js\";\n\n/**\n * The options to create or edit a role with.\n */\nexport interface RoleEditOptions {\n name?: string;\n /**\n * The primary color alone, see {@link RoleEditOptions.colors} for gradients.\n */\n color?: number;\n colors?: Partial<RoleColors> & { primaryColor: number };\n hoist?: boolean;\n permissions?: PermissionResolvable;\n mentionable?: boolean;\n /**\n * The icon as a data URI (`data:image/png;base64,...`), `null` to remove it.\n */\n icon?: string | null;\n unicodeEmoji?: string | null;\n /**\n * The reason for the audit log.\n */\n reason?: string;\n}\n\n/**\n * A role and the position to move it to.\n */\nexport interface RolePosition {\n role: string;\n position: number;\n}\n\n/**\n * Manages the {@link Role}s known to the client.\n */\nexport class RoleManager extends CachedManager<\"roles\", Role, [guildId: string, roleId: string]> {\n public constructor(client: GatewayClient) {\n super(client, \"roles\");\n }\n\n public construct(data: CacheEntityTypes[\"roles\"]): Role {\n return new Role(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"roles\"]): string {\n return this.resolveKey(data.guild_id, data.id);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"roles\"]): Awaitable<Role> {\n return whenAll([this.cachedGuild(data.guild_id)], ([guild]) => new Role(data, { guild }));\n }\n\n public resolveKey(guildId: string, roleId: string): string {\n return roleKey(guildId, roleId);\n }\n\n /**\n * Fetches every role of a guild from the API, and caches them.\n *\n * @param guildId The ID of the guild.\n * @returns The roles, highest first.\n */\n public async fetchAll(guildId: string): Promise<Role[]> {\n const roles = await this.client.api.guilds.getRoles(guildId);\n const structures = await Promise.all(roles.map((role) => this.store(guildId, role)));\n\n return structures.toSorted((a, b) => b.comparePositionTo(a));\n }\n\n /**\n * Fetches how many members each role of a guild has, `@everyone` excluded.\n *\n * @param guildId The ID of the guild.\n * @returns The member count of every role, by role ID.\n */\n public async fetchMemberCounts(guildId: string): Promise<Map<string, number>> {\n const counts = await this.client.api.guilds.getRoleMemberCounts(guildId);\n return new Map(Object.entries(counts));\n }\n\n /**\n * Creates a role.\n *\n * @param guildId The ID of the guild.\n * @param options The role's fields.\n */\n public async create(guildId: string, options: RoleEditOptions = {}): Promise<Role> {\n const role = await this.client.api.guilds.createRole(guildId, toRoleBody(options), {\n reason: options.reason,\n });\n return this.store(guildId, role);\n }\n\n /**\n * Edits a role.\n *\n * @param guildId The ID of the guild.\n * @param roleId The ID of the role.\n * @param options The fields to edit.\n */\n public async edit(guildId: string, roleId: string, options: RoleEditOptions): Promise<Role> {\n const role = await this.client.api.guilds.editRole(guildId, roleId, toRoleBody(options), {\n reason: options.reason,\n });\n return this.store(guildId, role);\n }\n\n /**\n * Deletes a role.\n *\n * @param guildId The ID of the guild.\n * @param roleId The ID of the role.\n * @param reason The reason for the audit log.\n */\n public async delete(guildId: string, roleId: string, reason?: string): Promise<void> {\n await this.client.api.guilds.deleteRole(guildId, roleId, { reason });\n await this.cache?.delete(this.resolveKey(guildId, roleId));\n }\n\n /**\n * Moves a role.\n *\n * @param guildId The ID of the guild.\n * @param roleId The ID of the role.\n * @param position The new position.\n * @param reason The reason for the audit log.\n */\n public async setPosition(\n guildId: string,\n roleId: string,\n position: number,\n reason?: string,\n ): Promise<Role[]> {\n return this.setPositions(guildId, [{ role: roleId, position }], reason);\n }\n\n /**\n * Moves several roles at once.\n *\n * @param guildId The ID of the guild.\n * @param positions The roles and their new positions.\n * @param reason The reason for the audit log.\n * @returns Every role of the guild, highest first.\n */\n public async setPositions(\n guildId: string,\n positions: readonly RolePosition[],\n reason?: string,\n ): Promise<Role[]> {\n const body: RESTPatchAPIGuildRolePositionsJSONBody = positions.map(({ role, position }) => ({\n id: role,\n position,\n }));\n const roles = await this.client.api.guilds.setRolePositions(guildId, body, { reason });\n const structures = await Promise.all(roles.map((role) => this.store(guildId, role)));\n return structures.toSorted((a, b) => b.comparePositionTo(a));\n }\n\n /**\n * Compares the positions of two roles.\n *\n * @returns A negative number when `a` is lower, a positive one when it is higher, `0` when they are the same.\n */\n public comparePositions(a: Role, b: Role): number {\n return a.comparePositionTo(b);\n }\n\n /**\n * Fetches the `@everyone` role of a guild, whose ID is the guild's.\n *\n * @param guildId The ID of the guild.\n */\n public everyone(guildId: string): Promise<Role> {\n return this.fetch(guildId, guildId);\n }\n\n /**\n * Fetches the highest role of a guild.\n *\n * @param guildId The ID of the guild.\n */\n public async highest(guildId: string): Promise<Role | null> {\n return (await this.fetchAll(guildId))[0] ?? null;\n }\n\n /**\n * Fetches the role Discord gives to the server boosters of a guild, if any.\n *\n * @param guildId The ID of the guild.\n */\n public async premiumSubscriberRole(guildId: string): Promise<Role | null> {\n const roles = await this.fetchAll(guildId);\n return roles.find((role) => role.tags?.premium_subscriber === null) ?? null;\n }\n\n /**\n * Fetches the role Discord manages for a bot in a guild, if any.\n *\n * @param guildId The ID of the guild.\n * @param botId The ID of the bot user.\n */\n public async botRoleFor(guildId: string, botId: string): Promise<Role | null> {\n const roles = await this.fetchAll(guildId);\n return roles.find((role) => role.tags?.bot_id === botId) ?? null;\n }\n\n protected async fetchRaw(guildId: string, roleId: string) {\n const role = await this.client.api.guilds.getRole(guildId, roleId);\n return { ...role, guild_id: guildId };\n }\n\n private store(guildId: string, role: APIRole): Promise<Role> {\n return this._add({ ...role, guild_id: guildId });\n }\n}\n\nfunction toRoleBody(options: RoleEditOptions): RESTPatchAPIGuildRoleJSONBody {\n const body: RESTPatchAPIGuildRoleJSONBody = {\n name: options.name,\n color: options.color,\n hoist: options.hoist,\n mentionable: options.mentionable,\n icon: options.icon,\n unicode_emoji: options.unicodeEmoji,\n };\n if (options.permissions !== undefined) {\n body.permissions = PermissionsBitField.resolve(options.permissions).toString();\n }\n\n if (options.colors) {\n body.colors = {\n primary_color: options.colors.primaryColor,\n secondary_color: options.colors.secondaryColor ?? null,\n tertiary_color: options.colors.tertiaryColor ?? null,\n };\n }\n\n return body;\n}\n","import {\n type APIWebhook,\n type RESTPatchAPIWebhookJSONBody,\n type RESTPatchAPIWebhookWithTokenMessageJSONBody,\n type RESTPostAPIChannelWebhookJSONBody,\n type RESTPostAPIWebhookWithTokenJSONBody,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport type { Message } from \"../structures/messages/Message.js\";\nimport { bindClient } from \"../structures/Structure.js\";\nimport { Webhook } from \"../structures/webhooks/Webhook.js\";\nimport { resolveId, type IdResolvable } from \"../util/channels.js\";\nimport {\n MessagePayload,\n type MessagePayloadResolvable,\n type WebhookMessageCreateOptions,\n type WebhookMessageEditOptions,\n type WebhookThreadOptions,\n} from \"../util/messages.js\";\n\nexport type { WebhookMessageCreateOptions, WebhookMessageEditOptions, WebhookThreadOptions };\n\n/**\n * The options to create a webhook with.\n */\nexport interface WebhookCreateOptions {\n name: string;\n /**\n * The avatar, as a data URI.\n */\n avatar?: string | null;\n reason?: string;\n}\n\n/**\n * The options to edit a webhook with.\n */\nexport interface WebhookEditOptions {\n name?: string;\n /**\n * The avatar, as a data URI, `null` to remove it.\n */\n avatar?: string | null;\n /**\n * The channel to move the webhook to. Needs the bot's authorization, not the webhook's token.\n */\n channel?: IdResolvable;\n reason?: string;\n}\n\n/**\n * Manages webhooks. Discord does not send them over the gateway, so they are never cached.\n *\n * @remarks\n * Methods taking a webhook's token call the API with it rather than with the bot's authorization, so they work for\n * webhooks of other applications too.\n */\nexport class WebhookManager {\n public readonly client: GatewayClient;\n\n public constructor(client: GatewayClient) {\n this.client = client;\n }\n\n /**\n * Fetches a webhook.\n *\n * @param webhookId The ID of the webhook.\n * @param token The webhook's token, to fetch it without the bot's authorization.\n */\n public async fetch(webhookId: string, token?: string): Promise<Webhook> {\n const webhook = await this.client.api.webhooks.get(webhookId, { token });\n return this.hydrate(webhook);\n }\n\n /**\n * Fetches the webhooks of a channel.\n *\n * @param channelId The ID of the channel.\n */\n public async fetchChannel(channelId: string): Promise<Webhook[]> {\n const webhooks = await this.client.api.channels.getWebhooks(channelId);\n return Promise.all(webhooks.map((webhook) => this.hydrate(webhook)));\n }\n\n /**\n * Fetches the webhooks of a guild.\n *\n * @param guildId The ID of the guild.\n */\n public async fetchGuild(guildId: string): Promise<Webhook[]> {\n const webhooks = await this.client.api.guilds.getWebhooks(guildId);\n return Promise.all(webhooks.map((webhook) => this.hydrate(webhook)));\n }\n\n /**\n * Creates a webhook in a channel.\n *\n * @param channelId The ID of the channel.\n * @param options The webhook's name and avatar, and the reason for the audit log.\n */\n public async create(channelId: string, options: WebhookCreateOptions): Promise<Webhook> {\n const body: RESTPostAPIChannelWebhookJSONBody = { name: options.name, avatar: options.avatar };\n const webhook = await this.client.api.channels.createWebhook(channelId, body, {\n reason: options.reason,\n });\n return this.hydrate(webhook);\n }\n\n /**\n * Edits a webhook.\n *\n * @param webhookId The ID of the webhook.\n * @param options The fields to edit, and the reason for the audit log.\n * @param token The webhook's token, to edit it without the bot's authorization (which cannot move it).\n */\n public async edit(\n webhookId: string,\n options: WebhookEditOptions,\n token?: string,\n ): Promise<Webhook> {\n const body: RESTPatchAPIWebhookJSONBody = {\n name: options.name,\n avatar: options.avatar,\n channel_id: options.channel === undefined ? undefined : resolveId(options.channel),\n };\n const webhook = await this.client.api.webhooks.edit(webhookId, body, {\n token,\n reason: options.reason,\n });\n return this.hydrate(webhook);\n }\n\n /**\n * Deletes a webhook.\n *\n * @param webhookId The ID of the webhook.\n * @param options The webhook's token, to delete it without the bot's authorization, and the reason for the audit log.\n */\n public async delete(\n webhookId: string,\n options: { token?: string; reason?: string } = {},\n ): Promise<void> {\n await this.client.api.webhooks.delete(webhookId, options);\n }\n\n /**\n * Sends a message through a webhook, and caches it.\n *\n * @param webhookId The ID of the webhook.\n * @param token The webhook's token.\n * @param options The message, or its content, and the thread to send it in.\n */\n public async send(\n webhookId: string,\n token: string,\n options: MessagePayloadResolvable<WebhookMessageCreateOptions>,\n ): Promise<Message> {\n const payload = MessagePayload.create(this.client, options, { webhook: true });\n const { threadId } = payload.options as WebhookThreadOptions;\n const { body, files } = await payload.resolve<RESTPostAPIWebhookWithTokenJSONBody>();\n const message = await this.client.api.webhooks.execute(webhookId, token, {\n ...body,\n files,\n thread_id: threadId,\n wait: true,\n });\n return this.client.messages._add(message);\n }\n\n /**\n * Fetches a message sent by a webhook.\n *\n * @param webhookId The ID of the webhook.\n * @param token The webhook's token.\n * @param messageId The ID of the message.\n * @param options The thread the message is in.\n */\n public async fetchMessage(\n webhookId: string,\n token: string,\n messageId: string,\n options: WebhookThreadOptions = {},\n ): Promise<Message> {\n const message = await this.client.api.webhooks.getMessage(webhookId, token, messageId, {\n thread_id: options.threadId,\n });\n return this.client.messages._add(message);\n }\n\n /**\n * Edits a message sent by a webhook.\n *\n * @param webhookId The ID of the webhook.\n * @param token The webhook's token.\n * @param messageId The ID of the message.\n * @param options The changes, or the new content, and the thread the message is in.\n */\n public async editMessage(\n webhookId: string,\n token: string,\n messageId: string,\n options: MessagePayloadResolvable<WebhookMessageEditOptions>,\n ): Promise<Message> {\n const payload = MessagePayload.create(this.client, options, { webhook: true, edit: true });\n const { threadId } = payload.options as WebhookThreadOptions;\n const { body, files } = await payload.resolve<RESTPatchAPIWebhookWithTokenMessageJSONBody>();\n const message = await this.client.api.webhooks.editMessage(webhookId, token, messageId, {\n ...body,\n files,\n thread_id: threadId,\n });\n return this.client.messages._add(message);\n }\n\n /**\n * Deletes a message sent by a webhook.\n *\n * @param webhookId The ID of the webhook.\n * @param token The webhook's token.\n * @param messageId The ID of the message.\n * @param options The thread the message is in.\n */\n public async deleteMessage(\n webhookId: string,\n token: string,\n messageId: string,\n options: WebhookThreadOptions = {},\n ): Promise<void> {\n await this.client.api.webhooks.deleteMessage(webhookId, token, messageId, {\n thread_id: options.threadId,\n });\n }\n\n /**\n * Builds the structure of a raw webhook, resolving its guild, channel, source guild, source channel, and owner from\n * the cache.\n *\n * @param data The raw webhook.\n */\n public async hydrate(data: APIWebhook): Promise<Webhook> {\n const [guild, channel, sourceGuild, sourceChannel, owner] = await Promise.all([\n data.guild_id ? this.client.guilds.get(data.guild_id) : undefined,\n data.channel_id ? this.client.channels.get(data.channel_id) : undefined,\n data.source_guild ? this.client.guilds.get(data.source_guild.id) : undefined,\n data.source_channel ? this.client.channels.get(data.source_channel.id) : undefined,\n data.user ? this.client.users.resolveData(data.user) : undefined,\n ]);\n return bindClient(\n new Webhook(data, {\n guild: guild ?? null,\n channel: channel ?? null,\n sourceGuild: sourceGuild ?? null,\n sourceChannel: sourceChannel ?? null,\n owner,\n }),\n this.client,\n );\n }\n}\n","import { RouteBases, type APITemplate } from \"discord-api-types/v10\";\nimport type {\n GuildTemplateCreateGuildOptions,\n GuildTemplateEditOptions,\n} from \"../../managers/GuildTemplateManager.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kPatch, kRelations, Structure } from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\n/**\n * The relations of a {@link GuildTemplate}: its source guild, when cached, and its creator.\n */\nexport interface GuildTemplateRelations {\n guild?: Guild | null;\n creator?: User;\n}\n\n/**\n * A guild template: a snapshot of a guild's channels, roles, and settings, to create guilds from.\n */\nexport class GuildTemplate extends Structure<APITemplate> {\n declare public [kRelations]: GuildTemplateRelations;\n\n protected override optimizeData(data: Partial<APITemplate>): void {\n this.optimizeTimestamp(\"created_at\", data.created_at);\n this.optimizeTimestamp(\"updated_at\", data.updated_at);\n }\n\n /**\n * @param data The raw template.\n * @param relations The source guild, as resolved from the cache.\n */\n public constructor(data: APITemplate, relations: GuildTemplateRelations = {}) {\n super(data, relations);\n }\n\n public override [kPatch](data: Readonly<Partial<APITemplate>>): this {\n if (data.creator) this.dropRelations(\"creator\");\n return super[kPatch](data);\n }\n\n public get code() {\n return this[kData].code;\n }\n\n public get name() {\n return this[kData].name;\n }\n\n public get description() {\n return this[kData].description;\n }\n\n public get usageCount() {\n return this[kData].usage_count;\n }\n\n public get creatorId() {\n return this[kData].creator_id;\n }\n\n /**\n * The user who created the template, from the cache, like discord.js, else from the payload.\n */\n public get creator(): User {\n return this[kRelations].creator ?? new User(this[kData].creator);\n }\n\n public get createdTimestamp() {\n return this.optimizedTimestamp(\"created_at\")!;\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n\n /**\n * When the template was last synced with its guild.\n */\n public get updatedTimestamp() {\n return this.optimizedTimestamp(\"updated_at\")!;\n }\n\n public get updatedAt() {\n return new Date(this.updatedTimestamp);\n }\n\n /**\n * The ID of the guild the template was made from.\n */\n public get guildId() {\n return this[kData].source_guild_id;\n }\n\n /**\n * The snapshot of the guild the template creates.\n */\n public get serializedGuild() {\n return this[kData].serialized_source_guild;\n }\n\n /**\n * Whether the guild changed since the template was last synced.\n */\n public get unSynced(): boolean | null {\n return this[kData].is_dirty;\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * The URL to create a guild from the template in the Discord app.\n */\n public get url(): string {\n return `${RouteBases.template}/${this.code}`;\n }\n\n /**\n * Creates a guild from the template, which Discord only allows to bots in fewer than 10 guilds.\n *\n * @param options The name and icon of the guild.\n */\n public createGuild(options: GuildTemplateCreateGuildOptions): Promise<Guild> {\n return this.client.templates.createGuild(this.code, options);\n }\n\n /**\n * Edits the template.\n *\n * @param options The name and description.\n */\n public async edit(options: GuildTemplateEditOptions): Promise<this> {\n const template = await this.client.templates.edit(this.guildId, this.code, options);\n return this[kPatch](template.toJSON());\n }\n\n /**\n * Syncs the template with the current state of its guild.\n */\n public async sync(): Promise<this> {\n const template = await this.client.templates.sync(this.guildId, this.code);\n return this[kPatch](template.toJSON());\n }\n\n public async delete(): Promise<this> {\n await this.client.templates.delete(this.guildId, this.code);\n return this;\n }\n\n public toString(): string {\n return this.code;\n }\n}\n","import {\n Routes,\n type APIGuild,\n type APITemplate,\n type RESTPatchAPIGuildTemplateJSONBody,\n type RESTPostAPIGuildTemplatesJSONBody,\n type RESTPostAPITemplateCreateGuildJSONBody,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport type { Guild } from \"../structures/guilds/Guild.js\";\nimport { GuildTemplate } from \"../structures/guilds/GuildTemplate.js\";\n\n/**\n * The options to create a template with.\n */\nexport interface GuildTemplateCreateOptions {\n name: string;\n description?: string | null;\n}\n\n/**\n * The options to edit a template with.\n */\nexport interface GuildTemplateEditOptions {\n name?: string;\n description?: string | null;\n}\n\n/**\n * The options to create a guild from a template with.\n */\nexport interface GuildTemplateCreateGuildOptions {\n name: string;\n /**\n * The icon, as a data URI.\n */\n icon?: string;\n}\n\n/**\n * Manages guild templates. Discord does not send them over the gateway, so they are never cached.\n */\nexport class GuildTemplateManager {\n public readonly client: GatewayClient;\n\n public constructor(client: GatewayClient) {\n this.client = client;\n }\n\n /**\n * Fetches a template by its code.\n *\n * @param code The code of the template, or its URL.\n */\n public async fetch(code: string): Promise<GuildTemplate> {\n // Accept `https://discord.new/code` as well as the bare code.\n const resolved = code.split(\"/\").pop()!;\n return this.build(await this.client.api.guilds.getTemplate(resolved));\n }\n\n /**\n * Fetches the templates of a guild.\n *\n * @param guildId The ID of the guild.\n */\n public async list(guildId: string): Promise<GuildTemplate[]> {\n const templates = await this.client.api.guilds.getTemplates(guildId);\n return Promise.all(templates.map((template) => this.build(template)));\n }\n\n /**\n * Creates a template of a guild.\n *\n * @param guildId The ID of the guild.\n * @param options The name and description of the template.\n */\n public async create(\n guildId: string,\n options: GuildTemplateCreateOptions,\n ): Promise<GuildTemplate> {\n const body: RESTPostAPIGuildTemplatesJSONBody = {\n name: options.name,\n description: options.description,\n };\n const template = await this.client.api.guilds.createTemplate(guildId, body);\n return this.build(template);\n }\n\n /**\n * Edits a template.\n *\n * @param guildId The ID of the template's guild.\n * @param code The code of the template.\n * @param options The name and description.\n */\n public async edit(\n guildId: string,\n code: string,\n options: GuildTemplateEditOptions,\n ): Promise<GuildTemplate> {\n const body: RESTPatchAPIGuildTemplateJSONBody = {\n name: options.name,\n description: options.description,\n };\n const template = await this.client.api.guilds.editTemplate(guildId, code, body);\n return this.build(template);\n }\n\n /**\n * Syncs a template with the current state of its guild.\n *\n * @param guildId The ID of the template's guild.\n * @param code The code of the template.\n */\n public async sync(guildId: string, code: string): Promise<GuildTemplate> {\n const template = await this.client.api.guilds.syncTemplate(guildId, code);\n return this.build(template);\n }\n\n /**\n * Deletes a template.\n *\n * @param guildId The ID of the template's guild.\n * @param code The code of the template.\n */\n public async delete(guildId: string, code: string): Promise<void> {\n await this.client.api.guilds.deleteTemplate(guildId, code);\n }\n\n /**\n * Creates a guild from a template, which Discord only allows to bots in fewer than 10 guilds.\n *\n * @param code The code of the template.\n * @param options The name and icon of the guild.\n */\n public async createGuild(code: string, options: GuildTemplateCreateGuildOptions): Promise<Guild> {\n const body: RESTPostAPITemplateCreateGuildJSONBody = { name: options.name, icon: options.icon };\n const guild = (await this.client.api.rest.post(Routes.template(code), {\n body,\n })) as APIGuild;\n return this.client.guilds._add(guild);\n }\n\n private async build(template: APITemplate): Promise<GuildTemplate> {\n const creator = await this.client.users._add(template.creator);\n const guild = (await this.client.guilds.get(template.source_guild_id)) ?? null;\n return new GuildTemplate(template, { guild, creator });\n }\n}\n","import { voiceStateKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { VoiceState } from \"../structures/voice/VoiceState.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { CachedManager } from \"./CachedManager.js\";\n\n/**\n * Manages the voice states of the members connected to voice channels.\n *\n * @remarks\n * The cache holds them when the bot has the `GuildVoiceStates` intent. `fetch` falls back to the API, which only\n * knows the voice states of connected members.\n */\nexport class VoiceStateManager extends CachedManager<\n \"voiceStates\",\n VoiceState,\n [guildId: string, userId: string]\n> {\n public constructor(client: GatewayClient) {\n super(client, \"voiceStates\");\n }\n\n public construct(data: CacheEntityTypes[\"voiceStates\"]): VoiceState {\n return new VoiceState(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"voiceStates\"]): string {\n if (!data.guild_id) throw new TypeError(\"Cannot key a voice state outside of a guild\");\n return this.resolveKey(data.guild_id, data.user_id);\n }\n\n public resolveKey(guildId: string, userId: string): string {\n return voiceStateKey(guildId, userId);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"voiceStates\"]): Awaitable<VoiceState> {\n const { member, guild_id: guildId, user_id: userId } = data;\n return whenAll(\n [\n member?.user && guildId\n ? this.client.members._resolveData({ ...member, guild_id: guildId })\n : guildId\n ? this.client.members._get(guildId, userId)\n : null,\n this.cachedGuild(guildId),\n data.channel_id ? this.client.channels._get(data.channel_id) : undefined,\n ],\n ([resolvedMember, guild, channel]) =>\n new VoiceState(data, { member: resolvedMember ?? null, guild, channel: channel ?? null }),\n );\n }\n\n /**\n * Lists the cached voice states of a guild.\n *\n * @param guildId The ID of the guild.\n * @returns The cached entries, `[]` when this entity is not cached.\n * @throws {TypeError} When the store cannot enumerate its entries.\n */\n public async listCached(guildId: string): Promise<VoiceState[]> {\n const prefix = `${guildId}:`;\n const entries = (await this.iterableCache()?.entries()) ?? [];\n return Promise.all(\n entries.filter(([key]) => key.startsWith(prefix)).map(([, raw]) => this.hydrate(raw)),\n );\n }\n\n protected async fetchRaw(guildId: string, userId: string) {\n const client = this.client;\n // The bot's own voice state is only reachable as `@me`.\n const target = (client.user?.id ?? client.id) === userId ? \"@me\" : userId;\n const state =\n target === \"@me\"\n ? await client.api.voice.getVoiceState(guildId)\n : await client.api.voice.getUserVoiceState(guildId, target);\n return { ...state, guild_id: guildId };\n }\n}\n","import { presenceKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { Presence } from \"../structures/presences/Presence.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { CachedManager } from \"./CachedManager.js\";\n\n/**\n * Manages the presences of guild members.\n *\n * @remarks\n * Presences only come from the gateway, with the `GuildPresences` intent: there is no API to fetch them, so `fetch`\n * rejects on a cache miss. Use `get`, which resolves to `undefined` instead.\n */\nexport class PresenceManager extends CachedManager<\n \"presences\",\n Presence,\n [guildId: string, userId: string]\n> {\n public constructor(client: GatewayClient) {\n super(client, \"presences\");\n }\n\n public construct(data: CacheEntityTypes[\"presences\"]): Presence {\n return new Presence(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"presences\"]): string {\n return this.resolveKey(data.guild_id, data.user.id);\n }\n\n public resolveKey(guildId: string, userId: string): string {\n return presenceKey(guildId, userId);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"presences\"]): Awaitable<Presence> {\n return whenAll(\n [\n this.client.users._get(data.user.id),\n this.client.members._get(data.guild_id, data.user.id),\n this.cachedGuild(data.guild_id),\n ],\n ([user, member, guild]) =>\n new Presence(data, { user: user ?? null, member: member ?? null, guild }),\n );\n }\n\n /**\n * Lists the cached presences of a guild.\n *\n * @param guildId The ID of the guild.\n * @returns The cached entries, `[]` when this entity is not cached.\n * @throws {TypeError} When the store cannot enumerate its entries.\n */\n public async listCached(guildId: string): Promise<Presence[]> {\n const prefix = `${guildId}:`;\n const entries = (await this.iterableCache()?.entries()) ?? [];\n return Promise.all(\n entries.filter(([key]) => key.startsWith(prefix)).map(([, raw]) => this.hydrate(raw)),\n );\n }\n\n protected fetchRaw(guildId: string, userId: string): Promise<CacheEntityTypes[\"presences\"]> {\n return Promise.reject(\n new Error(\n `Presences cannot be fetched from the API, they are only received from the gateway (user ${userId} of guild ${guildId} is not cached); enable the presences cache to read them later`,\n ),\n );\n }\n}\n","import type { Awaitable, CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { RawFile } from \"@discordjs/rest\";\nimport {\n ChannelType,\n type ThreadChannelType,\n type APIMessage,\n type APIThreadChannel,\n type APIThreadMember,\n type RESTPostAPIChannelThreadsJSONBody,\n type RESTPostAPIGuildForumThreadsJSONBody,\n type ThreadAutoArchiveDuration,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport type { AnnouncementThreadChannel } from \"../structures/channels/AnnouncementThreadChannel.js\";\nimport type { PrivateThreadChannel } from \"../structures/channels/PrivateThreadChannel.js\";\nimport type { PublicThreadChannel } from \"../structures/channels/PublicThreadChannel.js\";\nimport type { ThreadMember } from \"../structures/channels/ThreadMember.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport {\n MessagePayload,\n type MessageCreateOptions,\n type MessagePayloadResolvable,\n} from \"../util/messages.js\";\nimport { CachedManager } from \"./CachedManager.js\";\nimport { createChannel } from \"./ChannelManager.js\";\n\n/**\n * Any of the thread structures {@link ThreadManager} builds.\n */\nexport type AnyThreadChannel =\n | AnnouncementThreadChannel\n | PrivateThreadChannel\n | PublicThreadChannel;\n\n/**\n * The options to create a thread with.\n */\nexport interface ThreadCreateOptions {\n name: string;\n autoArchiveDuration?: ThreadAutoArchiveDuration;\n rateLimitPerUser?: number;\n /**\n * The type of a thread without a message: public (the default; an announcement thread in announcement channels) or\n * private.\n */\n type?: ChannelType.PublicThread | ChannelType.PrivateThread | ChannelType.AnnouncementThread;\n /**\n * Whether non-moderators can add members to a private thread.\n */\n invitable?: boolean;\n /**\n * The first message of a forum or media post.\n */\n message?: MessagePayloadResolvable<MessageCreateOptions>;\n /**\n * The tags of a forum or media post.\n */\n appliedTags?: readonly string[];\n reason?: string;\n}\n\n/**\n * The options to fetch archived threads with.\n */\nexport interface FetchArchivedThreadsOptions {\n /**\n * Public (the default) or private archived threads.\n */\n type?: \"public\" | \"private\";\n /**\n * Whether to fetch the private archived threads the bot joined, which needs no `ManageThreads`.\n */\n joined?: boolean;\n /**\n * The archive time (or, with `joined`, the thread ID) to fetch threads before.\n */\n before?: Date | number | string;\n limit?: number;\n}\n\n/**\n * Threads fetched in bulk, with the bot's membership of each.\n */\nexport interface FetchedThreads {\n threads: AnyThreadChannel[];\n members: ThreadMember[];\n /**\n * Whether more archived threads are left to fetch.\n */\n hasMore: boolean;\n}\n\n/**\n * Manages the threads known to the client.\n */\nexport class ThreadManager extends CachedManager<\"threads\", AnyThreadChannel, [threadId: string]> {\n public constructor(client: GatewayClient) {\n super(client, \"threads\");\n }\n\n public construct(data: CacheEntityTypes[\"threads\"]): AnyThreadChannel {\n return createChannel(data) as AnyThreadChannel;\n }\n\n public keyOf(data: CacheEntityTypes[\"threads\"]): string {\n return data.id;\n }\n\n public override _hydrate(data: CacheEntityTypes[\"threads\"]): Awaitable<AnyThreadChannel> {\n return whenAll(\n [this.cachedGuild(data.guild_id)],\n ([guild]) => this.client.channels._hydrateInGuild(data, guild) as Awaitable<AnyThreadChannel>,\n );\n }\n\n public resolveKey(threadId: string): string {\n return threadId;\n }\n\n /**\n * Creates a thread in a channel. With `message`, creates a post of a forum or media channel.\n *\n * @param channelId The ID of the parent channel.\n * @param options The thread's name and settings, and the first message of a post.\n */\n public async create(channelId: string, options: ThreadCreateOptions): Promise<AnyThreadChannel> {\n const common = {\n name: options.name,\n auto_archive_duration: options.autoArchiveDuration,\n rate_limit_per_user: options.rateLimitPerUser,\n };\n let body: RESTPostAPIChannelThreadsJSONBody | RESTPostAPIGuildForumThreadsJSONBody;\n let files: RawFile[] | undefined;\n if (options.message === undefined) {\n // Discord defaults to a private thread: pick discord.js's default, public (or announcement), client-side.\n const type = options.type ?? (await this.defaultThreadType(channelId));\n body = { ...common, type, invitable: options.invitable };\n } else {\n const message = await MessagePayload.create(this.client, options.message).resolve();\n body = { ...common, message: message.body, applied_tags: options.appliedTags?.slice() };\n files = message.files;\n }\n\n const thread = (\n options.message === undefined\n ? await this.client.api.channels.createThread(\n channelId,\n body as RESTPostAPIChannelThreadsJSONBody,\n undefined,\n { reason: options.reason },\n )\n : await this.client.api.channels.createForumThread(\n channelId,\n {\n ...(body as RESTPostAPIGuildForumThreadsJSONBody),\n message: { ...(body as RESTPostAPIGuildForumThreadsJSONBody).message, files },\n },\n { reason: options.reason },\n )\n ) as APIThreadChannel & { message?: APIMessage };\n // A forum post comes with its first message.\n if (thread.message) await this.client.messages._add(thread.message);\n return this._add(thread);\n }\n\n /**\n * Fetches the active threads of a guild, with the bot's membership of each, and caches them.\n *\n * @param guildId The ID of the guild.\n */\n public async fetchActive(guildId: string): Promise<FetchedThreads> {\n const result = await this.client.api.guilds.getActiveThreads(guildId);\n return this.storeList(result.threads as APIThreadChannel[], result.members, guildId, false);\n }\n\n /**\n * Fetches the archived threads of a channel, most recently archived first, and caches them.\n *\n * @param channelId The ID of the parent channel.\n * @param options Public or private threads (only the joined ones with `joined`), and the page.\n */\n public async fetchArchived(\n channelId: string,\n options: FetchArchivedThreadsOptions = {},\n ): Promise<FetchedThreads> {\n const query = {\n limit: options.limit,\n before:\n options.before === undefined\n ? undefined\n : options.joined\n ? String(options.before)\n : new Date(options.before).toISOString(),\n };\n const result = options.joined\n ? await this.client.api.channels.getJoinedPrivateArchivedThreads(channelId, query)\n : await this.client.api.channels.getArchivedThreads(\n channelId,\n options.type ?? \"public\",\n query,\n );\n const guildId = (result.threads[0] as { guild_id?: string } | undefined)?.guild_id;\n return this.storeList(\n result.threads as APIThreadChannel[],\n result.members,\n guildId,\n result.has_more,\n );\n }\n\n private async defaultThreadType(channelId: string): Promise<ThreadChannelType> {\n const parent = await this.client.channels.fetch(channelId);\n return parent.type === ChannelType.GuildAnnouncement\n ? ChannelType.AnnouncementThread\n : ChannelType.PublicThread;\n }\n\n private async storeList(\n threads: readonly APIThreadChannel[],\n members: readonly APIThreadMember[],\n guildId: string | undefined,\n hasMore: boolean,\n ): Promise<FetchedThreads> {\n return {\n threads: await Promise.all(threads.map((thread) => this._add(thread))),\n members: await Promise.all(\n members.map((member) =>\n this.client.threadMembers._add(guildId ? { ...member, guild_id: guildId } : member),\n ),\n ),\n hasMore,\n };\n }\n\n protected async fetchRaw(threadId: string) {\n return this.client.api.channels.get(threadId) as Promise<APIThreadChannel>;\n }\n}\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { AnyThreadChannel } from \"../../managers/ThreadManager.js\";\nimport type { GuildMember } from \"../guilds/GuildMember.js\";\nimport type { User } from \"../users/User.js\";\nimport { kData, kPatch, kRelations, Structure } from \"../Structure.js\";\n\n/**\n * The relations of a {@link ThreadMember}, resolved from the cache by `client.threadMembers`.\n */\nexport interface ThreadMemberRelations {\n /**\n * The member of the thread's guild, when the payload included it or the cache holds it.\n */\n guildMember?: GuildMember | null;\n thread?: AnyThreadChannel | null;\n user?: User | null;\n}\n\n/**\n * A member of a thread: a user who joined it, or was added to it.\n */\nexport class ThreadMember extends Structure<CacheEntityTypes[\"threadMembers\"]> {\n declare public [kRelations]: ThreadMemberRelations;\n\n protected override optimizeData(data: Partial<CacheEntityTypes[\"threadMembers\"]>): void {\n this.optimizeTimestamp(\"join_timestamp\", data.join_timestamp);\n }\n\n /**\n * @param data The raw thread member.\n * @param relations The guild member, thread, and user as resolved from the cache, by `client.threadMembers`.\n */\n public constructor(\n data: CacheEntityTypes[\"threadMembers\"],\n relations: ThreadMemberRelations = {},\n ) {\n super(data, relations);\n }\n\n public override [kPatch](data: Readonly<Partial<CacheEntityTypes[\"threadMembers\"]>>): this {\n if (data.member) this.dropRelations(\"guildMember\");\n return super[kPatch](data);\n }\n\n /**\n * The ID of the user. Absent only from the thread member the gateway attaches to a thread payload for the bot.\n */\n public get id(): string | null {\n return this[kData].user_id ?? null;\n }\n\n public get threadId(): string | null {\n return this[kData].id ?? null;\n }\n\n /**\n * Whether the thread member is partial: built from its IDs alone for an event about an uncached thread member, see\n * `Partials.ThreadMember`. Only `id`, `threadId`, and `guildId` are reliable then, and {@link ThreadMember.fetch}\n * completes it.\n */\n public get partial(): boolean {\n return this[kData].flags === undefined;\n }\n\n /**\n * Fetches the thread member from the API and patches this structure with the result.\n */\n public async fetch(): Promise<this> {\n const { threadId, id } = this;\n if (!threadId || !id)\n throw new Error(\"A thread member without a thread or user ID cannot be fetched\");\n const member = await this.client.threadMembers.fetch(threadId, id, { force: true });\n return this[kPatch](member.toJSON());\n }\n\n public get joinedTimestamp(): number {\n return this.optimizedTimestamp(\"join_timestamp\")!;\n }\n\n public get joinedAt(): Date {\n return new Date(this.joinedTimestamp);\n }\n\n /**\n * The thread member's notification flags.\n */\n public get flags(): number {\n return this[kData].flags;\n }\n\n /**\n * The member of the thread's guild, when known.\n */\n public get guildMember(): GuildMember | null {\n return this[kRelations].guildMember ?? null;\n }\n\n /**\n * The thread, from the cache, like discord.js's `ThreadMember#thread`. `null` when it is not cached, or when the\n * thread member was not built by a manager.\n */\n public get thread(): AnyThreadChannel | null {\n return this[kRelations].thread ?? null;\n }\n\n /**\n * The user, from the cache, like discord.js's `ThreadMember#user`, else the user of the guild member.\n */\n public get user(): User | null {\n return this[kRelations].user ?? this.guildMember?.user ?? null;\n }\n\n /**\n * Removes the member from the thread.\n */\n public async remove(): Promise<this> {\n const { id, threadId } = this;\n if (!id || !threadId) throw new Error(\"Cannot remove a thread member without its IDs\");\n await this.client.threadMembers.remove(threadId, id);\n return this;\n }\n}\n","import { threadMemberKey, type Awaitable, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport { Routes, type APIThreadMember } from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { ThreadMember } from \"../structures/channels/ThreadMember.js\";\nimport { whenAll } from \"../util/cache.js\";\nimport { CachedManager, type AddOptions } from \"./CachedManager.js\";\n\n/**\n * The options to list the members of a thread with.\n */\nexport interface ThreadMemberListOptions {\n /**\n * Whether to include each member's guild member.\n */\n withMember?: boolean;\n /**\n * How many members to fetch, up to 100. Paginating requires `withMember`.\n */\n limit?: number;\n after?: string;\n}\n\n/**\n * Manages the members of every thread known to the client.\n */\nexport class ThreadMemberManager extends CachedManager<\n \"threadMembers\",\n ThreadMember,\n [threadId: string, userId: string]\n> {\n public constructor(client: GatewayClient) {\n super(client, \"threadMembers\");\n }\n\n public construct(data: CacheEntityTypes[\"threadMembers\"]): ThreadMember {\n return new ThreadMember(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"threadMembers\"]): string {\n if (!data.id || !data.user_id) {\n throw new TypeError(\"Cannot key a thread member without its IDs\");\n }\n\n return this.resolveKey(data.id, data.user_id);\n }\n\n public resolveKey(threadId: string, userId: string): string {\n return threadMemberKey(threadId, userId);\n }\n\n /**\n * Adds a thread member to the cache, and its guild member to `client.members`.\n *\n * @internal\n */\n public override async _add(\n data: CacheEntityTypes[\"threadMembers\"],\n cache = true,\n options?: AddOptions,\n ): Promise<ThreadMember> {\n const { member, guild_id: guildId } = data;\n if (member?.user && guildId) {\n await this.client.members._add({ ...member, guild_id: guildId }, cache);\n }\n\n return super._add(data, cache, options);\n }\n\n public override _hydrate(data: CacheEntityTypes[\"threadMembers\"]): Awaitable<ThreadMember> {\n const { member, guild_id: guildId, user_id: userId } = data;\n return whenAll(\n [\n member?.user && guildId\n ? this.client.members._resolveData({ ...member, guild_id: guildId })\n : guildId && userId\n ? this.client.members._get(guildId, userId)\n : null,\n data.id ? this.client.threads._get(data.id) : undefined,\n userId ? this.client.users._get(userId) : undefined,\n ],\n ([guildMember, thread, user]) =>\n new ThreadMember(data, {\n guildMember: guildMember ?? null,\n thread: thread ?? null,\n user: user ?? null,\n }),\n );\n }\n\n /**\n * Fetches a member of a thread from the API, bypassing the cache, and caches it.\n *\n * @param threadId The ID of the thread.\n * @param userId The ID of the user.\n * @param options Whether to include the guild member.\n */\n public async fetchWithMember(\n threadId: string,\n userId: string,\n options: { withMember?: boolean } = {},\n ): Promise<ThreadMember> {\n const member = options.withMember\n ? ((await this.client.api.rest.get(Routes.threadMembers(threadId, userId), {\n query: new URLSearchParams({ with_member: \"true\" }),\n })) as APIThreadMember)\n : await this.client.api.threads.getMember(threadId, userId);\n return this._add(await this.withGuildId(threadId, member));\n }\n\n /**\n * Lists the members of a thread, and caches them.\n *\n * @param threadId The ID of the thread.\n * @param options Whether to include the guild members, and the page.\n */\n public async list(\n threadId: string,\n options: ThreadMemberListOptions = {},\n ): Promise<ThreadMember[]> {\n const members =\n options.withMember || options.limit || options.after\n ? ((await this.client.api.rest.get(Routes.threadMembers(threadId), {\n query: new URLSearchParams({\n with_member: String(options.withMember ?? false),\n ...(options.limit && { limit: String(options.limit) }),\n ...(options.after && { after: options.after }),\n }),\n })) as APIThreadMember[])\n : await this.client.api.threads.getAllMembers(threadId);\n const guildId = await this.guildIdOf(threadId);\n return Promise.all(\n members.map((member) => this._add(guildId ? { ...member, guild_id: guildId } : member)),\n );\n }\n\n /**\n * Adds a user to a thread.\n *\n * @param threadId The ID of the thread.\n * @param userId The ID of the user, `\"@me\"` (the default) to join it.\n */\n public async add(threadId: string, userId = \"@me\"): Promise<void> {\n if (userId === \"@me\") await this.client.api.threads.join(threadId);\n else await this.client.api.threads.addMember(threadId, userId);\n }\n\n /**\n * Removes a user from a thread, and from the cache.\n *\n * @param threadId The ID of the thread.\n * @param userId The ID of the user, `\"@me\"` (the default) to leave it.\n */\n public async remove(threadId: string, userId = \"@me\"): Promise<void> {\n if (userId === \"@me\") await this.client.api.threads.leave(threadId);\n else await this.client.api.threads.removeMember(threadId, userId);\n const cachedId = userId === \"@me\" ? (this.client.user?.id ?? this.client.id) : userId;\n await this.cache?.delete(this.resolveKey(threadId, cachedId));\n }\n\n protected async fetchRaw(threadId: string, userId: string) {\n const member = await this.client.api.threads.getMember(threadId, userId);\n return this.withGuildId(threadId, member);\n }\n\n // Thread members from REST lack the guild's ID, which resolving their guild member needs.\n private async withGuildId(\n threadId: string,\n member: APIThreadMember,\n ): Promise<CacheEntityTypes[\"threadMembers\"]> {\n const guildId = await this.guildIdOf(threadId);\n return guildId ? { ...member, guild_id: guildId } : member;\n }\n\n private async guildIdOf(threadId: string): Promise<string | undefined> {\n const thread = await this.client.threads.get(threadId);\n return (thread?.toJSON() as { guild_id?: string } | undefined)?.guild_id;\n }\n}\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport type { DMChannel } from \"../structures/channels/DMChannel.js\";\nimport type { Message } from \"../structures/messages/Message.js\";\nimport { User } from \"../structures/users/User.js\";\nimport type { MessageCreateOptions, MessagePayloadResolvable } from \"../util/messages.js\";\nimport { CachedManager } from \"./CachedManager.js\";\n\n/**\n * Manages the {@link User}s known to the client.\n */\nexport class UserManager extends CachedManager<\"users\", User, [userId: string]> {\n public constructor(client: GatewayClient) {\n super(client, \"users\");\n }\n\n public construct(data: CacheEntityTypes[\"users\"]): User {\n return new User(data);\n }\n\n public keyOf(data: CacheEntityTypes[\"users\"]): string {\n return data.id;\n }\n\n public resolveKey(userId: string): string {\n return userId;\n }\n\n /**\n * Opens a direct message channel with a user, or gets the existing one, and caches it.\n *\n * @remarks\n * Discord returns the existing channel when there is one, so this always calls the API: unlike discord.js, there is\n * no synchronous `dmChannel` lookup to try first.\n *\n * @param userId The ID of the user.\n */\n public async createDM(userId: string): Promise<DMChannel> {\n const channel = await this.client.api.users.createDM(userId);\n return (await this.client.channels._add(channel)) as DMChannel;\n }\n\n /**\n * Closes the direct message channel with a user.\n *\n * @param userId The ID of the user.\n * @returns The closed channel.\n */\n public async deleteDM(userId: string): Promise<DMChannel> {\n const channel = await this.createDM(userId);\n await this.client.api.channels.delete(channel.id);\n await this.client.cache?.channels?.delete(channel.id);\n return channel;\n }\n\n /**\n * Sends a direct message to a user.\n *\n * @param userId The ID of the user.\n * @param options The message, or its content.\n */\n public async send(\n userId: string,\n options: MessagePayloadResolvable<MessageCreateOptions>,\n ): Promise<Message> {\n const channel = await this.createDM(userId);\n return this.client.messages.send(channel.id, options);\n }\n\n protected async fetchRaw(userId: string) {\n return this.client.api.users.get(userId);\n }\n}\n","import { InviteType } from \"discord-api-types/v10\";\nimport { BaseInvite, type InviteData, type InviteRelations } from \"./BaseInvite.js\";\nimport { GuildInvite } from \"./GuildInvite.js\";\n\n/**\n * An invite to a group direct message. Its channel (name, icon, recipients) is exposed as `channel`.\n */\nexport class GroupDMInvite extends BaseInvite {}\n\n/**\n * Builds the invite structure matching the type of a raw invite.\n *\n * @param data The raw invite.\n * @param relations The related structures, resolved from the cache.\n */\nexport function createInvite(data: InviteData, relations: InviteRelations = {}): BaseInvite {\n switch (data.type ?? (data.guild_id || data.guild ? InviteType.Guild : InviteType.Friend)) {\n case InviteType.Guild:\n return new GuildInvite(data, relations);\n case InviteType.GroupDM:\n return new GroupDMInvite(data, relations);\n default:\n return new BaseInvite(data, relations);\n }\n}\n","import {\n GuildWidgetStyle,\n RouteBases,\n Routes,\n type APIGuildWidget,\n type APIGuildWidgetMember,\n} from \"discord-api-types/v10\";\nimport { kData, Structure } from \"../Structure.js\";\n\n/**\n * A member shown by a guild's widget. Its ID is only an index, not the user's: the widget hides who they are.\n */\nexport class WidgetMember extends Structure<APIGuildWidgetMember> {\n public get id() {\n return this[kData].id;\n }\n\n public get username() {\n return this[kData].username;\n }\n\n public get discriminator() {\n return this[kData].discriminator;\n }\n\n public get avatar() {\n return this[kData].avatar;\n }\n\n public get avatarURL() {\n return this[kData].avatar_url;\n }\n\n public get status() {\n return this[kData].status;\n }\n\n /**\n * The name of what the member is playing, if anything.\n */\n public get activity(): string | null {\n return this[kData].activity?.name ?? null;\n }\n}\n\n/**\n * The public widget of a guild: its online members and voice channels.\n */\nexport class Widget extends Structure<APIGuildWidget> {\n public get id() {\n return this[kData].id;\n }\n\n public get name() {\n return this[kData].name;\n }\n\n /**\n * The invite of the widget's channel, if it has one.\n */\n public get instantInvite() {\n return this[kData].instant_invite;\n }\n\n /**\n * The voice channels everyone can join.\n */\n public get channels() {\n return this[kData].channels;\n }\n\n /**\n * The online members, up to 100.\n */\n public get members(): WidgetMember[] {\n return this[kData].members.map((member) => new WidgetMember(member));\n }\n\n public get presenceCount() {\n return this[kData].presence_count;\n }\n\n /**\n * Gets the URL of the widget's image.\n *\n * @param style The style of the image.\n */\n public imageURL(style: GuildWidgetStyle = GuildWidgetStyle.Shield): string {\n return `${RouteBases.api}${Routes.guildWidgetImage(this.id)}?style=${style}`;\n }\n\n /**\n * Fetches the current state of the widget.\n */\n public fetch(): Promise<Widget> {\n return this.client.fetchGuildWidget(this.id);\n }\n}\n","import type { BaseImageURLOptions } from \"@discordjs/rest\";\nimport { StickerPack as BaseStickerPack } from \"@discordjs/structures\";\nimport type { APIStickerPack } from \"discord-api-types/v10\";\nimport { cdn } from \"../../util/cdn.js\";\nimport { Sticker } from \"./Sticker.js\";\nimport { Mixin } from \"../Mixin.js\";\nimport { initStructure, kData, snowflakeTimestamp, StructureMixin } from \"../Structure.js\";\n\nexport interface StickerPack extends StructureMixin<APIStickerPack> {}\n\n/**\n * A pack of standard stickers: `@discordjs/structures`' `StickerPack`, with its stickers and banner URL.\n */\nexport class StickerPack extends BaseStickerPack {\n /**\n * @param data The raw sticker pack.\n * @param relations The related structures, resolved from the cache.\n */\n public constructor(data: APIStickerPack, relations: object = {}) {\n super(data);\n initStructure(this, data, relations);\n }\n\n /**\n * The ID of the pack's banner asset, `null` if it has none.\n */\n public get bannerId(): string | null {\n return this.bannerAssetId ?? null;\n }\n\n public get stickers(): Sticker[] {\n return this[kData].stickers.map((sticker) => new Sticker(sticker));\n }\n\n /**\n * The sticker shown as the pack's cover, if any.\n */\n public get coverSticker(): Sticker | null {\n const { coverStickerId } = this;\n return this.stickers.find((sticker) => sticker.id === coverStickerId) ?? null;\n }\n\n public override get createdTimestamp(): number {\n return snowflakeTimestamp(this.id);\n }\n\n public get createdAt() {\n return new Date(this.createdTimestamp);\n }\n\n /**\n * Gets the URL of the pack's banner, or `null` if it has none.\n * @param options The image options.\n */\n public bannerURL(options?: BaseImageURLOptions): string | null {\n const { bannerId } = this;\n return bannerId ? cdn.stickerPackBanner(bannerId, options) : null;\n }\n}\n\nMixin(StickerPack, [StructureMixin]);\n","import type { GatewayAutoModerationActionExecutionDispatchData } from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { AutoModerationRule } from \"./AutoModerationRule.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport type { GuildMember } from \"../guilds/GuildMember.js\";\nimport { kData, kRelations, Structure } from \"../Structure.js\";\nimport type { User } from \"../users/User.js\";\n\n/**\n * The relations of an {@link AutoModerationActionExecution}, resolved from the cache.\n */\nexport interface AutoModerationActionExecutionRelations {\n guild?: Guild | null;\n user?: User | null;\n member?: GuildMember | null;\n channel?: AnyChannel | null;\n autoModerationRule?: AutoModerationRule | null;\n}\n\n/**\n * An action auto moderation took on a message or a member.\n */\nexport class AutoModerationActionExecution extends Structure<GatewayAutoModerationActionExecutionDispatchData> {\n declare public [kRelations]: AutoModerationActionExecutionRelations;\n\n /**\n * @param data The raw execution.\n * @param relations The guild and user as resolved from the cache.\n */\n public constructor(\n data: GatewayAutoModerationActionExecutionDispatchData,\n relations: AutoModerationActionExecutionRelations = {},\n ) {\n super(data, relations);\n }\n\n public get guildId() {\n return this[kData].guild_id;\n }\n\n /**\n * The action taken: blocking the message, alerting a channel, or timing the member out.\n */\n public get action() {\n return this[kData].action;\n }\n\n public get ruleId() {\n return this[kData].rule_id;\n }\n\n public get ruleTriggerType() {\n return this[kData].rule_trigger_type;\n }\n\n public get userId() {\n return this[kData].user_id;\n }\n\n public get channelId(): string | null {\n return this[kData].channel_id ?? null;\n }\n\n /**\n * The ID of the message that triggered the rule. Absent when the message was blocked.\n */\n public get messageId(): string | null {\n return this[kData].message_id ?? null;\n }\n\n /**\n * The ID of the alert message sent to the alert channel, for `SendAlertMessage` actions.\n */\n public get alertSystemMessageId(): string | null {\n return this[kData].alert_system_message_id ?? null;\n }\n\n /**\n * The content that triggered the rule. Needs the `MessageContent` intent.\n */\n public get content() {\n return this[kData].content;\n }\n\n public get matchedKeyword(): string | null {\n return this[kData].matched_keyword;\n }\n\n public get matchedContent(): string | null {\n return this[kData].matched_content;\n }\n\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n public get user(): User | null {\n return this[kRelations].user ?? null;\n }\n\n /**\n * The member who triggered the rule, from the cache, like discord.js's `AutoModerationActionExecution#member`.\n */\n public get member(): GuildMember | null {\n return this[kRelations].member ?? null;\n }\n\n /**\n * The channel the rule was triggered in, from the cache: `null` when there is none or it is not cached.\n */\n public get channel(): AnyChannel | null {\n return this[kRelations].channel ?? null;\n }\n\n /**\n * The rule that was triggered, from the cache: `null` when it is not cached.\n */\n public get autoModerationRule(): AutoModerationRule | null {\n return this[kRelations].autoModerationRule ?? null;\n }\n\n public fetchRule(): Promise<AutoModerationRule> {\n return this.client.guilds.autoModerationRules(this.guildId).fetch(this.ruleId);\n }\n\n public fetchMember(): Promise<GuildMember> {\n return this.client.members.fetch(this.guildId, this.userId);\n }\n\n public async fetchChannel(): Promise<AnyChannel | null> {\n const { channelId } = this;\n return channelId ? this.client.channels.fetch(channelId) : null;\n }\n}\n","import {\n ActivityType,\n GatewayOpcodes,\n PresenceUpdateStatus,\n type GatewayActivityUpdateData,\n type GatewayPresenceUpdateData,\n type RESTPatchAPICurrentUserJSONBody,\n} from \"discord-api-types/v10\";\nimport { kData, kPatch } from \"../Structure.js\";\nimport { User } from \"./User.js\";\n\n/**\n * The presence to set for the bot user. Omitted fields keep their current value.\n */\nexport interface PresenceData {\n status?: PresenceUpdateStatus;\n afk?: boolean;\n activities?: GatewayActivityUpdateData[];\n /**\n * The shards to update, every shard by default.\n */\n shardId?: number | readonly number[];\n}\n\n/**\n * An activity to set, with its type defaulting to `Playing`.\n */\nexport interface ActivityOptions extends Omit<GatewayActivityUpdateData, \"name\" | \"type\"> {\n type?: ActivityType;\n /**\n * The shards to update, every shard by default.\n */\n shardId?: number | readonly number[];\n}\n\n/**\n * The options to edit the bot user with. Images are data URIs (`data:image/png;base64,...`), `null` removes them.\n */\nexport interface ClientUserEditOptions {\n username?: string;\n avatar?: string | null;\n banner?: string | null;\n}\n\n/**\n * The bot user, as known to the {@link GatewayClient}: a {@link User} that can edit its profile and presence.\n */\nexport class ClientUser extends User {\n #presence: GatewayPresenceUpdateData = {\n since: null,\n activities: [],\n status: PresenceUpdateStatus.Online,\n afk: false,\n };\n\n /**\n * Whether the bot's owner account has two-factor authentication enabled.\n */\n public get mfaEnabled(): boolean {\n return this[kData].mfa_enabled ?? false;\n }\n\n /**\n * Whether the bot is verified.\n */\n public get verified(): boolean {\n return this[kData].verified ?? false;\n }\n\n /**\n * The presence last set through this structure.\n */\n public get presence(): Readonly<GatewayPresenceUpdateData> {\n return this.#presence;\n }\n\n /**\n * Edits the bot user's profile.\n *\n * @param options The fields to edit.\n */\n public async edit(options: ClientUserEditOptions): Promise<this> {\n const body: RESTPatchAPICurrentUserJSONBody = options;\n const user = await this.client.api.users.edit(body);\n await this.client.users._add(user);\n return this[kPatch](user);\n }\n\n public setUsername(username: string): Promise<this> {\n return this.edit({ username });\n }\n\n public setAvatar(avatar: string | null): Promise<this> {\n return this.edit({ avatar });\n }\n\n public setBanner(banner: string | null): Promise<this> {\n return this.edit({ banner });\n }\n\n /**\n * Sets the bot's presence on its shards.\n *\n * @param data The presence to set.\n */\n public async setPresence(data: PresenceData): Promise<Readonly<GatewayPresenceUpdateData>> {\n const { shardId, ...presence } = data;\n this.#presence = {\n ...this.#presence,\n ...presence,\n since: presence.afk ? Date.now() : this.#presence.since,\n };\n\n const gateway = this.client.gateway;\n const shards =\n shardId === undefined\n ? await gateway.getShardIds()\n : typeof shardId === \"number\"\n ? [shardId]\n : shardId;\n await Promise.all(\n shards.map((id) =>\n gateway.send(id, { op: GatewayOpcodes.PresenceUpdate, d: this.#presence }),\n ),\n );\n return this.#presence;\n }\n\n public setStatus(status: PresenceUpdateStatus, shardId?: number | readonly number[]) {\n return this.setPresence({ status, shardId });\n }\n\n /**\n * Sets the bot's activity, or clears it when called without a name.\n *\n * @param name The activity's name.\n * @param options The activity's type and other fields.\n */\n public setActivity(name?: string, options: ActivityOptions = {}) {\n const { shardId, type = ActivityType.Playing, ...activity } = options;\n return this.setPresence({\n activities: name === undefined ? [] : [{ ...activity, name, type }],\n shardId,\n });\n }\n\n public setAFK(afk = true, shardId?: number | readonly number[]) {\n return this.setPresence({ afk, shardId });\n }\n}\n","import type { GatewayTypingStartDispatchData } from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\nimport type { Guild } from \"../guilds/Guild.js\";\nimport { GuildMember } from \"../guilds/GuildMember.js\";\nimport { kData, kRelations, Structure } from \"../Structure.js\";\nimport { User } from \"../users/User.js\";\n\n/**\n * The relations of a {@link Typing}, resolved from the cache by the `typingStart` event.\n */\nexport interface TypingRelations {\n channel?: AnyChannel | null;\n user?: User | null;\n guild?: Guild | null;\n member?: GuildMember | null;\n}\n\n/**\n * A user starting to type in a channel, carried by the `typingStart` event.\n */\nexport class Typing extends Structure<GatewayTypingStartDispatchData> {\n declare public [kRelations]: TypingRelations;\n\n /**\n * @param data The raw dispatch.\n * @param relations The channel, user, guild, and member as resolved from the cache.\n */\n public constructor(data: GatewayTypingStartDispatchData, relations: TypingRelations = {}) {\n super(data, relations);\n }\n public get channelId() {\n return this[kData].channel_id;\n }\n\n public get guildId(): string | null {\n return this[kData].guild_id ?? null;\n }\n\n public get userId() {\n return this[kData].user_id;\n }\n\n /**\n * The time the user started typing, in milliseconds.\n */\n public get startedTimestamp(): number {\n return this[kData].timestamp * 1000;\n }\n\n public get startedAt(): Date {\n return new Date(this.startedTimestamp);\n }\n\n /**\n * The channel the user typed in, from the cache, like discord.js's `Typing#channel`: `null` when it is not cached.\n */\n public get channel(): AnyChannel | null {\n return this[kRelations].channel ?? null;\n }\n\n /**\n * The typing user, from the cache, else the user of the payload's member: `null` in a direct message whose user is\n * not cached.\n */\n public get user(): User | null {\n const resolved = this[kRelations].user;\n if (resolved) return resolved;\n const user = this[kData].member?.user;\n return user ? new User(user) : null;\n }\n\n /**\n * The guild of the channel, from the cache: `null` outside of guilds or when it is not cached.\n */\n public get guild(): Guild | null {\n return this[kRelations].guild ?? null;\n }\n\n /**\n * The typing member, when the channel is in a guild: the cached member, else the one of the payload.\n */\n public get member(): GuildMember | null {\n const resolved = this[kRelations].member;\n if (resolved) return resolved;\n const { member, guild_id: guildId } = this[kData];\n return member && guildId ? new GuildMember({ ...member, guild_id: guildId }) : null;\n }\n\n /**\n * Whether the user typed in a guild channel.\n */\n public inGuild(): boolean {\n return this.guildId !== null;\n }\n\n /**\n * Fetches the channel the user typed in.\n */\n public fetchChannel(): Promise<AnyChannel> {\n return this.client.channels.fetch(this.channelId);\n }\n\n /**\n * Fetches the typing user.\n */\n public fetchUser(): Promise<User> {\n return this.client.users.fetch(this.userId);\n }\n}\n","import type {\n GatewayChannelPinsUpdateDispatchData,\n GatewayDispatchPayload,\n GatewayGuildDeleteDispatchData,\n GatewayGuildIntegrationsUpdateDispatchData,\n GatewayIntegrationDeleteDispatchData,\n GatewayGuildMemberRemoveDispatchData,\n GatewayGuildMembersChunkDispatchData,\n GatewayGuildRoleDeleteDispatchData,\n GatewayInviteDeleteDispatchData,\n GatewayMessageDeleteBulkDispatchData,\n GatewayMessageDeleteDispatchData,\n GatewayMessageReactionRemoveAllDispatchData,\n ReactionType,\n GatewayGuildScheduledEventUserAddDispatchData,\n GatewayGuildScheduledEventUserRemoveDispatchData,\n GatewayGuildSoundboardSoundDeleteDispatchData,\n GatewayThreadDeleteDispatchData,\n GatewayThreadListSync,\n GatewayThreadMembersUpdateDispatchData,\n GatewayVoiceServerUpdateDispatchData,\n GatewayWebhooksUpdateDispatchData,\n} from \"discord-api-types/v10\";\nimport type { CacheEntityName } from \"@wolfstar/plugin-cache\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport type { AnyChannel } from \"../managers/ChannelManager.js\";\nimport type { AnyThreadChannel } from \"../managers/ThreadManager.js\";\nimport type { AutoModerationActionExecution } from \"../structures/automoderation/AutoModerationActionExecution.js\";\nimport type { AutoModerationRule } from \"../structures/automoderation/AutoModerationRule.js\";\nimport type { Guild } from \"../structures/guilds/Guild.js\";\nimport type { GuildAuditLogsEntry } from \"../structures/guilds/GuildAuditLogsEntry.js\";\nimport type { GuildBan } from \"../structures/guilds/GuildBan.js\";\nimport type { GuildScheduledEvent } from \"../structures/guilds/GuildScheduledEvent.js\";\nimport type { Integration } from \"../structures/guilds/Integration.js\";\nimport type { SoundboardSound } from \"../structures/soundboards/SoundboardSound.js\";\nimport type { StageInstance } from \"../structures/stageInstances/StageInstance.js\";\nimport type { GuildEmoji } from \"../structures/emojis/GuildEmoji.js\";\nimport type { GuildInvite } from \"../structures/invites/GuildInvite.js\";\nimport type { GuildMember } from \"../structures/guilds/GuildMember.js\";\nimport type { Message } from \"../structures/messages/Message.js\";\nimport type { MessageReaction } from \"../structures/messages/MessageReaction.js\";\nimport type { PollAnswer } from \"../structures/polls/PollAnswer.js\";\nimport type { Role } from \"../structures/guilds/Role.js\";\nimport type { Presence } from \"../structures/presences/Presence.js\";\nimport type { Sticker } from \"../structures/stickers/Sticker.js\";\nimport type { ThreadMember } from \"../structures/channels/ThreadMember.js\";\nimport type { Typing } from \"../structures/channels/Typing.js\";\nimport type { User } from \"../structures/users/User.js\";\nimport type { VoiceState } from \"../structures/voice/VoiceState.js\";\n\n/**\n * Where a cache failure reported by the `cacheError` event happened.\n */\nexport interface CacheErrorContext {\n /**\n * The entity cache that failed.\n */\n entity: CacheEntityName;\n /**\n * The key of the entry, `null` for operations spanning the whole cache.\n */\n key: string | null;\n /**\n * The operation that failed.\n */\n operation: \"get\" | \"set\" | \"upsert\" | \"delete\";\n}\n\n/**\n * What a reaction event says besides the reaction and the user.\n */\nexport interface MessageReactionEventDetails {\n /**\n * The ID of the user who reacted, known even when the user is not.\n */\n userId: string;\n type: ReactionType;\n /**\n * Whether the reaction is a super reaction.\n */\n burst: boolean;\n}\n\n/**\n * The events a {@link GatewayClient} emits on top of the base `Client`'s ones, and their arguments.\n *\n * @remarks\n * Update events receive the previous state of the entity as read from the cache before the dispatch was applied, or\n * `null` when it was not cached. Delete events receive the cached entity (or `null`) alongside the raw dispatch data,\n * which always identifies the deleted entity.\n *\n * With the matching `Partials` enabled, uncached messages, users, members, thread members, scheduled events,\n * soundboard sounds, polls, and direct messages are partial structures (`partial` is `true`) instead of `null`.\n */\nexport interface GatewayEventMap {\n /**\n * Emitted for every gateway dispatch, before any processing, with the raw payload.\n */\n raw: [payload: GatewayDispatchPayload, shardId: number];\n /**\n * Emitted for every gateway dispatch once it has been written to the cache (right away without one), before the\n * matching event, with the raw payload. Unlike `raw`, a listener reading the cache sees the dispatch applied, which\n * is what forwarding it to other processes sharing the cache needs.\n *\n * @remarks\n * Not emitted for `INTERACTION_CREATE`, served by the HTTP endpoint, nor for a dispatch dropped because its cache\n * write failed with {@link GatewayClientOptions.cacheFailure} set to `\"skip\"`.\n */\n dispatch: [payload: GatewayDispatchPayload, shardId: number];\n /**\n * Emitted when a shard receives `READY`.\n */\n shardReady: [shardId: number, user: User];\n /**\n * Emitted once, when every shard this client manages has connected and every guild `READY` listed as initially\n * unavailable became available, or {@link GatewayClientOptions.waitGuildTimeout} elapsed, like discord.js's\n * `Client#clientReady` (`ready` before discord.js deprecated it).\n */\n clientReady: [client: GatewayClient];\n /**\n * Emitted when a shard resumes its session.\n */\n shardResume: [shardId: number];\n /**\n * Emitted when a shard's connection closes, it reconnects on its own unless the close code is fatal.\n */\n shardClose: [shardId: number, code: number];\n /**\n * Emitted when a shard runs into an error.\n */\n shardError: [error: Error, shardId: number];\n /**\n * Emitted when a manager's cache read or write fails, e.g. while Redis is unreachable. With the default\n * `cacheErrors: \"miss\"`, the manager then carries on as if the entry was not cached.\n */\n cacheError: [error: unknown, context: CacheErrorContext];\n\n guildCreate: [guild: Guild];\n guildUpdate: [oldGuild: Guild | null, newGuild: Guild];\n /**\n * Emitted when the client leaves a guild, or when it becomes unavailable because of an outage, in which case\n * `data.unavailable` is `true`.\n */\n guildDelete: [guild: Guild | null, data: GatewayGuildDeleteDispatchData];\n\n channelCreate: [channel: AnyChannel];\n channelUpdate: [oldChannel: AnyChannel | null, newChannel: AnyChannel];\n channelDelete: [channel: AnyChannel];\n /**\n * Emitted when a message is pinned or unpinned; `data.last_pin_timestamp` is the time of the last pin left.\n */\n channelPinsUpdate: [data: GatewayChannelPinsUpdateDispatchData];\n /**\n * Emitted when a webhook of a channel is created, updated, or deleted.\n */\n webhooksUpdate: [data: GatewayWebhooksUpdateDispatchData];\n\n threadCreate: [thread: AnyThreadChannel];\n threadUpdate: [oldThread: AnyThreadChannel | null, newThread: AnyThreadChannel];\n threadDelete: [thread: AnyThreadChannel | null, data: GatewayThreadDeleteDispatchData];\n /**\n * Emitted when the bot gains access to a channel's threads, with the active ones and the bot's membership of each.\n */\n threadListSync: [\n threads: AnyThreadChannel[],\n members: ThreadMember[],\n data: GatewayThreadListSync,\n ];\n /**\n * Emitted when the bot's own thread member changes, e.g. its notification settings.\n */\n threadMemberUpdate: [oldMember: ThreadMember | null, newMember: ThreadMember];\n /**\n * Emitted when members are added to or removed from a thread. The removed members are the ones the cache held.\n */\n threadMembersUpdate: [\n added: ThreadMember[],\n removed: ThreadMember[],\n thread: AnyThreadChannel | null,\n data: GatewayThreadMembersUpdateDispatchData,\n ];\n\n messageCreate: [message: Message];\n messageUpdate: [oldMessage: Message | null, newMessage: Message];\n messageDelete: [message: Message | null, data: GatewayMessageDeleteDispatchData];\n messageDeleteBulk: [messages: Message[], data: GatewayMessageDeleteBulkDispatchData];\n\n /**\n * Emitted when a user reacts to a message. The reaction has its counts when the message is cached (`count` is\n * `null` otherwise), and the user is `null` when neither the payload (outside of guilds) nor the cache has it.\n */\n messageReactionAdd: [\n reaction: MessageReaction,\n user: User | null,\n details: MessageReactionEventDetails,\n ];\n /**\n * Emitted when a user removes their reaction. Like `messageReactionAdd`, `count` is `null` only when the message is\n * not cached: removing the last reaction of an emoji from a cached message gives a count of `0`.\n */\n messageReactionRemove: [\n reaction: MessageReaction,\n user: User | null,\n details: MessageReactionEventDetails,\n ];\n /**\n * Emitted when every reaction is removed from a message, with the reactions the cache held.\n */\n messageReactionRemoveAll: [\n message: Message | null,\n reactions: MessageReaction[],\n data: GatewayMessageReactionRemoveAllDispatchData,\n ];\n /**\n * Emitted when every reaction with one emoji is removed from a message.\n */\n messageReactionRemoveEmoji: [reaction: MessageReaction];\n /**\n * Emitted when a user votes for a poll answer. The answer has its text and counts when the message is cached.\n */\n messagePollVoteAdd: [answer: PollAnswer, userId: string];\n messagePollVoteRemove: [answer: PollAnswer, userId: string];\n\n guildMemberAdd: [member: GuildMember];\n guildMemberUpdate: [oldMember: GuildMember | null, newMember: GuildMember];\n guildMemberRemove: [member: GuildMember | null, data: GatewayGuildMemberRemoveDispatchData];\n /**\n * Emitted for each chunk of members Discord sends in answer to `client.members.request`, once it is cached.\n * `data` has the chunk's index and count, its nonce, and the requested IDs that are not members (`not_found`).\n */\n guildMembersChunk: [\n members: GuildMember[],\n guild: Guild | null,\n data: GatewayGuildMembersChunkDispatchData,\n ];\n\n guildRoleCreate: [role: Role];\n guildRoleUpdate: [oldRole: Role | null, newRole: Role];\n guildRoleDelete: [role: Role | null, data: GatewayGuildRoleDeleteDispatchData];\n\n userUpdate: [oldUser: User | null, newUser: User];\n\n /**\n * Emitted for every `GUILD_EMOJIS_UPDATE`, with every emoji the guild now has. Always emitted, cache or not: the\n * granular `emojiCreate`, `emojiUpdate`, and `emojiDelete` need the previous emojis, so the emojis cache.\n */\n guildEmojisUpdate: [guildId: string, emojis: GuildEmoji[]];\n /**\n * Emitted for each emoji a `GUILD_EMOJIS_UPDATE` adds, compared with the cache. Without an emojis cache (able to\n * enumerate its entries), the emoji events are not emitted: listen to `guildEmojisUpdate` instead.\n */\n emojiCreate: [emoji: GuildEmoji];\n emojiUpdate: [oldEmoji: GuildEmoji, newEmoji: GuildEmoji];\n emojiDelete: [emoji: GuildEmoji];\n\n /**\n * Emitted for every `GUILD_STICKERS_UPDATE`, with every sticker the guild now has, like `guildEmojisUpdate`.\n */\n guildStickersUpdate: [guildId: string, stickers: Sticker[]];\n /**\n * Emitted for each sticker a `GUILD_STICKERS_UPDATE` adds, compared with the cache, like the emoji events.\n */\n stickerCreate: [sticker: Sticker];\n stickerUpdate: [oldSticker: Sticker, newSticker: Sticker];\n stickerDelete: [sticker: Sticker];\n\n inviteCreate: [invite: GuildInvite];\n /**\n * Emitted when an invite is deleted or expires, with the cached invite if any.\n */\n inviteDelete: [invite: GuildInvite | null, data: GatewayInviteDeleteDispatchData];\n\n typingStart: [typing: Typing];\n /**\n * Emitted when a guild's voice server changes, e.g. to hand a voice connection a new endpoint.\n */\n voiceServerUpdate: [data: GatewayVoiceServerUpdateDispatchData];\n\n /**\n * Emitted when a user is banned. Bans from the gateway have no reason.\n */\n guildScheduledEventCreate: [event: GuildScheduledEvent];\n guildScheduledEventUpdate: [oldEvent: GuildScheduledEvent | null, newEvent: GuildScheduledEvent];\n guildScheduledEventDelete: [event: GuildScheduledEvent];\n /**\n * Emitted when a user subscribes to a scheduled event, with the cached event and user when there are.\n */\n guildScheduledEventUserAdd: [\n event: GuildScheduledEvent | null,\n user: User | null,\n data: GatewayGuildScheduledEventUserAddDispatchData,\n ];\n guildScheduledEventUserRemove: [\n event: GuildScheduledEvent | null,\n user: User | null,\n data: GatewayGuildScheduledEventUserRemoveDispatchData,\n ];\n stageInstanceCreate: [stageInstance: StageInstance];\n stageInstanceUpdate: [oldStageInstance: StageInstance | null, newStageInstance: StageInstance];\n stageInstanceDelete: [stageInstance: StageInstance];\n guildSoundboardSoundCreate: [sound: SoundboardSound];\n guildSoundboardSoundUpdate: [oldSound: SoundboardSound | null, newSound: SoundboardSound];\n /**\n * Emitted when a soundboard sound is deleted, with the cached sound when there is one.\n */\n guildSoundboardSoundDelete: [\n sound: SoundboardSound | null,\n data: GatewayGuildSoundboardSoundDeleteDispatchData,\n ];\n /**\n * Emitted when several soundboard sounds of a guild change at once.\n */\n guildSoundboardSoundsUpdate: [sounds: SoundboardSound[], guildId: string];\n /**\n * Emitted with the sounds of a guild, in answer to a request for them over the gateway.\n */\n soundboardSounds: [sounds: SoundboardSound[], guildId: string];\n\n guildBanAdd: [ban: GuildBan];\n /**\n * Emitted when a ban is lifted, with the cached ban (and its reason, if it was fetched) when there is one.\n */\n guildBanRemove: [ban: GuildBan];\n /**\n * Emitted when an entry is added to a guild's audit log. Needs the `GuildModeration` intent.\n */\n guildAuditLogEntryCreate: [entry: GuildAuditLogsEntry];\n autoModerationRuleCreate: [rule: AutoModerationRule];\n autoModerationRuleUpdate: [oldRule: AutoModerationRule | null, newRule: AutoModerationRule];\n autoModerationRuleDelete: [rule: AutoModerationRule];\n /**\n * Emitted when auto moderation takes an action. Needs the `AutoModerationExecution` intent.\n */\n autoModerationActionExecution: [execution: AutoModerationActionExecution];\n /**\n * Emitted when an integration of a guild is created, updated, or deleted.\n */\n guildIntegrationsUpdate: [guild: Guild | null, data: GatewayGuildIntegrationsUpdateDispatchData];\n integrationCreate: [integration: Integration];\n integrationUpdate: [oldIntegration: Integration | null, newIntegration: Integration];\n integrationDelete: [integration: Integration | null, data: GatewayIntegrationDeleteDispatchData];\n /**\n * Emitted when a member joins, leaves, or moves between voice channels, or changes their voice settings.\n */\n voiceStateUpdate: [oldState: VoiceState | null, newState: VoiceState];\n /**\n * Emitted when a member's status or activities change. Needs the `GuildPresences` intent.\n */\n presenceUpdate: [oldPresence: Presence | null, newPresence: Presence];\n}\n\n/**\n * The name of any of the events listed in {@link GatewayEventMap}.\n */\nexport type GatewayEventName = keyof GatewayEventMap;\n\n/**\n * The name of every event a {@link GatewayClient} emits, mirroring the keys of {@link GatewayEventMap}, like\n * `@wolfstar/http-framework`'s own `Events`.\n *\n * @remarks\n * Each member's value is the plain event name, so they are interchangeable with the string literals accepted by\n * `GatewayClient#on`, `GatewayClient#emit`, and `Listener.Options.event`.\n *\n * @example\n * ```typescript\n * client.on(GatewayEvents.MessageCreate, (message) => console.log(message.content));\n * ```\n */\nexport enum GatewayEvents {\n Raw = \"raw\",\n Dispatch = \"dispatch\",\n ShardReady = \"shardReady\",\n ClientReady = \"clientReady\",\n ShardResume = \"shardResume\",\n ShardClose = \"shardClose\",\n ShardError = \"shardError\",\n CacheError = \"cacheError\",\n GuildCreate = \"guildCreate\",\n GuildUpdate = \"guildUpdate\",\n GuildDelete = \"guildDelete\",\n ChannelCreate = \"channelCreate\",\n ChannelUpdate = \"channelUpdate\",\n ChannelDelete = \"channelDelete\",\n ChannelPinsUpdate = \"channelPinsUpdate\",\n WebhooksUpdate = \"webhooksUpdate\",\n ThreadCreate = \"threadCreate\",\n ThreadUpdate = \"threadUpdate\",\n ThreadDelete = \"threadDelete\",\n ThreadListSync = \"threadListSync\",\n ThreadMemberUpdate = \"threadMemberUpdate\",\n ThreadMembersUpdate = \"threadMembersUpdate\",\n MessageCreate = \"messageCreate\",\n MessageUpdate = \"messageUpdate\",\n MessageDelete = \"messageDelete\",\n MessageDeleteBulk = \"messageDeleteBulk\",\n MessageReactionAdd = \"messageReactionAdd\",\n MessageReactionRemove = \"messageReactionRemove\",\n MessageReactionRemoveAll = \"messageReactionRemoveAll\",\n MessageReactionRemoveEmoji = \"messageReactionRemoveEmoji\",\n MessagePollVoteAdd = \"messagePollVoteAdd\",\n MessagePollVoteRemove = \"messagePollVoteRemove\",\n GuildMemberAdd = \"guildMemberAdd\",\n GuildMemberUpdate = \"guildMemberUpdate\",\n GuildMemberRemove = \"guildMemberRemove\",\n GuildMembersChunk = \"guildMembersChunk\",\n GuildRoleCreate = \"guildRoleCreate\",\n GuildRoleUpdate = \"guildRoleUpdate\",\n GuildRoleDelete = \"guildRoleDelete\",\n UserUpdate = \"userUpdate\",\n GuildEmojisUpdate = \"guildEmojisUpdate\",\n EmojiCreate = \"emojiCreate\",\n EmojiUpdate = \"emojiUpdate\",\n EmojiDelete = \"emojiDelete\",\n GuildStickersUpdate = \"guildStickersUpdate\",\n StickerCreate = \"stickerCreate\",\n StickerUpdate = \"stickerUpdate\",\n StickerDelete = \"stickerDelete\",\n InviteCreate = \"inviteCreate\",\n InviteDelete = \"inviteDelete\",\n TypingStart = \"typingStart\",\n VoiceServerUpdate = \"voiceServerUpdate\",\n GuildScheduledEventCreate = \"guildScheduledEventCreate\",\n GuildScheduledEventUpdate = \"guildScheduledEventUpdate\",\n GuildScheduledEventDelete = \"guildScheduledEventDelete\",\n GuildScheduledEventUserAdd = \"guildScheduledEventUserAdd\",\n GuildScheduledEventUserRemove = \"guildScheduledEventUserRemove\",\n StageInstanceCreate = \"stageInstanceCreate\",\n StageInstanceUpdate = \"stageInstanceUpdate\",\n StageInstanceDelete = \"stageInstanceDelete\",\n GuildSoundboardSoundCreate = \"guildSoundboardSoundCreate\",\n GuildSoundboardSoundUpdate = \"guildSoundboardSoundUpdate\",\n GuildSoundboardSoundDelete = \"guildSoundboardSoundDelete\",\n GuildSoundboardSoundsUpdate = \"guildSoundboardSoundsUpdate\",\n SoundboardSounds = \"soundboardSounds\",\n GuildBanAdd = \"guildBanAdd\",\n GuildBanRemove = \"guildBanRemove\",\n GuildAuditLogEntryCreate = \"guildAuditLogEntryCreate\",\n AutoModerationRuleCreate = \"autoModerationRuleCreate\",\n AutoModerationRuleUpdate = \"autoModerationRuleUpdate\",\n AutoModerationRuleDelete = \"autoModerationRuleDelete\",\n AutoModerationActionExecution = \"autoModerationActionExecution\",\n GuildIntegrationsUpdate = \"guildIntegrationsUpdate\",\n IntegrationCreate = \"integrationCreate\",\n IntegrationUpdate = \"integrationUpdate\",\n IntegrationDelete = \"integrationDelete\",\n VoiceStateUpdate = \"voiceStateUpdate\",\n PresenceUpdate = \"presenceUpdate\",\n}\n\ndeclare module \"@wolfstar/http-framework\" {\n interface ClientEvents extends GatewayEventMap {}\n}\n","/**\n * The structures a `GatewayClient` builds partially when an event concerns one it has not cached, like discord.js's\n * `Partials`. Pass them to `GatewayClientOptions.partials`.\n *\n * @remarks\n * Unlike discord.js, events are always emitted, even without the matching partial: an uncached entity is `null` then,\n * as it always was. With the partial enabled, it is a structure built from the IDs the dispatch carries instead, whose\n * `partial` is `true`: only its IDs are reliable, and `fetch()` completes it. Partial structures are never written to\n * the cache.\n *\n * `Reaction` and `PollAnswer` are accepted for parity only: the reaction and the poll answer of an uncached message\n * have always been emitted, and are partial whether or not they are enabled.\n */\nexport const Partials = {\n User: 0,\n Channel: 1,\n GuildMember: 2,\n Message: 3,\n Reaction: 4,\n GuildScheduledEvent: 5,\n ThreadMember: 6,\n Poll: 7,\n PollAnswer: 8,\n SoundboardSound: 9,\n} as const;\n\n/**\n * One of the {@link Partials}.\n */\nexport type Partials = (typeof Partials)[keyof typeof Partials];\n","import {\n ChannelType,\n GatewayDispatchEvents,\n type APIPartialEmoji,\n type APIUser,\n type GatewayDispatchPayload,\n type GatewayMessagePollVoteDispatchData,\n} from \"discord-api-types/v10\";\nimport {\n isIterableCache,\n type Awaitable,\n type CacheEntityTypes,\n type EntityCache,\n} from \"@wolfstar/plugin-cache\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { AutoModerationActionExecution } from \"../structures/automoderation/AutoModerationActionExecution.js\";\nimport { ClientUser } from \"../structures/users/ClientUser.js\";\nimport { GuildAuditLogsEntry } from \"../structures/guilds/GuildAuditLogsEntry.js\";\nimport { bindClient, kPatch } from \"../structures/Structure.js\";\nimport type { GuildEmoji } from \"../structures/emojis/GuildEmoji.js\";\nimport { createChannel } from \"../managers/ChannelManager.js\";\nimport type { DMChannel } from \"../structures/channels/DMChannel.js\";\nimport { GuildMember } from \"../structures/guilds/GuildMember.js\";\nimport { GuildScheduledEvent } from \"../structures/guilds/GuildScheduledEvent.js\";\nimport { GuildInvite } from \"../structures/invites/GuildInvite.js\";\nimport type { Sticker } from \"../structures/stickers/Sticker.js\";\nimport { Message } from \"../structures/messages/Message.js\";\nimport { MessageReaction } from \"../structures/messages/MessageReaction.js\";\nimport { Poll } from \"../structures/polls/Poll.js\";\nimport { PollAnswer } from \"../structures/polls/PollAnswer.js\";\nimport { SoundboardSound } from \"../structures/soundboards/SoundboardSound.js\";\nimport { ThreadMember } from \"../structures/channels/ThreadMember.js\";\nimport { User } from \"../structures/users/User.js\";\nimport { Typing } from \"../structures/channels/Typing.js\";\nimport { resolveAuditLogTarget } from \"./auditLogs.js\";\nimport { GatewayEvents, type GatewayEventMap, type GatewayEventName } from \"./events.js\";\nimport { Partials } from \"./Partials.js\";\n\n/**\n * The data of the dispatch of type `Type`.\n */\nexport type DispatchData<Type extends GatewayDispatchEvents> = Extract<\n GatewayDispatchPayload,\n { t: Type }\n>[\"d\"];\n\n/**\n * Describes how a gateway dispatch turns into a {@link GatewayEventMap} event.\n *\n * @typeParam Type The dispatch type.\n * @typeParam Event The event emitted for it.\n */\nexport interface DispatchHandler<\n Type extends GatewayDispatchEvents,\n Event extends GatewayEventName,\n> {\n /**\n * The event to emit.\n */\n event: Event;\n /**\n * Runs before the dispatch is written to the cache, used to read the previous state of the entity.\n */\n before?(client: GatewayClient, data: DispatchData<Type>): Promise<unknown>;\n /**\n * Runs after the dispatch is written to the cache, and builds the arguments of the event.\n *\n * @param state The value `before` resolved to, if any.\n */\n build(\n client: GatewayClient,\n data: DispatchData<Type>,\n state: any,\n shardId: number,\n ): Awaitable<GatewayEventMap[Event]>;\n}\n\n/**\n * An event with its arguments, as emitted by a {@link MultiDispatchHandler}.\n */\nexport type GatewayEventTuple = {\n [Event in GatewayEventName]: [event: Event, ...args: GatewayEventMap[Event]];\n}[GatewayEventName];\n\n/**\n * Describes how a gateway dispatch turns into any number of {@link GatewayEventMap} events, e.g. one per emoji a\n * `GUILD_EMOJIS_UPDATE` changes.\n */\nexport interface MultiDispatchHandler<Type extends GatewayDispatchEvents> {\n /**\n * Runs before the dispatch is written to the cache, used to read the previous state.\n */\n before?(client: GatewayClient, data: DispatchData<Type>): Promise<unknown>;\n /**\n * Runs after the dispatch is written to the cache, and lists the events to emit, in order.\n */\n emit(client: GatewayClient, data: DispatchData<Type>, state: any): Awaitable<GatewayEventTuple[]>;\n}\n\n/**\n * A {@link DispatchHandler} for the dispatch of type `Type`, emitting any event.\n */\nexport type AnyDispatchHandler<Type extends GatewayDispatchEvents> = {\n [Event in GatewayEventName]: DispatchHandler<Type, Event>;\n}[GatewayEventName];\n\n/**\n * The table mapping every supported dispatch to its event.\n *\n * @remarks\n * `INTERACTION_CREATE` is deliberately absent: interactions are served by the HTTP endpoint, and the gateway may\n * deliver some of them as well. Dispatches without an entry are still written to the cache and emitted as `raw`.\n */\nexport const DispatchHandlers: { [Type in GatewayDispatchEvents]?: AnyDispatchHandler<Type> } = {\n [GatewayDispatchEvents.Ready]: {\n event: GatewayEvents.ShardReady,\n build: (client, data, _state, shardId) => {\n const user = new ClientUser(data.user);\n client.user = user;\n return [shardId, user];\n },\n },\n\n [GatewayDispatchEvents.GuildCreate]: {\n event: GatewayEvents.GuildCreate,\n // The cached entry has the collections stripped, prefer it over the (much larger) payload.\n build: async (client, data) => [\n (await cachedOrUndefined(client.guilds.get(data.id))) ??\n (await client.guilds.hydrate(data as CacheEntityTypes[\"guilds\"])),\n ],\n },\n [GatewayDispatchEvents.GuildUpdate]: {\n event: GatewayEvents.GuildUpdate,\n before: (client, data) => client.guilds.get(data.id),\n build: async (client, data, previous) => [previous ?? null, await client.guilds.hydrate(data)],\n },\n [GatewayDispatchEvents.GuildDelete]: {\n event: GatewayEvents.GuildDelete,\n before: (client, data) => client.guilds.get(data.id),\n build: (_client, data, previous) => [previous ?? null, data],\n },\n\n [GatewayDispatchEvents.ChannelCreate]: {\n event: GatewayEvents.ChannelCreate,\n build: async (client, data) => [await client.channels.hydrate(data)],\n },\n [GatewayDispatchEvents.ChannelUpdate]: {\n event: GatewayEvents.ChannelUpdate,\n before: (client, data) => client.channels.get(data.id),\n build: async (client, data, previous) => [\n previous ?? null,\n await client.channels.hydrate(data),\n ],\n },\n [GatewayDispatchEvents.ChannelDelete]: {\n event: GatewayEvents.ChannelDelete,\n build: async (client, data) => [await client.channels.hydrate(data)],\n },\n\n [GatewayDispatchEvents.ChannelPinsUpdate]: {\n event: GatewayEvents.ChannelPinsUpdate,\n build: (_client, data) => [data],\n },\n [GatewayDispatchEvents.WebhooksUpdate]: {\n event: GatewayEvents.WebhooksUpdate,\n build: (_client, data) => [data],\n },\n\n [GatewayDispatchEvents.ThreadCreate]: {\n event: GatewayEvents.ThreadCreate,\n build: async (client, data) => [await client.threads.hydrate(data)],\n },\n [GatewayDispatchEvents.ThreadUpdate]: {\n event: GatewayEvents.ThreadUpdate,\n before: (client, data) => client.threads.get(data.id),\n build: async (client, data, previous) => [previous ?? null, await client.threads.hydrate(data)],\n },\n [GatewayDispatchEvents.ThreadDelete]: {\n event: GatewayEvents.ThreadDelete,\n before: (client, data) => client.threads.get(data.id),\n build: (_client, data, previous) => [previous ?? null, data],\n },\n\n [GatewayDispatchEvents.ThreadListSync]: {\n event: GatewayEvents.ThreadListSync,\n build: async (client, data) => [\n await Promise.all(data.threads.map((thread) => client.threads.hydrate(thread as never))),\n await Promise.all(\n data.members.map((member) =>\n client.threadMembers.hydrate({ ...member, guild_id: data.guild_id }),\n ),\n ),\n data,\n ],\n },\n [GatewayDispatchEvents.ThreadMemberUpdate]: {\n event: GatewayEvents.ThreadMemberUpdate,\n before: (client, data) =>\n data.id && data.user_id\n ? client.threadMembers.get(data.id, data.user_id)\n : Promise.resolve(undefined),\n build: async (client, data, previous) => [\n previous ??\n (data.id && data.user_id\n ? partialThreadMember(client, data.id, data.user_id, data.guild_id)\n : null),\n await client.threadMembers.hydrate(data),\n ],\n },\n [GatewayDispatchEvents.ThreadMembersUpdate]: {\n event: GatewayEvents.ThreadMembersUpdate,\n before: async (client, data) => {\n const removed = await Promise.all(\n (data.removed_member_ids ?? []).map((userId) => client.threadMembers.get(data.id, userId)),\n );\n return removed.filter((member) => member !== undefined);\n },\n build: async (client, data, previous: ThreadMember[] | undefined) => [\n await Promise.all(\n (data.added_members ?? []).map((member) =>\n client.threadMembers.hydrate({ ...member, id: data.id, guild_id: data.guild_id }),\n ),\n ),\n withPartials(previous ?? [], data.removed_member_ids ?? [], (userId) =>\n partialThreadMember(client, data.id, userId, data.guild_id),\n ),\n (await cachedOrUndefined(client.threads.get(data.id))) ?? null,\n data,\n ],\n },\n\n [GatewayDispatchEvents.MessageCreate]: {\n event: GatewayEvents.MessageCreate,\n build: async (client, data) => [await client.messages.hydrate(data)],\n },\n [GatewayDispatchEvents.MessageUpdate]: {\n event: GatewayEvents.MessageUpdate,\n before: (client, data) => client.messages.get(data.channel_id, data.id),\n build: async (client, data, previous) => [\n previous ?? partialMessage(client, data.channel_id, data.id, data.guild_id),\n await client.messages.hydrate(data),\n ],\n },\n [GatewayDispatchEvents.MessageDelete]: {\n event: GatewayEvents.MessageDelete,\n before: (client, data) => client.messages.get(data.channel_id, data.id),\n build: (client, data, previous) => [\n previous ?? partialMessage(client, data.channel_id, data.id, data.guild_id),\n data,\n ],\n },\n [GatewayDispatchEvents.MessageDeleteBulk]: {\n event: GatewayEvents.MessageDeleteBulk,\n before: async (client, data) => {\n const messages = await Promise.all(\n data.ids.map((id) => client.messages.get(data.channel_id, id)),\n );\n return messages.filter((message) => message !== undefined);\n },\n build: (client, data, previous: Message[] | undefined) => [\n withPartials(previous ?? [], data.ids, (id) =>\n partialMessage(client, data.channel_id, id, data.guild_id),\n ),\n data,\n ],\n },\n\n [GatewayDispatchEvents.MessageReactionAdd]: {\n event: GatewayEvents.MessageReactionAdd,\n build: async (client, data) => [\n await reactionOf(client, data),\n (await cachedOrUndefined(client.users.get(data.user_id))) ??\n partialUser(client, data.user_id),\n { userId: data.user_id, type: data.type, burst: data.burst },\n ],\n },\n [GatewayDispatchEvents.MessageReactionRemove]: {\n event: GatewayEvents.MessageReactionRemove,\n build: async (client, data) => [\n await reactionOf(client, data),\n (await cachedOrUndefined(client.users.get(data.user_id))) ??\n partialUser(client, data.user_id),\n { userId: data.user_id, type: data.type, burst: data.burst },\n ],\n },\n [GatewayDispatchEvents.MessageReactionRemoveAll]: {\n event: GatewayEvents.MessageReactionRemoveAll,\n before: async (client, data) =>\n (await client.messages.get(data.channel_id, data.message_id))?.reactions.cache ?? [],\n build: async (client, data, previous: MessageReaction[] | undefined) => [\n (await cachedOrUndefined(client.messages.get(data.channel_id, data.message_id))) ??\n partialMessage(client, data.channel_id, data.message_id, data.guild_id),\n previous ?? [],\n data,\n ],\n },\n [GatewayDispatchEvents.MessageReactionRemoveEmoji]: {\n event: GatewayEvents.MessageReactionRemoveEmoji,\n before: async (client, data) =>\n (await client.messages.get(data.channel_id, data.message_id))?.reactions.resolve(\n data.emoji,\n ) ?? undefined,\n build: async (client, data, previous: MessageReaction | undefined) => [\n previous ?? (await partialReaction(client, data)),\n ],\n },\n [GatewayDispatchEvents.MessagePollVoteAdd]: {\n event: GatewayEvents.MessagePollVoteAdd,\n build: async (client, data) => [await pollAnswerOf(client, data), data.user_id],\n },\n [GatewayDispatchEvents.MessagePollVoteRemove]: {\n event: GatewayEvents.MessagePollVoteRemove,\n build: async (client, data) => [await pollAnswerOf(client, data), data.user_id],\n },\n\n [GatewayDispatchEvents.GuildMemberAdd]: {\n event: GatewayEvents.GuildMemberAdd,\n build: async (client, data) => [await client.members.hydrate(data)],\n },\n [GatewayDispatchEvents.GuildMemberUpdate]: {\n event: GatewayEvents.GuildMemberUpdate,\n before: (client, data) => client.members.get(data.guild_id, data.user.id),\n // The payload is partial: prefer the cached entry, which it was merged into.\n build: async (client, data, previous) => [\n previous ?? partialMember(client, data.guild_id, { id: data.user.id }),\n (await cachedOrUndefined(client.members.get(data.guild_id, data.user.id))) ??\n (await client.members.hydrate(data as CacheEntityTypes[\"members\"])),\n ],\n },\n [GatewayDispatchEvents.GuildMemberRemove]: {\n event: GatewayEvents.GuildMemberRemove,\n before: (client, data) => client.members.get(data.guild_id, data.user.id),\n build: (client, data, previous) => [\n previous ?? partialMember(client, data.guild_id, data.user),\n data,\n ],\n },\n [GatewayDispatchEvents.GuildMembersChunk]: {\n event: GatewayEvents.GuildMembersChunk,\n build: async (client, data) => {\n const [members, guild] = await Promise.all([\n Promise.all(\n data.members.map((member) =>\n client.members.hydrate({ ...member, guild_id: data.guild_id }),\n ),\n ),\n cachedOrUndefined(client.guilds.get(data.guild_id)),\n ]);\n // The chunk is cached by now, so a request resolving with it is followed by reads that see it.\n client.members.handleChunk(members, data);\n return [members, guild ?? null, data];\n },\n },\n\n [GatewayDispatchEvents.GuildRoleCreate]: {\n event: GatewayEvents.GuildRoleCreate,\n build: async (client, data) => [\n await client.roles.hydrate({ ...data.role, guild_id: data.guild_id }),\n ],\n },\n [GatewayDispatchEvents.GuildRoleUpdate]: {\n event: GatewayEvents.GuildRoleUpdate,\n before: (client, data) => client.roles.get(data.guild_id, data.role.id),\n build: async (client, data, previous) => [\n previous ?? null,\n await client.roles.hydrate({ ...data.role, guild_id: data.guild_id }),\n ],\n },\n [GatewayDispatchEvents.GuildRoleDelete]: {\n event: GatewayEvents.GuildRoleDelete,\n before: (client, data) => client.roles.get(data.guild_id, data.role_id),\n build: (_client, data, previous) => [previous ?? null, data],\n },\n\n [GatewayDispatchEvents.InviteCreate]: {\n event: GatewayEvents.InviteCreate,\n build: async (client, data) => [\n data.guild_id\n ? await client.guilds.invites(data.guild_id).hydrate(data)\n : bindClient(\n new GuildInvite(data, {\n channel: (await cachedOrUndefined(client.channels.get(data.channel_id))) ?? null,\n }),\n client,\n ),\n ],\n },\n [GatewayDispatchEvents.InviteDelete]: {\n event: GatewayEvents.InviteDelete,\n before: async (client, data) =>\n data.guild_id ? client.guilds.invites(data.guild_id).get(data.code) : undefined,\n build: (_client, data, previous) => [previous ?? null, data],\n },\n\n [GatewayDispatchEvents.TypingStart]: {\n event: GatewayEvents.TypingStart,\n build: async (client, data) => [await typingOf(client, data)],\n },\n [GatewayDispatchEvents.VoiceStateUpdate]: {\n event: GatewayEvents.VoiceStateUpdate,\n before: async (client, data) =>\n data.guild_id ? client.voiceStates.get(data.guild_id, data.user_id) : undefined,\n build: async (client, data, previous) => [\n previous ?? null,\n await client.voiceStates.hydrate(data),\n ],\n },\n [GatewayDispatchEvents.PresenceUpdate]: {\n event: GatewayEvents.PresenceUpdate,\n before: (client, data) => client.presences.get(data.guild_id, data.user.id),\n // The payload may be partial: prefer the cached entry, which it was merged into.\n build: async (client, data, previous) => [\n previous ?? null,\n (await cachedOrUndefined(client.presences.get(data.guild_id, data.user.id))) ??\n (await client.presences.hydrate(data)),\n ],\n },\n [GatewayDispatchEvents.GuildScheduledEventCreate]: {\n event: GatewayEvents.GuildScheduledEventCreate,\n build: async (client, data) => [\n await client.guilds.scheduledEvents(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.GuildScheduledEventUpdate]: {\n event: GatewayEvents.GuildScheduledEventUpdate,\n before: (client, data) => client.guilds.scheduledEvents(data.guild_id).get(data.id),\n build: async (client, data, previous) => [\n previous ?? partialScheduledEvent(client, data.guild_id, data.id),\n await client.guilds.scheduledEvents(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.GuildScheduledEventDelete]: {\n event: GatewayEvents.GuildScheduledEventDelete,\n build: async (client, data) => [\n await client.guilds.scheduledEvents(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.GuildScheduledEventUserAdd]: {\n event: GatewayEvents.GuildScheduledEventUserAdd,\n build: async (client, data) => [\n (await cachedOrUndefined(\n client.guilds.scheduledEvents(data.guild_id).get(data.guild_scheduled_event_id),\n )) ?? partialScheduledEvent(client, data.guild_id, data.guild_scheduled_event_id),\n (await cachedOrUndefined(client.users.get(data.user_id))) ??\n partialUser(client, data.user_id),\n data,\n ],\n },\n [GatewayDispatchEvents.GuildScheduledEventUserRemove]: {\n event: GatewayEvents.GuildScheduledEventUserRemove,\n build: async (client, data) => [\n (await cachedOrUndefined(\n client.guilds.scheduledEvents(data.guild_id).get(data.guild_scheduled_event_id),\n )) ?? partialScheduledEvent(client, data.guild_id, data.guild_scheduled_event_id),\n (await cachedOrUndefined(client.users.get(data.user_id))) ??\n partialUser(client, data.user_id),\n data,\n ],\n },\n [GatewayDispatchEvents.StageInstanceCreate]: {\n event: GatewayEvents.StageInstanceCreate,\n build: async (client, data) => [\n await client.guilds.stageInstances(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.StageInstanceUpdate]: {\n event: GatewayEvents.StageInstanceUpdate,\n before: (client, data) => client.guilds.stageInstances(data.guild_id).get(data.channel_id),\n build: async (client, data, previous) => [\n previous ?? null,\n await client.guilds.stageInstances(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.StageInstanceDelete]: {\n event: GatewayEvents.StageInstanceDelete,\n build: async (client, data) => [\n await client.guilds.stageInstances(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.GuildSoundboardSoundCreate]: {\n event: GatewayEvents.GuildSoundboardSoundCreate,\n build: async (client, data) => [\n await client.guilds.soundboardSounds(data.guild_id!).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.GuildSoundboardSoundUpdate]: {\n event: GatewayEvents.GuildSoundboardSoundUpdate,\n before: (client, data) => client.guilds.soundboardSounds(data.guild_id!).get(data.sound_id),\n build: async (client, data, previous) => [\n previous ?? partialSoundboardSound(client, data.guild_id!, data.sound_id),\n await client.guilds.soundboardSounds(data.guild_id!).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.GuildSoundboardSoundDelete]: {\n event: GatewayEvents.GuildSoundboardSoundDelete,\n before: (client, data) => client.guilds.soundboardSounds(data.guild_id).get(data.sound_id),\n build: (client, data, previous) => [\n previous ?? partialSoundboardSound(client, data.guild_id, data.sound_id),\n data,\n ],\n },\n [GatewayDispatchEvents.GuildSoundboardSoundsUpdate]: {\n event: GatewayEvents.GuildSoundboardSoundsUpdate,\n build: async (client, data) => {\n const sounds = client.guilds.soundboardSounds(data.guild_id);\n return [\n await Promise.all(data.soundboard_sounds.map((sound) => sounds.hydrate(sound))),\n data.guild_id,\n ];\n },\n },\n [GatewayDispatchEvents.SoundboardSounds]: {\n event: GatewayEvents.SoundboardSounds,\n build: async (client, data) => {\n const sounds = client.guilds.soundboardSounds(data.guild_id);\n return [\n await Promise.all(data.soundboard_sounds.map((sound) => sounds.hydrate(sound))),\n data.guild_id,\n ];\n },\n },\n\n [GatewayDispatchEvents.GuildBanAdd]: {\n event: GatewayEvents.GuildBanAdd,\n build: async (client, data) => [await client.guilds.bans(data.guild_id).hydrate(data)],\n },\n [GatewayDispatchEvents.GuildBanRemove]: {\n event: GatewayEvents.GuildBanRemove,\n before: (client, data) => client.guilds.bans(data.guild_id).get(data.user.id),\n build: async (client, data, previous) => [\n previous ?? (await client.guilds.bans(data.guild_id).hydrate(data)),\n ],\n },\n [GatewayDispatchEvents.GuildAuditLogEntryCreate]: {\n event: GatewayEvents.GuildAuditLogEntryCreate,\n build: async (client, data) => {\n const [executor, guild, target] = await Promise.all([\n data.user_id ? cachedOrUndefined(client.users.get(data.user_id)) : undefined,\n cachedOrUndefined(client.guilds.get(data.guild_id)),\n resolveAuditLogTarget(client, data),\n ]);\n return [\n bindClient(\n new GuildAuditLogsEntry(data, {\n executor: executor ?? null,\n guild: guild ?? null,\n target,\n }),\n client,\n ),\n ];\n },\n },\n [GatewayDispatchEvents.AutoModerationRuleCreate]: {\n event: GatewayEvents.AutoModerationRuleCreate,\n build: async (client, data) => [\n await client.guilds.autoModerationRules(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.AutoModerationRuleUpdate]: {\n event: GatewayEvents.AutoModerationRuleUpdate,\n before: (client, data) => client.guilds.autoModerationRules(data.guild_id).get(data.id),\n build: async (client, data, previous) => [\n previous ?? null,\n await client.guilds.autoModerationRules(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.AutoModerationRuleDelete]: {\n event: GatewayEvents.AutoModerationRuleDelete,\n build: async (client, data) => [\n await client.guilds.autoModerationRules(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.GuildIntegrationsUpdate]: {\n event: GatewayEvents.GuildIntegrationsUpdate,\n build: async (client, data) => [\n (await cachedOrUndefined(client.guilds.get(data.guild_id))) ?? null,\n data,\n ],\n },\n [GatewayDispatchEvents.IntegrationCreate]: {\n event: GatewayEvents.IntegrationCreate,\n build: async (client, data) => [await client.guilds.integrations(data.guild_id).hydrate(data)],\n },\n [GatewayDispatchEvents.IntegrationUpdate]: {\n event: GatewayEvents.IntegrationUpdate,\n before: (client, data) => client.guilds.integrations(data.guild_id).get(data.id),\n build: async (client, data, previous) => [\n previous ?? null,\n await client.guilds.integrations(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.IntegrationDelete]: {\n event: GatewayEvents.IntegrationDelete,\n before: (client, data) => client.guilds.integrations(data.guild_id).get(data.id),\n build: (_client, data, previous) => [previous ?? null, data],\n },\n\n [GatewayDispatchEvents.AutoModerationActionExecution]: {\n event: GatewayEvents.AutoModerationActionExecution,\n build: async (client, data) => {\n const [user, guild, member, channel, autoModerationRule] = await Promise.all([\n cachedOrUndefined(client.users.get(data.user_id)),\n cachedOrUndefined(client.guilds.get(data.guild_id)),\n cachedOrUndefined(client.members.get(data.guild_id, data.user_id)),\n data.channel_id ? cachedOrUndefined(client.channels.get(data.channel_id)) : undefined,\n cachedOrUndefined(client.guilds.autoModerationRules(data.guild_id).get(data.rule_id)),\n ]);\n return [\n bindClient(\n new AutoModerationActionExecution(data, {\n user: user ?? null,\n guild: guild ?? null,\n member: member ?? null,\n channel: channel ?? null,\n autoModerationRule: autoModerationRule ?? null,\n }),\n client,\n ),\n ];\n },\n },\n [GatewayDispatchEvents.VoiceServerUpdate]: {\n event: GatewayEvents.VoiceServerUpdate,\n build: (_client, data) => [data],\n },\n\n [GatewayDispatchEvents.UserUpdate]: {\n event: GatewayEvents.UserUpdate,\n before: (client, data) => client.users.get(data.id),\n build: async (client, data, previous) => {\n // The bot's own updates keep `client.user` a `ClientUser`, with its presence.\n if (client.user?.id === data.id) {\n client.user[kPatch](data);\n return [previous ?? partialUser(client, data.id), client.user];\n }\n\n return [previous ?? partialUser(client, data.id), await client.users.hydrate(data)];\n },\n },\n};\n\n/**\n * The table of the dispatches that turn into several events, diffed against the cache.\n *\n * @remarks\n * Their aggregate event (e.g. `guildEmojisUpdate`) is always emitted. Without a cache there is nothing to diff\n * against, so the granular events are not.\n */\nexport const MultiDispatchHandlers: {\n [Type in GatewayDispatchEvents]?: MultiDispatchHandler<Type>;\n} = {\n [GatewayDispatchEvents.GuildEmojisUpdate]: {\n before: (client, data) =>\n cachedList(client.cache?.emojis, () => client.guilds.emojis(data.guild_id).listCached()),\n emit: async (client, data, previous: GuildEmoji[] | undefined) => {\n const emojis = client.guilds.emojis(data.guild_id);\n const current = await Promise.all(\n data.emojis.map((emoji) => emojis.hydrate({ ...emoji, guild_id: data.guild_id })),\n );\n const events: GatewayEventTuple[] = [\n [GatewayEvents.GuildEmojisUpdate, data.guild_id, current],\n ];\n if (!previous) return events;\n return events.concat(\n diff(\n previous,\n current,\n GatewayEvents.EmojiCreate,\n GatewayEvents.EmojiUpdate,\n GatewayEvents.EmojiDelete,\n ),\n );\n },\n },\n [GatewayDispatchEvents.GuildStickersUpdate]: {\n before: (client, data) =>\n cachedList(client.cache?.stickers, () => client.guilds.stickers(data.guild_id).listCached()),\n emit: async (client, data, previous: Sticker[] | undefined) => {\n const stickers = client.guilds.stickers(data.guild_id);\n const current = await Promise.all(\n data.stickers.map((sticker) => stickers.hydrate({ ...sticker, guild_id: data.guild_id })),\n );\n const events: GatewayEventTuple[] = [\n [GatewayEvents.GuildStickersUpdate, data.guild_id, current],\n ];\n if (!previous) return events;\n return events.concat(\n diff(\n previous,\n current,\n GatewayEvents.StickerCreate,\n GatewayEvents.StickerUpdate,\n GatewayEvents.StickerDelete,\n ),\n );\n },\n },\n};\n\n// The cached list to diff against, `undefined` when there is none: no store, or one that cannot enumerate.\nasync function cachedList<Value>(\n store: EntityCache<unknown> | undefined,\n list: () => Promise<Value[]>,\n): Promise<Value[] | undefined> {\n return store && isIterableCache(store) ? list() : undefined;\n}\n\ntype Diffable = { id: string | null; equals(other: never): boolean };\n\n// Lists the create, update, and delete events turning `previous` into `current`, matched by ID.\nfunction diff<Value extends Diffable>(\n previous: readonly Value[],\n current: readonly Value[],\n create: GatewayEvents,\n update: GatewayEvents,\n remove: GatewayEvents,\n): GatewayEventTuple[] {\n const before = new Map(previous.map((value) => [value.id, value]));\n const events: unknown[][] = [];\n for (const value of current) {\n const old = before.get(value.id);\n if (!old) events.push([create, value]);\n else if (!old.equals(value as never)) events.push([update, old, value]);\n before.delete(value.id);\n }\n\n for (const value of before.values()) events.push([remove, value]);\n return events as GatewayEventTuple[];\n}\n\n/**\n * Resolves a cache read, or `undefined` when the cache cannot be read, so an event can still be built from its\n * payload. The failure itself was already reported while applying the dispatch.\n */\ntype ReactionData = {\n channel_id: string;\n message_id: string;\n guild_id?: string;\n emoji: APIPartialEmoji;\n burst_colors?: string[];\n};\n\n// The reaction as the cache holds it after the dispatch. When the message is cached but the reaction is gone (its\n// last user removed it), the counts are known to be zero; only an uncached message leaves them unknown.\nasync function reactionOf(client: GatewayClient, data: ReactionData): Promise<MessageReaction> {\n const message = await cachedOrUndefined(client.messages.get(data.channel_id, data.message_id));\n if (!message) return partialReaction(client, data);\n return message.reactions.resolve(data.emoji) ?? partialReaction(client, data, true, message);\n}\n\n// A reaction the cached message does not hold, with the message when it is cached, and the cached custom emoji of the\n// message's guild.\nasync function partialReaction(\n client: GatewayClient,\n data: ReactionData,\n emptied = false,\n message: Message | null = partialMessage(client, data.channel_id, data.message_id, data.guild_id),\n): Promise<MessageReaction> {\n const { guild_id: guildId, emoji } = data;\n const cachedEmoji =\n guildId && emoji.id\n ? await cachedOrUndefined(client.guilds.emojis(guildId).get(emoji.id))\n : undefined;\n return bindClient(\n new MessageReaction(\n {\n channel_id: data.channel_id,\n message_id: data.message_id,\n emoji,\n me: false,\n me_burst: false,\n burst_colors: data.burst_colors ?? [],\n ...(emptied && { count: 0, count_details: { normal: 0, burst: 0 } }),\n },\n { message, emoji: cachedEmoji ?? null },\n ),\n client,\n );\n}\n\n// The answer as the cache holds it after the dispatch, else one with only its ID.\nasync function pollAnswerOf(\n client: GatewayClient,\n data: GatewayMessagePollVoteDispatchData,\n): Promise<PollAnswer> {\n const message = await cachedOrUndefined(client.messages.get(data.channel_id, data.message_id));\n return (\n message?.poll?.answers.find((answer) => answer.id === data.answer_id) ??\n bindClient(\n new PollAnswer(\n {\n answer_id: data.answer_id,\n poll_media: {},\n channel_id: data.channel_id,\n message_id: data.message_id,\n },\n { poll: message?.poll ?? partialPoll(client, data.channel_id, data.message_id) },\n ),\n client,\n )\n );\n}\n\n// The typing user, as the cache knows them and their channel.\nasync function typingOf(\n client: GatewayClient,\n data: DispatchData<GatewayDispatchEvents.TypingStart>,\n): Promise<Typing> {\n const { guild_id: guildId, member, user_id: userId } = data;\n const [channel, user, guild, resolvedMember] = await Promise.all([\n cachedOrUndefined(client.channels.get(data.channel_id)),\n cachedOrUndefined(\n member?.user ? client.users.resolveData(member.user) : client.users.get(userId),\n ),\n guildId ? cachedOrUndefined(Promise.resolve(client.guilds._getShallow(guildId))) : undefined,\n guildId\n ? cachedOrUndefined(\n member?.user\n ? client.members.resolveData({ ...member, guild_id: guildId })\n : client.members.get(guildId, userId),\n )\n : undefined,\n ]);\n return bindClient(\n new Typing(data, {\n channel: channel ?? (guildId ? null : partialDMChannel(client, data.channel_id, userId)),\n user: user ?? partialUser(client, userId),\n guild: guild ?? null,\n member: resolvedMember ?? (guildId ? partialMember(client, guildId, { id: userId }) : null),\n }),\n client,\n );\n}\n\n// Whether the client builds partial structures of `partial`, see `GatewayClientOptions.partials`.\nfunction wants(client: GatewayClient, partial: Partials): boolean {\n return client.partials.includes(partial);\n}\n\n// The cached entities, in the dispatch's order, completed by partial ones for the uncached IDs when `build` returns\n// them (i.e. their partial is enabled): only the cached ones otherwise.\nfunction withPartials<Value extends { id: string | null }>(\n cached: readonly Value[],\n ids: readonly string[],\n build: (id: string) => Value | null,\n): Value[] {\n const byId = new Map(cached.map((value) => [value.id, value]));\n const values: Value[] = [];\n for (const id of ids) {\n const value = byId.get(id) ?? build(id);\n if (value) values.push(value);\n }\n\n return values;\n}\n\n// The partial structures, built from the IDs a dispatch carries when their partial is enabled, `null` otherwise. They\n// are never written to the cache.\n\nfunction partialMessage(\n client: GatewayClient,\n channelId: string,\n messageId: string,\n guildId?: string,\n): Message | null {\n if (!wants(client, Partials.Message)) return null;\n return bindClient(\n new Message({ id: messageId, channel_id: channelId, guild_id: guildId } as never),\n client,\n );\n}\n\nfunction partialUser(client: GatewayClient, userId: string): User | null {\n return wants(client, Partials.User)\n ? bindClient(new User({ id: userId } as never), client)\n : null;\n}\n\nfunction partialMember(\n client: GatewayClient,\n guildId: string,\n user: APIUser | { id: string },\n): GuildMember | null {\n if (!wants(client, Partials.GuildMember)) return null;\n return bindClient(new GuildMember({ guild_id: guildId, user } as never), client);\n}\n\nfunction partialThreadMember(\n client: GatewayClient,\n threadId: string,\n userId: string,\n guildId?: string,\n): ThreadMember | null {\n if (!wants(client, Partials.ThreadMember)) return null;\n return bindClient(\n new ThreadMember({ id: threadId, user_id: userId, guild_id: guildId } as never),\n client,\n );\n}\n\nfunction partialScheduledEvent(\n client: GatewayClient,\n guildId: string,\n eventId: string,\n): GuildScheduledEvent | null {\n if (!wants(client, Partials.GuildScheduledEvent)) return null;\n return bindClient(new GuildScheduledEvent({ id: eventId, guild_id: guildId } as never), client);\n}\n\nfunction partialSoundboardSound(\n client: GatewayClient,\n guildId: string,\n soundId: string,\n): SoundboardSound | null {\n if (!wants(client, Partials.SoundboardSound)) return null;\n return bindClient(new SoundboardSound({ sound_id: soundId, guild_id: guildId } as never), client);\n}\n\nfunction partialPoll(client: GatewayClient, channelId: string, messageId: string): Poll | null {\n if (!wants(client, Partials.Poll)) return null;\n return bindClient(new Poll({ channel_id: channelId, message_id: messageId } as never), client);\n}\n\n// Only direct messages can be partial channels, like discord.js's: a guild channel's type is unknown from its ID.\nfunction partialDMChannel(\n client: GatewayClient,\n channelId: string,\n recipientId: string,\n): DMChannel | null {\n if (!wants(client, Partials.Channel)) return null;\n return bindClient(\n createChannel({\n id: channelId,\n type: ChannelType.DM,\n recipients: [{ id: recipientId }],\n } as never) as DMChannel,\n client,\n );\n}\n\nfunction cachedOrUndefined<Value>(read: Promise<Value | undefined>): Promise<Value | undefined> {\n return read.catch(() => undefined);\n}\n","import type { GatewayDispatchPayload } from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport {\n DispatchHandlers,\n MultiDispatchHandlers,\n type DispatchHandler,\n type GatewayEventTuple,\n type MultiDispatchHandler,\n} from \"../util/dispatch.js\";\nimport type { GatewayEventName } from \"../util/events.js\";\n\n/** Processes one kind of gateway dispatch around the cache write. */\nexport abstract class Action {\n public constructor(protected readonly client: GatewayClient) {}\n\n /** Captures the state required to build the event before the cache changes. */\n public async before(_data: GatewayDispatchPayload[\"d\"]): Promise<unknown> {\n return undefined;\n }\n\n /** Builds and emits events after the cache has been updated. */\n public abstract handle(\n data: GatewayDispatchPayload[\"d\"],\n state: unknown,\n shardId: number,\n ): Promise<void>;\n\n protected emit([event, ...args]: GatewayEventTuple): void {\n this.client.emit(event, ...(args as never));\n }\n}\n\n/** An action producing one public event. */\nexport class DispatchAction extends Action {\n public constructor(\n client: GatewayClient,\n private readonly handler: DispatchHandler<GatewayDispatchPayload[\"t\"], GatewayEventName>,\n ) {\n super(client);\n }\n\n public override async before(data: GatewayDispatchPayload[\"d\"]): Promise<unknown> {\n return this.handler.before?.(this.client, data);\n }\n\n public async handle(\n data: GatewayDispatchPayload[\"d\"],\n state: unknown,\n shardId: number,\n ): Promise<void> {\n const args = await this.handler.build(this.client, data, state, shardId);\n this.emit([this.handler.event, ...args] as GatewayEventTuple);\n }\n}\n\n/** An action producing several public events from one dispatch. */\nexport class MultiDispatchAction extends Action {\n public constructor(\n client: GatewayClient,\n private readonly handler: MultiDispatchHandler<GatewayDispatchPayload[\"t\"]>,\n ) {\n super(client);\n }\n\n public override async before(data: GatewayDispatchPayload[\"d\"]): Promise<unknown> {\n return this.handler.before?.(this.client, data);\n }\n\n public async handle(data: GatewayDispatchPayload[\"d\"], state: unknown): Promise<void> {\n for (const event of await this.handler.emit(this.client, data, state)) this.emit(event);\n }\n}\n\n/** Holds one action per handled dispatch, like discord.js's ActionsManager. */\nexport class ActionsManager {\n readonly #actions = new Map<GatewayDispatchPayload[\"t\"], Action>();\n\n public constructor(client: GatewayClient) {\n for (const [event, handler] of Object.entries(DispatchHandlers)) {\n if (handler) {\n this.#actions.set(\n event as GatewayDispatchPayload[\"t\"],\n new DispatchAction(client, handler as never),\n );\n }\n }\n for (const [event, handler] of Object.entries(MultiDispatchHandlers)) {\n if (handler) {\n // An event holds a single action, so it may be registered in only one of the two handler tables.\n if (this.#actions.has(event as GatewayDispatchPayload[\"t\"])) {\n throw new Error(\n `Dispatch event \"${event}\" is registered in both DispatchHandlers and MultiDispatchHandlers`,\n );\n }\n this.#actions.set(\n event as GatewayDispatchPayload[\"t\"],\n new MultiDispatchAction(client, handler as never),\n );\n }\n }\n }\n\n public get(event: GatewayDispatchPayload[\"t\"]): Action | undefined {\n return this.#actions.get(event);\n }\n}\n","import { GatewayDispatchEvents, type GatewayDispatchPayload } from \"discord-api-types/v10\";\n\n/**\n * A snapshot of a {@link DispatchQueue}.\n */\nexport interface DispatchQueueStats {\n /**\n * The dispatches received but not processed yet, across every shard.\n */\n pending: number;\n /**\n * The partitions currently holding at least one pending dispatch.\n */\n partitions: number;\n}\n\ninterface ShardQueue {\n // The last dispatch every partition must wait for, e.g. `READY`.\n barrier: Promise<void>;\n partitions: Map<string, Promise<void>>;\n}\n\nconst GuildEvents: ReadonlySet<string> = new Set([\n GatewayDispatchEvents.GuildCreate,\n GatewayDispatchEvents.GuildUpdate,\n GatewayDispatchEvents.GuildDelete,\n]);\n\n/**\n * Gets the partition a dispatch is processed in: its guild, else its channel (direct messages), else `null`.\n *\n * @remarks\n * A `null` partition is a barrier: the dispatch waits for every pending dispatch of its shard, and every later one\n * waits for it. `READY`, `RESUMED`, and user-level dispatches such as `USER_UPDATE` are barriers.\n *\n * @param payload The dispatch payload.\n */\nexport function dispatchPartition(payload: GatewayDispatchPayload): string | null {\n const data = payload.d as { guild_id?: string; channel_id?: string; id?: string } | null;\n if (!data || typeof data !== \"object\") return null;\n if (data.guild_id) return `guild:${data.guild_id}`;\n if (GuildEvents.has(payload.t) && data.id) return `guild:${data.id}`;\n if (data.channel_id) return `channel:${data.channel_id}`;\n // Direct message channels are the only channels created or deleted without a guild.\n if (payload.t.startsWith(\"CHANNEL_\") && data.id) return `channel:${data.id}`;\n return null;\n}\n\n/**\n * Runs tasks in order within a partition, and partitions of the same shard concurrently.\n *\n * @remarks\n * An asynchronous cache (Redis) would otherwise let a later dispatch of a guild finish before an earlier one. Guilds\n * are independent, so a slow guild does not hold the others back. Tasks must never reject: the queue has no way to\n * report their errors.\n */\nexport class DispatchQueue {\n readonly #shards = new Map<number, ShardQueue>();\n // The shard each guild's dispatches come from, for the tasks the client queues on its own.\n readonly #guildShards = new Map<string, number>();\n #pending = 0;\n\n /**\n * Queues a task.\n *\n * @param shardId The shard the dispatch was received on.\n * @param partition The partition from {@link dispatchPartition}, `null` for a barrier.\n * @param task The task to run once the previous task of its partition is done.\n * @returns The task's completion.\n */\n public enqueue(\n shardId: number,\n partition: string | null,\n task: () => Promise<void>,\n ): Promise<void> {\n const shard = this.shard(shardId);\n this.#pending++;\n if (partition?.startsWith(\"guild:\")) this.#guildShards.set(partition, shardId);\n\n const previous =\n partition === null\n ? Promise.all([shard.barrier, ...shard.partitions.values()])\n : (shard.partitions.get(partition) ?? shard.barrier);\n const run = previous.then(task).finally(() => {\n this.#pending--;\n if (partition !== null && shard.partitions.get(partition) === run) {\n shard.partitions.delete(partition);\n }\n });\n\n if (partition === null) {\n // Every pending partition is covered by the barrier from now on.\n shard.barrier = run;\n shard.partitions.clear();\n } else {\n shard.partitions.set(partition, run);\n }\n\n return run;\n }\n\n /**\n * Queues a task in a guild's partition, on the shard the guild's dispatches come from: a cache write the client\n * makes on its own then stays in order with them. Before any dispatch of the guild, there is nothing to order it\n * with, and it runs on shard 0.\n *\n * @param guildId The ID of the guild.\n * @param task The task to run once the previous task of the guild is done.\n */\n public enqueueGuild(guildId: string, task: () => Promise<void>): Promise<void> {\n const partition = `guild:${guildId}`;\n return this.enqueue(this.#guildShards.get(partition) ?? 0, partition, task);\n }\n\n /**\n * Resolves once every task queued so far has run.\n */\n public async idle(): Promise<void> {\n await Promise.all(\n [...this.#shards.values()].flatMap((shard) => [shard.barrier, ...shard.partitions.values()]),\n );\n }\n\n /**\n * A snapshot of the pending work.\n */\n public get stats(): DispatchQueueStats {\n let partitions = 0;\n for (const shard of this.#shards.values()) partitions += shard.partitions.size;\n return { pending: this.#pending, partitions };\n }\n\n private shard(shardId: number): ShardQueue {\n let shard = this.#shards.get(shardId);\n if (!shard) {\n shard = { barrier: Promise.resolve(), partitions: new Map() };\n this.#shards.set(shardId, shard);\n }\n\n return shard;\n }\n}\n","import type { GatewaySessionInfo, GatewaySessionStore } from \"@wolfstar/plugin-cache\";\nimport { GatewaySessionStoreError } from \"./errors.js\";\n\n/**\n * Sits between `@discordjs/ws` and a {@link GatewaySessionStore}, which `@discordjs/ws` would otherwise read on every\n * dispatch and heartbeat, and write on every sequence change, while holding the dispatch back.\n *\n * @remarks\n * The session of a shard is read from the store once, when the shard first connects, then served from memory. Writes\n * never hold a dispatch back either: they run in the background, one at a time per shard, and the ones queued while a\n * write is in flight collapse into a single write of the latest session. A stored sequence is therefore slightly\n * behind after a crash, which Discord handles by replaying the dispatches since then.\n *\n * @internal\n */\nexport class GatewaySessionMirror {\n readonly #store: GatewaySessionStore;\n readonly #timeout: number | null;\n readonly #onError: (error: GatewaySessionStoreError) => void;\n readonly #sessions = new Map<number, GatewaySessionInfo | null>();\n // The shards with a write waiting for the one in flight, and the session it will write.\n readonly #pending = new Map<number, GatewaySessionInfo | null>();\n readonly #writes = new Map<number, Promise<void>>();\n\n public constructor(\n store: GatewaySessionStore,\n timeout: number | null,\n onError: (error: GatewaySessionStoreError) => void,\n ) {\n this.#store = store;\n this.#timeout = timeout;\n this.#onError = onError;\n }\n\n public async get(shardId: number): Promise<GatewaySessionInfo | null> {\n if (this.#sessions.has(shardId)) return this.#sessions.get(shardId)!;\n\n const session = await this.read(shardId);\n // A session written while reading is newer than the stored one.\n if (!this.#sessions.has(shardId)) this.#sessions.set(shardId, session);\n return this.#sessions.get(shardId)!;\n }\n\n public set(shardId: number, info: GatewaySessionInfo | null): void {\n this.#sessions.set(shardId, info);\n\n const queued = this.#pending.has(shardId);\n this.#pending.set(shardId, info);\n if (queued) return;\n\n const previous = this.#writes.get(shardId) ?? Promise.resolve();\n this.#writes.set(\n shardId,\n previous.then(() => this.write(shardId)),\n );\n }\n\n /**\n * Resolves once every session written so far reached the store.\n */\n public async flush(): Promise<void> {\n await Promise.all(this.#writes.values());\n }\n\n private async read(shardId: number): Promise<GatewaySessionInfo | null> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n const read = Promise.resolve(this.#store.get(shardId));\n if (this.#timeout === null) return await read;\n\n const timeout = this.#timeout;\n // A hanging store (e.g. a Redis client queueing commands while reconnecting) must not hold the shard back.\n return await Promise.race([\n read,\n new Promise<never>((_, reject) => {\n timer = setTimeout(() => reject(new Error(`Timed out after ${timeout}ms`)), timeout);\n }),\n ]);\n } catch (error) {\n // Identifying costs more than resuming, but a shard that cannot tell its session still connects.\n this.#onError(new GatewaySessionStoreError(\"get\", shardId, error));\n return null;\n } finally {\n if (timer) clearTimeout(timer);\n }\n }\n\n private async write(shardId: number): Promise<void> {\n const info = this.#pending.get(shardId)!;\n this.#pending.delete(shardId);\n try {\n await this.#store.set(shardId, info);\n } catch (error) {\n this.#onError(new GatewaySessionStoreError(\"set\", shardId, error));\n }\n }\n}\n","import {\n CloseCodes,\n DefaultWebSocketManagerOptions,\n WebSocketManager,\n WebSocketShardEvents,\n WebSocketShardStatus,\n type OptionalWebSocketManagerOptions,\n type SessionInfo,\n type ShardRange,\n} from \"@discordjs/ws\";\nimport { Client as DiscordCoreClient, type API } from \"@discordjs/core\";\nimport type { REST } from \"@discordjs/rest\";\nimport { Client, container, type ClientOptions } from \"@wolfstar/http-framework\";\nimport {\n applyGatewayDispatch,\n createCache,\n isIterableCache,\n type Cache,\n type CacheFactory,\n type CachePolicies,\n type GatewaySessionStore,\n} from \"@wolfstar/plugin-cache\";\nimport {\n GatewayDispatchEvents,\n GatewayIntentBits,\n GatewayOpcodes,\n type APIVoiceRegion,\n type GatewayDispatchPayload,\n type GatewayReadyDispatchData,\n} from \"discord-api-types/v10\";\nimport { ChannelManager } from \"./managers/ChannelManager.js\";\nimport { GuildManager } from \"./managers/GuildManager.js\";\nimport { GuildMemberManager } from \"./managers/GuildMemberManager.js\";\nimport { MessageManager } from \"./managers/MessageManager.js\";\nimport { RoleManager } from \"./managers/RoleManager.js\";\nimport { SoundboardSound } from \"./structures/soundboards/SoundboardSound.js\";\nimport { WebhookManager } from \"./managers/WebhookManager.js\";\nimport { GuildTemplateManager } from \"./managers/GuildTemplateManager.js\";\nimport { VoiceStateManager } from \"./managers/VoiceStateManager.js\";\nimport { PresenceManager } from \"./managers/PresenceManager.js\";\nimport { ThreadManager } from \"./managers/ThreadManager.js\";\nimport { ThreadMemberManager } from \"./managers/ThreadMemberManager.js\";\nimport { UserManager } from \"./managers/UserManager.js\";\nimport type { BaseInvite } from \"./structures/invites/BaseInvite.js\";\nimport type { ClientUser } from \"./structures/users/ClientUser.js\";\nimport { createInvite } from \"./structures/invites/GroupDMInvite.js\";\nimport { bindClient } from \"./structures/Structure.js\";\nimport { Sticker } from \"./structures/stickers/Sticker.js\";\nimport type { Webhook } from \"./structures/webhooks/Webhook.js\";\nimport type { GuildTemplate } from \"./structures/guilds/GuildTemplate.js\";\nimport { Widget } from \"./structures/guilds/Widget.js\";\nimport { StickerPack } from \"./structures/stickers/StickerPack.js\";\nimport { ActionsManager } from \"./actions/Action.js\";\nimport { dispatchPartition, DispatchQueue, type DispatchQueueStats } from \"./util/DispatchQueue.js\";\nimport { DispatchTimeoutError } from \"./util/errors.js\";\nimport type { GatewayClientMessageDefaults } from \"./structures/messages/MessagePayload.js\";\nimport type { Partials } from \"./util/Partials.js\";\nimport { GatewaySessionMirror } from \"./util/sessions.js\";\n\nexport interface GatewayClientOptions extends ClientOptions, GatewayClientMessageDefaults {\n /**\n * The gateway intents to identify with, e.g. `GatewayIntentBits.Guilds | GatewayIntentBits.GuildMessages`.\n */\n intents: GatewayIntentBits | number;\n /**\n * The total number of shards across every process, `null` to use the amount recommended by Discord.\n *\n * @default null\n */\n shardCount?: number | null;\n /**\n * The IDs of the shards this client manages, `null` to manage all of them.\n *\n * @default null\n */\n shardIds?: number[] | ShardRange | null;\n /**\n * The cache to write every dispatch into, see `@wolfstar/plugin-cache`. Without one, the managers' `get` always\n * resolve to `undefined`, update events receive `null` as their previous state, and `fetch` always hits the API.\n *\n * @remarks\n * Every entity cache is optional: an entity kind the cache does not hold is simply not cached, see\n * `createInMemoryCache`'s `entities` option.\n *\n * @default undefined\n */\n cache?: Cache;\n /**\n * Creates the store of each entity kind, `null` or `undefined` not to cache it: the `CacheConstructor` of the\n * discord.js RFC #11426. Called once per entity kind when the client is constructed, and takes precedence over\n * {@link GatewayClientOptions.cache}.\n *\n * @example\n * ```typescript\n * import { MemoryEntityCache } from '@wolfstar/plugin-cache';\n *\n * // Cache guilds, channels, and roles only.\n * const client = new GatewayClient({\n * intents,\n * makeCache: (entity) => (['guilds', 'channels', 'roles'].includes(entity) ? new MemoryEntityCache() : null),\n * });\n * ```\n *\n * @default undefined\n */\n makeCache?: CacheFactory;\n /**\n * The policies deciding which entries get cached, and for how long, per entity kind, see `withPolicy`. They apply to\n * every write, from dispatches as well as from the managers.\n *\n * @example\n * ```typescript\n * // Do not cache bots, and forget messages after an hour.\n * policies: { users: { filter: (user) => !user.bot }, messages: { ttl: () => 3_600_000 } }\n * ```\n *\n * @default undefined\n */\n policies?: CachePolicies;\n /**\n * What the managers do when a cache read or write fails, e.g. while Redis is unreachable. A `cacheError` event is\n * emitted either way.\n *\n * - `\"miss\"`: treat it as a cache miss, falling back to the API or to the data at hand.\n * - `\"throw\"`: reject with the error.\n *\n * @remarks\n * Dispatches follow {@link GatewayClientOptions.cacheFailure} instead.\n *\n * @default \"miss\"\n */\n cacheErrors?: \"miss\" | \"throw\";\n /**\n * Additional options for the underlying `@discordjs/ws` `WebSocketManager`, e.g. `compression` or\n * `initialPresence`.\n */\n gateway?: Partial<Omit<OptionalWebSocketManagerOptions, \"token\" | \"shardCount\" | \"shardIds\">>;\n /**\n * Where to keep the shards' sessions, e.g. `createRedisSessionStore` from `@wolfstar/plugin-cache`, so a restarted\n * process resumes them instead of identifying again: no identify quota spent, the dispatches missed meanwhile\n * replayed, and no `GUILD_CREATE` burst. Pair it with a persistent cache, since a resumed session does not refill an\n * empty one. Use {@link GatewayClient.destroy}'s `resumable` option to keep the sessions on a graceful shutdown.\n *\n * @remarks\n * The store is read once per shard when it first connects, then mirrored in memory, and written in the background\n * on every sequence change, see {@link GatewayClientOptions.sessionStoreTimeout}. Its failures are reported as\n * `GatewaySessionStoreError`s through the `error` event and never stop a shard: a failed read identifies.\n *\n * It replaces `gateway.retrieveSessionInfo` and `gateway.updateSessionInfo`, passing either alongside it throws.\n *\n * @default undefined\n */\n sessionStore?: GatewaySessionStore;\n /**\n * The time, in milliseconds, after which a shard stops waiting for {@link GatewayClientOptions.sessionStore} to read\n * its session, and identifies instead. `null` waits forever.\n *\n * @default 5_000\n */\n sessionStoreTimeout?: number | null;\n /**\n * What to do with a dispatch whose cache read or write fails, e.g. while Redis is unreachable. The error is always\n * reported through the `error` event (or the logger when nobody listens to it).\n *\n * - `\"skip\"`: drop the dispatch's event, so listeners never see state the cache does not hold.\n * - `\"emitUncached\"`: still emit the event, built from the payload alone, with `null` as the previous state.\n *\n * @default \"skip\"\n */\n cacheFailure?: \"skip\" | \"emitUncached\";\n /**\n * The time, in milliseconds, after which a dispatch still being processed is reported as a `DispatchTimeoutError`\n * through the `error` event. The dispatch is not cancelled. `null` disables the check.\n *\n * @default 30_000\n */\n dispatchTimeout?: number | null;\n /**\n * The structures to build partially when an event concerns one that is not cached, like discord.js's `partials`,\n * e.g. `[Partials.Message, Partials.User]`. See {@link Partials}.\n *\n * @default []\n */\n partials?: readonly Partials[];\n /**\n * How long, in milliseconds, the client waits for every guild `READY` listed as initially unavailable to become\n * available (its `GUILD_CREATE`) before emitting `clientReady` anyway, like discord.js's `waitGuildTimeout`.\n *\n * @remarks\n * It only bounds the wait on guild availability: `clientReady` still never fires before every shard this client\n * manages has connected, however long that takes, even past this timeout.\n *\n * Skipped (waits `0` ms) when `intents` does not include `GatewayIntentBits.Guilds`, since without it Discord never\n * sends the guilds' data, so no `GUILD_CREATE` for them ever arrives.\n *\n * @default 15_000\n */\n waitGuildTimeout?: number;\n}\n\n/** Options for loading pieces and starting both transports. */\nexport interface GatewayClientStartOptions {\n /** HTTP interaction server options. */\n listen: Client.ServerListenOptions;\n /** Piece loading options. */\n load?: Client.PieceLoadOptions;\n}\n\n/** Options for disconnecting the gateway shards. */\nexport interface GatewayClientDestroyOptions {\n /**\n * Whether to keep the shards' sessions resumable, for the next process to resume them (e.g. during a deploy): the\n * shards close with a code Discord does not invalidate the session on, and their sessions stay stored. Only\n * meaningful with {@link GatewayClientOptions.sessionStore}, or with `gateway.updateSessionInfo`.\n *\n * @default false\n */\n resumable?: boolean;\n}\n\n/**\n * A {@link Client} that, on top of serving HTTP interactions, connects to the Discord gateway, writes every dispatch\n * into an optional {@link Cache}, and emits {@link GatewayEventMap} events carrying structures.\n *\n * @example\n * ```typescript\n * import { GatewayClient } from '@wolfstar/plugin-gateway';\n * import { createInMemoryCache } from '@wolfstar/plugin-cache';\n * import { GatewayIntentBits } from 'discord-api-types/v10';\n *\n * const client = new GatewayClient({\n * intents: GatewayIntentBits.Guilds | GatewayIntentBits.GuildMessages,\n * cache: createInMemoryCache(),\n * });\n *\n * client.on('messageCreate', (message) => console.log(`${message.author.username}: ${message.content}`));\n *\n * await client.start({ listen: { port: 8080 } });\n * ```\n */\nexport class GatewayClient extends Client {\n /**\n * The cache every dispatch is written into, if any.\n */\n public readonly cache: Cache | undefined;\n\n /**\n * The REST manager the gateway (for its gateway bot info) and every manager's API calls go through, like\n * discord.js's `Client#rest`.\n */\n public readonly rest: REST;\n\n /**\n * The underlying `@discordjs/ws` manager, handling the shards' connections, resumes, and identify rate limits.\n */\n public readonly gateway: WebSocketManager;\n\n /**\n * The typed REST API every manager's calls go through, `@discordjs/core`'s `API` built from {@link GatewayClient.rest}.\n */\n public readonly api: API;\n\n /**\n * The discord.js core client, sharing this client's REST and gateway transports, like the RFC `next` `Client`'s\n * own `core`.\n *\n * @remarks\n * Kept protected: managers and structures reach its typed REST calls through {@link GatewayClient.api} instead, and\n * its gateway and REST manager are already {@link GatewayClient.gateway} and {@link GatewayClient.rest}. It is only\n * needed to build the discord.js core client's own event listeners, if this class ever wraps them.\n */\n protected readonly core: DiscordCoreClient;\n\n /** The actions that turn gateway dispatches into public client events. */\n public readonly actions: ActionsManager;\n\n /**\n * The bot user, set once the first shard receives `READY`.\n */\n public user: ClientUser | null = null;\n\n public readonly users: UserManager;\n public readonly guilds: GuildManager;\n public readonly channels: ChannelManager;\n public readonly threads: ThreadManager;\n public readonly threadMembers: ThreadMemberManager;\n public readonly messages: MessageManager;\n public readonly members: GuildMemberManager;\n public readonly roles: RoleManager;\n public readonly webhooks: WebhookManager;\n public readonly templates: GuildTemplateManager;\n public readonly voiceStates: VoiceStateManager;\n public readonly presences: PresenceManager;\n\n /**\n * What happens to a dispatch whose cache read or write fails, see {@link GatewayClientOptions.cacheFailure}.\n */\n public readonly cacheFailure: \"skip\" | \"emitUncached\";\n\n /**\n * What the managers do when a cache read or write fails, see {@link GatewayClientOptions.cacheErrors}.\n */\n public readonly cacheErrors: \"miss\" | \"throw\";\n\n /**\n * See {@link GatewayClientOptions.dispatchTimeout}.\n */\n public readonly dispatchTimeout: number | null;\n\n /**\n * The structures built partially for uncached entities, see {@link GatewayClientOptions.partials}.\n */\n public readonly partials: readonly Partials[];\n\n /**\n * See {@link GatewayClientOptions.waitGuildTimeout}.\n */\n public readonly waitGuildTimeout: number;\n\n /**\n * The timestamp the client last became ready, like discord.js's `Client#readyTimestamp`. `null` until\n * `clientReady` is first emitted, see {@link GatewayClient.clientReadyAt}.\n */\n public clientReadyTimestamp: number | null = null;\n\n // Dispatches of a guild are processed in order, so an asynchronous cache never reorders them, while different\n // guilds proceed concurrently.\n readonly #queue = new DispatchQueue();\n\n readonly #shardCount: number | null;\n\n readonly #intents: number;\n\n // Resolved once from the options (or the environment) and kept private, rather than read again from `this.options`,\n // which the base client scrubs it from.\n readonly #token: string;\n\n // The guilds `READY` listed as initially unavailable, whose `GUILD_CREATE` or `GUILD_DELETE` the client waits for\n // before emitting `clientReady`, like discord.js's `Client#expectedGuilds`.\n readonly #expectedGuilds = new Set<string>();\n\n // The fallback timer emitting `clientReady` even with guilds still unavailable, like discord.js's own\n // `readyTimeout`. Cleared and rescheduled every time `#checkClientReady` runs short of triggering it.\n #clientReadyTimer: ReturnType<typeof setTimeout> | null = null;\n\n #sessions: GatewaySessionMirror | null = null;\n\n // Set while a resumable `destroy` runs, see `sessionCallbacks`.\n #keepSessions = false;\n\n // The `destroy` in progress, which a concurrent call joins instead of changing `#keepSessions` under it.\n #destroying: Promise<void> | null = null;\n\n public constructor(options: GatewayClientOptions) {\n super(options);\n container.gatewayClient = this;\n\n // Set by the base client's constructor, which validated the token and built the REST manager already.\n this.rest = container.rest;\n this.cache = resolveCache(options);\n this.cacheErrors = options.cacheErrors ?? \"miss\";\n this.cacheFailure = options.cacheFailure ?? \"skip\";\n this.dispatchTimeout = options.dispatchTimeout === undefined ? 30_000 : options.dispatchTimeout;\n this.partials = Object.freeze([...(options.partials ?? [])]);\n this.waitGuildTimeout = options.waitGuildTimeout ?? 15_000;\n this.#shardCount = options.shardCount ?? null;\n this.#intents = Number(options.intents);\n // The base client validated it already, and scrubs it from `this.options`.\n this.#token = (options.discordToken ?? process.env.DISCORD_TOKEN)!;\n this.users = new UserManager(this);\n this.guilds = new GuildManager(this);\n this.channels = new ChannelManager(this);\n this.threads = new ThreadManager(this);\n this.threadMembers = new ThreadMemberManager(this);\n this.messages = new MessageManager(this);\n this.members = new GuildMemberManager(this);\n this.roles = new RoleManager(this);\n this.webhooks = new WebhookManager(this);\n this.templates = new GuildTemplateManager(this);\n this.voiceStates = new VoiceStateManager(this);\n this.presences = new PresenceManager(this);\n\n this.gateway = new WebSocketManager({\n ...options.gateway,\n ...this.sessionCallbacks(options),\n token: this.#token,\n intents: options.intents as GatewayIntentBits,\n rest: this.rest,\n shardCount: options.shardCount ?? null,\n shardIds: options.shardIds ?? null,\n });\n this.core = new DiscordCoreClient({ gateway: this.gateway, rest: this.rest });\n this.api = this.core.api;\n this.actions = new ActionsManager(this);\n\n this.gateway.on(WebSocketShardEvents.Dispatch, (payload, shardId) => {\n const partition = dispatchPartition(payload);\n void this.#queue.enqueue(shardId, partition, () =>\n this.runDispatch(payload, shardId, partition),\n );\n });\n this.gateway.on(WebSocketShardEvents.Resumed, (shardId) => this.emit(\"shardResume\", shardId));\n this.gateway.on(WebSocketShardEvents.Closed, (code, shardId) =>\n this.emit(\"shardClose\", shardId, code),\n );\n this.gateway.on(WebSocketShardEvents.Error, (error, shardId) =>\n this.emit(\"shardError\", error, shardId),\n );\n this.gateway.on(WebSocketShardEvents.Debug, (message, shardId) =>\n this.logger.debug(`[Gateway] [Shard ${shardId}] ${message}`),\n );\n }\n\n /**\n * Connects every configured shard to the gateway.\n */\n public async connect(): Promise<void> {\n await this.gateway.connect();\n }\n\n /** Loads pieces, starts the interaction endpoint, then connects gateway shards. */\n public async start({ listen, load }: GatewayClientStartOptions): Promise<void> {\n await this.load(load);\n await this.listen(listen);\n await this.connect();\n }\n\n /**\n * Disconnects every shard from the gateway. The HTTP server, if listening, is left untouched.\n *\n * @remarks\n * By default, the shards close their sessions, which Discord invalidates. Pass `resumable: true` to keep them\n * resumable instead, e.g. on a graceful shutdown before a deploy. Either way, it waits for the sessions to be\n * written to {@link GatewayClientOptions.sessionStore}.\n *\n * A call made while another one is still disconnecting the shards joins it, keeping the first call's `resumable`.\n *\n * @param options Whether to keep the sessions resumable.\n */\n public destroy(options: GatewayClientDestroyOptions = {}): Promise<void> {\n this.#destroying ??= this.disconnect(options.resumable ?? false).finally(() => {\n this.#destroying = null;\n });\n return this.#destroying;\n }\n\n private async disconnect(resumable: boolean): Promise<void> {\n this.#keepSessions = resumable;\n try {\n // Discord invalidates the session of a connection closed with 1000 or 1001, the default is 1000.\n await this.gateway.destroy(\n this.#keepSessions ? { code: CloseCodes.Resuming, reason: \"Resumable shutdown\" } : {},\n );\n } finally {\n this.#keepSessions = false;\n }\n\n await this.#sessions?.flush();\n await this.idle();\n }\n\n /**\n * Runs a cache write of the client's own (e.g. after leaving a guild) in order with the guild's dispatches.\n *\n * @param guildId The ID of the guild.\n * @param task The cache write.\n * @internal\n */\n public async runInGuildOrder<Value>(guildId: string, task: () => Promise<Value>): Promise<Value> {\n let outcome: { value: Value } | { error: unknown } | undefined;\n // Queued tasks must never reject: the outcome is carried out of the queue instead.\n await this.#queue.enqueueGuild(guildId, async () => {\n try {\n outcome = { value: await task() };\n } catch (error) {\n outcome = { error };\n }\n });\n\n if (\"error\" in outcome!) throw outcome.error;\n return outcome!.value;\n }\n\n /**\n * Resolves once every dispatch received so far has been processed.\n */\n public async idle(): Promise<void> {\n await this.#queue.idle();\n }\n\n /**\n * Fetches Discord's default soundboard sounds, which every guild can play.\n */\n public async fetchDefaultSoundboardSounds(): Promise<SoundboardSound[]> {\n const sounds = await this.api.soundboardSounds.getSoundboardDefaultSounds();\n return sounds.map((sound) => new SoundboardSound(sound));\n }\n\n /**\n * Fetches a webhook. discord.js: `client.fetchWebhook(id, token)`.\n *\n * @param webhookId The ID of the webhook.\n * @param token The webhook's token, to fetch it without the bot's authorization.\n */\n public fetchWebhook(webhookId: string, token?: string): Promise<Webhook> {\n return this.webhooks.fetch(webhookId, token);\n }\n\n /**\n * Fetches a guild template by its code. discord.js: `client.fetchGuildTemplate(code)`.\n *\n * @param code The code of the template, or its URL.\n */\n public fetchGuildTemplate(code: string): Promise<GuildTemplate> {\n return this.templates.fetch(code);\n }\n\n /**\n * Fetches the public widget of a guild, which must be enabled. Needs no membership of the guild.\n *\n * @param guildId The ID of the guild.\n */\n public async fetchGuildWidget(guildId: string): Promise<Widget> {\n return new Widget(await this.api.guilds.getWidget(guildId));\n }\n\n /**\n * Fetches an invite by its code.\n *\n * @param code The code of the invite, or its URL.\n * @param options Whether to include the approximate counts (default), and a scheduled event to attach.\n */\n public async fetchInvite(\n code: string,\n options: { withCounts?: boolean; guildScheduledEventId?: string } = {},\n ): Promise<BaseInvite> {\n // Accept `https://discord.gg/code` and `discord.com/invite/code` as well as the bare code.\n const resolved = code.split(\"/\").pop()!;\n const invite = await this.api.invites.get(resolved, {\n with_counts: options.withCounts ?? true,\n guild_scheduled_event_id: options.guildScheduledEventId,\n });\n const [guild, channel, inviter, targetUser] = await Promise.all([\n invite.guild ? this.guilds.get(invite.guild.id) : undefined,\n invite.channel ? this.channels.get(invite.channel.id) : undefined,\n invite.inviter ? this.users.resolveData(invite.inviter) : undefined,\n invite.target_user ? this.users.resolveData(invite.target_user) : undefined,\n ]);\n return bindClient(\n createInvite(invite, { guild: guild ?? null, channel: channel ?? null, inviter, targetUser }),\n this,\n );\n }\n\n /**\n * Fetches a sticker, standard or from a guild.\n *\n * @param stickerId The ID of the sticker.\n */\n public async fetchSticker(stickerId: string): Promise<Sticker> {\n return new Sticker(await this.api.stickers.get(stickerId));\n }\n\n /**\n * Fetches the packs of standard stickers.\n */\n public async fetchStickerPacks(): Promise<StickerPack[]> {\n const { sticker_packs: packs } = await this.api.stickers.getStickers();\n return packs.map((pack) => new StickerPack(pack));\n }\n\n /**\n * Fetches the voice regions available to the bot.\n */\n public async fetchVoiceRegions(): Promise<APIVoiceRegion[]> {\n return this.api.voice.getVoiceRegions();\n }\n\n /**\n * The dispatches received but not processed yet, and the partitions (guilds, direct message channels) they are\n * queued in. A growing `pending` count usually means a slow or unreachable cache.\n */\n public get queueStats(): DispatchQueueStats {\n return this.#queue.stats;\n }\n\n /**\n * The time the client last became ready, like discord.js's `Client#readyAt`. `null` until `clientReady` is first\n * emitted.\n */\n public get clientReadyAt(): Date | null {\n return this.clientReadyTimestamp === null ? null : new Date(this.clientReadyTimestamp);\n }\n\n /**\n * Whether the client already emitted `clientReady`, like discord.js's `Client#isReady()`.\n */\n public isClientReady(): boolean {\n return this.clientReadyTimestamp !== null;\n }\n\n /**\n * Processes a gateway dispatch: emits it as `raw`, writes it into the cache, emits it as `dispatch`, and emits the\n * matching {@link GatewayEventMap} event, if any.\n *\n * @param payload The dispatch payload.\n * @param shardId The ID of the shard that received it.\n */\n protected async handleDispatch(payload: GatewayDispatchPayload, shardId: number): Promise<void> {\n this.emit(\"raw\", payload, shardId);\n\n // Interactions are served by the HTTP endpoint, see the `DispatchHandlers` remarks.\n if (payload.t === GatewayDispatchEvents.InteractionCreate) return;\n // A rate limited members request gets no chunks: fail it now rather than at its timeout.\n if (payload.t === GatewayDispatchEvents.RateLimited) this.members.handleRateLimited(payload.d);\n\n const action = this.actions.get(payload.t);\n // `READY` is never dropped: it sets `client.user` and `shardReady` from the payload alone, and a shard without it\n // looks dead to the bot. Reconciling the cache with it is best effort, see `reconcileGuilds`.\n const isReady = payload.t === GatewayDispatchEvents.Ready;\n if (isReady) {\n await this.reconcileGuilds(payload.d, shardId);\n // The guilds this shard's `READY` listed as initially unavailable, awaited by `clientReady`.\n for (const guild of payload.d.guilds) this.#expectedGuilds.add(guild.id);\n }\n\n let state: unknown;\n try {\n state = await action?.before(payload.d);\n if (this.cache) {\n await applyGatewayDispatch(this.cache, payload, { clientUserId: this.user?.id ?? this.id });\n }\n } catch (error) {\n if (this.cacheFailure === \"skip\" && !isReady) throw error;\n this.reportError(error, payload.t, shardId);\n state = undefined;\n }\n\n this.emit(\"dispatch\", payload, shardId);\n await action?.handle(payload.d, state, shardId);\n\n if (this.clientReadyTimestamp === null) {\n if (isReady) {\n await this.#checkClientReady();\n } else if (\n (payload.t === GatewayDispatchEvents.GuildCreate ||\n payload.t === GatewayDispatchEvents.GuildDelete) &&\n this.#expectedGuilds.delete(payload.d.id)\n ) {\n await this.#checkClientReady();\n }\n }\n }\n\n /**\n * Emits `clientReady` once every shard this client manages has connected and every guild `READY` listed as\n * initially unavailable became available, or {@link GatewayClientOptions.waitGuildTimeout} elapses, like\n * discord.js's `Client#_checkReady`.\n *\n * @remarks\n * `waitGuildTimeout` bounds the wait on guild availability only: once it elapses, the still-unavailable guilds are\n * forgotten (so a later `GUILD_CREATE`/`GUILD_DELETE` for one of them does not spuriously re-run this), but every\n * shard connecting is never skipped, however long that takes — there is no such timeout for it, matching\n * `@discordjs/ws`, which waits for the network rather than giving up.\n *\n * Unlike discord.js, `clientReady` only ever fires once: subsequent guild or shard activity does not re-trigger it.\n */\n async #checkClientReady(): Promise<void> {\n // A concurrent shard's call already triggered it.\n if (this.clientReadyTimestamp !== null) return;\n\n if (this.#clientReadyTimer) {\n clearTimeout(this.#clientReadyTimer);\n this.#clientReadyTimer = null;\n }\n\n if (this.#expectedGuilds.size > 0) {\n // Without the `Guilds` intent, Discord never sends the unavailable guilds' data, so no `GUILD_CREATE` for them\n // ever arrives: there is nothing to wait for.\n const hasGuildsIntent = (this.#intents & GatewayIntentBits.Guilds) !== 0;\n this.#clientReadyTimer = setTimeout(\n () => {\n this.#clientReadyTimer = null;\n this.#expectedGuilds.clear();\n void this.#checkClientReady();\n },\n hasGuildsIntent ? this.waitGuildTimeout : 0,\n );\n this.#clientReadyTimer.unref?.();\n return;\n }\n\n const statuses = await this.gateway.fetchStatus();\n // Re-check: a concurrent call may have triggered it, or a shard may have disconnected, while this one awaited\n // the shards' statuses.\n if (this.clientReadyTimestamp !== null || this.#expectedGuilds.size > 0) return;\n\n const everyShardReady = [...statuses.values()].every(\n (status) => status === WebSocketShardStatus.Ready,\n );\n if (everyShardReady) this.#triggerClientReady();\n // Otherwise, nothing left to bound with a timer: the next shard to connect re-enters here through its own\n // `READY`.\n }\n\n // Sets `clientReadyTimestamp` and emits `clientReady`, guarding against a concurrent call (a racing shard, or the\n // fallback timer) doing it first: this is always called synchronously, with no `await` before it, so the guard\n // cannot itself be raced.\n #triggerClientReady(): void {\n if (this.clientReadyTimestamp !== null) return;\n this.clientReadyTimestamp = Date.now();\n this.emit(\"clientReady\", this);\n }\n\n /**\n * Drops the cached guilds of a shard its `READY` no longer lists, and emits `guildDelete` for each of them.\n *\n * @remarks\n * They are the guilds the bot left while it was disconnected, or while the process was down with a persistent\n * cache. Discord does not replay those removals on a new session, so the cache would otherwise keep them forever.\n *\n * It needs a guilds cache able to enumerate its entries, and is skipped without one.\n *\n * It is best effort: any failure (cache unreachable, unknown shard count) is reported through `error` and stops the\n * reconciliation, keeping the remaining guilds, but never fails `READY` itself.\n *\n * @param data The `READY` data.\n * @param shardId The shard that received it.\n */\n protected async reconcileGuilds(data: GatewayReadyDispatchData, shardId: number): Promise<void> {\n try {\n await this.dropUnlistedGuilds(data, shardId);\n } catch (error) {\n this.reportError(error, GatewayDispatchEvents.Ready, shardId);\n }\n }\n\n private async dropUnlistedGuilds(data: GatewayReadyDispatchData, shardId: number): Promise<void> {\n // Telling the guilds the bot left apart takes the list of the cached ones.\n const guilds = this.cache?.guilds;\n if (!guilds || !isIterableCache(guilds)) return;\n\n const cached = await guilds.keys();\n if (cached.length === 0) return;\n\n // Without the shard count, the guilds of this shard cannot be told apart from the others'.\n const count = data.shard?.[1] ?? this.#shardCount ?? (await this.gateway.getShardCount());\n const listed = new Set(data.guilds.map((guild) => guild.id));\n const shardCount = BigInt(count);\n for (const id of cached) {\n if (listed.has(id) || Number((BigInt(id) >> 22n) % shardCount) !== shardId) continue;\n\n const guild = (await this.guilds.get(id)) ?? null;\n await applyGatewayDispatch(this.cache!, {\n op: GatewayOpcodes.Dispatch,\n s: 0,\n t: GatewayDispatchEvents.GuildDelete,\n d: { id },\n });\n this.emit(\"guildDelete\", guild, { id });\n }\n }\n\n private async runDispatch(\n payload: GatewayDispatchPayload,\n shardId: number,\n partition: string | null,\n ): Promise<void> {\n const timeout = this.dispatchTimeout;\n const timer =\n timeout === null\n ? null\n : setTimeout(() => {\n this.reportError(\n new DispatchTimeoutError(payload.t, shardId, partition, timeout),\n payload.t,\n shardId,\n );\n }, timeout);\n timer?.unref?.();\n\n try {\n await this.handleDispatch(payload, shardId);\n } catch (error) {\n this.reportError(error, payload.t, shardId);\n } finally {\n if (timer) clearTimeout(timer);\n }\n }\n\n private sessionCallbacks(\n options: GatewayClientOptions,\n ): Pick<OptionalWebSocketManagerOptions, \"retrieveSessionInfo\" | \"updateSessionInfo\"> {\n const { sessionStore, gateway } = options;\n if (sessionStore && (gateway?.retrieveSessionInfo || gateway?.updateSessionInfo)) {\n throw new TypeError(\n \"sessionStore replaces gateway.retrieveSessionInfo and gateway.updateSessionInfo, pass one or the other\",\n );\n }\n\n let retrieve =\n gateway?.retrieveSessionInfo ?? DefaultWebSocketManagerOptions.retrieveSessionInfo;\n let update = gateway?.updateSessionInfo ?? DefaultWebSocketManagerOptions.updateSessionInfo;\n if (sessionStore) {\n const timeout =\n options.sessionStoreTimeout === undefined ? 5_000 : options.sessionStoreTimeout;\n const sessions = new GatewaySessionMirror(sessionStore, timeout, (error) =>\n this.reportError(error, `the session store ${error.operation}`, error.shardId),\n );\n this.#sessions = sessions;\n // Both directions keep `GatewaySessionInfo` assignable to and from `@discordjs/ws`'s `SessionInfo`.\n retrieve = (shardId): Promise<SessionInfo | null> => sessions.get(shardId);\n update = (shardId, info) => sessions.set(shardId, info);\n }\n\n return {\n retrieveSessionInfo: retrieve,\n // `@discordjs/ws` drops the session of every shard destroyed without resuming, a resumable shutdown included:\n // the session must stay stored for the next process to resume it.\n updateSessionInfo: (shardId, info) =>\n info === null && this.#keepSessions ? undefined : update(shardId, info),\n };\n }\n\n // Emitting \"error\" without listeners throws, which would reject the queue and stall the partition.\n private reportError(error: unknown, type: string, shardId: number): void {\n if (this.listenerCount(\"error\") > 0) this.emit(\"error\", error);\n else this.logger.error(`[Gateway] [Shard ${shardId}] Failed to process ${type}:`, error);\n }\n}\n\n/**\n * Builds the cache of a client out of its options: the stores of `makeCache` (or `cache`), wrapped by `policies`.\n * `undefined` when no entity kind is cached.\n */\nfunction resolveCache(options: GatewayClientOptions): Cache | undefined {\n const { makeCache, cache, policies } = options;\n const source: CacheFactory | undefined =\n makeCache ?? (cache ? (entity) => cache[entity] : undefined);\n if (!source) return undefined;\n\n const resolved =\n source === makeCache || policies ? createCache({ makeCache: source, policies }) : cache!;\n return Object.keys(resolved).length === 0 ? undefined : resolved;\n}\n","import type { GatewayEventName } from \"./events.js\";\nimport type { EventGatewayListener } from \"../EventGatewayListener.js\";\n\ntype ListenerConstructor = new (...args: any[]) => EventGatewayListener<any>;\n\n/**\n * Class decorator that binds the decorated {@link EventGatewayListener} to a gateway event, so it does not need to\n * declare a constructor.\n *\n * @example\n * ```typescript\n * import { EventGatewayListener, RegisterAsGatewayListener, type Message } from '@wolfstar/plugin-gateway';\n *\n * @RegisterAsGatewayListener('messageCreate')\n * export class LogMessagesListener extends EventGatewayListener<'messageCreate'> {\n * public override run(message: Message) {\n * console.log(`${message.author.username}: ${message.content}`);\n * }\n * }\n * ```\n *\n * @param event The event to listen to.\n * @param options The additional listener options.\n */\nexport function RegisterAsGatewayListener<Event extends GatewayEventName>(\n event: Event,\n options: Omit<EventGatewayListener.Options<Event>, \"event\"> = {},\n) {\n return function decorate<T extends ListenerConstructor>(target: T): T {\n // Seen through its instance type, the target is abstract (`run`), even though the decorated class implements it.\n const base = target as unknown as new (...args: any[]) => object;\n return class extends base {\n public constructor(...args: any[]) {\n const [context, baseOptions = {}] = args as [\n EventGatewayListener.LoaderContext,\n Partial<EventGatewayListener.Options<Event>>?,\n ];\n super(context, { ...baseOptions, ...options, event });\n }\n } as unknown as T;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,IAAsB,uBAAtB,cAEU,SAAsD;;;;CAI9D,AAAgB;CAEhB,AAAO,YACL,SACA,SACA;EACA,MAAM,SAAS;GAAE,GAAG;GAAS,SAAS;EAAS,CAAC;EAChD,KAAK,OAAO,QAAQ,QAAQ;EAE5B,IAAI,KAAK,MAAM;GAIb,MAAM,WAAW,KAAK;GAEtB,KAAK,YAAY,OAAO,GAAG,SAA6B;IACtD,MAAM,KAAK,OAAO;IAClB,OAAO,SAAS,GAAG,IAAI;GACzB;EACF;CACF;AAGF;;;;;;;;;ACvBA,SAAgB,UAAU,OAA6B;CACrD,MAAM,KAAK,OAAO,UAAU,WAAW,QAAQ,MAAM;CACrD,IAAI,CAAC,IAAI,MAAM,IAAI,UAAU,mDAAmD;CAChF,OAAO;AACT;;;;AA0BA,SAAgB,eAAe,WAAwC;CACrE,OAAO;EACL,IAAI,UAAU,UAAU,EAAE;EAC1B,MAAM,UAAU;EAChB,OAAO,OAAO,oBAAoB,QAAQ,UAAU,SAAS,EAAE,CAAC;EAChE,MAAM,OAAO,oBAAoB,QAAQ,UAAU,QAAQ,EAAE,CAAC;CAChE;AACF;;;;;;;AAQA,SAAgB,wBACd,SACA,UAA6C,CAAC,GACb;CACjC,IAAI,QAAQ,QAAQ,SAAS;CAC7B,IAAI,OAAO,QAAQ,QAAQ;CAC3B,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,OAAO,GAAG;EACnD,MAAM,MAAM,oBAAoB;EAChC,IAAI,UAAU,UAAa,QAAQ,QAAW;EAC9C,SAAS,CAAC;EACV,QAAQ,CAAC;EACT,IAAI,UAAU,MAAM,SAAS;OACxB,IAA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