@wolfstar/plugin-gateway 0.0.0 → 0.1.0-next-20260926141110

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["container","BaseStructure","BitField","BaseActivityFlagsBitField","BaseAttachmentFlagsBitField","BaseChannelFlagsBitField","BaseMessageFlagsBitField","toISO","DiscordCoreClient"],"sources":["../../src/EventGatewayListener.ts","../../src/util/channels.ts","../../src/util/container.ts","../../src/structures/Structure.ts","../../src/structures/Channel.ts","../../src/structures/Mixin.ts","../../src/structures/mixins/BaseChannelMixin.ts","../../src/structures/mixins/ChannelParentMixin.ts","../../src/structures/PermissionOverwrites.ts","../../src/managers/PermissionOverwriteManager.ts","../../src/util/permissions.ts","../../src/structures/mixins/edit.ts","../../src/structures/mixins/ChannelPermissionMixin.ts","../../src/structures/mixins/ChannelSlowmodeMixin.ts","../../src/managers/ChannelThreadManager.ts","../../src/structures/mixins/ChannelThreadsMixin.ts","../../src/structures/mixins/ChannelWebhooksMixin.ts","../../src/structures/mixins/ChannelTopicMixin.ts","../../src/structures/mixins/GuildChannelMixin.ts","../../src/managers/ChannelMessageManager.ts","../../src/structures/mixins/TextChannelMixin.ts","../../src/structures/AnnouncementChannel.ts","../../src/structures/mixins/ChannelOwnerMixin.ts","../../src/managers/ThreadChannelMemberManager.ts","../../src/structures/mixins/ThreadChannelMixin.ts","../../src/structures/AnnouncementThreadChannel.ts","../../src/structures/BaseChannel.ts","../../src/structures/CategoryChannel.ts","../../src/util/cdn.ts","../../src/util/flags.ts","../../src/structures/User.ts","../../src/structures/mixins/DMChannelMixin.ts","../../src/structures/DMChannel.ts","../../src/structures/mixins/ThreadOnlyChannelMixin.ts","../../src/structures/ForumChannel.ts","../../src/structures/mixins/GroupDMMixin.ts","../../src/structures/GroupDMChannel.ts","../../src/structures/MediaChannel.ts","../../src/structures/PrivateThreadChannel.ts","../../src/structures/mixins/AppliedTagsMixin.ts","../../src/structures/PublicThreadChannel.ts","../../src/structures/mixins/VoiceChannelMixin.ts","../../src/structures/StageChannel.ts","../../src/structures/TextChannel.ts","../../src/structures/VoiceChannel.ts","../../src/managers/CachedManager.ts","../../src/managers/ChannelManager.ts","../../src/structures/AnonymousGuild.ts","../../src/structures/Guild.ts","../../src/managers/GuildEmojiRoleManager.ts","../../src/structures/Emoji.ts","../../src/structures/GuildEmoji.ts","../../src/structures/Sticker.ts","../../src/structures/GuildPreview.ts","../../src/structures/GuildAuditLogsEntry.ts","../../src/structures/ReactionEmoji.ts","../../src/structures/GuildOnboarding.ts","../../src/structures/WelcomeScreen.ts","../../src/structures/Webhook.ts","../../src/structures/AutoModerationRule.ts","../../src/managers/AutoModerationRuleManager.ts","../../src/structures/GuildBan.ts","../../src/managers/GuildBanManager.ts","../../src/managers/GuildChannelManager.ts","../../src/structures/Integration.ts","../../src/managers/GuildIntegrationManager.ts","../../src/structures/GuildScheduledEvent.ts","../../src/managers/GuildScheduledEventManager.ts","../../src/structures/SoundboardSound.ts","../../src/managers/GuildSoundboardSoundManager.ts","../../src/structures/StageInstance.ts","../../src/managers/StageInstanceManager.ts","../../src/managers/GuildEmojiManager.ts","../../src/structures/BaseInvite.ts","../../src/structures/InviteGuild.ts","../../src/structures/GuildInvite.ts","../../src/managers/GuildInviteManager.ts","../../src/managers/GuildStickerManager.ts","../../src/managers/GuildManager.ts","../../src/managers/GuildMemberRoleManager.ts","../../src/structures/GuildMember.ts","../../src/managers/GuildMemberManager.ts","../../src/managers/ReactionUserManager.ts","../../src/structures/MessageReaction.ts","../../src/managers/ReactionManager.ts","../../src/util/equal.ts","../../src/structures/Attachment.ts","../../src/structures/Embed.ts","../../src/structures/MessageMentions.ts","../../src/structures/PollAnswer.ts","../../src/structures/Poll.ts","../../src/structures/Message.ts","../../src/util/messages.ts","../../src/managers/MessageManager.ts","../../src/structures/Role.ts","../../src/managers/RoleManager.ts","../../src/managers/WebhookManager.ts","../../src/structures/GuildTemplate.ts","../../src/managers/GuildTemplateManager.ts","../../src/structures/VoiceState.ts","../../src/managers/VoiceStateManager.ts","../../src/structures/RichPresenceAssets.ts","../../src/structures/Activity.ts","../../src/structures/Presence.ts","../../src/managers/PresenceManager.ts","../../src/managers/ThreadManager.ts","../../src/structures/ThreadMember.ts","../../src/managers/ThreadMemberManager.ts","../../src/managers/UserManager.ts","../../src/structures/GroupDMInvite.ts","../../src/structures/Widget.ts","../../src/structures/StickerPack.ts","../../src/structures/AutoModerationActionExecution.ts","../../src/structures/ClientUser.ts","../../src/structures/Typing.ts","../../src/util/dispatch.ts","../../src/actions/Action.ts","../../src/util/DispatchQueue.ts","../../src/util/errors.ts","../../src/GatewayClient.ts","../../src/util/decorators.ts"],"sourcesContent":["import { Listener } from \"@wolfstar/http-framework\";\r\nimport type { Awaitable } from \"@wolfstar/plugin-cache\";\r\nimport type { GatewayEventMap, GatewayEventName } from \"./util/events.js\";\r\n\r\n/**\r\n * A {@link Listener} bound to one of the {@link GatewayEventMap} events of the {@link GatewayClient}, with strongly\r\n * typed arguments. It is loaded from the `listeners` directory by `client.load()` like any other listener.\r\n *\r\n * @example\r\n * ```typescript\r\n * // listeners/log-messages.ts\r\n * import { EventGatewayListener, type Message } from '@wolfstar/plugin-gateway';\r\n *\r\n * export class LogMessagesListener extends EventGatewayListener<'messageCreate'> {\r\n * public constructor(context: EventGatewayListener.LoaderContext) {\r\n * super(context, { event: 'messageCreate' });\r\n * }\r\n *\r\n * public override run(message: Message) {\r\n * console.log(`${message.author.username}: ${message.content}`);\r\n * }\r\n * }\r\n * ```\r\n */\r\nexport abstract class EventGatewayListener<\r\n Event extends GatewayEventName = GatewayEventName,\r\n> extends Listener<EventGatewayListener.ResolvedOptions<Event>> {\r\n /**\r\n * Whether this listener unloads itself after its first run.\r\n */\r\n public readonly once: boolean;\r\n\r\n public constructor(\r\n context: EventGatewayListener.LoaderContext,\r\n options: EventGatewayListener.Options<Event>,\r\n ) {\r\n super(context, { ...options, emitter: \"client\" });\r\n this.once = options.once ?? false;\r\n\r\n if (this.once) {\r\n // `_listener` is what the framework's loader strategy attaches to the emitter, wrapping it is the only way to\r\n // unload the piece on its first run while keeping `run` overridable.\r\n // oxlint-disable-next-line no-underscore-dangle\r\n const listener = this._listener;\r\n // oxlint-disable-next-line no-underscore-dangle\r\n this._listener = async (...args: readonly unknown[]) => {\r\n await this.unload();\r\n return listener(...args);\r\n };\r\n }\r\n }\r\n\r\n public abstract override run(...args: GatewayEventMap[Event]): Awaitable<unknown>;\r\n}\r\n\r\nexport namespace EventGatewayListener {\r\n export type LoaderContext = Listener.LoaderContext;\r\n\r\n export interface Options<Event extends GatewayEventName = GatewayEventName> extends Omit<\r\n Listener.Options,\r\n \"emitter\" | \"event\"\r\n > {\r\n /**\r\n * The event to listen to.\r\n */\r\n event: Event;\r\n /**\r\n * Whether to unload the listener after its first run.\r\n *\r\n * @default false\r\n */\r\n once?: boolean;\r\n }\r\n\r\n export interface ResolvedOptions<Event extends GatewayEventName = GatewayEventName>\r\n extends Listener.Options {\r\n event: Event;\r\n once?: boolean;\r\n }\r\n}\r\n","import {\r\n type OverwriteType,\r\n PermissionFlagsBits,\r\n type APIGuildForumDefaultReactionEmoji,\r\n type APIGuildForumTag,\r\n type APIOverwrite,\r\n type ChannelFlags,\r\n type ChannelType,\r\n type ForumLayoutType,\r\n type RESTPatchAPIChannelJSONBody,\r\n type SortOrderType,\r\n type ThreadAutoArchiveDuration,\r\n type VideoQualityMode,\r\n} from \"discord-api-types/v10\";\r\nimport {\r\n PermissionsBitField,\r\n type PermissionResolvable,\r\n type PermissionsString,\r\n} from \"./PermissionsBitField.js\";\r\n\r\n/**\r\n * Something with an ID: a structure, or the ID itself.\r\n */\r\nexport type IdResolvable = string | { id: string | null };\r\n\r\n/**\r\n * Gets the ID of an {@link IdResolvable}.\r\n *\r\n * @param value The ID, or something with one.\r\n */\r\nexport function resolveId(value: IdResolvable): string {\r\n const id = typeof value === \"string\" ? value : value.id;\r\n if (!id) throw new TypeError(\"Cannot resolve an ID from a structure without one\");\r\n return id;\r\n}\r\n\r\n/**\r\n * A permission overwrite to set on a channel: whom it targets, and what it allows and denies.\r\n */\r\nexport interface OverwriteData {\r\n /**\r\n * The role or member the overwrite targets.\r\n */\r\n id: IdResolvable;\r\n /**\r\n * Whether `id` is a role or a member. Required when `id` is a plain ID.\r\n */\r\n type: OverwriteType;\r\n allow?: PermissionResolvable;\r\n deny?: PermissionResolvable;\r\n}\r\n\r\n/**\r\n * Permissions to change in an overwrite: `true` allows, `false` denies, `null` falls back to the role or `@everyone`.\r\n */\r\nexport type PermissionOverwriteOptions = Partial<Record<PermissionsString, boolean | null>>;\r\n\r\n/**\r\n * Converts an {@link OverwriteData} to the API's shape.\r\n */\r\nexport function toAPIOverwrite(overwrite: OverwriteData): APIOverwrite {\r\n return {\r\n id: resolveId(overwrite.id),\r\n type: overwrite.type,\r\n allow: String(PermissionsBitField.resolve(overwrite.allow ?? 0n)),\r\n deny: String(PermissionsBitField.resolve(overwrite.deny ?? 0n)),\r\n };\r\n}\r\n\r\n/**\r\n * Applies {@link PermissionOverwriteOptions} to an overwrite's allowed and denied permissions.\r\n *\r\n * @param options The permissions to change.\r\n * @param initial The overwrite's current permissions, none by default.\r\n */\r\nexport function resolveOverwriteOptions(\r\n options: PermissionOverwriteOptions,\r\n initial: { allow?: bigint; deny?: bigint } = {},\r\n): { allow: bigint; deny: bigint } {\r\n let allow = initial.allow ?? 0n;\r\n let deny = initial.deny ?? 0n;\r\n for (const [name, value] of Object.entries(options)) {\r\n const bit = PermissionFlagsBits[name as PermissionsString];\r\n if (value === undefined || bit === undefined) continue;\r\n allow &= ~bit;\r\n deny &= ~bit;\r\n if (value === true) allow |= bit;\r\n else if (value === false) deny |= bit;\r\n }\r\n\r\n return { allow, deny };\r\n}\r\n\r\n/**\r\n * A forum tag to set: an existing one (with its ID) or a new one.\r\n */\r\nexport type GuildForumTagData = Omit<APIGuildForumTag, \"id\" | \"moderated\"> &\r\n Partial<Pick<APIGuildForumTag, \"id\" | \"moderated\">>;\r\n\r\n/**\r\n * The fields of a guild channel that can be edited. Each applies to the channel types that have it.\r\n */\r\nexport interface GuildChannelEditOptions {\r\n name?: string;\r\n /**\r\n * Converts a text channel to an announcement channel, or back.\r\n */\r\n type?: ChannelType.GuildText | ChannelType.GuildAnnouncement;\r\n position?: number;\r\n topic?: string | null;\r\n nsfw?: boolean;\r\n rateLimitPerUser?: number;\r\n bitrate?: number;\r\n userLimit?: number;\r\n permissionOverwrites?: readonly OverwriteData[];\r\n /**\r\n * The category, `null` to move the channel out of its category.\r\n */\r\n parent?: IdResolvable | null;\r\n /**\r\n * Whether to copy the category's overwrites: the new one with `parent`, else the current one. Exclusive with\r\n * `permissionOverwrites`.\r\n */\r\n lockPermissions?: boolean;\r\n rtcRegion?: string | null;\r\n videoQualityMode?: VideoQualityMode;\r\n defaultAutoArchiveDuration?: ThreadAutoArchiveDuration;\r\n availableTags?: readonly GuildForumTagData[];\r\n defaultReactionEmoji?: APIGuildForumDefaultReactionEmoji | null;\r\n defaultThreadRateLimitPerUser?: number;\r\n defaultSortOrder?: SortOrderType | null;\r\n defaultForumLayout?: ForumLayoutType;\r\n flags?: ChannelFlags;\r\n /**\r\n * Whether a thread is archived.\r\n */\r\n archived?: boolean;\r\n /**\r\n * Whether a thread is locked: only moderators can unarchive it.\r\n */\r\n locked?: boolean;\r\n /**\r\n * Whether non-moderators can add members to a private thread.\r\n */\r\n invitable?: boolean;\r\n /**\r\n * The minutes of inactivity after which a thread is archived.\r\n */\r\n autoArchiveDuration?: ThreadAutoArchiveDuration;\r\n /**\r\n * The IDs of the tags of a thread of a forum or media channel.\r\n */\r\n appliedTags?: readonly string[];\r\n reason?: string;\r\n}\r\n\r\n/**\r\n * Converts {@link GuildChannelEditOptions} to the API's body, without `lockPermissions` which needs the parent.\r\n */\r\nexport function toChannelBody(\r\n options: GuildChannelEditOptions | GuildChannelCreateOptions,\r\n): RESTPatchAPIChannelJSONBody {\r\n const body: Record<string, unknown> = {\r\n name: options.name,\r\n type: options.type,\r\n position: options.position,\r\n topic: options.topic,\r\n nsfw: options.nsfw,\r\n rate_limit_per_user: options.rateLimitPerUser,\r\n bitrate: options.bitrate,\r\n user_limit: options.userLimit,\r\n permission_overwrites: options.permissionOverwrites?.map(toAPIOverwrite),\r\n parent_id:\r\n options.parent === undefined\r\n ? undefined\r\n : options.parent === null\r\n ? null\r\n : resolveId(options.parent),\r\n rtc_region: options.rtcRegion,\r\n video_quality_mode: options.videoQualityMode,\r\n default_auto_archive_duration: options.defaultAutoArchiveDuration,\r\n available_tags: options.availableTags,\r\n default_reaction_emoji: options.defaultReactionEmoji,\r\n default_thread_rate_limit_per_user: options.defaultThreadRateLimitPerUser,\r\n default_sort_order: options.defaultSortOrder,\r\n default_forum_layout: options.defaultForumLayout,\r\n flags: \"flags\" in options ? options.flags : undefined,\r\n archived: \"archived\" in options ? options.archived : undefined,\r\n locked: \"locked\" in options ? options.locked : undefined,\r\n invitable: \"invitable\" in options ? options.invitable : undefined,\r\n auto_archive_duration:\r\n \"autoArchiveDuration\" in options ? options.autoArchiveDuration : undefined,\r\n applied_tags: \"appliedTags\" in options ? options.appliedTags : undefined,\r\n };\r\n for (const key of Object.keys(body)) if (body[key] === undefined) delete body[key];\r\n return body as RESTPatchAPIChannelJSONBody;\r\n}\r\n\r\n/**\r\n * The options to create a guild channel with.\r\n */\r\nexport interface GuildChannelCreateOptions extends Omit<\r\n GuildChannelEditOptions,\r\n | \"type\"\r\n | \"lockPermissions\"\r\n | \"flags\"\r\n | \"archived\"\r\n | \"locked\"\r\n | \"invitable\"\r\n | \"autoArchiveDuration\"\r\n | \"appliedTags\"\r\n> {\r\n name: string;\r\n type?: ChannelType;\r\n}\r\n","import { container } from \"@wolfstar/http-framework\";\r\nimport type { GatewayClient } from \"../GatewayClient.js\";\r\n\r\nexport { container };\r\n\r\n/**\r\n * Gets the {@link GatewayClient} registered in the framework's container.\r\n *\r\n * @remarks\r\n * The framework's `Client` registers itself as `container.client` on construction, so this is the most recently\r\n * constructed `GatewayClient`. It throws when that client is a plain `Client`.\r\n */\r\nexport function getGatewayClient(): GatewayClient {\r\n const { client } = container;\r\n if (!client || !(\"gateway\" in client)) {\r\n throw new Error(\"No GatewayClient has been constructed yet\");\r\n }\r\n\r\n return client as GatewayClient;\r\n}\r\n","import { Structure as BaseStructure } from \"@discordjs/structures\";\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 subclasses below 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 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\n/**\n * The base class every structure extends: `@discordjs/structures`' `Structure`, with its data and patch/clone methods\n * made reachable from subclasses outside of discord.js.\n *\n * @remarks\n * Structures never hold a reference to a client, so they can be built from any raw payload, be it a gateway dispatch,\n * a cache hit, or a REST response.\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 readonly #timestamps = new Map<string, number | null>();\n\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. Subclasses narrow its type. Public only\n * so that {@link Structure.dropRelations} can check relation names against it.\n *\n * @internal\n */\n declare public [kRelations]: object;\n\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 this[kRelations] = relations;\n this.optimizeData(data);\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) this.#timestamps.set(key, value ? Date.parse(value) : null);\n }\n\n /** Gets a timestamp previously parsed by `optimizeData`. */\n protected optimizedTimestamp(key: string): number | null {\n return this.#timestamps.get(key) ?? null;\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 (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 return clone;\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] };\n for (const name of names) delete relations[name];\n this[kRelations] = relations;\n }\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 { ChannelType, type APIChannel, type Snowflake } from \"discord-api-types/v10\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, type kRelations, snowflakeTimestamp, Structure } from \"./Structure.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\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\n/**\n * The base of every channel structure, holding what all channel types share.\n *\n * @remarks\n * Concrete channels (`TextChannel`, `DMChannel`, ...) add their fields through mixins, following\n * `@discordjs/structures`' 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 Structure<\n ChannelDataType<Type>\n> {\n declare public [kRelations]: ChannelRelations;\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, relations);\n }\n\n public get id(): Snowflake {\n return this[kData].id;\n }\n\n public get type(): Type {\n return this[kData].type as Type;\n }\n\n public get flags(): number {\n return this[kData].flags ?? 0;\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 * Whether this channel is a thread.\n */\n public isThread(): boolean {\n return isThreadChannelType(this.type);\n }\n\n /**\n * Whether this channel is a direct message or a group direct message.\n */\n public isDMBased(): boolean {\n return this.type === ChannelType.DM || this.type === ChannelType.GroupDM;\n }\n\n public toString(): `<#${string}>` {\n return `<#${this.id}>`;\n }\n}\n","/**\n * Any class, abstract or not.\n */\nexport type MixinBase = abstract new (...args: any[]) => object;\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 { type ChannelType } from \"discord-api-types/v10\";\nimport { getGatewayClient } from \"../../util/container.js\";\nimport type { Channel, ChannelDataType } from \"../Channel.js\";\nimport { kPatch } from \"../Structure.js\";\n\nexport interface BaseChannelMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the REST actions every channel supports.\n */\nexport class BaseChannelMixin<Type extends ChannelType = ChannelType> {\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 getGatewayClient().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 getGatewayClient().core.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\";\r\nimport type { Channel } from \"../Channel.js\";\r\nimport { kData } from \"../Structure.js\";\r\n\r\ntype Data = { parent_id?: string | null; nsfw?: boolean };\r\n\r\nexport interface ChannelParentMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\r\n\r\n/**\r\n * Adds the parent (a category, or a channel for threads) and the age restriction of guild channels.\r\n */\r\nexport class ChannelParentMixin<Type extends ChannelType = ChannelType> {\r\n public get parentId(): string | null {\r\n return (this[kData] as Data).parent_id ?? null;\r\n }\r\n\r\n public get nsfw(): boolean {\r\n return (this[kData] as Data).nsfw ?? false;\r\n }\r\n}\r\n","import type { APIOverwrite } from \"discord-api-types/v10\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport type { PermissionOverwriteOptions } from \"../util/channels.js\";\nimport { PermissionsBitField } from \"../util/PermissionsBitField.js\";\nimport { kData, kPatch, Structure } from \"./Structure.js\";\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 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 * 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 getGatewayClient().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 getGatewayClient().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 { PermissionOverwrites } from \"../structures/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 public constructor(\n client: GatewayClient,\n channelId: string,\n guildId: string | null,\n overwrites: readonly APIOverwrite[],\n ) {\n this.client = client;\n this.channelId = channelId;\n this.guildId = guildId;\n this.#overwrites = overwrites;\n }\n\n /**\n * The overwrites of the channel.\n */\n public get cache(): PermissionOverwrites[] {\n return this.#overwrites.map(\n (overwrite) => new PermissionOverwrites({ ...overwrite, channel_id: this.channelId }),\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.core.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.core.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 {\r\n OverwriteType,\r\n PermissionFlagsBits,\r\n type APIOverwrite,\r\n type APIRole,\r\n type Snowflake,\r\n} from \"discord-api-types/v10\";\r\nimport type { AnyChannel } from \"../managers/ChannelManager.js\";\r\nimport type { GuildMember } from \"../structures/GuildMember.js\";\r\nimport type { Role } from \"../structures/Role.js\";\r\nimport { getGatewayClient } from \"./container.js\";\r\nimport { PermissionsBitField } from \"./PermissionsBitField.js\";\r\n\r\n/**\r\n * What {@link computeGuildPermissions} needs to know about a member of a guild.\r\n */\r\nexport interface GuildPermissionsContext {\r\n guildId: Snowflake;\r\n ownerId: Snowflake;\r\n userId: Snowflake;\r\n /**\r\n * The IDs of the member's roles, without `@everyone`.\r\n */\r\n memberRoleIds: readonly Snowflake[];\r\n /**\r\n * Every role of the guild, `@everyone` (whose ID is the guild's) included.\r\n */\r\n roles: readonly Pick<APIRole, \"id\" | \"permissions\">[];\r\n}\r\n\r\n/**\r\n * Computes a member's guild-wide permissions, the way Discord does before channel overwrites apply: the owner and\r\n * administrators get every permission, everyone else gets `@everyone`'s permissions combined with their roles'.\r\n *\r\n * @param context The member and the guild's roles.\r\n */\r\nexport function computeGuildPermissions(context: GuildPermissionsContext): PermissionsBitField {\r\n if (context.userId === context.ownerId) {\r\n return new PermissionsBitField(PermissionsBitField.All).freeze();\r\n }\r\n\r\n const granted = new Set([context.guildId, ...context.memberRoleIds]);\r\n let bits = 0n;\r\n for (const role of context.roles) {\r\n if (granted.has(role.id)) bits |= BigInt(role.permissions);\r\n }\r\n\r\n if ((bits & PermissionFlagsBits.Administrator) === PermissionFlagsBits.Administrator) {\r\n bits = PermissionsBitField.All;\r\n }\r\n\r\n return new PermissionsBitField(bits).freeze();\r\n}\r\n\r\n/**\r\n * Compares two roles the way Discord orders them: by position, then by ID for equal positions (older first).\r\n *\r\n * @returns A negative number when `a` is lower than `b`, a positive one when it is higher, `0` when they are the same.\r\n */\r\nexport function compareRolePositions(\r\n a: Pick<APIRole, \"id\" | \"position\">,\r\n b: Pick<APIRole, \"id\" | \"position\">,\r\n): number {\r\n if (a.position !== b.position) return a.position - b.position;\r\n // Among equal positions, the older (lower ID) role is the higher one.\r\n return Number(BigInt(b.id) - BigInt(a.id));\r\n}\r\n\r\n/**\r\n * What {@link computeChannelPermissions} needs to know about a channel and whom the permissions are for.\r\n */\r\nexport interface ChannelPermissionsContext {\r\n guildId: Snowflake;\r\n /**\r\n * The ID of the member, whose own overwrite applies last. Absent when computing a role's permissions.\r\n */\r\n userId?: Snowflake;\r\n /**\r\n * The IDs of the roles whose overwrites apply, without `@everyone`.\r\n */\r\n roleIds: readonly Snowflake[];\r\n overwrites: readonly APIOverwrite[];\r\n}\r\n\r\n/**\r\n * Applies a channel's permission overwrites to guild-wide permissions, the way Discord does: administrators keep\r\n * every permission, then the `@everyone` overwrite applies, then the roles' overwrites (combined), then the member's.\r\n *\r\n * @param base The guild-wide permissions, from {@link computeGuildPermissions}.\r\n * @param context The channel's overwrites, and the member or role.\r\n */\r\nexport function computeChannelPermissions(\r\n base: Readonly<PermissionsBitField>,\r\n context: ChannelPermissionsContext,\r\n): PermissionsBitField {\r\n if (base.has(PermissionFlagsBits.Administrator)) {\r\n return new PermissionsBitField(PermissionsBitField.All).freeze();\r\n }\r\n\r\n let bits = base.bitField;\r\n const apply = (allow: bigint, deny: bigint) => {\r\n bits = (bits & ~deny) | allow;\r\n };\r\n\r\n const everyone = context.overwrites.find((overwrite) => overwrite.id === context.guildId);\r\n if (everyone) apply(BigInt(everyone.allow), BigInt(everyone.deny));\r\n\r\n let allow = 0n;\r\n let deny = 0n;\r\n for (const overwrite of context.overwrites) {\r\n if (overwrite.type === OverwriteType.Role && context.roleIds.includes(overwrite.id)) {\r\n allow |= BigInt(overwrite.allow);\r\n deny |= BigInt(overwrite.deny);\r\n }\r\n }\r\n apply(allow, deny);\r\n\r\n const member = context.userId\r\n ? context.overwrites.find(\r\n (overwrite) => overwrite.type === OverwriteType.Member && overwrite.id === context.userId,\r\n )\r\n : undefined;\r\n if (member) apply(BigInt(member.allow), BigInt(member.deny));\r\n\r\n return new PermissionsBitField(bits).freeze();\r\n}\r\n\r\n/**\r\n * Computes the permissions of a member or role in a channel, given the channel's overwrites.\r\n *\r\n * @param guildId The ID of the channel's guild.\r\n * @param overwrites The channel's permission overwrites.\r\n * @param target A member, a role, or the ID of a member.\r\n */\r\nexport async function computeTargetPermissions(\r\n guildId: Snowflake,\r\n overwrites: readonly APIOverwrite[],\r\n target: GuildMember | Role | Snowflake,\r\n): Promise<PermissionsBitField> {\r\n const client = getGatewayClient();\r\n if (typeof target !== \"string\" && \"hoist\" in target) {\r\n // A role gets `@everyone`'s permissions and its own, then the `@everyone` and role overwrites.\r\n const everyone = await client.roles.everyone(guildId);\r\n const base = new PermissionsBitField(\r\n target.permissions.bitField | everyone.permissions.bitField,\r\n );\r\n if (base.has(PermissionFlagsBits.Administrator)) {\r\n return new PermissionsBitField(PermissionsBitField.All).freeze();\r\n }\r\n\r\n return computeChannelPermissions(base, { guildId, roleIds: [target.id], overwrites });\r\n }\r\n\r\n const member = typeof target === \"string\" ? await client.members.fetch(guildId, target) : target;\r\n return computeChannelPermissions(await member.fetchPermissions(), {\r\n guildId,\r\n userId: member.id ?? undefined,\r\n roleIds: member.roleIds,\r\n overwrites,\r\n });\r\n}\r\n\r\n/**\r\n * Computes the permissions of a member or role in a channel, fetching the channel if needed. Threads use their parent\r\n * channel's overwrites, like Discord does.\r\n *\r\n * @param channel The channel, or its ID.\r\n * @param target A member, a role, or the ID of a member.\r\n */\r\nexport async function computePermissionsIn(\r\n channel: AnyChannel | Snowflake,\r\n target: GuildMember | Role | Snowflake,\r\n): Promise<PermissionsBitField> {\r\n const client = getGatewayClient();\r\n let resolved = typeof channel === \"string\" ? await client.channels.fetch(channel) : channel;\r\n let data = resolved.toJSON() as OverwriteHolder;\r\n if (resolved.isThread() && data.parent_id) {\r\n resolved = await client.channels.fetch(data.parent_id);\r\n data = resolved.toJSON() as OverwriteHolder;\r\n }\r\n\r\n if (!data.guild_id) throw new Error(`Channel ${resolved.id} has no known guild`);\r\n return computeTargetPermissions(data.guild_id, data.permission_overwrites ?? [], target);\r\n}\r\n\r\ntype OverwriteHolder = {\r\n guild_id?: string;\r\n parent_id?: string | null;\r\n permission_overwrites?: APIOverwrite[];\r\n};\r\n","import type { GuildChannelEditOptions } from \"../../util/channels.js\";\r\nimport { getGatewayClient } from \"../../util/container.js\";\r\nimport type { Channel } from \"../Channel.js\";\r\nimport { kPatch } from \"../Structure.js\";\r\n\r\n/**\r\n * Edits a channel through `client.channels` and patches the structure with the result. Shared by the mixins' setters.\r\n *\r\n * @param channel The channel structure.\r\n * @param options The fields to edit.\r\n */\r\nexport async function editChannel<Value extends Channel>(\r\n channel: Value,\r\n options: GuildChannelEditOptions,\r\n): Promise<Value> {\r\n const edited = await getGatewayClient().channels.edit(channel.id, options);\r\n return channel[kPatch](edited.toJSON() as never);\r\n}\r\n","import type { ChannelType } from \"discord-api-types/v10\";\r\nimport type { Channel } from \"../Channel.js\";\r\nimport { kData, kPatch } from \"../Structure.js\";\r\nimport type { APIOverwrite } from \"discord-api-types/v10\";\r\nimport { PermissionOverwriteManager } from \"../../managers/PermissionOverwriteManager.js\";\r\nimport type { IdResolvable } from \"../../util/channels.js\";\r\nimport { getGatewayClient } from \"../../util/container.js\";\r\nimport { computeTargetPermissions } from \"../../util/permissions.js\";\r\nimport type { PermissionsBitField } from \"../../util/PermissionsBitField.js\";\r\nimport type { GuildMember } from \"../GuildMember.js\";\r\nimport type { Role } from \"../Role.js\";\r\nimport { editChannel } from \"./edit.js\";\r\n\r\ntype Data = {\r\n guild_id?: string;\r\n parent_id?: string | null;\r\n position?: number;\r\n permission_overwrites?: APIOverwrite[];\r\n};\r\n\r\nexport interface ChannelPermissionMixin<\r\n Type extends ChannelType = ChannelType,\r\n> extends Channel<Type> {}\r\n\r\n/**\r\n * Adds the position and permission overwrites of guild channels other than threads.\r\n */\r\nexport class ChannelPermissionMixin<Type extends ChannelType = ChannelType> {\r\n public get position(): number {\r\n return (this[kData] as Data).position ?? 0;\r\n }\r\n\r\n /**\r\n * The permission overwrites of the channel.\r\n */\r\n public get permissionOverwrites(): PermissionOverwriteManager {\r\n const data = this[kData] as Data;\r\n return new PermissionOverwriteManager(\r\n getGatewayClient(),\r\n this.id,\r\n data.guild_id ?? null,\r\n data.permission_overwrites ?? [],\r\n );\r\n }\r\n\r\n /**\r\n * Moves the channel.\r\n *\r\n * @param position The new position, or the offset from the current one with `relative`.\r\n * @param options Whether the position is relative, and the reason for the audit log.\r\n */\r\n public async setPosition(\r\n position: number,\r\n options: { relative?: boolean; reason?: string } = {},\r\n ): Promise<this> {\r\n const { guild_id: guildId } = this[kData] as Data;\r\n if (!guildId) throw new Error(`Channel ${this.id} has no known guild`);\r\n\r\n const target = options.relative ? this.position + position : position;\r\n await getGatewayClient()\r\n .guilds.channels(guildId)\r\n .setPositions([{ channel: this.id, position: target }], options.reason);\r\n return this[kPatch]({ position: target } as never);\r\n }\r\n\r\n /**\r\n * Moves the channel into a category, or out of its category.\r\n *\r\n * @param parent The category, `null` to move the channel out.\r\n * @param options Whether to copy the category's overwrites (the default), and the reason for the audit log.\r\n */\r\n public setParent(\r\n parent: IdResolvable | null,\r\n options: { lockPermissions?: boolean; reason?: string } = {},\r\n ): Promise<this> {\r\n return editChannel(this, {\r\n parent,\r\n lockPermissions: options.lockPermissions ?? true,\r\n reason: options.reason,\r\n });\r\n }\r\n\r\n public setNSFW(nsfw = true, reason?: string): Promise<this> {\r\n return editChannel(this, { nsfw, reason });\r\n }\r\n\r\n /**\r\n * Replaces the channel's overwrites with its category's.\r\n *\r\n * @param reason The reason for the audit log.\r\n */\r\n public lockPermissions(reason?: string): Promise<this> {\r\n if (!(this[kData] as Data).parent_id) {\r\n throw new Error(`Channel ${this.id} has no category to sync its permissions with`);\r\n }\r\n\r\n return editChannel(this, { lockPermissions: true, reason });\r\n }\r\n\r\n /**\r\n * Fetches whether the channel's overwrites are the same as its category's. `null` without a category.\r\n */\r\n public async fetchPermissionsLocked(): Promise<boolean | null> {\r\n const { parent_id: parentId } = this[kData] as Data;\r\n if (!parentId) return null;\r\n\r\n const parent = (await getGatewayClient().channels.fetch(parentId)).toJSON() as Data;\r\n const own = (this[kData] as Data).permission_overwrites ?? [];\r\n const theirs = parent.permission_overwrites ?? [];\r\n return (\r\n own.length === theirs.length &&\r\n own.every((overwrite) =>\r\n theirs.some(\r\n (other) =>\r\n other.id === overwrite.id &&\r\n other.type === overwrite.type &&\r\n other.allow === overwrite.allow &&\r\n other.deny === overwrite.deny,\r\n ),\r\n )\r\n );\r\n }\r\n\r\n /**\r\n * Fetches the permissions of a member or role in the channel: their guild permissions with the channel's overwrites\r\n * applied. discord.js: `channel.permissionsFor(memberOrRole)`.\r\n *\r\n * @param target A member, a role, or the ID of a member.\r\n */\r\n public async fetchPermissionsFor(\r\n target: GuildMember | Role | string,\r\n ): Promise<Readonly<PermissionsBitField>> {\r\n const { guild_id: guildId, permission_overwrites: overwrites = [] } = this[kData] as Data;\r\n if (!guildId) throw new Error(`Channel ${this.id} has no known guild`);\r\n return computeTargetPermissions(guildId, overwrites, target);\r\n }\r\n}\r\n","import type { ChannelType } from \"discord-api-types/v10\";\r\nimport type { Channel } from \"../Channel.js\";\r\nimport { kData } from \"../Structure.js\";\r\nimport { editChannel } from \"./edit.js\";\r\n\r\ntype Data = { rate_limit_per_user?: number };\r\n\r\nexport interface ChannelSlowmodeMixin<\r\n Type extends ChannelType = ChannelType,\r\n> extends Channel<Type> {}\r\n\r\n/**\r\n * Adds the slowmode of channels users can send messages in.\r\n */\r\nexport class ChannelSlowmodeMixin<Type extends ChannelType = ChannelType> {\r\n /**\r\n * The slowmode, in seconds. `0` when disabled.\r\n */\r\n public get rateLimitPerUser(): number {\r\n return (this[kData] as Data).rate_limit_per_user ?? 0;\r\n }\r\n\r\n /**\r\n * Sets the slowmode.\r\n *\r\n * @param rateLimitPerUser The slowmode, in seconds, `0` to disable it.\r\n * @param reason The reason for the audit log.\r\n */\r\n public setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise<this> {\r\n return editChannel(this, { rateLimitPerUser, reason });\r\n }\r\n}\r\n","import type { GatewayClient } from \"../GatewayClient.js\";\r\nimport type {\r\n AnyThreadChannel,\r\n FetchArchivedThreadsOptions,\r\n FetchedThreads,\r\n ThreadCreateOptions,\r\n} from \"./ThreadManager.js\";\r\n\r\n/**\r\n * Manages the threads of one channel: `client.threads`, with the channel's ID filled in.\r\n */\r\nexport class ChannelThreadManager {\r\n public readonly client: GatewayClient;\r\n public readonly channelId: string;\r\n public readonly guildId: string | null;\r\n\r\n public constructor(client: GatewayClient, channelId: string, guildId: string | null) {\r\n this.client = client;\r\n this.channelId = channelId;\r\n this.guildId = guildId;\r\n }\r\n\r\n /**\r\n * Creates a thread in the channel, or a post in a forum or media channel (with `message`).\r\n *\r\n * @param options The thread's name and settings.\r\n */\r\n public create(options: ThreadCreateOptions): Promise<AnyThreadChannel> {\r\n return this.client.threads.create(this.channelId, options);\r\n }\r\n\r\n /**\r\n * Fetches the active threads of the channel, and caches them.\r\n */\r\n public async fetchActive(): Promise<FetchedThreads> {\r\n if (!this.guildId) throw new Error(`Channel ${this.channelId} has no known guild`);\r\n\r\n // Discord only lists the active threads of a whole guild.\r\n const { threads, members } = await this.client.threads.fetchActive(this.guildId);\r\n const own = threads.filter((thread) => thread.parentId === this.channelId);\r\n const ids = new Set(own.map((thread) => thread.id));\r\n return {\r\n threads: own,\r\n members: members.filter((member) => member.threadId && ids.has(member.threadId)),\r\n hasMore: false,\r\n };\r\n }\r\n\r\n /**\r\n * Fetches the archived threads of the channel, and caches them.\r\n *\r\n * @param options Public or private threads, and the page.\r\n */\r\n public fetchArchived(options?: FetchArchivedThreadsOptions): Promise<FetchedThreads> {\r\n return this.client.threads.fetchArchived(this.channelId, options);\r\n }\r\n}\r\n","import type { ChannelType } from \"discord-api-types/v10\";\r\nimport { ChannelThreadManager } from \"../../managers/ChannelThreadManager.js\";\r\nimport { getGatewayClient } from \"../../util/container.js\";\r\nimport type { Channel } from \"../Channel.js\";\r\nimport { kData } from \"../Structure.js\";\r\n\r\ntype Data = { guild_id?: string };\r\n\r\nexport interface ChannelThreadsMixin<\r\n Type extends ChannelType = ChannelType,\r\n> extends Channel<Type> {}\r\n\r\n/**\r\n * Adds the threads of the channels that can have threads.\r\n */\r\nexport class ChannelThreadsMixin<Type extends ChannelType = ChannelType> {\r\n /**\r\n * The threads of the channel.\r\n */\r\n public get threads(): ChannelThreadManager {\r\n return new ChannelThreadManager(\r\n getGatewayClient(),\r\n this.id,\r\n (this[kData] as Data).guild_id ?? null,\r\n );\r\n }\r\n}\r\n","import type { ChannelType } from \"discord-api-types/v10\";\r\nimport type { WebhookCreateOptions } from \"../../managers/WebhookManager.js\";\r\nimport { getGatewayClient } from \"../../util/container.js\";\r\nimport type { Channel } from \"../Channel.js\";\r\nimport type { Webhook } from \"../Webhook.js\";\r\n\r\nexport interface ChannelWebhooksMixin<\r\n Type extends ChannelType = ChannelType,\r\n> extends Channel<Type> {}\r\n\r\n/**\r\n * Adds the webhook actions of the channels that can have webhooks.\r\n */\r\nexport class ChannelWebhooksMixin<Type extends ChannelType = ChannelType> {\r\n /**\r\n * Fetches the webhooks of the channel.\r\n */\r\n public fetchWebhooks(): Promise<Webhook[]> {\r\n return getGatewayClient().webhooks.fetchChannel(this.id);\r\n }\r\n\r\n /**\r\n * Creates a webhook in the channel.\r\n *\r\n * @param options The webhook's name and avatar, and the reason for the audit log.\r\n */\r\n public createWebhook(options: WebhookCreateOptions): Promise<Webhook> {\r\n return getGatewayClient().webhooks.create(this.id, options);\r\n }\r\n}\r\n","import type { ChannelType } from \"discord-api-types/v10\";\r\nimport type { Channel } from \"../Channel.js\";\r\nimport { kData } from \"../Structure.js\";\r\nimport { editChannel } from \"./edit.js\";\r\n\r\ntype Data = { topic?: string | null };\r\n\r\nexport interface ChannelTopicMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\r\n\r\n/**\r\n * Adds the topic of text, announcement, forum, and media channels.\r\n */\r\nexport class ChannelTopicMixin<Type extends ChannelType = ChannelType> {\r\n public get topic(): string | null {\r\n return (this[kData] as Data).topic ?? null;\r\n }\r\n\r\n public setTopic(topic: string | null, reason?: string): Promise<this> {\r\n return editChannel(this, { topic, reason });\r\n }\r\n}\r\n","import type {\r\n APIGuildForumDefaultReactionEmoji,\r\n APIGuildForumTag,\r\n APIOverwrite,\r\n ChannelType,\r\n ForumLayoutType,\r\n SortOrderType,\r\n ThreadAutoArchiveDuration,\r\n VideoQualityMode,\r\n} from \"discord-api-types/v10\";\r\nimport type { Channel } from \"../Channel.js\";\r\nimport { getGatewayClient } from \"../../util/container.js\";\r\nimport type { Guild } from \"../Guild.js\";\r\nimport { kData, kRelations } from \"../Structure.js\";\r\nimport type { GuildChannelCreateOptions, GuildChannelEditOptions } from \"../../util/channels.js\";\r\nimport type { AnyChannel } from \"../../managers/ChannelManager.js\";\r\nimport { editChannel } from \"./edit.js\";\r\n\r\ntype Data = { guild_id?: string; name?: string | null };\r\n\r\n// Every field `clone` copies, whichever the channel type.\r\ntype CloneableData = Data & {\r\n topic?: string | null;\r\n nsfw?: boolean;\r\n bitrate?: number;\r\n user_limit?: number;\r\n rate_limit_per_user?: number;\r\n parent_id?: string | null;\r\n position?: number;\r\n rtc_region?: string | null;\r\n video_quality_mode?: VideoQualityMode;\r\n default_auto_archive_duration?: ThreadAutoArchiveDuration;\r\n available_tags?: APIGuildForumTag[];\r\n default_reaction_emoji?: APIGuildForumDefaultReactionEmoji | null;\r\n default_thread_rate_limit_per_user?: number;\r\n default_sort_order?: SortOrderType | null;\r\n default_forum_layout?: ForumLayoutType;\r\n permission_overwrites?: APIOverwrite[];\r\n};\r\n\r\nexport interface GuildChannelMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\r\n\r\n/**\r\n * Adds the fields every guild channel has, threads included.\r\n */\r\nexport class GuildChannelMixin<Type extends ChannelType = ChannelType> {\r\n /**\r\n * The ID of the guild, when the payload included it.\r\n */\r\n public get guildId(): string | null {\r\n return (this[kData] as Data).guild_id ?? null;\r\n }\r\n\r\n /**\r\n * The guild, from the cache. `null` when the guild is not cached, or when the channel was not built by a manager: use\r\n * `fetchGuild()` to always get it.\r\n */\r\n public get guild(): Guild | null {\r\n return this[kRelations].guild ?? null;\r\n }\r\n\r\n /**\r\n * Fetches the guild, cache first. `null` when the payload did not include the guild's ID.\r\n */\r\n public async fetchGuild(): Promise<Guild | null> {\r\n const { guildId } = this;\r\n return guildId ? getGatewayClient().guilds.fetch(guildId) : null;\r\n }\r\n\r\n public get name(): string {\r\n return (this[kData] as Data).name ?? \"\";\r\n }\r\n\r\n /**\r\n * Edits the channel.\r\n *\r\n * @param options The fields to edit, and the reason for the audit log.\r\n */\r\n public edit(options: GuildChannelEditOptions): Promise<this> {\r\n return editChannel(this, options);\r\n }\r\n\r\n public setName(name: string, reason?: string): Promise<this> {\r\n return editChannel(this, { name, reason });\r\n }\r\n\r\n /**\r\n * Creates a copy of the channel in its guild: same type, name, settings, and overwrites.\r\n *\r\n * @param options The fields to change on the copy.\r\n */\r\n public async clone(options: Partial<GuildChannelCreateOptions> = {}): Promise<AnyChannel> {\r\n const { guildId } = this;\r\n if (!guildId) throw new Error(`Channel ${this.id} has no known guild`);\r\n\r\n const data = this[kData] as CloneableData;\r\n return getGatewayClient()\r\n .guilds.channels(guildId)\r\n .create({\r\n name: data.name ?? \"\",\r\n type: this.type,\r\n topic: data.topic,\r\n nsfw: data.nsfw,\r\n bitrate: data.bitrate,\r\n userLimit: data.user_limit,\r\n rateLimitPerUser: data.rate_limit_per_user,\r\n parent: data.parent_id,\r\n position: data.position,\r\n rtcRegion: data.rtc_region,\r\n videoQualityMode: data.video_quality_mode,\r\n defaultAutoArchiveDuration: data.default_auto_archive_duration,\r\n availableTags: data.available_tags,\r\n defaultReactionEmoji: data.default_reaction_emoji,\r\n defaultThreadRateLimitPerUser: data.default_thread_rate_limit_per_user,\r\n defaultSortOrder: data.default_sort_order,\r\n defaultForumLayout: data.default_forum_layout,\r\n permissionOverwrites: data.permission_overwrites?.map((overwrite) => ({\r\n id: overwrite.id,\r\n type: overwrite.type,\r\n allow: BigInt(overwrite.allow),\r\n deny: BigInt(overwrite.deny),\r\n })),\r\n ...options,\r\n });\r\n }\r\n}\r\n","import type { GatewayClient } from \"../GatewayClient.js\";\r\nimport type { Message } from \"../structures/Message.js\";\r\nimport type { FetchOptions } from \"./CachedManager.js\";\r\nimport type { EmojiIdentifierResolvable } from \"../structures/ReactionEmoji.js\";\r\nimport type { User } from \"../structures/User.js\";\r\nimport type {\r\n MessageListOptions,\r\n MessageThreadCreateOptions,\r\n PinnedMessage,\r\n} from \"./MessageManager.js\";\r\nimport type { AnyThreadChannel } from \"./ThreadManager.js\";\r\nimport type {\r\n MessageCreateOptions,\r\n MessageEditOptions,\r\n MessagePayloadResolvable,\r\n} from \"../util/messages.js\";\r\n\r\n/**\r\n * Manages the messages of one channel: `client.messages`, with the channel's ID filled in.\r\n */\r\nexport class ChannelMessageManager {\r\n public readonly client: GatewayClient;\r\n public readonly channelId: string;\r\n\r\n public constructor(client: GatewayClient, channelId: string) {\r\n this.client = client;\r\n this.channelId = channelId;\r\n }\r\n\r\n /**\r\n * Gets a message of the channel from the cache.\r\n */\r\n public get(messageId: string): Promise<Message | undefined> {\r\n return this.client.messages.get(this.channelId, messageId);\r\n }\r\n\r\n /**\r\n * Gets a message of the channel from the cache, falling back to the API.\r\n */\r\n public fetch(messageId: string, options?: FetchOptions): Promise<Message> {\r\n return options\r\n ? this.client.messages.fetch(this.channelId, messageId, options)\r\n : this.client.messages.fetch(this.channelId, messageId);\r\n }\r\n\r\n /**\r\n * Lists the messages of the channel, newest first.\r\n */\r\n public list(options?: MessageListOptions): Promise<Message[]> {\r\n return this.client.messages.list(this.channelId, options);\r\n }\r\n\r\n public send(options: MessagePayloadResolvable<MessageCreateOptions>): Promise<Message> {\r\n return this.client.messages.send(this.channelId, options);\r\n }\r\n\r\n public edit(\r\n messageId: string,\r\n options: MessagePayloadResolvable<MessageEditOptions>,\r\n ): Promise<Message> {\r\n return this.client.messages.edit(this.channelId, messageId, options);\r\n }\r\n\r\n public delete(messageId: string, reason?: string): Promise<void> {\r\n return this.client.messages.delete(this.channelId, messageId, reason);\r\n }\r\n\r\n public fetchPins(options?: { limit?: number; before?: Date | number }): Promise<{\r\n items: PinnedMessage[];\r\n hasMore: boolean;\r\n }> {\r\n return this.client.messages.fetchPins(this.channelId, options);\r\n }\r\n\r\n public pin(messageId: string, reason?: string): Promise<void> {\r\n return this.client.messages.pin(this.channelId, messageId, reason);\r\n }\r\n\r\n public unpin(messageId: string, reason?: string): Promise<void> {\r\n return this.client.messages.unpin(this.channelId, messageId, reason);\r\n }\r\n\r\n public crosspost(messageId: string): Promise<Message> {\r\n return this.client.messages.crosspost(this.channelId, messageId);\r\n }\r\n\r\n public bulkDelete(messages: readonly string[] | number, filterOld = false): Promise<string[]> {\r\n return this.client.messages.bulkDelete(this.channelId, messages, filterOld);\r\n }\r\n\r\n public forward(messageId: string, targetChannelId: string): Promise<Message> {\r\n return this.client.messages.forward(this.channelId, messageId, targetChannelId);\r\n }\r\n\r\n public react(messageId: string, emoji: EmojiIdentifierResolvable): Promise<void> {\r\n return this.client.messages.react(this.channelId, messageId, emoji);\r\n }\r\n\r\n public removeReactionEmoji(messageId: string, emoji: EmojiIdentifierResolvable): Promise<void> {\r\n return this.client.messages.removeReactionEmoji(this.channelId, messageId, emoji);\r\n }\r\n\r\n public removeAllReactions(messageId: string): Promise<void> {\r\n return this.client.messages.removeAllReactions(this.channelId, messageId);\r\n }\r\n\r\n public startThread(\r\n messageId: string,\r\n options: MessageThreadCreateOptions,\r\n ): Promise<AnyThreadChannel> {\r\n return this.client.messages.startThread(this.channelId, messageId, options);\r\n }\r\n\r\n public endPoll(messageId: string): Promise<Message> {\r\n return this.client.messages.endPoll(this.channelId, messageId);\r\n }\r\n\r\n public fetchPollAnswerVoters(\r\n messageId: string,\r\n answerId: number,\r\n options?: { limit?: number; after?: string },\r\n ): Promise<User[]> {\r\n return this.client.messages.fetchPollAnswerVoters(this.channelId, messageId, answerId, options);\r\n }\r\n}\r\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport { ChannelMessageManager } from \"../../managers/ChannelMessageManager.js\";\nimport { getGatewayClient } from \"../../util/container.js\";\nimport type { MessageCreateOptions, MessagePayloadResolvable } from \"../../util/messages.js\";\nimport type { Channel, ChannelDataType } from \"../Channel.js\";\nimport type { Message } from \"../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(getGatewayClient(), 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 getGatewayClient().messages.send(this.id, 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 getGatewayClient().core.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 getGatewayClient().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 ? getGatewayClient().messages.fetch(this.id, lastMessageId) : null;\n }\n}\n","import { type ChannelType } from \"discord-api-types/v10\";\nimport { resolveId, type IdResolvable } from \"../util/channels.js\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport { Channel } from \"./Channel.js\";\nimport { Mixin } from \"./Mixin.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 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 * A guild announcement channel.\n */\nexport class AnnouncementChannel extends Channel<ChannelType.GuildAnnouncement> {\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 getGatewayClient().core.api.channels.followAnnouncements(\n this.id,\n resolveId(channel),\n { reason },\n );\n return result.webhook_id;\n }\n}\n\nMixin(AnnouncementChannel, [\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\";\r\nimport type { Channel } from \"../Channel.js\";\r\nimport { kData } from \"../Structure.js\";\r\n\r\ntype Data = { owner_id?: string };\r\n\r\nexport interface ChannelOwnerMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\r\n\r\n/**\r\n * Adds the owner of threads and group direct messages.\r\n */\r\nexport class ChannelOwnerMixin<Type extends ChannelType = ChannelType> {\r\n public get ownerId(): string | null {\r\n return (this[kData] as Data).owner_id ?? null;\r\n }\r\n}\r\n","import type { GatewayClient } from \"../GatewayClient.js\";\r\nimport type { ThreadMember } from \"../structures/ThreadMember.js\";\r\nimport type { FetchOptions } from \"./CachedManager.js\";\r\nimport type { ThreadMemberListOptions } from \"./ThreadMemberManager.js\";\r\n\r\n/**\r\n * Manages the members of one thread: `client.threadMembers`, with the thread's ID filled in.\r\n */\r\nexport class ThreadChannelMemberManager {\r\n public readonly client: GatewayClient;\r\n public readonly threadId: string;\r\n\r\n public constructor(client: GatewayClient, threadId: string) {\r\n this.client = client;\r\n this.threadId = threadId;\r\n }\r\n\r\n /**\r\n * Gets a member of the thread from the cache.\r\n */\r\n public get(userId: string): Promise<ThreadMember | undefined> {\r\n return this.client.threadMembers.get(this.threadId, userId);\r\n }\r\n\r\n /**\r\n * Gets a member of the thread from the cache, falling back to the API.\r\n *\r\n * @param userId The ID of the user.\r\n * @param options The cache options, and whether to include the guild member (which always calls the API).\r\n */\r\n public fetch(\r\n userId: string,\r\n options: FetchOptions & { withMember?: boolean } = {},\r\n ): Promise<ThreadMember> {\r\n const { withMember, ...fetchOptions } = options;\r\n return withMember\r\n ? this.client.threadMembers.fetchWithMember(this.threadId, userId, { withMember })\r\n : this.client.threadMembers.fetch(this.threadId, userId, fetchOptions);\r\n }\r\n\r\n /**\r\n * Lists the members of the thread.\r\n */\r\n public list(options?: ThreadMemberListOptions): Promise<ThreadMember[]> {\r\n return this.client.threadMembers.list(this.threadId, options);\r\n }\r\n\r\n /**\r\n * Adds a user to the thread, the bot by default.\r\n */\r\n public add(userId = \"@me\"): Promise<void> {\r\n return this.client.threadMembers.add(this.threadId, userId);\r\n }\r\n\r\n /**\r\n * Removes a user from the thread, the bot by default.\r\n */\r\n public remove(userId = \"@me\"): Promise<void> {\r\n return this.client.threadMembers.remove(this.threadId, userId);\r\n }\r\n}\r\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 { getGatewayClient } from \"../../util/container.js\";\nimport type { Message } from \"../Message.js\";\nimport type { ThreadMember } from \"../ThreadMember.js\";\nimport { kData } 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};\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 * The members of the thread.\n */\n public get members(): ThreadChannelMemberManager {\n return new ThreadChannelMemberManager(getGatewayClient(), 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 getGatewayClient().threadMembers.add(this.id);\n return this;\n }\n\n /**\n * Leaves the thread.\n */\n public async leave(): Promise<this> {\n await getGatewayClient().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 getGatewayClient().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 getGatewayClient().threadMembers.fetch(this.id, ownerId);\n }\n}\n","import type { ChannelType } from \"discord-api-types/v10\";\r\nimport { Channel } from \"./Channel.js\";\r\nimport { Mixin } from \"./Mixin.js\";\r\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\r\nimport { ChannelOwnerMixin } from \"./mixins/ChannelOwnerMixin.js\";\r\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\r\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\r\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\r\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\r\nimport { ThreadChannelMixin } from \"./mixins/ThreadChannelMixin.js\";\r\n\r\nexport interface AnnouncementThreadChannel\r\n extends\r\n BaseChannelMixin<ChannelType.AnnouncementThread>,\r\n TextChannelMixin<ChannelType.AnnouncementThread>,\r\n GuildChannelMixin<ChannelType.AnnouncementThread>,\r\n ChannelOwnerMixin<ChannelType.AnnouncementThread>,\r\n ChannelParentMixin<ChannelType.AnnouncementThread>,\r\n ChannelSlowmodeMixin<ChannelType.AnnouncementThread>,\r\n ThreadChannelMixin<ChannelType.AnnouncementThread> {}\r\n\r\n/**\r\n * A thread of an announcement channel.\r\n */\r\nexport class AnnouncementThreadChannel extends Channel<ChannelType.AnnouncementThread> {}\r\n\r\nMixin(AnnouncementThreadChannel, [\r\n BaseChannelMixin,\r\n TextChannelMixin,\r\n GuildChannelMixin,\r\n ChannelOwnerMixin,\r\n ChannelParentMixin,\r\n ChannelSlowmodeMixin,\r\n ThreadChannelMixin,\r\n]);\r\n","import type { ChannelType } from \"discord-api-types/v10\";\r\nimport { Channel } from \"./Channel.js\";\r\nimport { Mixin } from \"./Mixin.js\";\r\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\r\n\r\nexport interface BaseChannel extends BaseChannelMixin<ChannelType> {}\r\n\r\n/**\r\n * A channel of a type no other structure covers yet.\r\n */\r\nexport class BaseChannel extends Channel<ChannelType> {}\r\n\r\nMixin(BaseChannel, [BaseChannelMixin]);\r\n","import type { ChannelType } from \"discord-api-types/v10\";\r\nimport { Channel } from \"./Channel.js\";\r\nimport { Mixin } from \"./Mixin.js\";\r\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\r\nimport { ChannelPermissionMixin } from \"./mixins/ChannelPermissionMixin.js\";\r\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\r\n\r\nexport interface CategoryChannel\r\n extends\r\n BaseChannelMixin<ChannelType.GuildCategory>,\r\n GuildChannelMixin<ChannelType.GuildCategory>,\r\n ChannelPermissionMixin<ChannelType.GuildCategory> {}\r\n\r\n/**\r\n * A guild category.\r\n */\r\nexport class CategoryChannel extends Channel<ChannelType.GuildCategory> {}\r\n\r\nMixin(CategoryChannel, [BaseChannelMixin, GuildChannelMixin, ChannelPermissionMixin]);\r\n","import { CDN } from \"@discordjs/rest\";\r\n\r\n/**\r\n * @internal The CDN URL builder shared by the structures. Structures never hold a client, so they cannot use\r\n * `container.rest.cdn`.\r\n */\r\nexport const cdn = new CDN();\r\n","import {\r\n ActivityFlagsBitField as BaseActivityFlagsBitField,\r\n AttachmentFlagsBitField as BaseAttachmentFlagsBitField,\r\n BitField,\r\n ChannelFlagsBitField as BaseChannelFlagsBitField,\r\n MessageFlagsBitField as BaseMessageFlagsBitField,\r\n type BitFieldResolvable,\r\n} from \"@discordjs/structures\";\r\nimport {\r\n GatewayIntentBits,\r\n GuildMemberFlags,\r\n GuildSystemChannelFlags,\r\n RoleFlags,\r\n UserFlags,\r\n type ActivityFlags,\r\n type AttachmentFlags,\r\n type ChannelFlags,\r\n type MessageFlags,\r\n} from \"discord-api-types/v10\";\r\n\r\n// `@discordjs/structures`' `BitField.resolve` returns a flag's enum value as is, which is a `number` for the 32-bit\r\n// flag enums: combining it with the `bigint` bits then throws \"Cannot mix BigInt and other types\". Every flags bitfield\r\n// below overrides `resolve` to always return a `bigint`, including the ones `@discordjs/structures` ships.\r\n\r\n/**\r\n * A 32-bit flags bitfield, resolving flag names to `bigint`s and serializing to a `number`.\r\n */\r\nexport abstract class NumberFlagsBitField<Flags extends string> extends BitField<Flags> {\r\n public static override resolve<Flags extends string = string>(\r\n bit: BitFieldResolvable<Flags>,\r\n ): bigint {\r\n return BigInt(super.resolve(bit));\r\n }\r\n\r\n public override toJSON(): number {\r\n return super.toJSON(true) as number;\r\n }\r\n}\r\n\r\nexport type ActivityFlagsString = keyof typeof ActivityFlags;\r\nexport type ActivityFlagsResolvable = BitFieldResolvable<ActivityFlagsString>;\r\n\r\n/**\r\n * The flags of a presence activity.\r\n */\r\nexport class ActivityFlagsBitField extends BaseActivityFlagsBitField {\r\n public static override resolve<Flags extends string = string>(\r\n bit: BitFieldResolvable<Flags>,\r\n ): bigint {\r\n return BigInt(super.resolve(bit));\r\n }\r\n}\r\n\r\nexport type AttachmentFlagsString = keyof typeof AttachmentFlags;\r\nexport type AttachmentFlagsResolvable = BitFieldResolvable<AttachmentFlagsString>;\r\n\r\n/**\r\n * The flags of a message attachment.\r\n */\r\nexport class AttachmentFlagsBitField extends BaseAttachmentFlagsBitField {\r\n public static override resolve<Flags extends string = string>(\r\n bit: BitFieldResolvable<Flags>,\r\n ): bigint {\r\n return BigInt(super.resolve(bit));\r\n }\r\n}\r\n\r\nexport type ChannelFlagsString = keyof typeof ChannelFlags;\r\nexport type ChannelFlagsResolvable = BitFieldResolvable<ChannelFlagsString>;\r\n\r\n/**\r\n * The flags of a channel.\r\n */\r\nexport class ChannelFlagsBitField extends BaseChannelFlagsBitField {\r\n public static override resolve<Flags extends string = string>(\r\n bit: BitFieldResolvable<Flags>,\r\n ): bigint {\r\n return BigInt(super.resolve(bit));\r\n }\r\n}\r\n\r\nexport type MessageFlagsString = keyof typeof MessageFlags;\r\nexport type MessageFlagsResolvable = BitFieldResolvable<MessageFlagsString>;\r\n\r\n/**\r\n * The flags of a message.\r\n */\r\nexport class MessageFlagsBitField extends BaseMessageFlagsBitField {\r\n public static override resolve<Flags extends string = string>(\r\n bit: BitFieldResolvable<Flags>,\r\n ): bigint {\r\n return BigInt(super.resolve(bit));\r\n }\r\n}\r\n\r\nexport type GuildMemberFlagsString = keyof typeof GuildMemberFlags;\r\nexport type GuildMemberFlagsResolvable = BitFieldResolvable<GuildMemberFlagsString>;\r\n\r\n/**\r\n * The flags of a guild member.\r\n */\r\nexport class GuildMemberFlagsBitField extends NumberFlagsBitField<GuildMemberFlagsString> {\r\n public static override readonly Flags = GuildMemberFlags;\r\n}\r\n\r\nexport type IntentsString = keyof typeof GatewayIntentBits;\r\nexport type IntentsResolvable = BitFieldResolvable<IntentsString>;\r\n\r\n/**\r\n * The gateway intents to identify with.\r\n */\r\nexport class IntentsBitField extends NumberFlagsBitField<IntentsString> {\r\n public static override readonly Flags = GatewayIntentBits;\r\n}\r\n\r\nexport type RoleFlagsString = keyof typeof RoleFlags;\r\nexport type RoleFlagsResolvable = BitFieldResolvable<RoleFlagsString>;\r\n\r\n/**\r\n * The flags of a role.\r\n */\r\nexport class RoleFlagsBitField extends NumberFlagsBitField<RoleFlagsString> {\r\n public static override readonly Flags = RoleFlags;\r\n}\r\n\r\nexport type SystemChannelFlagsString = keyof typeof GuildSystemChannelFlags;\r\nexport type SystemChannelFlagsResolvable = BitFieldResolvable<SystemChannelFlagsString>;\r\n\r\n/**\r\n * The flags of a guild's system channel, deciding which system messages are suppressed.\r\n */\r\nexport class SystemChannelFlagsBitField extends NumberFlagsBitField<SystemChannelFlagsString> {\r\n public static override readonly Flags = GuildSystemChannelFlags;\r\n}\r\n\r\nexport type UserFlagsString = keyof typeof UserFlags;\r\nexport type UserFlagsResolvable = BitFieldResolvable<UserFlagsString>;\r\n\r\n/**\r\n * The flags (badges) of a user.\r\n */\r\nexport class UserFlagsBitField extends NumberFlagsBitField<UserFlagsString> {\r\n public static override readonly Flags = UserFlags;\r\n}\r\n","import type { BaseImageURLOptions, ImageURLOptions } from \"@discordjs/rest\";\r\nimport type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\r\nimport type {\r\n APIAvatarDecorationData,\r\n APICollectibles,\r\n APIUserPrimaryGuild,\r\n} from \"discord-api-types/v10\";\r\nimport { cdn } from \"../util/cdn.js\";\r\nimport { getGatewayClient } from \"../util/container.js\";\r\nimport { UserFlagsBitField } from \"../util/flags.js\";\r\nimport type { MessageCreateOptions, MessagePayloadResolvable } from \"../util/messages.js\";\r\nimport type { DMChannel } from \"./DMChannel.js\";\r\nimport type { Message } from \"./Message.js\";\r\nimport { kData, kPatch, snowflakeTimestamp, Structure } from \"./Structure.js\";\r\n\r\n/**\r\n * A Discord user.\r\n */\r\nexport class User extends Structure<CacheEntityTypes[\"users\"]> {\r\n public get id() {\r\n return this[kData].id;\r\n }\r\n\r\n public get username() {\r\n return this[kData].username;\r\n }\r\n\r\n public get discriminator() {\r\n return this[kData].discriminator;\r\n }\r\n\r\n /**\r\n * The user's display name, if set.\r\n */\r\n public get globalName() {\r\n return this[kData].global_name;\r\n }\r\n\r\n /**\r\n * The name to show for this user: their {@link User.globalName} when set, their username otherwise.\r\n */\r\n public get displayName() {\r\n return this[kData].global_name ?? this[kData].username;\r\n }\r\n\r\n /**\r\n * The user's tag: their username for migrated users, `username#discriminator` for legacy ones.\r\n */\r\n public get tag(): string {\r\n return this.discriminator === \"0\" ? this.username : `${this.username}#${this.discriminator}`;\r\n }\r\n\r\n public get avatar() {\r\n return this[kData].avatar;\r\n }\r\n\r\n /**\r\n * The user's banner hash. Only fetched users have it: `undefined` means unknown, `null` means none.\r\n */\r\n public get banner(): string | null | undefined {\r\n return this[kData].banner;\r\n }\r\n\r\n /**\r\n * The user's accent color. Only fetched users have it: `undefined` means unknown, `null` means none.\r\n */\r\n public get accentColor(): number | null | undefined {\r\n return this[kData].accent_color;\r\n }\r\n\r\n /**\r\n * The user's accent color as a `#rrggbb` string, with the same `undefined`/`null` semantics.\r\n */\r\n public get hexAccentColor(): `#${string}` | null | undefined {\r\n const { accentColor } = this;\r\n if (typeof accentColor !== \"number\") return accentColor;\r\n return `#${accentColor.toString(16).padStart(6, \"0\")}`;\r\n }\r\n\r\n public get avatarDecorationData(): APIAvatarDecorationData | null {\r\n return this[kData].avatar_decoration_data ?? null;\r\n }\r\n\r\n public get collectibles(): APICollectibles | null {\r\n return this[kData].collectibles ?? null;\r\n }\r\n\r\n /**\r\n * The guild whose tag the user displays, if any.\r\n */\r\n public get primaryGuild(): APIUserPrimaryGuild | null {\r\n return this[kData].primary_guild ?? null;\r\n }\r\n\r\n /**\r\n * The user's public flags (badges).\r\n */\r\n public get flags(): Readonly<UserFlagsBitField> {\r\n return new UserFlagsBitField(this[kData].public_flags ?? this[kData].flags ?? 0).freeze();\r\n }\r\n\r\n public get bot() {\r\n return this[kData].bot ?? false;\r\n }\r\n\r\n public get system() {\r\n return this[kData].system ?? false;\r\n }\r\n\r\n public get createdTimestamp() {\r\n return snowflakeTimestamp(this.id);\r\n }\r\n\r\n public get createdAt() {\r\n return new Date(this.createdTimestamp);\r\n }\r\n\r\n /**\r\n * Gets the URL of the user's avatar, or `null` if they have none.\r\n * @param options The image options.\r\n */\r\n public avatarURL(options?: ImageURLOptions): string | null {\r\n const { avatar } = this[kData];\r\n return avatar ? cdn.avatar(this.id, avatar, options) : null;\r\n }\r\n\r\n /**\r\n * The URL of the user's default avatar.\r\n */\r\n public get defaultAvatarURL(): string {\r\n return cdn.defaultAvatar(this.defaultAvatarIndex);\r\n }\r\n\r\n /**\r\n * Gets the URL of the user's avatar, falling back to their default avatar.\r\n * @param options The image options.\r\n */\r\n public displayAvatarURL(options?: ImageURLOptions): string {\r\n return this.avatarURL(options) ?? this.defaultAvatarURL;\r\n }\r\n\r\n /**\r\n * The index of the user's default avatar: migrated users (discriminator `\"0\"`) derive it from their ID, legacy ones\r\n * from their discriminator.\r\n */\r\n public get defaultAvatarIndex(): number {\r\n return this.discriminator === \"0\"\r\n ? Number((BigInt(this.id) >> 22n) % 6n)\r\n : Number(this.discriminator) % 5;\r\n }\r\n\r\n /**\r\n * Gets the URL of the user's avatar decoration, or `null` if they have none.\r\n */\r\n public avatarDecorationURL(): string | null {\r\n const asset = this.avatarDecorationData?.asset;\r\n return asset ? cdn.avatarDecoration(asset) : null;\r\n }\r\n\r\n /**\r\n * Gets the URL of the user's banner: `undefined` when unknown (not fetched), `null` when they have none.\r\n * @param options The image options.\r\n */\r\n public bannerURL(options?: ImageURLOptions): string | null | undefined {\r\n const { banner } = this;\r\n return banner ? cdn.banner(this.id, banner, options) : banner;\r\n }\r\n\r\n /**\r\n * Gets the URL of the badge of the guild tag the user displays, or `null` if they display none.\r\n * @param options The image options.\r\n */\r\n public guildTagBadgeURL(options?: BaseImageURLOptions): string | null {\r\n const guild = this.primaryGuild;\r\n return guild?.identity_guild_id && guild.badge\r\n ? cdn.guildTagBadge(guild.identity_guild_id, guild.badge, options)\r\n : null;\r\n }\r\n\r\n /**\r\n * Opens a direct message channel with the user, or gets the existing one.\r\n */\r\n public createDM(): Promise<DMChannel> {\r\n return getGatewayClient().users.createDM(this.id);\r\n }\r\n\r\n /**\r\n * Closes the direct message channel with the user.\r\n */\r\n public deleteDM(): Promise<DMChannel> {\r\n return getGatewayClient().users.deleteDM(this.id);\r\n }\r\n\r\n /**\r\n * Sends a direct message to the user.\r\n *\r\n * @param options The message, or its content.\r\n */\r\n public send(options: MessagePayloadResolvable<MessageCreateOptions>): Promise<Message> {\r\n return getGatewayClient().users.send(this.id, options);\r\n }\r\n\r\n /**\r\n * Fetches the user from the API and patches this structure with the result.\r\n */\r\n public async fetch(): Promise<this> {\r\n const user = await getGatewayClient().users.fetch(this.id, { force: true });\r\n return this[kPatch](user.toJSON());\r\n }\r\n\r\n /**\r\n * Whether this user has the same data as another one.\r\n * @param user The user to compare with.\r\n */\r\n public equals(user: User): boolean {\r\n return (\r\n this.id === user.id &&\r\n this.username === user.username &&\r\n this.discriminator === user.discriminator &&\r\n this.globalName === user.globalName &&\r\n this.avatar === user.avatar &&\r\n this.flags.bitField === user.flags.bitField &&\r\n this.banner === user.banner &&\r\n this.accentColor === user.accentColor &&\r\n this.avatarDecorationData?.asset === user.avatarDecorationData?.asset\r\n );\r\n }\r\n\r\n public toString(): `<@${string}>` {\r\n return `<@${this.id}>`;\r\n }\r\n}\r\n","import type { ChannelType } from \"discord-api-types/v10\";\r\nimport type { Channel } from \"../Channel.js\";\r\nimport { kData } from \"../Structure.js\";\r\nimport type { APIUser } from \"discord-api-types/v10\";\r\nimport { User } from \"../User.js\";\r\n\r\ntype Data = { recipients?: APIUser[] };\r\n\r\nexport interface DMChannelMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\r\n\r\n/**\r\n * Adds the recipients of direct messages.\r\n */\r\nexport class DMChannelMixin<Type extends ChannelType = ChannelType> {\r\n public get recipients(): User[] {\r\n return ((this[kData] as Data).recipients ?? []).map((user) => new User(user));\r\n }\r\n}\r\n","import type { ChannelType } from \"discord-api-types/v10\";\r\nimport { Channel } from \"./Channel.js\";\r\nimport { Mixin } from \"./Mixin.js\";\r\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\r\nimport { DMChannelMixin } from \"./mixins/DMChannelMixin.js\";\r\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\r\n\r\nexport interface DMChannel\r\n extends\r\n BaseChannelMixin<ChannelType.DM>,\r\n DMChannelMixin<ChannelType.DM>,\r\n TextChannelMixin<ChannelType.DM> {}\r\n\r\n/**\r\n * A direct message channel.\r\n */\r\nexport class DMChannel extends Channel<ChannelType.DM> {}\r\n\r\nMixin(DMChannel, [BaseChannelMixin, DMChannelMixin, TextChannelMixin]);\r\n","import type { ChannelType } from \"discord-api-types/v10\";\r\nimport type { Channel } from \"../Channel.js\";\r\nimport { kData } from \"../Structure.js\";\r\nimport type { GuildForumTagData } from \"../../util/channels.js\";\r\nimport { editChannel } from \"./edit.js\";\r\nimport type {\r\n APIGuildForumDefaultReactionEmoji,\r\n APIGuildForumTag,\r\n ForumLayoutType,\r\n SortOrderType,\r\n} from \"discord-api-types/v10\";\r\n\r\ntype Data = {\r\n available_tags?: APIGuildForumTag[];\r\n default_reaction_emoji?: APIGuildForumDefaultReactionEmoji | null;\r\n default_thread_rate_limit_per_user?: number;\r\n};\r\n\r\nexport interface ThreadOnlyChannelMixin<\r\n Type extends ChannelType = ChannelType,\r\n> extends Channel<Type> {}\r\n\r\n/**\r\n * Adds the fields of forum and media channels, which only hold threads.\r\n */\r\nexport class ThreadOnlyChannelMixin<Type extends ChannelType = ChannelType> {\r\n public get availableTags(): readonly APIGuildForumTag[] {\r\n return (this[kData] as Data).available_tags ?? [];\r\n }\r\n\r\n public get defaultReactionEmoji(): APIGuildForumDefaultReactionEmoji | null {\r\n return (this[kData] as Data).default_reaction_emoji ?? null;\r\n }\r\n\r\n public get defaultThreadRateLimitPerUser(): number {\r\n return (this[kData] as Data).default_thread_rate_limit_per_user ?? 0;\r\n }\r\n\r\n public setAvailableTags(\r\n availableTags: readonly GuildForumTagData[],\r\n reason?: string,\r\n ): Promise<this> {\r\n return editChannel(this, { availableTags, reason });\r\n }\r\n\r\n public setDefaultReactionEmoji(\r\n defaultReactionEmoji: APIGuildForumDefaultReactionEmoji | null,\r\n reason?: string,\r\n ): Promise<this> {\r\n return editChannel(this, { defaultReactionEmoji, reason });\r\n }\r\n\r\n public setDefaultThreadRateLimitPerUser(\r\n defaultThreadRateLimitPerUser: number,\r\n reason?: string,\r\n ): Promise<this> {\r\n return editChannel(this, { defaultThreadRateLimitPerUser, reason });\r\n }\r\n\r\n public setDefaultSortOrder(\r\n defaultSortOrder: SortOrderType | null,\r\n reason?: string,\r\n ): Promise<this> {\r\n return editChannel(this, { defaultSortOrder, reason });\r\n }\r\n\r\n public setDefaultForumLayout(\r\n defaultForumLayout: ForumLayoutType,\r\n reason?: string,\r\n ): Promise<this> {\r\n return editChannel(this, { defaultForumLayout, reason });\r\n }\r\n}\r\n","import type { ChannelType } from \"discord-api-types/v10\";\r\nimport { Channel } from \"./Channel.js\";\r\nimport { Mixin } from \"./Mixin.js\";\r\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\r\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\r\nimport { ChannelPermissionMixin } from \"./mixins/ChannelPermissionMixin.js\";\r\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\r\nimport { ChannelThreadsMixin } from \"./mixins/ChannelThreadsMixin.js\";\r\nimport { ChannelWebhooksMixin } from \"./mixins/ChannelWebhooksMixin.js\";\r\nimport { ChannelTopicMixin } from \"./mixins/ChannelTopicMixin.js\";\r\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\r\nimport { ThreadOnlyChannelMixin } from \"./mixins/ThreadOnlyChannelMixin.js\";\r\n\r\nexport interface ForumChannel\r\n extends\r\n BaseChannelMixin<ChannelType.GuildForum>,\r\n GuildChannelMixin<ChannelType.GuildForum>,\r\n ChannelParentMixin<ChannelType.GuildForum>,\r\n ChannelPermissionMixin<ChannelType.GuildForum>,\r\n ChannelSlowmodeMixin<ChannelType.GuildForum>,\r\n ChannelTopicMixin<ChannelType.GuildForum>,\r\n ThreadOnlyChannelMixin<ChannelType.GuildForum>,\r\n ChannelWebhooksMixin<ChannelType.GuildForum>,\r\n ChannelThreadsMixin<ChannelType.GuildForum> {}\r\n\r\n/**\r\n * A guild forum channel.\r\n */\r\nexport class ForumChannel extends Channel<ChannelType.GuildForum> {}\r\n\r\nMixin(ForumChannel, [\r\n BaseChannelMixin,\r\n GuildChannelMixin,\r\n ChannelParentMixin,\r\n ChannelPermissionMixin,\r\n ChannelSlowmodeMixin,\r\n ChannelTopicMixin,\r\n ThreadOnlyChannelMixin,\r\n ChannelWebhooksMixin,\r\n ChannelThreadsMixin,\r\n]);\r\n","import type { ChannelType } from \"discord-api-types/v10\";\r\nimport type { Channel } from \"../Channel.js\";\r\nimport { kData } from \"../Structure.js\";\r\nimport type { ImageURLOptions } from \"@discordjs/rest\";\r\nimport { cdn } from \"../../util/cdn.js\";\r\n\r\ntype Data = { name?: string | null; icon?: string | null; application_id?: string };\r\n\r\nexport interface GroupDMMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\r\n\r\n/**\r\n * Adds the fields of group direct messages.\r\n */\r\nexport class GroupDMMixin<Type extends ChannelType = ChannelType> {\r\n public get name(): string | null {\r\n return (this[kData] as Data).name ?? null;\r\n }\r\n\r\n public get icon(): string | null {\r\n return (this[kData] as Data).icon ?? null;\r\n }\r\n\r\n /**\r\n * The ID of the application that created the group, if any.\r\n */\r\n public get applicationId(): string | null {\r\n return (this[kData] as Data).application_id ?? null;\r\n }\r\n\r\n /**\r\n * Gets the URL of the group's icon, or `null` if it has none.\r\n * @param options The image options.\r\n */\r\n public iconURL(options?: ImageURLOptions): string | null {\r\n const { icon } = this[kData] as Data;\r\n return icon ? cdn.channelIcon(this.id, icon, options) : null;\r\n }\r\n}\r\n","import type { ChannelType } from \"discord-api-types/v10\";\r\nimport { Channel } from \"./Channel.js\";\r\nimport { Mixin } from \"./Mixin.js\";\r\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\r\nimport { ChannelOwnerMixin } from \"./mixins/ChannelOwnerMixin.js\";\r\nimport { DMChannelMixin } from \"./mixins/DMChannelMixin.js\";\r\nimport { GroupDMMixin } from \"./mixins/GroupDMMixin.js\";\r\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\r\n\r\nexport interface GroupDMChannel\r\n extends\r\n BaseChannelMixin<ChannelType.GroupDM>,\r\n DMChannelMixin<ChannelType.GroupDM>,\r\n TextChannelMixin<ChannelType.GroupDM>,\r\n ChannelOwnerMixin<ChannelType.GroupDM>,\r\n GroupDMMixin<ChannelType.GroupDM> {}\r\n\r\n/**\r\n * A group direct message channel.\r\n */\r\nexport class GroupDMChannel extends Channel<ChannelType.GroupDM> {}\r\n\r\nMixin(GroupDMChannel, [\r\n BaseChannelMixin,\r\n DMChannelMixin,\r\n TextChannelMixin,\r\n ChannelOwnerMixin,\r\n GroupDMMixin,\r\n]);\r\n","import type { ChannelType } from \"discord-api-types/v10\";\r\nimport { Channel } from \"./Channel.js\";\r\nimport { Mixin } from \"./Mixin.js\";\r\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\r\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\r\nimport { ChannelPermissionMixin } from \"./mixins/ChannelPermissionMixin.js\";\r\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\r\nimport { ChannelThreadsMixin } from \"./mixins/ChannelThreadsMixin.js\";\r\nimport { ChannelWebhooksMixin } from \"./mixins/ChannelWebhooksMixin.js\";\r\nimport { ChannelTopicMixin } from \"./mixins/ChannelTopicMixin.js\";\r\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\r\nimport { ThreadOnlyChannelMixin } from \"./mixins/ThreadOnlyChannelMixin.js\";\r\n\r\nexport interface MediaChannel\r\n extends\r\n BaseChannelMixin<ChannelType.GuildMedia>,\r\n GuildChannelMixin<ChannelType.GuildMedia>,\r\n ChannelParentMixin<ChannelType.GuildMedia>,\r\n ChannelPermissionMixin<ChannelType.GuildMedia>,\r\n ChannelSlowmodeMixin<ChannelType.GuildMedia>,\r\n ChannelTopicMixin<ChannelType.GuildMedia>,\r\n ThreadOnlyChannelMixin<ChannelType.GuildMedia>,\r\n ChannelWebhooksMixin<ChannelType.GuildMedia>,\r\n ChannelThreadsMixin<ChannelType.GuildMedia> {}\r\n\r\n/**\r\n * A guild media channel.\r\n */\r\nexport class MediaChannel extends Channel<ChannelType.GuildMedia> {}\r\n\r\nMixin(MediaChannel, [\r\n BaseChannelMixin,\r\n GuildChannelMixin,\r\n ChannelParentMixin,\r\n ChannelPermissionMixin,\r\n ChannelSlowmodeMixin,\r\n ChannelTopicMixin,\r\n ThreadOnlyChannelMixin,\r\n ChannelWebhooksMixin,\r\n ChannelThreadsMixin,\r\n]);\r\n","import type { ChannelType } from \"discord-api-types/v10\";\r\nimport { Channel } from \"./Channel.js\";\r\nimport { Mixin } from \"./Mixin.js\";\r\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\r\nimport { ChannelOwnerMixin } from \"./mixins/ChannelOwnerMixin.js\";\r\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\r\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\r\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\r\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\r\nimport { ThreadChannelMixin } from \"./mixins/ThreadChannelMixin.js\";\r\n\r\nexport interface PrivateThreadChannel\r\n extends\r\n BaseChannelMixin<ChannelType.PrivateThread>,\r\n TextChannelMixin<ChannelType.PrivateThread>,\r\n GuildChannelMixin<ChannelType.PrivateThread>,\r\n ChannelOwnerMixin<ChannelType.PrivateThread>,\r\n ChannelParentMixin<ChannelType.PrivateThread>,\r\n ChannelSlowmodeMixin<ChannelType.PrivateThread>,\r\n ThreadChannelMixin<ChannelType.PrivateThread> {}\r\n\r\n/**\r\n * A private thread.\r\n */\r\nexport class PrivateThreadChannel extends Channel<ChannelType.PrivateThread> {}\r\n\r\nMixin(PrivateThreadChannel, [\r\n BaseChannelMixin,\r\n TextChannelMixin,\r\n GuildChannelMixin,\r\n ChannelOwnerMixin,\r\n ChannelParentMixin,\r\n ChannelSlowmodeMixin,\r\n ThreadChannelMixin,\r\n]);\r\n","import type { ChannelType } from \"discord-api-types/v10\";\r\nimport type { Channel } from \"../Channel.js\";\r\nimport { kData } from \"../Structure.js\";\r\nimport { editChannel } from \"./edit.js\";\r\n\r\ntype Data = { applied_tags?: string[] };\r\n\r\nexport interface AppliedTagsMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\r\n\r\n/**\r\n * Adds the tags applied to a thread of a forum or media channel.\r\n */\r\nexport class AppliedTagsMixin<Type extends ChannelType = ChannelType> {\r\n public get appliedTagIds(): readonly string[] {\r\n return (this[kData] as Data).applied_tags ?? [];\r\n }\r\n\r\n /**\r\n * Sets the tags of the thread.\r\n *\r\n * @param appliedTags The IDs of the tags.\r\n * @param reason The reason for the audit log.\r\n */\r\n public setAppliedTags(appliedTags: readonly string[], reason?: string): Promise<this> {\r\n return editChannel(this, { appliedTags, reason });\r\n }\r\n}\r\n","import type { ChannelType } from \"discord-api-types/v10\";\r\nimport { Channel } from \"./Channel.js\";\r\nimport { Mixin } from \"./Mixin.js\";\r\nimport { AppliedTagsMixin } from \"./mixins/AppliedTagsMixin.js\";\r\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\r\nimport { ChannelOwnerMixin } from \"./mixins/ChannelOwnerMixin.js\";\r\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\r\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\r\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\r\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\r\nimport { ThreadChannelMixin } from \"./mixins/ThreadChannelMixin.js\";\r\n\r\nexport interface PublicThreadChannel\r\n extends\r\n BaseChannelMixin<ChannelType.PublicThread>,\r\n TextChannelMixin<ChannelType.PublicThread>,\r\n GuildChannelMixin<ChannelType.PublicThread>,\r\n ChannelOwnerMixin<ChannelType.PublicThread>,\r\n ChannelParentMixin<ChannelType.PublicThread>,\r\n ChannelSlowmodeMixin<ChannelType.PublicThread>,\r\n ThreadChannelMixin<ChannelType.PublicThread>,\r\n AppliedTagsMixin<ChannelType.PublicThread> {}\r\n\r\n/**\r\n * A public thread.\r\n */\r\nexport class PublicThreadChannel extends Channel<ChannelType.PublicThread> {}\r\n\r\nMixin(PublicThreadChannel, [\r\n BaseChannelMixin,\r\n TextChannelMixin,\r\n GuildChannelMixin,\r\n ChannelOwnerMixin,\r\n ChannelParentMixin,\r\n ChannelSlowmodeMixin,\r\n ThreadChannelMixin,\r\n AppliedTagsMixin,\r\n]);\r\n","import type { ChannelType, VideoQualityMode } from \"discord-api-types/v10\";\r\nimport type { Channel } from \"../Channel.js\";\r\nimport { kData } from \"../Structure.js\";\r\nimport { editChannel } from \"./edit.js\";\r\n\r\ntype Data = {\r\n bitrate?: number;\r\n user_limit?: number;\r\n rtc_region?: string | null;\r\n video_quality_mode?: number;\r\n};\r\n\r\nexport interface VoiceChannelMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\r\n\r\n/**\r\n * Adds the fields of voice and stage channels.\r\n */\r\nexport class VoiceChannelMixin<Type extends ChannelType = ChannelType> {\r\n public get bitrate(): number {\r\n return (this[kData] as Data).bitrate ?? 0;\r\n }\r\n\r\n /**\r\n * The user limit, `0` when unlimited.\r\n */\r\n public get userLimit(): number {\r\n return (this[kData] as Data).user_limit ?? 0;\r\n }\r\n\r\n /**\r\n * The voice region, `null` for automatic.\r\n */\r\n public get rtcRegion(): string | null {\r\n return (this[kData] as Data).rtc_region ?? null;\r\n }\r\n\r\n public get videoQualityMode(): number | null {\r\n return (this[kData] as Data).video_quality_mode ?? null;\r\n }\r\n\r\n public setBitrate(bitrate: number, reason?: string): Promise<this> {\r\n return editChannel(this, { bitrate, reason });\r\n }\r\n\r\n /**\r\n * Sets the user limit.\r\n *\r\n * @param userLimit The user limit, `0` for none.\r\n * @param reason The reason for the audit log.\r\n */\r\n public setUserLimit(userLimit: number, reason?: string): Promise<this> {\r\n return editChannel(this, { userLimit, reason });\r\n }\r\n\r\n /**\r\n * Sets the voice region.\r\n *\r\n * @param rtcRegion The region, `null` for automatic.\r\n * @param reason The reason for the audit log.\r\n */\r\n public setRTCRegion(rtcRegion: string | null, reason?: string): Promise<this> {\r\n return editChannel(this, { rtcRegion, reason });\r\n }\r\n\r\n public setVideoQualityMode(videoQualityMode: VideoQualityMode, reason?: string): Promise<this> {\r\n return editChannel(this, { videoQualityMode, reason });\r\n }\r\n}\r\n","import { DiscordAPIError } from \"@discordjs/rest\";\r\nimport type { ChannelType } from \"discord-api-types/v10\";\r\nimport type { StageInstanceCreateOptions } from \"../managers/StageInstanceManager.js\";\r\nimport { getGatewayClient } from \"../util/container.js\";\r\nimport type { StageInstance } from \"./StageInstance.js\";\r\nimport { Channel } from \"./Channel.js\";\r\nimport { Mixin } from \"./Mixin.js\";\r\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\r\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\r\nimport { ChannelPermissionMixin } from \"./mixins/ChannelPermissionMixin.js\";\r\nimport { ChannelWebhooksMixin } from \"./mixins/ChannelWebhooksMixin.js\";\r\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\r\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\r\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\r\nimport { VoiceChannelMixin } from \"./mixins/VoiceChannelMixin.js\";\r\n\r\nexport interface StageChannel\r\n extends\r\n BaseChannelMixin<ChannelType.GuildStageVoice>,\r\n TextChannelMixin<ChannelType.GuildStageVoice>,\r\n GuildChannelMixin<ChannelType.GuildStageVoice>,\r\n ChannelParentMixin<ChannelType.GuildStageVoice>,\r\n ChannelPermissionMixin<ChannelType.GuildStageVoice>,\r\n ChannelSlowmodeMixin<ChannelType.GuildStageVoice>,\r\n VoiceChannelMixin<ChannelType.GuildStageVoice>,\r\n ChannelWebhooksMixin<ChannelType.GuildStageVoice> {}\r\n\r\n/**\r\n * A guild stage channel.\r\n */\r\nexport class StageChannel extends Channel<ChannelType.GuildStageVoice> {\r\n /**\r\n * Fetches the live stage of the channel, `null` when the stage is not live.\r\n */\r\n public async fetchStageInstance(): Promise<StageInstance | null> {\r\n const { guildId } = this;\r\n if (!guildId) return null;\r\n try {\r\n return await getGatewayClient().guilds.stageInstances(guildId).fetch(this.id);\r\n } catch (error) {\r\n // Discord answers 404 (Unknown Stage Instance) when the stage is not live.\r\n if (error instanceof DiscordAPIError && error.status === 404) return null;\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Starts a stage in the channel.\r\n *\r\n * @param options The topic and privacy level, and whether to notify the guild.\r\n */\r\n public createStageInstance(options: StageInstanceCreateOptions): Promise<StageInstance> {\r\n const { guildId } = this;\r\n if (!guildId) return Promise.reject(new Error(`Channel ${this.id} has no known guild`));\r\n return getGatewayClient().guilds.stageInstances(guildId).create(this.id, options);\r\n }\r\n}\r\n\r\nMixin(StageChannel, [\r\n BaseChannelMixin,\r\n TextChannelMixin,\r\n GuildChannelMixin,\r\n ChannelParentMixin,\r\n ChannelPermissionMixin,\r\n ChannelSlowmodeMixin,\r\n VoiceChannelMixin,\r\n ChannelWebhooksMixin,\r\n]);\r\n","import type { ChannelType } from \"discord-api-types/v10\";\r\nimport { Channel } from \"./Channel.js\";\r\nimport { Mixin } from \"./Mixin.js\";\r\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\r\nimport { ChannelParentMixin } from \"./mixins/ChannelParentMixin.js\";\r\nimport { ChannelPermissionMixin } from \"./mixins/ChannelPermissionMixin.js\";\r\nimport { ChannelThreadsMixin } from \"./mixins/ChannelThreadsMixin.js\";\r\nimport { ChannelWebhooksMixin } from \"./mixins/ChannelWebhooksMixin.js\";\r\nimport { ChannelSlowmodeMixin } from \"./mixins/ChannelSlowmodeMixin.js\";\r\nimport { ChannelTopicMixin } from \"./mixins/ChannelTopicMixin.js\";\r\nimport { GuildChannelMixin } from \"./mixins/GuildChannelMixin.js\";\r\nimport { TextChannelMixin } from \"./mixins/TextChannelMixin.js\";\r\n\r\nexport interface TextChannel\r\n extends\r\n BaseChannelMixin<ChannelType.GuildText>,\r\n TextChannelMixin<ChannelType.GuildText>,\r\n GuildChannelMixin<ChannelType.GuildText>,\r\n ChannelParentMixin<ChannelType.GuildText>,\r\n ChannelPermissionMixin<ChannelType.GuildText>,\r\n ChannelSlowmodeMixin<ChannelType.GuildText>,\r\n ChannelTopicMixin<ChannelType.GuildText>,\r\n ChannelWebhooksMixin<ChannelType.GuildText>,\r\n ChannelThreadsMixin<ChannelType.GuildText> {}\r\n\r\n/**\r\n * A guild text channel.\r\n */\r\nexport class TextChannel extends Channel<ChannelType.GuildText> {}\r\n\r\nMixin(TextChannel, [\r\n BaseChannelMixin,\r\n TextChannelMixin,\r\n GuildChannelMixin,\r\n ChannelParentMixin,\r\n ChannelPermissionMixin,\r\n ChannelSlowmodeMixin,\r\n ChannelTopicMixin,\r\n ChannelWebhooksMixin,\r\n ChannelThreadsMixin,\r\n]);\r\n","import {\n type ChannelType,\n type RESTPostAPISoundboardSendSoundJSONBody,\n} from \"discord-api-types/v10\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport type { SoundboardSound } from \"./SoundboardSound.js\";\nimport { Channel } from \"./Channel.js\";\nimport { Mixin } from \"./Mixin.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 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 * A guild voice channel.\n */\nexport class VoiceChannel extends Channel<ChannelType.GuildVoice> {\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 getGatewayClient().core.api.channels.sendSoundboardSound(this.id, body);\n }\n}\n\nMixin(VoiceChannel, [\n BaseChannelMixin,\n TextChannelMixin,\n GuildChannelMixin,\n ChannelParentMixin,\n ChannelPermissionMixin,\n ChannelSlowmodeMixin,\n VoiceChannelMixin,\n ChannelWebhooksMixin,\n]);\n","import type { CacheEntityName, CacheEntityTypes, EntityCache } from \"@wolfstar/plugin-cache\";\r\nimport type { GatewayClient } from \"../GatewayClient.js\";\r\nimport type { Guild } from \"../structures/Guild.js\";\r\nimport type { Structure } from \"../structures/Structure.js\";\r\n\r\n/**\r\n * The options to fetch an entity with.\r\n */\r\nexport interface FetchOptions {\r\n /**\r\n * Whether to skip the cache lookup and always hit the API.\r\n *\r\n * @default false\r\n */\r\n force?: boolean;\r\n /**\r\n * Whether to store the entity fetched from the API in the cache.\r\n *\r\n * @default true\r\n */\r\n cache?: boolean;\r\n}\r\n\r\n/**\r\n * The options of {@link CachedManager._add}.\r\n */\r\nexport interface AddOptions {\r\n /**\r\n * The cache key of the entity, when it cannot be derived from its data.\r\n */\r\n key?: string;\r\n}\r\n\r\n/**\r\n * The base class of every manager: it reads raw data from one of the client's entity caches, falls back to the REST\r\n * API when asked to, and wraps the result in a {@link Structure}.\r\n *\r\n * @remarks\r\n * The cache only ever holds raw API data, building structures is always the manager's job. Without a cache, `get`\r\n * always resolves to `undefined` and `fetch` always hits the API.\r\n *\r\n * Like discord.js's `CachedManager`, every payload coming from the API goes through {@link CachedManager._add}, which\r\n * patches the cached entry and builds the structure. Structures are built by {@link CachedManager.hydrate}, which\r\n * resolves their relations (a message's author, a member's user, ...) from the cache, so they carry the latest known\r\n * data rather than the copy embedded in the payload.\r\n *\r\n * @typeParam Name The name of the entity cache this manager reads from.\r\n * @typeParam Value The structure this manager builds.\r\n * @typeParam Args The arguments identifying an entity, e.g. `[id]` or `[guildId, userId]`.\r\n */\r\nexport abstract class CachedManager<\r\n Name extends CacheEntityName,\r\n Value extends Structure<object>,\r\n Args extends readonly string[],\r\n> {\r\n /**\r\n * The client this manager belongs to.\r\n */\r\n public readonly client: GatewayClient;\r\n\r\n /**\r\n * The name of the entity cache this manager reads from.\r\n */\r\n public readonly entity: Name;\r\n\r\n public constructor(client: GatewayClient, entity: Name) {\r\n this.client = client;\r\n this.entity = entity;\r\n }\r\n\r\n /**\r\n * The entity cache this manager reads from, or `undefined` when the client has no cache.\r\n */\r\n public get cache(): EntityCache<CacheEntityTypes[Name]> | undefined {\r\n return this.client.cache?.[this.entity] as EntityCache<CacheEntityTypes[Name]> | undefined;\r\n }\r\n\r\n /**\r\n * Gets an entity from the cache.\r\n *\r\n * @param args The arguments identifying the entity.\r\n * @returns The entity, or `undefined` if it is not cached.\r\n */\r\n public async get(...args: Args): Promise<Value | undefined> {\r\n return this.getByKey(this.resolveKey(...args));\r\n }\r\n\r\n /**\r\n * Resolves a structure or a cache key to a structure, like discord.js's `DataManager#resolve`.\r\n *\r\n * @param value A structure, returned as is, or the cache key of an entity (its ID, for managers keyed by ID).\r\n * @returns The structure, or `null` if the key is not cached.\r\n */\r\n public async resolve(value: Value | string): Promise<Value | null> {\r\n if (typeof value !== \"string\") return value;\r\n return (await this.getByKey(value)) ?? null;\r\n }\r\n\r\n /**\r\n * Adds an API payload to the cache, patching the cached entry with it, and builds its structure. The counterpart of\r\n * discord.js's `CachedManager#_add`, asynchronous since the cache can be remote.\r\n *\r\n * @remarks\r\n * Like discord.js's `_patch`, the payload is shallowly merged into the cached entry, so the fields a partial payload\r\n * lacks keep their cached value. With `cache` set to `false`, the merged entry is built but not written.\r\n *\r\n * The merge is a read followed by a write, not an atomic operation: on a shared cache, a write landing in between\r\n * (another process, or a dispatch outside the guild's queue) is overwritten. `@wolfstar/plugin-cache` merges partial\r\n * dispatches the same way, and the fields at stake are refreshed by the next payload of the entity.\r\n *\r\n * @param data The raw data.\r\n * @param cache Whether to write the merged entry to the cache.\r\n * @param options The cache key, when it cannot be derived from the data.\r\n * @internal\r\n */\r\n public async _add(\r\n data: CacheEntityTypes[Name],\r\n cache = true,\r\n { key = this.keyOf(data) }: AddOptions = {},\r\n ): Promise<Value> {\r\n const existing = await this.cache?.get(key);\r\n const merged = existing ? { ...existing, ...data } : data;\r\n if (cache) await this.storeRaw(key, merged);\r\n return this.hydrate(merged);\r\n }\r\n\r\n /**\r\n * Gets the cached structure of the entity raw data describes, or builds one from the data when it is not cached.\r\n * Used to resolve the relations of other structures, e.g. a message's author.\r\n *\r\n * @param data The raw data.\r\n */\r\n public async resolveData(data: CacheEntityTypes[Name]): Promise<Value> {\r\n return (await this.getByKey(this.keyOf(data))) ?? this.hydrate(data);\r\n }\r\n\r\n /**\r\n * Gets a guild from the cache, to resolve the `guild` of a structure.\r\n *\r\n * @param guildId The ID of the guild, if the structure belongs to one.\r\n * @returns The guild, or `null` when there is no ID or the guild is not cached.\r\n */\r\n protected async cachedGuild(guildId: string | null | undefined): Promise<Guild | null> {\r\n return guildId ? ((await this.client.guilds.get(guildId)) ?? null) : null;\r\n }\r\n\r\n /**\r\n * Builds the structure of raw data, resolving its relations from the cache. Without relations to resolve, the same\r\n * as {@link CachedManager.createStructure}.\r\n *\r\n * @param data The raw data.\r\n */\r\n public async hydrate(data: CacheEntityTypes[Name]): Promise<Value> {\r\n return this.createStructure(data);\r\n }\r\n\r\n /**\r\n * Gets an entity from the cache, fetching it from the API (and caching it) on a cache miss.\r\n *\r\n * @example\r\n * ```typescript\r\n * await client.users.fetch(userId); // cache first\r\n * await client.users.fetch(userId, { force: true }); // always the API\r\n * await client.users.fetch(userId, { force: true, cache: false }); // the API, without storing the result\r\n * ```\r\n *\r\n * @param args The arguments identifying the entity, optionally followed by {@link FetchOptions}.\r\n */\r\n public async fetch(...args: [...Args] | [...Args, FetchOptions]): Promise<Value> {\r\n const ids = args.slice(0, this.resolveKey.length) as unknown as Args;\r\n const { force = false, cache = true } = (args[this.resolveKey.length] ?? {}) as FetchOptions;\r\n\r\n if (!force) {\r\n const cached = await this.get(...ids);\r\n if (cached) return cached;\r\n }\r\n\r\n const raw = await this.fetchRaw(...ids);\r\n return this._add(raw, cache, { key: this.resolveKey(...ids) });\r\n }\r\n\r\n /**\r\n * Fetches an entity from the API, bypassing and then updating the cache. Same as `fetch(...args, { force: true })`.\r\n *\r\n * @param args The arguments identifying the entity.\r\n */\r\n public refresh(...args: Args): Promise<Value> {\r\n return this.fetch(...args, { force: true });\r\n }\r\n\r\n /**\r\n * Wraps raw data in this manager's structure.\r\n *\r\n * @param data The raw data.\r\n */\r\n public abstract createStructure(data: CacheEntityTypes[Name]): Value;\r\n\r\n /**\r\n * Gets the cache key of raw data.\r\n *\r\n * @param data The raw data.\r\n */\r\n public abstract keyOf(data: CacheEntityTypes[Name]): string;\r\n\r\n /**\r\n * Gets the cache key of an entity.\r\n *\r\n * @param args The arguments identifying the entity.\r\n */\r\n public abstract resolveKey(...args: Args): string;\r\n\r\n /**\r\n * Fetches the raw data of an entity from the API.\r\n *\r\n * @param args The arguments identifying the entity.\r\n */\r\n protected abstract fetchRaw(...args: Args): Promise<CacheEntityTypes[Name]>;\r\n\r\n /**\r\n * Writes raw data to the cache.\r\n *\r\n * @param key The cache key of the entity.\r\n * @param raw The raw data of the entity.\r\n */\r\n protected async storeRaw(key: string, raw: CacheEntityTypes[Name]): Promise<void> {\r\n await this.cache?.set(key, raw);\r\n }\r\n\r\n /**\r\n * Gets an entity from the cache by its key.\r\n *\r\n * @param key The cache key of the entity.\r\n */\r\n protected async getByKey(key: string): Promise<Value | undefined> {\r\n const raw = await this.cache?.get(key);\r\n return raw === undefined ? undefined : this.hydrate(raw);\r\n }\r\n}\r\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport { applyGatewayDispatch } 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/AnnouncementChannel.js\";\nimport { AnnouncementThreadChannel } from \"../structures/AnnouncementThreadChannel.js\";\nimport { BaseChannel } from \"../structures/BaseChannel.js\";\nimport { isThreadChannelType, type ChannelRelations } from \"../structures/Channel.js\";\nimport { CategoryChannel } from \"../structures/CategoryChannel.js\";\nimport { DMChannel } from \"../structures/DMChannel.js\";\nimport { ForumChannel } from \"../structures/ForumChannel.js\";\nimport { GroupDMChannel } from \"../structures/GroupDMChannel.js\";\nimport { MediaChannel } from \"../structures/MediaChannel.js\";\nimport { PrivateThreadChannel } from \"../structures/PrivateThreadChannel.js\";\nimport { PublicThreadChannel } from \"../structures/PublicThreadChannel.js\";\nimport { StageChannel } from \"../structures/StageChannel.js\";\nimport { TextChannel } from \"../structures/TextChannel.js\";\nimport { VoiceChannel } from \"../structures/VoiceChannel.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// 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 async hydrate(data: CacheEntityTypes[\"channels\"]): Promise<AnyChannel> {\n return createChannel(data, { guild: await this.cachedGuild(channelGuildId(data)) });\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.\n *\n * @param channelId The ID of the channel.\n */\n public override async get(channelId: string): Promise<AnyChannel | undefined> {\n const channel = await super.get(channelId);\n if (channel) return channel;\n\n return this.client.threads.get(channelId);\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.core.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.core.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.core.api.channels.get(channelId);\n }\n}\n","import type { BaseImageURLOptions, ImageURLOptions } from \"@discordjs/rest\";\r\nimport { GuildFeature, type APIGuild } from \"discord-api-types/v10\";\r\nimport { cdn } from \"../util/cdn.js\";\r\nimport { kData, snowflakeTimestamp, Structure } from \"./Structure.js\";\r\n\r\n/**\r\n * The raw fields every guild-like payload carries, from the partial guilds of invites to full guilds.\r\n */\r\nexport type AnonymousGuildData = Pick<APIGuild, \"features\" | \"icon\" | \"id\" | \"name\"> &\r\n Partial<\r\n Pick<\r\n APIGuild,\r\n | \"banner\"\r\n | \"description\"\r\n | \"nsfw_level\"\r\n | \"premium_subscription_count\"\r\n | \"splash\"\r\n | \"vanity_url_code\"\r\n | \"verification_level\"\r\n >\r\n >;\r\n\r\n/**\r\n * The public attributes shared by {@link Guild} and {@link InviteGuild}, i.e. what an anonymous user can see of a\r\n * guild.\r\n *\r\n * @remarks\r\n * Merges discord.js's `BaseGuild` and `AnonymousGuild`, there being no `OAuth2Guild` here to justify the split.\r\n *\r\n * @typeParam Data The raw guild data this structure wraps.\r\n */\r\nexport class AnonymousGuild<\r\n Data extends AnonymousGuildData = AnonymousGuildData,\r\n> extends Structure<Data> {\r\n public get id() {\r\n return this[kData].id;\r\n }\r\n\r\n public get name() {\r\n return this[kData].name;\r\n }\r\n\r\n public get icon() {\r\n return this[kData].icon;\r\n }\r\n\r\n public get features() {\r\n return this[kData].features;\r\n }\r\n\r\n public get splash(): string | null {\r\n return this[kData].splash ?? null;\r\n }\r\n\r\n public get banner(): string | null {\r\n return this[kData].banner ?? null;\r\n }\r\n\r\n public get description(): string | null {\r\n return this[kData].description ?? null;\r\n }\r\n\r\n public get verificationLevel() {\r\n return this[kData].verification_level ?? null;\r\n }\r\n\r\n /**\r\n * The vanity invite code of the guild, if any.\r\n */\r\n public get vanityURLCode(): string | null {\r\n return this[kData].vanity_url_code ?? null;\r\n }\r\n\r\n public get nsfwLevel() {\r\n return this[kData].nsfw_level ?? null;\r\n }\r\n\r\n /**\r\n * The total number of boosts of the guild, or `null` if unknown.\r\n */\r\n public get premiumSubscriptionCount(): number | null {\r\n return this[kData].premium_subscription_count ?? null;\r\n }\r\n\r\n public get createdTimestamp() {\r\n return snowflakeTimestamp(this.id);\r\n }\r\n\r\n public get createdAt() {\r\n return new Date(this.createdTimestamp);\r\n }\r\n\r\n /**\r\n * The acronym shown in place of the guild's icon when it has none.\r\n */\r\n public get nameAcronym(): string {\r\n return this.name\r\n .replaceAll(\"'s \", \" \")\r\n .replaceAll(/\\w+/g, (word) => word[0]!)\r\n .replaceAll(/\\s/g, \"\");\r\n }\r\n\r\n /**\r\n * Whether the guild is partnered.\r\n */\r\n public get partnered(): boolean {\r\n return this.features.includes(GuildFeature.Partnered);\r\n }\r\n\r\n /**\r\n * Whether the guild is verified.\r\n */\r\n public get verified(): boolean {\r\n return this.features.includes(GuildFeature.Verified);\r\n }\r\n\r\n /**\r\n * Gets the URL of the guild's icon, or `null` if it has none.\r\n * @param options The image options.\r\n */\r\n public iconURL(options?: ImageURLOptions): string | null {\r\n const { icon } = this[kData];\r\n return icon ? cdn.icon(this.id, icon, options) : null;\r\n }\r\n\r\n /**\r\n * Gets the URL of the guild's banner, or `null` if it has none.\r\n * @param options The image options.\r\n */\r\n public bannerURL(options?: ImageURLOptions): string | null {\r\n const { banner } = this[kData];\r\n return banner ? cdn.banner(this.id, banner, options) : null;\r\n }\r\n\r\n /**\r\n * Gets the URL of the guild's invite splash image, or `null` if it has none.\r\n * @param options The image options.\r\n */\r\n public splashURL(options?: BaseImageURLOptions): string | null {\r\n const { splash } = this[kData];\r\n return splash ? cdn.splash(this.id, splash, options) : null;\r\n }\r\n\r\n public toString(): string {\r\n return this.name;\r\n }\r\n}\r\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 {\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 { getGatewayClient } from \"../util/container.js\";\nimport type { Webhook } from \"./Webhook.js\";\nimport { SystemChannelFlagsBitField, type SystemChannelFlagsResolvable } from \"../util/flags.js\";\nimport { AnonymousGuild } from \"./AnonymousGuild.js\";\nimport type { GuildInvite } from \"./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 { kData, kPatch } from \"./Structure.js\";\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 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 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 getGatewayClient().guilds.emojis(this.id);\n }\n\n /**\n * The custom stickers of the guild.\n */\n public get stickers(): GuildStickerManager {\n return getGatewayClient().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 getGatewayClient().threads.fetchActive(this.id);\n }\n\n /**\n * Fetches the webhooks of the guild.\n */\n public fetchWebhooks(): Promise<Webhook[]> {\n return getGatewayClient().webhooks.fetchGuild(this.id);\n }\n\n /**\n * The scheduled events of the guild.\n */\n public get scheduledEvents(): GuildScheduledEventManager {\n return getGatewayClient().guilds.scheduledEvents(this.id);\n }\n\n /**\n * The live stages of the guild.\n */\n public get stageInstances(): StageInstanceManager {\n return getGatewayClient().guilds.stageInstances(this.id);\n }\n\n /**\n * The soundboard sounds of the guild.\n */\n public get soundboardSounds(): GuildSoundboardSoundManager {\n return getGatewayClient().guilds.soundboardSounds(this.id);\n }\n\n /**\n * The integrations of the guild.\n */\n public get integrations(): GuildIntegrationManager {\n return getGatewayClient().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 getGatewayClient().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 getGatewayClient().templates.create(this.id, options);\n }\n\n /**\n * Fetches the welcome screen of the guild.\n */\n public fetchWelcomeScreen(): Promise<WelcomeScreen> {\n return getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().guilds.editOnboarding(this.id, options);\n }\n\n /**\n * The bans of the guild.\n */\n public get bans(): GuildBanManager {\n return getGatewayClient().guilds.bans(this.id);\n }\n\n /**\n * The auto moderation rules of the guild.\n */\n public get autoModerationRules(): AutoModerationRuleManager {\n return getGatewayClient().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 getGatewayClient().guilds.fetchAuditLogs(this.id, options);\n }\n\n /**\n * The channels of the guild.\n */\n public get channels(): GuildChannelManager {\n return getGatewayClient().guilds.channels(this.id);\n }\n\n /**\n * The invites of the guild.\n */\n public get invites(): GuildInviteManager {\n return getGatewayClient().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 getGatewayClient().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 getGatewayClient().members.fetch(this.id, this.ownerId);\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 getGatewayClient().guilds.fetchPreview(this.id);\n }\n\n /**\n * Fetches the voice regions available to this guild.\n */\n public fetchVoiceRegions(): Promise<APIVoiceRegion[]> {\n return getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 type { GatewayClient } from \"../GatewayClient.js\";\r\nimport type { GuildEmoji } from \"../structures/GuildEmoji.js\";\r\nimport type { Role } from \"../structures/Role.js\";\r\n\r\n/**\r\n * Manages the roles allowed to use one custom emoji. When it has none, everyone can use it.\r\n */\r\nexport class GuildEmojiRoleManager {\r\n public readonly client: GatewayClient;\r\n public readonly guildId: string;\r\n public readonly emojiId: string;\r\n\r\n readonly #roleIds: readonly string[];\r\n\r\n public constructor(\r\n client: GatewayClient,\r\n guildId: string,\r\n emojiId: string,\r\n roleIds: readonly string[],\r\n ) {\r\n this.client = client;\r\n this.guildId = guildId;\r\n this.emojiId = emojiId;\r\n this.#roleIds = roleIds;\r\n }\r\n\r\n /**\r\n * The IDs of the allowed roles.\r\n */\r\n public get ids(): readonly string[] {\r\n return this.#roleIds;\r\n }\r\n\r\n /**\r\n * Fetches the allowed roles, cache first.\r\n */\r\n public fetch(): Promise<Role[]> {\r\n return Promise.all(this.#roleIds.map((id) => this.client.roles.fetch(this.guildId, id)));\r\n }\r\n\r\n /**\r\n * Allows more roles to use the emoji.\r\n *\r\n * @param roles The ID of the role, or several IDs.\r\n */\r\n public add(roles: string | readonly string[]): Promise<GuildEmoji> {\r\n const added = typeof roles === \"string\" ? [roles] : roles;\r\n return this.set([...new Set([...this.#roleIds, ...added])]);\r\n }\r\n\r\n /**\r\n * Stops allowing roles to use the emoji.\r\n *\r\n * @param roles The ID of the role, or several IDs.\r\n */\r\n public remove(roles: string | readonly string[]): Promise<GuildEmoji> {\r\n const removed = new Set(typeof roles === \"string\" ? [roles] : roles);\r\n return this.set(this.#roleIds.filter((id) => !removed.has(id)));\r\n }\r\n\r\n /**\r\n * Replaces the allowed roles, everyone when empty.\r\n *\r\n * @param roles The IDs of the roles.\r\n */\r\n public set(roles: readonly string[]): Promise<GuildEmoji> {\r\n return this.client.guilds.emojis(this.guildId).edit(this.emojiId, { roles });\r\n }\r\n}\r\n","import type { EmojiURLOptions } from \"@discordjs/rest\";\r\nimport type { APIEmoji } from \"discord-api-types/v10\";\r\nimport { cdn } from \"../util/cdn.js\";\r\nimport { kData, snowflakeTimestamp, Structure } from \"./Structure.js\";\r\n\r\n/**\r\n * The raw fields any emoji carries: a custom emoji has an ID, a Unicode one only a name.\r\n */\r\nexport type EmojiData = Pick<APIEmoji, \"id\" | \"name\"> & Partial<Pick<APIEmoji, \"animated\">>;\r\n\r\n/**\r\n * An emoji: a custom one (with an ID) or a Unicode one.\r\n *\r\n * @typeParam Data The raw emoji data this structure wraps.\r\n */\r\nexport class Emoji<Data extends EmojiData = EmojiData> extends Structure<Data> {\r\n /**\r\n * The ID of the emoji, `null` for a Unicode emoji.\r\n */\r\n public get id(): string | null {\r\n return this[kData].id;\r\n }\r\n\r\n /**\r\n * The name of the emoji, or the emoji itself for a Unicode one. `null` for deleted custom emojis in reactions.\r\n */\r\n public get name(): string | null {\r\n return this[kData].name;\r\n }\r\n\r\n public get animated(): boolean {\r\n return this[kData].animated ?? false;\r\n }\r\n\r\n /**\r\n * The form reactions routes expect: `name:id` for custom emojis, the URL-encoded emoji for Unicode ones.\r\n */\r\n public get identifier(): string {\r\n const { id, name } = this;\r\n if (id) return `${this.animated ? \"a:\" : \"\"}${name ?? \"_\"}:${id}`;\r\n return encodeURIComponent(name ?? \"\");\r\n }\r\n\r\n /**\r\n * When the custom emoji was created, `null` for a Unicode emoji.\r\n */\r\n public get createdTimestamp(): number | null {\r\n const { id } = this;\r\n return id ? snowflakeTimestamp(id) : null;\r\n }\r\n\r\n public get createdAt(): Date | null {\r\n const { createdTimestamp } = this;\r\n return createdTimestamp === null ? null : new Date(createdTimestamp);\r\n }\r\n\r\n /**\r\n * Gets the URL of the custom emoji's image, `null` for a Unicode emoji. Animated emojis default to a GIF.\r\n * @param options The image options.\r\n */\r\n public imageURL(options?: EmojiURLOptions): string | null {\r\n const { id } = this;\r\n if (!id) return null;\r\n return cdn.emoji(id, options ?? (this.animated ? { extension: \"gif\" } : undefined));\r\n }\r\n\r\n /**\r\n * The emoji as it is written in a message: `<:name:id>`, `<a:name:id>`, or the Unicode emoji itself.\r\n */\r\n public toString(): string {\r\n const { id, name } = this;\r\n return id ? `<${this.animated ? \"a\" : \"\"}:${name ?? \"_\"}:${id}>` : (name ?? \"\");\r\n }\r\n}\r\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\r\nimport type { GuildEmojiEditOptions } from \"../managers/GuildEmojiManager.js\";\r\nimport { GuildEmojiRoleManager } from \"../managers/GuildEmojiRoleManager.js\";\r\nimport { getGatewayClient } from \"../util/container.js\";\r\nimport { Emoji } from \"./Emoji.js\";\r\nimport type { Guild } from \"./Guild.js\";\r\nimport { kData, kPatch, kRelations } from \"./Structure.js\";\r\nimport { User } from \"./User.js\";\r\n\r\n/**\r\n * A custom emoji of a guild.\r\n */\r\nexport class GuildEmoji extends Emoji<CacheEntityTypes[\"emojis\"]> {\r\n declare public [kRelations]: { author?: User; guild?: Guild | null };\r\n\r\n /**\r\n * @param data The raw emoji.\r\n * @param relations The uploader and guild as resolved from the cache, by the guild's emoji manager.\r\n */\r\n public constructor(\r\n data: CacheEntityTypes[\"emojis\"],\r\n relations: { author?: User; guild?: Guild | null } = {},\r\n ) {\r\n super(data, relations);\r\n }\r\n\r\n public override [kPatch](data: Readonly<Partial<CacheEntityTypes[\"emojis\"]>>): this {\r\n if (data.user) this.dropRelations(\"author\");\r\n return super[kPatch](data);\r\n }\r\n\r\n public override get id(): string {\r\n return this[kData].id!;\r\n }\r\n\r\n public get guildId() {\r\n return this[kData].guild_id;\r\n }\r\n\r\n /**\r\n * The guild, from the cache. `null` when the guild is not cached, or when the emoji was not built by a manager: use\r\n * `fetchGuild()` to always get it.\r\n */\r\n public get guild(): Guild | null {\r\n return this[kRelations].guild ?? null;\r\n }\r\n\r\n /**\r\n * Fetches the guild, cache first.\r\n */\r\n public fetchGuild(): Promise<Guild> {\r\n return getGatewayClient().guilds.fetch(this.guildId);\r\n }\r\n\r\n /**\r\n * Whether the emoji is managed by an integration, e.g. Twitch.\r\n */\r\n public get managed(): boolean {\r\n return this[kData].managed ?? false;\r\n }\r\n\r\n public get requiresColons(): boolean {\r\n return this[kData].require_colons ?? true;\r\n }\r\n\r\n /**\r\n * Whether the emoji can be used, `false` when the guild lost the boosts it needs.\r\n */\r\n public get available(): boolean {\r\n return this[kData].available ?? true;\r\n }\r\n\r\n /**\r\n * The IDs of the roles allowed to use the emoji, everyone when empty.\r\n */\r\n public get roleIds(): readonly string[] {\r\n return this[kData].roles ?? [];\r\n }\r\n\r\n /**\r\n * The roles allowed to use the emoji.\r\n */\r\n public get roles(): GuildEmojiRoleManager {\r\n return new GuildEmojiRoleManager(getGatewayClient(), this.guildId, this.id, this.roleIds);\r\n }\r\n\r\n /**\r\n * The user who uploaded the emoji, when the payload includes it (it needs `ManageGuildExpressions`).\r\n */\r\n public get author(): User | null {\r\n const { user } = this[kData];\r\n return this[kRelations].author ?? (user ? new User(user) : null);\r\n }\r\n\r\n /**\r\n * Whether the bot can delete the emoji: it is not managed, and the bot has `ManageGuildExpressions`.\r\n */\r\n public async fetchDeletable(): Promise<boolean> {\r\n if (this.managed) return false;\r\n const me = await getGatewayClient().members.fetchMe(this.guildId);\r\n return (await me.fetchPermissions()).has(\"ManageGuildExpressions\");\r\n }\r\n\r\n /**\r\n * Fetches the user who uploaded the emoji.\r\n */\r\n public fetchAuthor(): Promise<User | null> {\r\n return getGatewayClient().guilds.emojis(this.guildId).fetchAuthor(this.id);\r\n }\r\n\r\n public async edit(options: GuildEmojiEditOptions): Promise<this> {\r\n const emoji = await getGatewayClient().guilds.emojis(this.guildId).edit(this.id, options);\r\n return this[kPatch](emoji.toJSON());\r\n }\r\n\r\n public setName(name: string, reason?: string): Promise<this> {\r\n return this.edit({ name, reason });\r\n }\r\n\r\n public async delete(reason?: string): Promise<this> {\r\n await getGatewayClient().guilds.emojis(this.guildId).delete(this.id, reason);\r\n return this;\r\n }\r\n\r\n /**\r\n * Whether this emoji has the same data as another one.\r\n * @param emoji The emoji to compare with.\r\n */\r\n public equals(emoji: GuildEmoji): boolean {\r\n return (\r\n this.id === emoji.id &&\r\n this.name === emoji.name &&\r\n this.managed === emoji.managed &&\r\n this.available === emoji.available &&\r\n this.requiresColons === emoji.requiresColons &&\r\n this.roleIds.length === emoji.roleIds.length &&\r\n this.roleIds.every((id) => emoji.roleIds.includes(id))\r\n );\r\n }\r\n}\r\n","import type { StickerExtension } from \"@discordjs/rest\";\r\nimport { StickerFormatType, type APISticker } from \"discord-api-types/v10\";\r\nimport type { GuildStickerEditOptions } from \"../managers/GuildStickerManager.js\";\r\nimport { cdn } from \"../util/cdn.js\";\r\nimport { getGatewayClient } from \"../util/container.js\";\r\nimport type { StickerPack } from \"./StickerPack.js\";\r\nimport type { Guild } from \"./Guild.js\";\r\nimport { kData, kPatch, kRelations, snowflakeTimestamp, Structure } from \"./Structure.js\";\r\nimport { User } from \"./User.js\";\r\n\r\n/**\r\n * A sticker: a standard one from a sticker pack, or a custom one of a guild.\r\n */\r\nexport class Sticker extends Structure<APISticker> {\r\n declare public [kRelations]: { user?: User; guild?: Guild | null };\r\n\r\n /**\r\n * @param data The raw sticker.\r\n * @param relations The uploader and guild as resolved from the cache, by the guild's sticker manager.\r\n */\r\n public constructor(data: APISticker, relations: { user?: User; guild?: Guild | null } = {}) {\r\n super(data, relations);\r\n }\r\n\r\n public override [kPatch](data: Readonly<Partial<APISticker>>): this {\r\n if (data.user) this.dropRelations(\"user\");\r\n return super[kPatch](data);\r\n }\r\n\r\n public get id() {\r\n return this[kData].id;\r\n }\r\n\r\n public get name() {\r\n return this[kData].name;\r\n }\r\n\r\n public get description() {\r\n return this[kData].description;\r\n }\r\n\r\n /**\r\n * The autocomplete and suggestion tags of the sticker, comma separated.\r\n */\r\n public get tags() {\r\n return this[kData].tags;\r\n }\r\n\r\n /**\r\n * Whether it is a standard (pack) sticker or a guild one.\r\n */\r\n public get type() {\r\n return this[kData].type;\r\n }\r\n\r\n public get format() {\r\n return this[kData].format_type;\r\n }\r\n\r\n /**\r\n * Whether the sticker can be used, `false` when its guild lost the boosts it needs.\r\n */\r\n public get available(): boolean {\r\n return this[kData].available ?? true;\r\n }\r\n\r\n public get guildId(): string | null {\r\n return this[kData].guild_id ?? null;\r\n }\r\n\r\n /**\r\n * The guild, from the cache. `null` outside of guilds, when the guild is not cached, or when the sticker was not built by\r\n * a manager: use `fetchGuild()` to always get it.\r\n */\r\n public get guild(): Guild | null {\r\n return this[kRelations].guild ?? null;\r\n }\r\n\r\n /**\r\n * Fetches the guild, cache first. `null` outside of guilds.\r\n */\r\n public async fetchGuild(): Promise<Guild | null> {\r\n const { guildId } = this;\r\n return guildId ? getGatewayClient().guilds.fetch(guildId) : null;\r\n }\r\n\r\n /**\r\n * The ID of the pack of a standard sticker.\r\n */\r\n public get packId(): string | null {\r\n return this[kData].pack_id ?? null;\r\n }\r\n\r\n /**\r\n * The position of a standard sticker in its pack.\r\n */\r\n public get sortValue(): number | null {\r\n return this[kData].sort_value ?? null;\r\n }\r\n\r\n /**\r\n * The user who uploaded a guild sticker, when the payload includes it (it needs `ManageGuildExpressions`).\r\n */\r\n public get user(): User | null {\r\n const { user } = this[kData];\r\n return this[kRelations].user ?? (user ? new User(user) : null);\r\n }\r\n\r\n public get createdTimestamp() {\r\n return snowflakeTimestamp(this.id);\r\n }\r\n\r\n public get createdAt() {\r\n return new Date(this.createdTimestamp);\r\n }\r\n\r\n /**\r\n * The URL of the sticker's image: a GIF for GIF stickers, a JSON file for Lottie ones, a PNG otherwise.\r\n */\r\n public get url(): string {\r\n const extension: StickerExtension =\r\n this.format === StickerFormatType.GIF\r\n ? \"gif\"\r\n : this.format === StickerFormatType.Lottie\r\n ? \"json\"\r\n : \"png\";\r\n return cdn.sticker(this.id, extension);\r\n }\r\n\r\n /**\r\n * Fetches the sticker from the API and patches this structure with the result.\r\n */\r\n public async fetch(): Promise<this> {\r\n const sticker = await getGatewayClient().fetchSticker(this.id);\r\n return this[kPatch](sticker.toJSON());\r\n }\r\n\r\n /**\r\n * Fetches the pack of a standard sticker, `null` for a guild sticker.\r\n */\r\n public async fetchPack(): Promise<StickerPack | null> {\r\n const { packId } = this;\r\n if (!packId) return null;\r\n const packs = await getGatewayClient().fetchStickerPacks();\r\n return packs.find((pack) => pack.id === packId) ?? null;\r\n }\r\n\r\n /**\r\n * Fetches the user who uploaded a guild sticker, `null` for a standard one or without `ManageGuildExpressions`.\r\n */\r\n public async fetchUser(): Promise<User | null> {\r\n const { guildId } = this;\r\n if (!guildId) return null;\r\n return getGatewayClient().guilds.stickers(guildId).fetchUser(this.id);\r\n }\r\n\r\n /**\r\n * Edits a guild sticker.\r\n *\r\n * @param options The changes to apply.\r\n */\r\n public async edit(options: GuildStickerEditOptions): Promise<this> {\r\n const sticker = await getGatewayClient()\r\n .guilds.stickers(this.requireGuildId())\r\n .edit(this.id, options);\r\n return this[kPatch](sticker.toJSON());\r\n }\r\n\r\n /**\r\n * Deletes a guild sticker.\r\n *\r\n * @param reason The reason for the audit log.\r\n */\r\n public async delete(reason?: string): Promise<this> {\r\n await getGatewayClient().guilds.stickers(this.requireGuildId()).delete(this.id, reason);\r\n return this;\r\n }\r\n\r\n /**\r\n * Whether this sticker has the same data as another one.\r\n * @param sticker The sticker to compare with.\r\n */\r\n public equals(sticker: Sticker): boolean {\r\n return (\r\n this.id === sticker.id &&\r\n this.name === sticker.name &&\r\n this.description === sticker.description &&\r\n this.tags === sticker.tags &&\r\n this.format === sticker.format &&\r\n this.available === sticker.available &&\r\n this.guildId === sticker.guildId\r\n );\r\n }\r\n\r\n private requireGuildId(): string {\r\n const { guildId } = this;\r\n if (!guildId) throw new Error(\"Only guild stickers can be edited or deleted\");\r\n return guildId;\r\n }\r\n}\r\n","import type { BaseImageURLOptions, ImageURLOptions } from \"@discordjs/rest\";\r\nimport type { APIGuildPreview } from \"discord-api-types/v10\";\r\nimport { cdn } from \"../util/cdn.js\";\r\nimport { GuildEmoji } from \"./GuildEmoji.js\";\r\nimport { Sticker } from \"./Sticker.js\";\r\nimport { kData, snowflakeTimestamp, Structure } from \"./Structure.js\";\r\n\r\n/**\r\n * The public preview of a guild, available for discoverable guilds and the ones the bot is in.\r\n */\r\nexport class GuildPreview extends Structure<APIGuildPreview> {\r\n public get id() {\r\n return this[kData].id;\r\n }\r\n\r\n public get name() {\r\n return this[kData].name;\r\n }\r\n\r\n public get icon() {\r\n return this[kData].icon;\r\n }\r\n\r\n public get splash() {\r\n return this[kData].splash;\r\n }\r\n\r\n public get discoverySplash() {\r\n return this[kData].discovery_splash;\r\n }\r\n\r\n public get description() {\r\n return this[kData].description;\r\n }\r\n\r\n public get features() {\r\n return this[kData].features;\r\n }\r\n\r\n public get approximateMemberCount() {\r\n return this[kData].approximate_member_count;\r\n }\r\n\r\n public get approximatePresenceCount() {\r\n return this[kData].approximate_presence_count;\r\n }\r\n\r\n public get emojis(): GuildEmoji[] {\r\n return this[kData].emojis.map((emoji) => new GuildEmoji({ ...emoji, guild_id: this.id }));\r\n }\r\n\r\n public get stickers(): Sticker[] {\r\n return this[kData].stickers.map((sticker) => new Sticker(sticker));\r\n }\r\n\r\n public get createdTimestamp() {\r\n return snowflakeTimestamp(this.id);\r\n }\r\n\r\n public get createdAt() {\r\n return new Date(this.createdTimestamp);\r\n }\r\n\r\n public iconURL(options?: ImageURLOptions): string | null {\r\n const { icon } = this;\r\n return icon ? cdn.icon(this.id, icon, options) : null;\r\n }\r\n\r\n public splashURL(options?: BaseImageURLOptions): string | null {\r\n const { splash } = this;\r\n return splash ? cdn.splash(this.id, splash, options) : null;\r\n }\r\n\r\n public discoverySplashURL(options?: BaseImageURLOptions): string | null {\r\n const { discoverySplash } = this;\r\n return discoverySplash ? cdn.discoverySplash(this.id, discoverySplash, options) : null;\r\n }\r\n\r\n public toString(): string {\r\n return this.name;\r\n }\r\n}\r\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\r\nimport { AuditLogEvent, type APIAuditLogChange } from \"discord-api-types/v10\";\r\nimport type { Guild } from \"./Guild.js\";\r\nimport { kData, kRelations, snowflakeTimestamp, Structure } from \"./Structure.js\";\r\nimport type { User } from \"./User.js\";\r\n\r\n/**\r\n * Whether an audit log action created, deleted, or updated something, like discord.js's `actionType`.\r\n */\r\nexport type AuditLogActionType = \"Create\" | \"Delete\" | \"Update\";\r\n\r\nconst CreateActions = new Set<AuditLogEvent>([\r\n AuditLogEvent.ChannelCreate,\r\n AuditLogEvent.ChannelOverwriteCreate,\r\n AuditLogEvent.MemberBanRemove,\r\n AuditLogEvent.BotAdd,\r\n AuditLogEvent.RoleCreate,\r\n AuditLogEvent.InviteCreate,\r\n AuditLogEvent.WebhookCreate,\r\n AuditLogEvent.EmojiCreate,\r\n AuditLogEvent.MessagePin,\r\n AuditLogEvent.IntegrationCreate,\r\n AuditLogEvent.StageInstanceCreate,\r\n AuditLogEvent.StickerCreate,\r\n AuditLogEvent.GuildScheduledEventCreate,\r\n AuditLogEvent.ThreadCreate,\r\n AuditLogEvent.SoundboardSoundCreate,\r\n AuditLogEvent.AutoModerationRuleCreate,\r\n AuditLogEvent.OnboardingPromptCreate,\r\n]);\r\n\r\nconst DeleteActions = new Set<AuditLogEvent>([\r\n AuditLogEvent.ChannelDelete,\r\n AuditLogEvent.ChannelOverwriteDelete,\r\n AuditLogEvent.MemberKick,\r\n AuditLogEvent.MemberPrune,\r\n AuditLogEvent.MemberBanAdd,\r\n AuditLogEvent.MemberDisconnect,\r\n AuditLogEvent.RoleDelete,\r\n AuditLogEvent.InviteDelete,\r\n AuditLogEvent.WebhookDelete,\r\n AuditLogEvent.EmojiDelete,\r\n AuditLogEvent.MessageDelete,\r\n AuditLogEvent.MessageBulkDelete,\r\n AuditLogEvent.MessageUnpin,\r\n AuditLogEvent.IntegrationDelete,\r\n AuditLogEvent.StageInstanceDelete,\r\n AuditLogEvent.StickerDelete,\r\n AuditLogEvent.GuildScheduledEventDelete,\r\n AuditLogEvent.ThreadDelete,\r\n AuditLogEvent.SoundboardSoundDelete,\r\n AuditLogEvent.AutoModerationRuleDelete,\r\n AuditLogEvent.OnboardingPromptDelete,\r\n]);\r\n\r\n/**\r\n * The relations of a {@link GuildAuditLogsEntry}: the users of the audit log page, or of the cache.\r\n */\r\nexport interface GuildAuditLogsEntryRelations {\r\n executor?: User | null;\r\n guild?: Guild | null;\r\n}\r\n\r\n/**\r\n * An entry of a guild's audit log.\r\n */\r\nexport class GuildAuditLogsEntry extends Structure<CacheEntityTypes[\"auditLogEntries\"]> {\r\n declare public [kRelations]: GuildAuditLogsEntryRelations;\r\n\r\n /**\r\n * @param data The raw entry, with its guild's ID.\r\n * @param relations The executor and guild, resolved by `guild.fetchAuditLogs()` or the event.\r\n */\r\n public constructor(\r\n data: CacheEntityTypes[\"auditLogEntries\"],\r\n relations: GuildAuditLogsEntryRelations = {},\r\n ) {\r\n super(data, relations);\r\n }\r\n\r\n public get id() {\r\n return this[kData].id;\r\n }\r\n\r\n public get guildId() {\r\n return this[kData].guild_id;\r\n }\r\n\r\n public get action(): AuditLogEvent {\r\n return this[kData].action_type;\r\n }\r\n\r\n public get actionType(): AuditLogActionType {\r\n if (CreateActions.has(this.action)) return \"Create\";\r\n if (DeleteActions.has(this.action)) return \"Delete\";\r\n return \"Update\";\r\n }\r\n\r\n /**\r\n * The ID of the user or application that made the change.\r\n */\r\n public get executorId(): string | null {\r\n return this[kData].user_id;\r\n }\r\n\r\n /**\r\n * The ID of the affected entity: a user, role, channel, webhook, ...\r\n */\r\n public get targetId(): string | null {\r\n return this[kData].target_id;\r\n }\r\n\r\n public get reason(): string | null {\r\n return this[kData].reason ?? null;\r\n }\r\n\r\n /**\r\n * The changed fields, with their old and new values.\r\n */\r\n public get changes(): readonly APIAuditLogChange[] {\r\n return this[kData].changes ?? [];\r\n }\r\n\r\n /**\r\n * The extra details of some actions, e.g. the channel of a message deletion.\r\n */\r\n public get extra() {\r\n return this[kData].options ?? null;\r\n }\r\n\r\n public get executor(): User | null {\r\n return this[kRelations].executor ?? null;\r\n }\r\n\r\n public get guild(): Guild | null {\r\n return this[kRelations].guild ?? null;\r\n }\r\n\r\n public get createdTimestamp() {\r\n return snowflakeTimestamp(this.id);\r\n }\r\n\r\n public get createdAt() {\r\n return new Date(this.createdTimestamp);\r\n }\r\n}\r\n","import { FormattingPatterns, type APIPartialEmoji } from \"discord-api-types/v10\";\r\nimport { Emoji } from \"./Emoji.js\";\r\n\r\n/**\r\n * Anything identifying an emoji: a Unicode emoji, a custom emoji mention (`<a:name:id>`), a `name:id` pair, a bare\r\n * emoji ID, or any object carrying `id`/`name`/`animated` (an {@link Emoji}, a raw `APIPartialEmoji`, ...).\r\n */\r\nexport type EmojiIdentifierResolvable =\r\n | string\r\n | { id?: string | null; name?: string | null; animated?: boolean | null };\r\n\r\n/**\r\n * Matches a `name:id` or `a:name:id` pair without the mention brackets.\r\n */\r\nconst CustomEmojiPattern = /^(?:(?<animated>a):)?(?<name>\\w{2,32}):(?<id>\\d{17,20})$/;\r\n\r\n/**\r\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.\r\n */\r\nexport class ReactionEmoji extends Emoji<APIPartialEmoji> {\r\n /**\r\n * Resolves anything {@link EmojiIdentifierResolvable} to the identifier reaction routes expect.\r\n *\r\n * @param emoji The emoji to resolve.\r\n * @throws A `TypeError` when the value identifies no emoji.\r\n */\r\n public static resolveIdentifier(emoji: EmojiIdentifierResolvable): string {\r\n if (typeof emoji === \"string\") {\r\n const decoded = emoji.includes(\"%\") ? decodeURIComponent(emoji) : emoji;\r\n if (/^\\d{17,20}$/.test(decoded)) return `_:${decoded}`;\r\n\r\n const custom = FormattingPatterns.Emoji.exec(decoded) ?? CustomEmojiPattern.exec(decoded);\r\n if (custom?.groups) {\r\n const { animated, name, id } = custom.groups;\r\n return `${animated ? \"a:\" : \"\"}${name}:${id}`;\r\n }\r\n\r\n if (!decoded) throw new TypeError(\"Cannot resolve an empty string to an emoji\");\r\n return encodeURIComponent(decoded);\r\n }\r\n\r\n const { id, name, animated } = emoji;\r\n if (id) return `${animated ? \"a:\" : \"\"}${name ?? \"_\"}:${id}`;\r\n if (name) return encodeURIComponent(name);\r\n throw new TypeError(\"Cannot resolve an emoji without an ID nor a name\");\r\n }\r\n\r\n /**\r\n * Resolves anything {@link EmojiIdentifierResolvable} to the ID and name pair of welcome screens and onboarding.\r\n *\r\n * @param emoji The emoji to resolve.\r\n */\r\n public static resolvePartial(emoji: EmojiIdentifierResolvable): {\r\n id: string | null;\r\n name: string | null;\r\n animated: boolean;\r\n } {\r\n if (typeof emoji !== \"string\") {\r\n return { id: emoji.id ?? null, name: emoji.name ?? null, animated: emoji.animated ?? false };\r\n }\r\n\r\n if (/^\\d{17,20}$/.test(emoji)) return { id: emoji, name: null, animated: false };\r\n const custom = FormattingPatterns.Emoji.exec(emoji) ?? CustomEmojiPattern.exec(emoji);\r\n if (custom?.groups) {\r\n const { animated, name, id } = custom.groups;\r\n return { id: id!, name: name!, animated: Boolean(animated) };\r\n }\r\n\r\n return { id: null, name: emoji, animated: false };\r\n }\r\n}\r\n","import type {\r\n APIGuildOnboarding,\r\n APIGuildOnboardingPrompt,\r\n APIGuildOnboardingPromptOption,\r\n} from \"discord-api-types/v10\";\r\nimport type { GuildOnboardingEditOptions } from \"../managers/GuildManager.js\";\r\nimport { getGatewayClient } from \"../util/container.js\";\r\nimport type { Guild } from \"./Guild.js\";\r\nimport { ReactionEmoji } from \"./ReactionEmoji.js\";\r\nimport { kData, kPatch, kRelations, Structure } from \"./Structure.js\";\r\n\r\n/**\r\n * An answer of an onboarding prompt, with the channels and roles it gives.\r\n */\r\nexport class GuildOnboardingPromptOption extends Structure<APIGuildOnboardingPromptOption> {\r\n public get id() {\r\n return this[kData].id;\r\n }\r\n\r\n public get title() {\r\n return this[kData].title;\r\n }\r\n\r\n public get description() {\r\n return this[kData].description;\r\n }\r\n\r\n public get channelIds() {\r\n return this[kData].channel_ids;\r\n }\r\n\r\n public get roleIds() {\r\n return this[kData].role_ids;\r\n }\r\n\r\n public get emoji(): ReactionEmoji | null {\r\n const { emoji } = this[kData];\r\n return emoji?.id || emoji?.name ? new ReactionEmoji(emoji) : null;\r\n }\r\n}\r\n\r\n/**\r\n * A question of a guild's onboarding.\r\n */\r\nexport class GuildOnboardingPrompt extends Structure<APIGuildOnboardingPrompt> {\r\n public get id() {\r\n return this[kData].id;\r\n }\r\n\r\n public get title() {\r\n return this[kData].title;\r\n }\r\n\r\n public get type() {\r\n return this[kData].type;\r\n }\r\n\r\n public get singleSelect() {\r\n return this[kData].single_select;\r\n }\r\n\r\n public get required() {\r\n return this[kData].required;\r\n }\r\n\r\n /**\r\n * Whether the prompt is asked during onboarding, rather than only in the channels & roles page.\r\n */\r\n public get inOnboarding() {\r\n return this[kData].in_onboarding;\r\n }\r\n\r\n public get options(): GuildOnboardingPromptOption[] {\r\n return this[kData].options.map((option) => new GuildOnboardingPromptOption(option));\r\n }\r\n}\r\n\r\n/**\r\n * The relations of a {@link GuildOnboarding}: its guild, when cached.\r\n */\r\nexport interface GuildOnboardingRelations {\r\n guild?: Guild | null;\r\n}\r\n\r\n/**\r\n * The onboarding of a guild: the prompts new members answer, and the channels they start in.\r\n */\r\nexport class GuildOnboarding extends Structure<APIGuildOnboarding> {\r\n declare public [kRelations]: GuildOnboardingRelations;\r\n\r\n /**\r\n * @param data The raw onboarding.\r\n * @param relations The guild, as resolved from the cache.\r\n */\r\n public constructor(data: APIGuildOnboarding, relations: GuildOnboardingRelations = {}) {\r\n super(data, relations);\r\n }\r\n\r\n public get guildId() {\r\n return this[kData].guild_id;\r\n }\r\n\r\n public get prompts(): GuildOnboardingPrompt[] {\r\n return this[kData].prompts.map((prompt) => new GuildOnboardingPrompt(prompt));\r\n }\r\n\r\n /**\r\n * The channels members are in by default.\r\n */\r\n public get defaultChannelIds() {\r\n return this[kData].default_channel_ids;\r\n }\r\n\r\n public get enabled() {\r\n return this[kData].enabled;\r\n }\r\n\r\n public get mode() {\r\n return this[kData].mode;\r\n }\r\n\r\n public get guild(): Guild | null {\r\n return this[kRelations].guild ?? null;\r\n }\r\n\r\n /**\r\n * Edits the onboarding.\r\n *\r\n * @param options The changes to apply.\r\n */\r\n public async edit(options: GuildOnboardingEditOptions): Promise<this> {\r\n const onboarding = await getGatewayClient().guilds.editOnboarding(this.guildId, options);\r\n return this[kPatch](onboarding.toJSON());\r\n }\r\n}\r\n","import { GuildFeature, type APIGuildWelcomeScreen } from \"discord-api-types/v10\";\r\nimport type { GuildWelcomeScreenEditOptions } from \"../managers/GuildManager.js\";\r\nimport { getGatewayClient } from \"../util/container.js\";\r\nimport type { Guild } from \"./Guild.js\";\r\nimport { ReactionEmoji } from \"./ReactionEmoji.js\";\r\nimport { kData, kPatch, kRelations, Structure } from \"./Structure.js\";\r\n\r\n/**\r\n * The raw data of a welcome screen, with the ID of its guild.\r\n */\r\nexport type WelcomeScreenData = APIGuildWelcomeScreen & { guild_id: string };\r\n\r\n/**\r\n * A channel suggested by a welcome screen.\r\n */\r\nexport interface WelcomeChannel {\r\n channelId: string;\r\n description: string;\r\n /**\r\n * The emoji shown next to the channel, if any.\r\n */\r\n emoji: ReactionEmoji | null;\r\n}\r\n\r\n/**\r\n * The relations of a {@link WelcomeScreen}: its guild, when cached.\r\n */\r\nexport interface WelcomeScreenRelations {\r\n guild?: Guild | null;\r\n}\r\n\r\n/**\r\n * The screen new members of a community guild see, suggesting channels to start with.\r\n */\r\nexport class WelcomeScreen extends Structure<WelcomeScreenData> {\r\n declare public [kRelations]: WelcomeScreenRelations;\r\n\r\n /**\r\n * @param data The raw welcome screen.\r\n * @param relations The guild, as resolved from the cache.\r\n */\r\n public constructor(data: WelcomeScreenData, relations: WelcomeScreenRelations = {}) {\r\n super(data, relations);\r\n }\r\n\r\n public get guildId() {\r\n return this[kData].guild_id;\r\n }\r\n\r\n public get description() {\r\n return this[kData].description;\r\n }\r\n\r\n public get welcomeChannels(): WelcomeChannel[] {\r\n return this[kData].welcome_channels.map((channel) => ({\r\n channelId: channel.channel_id,\r\n description: channel.description,\r\n emoji:\r\n channel.emoji_id || channel.emoji_name\r\n ? new ReactionEmoji({ id: channel.emoji_id, name: channel.emoji_name })\r\n : null,\r\n }));\r\n }\r\n\r\n public get guild(): Guild | null {\r\n return this[kRelations].guild ?? null;\r\n }\r\n\r\n /**\r\n * Whether the welcome screen is shown, from the features of the cached guild; `null` when it is not cached.\r\n */\r\n public get enabled(): boolean | null {\r\n return this.guild?.features.includes(GuildFeature.WelcomeScreenEnabled) ?? null;\r\n }\r\n\r\n /**\r\n * Edits the welcome screen.\r\n *\r\n * @param options The changes to apply.\r\n */\r\n public async edit(options: GuildWelcomeScreenEditOptions): Promise<this> {\r\n const screen = await getGatewayClient().guilds.editWelcomeScreen(this.guildId, options);\r\n return this[kPatch](screen.toJSON());\r\n }\r\n}\r\n","import type { ImageURLOptions } from \"@discordjs/rest\";\r\nimport { WebhookType, type APIWebhook } from \"discord-api-types/v10\";\r\nimport type {\r\n WebhookEditOptions,\r\n WebhookMessageCreateOptions,\r\n WebhookMessageEditOptions,\r\n WebhookThreadOptions,\r\n} from \"../managers/WebhookManager.js\";\r\nimport { cdn } from \"../util/cdn.js\";\r\nimport { getGatewayClient } from \"../util/container.js\";\r\nimport type { MessagePayloadResolvable } from \"../util/messages.js\";\r\nimport type { Message } from \"./Message.js\";\r\nimport { kData, kPatch, snowflakeTimestamp, Structure } from \"./Structure.js\";\r\nimport { User } from \"./User.js\";\r\n\r\n/**\r\n * A webhook: an incoming one posting to a channel, a channel follower, or an application's.\r\n */\r\nexport class Webhook extends Structure<APIWebhook> {\r\n public get id() {\r\n return this[kData].id;\r\n }\r\n\r\n public get type() {\r\n return this[kData].type;\r\n }\r\n\r\n public get name(): string | null {\r\n return this[kData].name;\r\n }\r\n\r\n public get avatar(): string | null {\r\n return this[kData].avatar;\r\n }\r\n\r\n /**\r\n * The token to post with. Only incoming webhooks have one, and only their creator (or the guild's managers) see it.\r\n */\r\n public get token(): string | null {\r\n return this[kData].token ?? null;\r\n }\r\n\r\n public get guildId(): string | null {\r\n return this[kData].guild_id ?? null;\r\n }\r\n\r\n public get channelId(): string | null {\r\n return this[kData].channel_id;\r\n }\r\n\r\n public get applicationId(): string | null {\r\n return this[kData].application_id;\r\n }\r\n\r\n /**\r\n * The user who created the webhook, when the payload includes it.\r\n */\r\n public get owner(): User | null {\r\n const { user } = this[kData];\r\n return user ? new User(user) : null;\r\n }\r\n\r\n /**\r\n * The guild a channel follower webhook posts from.\r\n */\r\n public get sourceGuild() {\r\n return this[kData].source_guild ?? null;\r\n }\r\n\r\n /**\r\n * The channel a channel follower webhook posts from.\r\n */\r\n public get sourceChannel() {\r\n return this[kData].source_channel ?? null;\r\n }\r\n\r\n /**\r\n * The URL to post to, for webhooks with a token.\r\n */\r\n public get url(): string | null {\r\n const { token } = this;\r\n return (\r\n this[kData].url ?? (token ? `https://discord.com/api/webhooks/${this.id}/${token}` : null)\r\n );\r\n }\r\n\r\n public get createdTimestamp() {\r\n return snowflakeTimestamp(this.id);\r\n }\r\n\r\n public get createdAt() {\r\n return new Date(this.createdTimestamp);\r\n }\r\n\r\n public avatarURL(options?: Readonly<ImageURLOptions>): string | null {\r\n const { avatar } = this;\r\n return avatar ? cdn.avatar(this.id, avatar, options) : null;\r\n }\r\n\r\n public isIncoming(): boolean {\r\n return this.type === WebhookType.Incoming;\r\n }\r\n\r\n public isChannelFollower(): boolean {\r\n return this.type === WebhookType.ChannelFollower;\r\n }\r\n\r\n public isApplicationCreated(): boolean {\r\n return this.type === WebhookType.Application;\r\n }\r\n\r\n /**\r\n * Sends a message through the webhook.\r\n *\r\n * @param options The message, or its content, and the thread to send it in.\r\n */\r\n public send(\r\n options: MessagePayloadResolvable<WebhookMessageCreateOptions> & WebhookThreadOptions,\r\n ): Promise<Message> {\r\n return getGatewayClient().webhooks.send(this.id, this.requireToken(), options);\r\n }\r\n\r\n /**\r\n * Edits the webhook, with its token when it has one (then it cannot be moved to another channel).\r\n *\r\n * @param options The fields to edit, and the reason for the audit log.\r\n */\r\n public async edit(options: WebhookEditOptions): Promise<this> {\r\n const token = options.channel === undefined ? (this.token ?? undefined) : undefined;\r\n const webhook = await getGatewayClient().webhooks.edit(this.id, options, token);\r\n return this[kPatch](webhook.toJSON());\r\n }\r\n\r\n /**\r\n * Deletes the webhook.\r\n *\r\n * @param reason The reason for the audit log.\r\n */\r\n public async delete(reason?: string): Promise<this> {\r\n await getGatewayClient().webhooks.delete(this.id, { token: this.token ?? undefined, reason });\r\n return this;\r\n }\r\n\r\n public fetchMessage(messageId: string, options?: WebhookThreadOptions): Promise<Message> {\r\n return getGatewayClient().webhooks.fetchMessage(\r\n this.id,\r\n this.requireToken(),\r\n messageId,\r\n options,\r\n );\r\n }\r\n\r\n public editMessage(\r\n messageId: string,\r\n options: MessagePayloadResolvable<WebhookMessageEditOptions> & WebhookThreadOptions,\r\n ): Promise<Message> {\r\n return getGatewayClient().webhooks.editMessage(\r\n this.id,\r\n this.requireToken(),\r\n messageId,\r\n options,\r\n );\r\n }\r\n\r\n public deleteMessage(messageId: string, options?: WebhookThreadOptions): Promise<void> {\r\n return getGatewayClient().webhooks.deleteMessage(\r\n this.id,\r\n this.requireToken(),\r\n messageId,\r\n options,\r\n );\r\n }\r\n\r\n private requireToken(): string {\r\n const { token } = this;\r\n if (!token) throw new Error(`Webhook ${this.id} has no token to post with`);\r\n return token;\r\n }\r\n}\r\n","import type {\r\n APIAutoModerationAction,\r\n APIAutoModerationRule,\r\n APIAutoModerationRuleTriggerMetadata,\r\n AutoModerationRuleEventType,\r\n AutoModerationRuleKeywordPresetType,\r\n} from \"discord-api-types/v10\";\r\nimport type { AutoModerationRuleEditOptions } from \"../managers/AutoModerationRuleManager.js\";\r\nimport type { IdResolvable } from \"../util/channels.js\";\r\nimport { getGatewayClient } from \"../util/container.js\";\r\nimport type { Guild } from \"./Guild.js\";\r\nimport { kData, kPatch, kRelations, Structure } from \"./Structure.js\";\r\n\r\n/**\r\n * The relations of an {@link AutoModerationRule}, resolved from the cache by the guild's rule manager.\r\n */\r\nexport interface AutoModerationRuleRelations {\r\n guild?: Guild | null;\r\n}\r\n\r\n/**\r\n * An auto moderation rule of a guild.\r\n */\r\nexport class AutoModerationRule extends Structure<APIAutoModerationRule> {\r\n declare public [kRelations]: AutoModerationRuleRelations;\r\n\r\n /**\r\n * @param data The raw rule.\r\n * @param relations The guild as resolved from the cache, by the guild's rule manager.\r\n */\r\n public constructor(data: APIAutoModerationRule, relations: AutoModerationRuleRelations = {}) {\r\n super(data, relations);\r\n }\r\n\r\n public get id() {\r\n return this[kData].id;\r\n }\r\n\r\n public get guildId() {\r\n return this[kData].guild_id;\r\n }\r\n\r\n public get name() {\r\n return this[kData].name;\r\n }\r\n\r\n public get creatorId() {\r\n return this[kData].creator_id;\r\n }\r\n\r\n public get eventType() {\r\n return this[kData].event_type;\r\n }\r\n\r\n public get triggerType() {\r\n return this[kData].trigger_type;\r\n }\r\n\r\n public get triggerMetadata(): Readonly<APIAutoModerationRuleTriggerMetadata> {\r\n return this[kData].trigger_metadata;\r\n }\r\n\r\n public get actions(): readonly APIAutoModerationAction[] {\r\n return this[kData].actions;\r\n }\r\n\r\n public get enabled() {\r\n return this[kData].enabled;\r\n }\r\n\r\n public get exemptRoles(): readonly string[] {\r\n return this[kData].exempt_roles;\r\n }\r\n\r\n public get exemptChannels(): readonly string[] {\r\n return this[kData].exempt_channels;\r\n }\r\n\r\n public get guild(): Guild | null {\r\n return this[kRelations].guild ?? null;\r\n }\r\n\r\n /**\r\n * Edits the rule.\r\n *\r\n * @param options The fields to edit, and the reason for the audit log.\r\n */\r\n public async edit(options: AutoModerationRuleEditOptions): Promise<this> {\r\n const rule = await getGatewayClient()\r\n .guilds.autoModerationRules(this.guildId)\r\n .edit(this.id, options);\r\n return this[kPatch](rule.toJSON());\r\n }\r\n\r\n public setName(name: string, reason?: string): Promise<this> {\r\n return this.edit({ name, reason });\r\n }\r\n\r\n public setEventType(eventType: AutoModerationRuleEventType, reason?: string): Promise<this> {\r\n return this.edit({ eventType, reason });\r\n }\r\n\r\n public setEnabled(enabled = true, reason?: string): Promise<this> {\r\n return this.edit({ enabled, reason });\r\n }\r\n\r\n public setActions(actions: readonly APIAutoModerationAction[], reason?: string): Promise<this> {\r\n return this.edit({ actions, reason });\r\n }\r\n\r\n public setExemptRoles(roles: readonly IdResolvable[], reason?: string): Promise<this> {\r\n return this.edit({ exemptRoles: roles, reason });\r\n }\r\n\r\n public setExemptChannels(channels: readonly IdResolvable[], reason?: string): Promise<this> {\r\n return this.edit({ exemptChannels: channels, reason });\r\n }\r\n\r\n /**\r\n * Sets the keywords of a keyword rule, keeping the rest of its trigger.\r\n */\r\n public setKeywordFilter(keywordFilter: readonly string[], reason?: string): Promise<this> {\r\n return this.editTrigger({ keyword_filter: [...keywordFilter] }, reason);\r\n }\r\n\r\n /**\r\n * Sets the regular expressions of a keyword rule, keeping the rest of its trigger.\r\n */\r\n public setRegexPatterns(regexPatterns: readonly string[], reason?: string): Promise<this> {\r\n return this.editTrigger({ regex_patterns: [...regexPatterns] }, reason);\r\n }\r\n\r\n /**\r\n * Sets the keyword presets of a keyword preset rule, keeping the rest of its trigger.\r\n */\r\n public setPresets(\r\n presets: readonly AutoModerationRuleKeywordPresetType[],\r\n reason?: string,\r\n ): Promise<this> {\r\n return this.editTrigger({ presets: [...presets] }, reason);\r\n }\r\n\r\n /**\r\n * Sets the keywords exempt from the rule, keeping the rest of its trigger.\r\n */\r\n public setAllowList(allowList: readonly string[], reason?: string): Promise<this> {\r\n return this.editTrigger({ allow_list: [...allowList] }, reason);\r\n }\r\n\r\n /**\r\n * Sets how many mentions a message may have, for a mention spam rule.\r\n */\r\n public setMentionTotalLimit(mentionTotalLimit: number, reason?: string): Promise<this> {\r\n return this.editTrigger({ mention_total_limit: mentionTotalLimit }, reason);\r\n }\r\n\r\n /**\r\n * Sets whether a mention spam rule detects mention raids.\r\n */\r\n public setMentionRaidProtectionEnabled(enabled = true, reason?: string): Promise<this> {\r\n return this.editTrigger({ mention_raid_protection_enabled: enabled }, reason);\r\n }\r\n\r\n /**\r\n * Deletes the rule.\r\n *\r\n * @param reason The reason for the audit log.\r\n */\r\n public async delete(reason?: string): Promise<this> {\r\n await getGatewayClient().guilds.autoModerationRules(this.guildId).delete(this.id, reason);\r\n return this;\r\n }\r\n\r\n // Discord replaces the whole trigger metadata, so the setters merge their field into the current one.\r\n private editTrigger(patch: APIAutoModerationRuleTriggerMetadata, reason?: string): Promise<this> {\r\n return this.edit({ triggerMetadata: { ...this.triggerMetadata, ...patch }, reason });\r\n }\r\n}\r\n","import { autoModerationRuleKey, type CacheEntityTypes } 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/AutoModerationRule.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 async hydrate(\n data: CacheEntityTypes[\"autoModerationRules\"],\n ): Promise<AutoModerationRule> {\n return new AutoModerationRule(data, { guild: await this.cachedGuild(data.guild_id) });\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.core.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.core.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.core.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.core.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.core.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\";\r\nimport { getGatewayClient } from \"../util/container.js\";\r\nimport type { Guild } from \"./Guild.js\";\r\nimport { kData, kRelations, Structure } from \"./Structure.js\";\r\nimport { User } from \"./User.js\";\r\n\r\n/**\r\n * The raw data of a ban: the banned user, the guild, and the reason when it came from the API.\r\n */\r\nexport type GuildBanData = CacheEntityTypes[\"bans\"] & { reason?: string | null };\r\n\r\n/**\r\n * The relations of a {@link GuildBan}, resolved from the cache by the guild's ban manager.\r\n */\r\nexport interface GuildBanRelations {\r\n user?: User;\r\n guild?: Guild | null;\r\n}\r\n\r\n/**\r\n * A ban of a user from a guild.\r\n */\r\nexport class GuildBan extends Structure<GuildBanData> {\r\n declare public [kRelations]: GuildBanRelations;\r\n\r\n /**\r\n * @param data The raw ban.\r\n * @param relations The user and guild as resolved from the cache, by the guild's ban manager.\r\n */\r\n public constructor(data: GuildBanData, relations: GuildBanRelations = {}) {\r\n super(data, relations);\r\n }\r\n\r\n public get guildId() {\r\n return this[kData].guild_id;\r\n }\r\n\r\n public get user(): User {\r\n return this[kRelations].user ?? new User(this[kData].user);\r\n }\r\n\r\n /**\r\n * The reason of the ban. Only bans fetched from the API have it: the gateway does not send it.\r\n */\r\n public get reason(): string | null {\r\n return this[kData].reason ?? null;\r\n }\r\n\r\n public get guild(): Guild | null {\r\n return this[kRelations].guild ?? null;\r\n }\r\n\r\n /**\r\n * Fetches the ban from the API, which knows its reason.\r\n */\r\n public fetch(): Promise<GuildBan> {\r\n return getGatewayClient().guilds.bans(this.guildId).fetch(this.user.id, { force: true });\r\n }\r\n\r\n /**\r\n * Lifts the ban.\r\n *\r\n * @param reason The reason for the audit log.\r\n */\r\n public async remove(reason?: string): Promise<this> {\r\n await getGatewayClient().guilds.bans(this.guildId).remove(this.user.id, reason);\r\n return this;\r\n }\r\n}\r\n","import { banKey, 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/GuildBan.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 async hydrate(data: CacheEntityTypes[\"bans\"]): Promise<GuildBan> {\n const [user, guild] = await Promise.all([\n this.client.users.resolveData(data.user),\n this.cachedGuild(data.guild_id),\n ]);\n return new GuildBan(data, { user, guild });\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.core.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.core.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 { 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.core.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.core.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.core.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}\nimport type { APIChannel, RESTPostAPIGuildChannelJSONBody } from \"discord-api-types/v10\";\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kRelations, Structure } from \"./Structure.js\";\nimport { User } from \"./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}\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 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 getGatewayClient().guilds.integrations(this.guildId).delete(this.id, reason);\n return this;\n }\n}\n","import { integrationKey, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { Integration } from \"../structures/Integration.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 async hydrate(data: CacheEntityTypes[\"integrations\"]): Promise<Integration> {\n const [user, guild] = await Promise.all([\n data.user ? this.client.users.resolveData(data.user) : null,\n this.cachedGuild(data.guild_id),\n ]);\n return new Integration(data, { user, guild });\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.core.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.core.api.guilds.getIntegrations(this.guildId);\n return integrations.map((integration) => ({ ...integration, guild_id: this.guildId }));\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 { getGatewayClient } from \"../util/container.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kPatch, kRelations, snowflakeTimestamp, Structure } from \"./Structure.js\";\nimport { User } from \"./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 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 getGatewayClient()\n .guilds.scheduledEvents(this.guildId)\n .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 getGatewayClient()\n .guilds.scheduledEvents(this.guildId)\n .fetchSubscribers(this.id, options);\n }\n\n public async delete(reason?: string): Promise<this> {\n await getGatewayClient().guilds.scheduledEvents(this.guildId).delete(this.id, reason);\n return this;\n }\n}\n","import { scheduledEventKey, 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/GuildScheduledEvent.js\";\nimport type { GuildMember } from \"../structures/GuildMember.js\";\nimport type { User } from \"../structures/User.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 async hydrate(\n data: CacheEntityTypes[\"scheduledEvents\"],\n ): Promise<GuildScheduledEvent> {\n const [creator, guild, channel] = await Promise.all([\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 return new GuildScheduledEvent(data, {\n creator: creator ?? null,\n guild,\n channel: channel ?? null,\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.core.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.core.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.core.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.core.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.core.api.guilds.getScheduledEventUsers(\n this.guildId,\n eventId,\n {\n with_member: options.withMember ?? false,\n limit: options.limit,\n before: options.before,\n after: options.after,\n },\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.core.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 type { APISoundboardSound } from \"discord-api-types/v10\";\r\nimport type { SoundboardSoundEditOptions } from \"../managers/GuildSoundboardSoundManager.js\";\r\nimport { cdn } from \"../util/cdn.js\";\r\nimport { getGatewayClient } from \"../util/container.js\";\r\nimport type { Guild } from \"./Guild.js\";\r\nimport { kData, kPatch, kRelations, snowflakeTimestamp, Structure } from \"./Structure.js\";\r\nimport { User } from \"./User.js\";\r\n\r\n/**\r\n * The relations of a {@link SoundboardSound}, resolved from the cache by the guild's soundboard manager.\r\n */\r\nexport interface SoundboardSoundRelations {\r\n user?: User | null;\r\n guild?: Guild | null;\r\n}\r\n\r\n/**\r\n * A soundboard sound: one of Discord's defaults, or a guild's.\r\n */\r\nexport class SoundboardSound extends Structure<APISoundboardSound> {\r\n declare public [kRelations]: SoundboardSoundRelations;\r\n\r\n /**\r\n * @param data The raw sound.\r\n * @param relations The uploader and guild as resolved from the cache, by the guild's soundboard manager.\r\n */\r\n public constructor(data: APISoundboardSound, relations: SoundboardSoundRelations = {}) {\r\n super(data, relations);\r\n }\r\n\r\n public override [kPatch](data: Readonly<Partial<APISoundboardSound>>): this {\r\n if (data.user) this.dropRelations(\"user\");\r\n return super[kPatch](data);\r\n }\r\n\r\n /**\r\n * The ID of the sound. Default sounds have small numeric IDs rather than snowflakes.\r\n */\r\n public get soundId() {\r\n return this[kData].sound_id;\r\n }\r\n\r\n public get name() {\r\n return this[kData].name;\r\n }\r\n\r\n /**\r\n * The volume, from 0 to 1.\r\n */\r\n public get volume() {\r\n return this[kData].volume;\r\n }\r\n\r\n public get emojiId(): string | null {\r\n return this[kData].emoji_id;\r\n }\r\n\r\n public get emojiName(): string | null {\r\n return this[kData].emoji_name;\r\n }\r\n\r\n /**\r\n * The ID of the guild, `null` for a default sound.\r\n */\r\n public get guildId(): string | null {\r\n return this[kData].guild_id ?? null;\r\n }\r\n\r\n /**\r\n * Whether the sound can be played; guild sounds can become unavailable when the guild loses boosts.\r\n */\r\n public get available() {\r\n return this[kData].available;\r\n }\r\n\r\n /**\r\n * The user who uploaded a guild sound, when the payload includes it.\r\n */\r\n public get user(): User | null {\r\n const { user } = this[kData];\r\n return this[kRelations].user ?? (user ? new User(user) : null);\r\n }\r\n\r\n public get guild(): Guild | null {\r\n return this[kRelations].guild ?? null;\r\n }\r\n\r\n /**\r\n * The URL of the sound file.\r\n */\r\n public get url(): string {\r\n return cdn.soundboardSound(this.soundId);\r\n }\r\n\r\n /**\r\n * When a guild sound was created. Default sounds have no snowflake, so theirs is `null`.\r\n */\r\n public get createdTimestamp(): number | null {\r\n return this.guildId ? snowflakeTimestamp(this.soundId) : null;\r\n }\r\n\r\n public edit(options: SoundboardSoundEditOptions): Promise<this> {\r\n return this.withGuild(async (guildId) => {\r\n const sound = await getGatewayClient()\r\n .guilds.soundboardSounds(guildId)\r\n .edit(this.soundId, options);\r\n return this[kPatch](sound.toJSON());\r\n });\r\n }\r\n\r\n public delete(reason?: string): Promise<this> {\r\n return this.withGuild(async (guildId) => {\r\n await getGatewayClient().guilds.soundboardSounds(guildId).delete(this.soundId, reason);\r\n return this;\r\n });\r\n }\r\n\r\n private withGuild(action: (guildId: string) => Promise<this>): Promise<this> {\r\n const { guildId } = this;\r\n if (!guildId) return Promise.reject(new Error(\"Default soundboard sounds cannot be changed\"));\r\n return action(guildId);\r\n }\r\n}\r\n","import { soundboardSoundKey, 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/SoundboardSound.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 async hydrate(\n data: CacheEntityTypes[\"soundboardSounds\"],\n ): Promise<SoundboardSound> {\n const [user, guild] = await Promise.all([\n data.user ? this.client.users.resolveData(data.user) : null,\n this.cachedGuild(data.guild_id),\n ]);\n return new SoundboardSound(data, { user, guild });\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.core.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.core.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.core.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.core.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.core.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 type { APIStageInstance, StageInstancePrivacyLevel } from \"discord-api-types/v10\";\r\nimport type { AnyChannel } from \"../managers/ChannelManager.js\";\r\nimport type { StageInstanceEditOptions } from \"../managers/StageInstanceManager.js\";\r\nimport { getGatewayClient } from \"../util/container.js\";\r\nimport type { Guild } from \"./Guild.js\";\r\nimport type { GuildScheduledEvent } from \"./GuildScheduledEvent.js\";\r\nimport { kData, kPatch, kRelations, snowflakeTimestamp, Structure } from \"./Structure.js\";\r\n\r\n/**\r\n * The relations of a {@link StageInstance}, resolved from the cache by the guild's stage instance manager.\r\n */\r\nexport interface StageInstanceRelations {\r\n guild?: Guild | null;\r\n channel?: AnyChannel | null;\r\n}\r\n\r\n/**\r\n * A live stage: the topic of a stage channel while it is open.\r\n */\r\nexport class StageInstance extends Structure<APIStageInstance> {\r\n declare public [kRelations]: StageInstanceRelations;\r\n\r\n /**\r\n * @param data The raw stage instance.\r\n * @param relations The guild and channel as resolved from the cache, by the guild's stage instance manager.\r\n */\r\n public constructor(data: APIStageInstance, relations: StageInstanceRelations = {}) {\r\n super(data, relations);\r\n }\r\n\r\n public get id() {\r\n return this[kData].id;\r\n }\r\n\r\n public get guildId() {\r\n return this[kData].guild_id;\r\n }\r\n\r\n public get channelId() {\r\n return this[kData].channel_id;\r\n }\r\n\r\n public get topic() {\r\n return this[kData].topic;\r\n }\r\n\r\n public get privacyLevel() {\r\n return this[kData].privacy_level;\r\n }\r\n\r\n public get guildScheduledEventId(): string | null {\r\n return this[kData].guild_scheduled_event_id ?? null;\r\n }\r\n\r\n public get guild(): Guild | null {\r\n return this[kRelations].guild ?? null;\r\n }\r\n\r\n public get channel(): AnyChannel | null {\r\n return this[kRelations].channel ?? null;\r\n }\r\n\r\n public get createdTimestamp() {\r\n return snowflakeTimestamp(this.id);\r\n }\r\n\r\n public get createdAt() {\r\n return new Date(this.createdTimestamp);\r\n }\r\n\r\n /**\r\n * Fetches the scheduled event the stage belongs to, if any.\r\n */\r\n public async fetchGuildScheduledEvent(): Promise<GuildScheduledEvent | null> {\r\n const { guildScheduledEventId } = this;\r\n return guildScheduledEventId\r\n ? getGatewayClient().guilds.scheduledEvents(this.guildId).fetch(guildScheduledEventId)\r\n : null;\r\n }\r\n\r\n /**\r\n * Edits the stage.\r\n *\r\n * @param options The topic and privacy level, and the reason for the audit log.\r\n */\r\n public async edit(options: StageInstanceEditOptions): Promise<this> {\r\n const instance = await getGatewayClient()\r\n .guilds.stageInstances(this.guildId)\r\n .edit(this.channelId, options);\r\n return this[kPatch](instance.toJSON());\r\n }\r\n\r\n public setTopic(topic: string, reason?: string): Promise<this> {\r\n return this.edit({ topic, reason });\r\n }\r\n\r\n public setPrivacyLevel(privacyLevel: StageInstancePrivacyLevel, reason?: string): Promise<this> {\r\n return this.edit({ privacyLevel, reason });\r\n }\r\n\r\n /**\r\n * Ends the stage.\r\n *\r\n * @param reason The reason for the audit log.\r\n */\r\n public async delete(reason?: string): Promise<this> {\r\n await getGatewayClient().guilds.stageInstances(this.guildId).delete(this.channelId, reason);\r\n return this;\r\n }\r\n}\r\n","import { stageInstanceKey, 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/StageInstance.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 async hydrate(data: CacheEntityTypes[\"stageInstances\"]): Promise<StageInstance> {\n const [guild, channel] = await Promise.all([\n this.cachedGuild(data.guild_id),\n this.client.channels.get(data.channel_id),\n ]);\n return new StageInstance(data, { guild, channel: channel ?? null });\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.core.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.core.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.core.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.core.api.stageInstances.get(channelId);\n }\n}\n","import { emojiKey, 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/GuildEmoji.js\";\nimport type { User } from \"../structures/User.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 async hydrate(data: CacheEntityTypes[\"emojis\"]): Promise<GuildEmoji> {\n const [author, guild] = await Promise.all([\n data.user ? this.client.users.resolveData(data.user) : undefined,\n this.cachedGuild(data.guild_id),\n ]);\n return new GuildEmoji(data, { author, guild });\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.core.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.core.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.core.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.core.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.core.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 {\n InviteType,\n type APIApplication,\n type APIExtendedInvite,\n type APIInviteChannel,\n type GatewayInviteCreateDispatchData,\n type InviteTargetType,\n} from \"discord-api-types/v10\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kPatch, kRelations, Structure } from \"./Structure.js\";\nimport { User } from \"./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}\n\n/**\n * The base of every invite: to a guild, to a group direct message, or a friend invite.\n *\n * @typeParam Data The raw invite data this structure wraps.\n */\nexport class BaseInvite<Data extends InviteData = InviteData> extends Structure<Data> {\n declare public [kRelations]: InviteRelations;\n\n protected override optimizeData(data: Partial<Data>): void {\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 super(data, relations);\n }\n\n public override [kPatch](data: Readonly<Partial<Data>>): this {\n if (data.inviter) this.dropRelations(\"inviter\");\n if (data.target_user) this.dropRelations(\"targetUser\");\n return super[kPatch](data);\n }\n\n public get code() {\n return this[kData].code;\n }\n\n /**\n * The URL of the invite.\n */\n public get url(): string {\n return `https://discord.gg/${this.code}`;\n }\n\n public 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, as the partial channel the API returns, if known.\n */\n public get channel(): APIInviteChannel | null {\n return 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 /**\n * What the invite targets in a voice channel: a stream, or an embedded application.\n */\n public get targetType(): InviteTargetType | null {\n return this[kData].target_type ?? 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 get approximateMemberCount(): number | null {\n return this[kData].approximate_member_count ?? null;\n }\n\n public get approximatePresenceCount(): number | null {\n return this[kData].approximate_presence_count ?? null;\n }\n\n /**\n * How many times the invite was used, `null` when the payload omits it.\n */\n public get uses(): number | null {\n return this[kData].uses ?? null;\n }\n\n /**\n * How many times the invite can be used, `0` for unlimited, `null` when the payload omits it.\n */\n public get maxUses(): number | null {\n return this[kData].max_uses ?? null;\n }\n\n /**\n * How long the invite lasts, in seconds, `0` for forever, `null` when the payload omits it.\n */\n public get maxAge(): number | null {\n return this[kData].max_age ?? null;\n }\n\n /**\n * Whether the invite only grants temporary membership, `null` when the payload omits it.\n */\n public get temporary(): boolean | null {\n return this[kData].temporary ?? null;\n }\n\n public 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 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 public toString(): string {\n return this.url;\n }\n\n public valueOf(): string {\n return this.code;\n }\n}\n","import type { APIInviteGuild } from \"discord-api-types/v10\";\r\nimport { AnonymousGuild } from \"./AnonymousGuild.js\";\r\n\r\n/**\r\n * The partial guild carried by a {@link GuildInvite}.\r\n *\r\n * @remarks\r\n * The welcome screen discord.js attaches here comes with the admin phase (see #54).\r\n */\r\nexport class InviteGuild extends AnonymousGuild<APIInviteGuild> {}\r\n","import { getGatewayClient } from \"../util/container.js\";\r\nimport { BaseInvite } from \"./BaseInvite.js\";\r\nimport { InviteGuild } from \"./InviteGuild.js\";\r\nimport type { Guild } from \"./Guild.js\";\r\nimport { kData, kRelations } from \"./Structure.js\";\r\n\r\n/**\r\n * An invite to a guild.\r\n */\r\nexport class GuildInvite extends BaseInvite {\r\n public get guildId(): string | null {\r\n return this[kData].guild?.id ?? this[kData].guild_id ?? null;\r\n }\r\n\r\n /**\r\n * The guild the invite leads to: the cached guild when the invite comes from a manager, like discord.js, else the\r\n * partial guild the API returns with the invite, if any.\r\n */\r\n public get guild(): Guild | InviteGuild | null {\r\n const { guild } = this[kData];\r\n return this[kRelations].guild ?? (guild ? new InviteGuild(guild) : null);\r\n }\r\n\r\n /**\r\n * Whether the bot can delete the invite: it created it, or it has `ManageGuild` (or `ManageChannels`).\r\n */\r\n public async fetchDeletable(): Promise<boolean> {\r\n const client = getGatewayClient();\r\n const { guildId } = this;\r\n if (!guildId) return false;\r\n if (this.inviterId === (client.user?.id ?? client.id)) return true;\r\n\r\n const me = await client.members.fetchMe(guildId);\r\n const permissions = await me.fetchPermissions();\r\n return permissions.any([\"ManageGuild\", \"ManageChannels\"]);\r\n }\r\n\r\n /**\r\n * Deletes the invite.\r\n *\r\n * @param reason The reason for the audit log.\r\n */\r\n public async delete(reason?: string): Promise<this> {\r\n const { guildId } = this;\r\n if (!guildId) throw new Error(`Invite ${this.code} has no known guild`);\r\n await getGatewayClient().guilds.invites(guildId).delete(this.code, reason);\r\n return this;\r\n }\r\n}\r\n","import { inviteKey, 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/BaseInvite.js\";\nimport { GuildInvite } from \"../structures/GuildInvite.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 async hydrate(data: CacheEntityTypes[\"invites\"]): Promise<GuildInvite> {\n const { users } = this.client;\n const [inviter, targetUser, guild] = await Promise.all([\n data.inviter ? users.resolveData(data.inviter) : undefined,\n data.target_user ? users.resolveData(data.target_user) : undefined,\n this.cachedGuild(this.guildId),\n ]);\n return new GuildInvite(data, { inviter, targetUser, guild });\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.core.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.core.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.core.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.core.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.core.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 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/Sticker.js\";\nimport type { User } from \"../structures/User.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 async hydrate(data: CacheEntityTypes[\"stickers\"]): Promise<Sticker> {\n const [user, guild] = await Promise.all([\n data.user ? this.client.users.resolveData(data.user) : undefined,\n this.cachedGuild(data.guild_id),\n ]);\n return new Sticker(data, { user, guild });\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.core.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.core.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.core.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.core.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.core.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 { 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 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/AnonymousGuild.js\";\nimport { Guild, type GuildEditOptions } from \"../structures/Guild.js\";\nimport { GuildPreview } from \"../structures/GuildPreview.js\";\nimport { GuildAuditLogsEntry } from \"../structures/GuildAuditLogsEntry.js\";\nimport { GuildOnboarding } from \"../structures/GuildOnboarding.js\";\nimport type { Integration } from \"../structures/Integration.js\";\nimport { ReactionEmoji, type EmojiIdentifierResolvable } from \"../structures/ReactionEmoji.js\";\nimport { WelcomeScreen } from \"../structures/WelcomeScreen.js\";\nimport type { AutoModerationRule } from \"../structures/AutoModerationRule.js\";\nimport type { User } from \"../structures/User.js\";\nimport { Webhook } from \"../structures/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 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.core.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.core.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.core.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.core.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.core.api.guilds.getOnboarding(guildId);\n return new GuildOnboarding(onboarding, { guild: await this.cachedGuild(guildId) });\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.core.api.guilds.editOnboarding(guildId, body, {\n reason: options.reason,\n });\n return new GuildOnboarding(onboarding, { guild: await this.cachedGuild(guildId) });\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.core.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\n return {\n entries: log.audit_log_entries.map(\n (entry) =>\n new GuildAuditLogsEntry(\n { ...entry, guild_id: guildId },\n { executor: (entry.user_id && usersById.get(entry.user_id)) || null, guild },\n ),\n ),\n users,\n webhooks: log.webhooks.map((webhook) => new Webhook(webhook)),\n autoModerationRules: await Promise.all(\n log.auto_moderation_rules.map((rule) => rules.hydrate(rule)),\n ),\n threads: await Promise.all(\n log.threads.map((thread) => this.client.threads.hydrate(thread as APIThreadChannel)),\n ),\n integrations: log.integrations.map((integration) =>\n integrations.createStructure({ ...integration, guild_id: guildId }),\n ),\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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.api.guilds.get(guildId, { with_counts: true });\n }\n\n private store(guild: APIGuild): Promise<Guild> {\n return this._add(guild);\n }\n\n private async welcomeScreen(\n guildId: string,\n screen: APIGuildWelcomeScreen,\n ): Promise<WelcomeScreen> {\n return new WelcomeScreen(\n { ...screen, guild_id: guildId },\n { guild: await this.cachedGuild(guildId) },\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// 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\";\r\nimport type { Role } from \"../structures/Role.js\";\r\n\r\n/**\r\n * Manages the roles of one {@link GuildMember}, reading them through the client's role manager.\r\n *\r\n * @remarks\r\n * discord.js's synchronous `member.roles.cache`, `highest`, `color`, ... become the `fetch*` methods here: the roles\r\n * are read from the (possibly asynchronous) cache, falling back to the API.\r\n */\r\nexport class GuildMemberRoleManager {\r\n public readonly client: GatewayClient;\r\n public readonly guildId: string;\r\n public readonly userId: string;\r\n\r\n readonly #roleIds: readonly string[];\r\n\r\n /**\r\n * @param client The client.\r\n * @param guildId The ID of the guild.\r\n * @param userId The ID of the member's user.\r\n * @param roleIds The IDs of the member's roles, as known to the member structure.\r\n */\r\n public constructor(\r\n client: GatewayClient,\r\n guildId: string,\r\n userId: string,\r\n roleIds: readonly string[],\r\n ) {\r\n this.client = client;\r\n this.guildId = guildId;\r\n this.userId = userId;\r\n this.#roleIds = roleIds;\r\n }\r\n\r\n /**\r\n * The IDs of the member's roles, `@everyone` excluded.\r\n */\r\n public get ids(): readonly string[] {\r\n return this.#roleIds;\r\n }\r\n\r\n /**\r\n * Fetches the member's roles, `@everyone` included, highest first.\r\n */\r\n public async fetch(): Promise<Role[]> {\r\n const ids = [...this.#roleIds, this.guildId];\r\n const roles = await Promise.all(ids.map((id) => this.client.roles.fetch(this.guildId, id)));\r\n return roles.toSorted((a, b) => b.comparePositionTo(a));\r\n }\r\n\r\n /**\r\n * Fetches the member's highest role, `@everyone` when they have no other.\r\n */\r\n public async fetchHighest(): Promise<Role | null> {\r\n return (await this.fetch())[0] ?? null;\r\n }\r\n\r\n /**\r\n * Fetches the role the member is displayed under in the member list, if any.\r\n */\r\n public async fetchHoist(): Promise<Role | null> {\r\n return (await this.fetch()).find((role) => role.hoist) ?? null;\r\n }\r\n\r\n /**\r\n * Fetches the highest role giving the member a color, if any.\r\n */\r\n public async fetchColor(): Promise<Role | null> {\r\n return (await this.fetch()).find((role) => role.color !== 0) ?? null;\r\n }\r\n\r\n /**\r\n * Fetches the highest role giving the member an icon, if any.\r\n */\r\n public async fetchIcon(): Promise<Role | null> {\r\n return (await this.fetch()).find((role) => role.icon ?? role.unicodeEmoji) ?? null;\r\n }\r\n\r\n /**\r\n * Fetches the server booster role, if the member has it.\r\n */\r\n public async fetchPremiumSubscriberRole(): Promise<Role | null> {\r\n return (await this.fetch()).find((role) => role.tags?.premium_subscriber === null) ?? null;\r\n }\r\n\r\n /**\r\n * Fetches the role Discord manages for the member, when the member is a bot.\r\n */\r\n public async fetchBotRole(): Promise<Role | null> {\r\n return (await this.fetch()).find((role) => role.tags?.bot_id === this.userId) ?? null;\r\n }\r\n\r\n /**\r\n * Adds roles to the member.\r\n *\r\n * @param roles The ID of the role, or several IDs.\r\n * @param reason The reason for the audit log.\r\n */\r\n public async add(roles: string | readonly string[], reason?: string) {\r\n if (typeof roles === \"string\") {\r\n return this.client.members.addRole(this.guildId, this.userId, roles, reason);\r\n }\r\n\r\n return this.set([...new Set([...this.#roleIds, ...roles])], reason);\r\n }\r\n\r\n /**\r\n * Removes roles from the member.\r\n *\r\n * @param roles The ID of the role, or several IDs.\r\n * @param reason The reason for the audit log.\r\n */\r\n public async remove(roles: string | readonly string[], reason?: string) {\r\n if (typeof roles === \"string\") {\r\n return this.client.members.removeRole(this.guildId, this.userId, roles, reason);\r\n }\r\n\r\n const removed = new Set(roles);\r\n return this.set(\r\n this.#roleIds.filter((id) => !removed.has(id)),\r\n reason,\r\n );\r\n }\r\n\r\n /**\r\n * Replaces the member's roles.\r\n *\r\n * @param roles The IDs of the roles the member ends up with.\r\n * @param reason The reason for the audit log.\r\n */\r\n public set(roles: readonly string[], reason?: string) {\r\n return this.client.members.edit(this.guildId, this.userId, { roles, reason });\r\n }\r\n}\r\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 { getGatewayClient } from \"../util/container.js\";\nimport { GuildMemberFlagsBitField, type GuildMemberFlagsResolvable } from \"../util/flags.js\";\nimport type { MessageCreateOptions, MessagePayloadResolvable } from \"../util/messages.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 \"./DMChannel.js\";\nimport type { Message } from \"./Message.js\";\nimport type { Presence } from \"./Presence.js\";\nimport type { VoiceState } from \"./VoiceState.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kPatch, kRelations, Structure } from \"./Structure.js\";\nimport { User } from \"./User.js\";\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]: { user?: User; guild?: Guild | null };\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(\n data: CacheEntityTypes[\"members\"],\n relations: { user?: User; guild?: Guild | null } = {},\n ) {\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 getGatewayClient().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(\n getGatewayClient(),\n this.guildId,\n this.requireId(),\n this.roleIds,\n );\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 = getGatewayClient();\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 * 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 getGatewayClient().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 getGatewayClient().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 = getGatewayClient();\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 getGatewayClient().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 getGatewayClient().members.kick(this.guildId, this.requireId(), reason);\n return this;\n }\n\n public async ban(options?: BanOptions): Promise<this> {\n await getGatewayClient().members.ban(this.guildId, this.requireId(), options);\n return this;\n }\n\n public createDM(): Promise<DMChannel> {\n return getGatewayClient().users.createDM(this.requireId());\n }\n\n public deleteDM(): Promise<DMChannel> {\n return getGatewayClient().users.deleteDM(this.requireId());\n }\n\n public send(options: MessagePayloadResolvable<MessageCreateOptions>): Promise<Message> {\n return getGatewayClient().users.send(this.requireId(), options);\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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 { memberKey, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n type APIGuildMember,\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 } from \"../structures/GuildMember.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 * 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 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 public override async hydrate(data: CacheEntityTypes[\"members\"]): Promise<GuildMember> {\n const [user, guild] = await Promise.all([\n data.user ? this.client.users.resolveData(data.user) : undefined,\n this.cachedGuild(data.guild_id),\n ]);\n return new GuildMember(data, { user, guild });\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.core.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.core.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 * 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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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 // 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/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.core.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.core.api.channels.deleteOwnMessageReaction(\n this.channelId,\n this.messageId,\n this.emoji,\n );\n } else {\n await this.client.core.api.channels.deleteUserMessageReaction(\n this.channelId,\n this.messageId,\n this.emoji,\n userId,\n );\n }\n }\n}\n","import type { APIReaction } from \"discord-api-types/v10\";\r\nimport { ReactionUserManager } from \"../managers/ReactionUserManager.js\";\r\nimport { getGatewayClient } from \"../util/container.js\";\r\nimport { ReactionEmoji } from \"./ReactionEmoji.js\";\r\nimport { kData, kPatch, Structure } from \"./Structure.js\";\r\n\r\n/**\r\n * The raw data of a reaction, with the message it belongs to. The counts are absent when the reaction was built from\r\n * a gateway event on a message the cache did not hold.\r\n */\r\nexport type MessageReactionData = Omit<APIReaction, \"count\" | \"count_details\"> &\r\n Partial<Pick<APIReaction, \"count\" | \"count_details\">> & {\r\n channel_id: string;\r\n message_id: string;\r\n };\r\n\r\n/**\r\n * A reaction on a message: an emoji, how many users reacted with it, and whether the bot did.\r\n */\r\nexport class MessageReaction extends Structure<MessageReactionData> {\r\n public get channelId() {\r\n return this[kData].channel_id;\r\n }\r\n\r\n public get messageId() {\r\n return this[kData].message_id;\r\n }\r\n\r\n public get emoji(): ReactionEmoji {\r\n return new ReactionEmoji(this[kData].emoji);\r\n }\r\n\r\n /**\r\n * How many users reacted, super reactions included; `null` when unknown.\r\n */\r\n public get count(): number | null {\r\n return this[kData].count ?? null;\r\n }\r\n\r\n /**\r\n * How many normal and super (burst) reactions there are; `null` when unknown.\r\n */\r\n public get countDetails(): { normal: number; burst: number } | null {\r\n return this[kData].count_details ?? null;\r\n }\r\n\r\n /**\r\n * Whether the bot reacted with a normal reaction.\r\n */\r\n public get me(): boolean {\r\n return this[kData].me;\r\n }\r\n\r\n /**\r\n * Whether the bot reacted with a super reaction.\r\n */\r\n public get meBurst(): boolean {\r\n return this[kData].me_burst;\r\n }\r\n\r\n /**\r\n * The colors of the super reaction animation, as `#rrggbb` strings.\r\n */\r\n public get burstColors(): readonly string[] {\r\n return this[kData].burst_colors;\r\n }\r\n\r\n /**\r\n * The users who reacted.\r\n */\r\n public get users(): ReactionUserManager {\r\n return new ReactionUserManager(\r\n getGatewayClient(),\r\n this.channelId,\r\n this.messageId,\r\n this.emoji.identifier,\r\n );\r\n }\r\n\r\n /**\r\n * Reacts with this emoji as the bot.\r\n */\r\n public async react(): Promise<this> {\r\n await getGatewayClient().messages.react(this.channelId, this.messageId, this.emoji.identifier);\r\n return this[kPatch]({ me: true });\r\n }\r\n\r\n /**\r\n * Removes every reaction with this emoji.\r\n */\r\n public async remove(): Promise<this> {\r\n await getGatewayClient().messages.removeReactionEmoji(\r\n this.channelId,\r\n this.messageId,\r\n this.emoji.identifier,\r\n );\r\n return this;\r\n }\r\n\r\n /**\r\n * Fetches the message and patches this reaction with its current counts.\r\n */\r\n public async fetch(): Promise<this> {\r\n const message = await getGatewayClient().messages.fetch(this.channelId, this.messageId, {\r\n force: true,\r\n });\r\n const identifier = this.emoji.identifier;\r\n const current = message.reactions.cache.find(\r\n (reaction) => reaction.emoji.identifier === identifier,\r\n );\r\n return current\r\n ? this[kPatch](current.toJSON())\r\n : this[kPatch]({\r\n count: 0,\r\n count_details: { normal: 0, burst: 0 },\r\n me: false,\r\n me_burst: false,\r\n burst_colors: [],\r\n });\r\n }\r\n\r\n public valueOf(): string {\r\n return this.emoji.id ?? this.emoji.name ?? \"\";\r\n }\r\n}\r\n","import type { APIReaction } from \"discord-api-types/v10\";\r\nimport type { GatewayClient } from \"../GatewayClient.js\";\r\nimport { MessageReaction } from \"../structures/MessageReaction.js\";\r\nimport { ReactionEmoji, type EmojiIdentifierResolvable } from \"../structures/ReactionEmoji.js\";\r\n\r\n/**\r\n * Manages the reactions of one message, as they were in the message's payload.\r\n */\r\nexport class ReactionManager {\r\n public readonly client: GatewayClient;\r\n public readonly channelId: string;\r\n public readonly messageId: string;\r\n\r\n readonly #reactions: readonly APIReaction[];\r\n\r\n public constructor(\r\n client: GatewayClient,\r\n channelId: string,\r\n messageId: string,\r\n reactions: readonly APIReaction[],\r\n ) {\r\n this.client = client;\r\n this.channelId = channelId;\r\n this.messageId = messageId;\r\n this.#reactions = reactions;\r\n }\r\n\r\n /**\r\n * The reactions of the message.\r\n */\r\n public get cache(): MessageReaction[] {\r\n return this.#reactions.map(\r\n (reaction) =>\r\n new MessageReaction({\r\n ...reaction,\r\n channel_id: this.channelId,\r\n message_id: this.messageId,\r\n }),\r\n );\r\n }\r\n\r\n /**\r\n * Finds the reaction with an emoji, if the message has it.\r\n *\r\n * @param emoji The emoji.\r\n */\r\n public resolve(emoji: EmojiIdentifierResolvable): MessageReaction | null {\r\n const identifier = ReactionEmoji.resolveIdentifier(emoji);\r\n return this.cache.find((reaction) => reaction.emoji.identifier === identifier) ?? null;\r\n }\r\n\r\n /**\r\n * Removes every reaction of the message.\r\n */\r\n public removeAll(): Promise<void> {\r\n return this.client.messages.removeAllReactions(this.channelId, this.messageId);\r\n }\r\n}\r\n","/**\r\n * Compares two JSON-like values structurally, regardless of key order. `undefined` properties count as missing, like\r\n * they do once serialized.\r\n *\r\n * @param a The first value.\r\n * @param b The second value.\r\n */\r\nexport function isDeepEqual(a: unknown, b: unknown): boolean {\r\n if (Object.is(a, b)) return true;\r\n if (typeof a !== \"object\" || typeof b !== \"object\" || a === null || b === null) return false;\r\n if (Array.isArray(a) !== Array.isArray(b)) return false;\r\n\r\n if (Array.isArray(a)) {\r\n const other = b as unknown[];\r\n return a.length === other.length && a.every((value, index) => isDeepEqual(value, other[index]));\r\n }\r\n\r\n const left = definedEntries(a as Record<string, unknown>);\r\n const right = new Map(definedEntries(b as Record<string, unknown>));\r\n return (\r\n left.length === right.size &&\r\n left.every(([key, value]) => right.has(key) && isDeepEqual(value, right.get(key)))\r\n );\r\n}\r\n\r\nfunction definedEntries(value: Record<string, unknown>): [string, unknown][] {\r\n return Object.entries(value).filter(([, entry]) => entry !== undefined);\r\n}\r\n","import type { APIAttachment } from \"discord-api-types/v10\";\r\nimport { AttachmentFlagsBitField } from \"../util/flags.js\";\r\nimport { kData, snowflakeTimestamp, Structure } from \"./Structure.js\";\r\n\r\n/**\r\n * A file attached to a message.\r\n */\r\nexport class Attachment extends Structure<APIAttachment> {\r\n public get id() {\r\n return this[kData].id;\r\n }\r\n\r\n /**\r\n * The name of the file.\r\n */\r\n public get name() {\r\n return this[kData].filename;\r\n }\r\n\r\n /**\r\n * The title of the file, if any.\r\n */\r\n public get title(): string | null {\r\n return this[kData].title ?? null;\r\n }\r\n\r\n /**\r\n * The description (alt text) of the file, if any.\r\n */\r\n public get description(): string | null {\r\n return this[kData].description ?? null;\r\n }\r\n\r\n /**\r\n * The media type of the file, if known.\r\n */\r\n public get contentType(): string | null {\r\n return this[kData].content_type ?? null;\r\n }\r\n\r\n /**\r\n * The size of the file, in bytes.\r\n */\r\n public get size() {\r\n return this[kData].size;\r\n }\r\n\r\n public get url() {\r\n return this[kData].url;\r\n }\r\n\r\n public get proxyURL() {\r\n return this[kData].proxy_url;\r\n }\r\n\r\n /**\r\n * The height of the file, if it is an image or a video.\r\n */\r\n public get height(): number | null {\r\n return this[kData].height ?? null;\r\n }\r\n\r\n /**\r\n * The width of the file, if it is an image or a video.\r\n */\r\n public get width(): number | null {\r\n return this[kData].width ?? null;\r\n }\r\n\r\n /**\r\n * Whether the attachment is ephemeral: it is deleted shortly after the message is, unless referenced elsewhere.\r\n */\r\n public get ephemeral(): boolean {\r\n return this[kData].ephemeral ?? false;\r\n }\r\n\r\n /**\r\n * The duration of a voice message, in seconds.\r\n */\r\n public get duration(): number | null {\r\n return this[kData].duration_secs ?? null;\r\n }\r\n\r\n /**\r\n * The base64 encoded byte array of a voice message's sampled waveform.\r\n */\r\n public get waveform(): string | null {\r\n return this[kData].waveform ?? null;\r\n }\r\n\r\n public get flags() {\r\n return new AttachmentFlagsBitField(this[kData].flags ?? 0).freeze();\r\n }\r\n\r\n /**\r\n * Whether the attachment is marked as a spoiler.\r\n */\r\n public get spoiler(): boolean {\r\n return this.flags.has(\"IsSpoiler\");\r\n }\r\n\r\n public get createdTimestamp() {\r\n return snowflakeTimestamp(this.id);\r\n }\r\n\r\n public get createdAt() {\r\n return new Date(this.createdTimestamp);\r\n }\r\n}\r\n","import type {\r\n APIEmbed,\r\n APIEmbedAuthor,\r\n APIEmbedField,\r\n APIEmbedFooter,\r\n APIEmbedImage,\r\n APIEmbedProvider,\r\n APIEmbedThumbnail,\r\n APIEmbedVideo,\r\n} from \"discord-api-types/v10\";\r\nimport { isDeepEqual } from \"../util/equal.js\";\r\nimport { kData, Structure } from \"./Structure.js\";\r\n\r\n/**\r\n * An embed of a received message. Use `@discordjs/builders`' `EmbedBuilder` to create embeds.\r\n */\r\nexport class Embed extends Structure<APIEmbed> {\r\n public get title(): string | null {\r\n return this[kData].title ?? null;\r\n }\r\n\r\n public get description(): string | null {\r\n return this[kData].description ?? null;\r\n }\r\n\r\n public get url(): string | null {\r\n return this[kData].url ?? null;\r\n }\r\n\r\n public get color(): number | null {\r\n return this[kData].color ?? null;\r\n }\r\n\r\n /**\r\n * The color as a `#rrggbb` string, `null` when the embed has none.\r\n */\r\n public get hexColor(): `#${string}` | null {\r\n const { color } = this;\r\n return color === null ? null : `#${color.toString(16).padStart(6, \"0\")}`;\r\n }\r\n\r\n /**\r\n * The ISO timestamp shown in the footer, if any.\r\n */\r\n public get timestamp(): string | null {\r\n return this[kData].timestamp ?? null;\r\n }\r\n\r\n public get fields(): readonly APIEmbedField[] {\r\n return this[kData].fields ?? [];\r\n }\r\n\r\n public get thumbnail(): APIEmbedThumbnail | null {\r\n return this[kData].thumbnail ?? null;\r\n }\r\n\r\n public get image(): APIEmbedImage | null {\r\n return this[kData].image ?? null;\r\n }\r\n\r\n public get video(): APIEmbedVideo | null {\r\n return this[kData].video ?? null;\r\n }\r\n\r\n public get author(): APIEmbedAuthor | null {\r\n return this[kData].author ?? null;\r\n }\r\n\r\n public get provider(): APIEmbedProvider | null {\r\n return this[kData].provider ?? null;\r\n }\r\n\r\n public get footer(): APIEmbedFooter | null {\r\n return this[kData].footer ?? null;\r\n }\r\n\r\n /**\r\n * The number of characters counting towards Discord's 6000 characters limit.\r\n */\r\n public get length(): number {\r\n return (\r\n (this.title?.length ?? 0) +\r\n (this.description?.length ?? 0) +\r\n this.fields.reduce((sum, field) => sum + field.name.length + field.value.length, 0) +\r\n (this.footer?.text.length ?? 0) +\r\n (this.author?.name.length ?? 0)\r\n );\r\n }\r\n\r\n /**\r\n * Whether this embed has the same data as another one.\r\n * @param embed The embed, or raw embed data, to compare with.\r\n */\r\n public equals(embed: Embed | APIEmbed): boolean {\r\n return isDeepEqual(this.toJSON(), embed instanceof Embed ? embed.toJSON() : embed);\r\n }\r\n}\r\n","import type { APIChannelMention, APIGuildMember, APIMessage, APIUser } from \"discord-api-types/v10\";\r\nimport { GuildMember } from \"./GuildMember.js\";\r\nimport { User } from \"./User.js\";\r\n\r\n/**\r\n * The raw fields of a message the mentions are read from.\r\n */\r\nexport type MessageMentionsData = Pick<\r\n APIMessage,\r\n \"content\" | \"mention_everyone\" | \"mention_roles\"\r\n> &\r\n Partial<Pick<APIMessage, \"mention_channels\" | \"referenced_message\">> & {\r\n guild_id?: string;\r\n /**\r\n * The mentioned users. In guilds, the gateway attaches each one's partial member.\r\n */\r\n mentions: (APIUser & { member?: Omit<APIGuildMember, \"user\"> })[];\r\n };\r\n\r\n/**\r\n * The options of {@link MessageMentions.has}.\r\n */\r\nexport interface MentionsHasOptions {\r\n /**\r\n * Whether to ignore direct mentions of the user, role, or channel.\r\n */\r\n ignoreDirect?: boolean;\r\n /**\r\n * Whether to ignore mentions of the member's roles.\r\n */\r\n ignoreRoles?: boolean;\r\n /**\r\n * Whether to ignore the author of the replied message.\r\n */\r\n ignoreRepliedUser?: boolean;\r\n /**\r\n * Whether to ignore `@everyone` and `@here`.\r\n */\r\n ignoreEveryone?: boolean;\r\n}\r\n\r\n/**\r\n * The users, roles, and channels a message mentions.\r\n *\r\n * @remarks\r\n * Users and members come with the message payload. Roles and channels are IDs: resolve them with `client.roles` and\r\n * `client.channels`, since discord.js's synchronous cache lookups have no equivalent here.\r\n */\r\nexport class MessageMentions {\r\n /**\r\n * Matches `@everyone` and `@here`.\r\n */\r\n public static readonly EveryonePattern = /@(?<mention>everyone|here)/;\r\n\r\n /**\r\n * Matches user mentions, `<@id>` and the legacy `<@!id>`.\r\n */\r\n public static readonly UsersPattern = /<@!?(?<id>\\d{17,20})>/g;\r\n\r\n /**\r\n * Matches role mentions, `<@&id>`.\r\n */\r\n public static readonly RolesPattern = /<@&(?<id>\\d{17,20})>/g;\r\n\r\n /**\r\n * Matches channel mentions, `<#id>`.\r\n */\r\n public static readonly ChannelsPattern = /<#(?<id>\\d{17,20})>/g;\r\n\r\n readonly #data: MessageMentionsData;\r\n\r\n public constructor(data: MessageMentionsData) {\r\n this.#data = data;\r\n }\r\n\r\n /**\r\n * Whether the message mentions `@everyone` or `@here`.\r\n */\r\n public get everyone(): boolean {\r\n return this.#data.mention_everyone;\r\n }\r\n\r\n public get users(): User[] {\r\n return this.#data.mentions.map((user) => new User(user));\r\n }\r\n\r\n /**\r\n * The mentioned users as members, for messages sent in a guild.\r\n */\r\n public get members(): GuildMember[] {\r\n const guildId = this.#data.guild_id;\r\n if (!guildId) return [];\r\n\r\n return this.#data.mentions.flatMap(({ member, ...user }) =>\r\n member ? [new GuildMember({ ...member, user, guild_id: guildId })] : [],\r\n );\r\n }\r\n\r\n public get roleIds(): readonly string[] {\r\n return this.#data.mention_roles;\r\n }\r\n\r\n /**\r\n * The IDs of the channels mentioned in the content, and of the crossposted channels.\r\n */\r\n public get channelIds(): string[] {\r\n const ids = new Set(this.crosspostedChannels.map((channel) => channel.id));\r\n for (const match of this.#data.content.matchAll(MessageMentions.ChannelsPattern)) {\r\n ids.add(match.groups!.id!);\r\n }\r\n\r\n return [...ids];\r\n }\r\n\r\n /**\r\n * The channels a crossposted message mentions, from other guilds.\r\n */\r\n public get crosspostedChannels(): readonly APIChannelMention[] {\r\n return this.#data.mention_channels ?? [];\r\n }\r\n\r\n /**\r\n * The author of the message this one replies to, if any.\r\n */\r\n public get repliedUser(): User | null {\r\n const author = this.#data.referenced_message?.author;\r\n return author ? new User(author) : null;\r\n }\r\n\r\n /**\r\n * The IDs of the users mentioned in the content, including the ones Discord did not resolve.\r\n */\r\n public get parsedUserIds(): string[] {\r\n return [\r\n ...new Set(\r\n [...this.#data.content.matchAll(MessageMentions.UsersPattern)].map(\r\n (match) => match.groups!.id!,\r\n ),\r\n ),\r\n ];\r\n }\r\n\r\n /**\r\n * Whether the message mentions a user, member, role, or channel.\r\n *\r\n * @param target The ID, or a structure with an `id` (and `roleIds` for members).\r\n * @param options What kinds of mentions to ignore.\r\n */\r\n public has(\r\n target: string | { id: string | null; roleIds?: readonly string[] },\r\n options: MentionsHasOptions = {},\r\n ): boolean {\r\n const id = typeof target === \"string\" ? target : target.id;\r\n if (!id) return false;\r\n\r\n if (!options.ignoreEveryone && this.everyone) return true;\r\n if (!options.ignoreRepliedUser && this.repliedUser?.id === id) return true;\r\n\r\n if (!options.ignoreDirect) {\r\n if (this.#data.mentions.some((user) => user.id === id)) return true;\r\n if (this.roleIds.includes(id)) return true;\r\n if (this.channelIds.includes(id)) return true;\r\n }\r\n\r\n if (!options.ignoreRoles && typeof target !== \"string\" && target.roleIds) {\r\n return target.roleIds.some((roleId) => this.roleIds.includes(roleId));\r\n }\r\n\r\n return false;\r\n }\r\n}\r\n","import type { APIPollAnswer } from \"discord-api-types/v10\";\r\nimport { getGatewayClient } from \"../util/container.js\";\r\nimport { ReactionEmoji } from \"./ReactionEmoji.js\";\r\nimport { kData, Structure } from \"./Structure.js\";\r\nimport type { User } from \"./User.js\";\r\n\r\n/**\r\n * The raw data of a poll answer, with its vote count from the poll's results and the message it belongs to.\r\n */\r\nexport type PollAnswerData = APIPollAnswer & {\r\n channel_id: string;\r\n message_id: string;\r\n /**\r\n * The vote count from the poll's results, absent when Discord did not send them.\r\n */\r\n count?: number;\r\n me_voted?: boolean;\r\n};\r\n\r\n/**\r\n * An answer of a {@link Poll}.\r\n */\r\nexport class PollAnswer extends Structure<PollAnswerData> {\r\n public get id() {\r\n return this[kData].answer_id;\r\n }\r\n\r\n public get channelId() {\r\n return this[kData].channel_id;\r\n }\r\n\r\n public get messageId() {\r\n return this[kData].message_id;\r\n }\r\n\r\n public get text(): string | null {\r\n return this[kData].poll_media.text ?? null;\r\n }\r\n\r\n public get emoji(): ReactionEmoji | null {\r\n const { emoji } = this[kData].poll_media;\r\n return emoji ? new ReactionEmoji(emoji) : null;\r\n }\r\n\r\n /**\r\n * How many users voted for the answer, `0` when the results are unknown.\r\n */\r\n public get voteCount(): number {\r\n return this[kData].count ?? 0;\r\n }\r\n\r\n /**\r\n * Whether the bot voted for the answer.\r\n */\r\n public get meVoted(): boolean {\r\n return this[kData].me_voted ?? false;\r\n }\r\n\r\n /**\r\n * Fetches the users who voted for the answer, paginated by user ID.\r\n *\r\n * @param options How many voters to fetch (up to 100), and after which user ID.\r\n */\r\n public fetchVoters(options: { limit?: number; after?: string } = {}): Promise<User[]> {\r\n return getGatewayClient().messages.fetchPollAnswerVoters(\r\n this.channelId,\r\n this.messageId,\r\n this.id,\r\n options,\r\n );\r\n }\r\n}\r\n","import type { APIPoll } from \"discord-api-types/v10\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport type { Message } from \"./Message.js\";\nimport { PollAnswer } from \"./PollAnswer.js\";\nimport { ReactionEmoji } from \"./ReactionEmoji.js\";\nimport { kData, Structure } 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 poll of a message.\n */\nexport class Poll extends Structure<PollData> {\n protected override optimizeData(data: Partial<PollData>): void {\n this.optimizeTimestamp(\"expiry\", data.expiry);\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 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 return new PollAnswer({\n ...answer,\n channel_id: this.channelId,\n message_id: this.messageId,\n count: count?.count,\n me_voted: count?.me_voted,\n });\n });\n }\n\n public get allowMultiselect() {\n return this[kData].allow_multiselect;\n }\n\n public get layoutType() {\n return this[kData].layout_type;\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 expiresTimestamp(): number | null {\n return this.optimizedTimestamp(\"expiry\");\n }\n\n public get expiresAt(): Date | null {\n const { expiresTimestamp } = this;\n return expiresTimestamp === null ? null : new Date(expiresTimestamp);\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 getGatewayClient().messages.endPoll(this.channelId, this.messageId);\n }\n}\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n ChannelType,\n MessageFlags,\n MessageReferenceType,\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 { getGatewayClient } from \"../util/container.js\";\nimport { isDeepEqual } from \"../util/equal.js\";\nimport { MessageFlagsBitField } from \"../util/flags.js\";\nimport type {\n MessageCreateOptions,\n MessageEditOptions,\n MessagePayloadResolvable,\n} from \"../util/messages.js\";\nimport type { PermissionsString } from \"../util/PermissionsBitField.js\";\nimport { Attachment } from \"./Attachment.js\";\nimport { Embed } from \"./Embed.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { GuildMember } from \"./GuildMember.js\";\nimport { MessageMentions } from \"./MessageMentions.js\";\nimport { Poll } from \"./Poll.js\";\nimport type { EmojiIdentifierResolvable } from \"./ReactionEmoji.js\";\nimport { kData, kPatch, kRelations, snowflakeTimestamp, Structure } from \"./Structure.js\";\nimport { User } from \"./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\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\n/**\n * A Discord message.\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 Structure<CacheEntityTypes[\"messages\"]> {\n declare public [kRelations]: MessageRelations;\n\n protected override optimizeData(data: Partial<CacheEntityTypes[\"messages\"]>): void {\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, relations);\n }\n\n public override [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 return super[kPatch](data);\n }\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 public get guildId(): string | null {\n return this[kData].guild_id ?? null;\n }\n\n public get content() {\n return this[kData].content;\n }\n\n public get type() {\n return this[kData].type;\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 return this[kRelations].author ?? new User(this[kData].author);\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 get webhookId(): string | null {\n return this[kData].webhook_id ?? null;\n }\n\n /**\n * The ID of the application that sent the message, for interaction responses and webhooks of an application.\n */\n public get applicationId(): string | null {\n return this[kData].application_id ?? null;\n }\n\n public get pinned() {\n return this[kData].pinned;\n }\n\n public get tts() {\n return this[kData].tts;\n }\n\n /**\n * The nonce the message was sent with, used to confirm it was sent.\n */\n public get nonce(): string | number | null {\n return this[kData].nonce ?? null;\n }\n\n /**\n * The position of the message in its thread, if it was sent in one.\n */\n public get position(): number | null {\n return this[kData].position ?? null;\n }\n\n public 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 public get mentions(): MessageMentions {\n return new MessageMentions(this[kData]);\n }\n\n public get reactions(): ReactionManager {\n return new ReactionManager(\n getGatewayClient(),\n this.channelId,\n this.id,\n this[kData].reactions ?? [],\n );\n }\n\n public get poll(): Poll | null {\n const { poll } = this[kData];\n return poll ? new Poll({ ...poll, channel_id: this.channelId, message_id: this.id }) : null;\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, when the payload includes it.\n */\n public get thread(): AnyThreadChannel | null {\n const { thread } = this[kData] as APIMessage & { thread?: APIThreadChannel };\n return thread ? getGatewayClient().threads.createStructure(thread) : null;\n }\n\n /**\n * The content with user mentions replaced by names, and `@everyone`/`@here` defused. Role and channel mentions are\n * kept, since resolving them would take the (asynchronous) cache.\n */\n public get cleanContent(): string {\n const members = new Map(\n this.mentions.members.map((member) => [member.id, member.displayName] as const),\n );\n const users = new Map(this.mentions.users.map((user) => [user.id, user.displayName] as const));\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(/@(everyone|here)/g, `@${ZeroWidthSpace}$1`);\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 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 getGatewayClient().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 ? getGatewayClient().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 getGatewayClient().messages.fetch(\n reference.channel_id ?? this.channelId,\n reference.message_id,\n );\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 = getGatewayClient();\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 * Fetches the message from the API and patches this structure with the result.\n */\n public async fetch(): Promise<this> {\n const message = await getGatewayClient().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 getGatewayClient().messages.edit(this.channelId, this.id, options);\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 = typeof options === \"string\" ? { content: options } : options;\n return getGatewayClient().messages.send(this.channelId, {\n ...payload,\n message_reference: {\n type: MessageReferenceType.Default,\n message_id: this.id,\n channel_id: this.channelId,\n fail_if_not_exists: false,\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 getGatewayClient().messages.forward(this.channelId, this.id, channelId);\n }\n\n public async delete(reason?: string): Promise<this> {\n await getGatewayClient().messages.delete(this.channelId, this.id, reason);\n return this;\n }\n\n public async pin(reason?: string): Promise<this> {\n await getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 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 getGatewayClient().members.fetchMe(guildId);\n return (await me.fetchPermissionsIn(this.channelId)).has(permission);\n }\n}\n","import type { RawFile } from \"@discordjs/rest\";\r\nimport type {\r\n RESTPatchAPIChannelMessageJSONBody,\r\n RESTPostAPIChannelMessageJSONBody,\r\n} from \"discord-api-types/v10\";\r\n\r\n/**\r\n * The options to send a message with: the REST body, plus the files to attach.\r\n */\r\nexport type MessageCreateOptions = RESTPostAPIChannelMessageJSONBody & { files?: RawFile[] };\r\n\r\n/**\r\n * The options to edit a message with: the REST body, plus the files to attach.\r\n */\r\nexport type MessageEditOptions = RESTPatchAPIChannelMessageJSONBody & { files?: RawFile[] };\r\n\r\n/**\r\n * Anything accepted where a message payload is expected: a string is the message content.\r\n */\r\nexport type MessagePayloadResolvable<Options extends { files?: RawFile[] }> = Options | string;\r\n\r\n/**\r\n * Splits message options into the REST body and the files, turning a plain string into `{ content }`.\r\n *\r\n * @param options The options, or the content.\r\n */\r\nexport function resolveMessageOptions<Options extends { files?: RawFile[] }>(\r\n options: MessagePayloadResolvable<Options>,\r\n): { body: Omit<Options, \"files\">; files: RawFile[] | undefined } {\r\n if (typeof options === \"string\") {\r\n return { body: { content: options } as unknown as Omit<Options, \"files\">, files: undefined };\r\n }\r\n\r\n const { files, ...body } = options;\r\n return { body, files };\r\n}\r\n","import { messageKey, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n MessageReferenceType,\n Routes,\n type APIMessage,\n type RESTGetAPIChannelMessagesPinsResult,\n type RESTPostAPIChannelMessagesThreadsJSONBody,\n type ThreadAutoArchiveDuration,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { Message } from \"../structures/Message.js\";\nimport { ReactionEmoji, type EmojiIdentifierResolvable } from \"../structures/ReactionEmoji.js\";\nimport { type User } from \"../structures/User.js\";\nimport {\n resolveMessageOptions,\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 async hydrate(data: CacheEntityTypes[\"messages\"]): Promise<Message> {\n const { author, member, guild_id: guildId } = data;\n const [resolvedAuthor, resolvedMember, guild, channel] = await Promise.all([\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 ]);\n return new Message(data, {\n author: resolvedAuthor,\n member: resolvedMember,\n guild,\n channel: channel ?? null,\n });\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.core.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 } = resolveMessageOptions(options);\n const message = await this.client.core.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 message_reference: {\n type: MessageReferenceType.Forward,\n channel_id: channelId,\n message_id: messageId,\n },\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 } = resolveMessageOptions(options);\n const message = await this.client.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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 { getGatewayClient } from \"../util/container.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 getGatewayClient().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 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 = getGatewayClient();\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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 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/Role.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 async hydrate(data: CacheEntityTypes[\"roles\"]): Promise<Role> {\n return new Role(data, { guild: await this.cachedGuild(data.guild_id) });\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.core.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.core.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.core.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.core.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.core.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.core.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.core.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 type { RawFile } from \"@discordjs/rest\";\nimport {\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/Message.js\";\nimport { Webhook } from \"../structures/Webhook.js\";\nimport { resolveId, type IdResolvable } from \"../util/channels.js\";\nimport { resolveMessageOptions, type MessagePayloadResolvable } from \"../util/messages.js\";\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 * The options to send a message through a webhook with: the REST body, plus the files to attach.\n */\nexport type WebhookMessageCreateOptions = RESTPostAPIWebhookWithTokenJSONBody & {\n files?: RawFile[];\n};\n\n/**\n * The options to edit a message sent by a webhook with: the REST body, plus the files to attach.\n */\nexport type WebhookMessageEditOptions = RESTPatchAPIWebhookWithTokenMessageJSONBody & {\n files?: RawFile[];\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 * 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, like discord.js's\n * `WebhookClient`: they work for 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.core.api.webhooks.get(webhookId, { token });\n return new Webhook(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.core.api.channels.getWebhooks(channelId);\n return webhooks.map((webhook) => new Webhook(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.core.api.guilds.getWebhooks(guildId);\n return webhooks.map((webhook) => new Webhook(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.core.api.channels.createWebhook(channelId, body, {\n reason: options.reason,\n });\n return new Webhook(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.core.api.webhooks.edit(webhookId, body, {\n token,\n reason: options.reason,\n });\n return new Webhook(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.core.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> & WebhookThreadOptions,\n ): Promise<Message> {\n const { threadId, ...payload } =\n typeof options === \"string\" ? { content: options, threadId: undefined } : options;\n const { body, files } = resolveMessageOptions<WebhookMessageCreateOptions>(payload);\n const message = await this.client.core.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.core.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> & WebhookThreadOptions,\n ): Promise<Message> {\n const { threadId, ...payload } =\n typeof options === \"string\" ? { content: options, threadId: undefined } : options;\n const { body, files } = resolveMessageOptions<WebhookMessageEditOptions>(payload);\n const message = await this.client.core.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.core.api.webhooks.deleteMessage(webhookId, token, messageId, {\n thread_id: options.threadId,\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 { getGatewayClient } from \"../util/container.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kPatch, kRelations, Structure } from \"./Structure.js\";\nimport { User } from \"./User.js\";\n\n/**\n * The relations of a {@link GuildTemplate}: its source guild, when cached.\n */\nexport interface GuildTemplateRelations {\n guild?: Guild | null;\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 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 public get creator(): User {\n return 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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().templates.sync(this.guildId, this.code);\n return this[kPatch](template.toJSON());\n }\n\n public async delete(): Promise<this> {\n await getGatewayClient().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/Guild.js\";\nimport { GuildTemplate } from \"../structures/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.core.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.core.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.core.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.core.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.core.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.core.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.core.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 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 });\n }\n}\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { AnyChannel } from \"../managers/ChannelManager.js\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport type { Guild } from \"./Guild.js\";\nimport type { GuildMember } from \"./GuildMember.js\";\nimport { kData, kPatch, kRelations, Structure } from \"./Structure.js\";\nimport type { User } from \"./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}\n\n/**\n * The voice state of a guild member.\n */\nexport class VoiceState extends Structure<CacheEntityTypes[\"voiceStates\"]> {\n declare public [kRelations]: VoiceStateRelations;\n\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, relations);\n }\n\n public override [kPatch](data: Readonly<Partial<CacheEntityTypes[\"voiceStates\"]>>): this {\n if (data.member) this.dropRelations(\"member\");\n return super[kPatch](data);\n }\n\n /**\n * The ID of the guild this voice state is in, or `null` if the payload did not include it.\n */\n public get guildId(): string | null {\n return this[kData].guild_id ?? null;\n }\n\n /**\n * The ID of the voice or stage channel the member is connected to, or `null` if they are disconnected.\n */\n public get channelId(): string | null {\n return this[kData].channel_id;\n }\n\n /**\n * The ID of the user this voice state belongs to.\n */\n public get userId() {\n return this[kData].user_id;\n }\n\n /**\n * The ID of the member's voice session.\n */\n public get sessionId() {\n return this[kData].session_id;\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 deafened themselves.\n */\n public get selfDeaf() {\n return this[kData].self_deaf;\n }\n\n /**\n * Whether the member muted themselves.\n */\n public get selfMute() {\n return this[kData].self_mute;\n }\n\n /**\n * Whether the member's camera is enabled.\n */\n public get selfVideo() {\n return this[kData].self_video;\n }\n\n /**\n * Whether the member is streaming using \"Screen Share\".\n */\n public get streaming() {\n return this[kData].self_stream ?? false;\n }\n\n /**\n * Whether the member is suppressed from speaking. Only meaningful in stage channels.\n */\n public get suppress() {\n return this[kData].suppress;\n }\n\n /**\n * The timestamp at which the member requested to speak, or `null` if they did not. Only meaningful in stage\n * channels.\n */\n public get requestToSpeakTimestamp(): number | null {\n return this.optimizedTimestamp(\"request_to_speak_timestamp\");\n }\n\n /**\n * The time at which the member requested to speak, or `null` if they did not.\n */\n public get requestToSpeakAt(): Date | null {\n const { requestToSpeakTimestamp } = this;\n return requestToSpeakTimestamp === null ? null : new Date(requestToSpeakTimestamp);\n }\n\n /**\n * Whether the member is deafened, either by themselves or server-wide.\n */\n public 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 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 public fetchMember(): Promise<GuildMember> {\n return getGatewayClient().members.fetch(this.requireGuildId(), this.userId);\n }\n\n public fetchUser(): Promise<User> {\n return getGatewayClient().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 ? getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().core.api.voice.editVoiceState(this.requireGuildId(), body);\n } else {\n await getGatewayClient().core.api.voice.editUserVoiceState(\n this.requireGuildId(),\n target,\n body,\n );\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 = getGatewayClient();\n return (client.user?.id ?? client.id) === this.userId ? \"@me\" : this.userId;\n }\n}\n","import { voiceStateKey, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { VoiceState } from \"../structures/VoiceState.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 async hydrate(data: CacheEntityTypes[\"voiceStates\"]): Promise<VoiceState> {\n const { member, guild_id: guildId, user_id: userId } = data;\n const [resolvedMember, guild] = await Promise.all([\n member?.user && guildId\n ? this.client.members.resolveData({ ...member, guild_id: guildId })\n : guildId\n ? this.client.members.get(guildId, userId).then((cached) => cached ?? null)\n : null,\n this.cachedGuild(guildId),\n ]);\n return new VoiceState(data, { member: resolvedMember, guild });\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.core.api.voice.getVoiceState(guildId)\n : await client.core.api.voice.getUserVoiceState(guildId, target);\n return { ...state, guild_id: guildId };\n }\n}\n","import type { ImageURLOptions } from \"@discordjs/rest\";\r\nimport type { GatewayActivityAssets } from \"discord-api-types/v10\";\r\nimport { cdn } from \"../util/cdn.js\";\r\nimport { kData, Structure } from \"./Structure.js\";\r\n\r\n/**\r\n * The raw assets of an activity, with the ID of the activity's application.\r\n */\r\nexport type RichPresenceAssetsData = GatewayActivityAssets & { application_id?: string | null };\r\n\r\n/**\r\n * The assets (images and their hover texts) of a rich presence activity.\r\n */\r\nexport class RichPresenceAssets extends Structure<RichPresenceAssetsData> {\r\n /**\r\n * The ID of the application the assets belong to, needed to build the URLs of application assets.\r\n */\r\n public get applicationId(): string | null {\r\n return this[kData].application_id ?? null;\r\n }\r\n\r\n /**\r\n * The hover text of the large image.\r\n */\r\n public get largeText(): string | null {\r\n return this[kData].large_text ?? null;\r\n }\r\n\r\n /**\r\n * The hover text of the small image.\r\n */\r\n public get smallText(): string | null {\r\n return this[kData].small_text ?? null;\r\n }\r\n\r\n /**\r\n * The ID of the large image asset, or an external asset in the `platform:id` form.\r\n */\r\n public get largeImage(): string | null {\r\n return this[kData].large_image ?? null;\r\n }\r\n\r\n /**\r\n * The ID of the small image asset, or an external asset in the `platform:id` form.\r\n */\r\n public get smallImage(): string | null {\r\n return this[kData].small_image ?? null;\r\n }\r\n\r\n /**\r\n * Gets the URL of the small image, or `null` if there is none or it comes from an unsupported platform.\r\n *\r\n * @param options The image options, ignored for external assets.\r\n */\r\n public smallImageURL(options?: ImageURLOptions): string | null {\r\n const { smallImage } = this;\r\n if (!smallImage) return null;\r\n if (smallImage.includes(\":\")) {\r\n const [platform, id] = smallImage.split(\":\") as [string, string];\r\n switch (platform) {\r\n case \"mp\":\r\n return `https://media.discordapp.net/${id}`;\r\n default:\r\n return null;\r\n }\r\n }\r\n\r\n return this.applicationId ? cdn.appAsset(this.applicationId, smallImage, options) : null;\r\n }\r\n\r\n /**\r\n * Gets the URL of the large image, or `null` if there is none or it comes from an unsupported platform.\r\n *\r\n * @param options The image options, ignored for external assets.\r\n */\r\n public largeImageURL(options?: ImageURLOptions): string | null {\r\n const { largeImage } = this;\r\n if (!largeImage) return null;\r\n if (largeImage.includes(\":\")) {\r\n const [platform, id] = largeImage.split(\":\") as [string, string];\r\n switch (platform) {\r\n case \"mp\":\r\n return `https://media.discordapp.net/${id}`;\r\n case \"spotify\":\r\n return `https://i.scdn.co/image/${id}`;\r\n case \"youtube\":\r\n return `https://i.ytimg.com/vi/${id}/hqdefault_live.jpg`;\r\n case \"twitch\":\r\n return `https://static-cdn.jtvnw.net/previews-ttv/live_user_${id}.png`;\r\n default:\r\n return null;\r\n }\r\n }\r\n\r\n return this.applicationId ? cdn.appAsset(this.applicationId, largeImage, options) : null;\r\n }\r\n}\r\n","import type { ActivityType, GatewayActivity } from \"discord-api-types/v10\";\r\nimport { ActivityFlagsBitField } from \"../util/flags.js\";\r\nimport { RichPresenceAssets } from \"./RichPresenceAssets.js\";\r\nimport { kData, Structure } from \"./Structure.js\";\r\n\r\n/**\r\n * The start and end of an activity.\r\n */\r\nexport interface ActivityTimestamps {\r\n /**\r\n * When the activity started, if known.\r\n */\r\n start: Date | null;\r\n /**\r\n * When the activity ends, if known.\r\n */\r\n end: Date | null;\r\n}\r\n\r\n/**\r\n * The party of an activity.\r\n */\r\nexport interface ActivityParty {\r\n /**\r\n * The ID of the party.\r\n */\r\n id: string | null;\r\n /**\r\n * The size of the party, as `[current, max]`.\r\n */\r\n size: readonly [current: number, max: number] | null;\r\n}\r\n\r\n/**\r\n * The emoji of a custom status activity.\r\n */\r\nexport interface ActivityEmoji {\r\n /**\r\n * The ID of the emoji, or `null` for a unicode emoji.\r\n */\r\n id: string | null;\r\n /**\r\n * The name of the emoji, or the unicode character.\r\n */\r\n name: string | null;\r\n /**\r\n * Whether the emoji is animated.\r\n */\r\n animated: boolean;\r\n}\r\n\r\n/**\r\n * An activity of a user's presence.\r\n */\r\nexport class Activity extends Structure<GatewayActivity> {\r\n /**\r\n * The name of the activity.\r\n */\r\n public get name() {\r\n return this[kData].name;\r\n }\r\n\r\n /**\r\n * The type of the activity.\r\n */\r\n public get type(): ActivityType {\r\n return this[kData].type;\r\n }\r\n\r\n /**\r\n * The URL of the stream, when the activity is being streamed.\r\n */\r\n public get url(): string | null {\r\n return this[kData].url ?? null;\r\n }\r\n\r\n /**\r\n * What the user is currently doing.\r\n */\r\n public get details(): string | null {\r\n return this[kData].details ?? null;\r\n }\r\n\r\n /**\r\n * The user's current party status, or the text of a custom status.\r\n */\r\n public get state(): string | null {\r\n return this[kData].state ?? null;\r\n }\r\n\r\n /**\r\n * The ID of the application the activity belongs to.\r\n */\r\n public get applicationId(): string | null {\r\n return this[kData].application_id ?? null;\r\n }\r\n\r\n /**\r\n * When the activity started and ends, if known.\r\n */\r\n public get timestamps(): ActivityTimestamps | null {\r\n const { timestamps } = this[kData];\r\n if (!timestamps) return null;\r\n return {\r\n start: timestamps.start ? new Date(Number(timestamps.start)) : null,\r\n end: timestamps.end ? new Date(Number(timestamps.end)) : null,\r\n };\r\n }\r\n\r\n /**\r\n * The party of the activity.\r\n */\r\n public get party(): ActivityParty | null {\r\n const { party } = this[kData];\r\n if (!party) return null;\r\n return { id: party.id ?? null, size: party.size ?? null };\r\n }\r\n\r\n /**\r\n * The sync ID of the activity, which is the track ID for Spotify activities.\r\n *\r\n * @remarks This field is not documented by Discord.\r\n */\r\n public get syncId(): string | null {\r\n return this[kData].sync_id ?? null;\r\n }\r\n\r\n /**\r\n * The assets of the activity, when it is a rich presence.\r\n */\r\n public get assets(): RichPresenceAssets | null {\r\n const { assets } = this[kData];\r\n return assets\r\n ? new RichPresenceAssets({ ...assets, application_id: this.applicationId })\r\n : null;\r\n }\r\n\r\n /**\r\n * The flags describing the activity.\r\n */\r\n public get flags(): Readonly<ActivityFlagsBitField> {\r\n return new ActivityFlagsBitField(this[kData].flags ?? 0).freeze();\r\n }\r\n\r\n /**\r\n * The emoji of a custom status activity.\r\n */\r\n public get emoji(): ActivityEmoji | null {\r\n const { emoji } = this[kData];\r\n if (!emoji) return null;\r\n return { id: emoji.id ?? null, name: emoji.name, animated: emoji.animated ?? false };\r\n }\r\n\r\n /**\r\n * The labels of the buttons of a rich presence activity.\r\n */\r\n public get buttons(): string[] {\r\n return (this[kData].buttons ?? []).map((button) =>\r\n typeof button === \"string\" ? button : button.label,\r\n );\r\n }\r\n\r\n /**\r\n * The timestamp at which the activity was added to the user's session.\r\n */\r\n public get createdTimestamp(): number {\r\n return this[kData].created_at;\r\n }\r\n\r\n /**\r\n * The time at which the activity was added to the user's session.\r\n */\r\n public get createdAt(): Date {\r\n return new Date(this.createdTimestamp);\r\n }\r\n\r\n /**\r\n * Whether this activity equals another: same name, type, URL, state, details and emoji.\r\n *\r\n * @param activity The activity to compare with.\r\n */\r\n public equals(activity: Activity | null | undefined): boolean {\r\n if (this === activity) return true;\r\n if (!activity) return false;\r\n return (\r\n this.name === activity.name &&\r\n this.type === activity.type &&\r\n this.url === activity.url &&\r\n this.state === activity.state &&\r\n this.details === activity.details &&\r\n this.emoji?.id === activity.emoji?.id &&\r\n this.emoji?.name === activity.emoji?.name\r\n );\r\n }\r\n\r\n public toString(): string {\r\n return this.name;\r\n }\r\n}\r\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\r\nimport {\r\n PresenceUpdateStatus,\r\n type GatewayPresenceClientStatus,\r\n type PresenceUpdateReceiveStatus,\r\n} from \"discord-api-types/v10\";\r\nimport { getGatewayClient } from \"../util/container.js\";\r\nimport { Activity } from \"./Activity.js\";\r\nimport type { Guild } from \"./Guild.js\";\r\nimport type { GuildMember } from \"./GuildMember.js\";\r\nimport { kData, kRelations, Structure } from \"./Structure.js\";\r\nimport type { User } from \"./User.js\";\r\n\r\n/**\r\n * The status of a presence on each of the user's platforms; a missing platform means the user is offline there.\r\n */\r\nexport type ClientStatus = GatewayPresenceClientStatus;\r\n\r\n/**\r\n * The relations of a {@link Presence}, resolved from the cache by `client.presences`.\r\n */\r\nexport interface PresenceRelations {\r\n user?: User | null;\r\n member?: GuildMember | null;\r\n guild?: Guild | null;\r\n}\r\n\r\n/**\r\n * The presence of a user in a guild: their status and activities.\r\n */\r\nexport class Presence extends Structure<CacheEntityTypes[\"presences\"]> {\r\n declare public [kRelations]: PresenceRelations;\r\n\r\n /**\r\n * @param data The raw presence.\r\n * @param relations The user, member, and guild as resolved from the cache, by `client.presences`.\r\n */\r\n public constructor(data: CacheEntityTypes[\"presences\"], relations: PresenceRelations = {}) {\r\n super(data, relations);\r\n }\r\n\r\n public get userId() {\r\n return this[kData].user.id;\r\n }\r\n\r\n public get guildId() {\r\n return this[kData].guild_id;\r\n }\r\n\r\n /**\r\n * The status of the user, `offline` when the payload did not include it.\r\n */\r\n public get status(): PresenceUpdateReceiveStatus {\r\n return this[kData].status ?? PresenceUpdateStatus.Offline;\r\n }\r\n\r\n public get activities(): Activity[] {\r\n return (this[kData].activities ?? []).map((activity) => new Activity(activity));\r\n }\r\n\r\n /**\r\n * The status of the user on each of their platforms, `null` when the payload did not include it.\r\n */\r\n public get clientStatus(): ClientStatus | null {\r\n return this[kData].client_status ?? null;\r\n }\r\n\r\n /**\r\n * The user, from the cache. Presence payloads only carry the user's changed fields.\r\n */\r\n public get user(): User | null {\r\n return this[kRelations].user ?? null;\r\n }\r\n\r\n public get member(): GuildMember | null {\r\n return this[kRelations].member ?? null;\r\n }\r\n\r\n public get guild(): Guild | null {\r\n return this[kRelations].guild ?? null;\r\n }\r\n\r\n public fetchMember(): Promise<GuildMember> {\r\n return getGatewayClient().members.fetch(this.guildId, this.userId);\r\n }\r\n\r\n public fetchUser(): Promise<User> {\r\n return getGatewayClient().users.fetch(this.userId);\r\n }\r\n\r\n /**\r\n * Whether this presence has the same status, client status, and activities as another.\r\n *\r\n * @param presence The presence to compare with.\r\n */\r\n public equals(presence: Presence | null | undefined): boolean {\r\n if (this === presence) return true;\r\n if (!presence) return false;\r\n\r\n const activities = this.activities;\r\n const otherActivities = presence.activities;\r\n return (\r\n this.status === presence.status &&\r\n this.clientStatus?.web === presence.clientStatus?.web &&\r\n this.clientStatus?.mobile === presence.clientStatus?.mobile &&\r\n this.clientStatus?.desktop === presence.clientStatus?.desktop &&\r\n activities.length === otherActivities.length &&\r\n activities.every((activity, index) => activity.equals(otherActivities[index]))\r\n );\r\n }\r\n}\r\n","import { presenceKey, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\r\nimport type { GatewayClient } from \"../GatewayClient.js\";\r\nimport { Presence } from \"../structures/Presence.js\";\r\nimport { CachedManager } from \"./CachedManager.js\";\r\n\r\n/**\r\n * Manages the presences of guild members.\r\n *\r\n * @remarks\r\n * Presences only come from the gateway, with the `GuildPresences` intent: there is no API to fetch them, so `fetch`\r\n * rejects on a cache miss. Use `get`, which resolves to `undefined` instead.\r\n */\r\nexport class PresenceManager extends CachedManager<\r\n \"presences\",\r\n Presence,\r\n [guildId: string, userId: string]\r\n> {\r\n public constructor(client: GatewayClient) {\r\n super(client, \"presences\");\r\n }\r\n\r\n public createStructure(data: CacheEntityTypes[\"presences\"]): Presence {\r\n return new Presence(data);\r\n }\r\n\r\n public keyOf(data: CacheEntityTypes[\"presences\"]): string {\r\n return this.resolveKey(data.guild_id, data.user.id);\r\n }\r\n\r\n public resolveKey(guildId: string, userId: string): string {\r\n return presenceKey(guildId, userId);\r\n }\r\n\r\n public override async hydrate(data: CacheEntityTypes[\"presences\"]): Promise<Presence> {\r\n const [user, member, guild] = await Promise.all([\r\n this.client.users.get(data.user.id),\r\n this.client.members.get(data.guild_id, data.user.id),\r\n this.cachedGuild(data.guild_id),\r\n ]);\r\n return new Presence(data, { user: user ?? null, member: member ?? null, guild });\r\n }\r\n\r\n /**\r\n * Lists the cached presences of a guild.\r\n *\r\n * @param guildId The ID of the guild.\r\n */\r\n public async listCached(guildId: string): Promise<Presence[]> {\r\n const prefix = `${guildId}:`;\r\n const entries = (await this.cache?.entries()) ?? [];\r\n return Promise.all(\r\n entries.filter(([key]) => key.startsWith(prefix)).map(([, raw]) => this.hydrate(raw)),\r\n );\r\n }\r\n\r\n protected fetchRaw(guildId: string, userId: string): Promise<CacheEntityTypes[\"presences\"]> {\r\n return Promise.reject(\r\n new Error(\r\n `Presences cannot be fetched from the API (user ${userId} of guild ${guildId} is not cached)`,\r\n ),\r\n );\r\n }\r\n}\r\n","import type { 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/AnnouncementThreadChannel.js\";\nimport type { PrivateThreadChannel } from \"../structures/PrivateThreadChannel.js\";\nimport type { PublicThreadChannel } from \"../structures/PublicThreadChannel.js\";\nimport type { ThreadMember } from \"../structures/ThreadMember.js\";\nimport {\n resolveMessageOptions,\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 async hydrate(data: CacheEntityTypes[\"threads\"]): Promise<AnyThreadChannel> {\n return createChannel(data, {\n guild: await this.cachedGuild(data.guild_id),\n }) as AnyThreadChannel;\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 = resolveMessageOptions(options.message);\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.core.api.channels.createThread(\n channelId,\n body as RESTPostAPIChannelThreadsJSONBody,\n undefined,\n { reason: options.reason },\n )\n : await this.client.core.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.core.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.core.api.channels.getJoinedPrivateArchivedThreads(channelId, query)\n : await this.client.core.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.core.api.channels.get(threadId) as Promise<APIThreadChannel>;\n }\n}\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport type { GuildMember } from \"./GuildMember.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}\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 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 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 * 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 getGatewayClient().threadMembers.remove(threadId, id);\n return this;\n }\n}\n","import { threadMemberKey, 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/ThreadMember.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 async hydrate(data: CacheEntityTypes[\"threadMembers\"]): Promise<ThreadMember> {\n const { member, guild_id: guildId, user_id: userId } = data;\n let guildMember = null;\n if (member?.user && guildId) {\n guildMember = await this.client.members.resolveData({ ...member, guild_id: guildId });\n } else if (guildId && userId) {\n guildMember = (await this.client.members.get(guildId, userId)) ?? null;\n }\n\n return new ThreadMember(data, { guildMember });\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.core.api.rest.get(Routes.threadMembers(threadId, userId), {\n query: new URLSearchParams({ with_member: \"true\" }),\n })) as APIThreadMember)\n : await this.client.core.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.core.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.core.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.core.api.threads.join(threadId);\n else await this.client.core.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.core.api.threads.leave(threadId);\n else await this.client.core.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.core.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/DMChannel.js\";\nimport type { Message } from \"../structures/Message.js\";\nimport { User } from \"../structures/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.core.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.core.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.core.api.users.get(userId);\n }\n}\n","import { InviteType } from \"discord-api-types/v10\";\r\nimport { BaseInvite, type InviteData } from \"./BaseInvite.js\";\r\nimport { GuildInvite } from \"./GuildInvite.js\";\r\n\r\n/**\r\n * An invite to a group direct message. Its channel (name, icon, recipients) is exposed as `channel`.\r\n */\r\nexport class GroupDMInvite extends BaseInvite {}\r\n\r\n/**\r\n * Builds the invite structure matching the type of a raw invite.\r\n *\r\n * @param data The raw invite.\r\n */\r\nexport function createInvite(data: InviteData): BaseInvite {\r\n switch (data.type ?? (data.guild_id || data.guild ? InviteType.Guild : InviteType.Friend)) {\r\n case InviteType.Guild:\r\n return new GuildInvite(data);\r\n case InviteType.GroupDM:\r\n return new GroupDMInvite(data);\r\n default:\r\n return new BaseInvite(data);\r\n }\r\n}\r\n","import {\r\n GuildWidgetStyle,\r\n RouteBases,\r\n Routes,\r\n type APIGuildWidget,\r\n type APIGuildWidgetMember,\r\n} from \"discord-api-types/v10\";\r\nimport { getGatewayClient } from \"../util/container.js\";\r\nimport { kData, Structure } from \"./Structure.js\";\r\n\r\n/**\r\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.\r\n */\r\nexport class WidgetMember extends Structure<APIGuildWidgetMember> {\r\n public get id() {\r\n return this[kData].id;\r\n }\r\n\r\n public get username() {\r\n return this[kData].username;\r\n }\r\n\r\n public get discriminator() {\r\n return this[kData].discriminator;\r\n }\r\n\r\n public get avatar() {\r\n return this[kData].avatar;\r\n }\r\n\r\n public get avatarURL() {\r\n return this[kData].avatar_url;\r\n }\r\n\r\n public get status() {\r\n return this[kData].status;\r\n }\r\n\r\n /**\r\n * The name of what the member is playing, if anything.\r\n */\r\n public get activity(): string | null {\r\n return this[kData].activity?.name ?? null;\r\n }\r\n}\r\n\r\n/**\r\n * The public widget of a guild: its online members and voice channels.\r\n */\r\nexport class Widget extends Structure<APIGuildWidget> {\r\n public get id() {\r\n return this[kData].id;\r\n }\r\n\r\n public get name() {\r\n return this[kData].name;\r\n }\r\n\r\n /**\r\n * The invite of the widget's channel, if it has one.\r\n */\r\n public get instantInvite() {\r\n return this[kData].instant_invite;\r\n }\r\n\r\n /**\r\n * The voice channels everyone can join.\r\n */\r\n public get channels() {\r\n return this[kData].channels;\r\n }\r\n\r\n /**\r\n * The online members, up to 100.\r\n */\r\n public get members(): WidgetMember[] {\r\n return this[kData].members.map((member) => new WidgetMember(member));\r\n }\r\n\r\n public get presenceCount() {\r\n return this[kData].presence_count;\r\n }\r\n\r\n /**\r\n * Gets the URL of the widget's image.\r\n *\r\n * @param style The style of the image.\r\n */\r\n public imageURL(style: GuildWidgetStyle = GuildWidgetStyle.Shield): string {\r\n return `${RouteBases.api}${Routes.guildWidgetImage(this.id)}?style=${style}`;\r\n }\r\n\r\n /**\r\n * Fetches the current state of the widget.\r\n */\r\n public fetch(): Promise<Widget> {\r\n return getGatewayClient().fetchGuildWidget(this.id);\r\n }\r\n}\r\n","import type { BaseImageURLOptions } from \"@discordjs/rest\";\r\nimport type { APIStickerPack } from \"discord-api-types/v10\";\r\nimport { cdn } from \"../util/cdn.js\";\r\nimport { Sticker } from \"./Sticker.js\";\r\nimport { kData, snowflakeTimestamp, Structure } from \"./Structure.js\";\r\n\r\n/**\r\n * A pack of standard stickers.\r\n */\r\nexport class StickerPack extends Structure<APIStickerPack> {\r\n public get id() {\r\n return this[kData].id;\r\n }\r\n\r\n public get name() {\r\n return this[kData].name;\r\n }\r\n\r\n public get description() {\r\n return this[kData].description;\r\n }\r\n\r\n /**\r\n * The ID of the pack's SKU.\r\n */\r\n public get skuId() {\r\n return this[kData].sku_id;\r\n }\r\n\r\n public get coverStickerId(): string | null {\r\n return this[kData].cover_sticker_id ?? null;\r\n }\r\n\r\n public get bannerId(): string | null {\r\n return this[kData].banner_asset_id ?? null;\r\n }\r\n\r\n public get stickers(): Sticker[] {\r\n return this[kData].stickers.map((sticker) => new Sticker(sticker));\r\n }\r\n\r\n /**\r\n * The sticker shown as the pack's cover, if any.\r\n */\r\n public get coverSticker(): Sticker | null {\r\n const { coverStickerId } = this;\r\n return this.stickers.find((sticker) => sticker.id === coverStickerId) ?? null;\r\n }\r\n\r\n public get createdTimestamp() {\r\n return snowflakeTimestamp(this.id);\r\n }\r\n\r\n public get createdAt() {\r\n return new Date(this.createdTimestamp);\r\n }\r\n\r\n /**\r\n * Gets the URL of the pack's banner, or `null` if it has none.\r\n * @param options The image options.\r\n */\r\n public bannerURL(options?: BaseImageURLOptions): string | null {\r\n const { bannerId } = this;\r\n return bannerId ? cdn.stickerPackBanner(bannerId, options) : null;\r\n }\r\n}\r\n","import type { GatewayAutoModerationActionExecutionDispatchData } from \"discord-api-types/v10\";\r\nimport type { AnyChannel } from \"../managers/ChannelManager.js\";\r\nimport { getGatewayClient } from \"../util/container.js\";\r\nimport type { AutoModerationRule } from \"./AutoModerationRule.js\";\r\nimport type { Guild } from \"./Guild.js\";\r\nimport type { GuildMember } from \"./GuildMember.js\";\r\nimport { kData, kRelations, Structure } from \"./Structure.js\";\r\nimport type { User } from \"./User.js\";\r\n\r\n/**\r\n * The relations of an {@link AutoModerationActionExecution}, resolved from the cache.\r\n */\r\nexport interface AutoModerationActionExecutionRelations {\r\n guild?: Guild | null;\r\n user?: User | null;\r\n}\r\n\r\n/**\r\n * An action auto moderation took on a message or a member.\r\n */\r\nexport class AutoModerationActionExecution extends Structure<GatewayAutoModerationActionExecutionDispatchData> {\r\n declare public [kRelations]: AutoModerationActionExecutionRelations;\r\n\r\n /**\r\n * @param data The raw execution.\r\n * @param relations The guild and user as resolved from the cache.\r\n */\r\n public constructor(\r\n data: GatewayAutoModerationActionExecutionDispatchData,\r\n relations: AutoModerationActionExecutionRelations = {},\r\n ) {\r\n super(data, relations);\r\n }\r\n\r\n public get guildId() {\r\n return this[kData].guild_id;\r\n }\r\n\r\n /**\r\n * The action taken: blocking the message, alerting a channel, or timing the member out.\r\n */\r\n public get action() {\r\n return this[kData].action;\r\n }\r\n\r\n public get ruleId() {\r\n return this[kData].rule_id;\r\n }\r\n\r\n public get ruleTriggerType() {\r\n return this[kData].rule_trigger_type;\r\n }\r\n\r\n public get userId() {\r\n return this[kData].user_id;\r\n }\r\n\r\n public get channelId(): string | null {\r\n return this[kData].channel_id ?? null;\r\n }\r\n\r\n /**\r\n * The ID of the message that triggered the rule. Absent when the message was blocked.\r\n */\r\n public get messageId(): string | null {\r\n return this[kData].message_id ?? null;\r\n }\r\n\r\n /**\r\n * The ID of the alert message sent to the alert channel, for `SendAlertMessage` actions.\r\n */\r\n public get alertSystemMessageId(): string | null {\r\n return this[kData].alert_system_message_id ?? null;\r\n }\r\n\r\n /**\r\n * The content that triggered the rule. Needs the `MessageContent` intent.\r\n */\r\n public get content() {\r\n return this[kData].content;\r\n }\r\n\r\n public get matchedKeyword(): string | null {\r\n return this[kData].matched_keyword;\r\n }\r\n\r\n public get matchedContent(): string | null {\r\n return this[kData].matched_content;\r\n }\r\n\r\n public get guild(): Guild | null {\r\n return this[kRelations].guild ?? null;\r\n }\r\n\r\n public get user(): User | null {\r\n return this[kRelations].user ?? null;\r\n }\r\n\r\n public fetchRule(): Promise<AutoModerationRule> {\r\n return getGatewayClient().guilds.autoModerationRules(this.guildId).fetch(this.ruleId);\r\n }\r\n\r\n public fetchMember(): Promise<GuildMember> {\r\n return getGatewayClient().members.fetch(this.guildId, this.userId);\r\n }\r\n\r\n public async fetchChannel(): Promise<AnyChannel | null> {\r\n const { channelId } = this;\r\n return channelId ? getGatewayClient().channels.fetch(channelId) : null;\r\n }\r\n}\r\n","import {\n ActivityType,\n GatewayOpcodes,\n PresenceUpdateStatus,\n type GatewayActivityUpdateData,\n type GatewayPresenceUpdateData,\n type RESTPatchAPICurrentUserJSONBody,\n} from \"discord-api-types/v10\";\nimport { getGatewayClient } from \"../util/container.js\";\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 getGatewayClient().core.api.users.edit(body);\n await getGatewayClient().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 = getGatewayClient().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\";\r\nimport type { AnyChannel } from \"../managers/ChannelManager.js\";\r\nimport { getGatewayClient } from \"../util/container.js\";\r\nimport { GuildMember } from \"./GuildMember.js\";\r\nimport { kData, Structure } from \"./Structure.js\";\r\nimport type { User } from \"./User.js\";\r\n\r\n/**\r\n * A user starting to type in a channel, carried by the `typingStart` event.\r\n */\r\nexport class Typing extends Structure<GatewayTypingStartDispatchData> {\r\n public get channelId() {\r\n return this[kData].channel_id;\r\n }\r\n\r\n public get guildId(): string | null {\r\n return this[kData].guild_id ?? null;\r\n }\r\n\r\n public get userId() {\r\n return this[kData].user_id;\r\n }\r\n\r\n /**\r\n * The time the user started typing, in milliseconds.\r\n */\r\n public get startedTimestamp(): number {\r\n return this[kData].timestamp * 1000;\r\n }\r\n\r\n public get startedAt(): Date {\r\n return new Date(this.startedTimestamp);\r\n }\r\n\r\n /**\r\n * The typing member, when the channel is in a guild.\r\n */\r\n public get member(): GuildMember | null {\r\n const { member, guild_id: guildId } = this[kData];\r\n // TODO: use GuildMemberMananger to resolve the member instead this\r\n return member && guildId ? new GuildMember({ ...member, guild_id: guildId }) : null;\r\n }\r\n\r\n /**\r\n * Whether the user typed in a guild channel.\r\n */\r\n public inGuild(): boolean {\r\n return this.guildId !== null;\r\n }\r\n\r\n /**\r\n * Fetches the channel the user typed in.\r\n */\r\n public fetchChannel(): Promise<AnyChannel> {\r\n return getGatewayClient().channels.fetch(this.channelId);\r\n }\r\n\r\n /**\r\n * Fetches the typing user.\r\n */\r\n public fetchUser(): Promise<User> {\r\n return getGatewayClient().users.fetch(this.userId);\r\n }\r\n}\r\n","import {\r\n GatewayDispatchEvents,\r\n type APIPartialEmoji,\r\n type GatewayDispatchPayload,\r\n type GatewayMessagePollVoteDispatchData,\r\n} from \"discord-api-types/v10\";\r\nimport type { Awaitable, CacheEntityTypes } from \"@wolfstar/plugin-cache\";\r\nimport type { GatewayClient } from \"../GatewayClient.js\";\r\nimport { AutoModerationActionExecution } from \"../structures/AutoModerationActionExecution.js\";\r\nimport { ClientUser } from \"../structures/ClientUser.js\";\r\nimport { GuildAuditLogsEntry } from \"../structures/GuildAuditLogsEntry.js\";\r\nimport { kPatch } from \"../structures/Structure.js\";\r\nimport type { GuildEmoji } from \"../structures/GuildEmoji.js\";\r\nimport { GuildInvite } from \"../structures/GuildInvite.js\";\r\nimport type { Sticker } from \"../structures/Sticker.js\";\r\nimport { MessageReaction } from \"../structures/MessageReaction.js\";\r\nimport { PollAnswer } from \"../structures/PollAnswer.js\";\r\nimport type { ThreadMember } from \"../structures/ThreadMember.js\";\r\nimport { Typing } from \"../structures/Typing.js\";\r\nimport type { GatewayEventMap, GatewayEventName } from \"./events.js\";\r\n\r\n/**\r\n * The data of the dispatch of type `Type`.\r\n */\r\nexport type DispatchData<Type extends GatewayDispatchEvents> = Extract<\r\n GatewayDispatchPayload,\r\n { t: Type }\r\n>[\"d\"];\r\n\r\n/**\r\n * Describes how a gateway dispatch turns into a {@link GatewayEventMap} event.\r\n *\r\n * @typeParam Type The dispatch type.\r\n * @typeParam Event The event emitted for it.\r\n */\r\nexport interface DispatchHandler<\r\n Type extends GatewayDispatchEvents,\r\n Event extends GatewayEventName,\r\n> {\r\n /**\r\n * The event to emit.\r\n */\r\n event: Event;\r\n /**\r\n * Runs before the dispatch is written to the cache, used to read the previous state of the entity.\r\n */\r\n before?(client: GatewayClient, data: DispatchData<Type>): Promise<unknown>;\r\n /**\r\n * Runs after the dispatch is written to the cache, and builds the arguments of the event.\r\n *\r\n * @param state The value `before` resolved to, if any.\r\n */\r\n build(\r\n client: GatewayClient,\r\n data: DispatchData<Type>,\r\n state: any,\r\n shardId: number,\r\n ): Awaitable<GatewayEventMap[Event]>;\r\n}\r\n\r\n/**\r\n * An event with its arguments, as emitted by a {@link MultiDispatchHandler}.\r\n */\r\nexport type GatewayEventTuple = {\r\n [Event in GatewayEventName]: [event: Event, ...args: GatewayEventMap[Event]];\r\n}[GatewayEventName];\r\n\r\n/**\r\n * Describes how a gateway dispatch turns into any number of {@link GatewayEventMap} events, e.g. one per emoji a\r\n * `GUILD_EMOJIS_UPDATE` changes.\r\n */\r\nexport interface MultiDispatchHandler<Type extends GatewayDispatchEvents> {\r\n /**\r\n * Runs before the dispatch is written to the cache, used to read the previous state.\r\n */\r\n before?(client: GatewayClient, data: DispatchData<Type>): Promise<unknown>;\r\n /**\r\n * Runs after the dispatch is written to the cache, and lists the events to emit, in order.\r\n */\r\n emit(client: GatewayClient, data: DispatchData<Type>, state: any): Awaitable<GatewayEventTuple[]>;\r\n}\r\n\r\n/**\r\n * A {@link DispatchHandler} for the dispatch of type `Type`, emitting any event.\r\n */\r\nexport type AnyDispatchHandler<Type extends GatewayDispatchEvents> = {\r\n [Event in GatewayEventName]: DispatchHandler<Type, Event>;\r\n}[GatewayEventName];\r\n\r\n/**\r\n * The table mapping every supported dispatch to its event.\r\n *\r\n * @remarks\r\n * `INTERACTION_CREATE` is deliberately absent: interactions are served by the HTTP endpoint, and the gateway may\r\n * deliver some of them as well. Dispatches without an entry are still written to the cache and emitted as `raw`.\r\n */\r\nexport const DispatchHandlers: { [Type in GatewayDispatchEvents]?: AnyDispatchHandler<Type> } = {\r\n [GatewayDispatchEvents.Ready]: {\r\n event: \"shardReady\",\r\n build: (client, data, _state, shardId) => {\r\n const user = new ClientUser(data.user);\r\n client.user = user;\r\n return [shardId, user];\r\n },\r\n },\r\n\r\n [GatewayDispatchEvents.GuildCreate]: {\r\n event: \"guildCreate\",\r\n // The cached entry has the collections stripped, prefer it over the (much larger) payload.\r\n build: async (client, data) => [\r\n (await cachedOrUndefined(client.guilds.get(data.id))) ??\r\n (await client.guilds.hydrate(data as CacheEntityTypes[\"guilds\"])),\r\n ],\r\n },\r\n [GatewayDispatchEvents.GuildUpdate]: {\r\n event: \"guildUpdate\",\r\n before: (client, data) => client.guilds.get(data.id),\r\n build: async (client, data, previous) => [previous ?? null, await client.guilds.hydrate(data)],\r\n },\r\n [GatewayDispatchEvents.GuildDelete]: {\r\n event: \"guildDelete\",\r\n before: (client, data) => client.guilds.get(data.id),\r\n build: (_client, data, previous) => [previous ?? null, data],\r\n },\r\n\r\n [GatewayDispatchEvents.ChannelCreate]: {\r\n event: \"channelCreate\",\r\n build: async (client, data) => [await client.channels.hydrate(data)],\r\n },\r\n [GatewayDispatchEvents.ChannelUpdate]: {\r\n event: \"channelUpdate\",\r\n before: (client, data) => client.channels.get(data.id),\r\n build: async (client, data, previous) => [\r\n previous ?? null,\r\n await client.channels.hydrate(data),\r\n ],\r\n },\r\n [GatewayDispatchEvents.ChannelDelete]: {\r\n event: \"channelDelete\",\r\n build: async (client, data) => [await client.channels.hydrate(data)],\r\n },\r\n\r\n [GatewayDispatchEvents.ChannelPinsUpdate]: {\r\n event: \"channelPinsUpdate\",\r\n build: (_client, data) => [data],\r\n },\r\n [GatewayDispatchEvents.WebhooksUpdate]: {\r\n event: \"webhooksUpdate\",\r\n build: (_client, data) => [data],\r\n },\r\n\r\n [GatewayDispatchEvents.ThreadCreate]: {\r\n event: \"threadCreate\",\r\n build: async (client, data) => [await client.threads.hydrate(data)],\r\n },\r\n [GatewayDispatchEvents.ThreadUpdate]: {\r\n event: \"threadUpdate\",\r\n before: (client, data) => client.threads.get(data.id),\r\n build: async (client, data, previous) => [previous ?? null, await client.threads.hydrate(data)],\r\n },\r\n [GatewayDispatchEvents.ThreadDelete]: {\r\n event: \"threadDelete\",\r\n before: (client, data) => client.threads.get(data.id),\r\n build: (_client, data, previous) => [previous ?? null, data],\r\n },\r\n\r\n [GatewayDispatchEvents.ThreadListSync]: {\r\n event: \"threadListSync\",\r\n build: async (client, data) => [\r\n await Promise.all(data.threads.map((thread) => client.threads.hydrate(thread as never))),\r\n await Promise.all(\r\n data.members.map((member) =>\r\n client.threadMembers.hydrate({ ...member, guild_id: data.guild_id }),\r\n ),\r\n ),\r\n data,\r\n ],\r\n },\r\n [GatewayDispatchEvents.ThreadMemberUpdate]: {\r\n event: \"threadMemberUpdate\",\r\n before: (client, data) =>\r\n data.id && data.user_id\r\n ? client.threadMembers.get(data.id, data.user_id)\r\n : Promise.resolve(undefined),\r\n build: async (client, data, previous) => [\r\n previous ?? null,\r\n await client.threadMembers.hydrate(data),\r\n ],\r\n },\r\n [GatewayDispatchEvents.ThreadMembersUpdate]: {\r\n event: \"threadMembersUpdate\",\r\n before: async (client, data) => {\r\n const removed = await Promise.all(\r\n (data.removed_member_ids ?? []).map((userId) => client.threadMembers.get(data.id, userId)),\r\n );\r\n return removed.filter((member) => member !== undefined);\r\n },\r\n build: async (client, data, previous: ThreadMember[] | undefined) => [\r\n await Promise.all(\r\n (data.added_members ?? []).map((member) =>\r\n client.threadMembers.hydrate({ ...member, id: data.id, guild_id: data.guild_id }),\r\n ),\r\n ),\r\n previous ?? [],\r\n (await cachedOrUndefined(client.threads.get(data.id))) ?? null,\r\n data,\r\n ],\r\n },\r\n\r\n [GatewayDispatchEvents.MessageCreate]: {\r\n event: \"messageCreate\",\r\n build: async (client, data) => [await client.messages.hydrate(data)],\r\n },\r\n [GatewayDispatchEvents.MessageUpdate]: {\r\n event: \"messageUpdate\",\r\n before: (client, data) => client.messages.get(data.channel_id, data.id),\r\n build: async (client, data, previous) => [\r\n previous ?? null,\r\n await client.messages.hydrate(data),\r\n ],\r\n },\r\n [GatewayDispatchEvents.MessageDelete]: {\r\n event: \"messageDelete\",\r\n before: (client, data) => client.messages.get(data.channel_id, data.id),\r\n build: (_client, data, previous) => [previous ?? null, data],\r\n },\r\n [GatewayDispatchEvents.MessageDeleteBulk]: {\r\n event: \"messageDeleteBulk\",\r\n before: async (client, data) => {\r\n const messages = await Promise.all(\r\n data.ids.map((id) => client.messages.get(data.channel_id, id)),\r\n );\r\n return messages.filter((message) => message !== undefined);\r\n },\r\n build: (_client, data, previous) => [previous ?? [], data],\r\n },\r\n\r\n [GatewayDispatchEvents.MessageReactionAdd]: {\r\n event: \"messageReactionAdd\",\r\n build: async (client, data) => [\r\n await reactionOf(client, data),\r\n (await cachedOrUndefined(client.users.get(data.user_id))) ?? null,\r\n { userId: data.user_id, type: data.type, burst: data.burst },\r\n ],\r\n },\r\n [GatewayDispatchEvents.MessageReactionRemove]: {\r\n event: \"messageReactionRemove\",\r\n build: async (client, data) => [\r\n await reactionOf(client, data),\r\n (await cachedOrUndefined(client.users.get(data.user_id))) ?? null,\r\n { userId: data.user_id, type: data.type, burst: data.burst },\r\n ],\r\n },\r\n [GatewayDispatchEvents.MessageReactionRemoveAll]: {\r\n event: \"messageReactionRemoveAll\",\r\n before: async (client, data) =>\r\n (await client.messages.get(data.channel_id, data.message_id))?.reactions.cache ?? [],\r\n build: async (client, data, previous: MessageReaction[] | undefined) => [\r\n (await cachedOrUndefined(client.messages.get(data.channel_id, data.message_id))) ?? null,\r\n previous ?? [],\r\n data,\r\n ],\r\n },\r\n [GatewayDispatchEvents.MessageReactionRemoveEmoji]: {\r\n event: \"messageReactionRemoveEmoji\",\r\n before: async (client, data) =>\r\n (await client.messages.get(data.channel_id, data.message_id))?.reactions.resolve(\r\n data.emoji,\r\n ) ?? undefined,\r\n build: (_client, data, previous: MessageReaction | undefined) => [\r\n previous ?? partialReaction(data),\r\n ],\r\n },\r\n [GatewayDispatchEvents.MessagePollVoteAdd]: {\r\n event: \"messagePollVoteAdd\",\r\n build: async (client, data) => [await pollAnswerOf(client, data), data.user_id],\r\n },\r\n [GatewayDispatchEvents.MessagePollVoteRemove]: {\r\n event: \"messagePollVoteRemove\",\r\n build: async (client, data) => [await pollAnswerOf(client, data), data.user_id],\r\n },\r\n\r\n [GatewayDispatchEvents.GuildMemberAdd]: {\r\n event: \"guildMemberAdd\",\r\n build: async (client, data) => [await client.members.hydrate(data)],\r\n },\r\n [GatewayDispatchEvents.GuildMemberUpdate]: {\r\n event: \"guildMemberUpdate\",\r\n before: (client, data) => client.members.get(data.guild_id, data.user.id),\r\n // The payload is partial: prefer the cached entry, which it was merged into.\r\n build: async (client, data, previous) => [\r\n previous ?? null,\r\n (await cachedOrUndefined(client.members.get(data.guild_id, data.user.id))) ??\r\n (await client.members.hydrate(data as CacheEntityTypes[\"members\"])),\r\n ],\r\n },\r\n [GatewayDispatchEvents.GuildMemberRemove]: {\r\n event: \"guildMemberRemove\",\r\n before: (client, data) => client.members.get(data.guild_id, data.user.id),\r\n build: (_client, data, previous) => [previous ?? null, data],\r\n },\r\n\r\n [GatewayDispatchEvents.GuildRoleCreate]: {\r\n event: \"guildRoleCreate\",\r\n build: async (client, data) => [\r\n await client.roles.hydrate({ ...data.role, guild_id: data.guild_id }),\r\n ],\r\n },\r\n [GatewayDispatchEvents.GuildRoleUpdate]: {\r\n event: \"guildRoleUpdate\",\r\n before: (client, data) => client.roles.get(data.guild_id, data.role.id),\r\n build: async (client, data, previous) => [\r\n previous ?? null,\r\n await client.roles.hydrate({ ...data.role, guild_id: data.guild_id }),\r\n ],\r\n },\r\n [GatewayDispatchEvents.GuildRoleDelete]: {\r\n event: \"guildRoleDelete\",\r\n before: (client, data) => client.roles.get(data.guild_id, data.role_id),\r\n build: (_client, data, previous) => [previous ?? null, data],\r\n },\r\n\r\n [GatewayDispatchEvents.InviteCreate]: {\r\n event: \"inviteCreate\",\r\n build: async (client, data) => [\r\n data.guild_id\r\n ? await client.guilds.invites(data.guild_id).hydrate(data)\r\n : new GuildInvite(data),\r\n ],\r\n },\r\n [GatewayDispatchEvents.InviteDelete]: {\r\n event: \"inviteDelete\",\r\n before: async (client, data) =>\r\n data.guild_id ? client.guilds.invites(data.guild_id).get(data.code) : undefined,\r\n build: (_client, data, previous) => [previous ?? null, data],\r\n },\r\n\r\n [GatewayDispatchEvents.TypingStart]: {\r\n event: \"typingStart\",\r\n build: (_client, data) => [new Typing(data)],\r\n },\r\n [GatewayDispatchEvents.VoiceStateUpdate]: {\r\n event: \"voiceStateUpdate\",\r\n before: async (client, data) =>\r\n data.guild_id ? client.voiceStates.get(data.guild_id, data.user_id) : undefined,\r\n build: async (client, data, previous) => [\r\n previous ?? null,\r\n await client.voiceStates.hydrate(data),\r\n ],\r\n },\r\n [GatewayDispatchEvents.PresenceUpdate]: {\r\n event: \"presenceUpdate\",\r\n before: (client, data) => client.presences.get(data.guild_id, data.user.id),\r\n // The payload may be partial: prefer the cached entry, which it was merged into.\r\n build: async (client, data, previous) => [\r\n previous ?? null,\r\n (await cachedOrUndefined(client.presences.get(data.guild_id, data.user.id))) ??\r\n (await client.presences.hydrate(data)),\r\n ],\r\n },\r\n [GatewayDispatchEvents.GuildScheduledEventCreate]: {\r\n event: \"guildScheduledEventCreate\",\r\n build: async (client, data) => [\r\n await client.guilds.scheduledEvents(data.guild_id).hydrate(data),\r\n ],\r\n },\r\n [GatewayDispatchEvents.GuildScheduledEventUpdate]: {\r\n event: \"guildScheduledEventUpdate\",\r\n before: (client, data) => client.guilds.scheduledEvents(data.guild_id).get(data.id),\r\n build: async (client, data, previous) => [\r\n previous ?? null,\r\n await client.guilds.scheduledEvents(data.guild_id).hydrate(data),\r\n ],\r\n },\r\n [GatewayDispatchEvents.GuildScheduledEventDelete]: {\r\n event: \"guildScheduledEventDelete\",\r\n build: async (client, data) => [\r\n await client.guilds.scheduledEvents(data.guild_id).hydrate(data),\r\n ],\r\n },\r\n [GatewayDispatchEvents.GuildScheduledEventUserAdd]: {\r\n event: \"guildScheduledEventUserAdd\",\r\n build: async (client, data) => [\r\n (await cachedOrUndefined(\r\n client.guilds.scheduledEvents(data.guild_id).get(data.guild_scheduled_event_id),\r\n )) ?? null,\r\n (await cachedOrUndefined(client.users.get(data.user_id))) ?? null,\r\n data,\r\n ],\r\n },\r\n [GatewayDispatchEvents.GuildScheduledEventUserRemove]: {\r\n event: \"guildScheduledEventUserRemove\",\r\n build: async (client, data) => [\r\n (await cachedOrUndefined(\r\n client.guilds.scheduledEvents(data.guild_id).get(data.guild_scheduled_event_id),\r\n )) ?? null,\r\n (await cachedOrUndefined(client.users.get(data.user_id))) ?? null,\r\n data,\r\n ],\r\n },\r\n [GatewayDispatchEvents.StageInstanceCreate]: {\r\n event: \"stageInstanceCreate\",\r\n build: async (client, data) => [\r\n await client.guilds.stageInstances(data.guild_id).hydrate(data),\r\n ],\r\n },\r\n [GatewayDispatchEvents.StageInstanceUpdate]: {\r\n event: \"stageInstanceUpdate\",\r\n before: (client, data) => client.guilds.stageInstances(data.guild_id).get(data.channel_id),\r\n build: async (client, data, previous) => [\r\n previous ?? null,\r\n await client.guilds.stageInstances(data.guild_id).hydrate(data),\r\n ],\r\n },\r\n [GatewayDispatchEvents.StageInstanceDelete]: {\r\n event: \"stageInstanceDelete\",\r\n build: async (client, data) => [\r\n await client.guilds.stageInstances(data.guild_id).hydrate(data),\r\n ],\r\n },\r\n [GatewayDispatchEvents.GuildSoundboardSoundCreate]: {\r\n event: \"guildSoundboardSoundCreate\",\r\n build: async (client, data) => [\r\n await client.guilds.soundboardSounds(data.guild_id!).hydrate(data),\r\n ],\r\n },\r\n [GatewayDispatchEvents.GuildSoundboardSoundUpdate]: {\r\n event: \"guildSoundboardSoundUpdate\",\r\n before: (client, data) => client.guilds.soundboardSounds(data.guild_id!).get(data.sound_id),\r\n build: async (client, data, previous) => [\r\n previous ?? null,\r\n await client.guilds.soundboardSounds(data.guild_id!).hydrate(data),\r\n ],\r\n },\r\n [GatewayDispatchEvents.GuildSoundboardSoundDelete]: {\r\n event: \"guildSoundboardSoundDelete\",\r\n before: (client, data) => client.guilds.soundboardSounds(data.guild_id).get(data.sound_id),\r\n build: (_client, data, previous) => [previous ?? null, data],\r\n },\r\n [GatewayDispatchEvents.GuildSoundboardSoundsUpdate]: {\r\n event: \"guildSoundboardSoundsUpdate\",\r\n build: async (client, data) => {\r\n const sounds = client.guilds.soundboardSounds(data.guild_id);\r\n return [\r\n await Promise.all(data.soundboard_sounds.map((sound) => sounds.hydrate(sound))),\r\n data.guild_id,\r\n ];\r\n },\r\n },\r\n [GatewayDispatchEvents.SoundboardSounds]: {\r\n event: \"soundboardSounds\",\r\n build: async (client, data) => {\r\n const sounds = client.guilds.soundboardSounds(data.guild_id);\r\n return [\r\n await Promise.all(data.soundboard_sounds.map((sound) => sounds.hydrate(sound))),\r\n data.guild_id,\r\n ];\r\n },\r\n },\r\n\r\n [GatewayDispatchEvents.GuildBanAdd]: {\r\n event: \"guildBanAdd\",\r\n build: async (client, data) => [await client.guilds.bans(data.guild_id).hydrate(data)],\r\n },\r\n [GatewayDispatchEvents.GuildBanRemove]: {\r\n event: \"guildBanRemove\",\r\n before: (client, data) => client.guilds.bans(data.guild_id).get(data.user.id),\r\n build: async (client, data, previous) => [\r\n previous ?? (await client.guilds.bans(data.guild_id).hydrate(data)),\r\n ],\r\n },\r\n [GatewayDispatchEvents.GuildAuditLogEntryCreate]: {\r\n event: \"guildAuditLogEntryCreate\",\r\n build: async (client, data) => {\r\n const [executor, guild] = await Promise.all([\r\n data.user_id ? cachedOrUndefined(client.users.get(data.user_id)) : undefined,\r\n cachedOrUndefined(client.guilds.get(data.guild_id)),\r\n ]);\r\n return [new GuildAuditLogsEntry(data, { executor: executor ?? null, guild: guild ?? null })];\r\n },\r\n },\r\n [GatewayDispatchEvents.AutoModerationRuleCreate]: {\r\n event: \"autoModerationRuleCreate\",\r\n build: async (client, data) => [\r\n await client.guilds.autoModerationRules(data.guild_id).hydrate(data),\r\n ],\r\n },\r\n [GatewayDispatchEvents.AutoModerationRuleUpdate]: {\r\n event: \"autoModerationRuleUpdate\",\r\n before: (client, data) => client.guilds.autoModerationRules(data.guild_id).get(data.id),\r\n build: async (client, data, previous) => [\r\n previous ?? null,\r\n await client.guilds.autoModerationRules(data.guild_id).hydrate(data),\r\n ],\r\n },\r\n [GatewayDispatchEvents.AutoModerationRuleDelete]: {\r\n event: \"autoModerationRuleDelete\",\r\n build: async (client, data) => [\r\n await client.guilds.autoModerationRules(data.guild_id).hydrate(data),\r\n ],\r\n },\r\n [GatewayDispatchEvents.GuildIntegrationsUpdate]: {\r\n event: \"guildIntegrationsUpdate\",\r\n build: async (client, data) => [\r\n (await cachedOrUndefined(client.guilds.get(data.guild_id))) ?? null,\r\n data,\r\n ],\r\n },\r\n [GatewayDispatchEvents.IntegrationCreate]: {\r\n event: \"integrationCreate\",\r\n build: async (client, data) => [await client.guilds.integrations(data.guild_id).hydrate(data)],\r\n },\r\n [GatewayDispatchEvents.IntegrationUpdate]: {\r\n event: \"integrationUpdate\",\r\n before: (client, data) => client.guilds.integrations(data.guild_id).get(data.id),\r\n build: async (client, data, previous) => [\r\n previous ?? null,\r\n await client.guilds.integrations(data.guild_id).hydrate(data),\r\n ],\r\n },\r\n [GatewayDispatchEvents.IntegrationDelete]: {\r\n event: \"integrationDelete\",\r\n before: (client, data) => client.guilds.integrations(data.guild_id).get(data.id),\r\n build: (_client, data, previous) => [previous ?? null, data],\r\n },\r\n\r\n [GatewayDispatchEvents.AutoModerationActionExecution]: {\r\n event: \"autoModerationActionExecution\",\r\n build: async (client, data) => {\r\n const [user, guild] = await Promise.all([\r\n cachedOrUndefined(client.users.get(data.user_id)),\r\n cachedOrUndefined(client.guilds.get(data.guild_id)),\r\n ]);\r\n return [\r\n new AutoModerationActionExecution(data, { user: user ?? null, guild: guild ?? null }),\r\n ];\r\n },\r\n },\r\n [GatewayDispatchEvents.VoiceServerUpdate]: {\r\n event: \"voiceServerUpdate\",\r\n build: (_client, data) => [data],\r\n },\r\n\r\n [GatewayDispatchEvents.UserUpdate]: {\r\n event: \"userUpdate\",\r\n before: (client, data) => client.users.get(data.id),\r\n build: async (client, data, previous) => {\r\n // The bot's own updates keep `client.user` a `ClientUser`, with its presence.\r\n if (client.user?.id === data.id) {\r\n client.user[kPatch](data);\r\n return [previous ?? null, client.user];\r\n }\r\n\r\n return [previous ?? null, await client.users.hydrate(data)];\r\n },\r\n },\r\n};\r\n\r\n/**\r\n * The table of the dispatches that turn into several events, diffed against the cache.\r\n *\r\n * @remarks\r\n * Without a cache there is nothing to diff against, so these dispatches only reach `raw`.\r\n */\r\nexport const MultiDispatchHandlers: {\r\n [Type in GatewayDispatchEvents]?: MultiDispatchHandler<Type>;\r\n} = {\r\n [GatewayDispatchEvents.GuildEmojisUpdate]: {\r\n before: (client, data) => client.guilds.emojis(data.guild_id).listCached(),\r\n emit: async (client, data, previous: GuildEmoji[] | undefined) => {\r\n if (!client.cache || !previous) return [];\r\n const emojis = client.guilds.emojis(data.guild_id);\r\n const current = await Promise.all(\r\n data.emojis.map((emoji) => emojis.hydrate({ ...emoji, guild_id: data.guild_id })),\r\n );\r\n return diff(previous, current, \"emojiCreate\", \"emojiUpdate\", \"emojiDelete\");\r\n },\r\n },\r\n [GatewayDispatchEvents.GuildStickersUpdate]: {\r\n before: (client, data) => client.guilds.stickers(data.guild_id).listCached(),\r\n emit: async (client, data, previous: Sticker[] | undefined) => {\r\n if (!client.cache || !previous) return [];\r\n const stickers = client.guilds.stickers(data.guild_id);\r\n const current = await Promise.all(\r\n data.stickers.map((sticker) => stickers.hydrate({ ...sticker, guild_id: data.guild_id })),\r\n );\r\n return diff(previous, current, \"stickerCreate\", \"stickerUpdate\", \"stickerDelete\");\r\n },\r\n },\r\n};\r\n\r\ntype Diffable = { id: string | null; equals(other: never): boolean };\r\n\r\n// Lists the create, update, and delete events turning `previous` into `current`, matched by ID.\r\nfunction diff<Value extends Diffable>(\r\n previous: readonly Value[],\r\n current: readonly Value[],\r\n create: string,\r\n update: string,\r\n remove: string,\r\n): GatewayEventTuple[] {\r\n const before = new Map(previous.map((value) => [value.id, value]));\r\n const events: unknown[][] = [];\r\n for (const value of current) {\r\n const old = before.get(value.id);\r\n if (!old) events.push([create, value]);\r\n else if (!old.equals(value as never)) events.push([update, old, value]);\r\n before.delete(value.id);\r\n }\r\n\r\n for (const value of before.values()) events.push([remove, value]);\r\n return events as GatewayEventTuple[];\r\n}\r\n\r\n/**\r\n * Resolves a cache read, or `undefined` when the cache cannot be read, so an event can still be built from its\r\n * payload. The failure itself was already reported while applying the dispatch.\r\n */\r\ntype ReactionData = {\r\n channel_id: string;\r\n message_id: string;\r\n emoji: APIPartialEmoji;\r\n burst_colors?: string[];\r\n};\r\n\r\n// The reaction as the cache holds it after the dispatch. When the message is cached but the reaction is gone (its\r\n// last user removed it), the counts are known to be zero; only an uncached message leaves them unknown.\r\nasync function reactionOf(client: GatewayClient, data: ReactionData): Promise<MessageReaction> {\r\n const message = await cachedOrUndefined(client.messages.get(data.channel_id, data.message_id));\r\n if (!message) return partialReaction(data);\r\n return message.reactions.resolve(data.emoji) ?? partialReaction(data, true);\r\n}\r\n\r\nfunction partialReaction(data: ReactionData, emptied = false): MessageReaction {\r\n return new MessageReaction({\r\n channel_id: data.channel_id,\r\n message_id: data.message_id,\r\n emoji: data.emoji,\r\n me: false,\r\n me_burst: false,\r\n burst_colors: data.burst_colors ?? [],\r\n ...(emptied && { count: 0, count_details: { normal: 0, burst: 0 } }),\r\n });\r\n}\r\n\r\n// The answer as the cache holds it after the dispatch, else one with only its ID.\r\nasync function pollAnswerOf(\r\n client: GatewayClient,\r\n data: GatewayMessagePollVoteDispatchData,\r\n): Promise<PollAnswer> {\r\n const message = await cachedOrUndefined(client.messages.get(data.channel_id, data.message_id));\r\n return (\r\n message?.poll?.answers.find((answer) => answer.id === data.answer_id) ??\r\n new PollAnswer({\r\n answer_id: data.answer_id,\r\n poll_media: {},\r\n channel_id: data.channel_id,\r\n message_id: data.message_id,\r\n })\r\n );\r\n}\r\n\r\nfunction cachedOrUndefined<Value>(read: Promise<Value | undefined>): Promise<Value | undefined> {\r\n return read.catch(() => undefined);\r\n}\r\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 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\";\r\n\r\n/**\r\n * A snapshot of a {@link DispatchQueue}.\r\n */\r\nexport interface DispatchQueueStats {\r\n /**\r\n * The dispatches received but not processed yet, across every shard.\r\n */\r\n pending: number;\r\n /**\r\n * The partitions currently holding at least one pending dispatch.\r\n */\r\n partitions: number;\r\n}\r\n\r\ninterface ShardQueue {\r\n // The last dispatch every partition must wait for, e.g. `READY`.\r\n barrier: Promise<void>;\r\n partitions: Map<string, Promise<void>>;\r\n}\r\n\r\nconst GuildEvents: ReadonlySet<string> = new Set([\r\n GatewayDispatchEvents.GuildCreate,\r\n GatewayDispatchEvents.GuildUpdate,\r\n GatewayDispatchEvents.GuildDelete,\r\n]);\r\n\r\n/**\r\n * Gets the partition a dispatch is processed in: its guild, else its channel (direct messages), else `null`.\r\n *\r\n * @remarks\r\n * A `null` partition is a barrier: the dispatch waits for every pending dispatch of its shard, and every later one\r\n * waits for it. `READY`, `RESUMED`, and user-level dispatches such as `USER_UPDATE` are barriers.\r\n *\r\n * @param payload The dispatch payload.\r\n */\r\nexport function dispatchPartition(payload: GatewayDispatchPayload): string | null {\r\n const data = payload.d as { guild_id?: string; channel_id?: string; id?: string } | null;\r\n if (!data || typeof data !== \"object\") return null;\r\n if (data.guild_id) return `guild:${data.guild_id}`;\r\n if (GuildEvents.has(payload.t) && data.id) return `guild:${data.id}`;\r\n if (data.channel_id) return `channel:${data.channel_id}`;\r\n // Direct message channels are the only channels created or deleted without a guild.\r\n if (payload.t.startsWith(\"CHANNEL_\") && data.id) return `channel:${data.id}`;\r\n return null;\r\n}\r\n\r\n/**\r\n * Runs tasks in order within a partition, and partitions of the same shard concurrently.\r\n *\r\n * @remarks\r\n * An asynchronous cache (Redis) would otherwise let a later dispatch of a guild finish before an earlier one. Guilds\r\n * are independent, so a slow guild does not hold the others back. Tasks must never reject: the queue has no way to\r\n * report their errors.\r\n */\r\nexport class DispatchQueue {\r\n readonly #shards = new Map<number, ShardQueue>();\r\n // The shard each guild's dispatches come from, for the tasks the client queues on its own.\r\n readonly #guildShards = new Map<string, number>();\r\n #pending = 0;\r\n\r\n /**\r\n * Queues a task.\r\n *\r\n * @param shardId The shard the dispatch was received on.\r\n * @param partition The partition from {@link dispatchPartition}, `null` for a barrier.\r\n * @param task The task to run once the previous task of its partition is done.\r\n * @returns The task's completion.\r\n */\r\n public enqueue(\r\n shardId: number,\r\n partition: string | null,\r\n task: () => Promise<void>,\r\n ): Promise<void> {\r\n const shard = this.shard(shardId);\r\n this.#pending++;\r\n if (partition?.startsWith(\"guild:\")) this.#guildShards.set(partition, shardId);\r\n\r\n const previous =\r\n partition === null\r\n ? Promise.all([shard.barrier, ...shard.partitions.values()])\r\n : (shard.partitions.get(partition) ?? shard.barrier);\r\n const run = previous.then(task).finally(() => {\r\n this.#pending--;\r\n if (partition !== null && shard.partitions.get(partition) === run) {\r\n shard.partitions.delete(partition);\r\n }\r\n });\r\n\r\n if (partition === null) {\r\n // Every pending partition is covered by the barrier from now on.\r\n shard.barrier = run;\r\n shard.partitions.clear();\r\n } else {\r\n shard.partitions.set(partition, run);\r\n }\r\n\r\n return run;\r\n }\r\n\r\n /**\r\n * Queues a task in a guild's partition, on the shard the guild's dispatches come from: a cache write the client\r\n * makes on its own then stays in order with them. Before any dispatch of the guild, there is nothing to order it\r\n * with, and it runs on shard 0.\r\n *\r\n * @param guildId The ID of the guild.\r\n * @param task The task to run once the previous task of the guild is done.\r\n */\r\n public enqueueGuild(guildId: string, task: () => Promise<void>): Promise<void> {\r\n const partition = `guild:${guildId}`;\r\n return this.enqueue(this.#guildShards.get(partition) ?? 0, partition, task);\r\n }\r\n\r\n /**\r\n * Resolves once every task queued so far has run.\r\n */\r\n public async idle(): Promise<void> {\r\n await Promise.all(\r\n [...this.#shards.values()].flatMap((shard) => [shard.barrier, ...shard.partitions.values()]),\r\n );\r\n }\r\n\r\n /**\r\n * A snapshot of the pending work.\r\n */\r\n public get stats(): DispatchQueueStats {\r\n let partitions = 0;\r\n for (const shard of this.#shards.values()) partitions += shard.partitions.size;\r\n return { pending: this.#pending, partitions };\r\n }\r\n\r\n private shard(shardId: number): ShardQueue {\r\n let shard = this.#shards.get(shardId);\r\n if (!shard) {\r\n shard = { barrier: Promise.resolve(), partitions: new Map() };\r\n this.#shards.set(shardId, shard);\r\n }\r\n\r\n return shard;\r\n }\r\n}\r\n","/**\r\n * Emitted as an `error` when a dispatch takes longer than `GatewayClientOptions.dispatchTimeout` to process.\r\n *\r\n * @remarks\r\n * The dispatch is not cancelled: it keeps running, and later dispatches of its partition keep waiting for it, so the\r\n * event order is preserved. The error only reports that the partition is stuck, usually on a slow or unreachable\r\n * cache.\r\n */\r\nexport class DispatchTimeoutError extends Error {\r\n /**\r\n * The type of the slow dispatch, e.g. `MESSAGE_CREATE`.\r\n */\r\n public readonly type: string;\r\n\r\n /**\r\n * The shard the dispatch was received on.\r\n */\r\n public readonly shardId: number;\r\n\r\n /**\r\n * The partition the dispatch runs in, `null` for a barrier.\r\n */\r\n public readonly partition: string | null;\r\n\r\n /**\r\n * The timeout that was exceeded, in milliseconds.\r\n */\r\n public readonly timeout: number;\r\n\r\n public constructor(type: string, shardId: number, partition: string | null, timeout: number) {\r\n super(\r\n `Processing ${type} on shard ${shardId} (${partition ?? \"barrier\"}) took longer than ${timeout}ms`,\r\n );\r\n this.name = \"DispatchTimeoutError\";\r\n this.type = type;\r\n this.shardId = shardId;\r\n this.partition = partition;\r\n this.timeout = timeout;\r\n }\r\n}\r\n","import {\n WebSocketManager,\n WebSocketShardEvents,\n type OptionalWebSocketManagerOptions,\n type ShardRange,\n} from \"@discordjs/ws\";\nimport { Client as DiscordCoreClient } from \"@discordjs/core\";\nimport { Client, container, type ClientOptions } from \"@wolfstar/http-framework\";\nimport { applyGatewayDispatch, type Cache } from \"@wolfstar/plugin-cache\";\nimport {\n GatewayDispatchEvents,\n GatewayOpcodes,\n type APIVoiceRegion,\n type GatewayDispatchPayload,\n type GatewayReadyDispatchData,\n type GatewayIntentBits,\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/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/BaseInvite.js\";\nimport type { ClientUser } from \"./structures/ClientUser.js\";\nimport { createInvite } from \"./structures/GroupDMInvite.js\";\nimport { Sticker } from \"./structures/Sticker.js\";\nimport type { Webhook } from \"./structures/Webhook.js\";\nimport type { GuildTemplate } from \"./structures/GuildTemplate.js\";\nimport { Widget } from \"./structures/Widget.js\";\nimport { StickerPack } from \"./structures/StickerPack.js\";\nimport { ActionsManager } from \"./actions/Action.js\";\nimport { dispatchPartition, DispatchQueue, type DispatchQueueStats } from \"./util/DispatchQueue.js\";\nimport { DispatchTimeoutError } from \"./util/errors.js\";\n\nexport interface GatewayClientOptions extends ClientOptions {\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 * 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\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/**\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 underlying `@discordjs/ws` manager, handling the shards' connections, resumes, and identify rate limits.\n */\n public readonly gateway: WebSocketManager;\n\n /** The discord.js core client, sharing this client's REST and gateway transports. */\n public 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 // 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 public constructor(options: GatewayClientOptions) {\n super(options);\n\n this.cache = options.cache;\n this.cacheFailure = options.cacheFailure ?? \"skip\";\n this.dispatchTimeout = options.dispatchTimeout === undefined ? 30_000 : options.dispatchTimeout;\n this.#shardCount = options.shardCount ?? null;\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 // The base client validated the token already, and scrubs it from `this.options`.\n token: (options.discordToken ?? process.env.DISCORD_TOKEN)!,\n intents: options.intents as GatewayIntentBits,\n rest: container.rest,\n shardCount: options.shardCount ?? null,\n shardIds: options.shardIds ?? null,\n });\n this.core = new DiscordCoreClient({ gateway: this.gateway, rest: container.rest });\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 public async destroy(): Promise<void> {\n await this.gateway.destroy();\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.core.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.core.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.core.api.invites.get(resolved, {\n with_counts: options.withCounts ?? true,\n guild_scheduled_event_id: options.guildScheduledEventId,\n });\n return createInvite(invite);\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.core.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.core.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.core.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 * Processes a gateway dispatch: emits it as `raw`, writes it into the cache, and emits the matching\n * {@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\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) await this.reconcileGuilds(payload.d, shardId);\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 await action?.handle(payload.d, state, shardId);\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 // 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\";\r\nimport type { EventGatewayListener } from \"../EventGatewayListener.js\";\r\n\r\ntype ListenerConstructor = new (...args: any[]) => EventGatewayListener<any>;\r\n\r\n/**\r\n * Class decorator that binds the decorated {@link EventGatewayListener} to a gateway event, so it does not need to\r\n * declare a constructor.\r\n *\r\n * @example\r\n * ```typescript\r\n * import { EventGatewayListener, RegisterAsGatewayListener, type Message } from '@wolfstar/plugin-gateway';\r\n *\r\n * @RegisterAsGatewayListener('messageCreate')\r\n * export class LogMessagesListener extends EventGatewayListener<'messageCreate'> {\r\n * public override run(message: Message) {\r\n * console.log(`${message.author.username}: ${message.content}`);\r\n * }\r\n * }\r\n * ```\r\n *\r\n * @param event The event to listen to.\r\n * @param options The additional listener options.\r\n */\r\nexport function RegisterAsGatewayListener<Event extends GatewayEventName>(\r\n event: Event,\r\n options: Omit<EventGatewayListener.Options<Event>, \"event\"> = {},\r\n) {\r\n return function decorate<T extends ListenerConstructor>(target: T): T {\r\n // Seen through its instance type, the target is abstract (`run`), even though the decorated class implements it.\r\n const base = target as unknown as new (...args: any[]) => object;\r\n return class extends base {\r\n public constructor(...args: any[]) {\r\n const [context, baseOptions = {}] = args as [\r\n EventGatewayListener.LoaderContext,\r\n Partial<EventGatewayListener.Options<Event>>?,\r\n ];\r\n super(context, { ...baseOptions, ...options, event });\r\n }\r\n } as unknown as T;\r\n };\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;A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xD,KAAK,OAAO,MAAM,oBAAoB,QAAQ,sBAAsB,KAAK,IAAI,KAAK;CACzF;AACF;;;;;;;;;;;;;;;;;;;;;;;AC5bA,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","toISO","DiscordCoreClient"],"sources":["../../src/EventGatewayListener.ts","../../src/util/channels.ts","../../src/util/container.ts","../../src/structures/Structure.ts","../../src/structures/Channel.ts","../../src/structures/Mixin.ts","../../src/structures/mixins/BaseChannelMixin.ts","../../src/structures/mixins/ChannelParentMixin.ts","../../src/structures/PermissionOverwrites.ts","../../src/managers/PermissionOverwriteManager.ts","../../src/util/permissions.ts","../../src/structures/mixins/edit.ts","../../src/structures/mixins/ChannelPermissionMixin.ts","../../src/structures/mixins/ChannelSlowmodeMixin.ts","../../src/managers/ChannelThreadManager.ts","../../src/structures/mixins/ChannelThreadsMixin.ts","../../src/structures/mixins/ChannelWebhooksMixin.ts","../../src/structures/mixins/ChannelTopicMixin.ts","../../src/structures/mixins/GuildChannelMixin.ts","../../src/managers/ChannelMessageManager.ts","../../src/structures/mixins/TextChannelMixin.ts","../../src/structures/AnnouncementChannel.ts","../../src/structures/mixins/ChannelOwnerMixin.ts","../../src/managers/ThreadChannelMemberManager.ts","../../src/structures/mixins/ThreadChannelMixin.ts","../../src/structures/AnnouncementThreadChannel.ts","../../src/structures/BaseChannel.ts","../../src/structures/CategoryChannel.ts","../../src/util/cdn.ts","../../src/util/flags.ts","../../src/structures/User.ts","../../src/structures/mixins/DMChannelMixin.ts","../../src/structures/DMChannel.ts","../../src/structures/mixins/ThreadOnlyChannelMixin.ts","../../src/structures/ForumChannel.ts","../../src/structures/mixins/GroupDMMixin.ts","../../src/structures/GroupDMChannel.ts","../../src/structures/MediaChannel.ts","../../src/structures/PrivateThreadChannel.ts","../../src/structures/mixins/AppliedTagsMixin.ts","../../src/structures/PublicThreadChannel.ts","../../src/structures/mixins/VoiceChannelMixin.ts","../../src/structures/StageChannel.ts","../../src/structures/TextChannel.ts","../../src/structures/VoiceChannel.ts","../../src/managers/CachedManager.ts","../../src/managers/ChannelManager.ts","../../src/structures/AnonymousGuild.ts","../../src/structures/Guild.ts","../../src/managers/GuildEmojiRoleManager.ts","../../src/structures/Emoji.ts","../../src/structures/GuildEmoji.ts","../../src/structures/Sticker.ts","../../src/structures/GuildPreview.ts","../../src/structures/GuildAuditLogsEntry.ts","../../src/structures/ReactionEmoji.ts","../../src/structures/GuildOnboarding.ts","../../src/structures/WelcomeScreen.ts","../../src/structures/Webhook.ts","../../src/structures/AutoModerationRule.ts","../../src/managers/AutoModerationRuleManager.ts","../../src/structures/GuildBan.ts","../../src/managers/GuildBanManager.ts","../../src/managers/GuildChannelManager.ts","../../src/structures/Integration.ts","../../src/managers/GuildIntegrationManager.ts","../../src/structures/GuildScheduledEvent.ts","../../src/managers/GuildScheduledEventManager.ts","../../src/structures/SoundboardSound.ts","../../src/managers/GuildSoundboardSoundManager.ts","../../src/structures/StageInstance.ts","../../src/managers/StageInstanceManager.ts","../../src/managers/GuildEmojiManager.ts","../../src/structures/BaseInvite.ts","../../src/structures/InviteGuild.ts","../../src/structures/GuildInvite.ts","../../src/managers/GuildInviteManager.ts","../../src/managers/GuildStickerManager.ts","../../src/managers/GuildManager.ts","../../src/managers/GuildMemberRoleManager.ts","../../src/structures/GuildMember.ts","../../src/managers/GuildMemberManager.ts","../../src/managers/ReactionUserManager.ts","../../src/structures/MessageReaction.ts","../../src/managers/ReactionManager.ts","../../src/util/equal.ts","../../src/structures/Attachment.ts","../../src/structures/Embed.ts","../../src/structures/MessageMentions.ts","../../src/structures/PollAnswer.ts","../../src/structures/Poll.ts","../../src/structures/Message.ts","../../src/util/messages.ts","../../src/managers/MessageManager.ts","../../src/structures/Role.ts","../../src/managers/RoleManager.ts","../../src/managers/WebhookManager.ts","../../src/structures/GuildTemplate.ts","../../src/managers/GuildTemplateManager.ts","../../src/structures/VoiceState.ts","../../src/managers/VoiceStateManager.ts","../../src/structures/RichPresenceAssets.ts","../../src/structures/Activity.ts","../../src/structures/Presence.ts","../../src/managers/PresenceManager.ts","../../src/managers/ThreadManager.ts","../../src/structures/ThreadMember.ts","../../src/managers/ThreadMemberManager.ts","../../src/managers/UserManager.ts","../../src/structures/GroupDMInvite.ts","../../src/structures/Widget.ts","../../src/structures/StickerPack.ts","../../src/structures/AutoModerationActionExecution.ts","../../src/structures/ClientUser.ts","../../src/structures/Typing.ts","../../src/util/dispatch.ts","../../src/actions/Action.ts","../../src/util/DispatchQueue.ts","../../src/util/errors.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 { 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","import { Structure as BaseStructure } from \"@discordjs/structures\";\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 subclasses below 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 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\n/**\n * The base class every structure extends: `@discordjs/structures`' `Structure`, with its data and patch/clone methods\n * made reachable from subclasses outside of discord.js.\n *\n * @remarks\n * Structures never hold a reference to a client, so they can be built from any raw payload, be it a gateway dispatch,\n * a cache hit, or a REST response.\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 readonly #timestamps = new Map<string, number | null>();\n\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. Subclasses narrow its type. Public only\n * so that {@link Structure.dropRelations} can check relation names against it.\n *\n * @internal\n */\n declare public [kRelations]: object;\n\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 this[kRelations] = relations;\n this.optimizeData(data);\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) this.#timestamps.set(key, value ? Date.parse(value) : null);\n }\n\n /** Gets a timestamp previously parsed by `optimizeData`. */\n protected optimizedTimestamp(key: string): number | null {\n return this.#timestamps.get(key) ?? null;\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 (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 return clone;\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] };\n for (const name of names) delete relations[name];\n this[kRelations] = relations;\n }\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 { ChannelType, type APIChannel, type Snowflake } from \"discord-api-types/v10\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, type kRelations, snowflakeTimestamp, Structure } from \"./Structure.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\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\n/**\n * The base of every channel structure, holding what all channel types share.\n *\n * @remarks\n * Concrete channels (`TextChannel`, `DMChannel`, ...) add their fields through mixins, following\n * `@discordjs/structures`' 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 Structure<\n ChannelDataType<Type>\n> {\n declare public [kRelations]: ChannelRelations;\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, relations);\n }\n\n public get id(): Snowflake {\n return this[kData].id;\n }\n\n public get type(): Type {\n return this[kData].type as Type;\n }\n\n public get flags(): number {\n return this[kData].flags ?? 0;\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 * Whether this channel is a thread.\n */\n public isThread(): boolean {\n return isThreadChannelType(this.type);\n }\n\n /**\n * Whether this channel is a direct message or a group direct message.\n */\n public isDMBased(): boolean {\n return this.type === ChannelType.DM || this.type === ChannelType.GroupDM;\n }\n\n public toString(): `<#${string}>` {\n return `<#${this.id}>`;\n }\n}\n","/**\n * Any class, abstract or not.\n */\nexport type MixinBase = abstract new (...args: any[]) => object;\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 { type ChannelType } from \"discord-api-types/v10\";\nimport { getGatewayClient } from \"../../util/container.js\";\nimport type { Channel, ChannelDataType } from \"../Channel.js\";\nimport { kPatch } from \"../Structure.js\";\n\nexport interface BaseChannelMixin<Type extends ChannelType = ChannelType> extends Channel<Type> {}\n\n/**\n * Adds the REST actions every channel supports.\n */\nexport class BaseChannelMixin<Type extends ChannelType = ChannelType> {\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 getGatewayClient().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 getGatewayClient().core.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 { Channel } from \"../Channel.js\";\nimport { kData } 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 public get nsfw(): boolean {\n return (this[kData] as Data).nsfw ?? false;\n }\n}\n","import type { APIOverwrite } from \"discord-api-types/v10\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport type { PermissionOverwriteOptions } from \"../util/channels.js\";\nimport { PermissionsBitField } from \"../util/PermissionsBitField.js\";\nimport { kData, kPatch, Structure } from \"./Structure.js\";\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 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 * 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 getGatewayClient().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 getGatewayClient().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 { PermissionOverwrites } from \"../structures/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 public constructor(\n client: GatewayClient,\n channelId: string,\n guildId: string | null,\n overwrites: readonly APIOverwrite[],\n ) {\n this.client = client;\n this.channelId = channelId;\n this.guildId = guildId;\n this.#overwrites = overwrites;\n }\n\n /**\n * The overwrites of the channel.\n */\n public get cache(): PermissionOverwrites[] {\n return this.#overwrites.map(\n (overwrite) => new PermissionOverwrites({ ...overwrite, channel_id: this.channelId }),\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.core.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.core.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/GuildMember.js\";\nimport type { Role } from \"../structures/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 { getGatewayClient } from \"../../util/container.js\";\nimport type { Channel } from \"../Channel.js\";\nimport { kPatch } 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 Channel>(\n channel: Value,\n options: GuildChannelEditOptions,\n): Promise<Value> {\n const edited = await getGatewayClient().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 } 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 { getGatewayClient } from \"../../util/container.js\";\nimport { computeTargetPermissions } from \"../../util/permissions.js\";\nimport type { PermissionsBitField } from \"../../util/PermissionsBitField.js\";\nimport type { GuildMember } from \"../GuildMember.js\";\nimport type { Role } from \"../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\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 getGatewayClient(),\n this.id,\n data.guild_id ?? null,\n data.permission_overwrites ?? [],\n );\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 getGatewayClient()\n .guilds.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 getGatewayClient().channels.fetch(parentId)).toJSON() as Data;\n const own = (this[kData] as Data).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\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 { getGatewayClient } from \"../../util/container.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(\n getGatewayClient(),\n this.id,\n (this[kData] as Data).guild_id ?? null,\n );\n }\n}\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport type { WebhookCreateOptions } from \"../../managers/WebhookManager.js\";\nimport { getGatewayClient } from \"../../util/container.js\";\nimport type { Channel } from \"../Channel.js\";\nimport type { Webhook } from \"../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 getGatewayClient().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 getGatewayClient().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 { getGatewayClient } from \"../../util/container.js\";\nimport type { Guild } from \"../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 ? getGatewayClient().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 getGatewayClient()\n .guilds.channels(guildId)\n .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/Message.js\";\nimport type { FetchOptions } from \"./CachedManager.js\";\nimport type { EmojiIdentifierResolvable } from \"../structures/ReactionEmoji.js\";\nimport type { User } from \"../structures/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 type { ChannelType } from \"discord-api-types/v10\";\nimport { ChannelMessageManager } from \"../../managers/ChannelMessageManager.js\";\nimport { getGatewayClient } from \"../../util/container.js\";\nimport type { MessageCreateOptions, MessagePayloadResolvable } from \"../../util/messages.js\";\nimport type { Channel, ChannelDataType } from \"../Channel.js\";\nimport type { Message } from \"../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(getGatewayClient(), 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 getGatewayClient().messages.send(this.id, 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 getGatewayClient().core.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 getGatewayClient().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 ? getGatewayClient().messages.fetch(this.id, lastMessageId) : null;\n }\n}\n","import { type ChannelType } from \"discord-api-types/v10\";\nimport { resolveId, type IdResolvable } from \"../util/channels.js\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport { Channel } from \"./Channel.js\";\nimport { Mixin } from \"./Mixin.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 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 * A guild announcement channel.\n */\nexport class AnnouncementChannel extends Channel<ChannelType.GuildAnnouncement> {\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 getGatewayClient().core.api.channels.followAnnouncements(\n this.id,\n resolveId(channel),\n { reason },\n );\n return result.webhook_id;\n }\n}\n\nMixin(AnnouncementChannel, [\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/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 { getGatewayClient } from \"../../util/container.js\";\nimport type { Message } from \"../Message.js\";\nimport type { ThreadMember } from \"../ThreadMember.js\";\nimport { kData } 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};\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 * The members of the thread.\n */\n public get members(): ThreadChannelMemberManager {\n return new ThreadChannelMemberManager(getGatewayClient(), 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 getGatewayClient().threadMembers.add(this.id);\n return this;\n }\n\n /**\n * Leaves the thread.\n */\n public async leave(): Promise<this> {\n await getGatewayClient().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 getGatewayClient().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 getGatewayClient().threadMembers.fetch(this.id, ownerId);\n }\n}\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport { Channel } from \"./Channel.js\";\nimport { Mixin } from \"./Mixin.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 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 * A thread of an announcement channel.\n */\nexport class AnnouncementThreadChannel extends Channel<ChannelType.AnnouncementThread> {}\n\nMixin(AnnouncementThreadChannel, [\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 { Channel } from \"./Channel.js\";\nimport { Mixin } from \"./Mixin.js\";\nimport { BaseChannelMixin } from \"./mixins/BaseChannelMixin.js\";\n\nexport interface BaseChannel extends BaseChannelMixin<ChannelType> {}\n\n/**\n * A channel of a type no other structure covers yet.\n */\nexport class BaseChannel extends Channel<ChannelType> {}\n\nMixin(BaseChannel, [BaseChannelMixin]);\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport { Channel } from \"./Channel.js\";\nimport { Mixin } from \"./Mixin.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 BaseChannelMixin<ChannelType.GuildCategory>,\n GuildChannelMixin<ChannelType.GuildCategory>,\n ChannelPermissionMixin<ChannelType.GuildCategory> {}\n\n/**\n * A guild category.\n */\nexport class CategoryChannel extends Channel<ChannelType.GuildCategory> {}\n\nMixin(CategoryChannel, [BaseChannelMixin, GuildChannelMixin, ChannelPermissionMixin]);\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 {\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 { BaseImageURLOptions, ImageURLOptions } from \"@discordjs/rest\";\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 { getGatewayClient } from \"../util/container.js\";\nimport { UserFlagsBitField } from \"../util/flags.js\";\nimport type { MessageCreateOptions, MessagePayloadResolvable } from \"../util/messages.js\";\nimport type { DMChannel } from \"./DMChannel.js\";\nimport type { Message } from \"./Message.js\";\nimport { kData, kPatch, snowflakeTimestamp, Structure } from \"./Structure.js\";\n\n/**\n * A Discord user.\n */\nexport class User extends Structure<CacheEntityTypes[\"users\"]> {\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 /**\n * The user's display name, if set.\n */\n public get globalName() {\n return this[kData].global_name;\n }\n\n /**\n * The name to show for this user: their {@link User.globalName} when set, their username otherwise.\n */\n public get displayName() {\n return this[kData].global_name ?? this[kData].username;\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 public get avatar() {\n return this[kData].avatar;\n }\n\n /**\n * The user's banner hash. Only fetched users have it: `undefined` means unknown, `null` means none.\n */\n public get banner(): string | null | undefined {\n return this[kData].banner;\n }\n\n /**\n * The user's accent color. Only fetched users have it: `undefined` means unknown, `null` means none.\n */\n public get accentColor(): number | null | undefined {\n return this[kData].accent_color;\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 bot() {\n return this[kData].bot ?? false;\n }\n\n public get system() {\n return this[kData].system ?? false;\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 getGatewayClient().users.createDM(this.id);\n }\n\n /**\n * Closes the direct message channel with the user.\n */\n public deleteDM(): Promise<DMChannel> {\n return getGatewayClient().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 getGatewayClient().users.send(this.id, options);\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 getGatewayClient().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}\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 \"../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 type { ChannelType } from \"discord-api-types/v10\";\nimport { Channel } from \"./Channel.js\";\nimport { Mixin } from \"./Mixin.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 BaseChannelMixin<ChannelType.DM>,\n DMChannelMixin<ChannelType.DM>,\n TextChannelMixin<ChannelType.DM> {}\n\n/**\n * A direct message channel.\n */\nexport class DMChannel extends Channel<ChannelType.DM> {}\n\nMixin(DMChannel, [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 type { ChannelType } from \"discord-api-types/v10\";\nimport { Channel } from \"./Channel.js\";\nimport { Mixin } from \"./Mixin.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 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 * A guild forum channel.\n */\nexport class ForumChannel extends Channel<ChannelType.GuildForum> {}\n\nMixin(ForumChannel, [\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 type { ChannelType } from \"discord-api-types/v10\";\nimport { Channel } from \"./Channel.js\";\nimport { Mixin } from \"./Mixin.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 BaseChannelMixin<ChannelType.GroupDM>,\n DMChannelMixin<ChannelType.GroupDM>,\n TextChannelMixin<ChannelType.GroupDM>,\n ChannelOwnerMixin<ChannelType.GroupDM>,\n GroupDMMixin<ChannelType.GroupDM> {}\n\n/**\n * A group direct message channel.\n */\nexport class GroupDMChannel extends Channel<ChannelType.GroupDM> {}\n\nMixin(GroupDMChannel, [\n BaseChannelMixin,\n DMChannelMixin,\n TextChannelMixin,\n ChannelOwnerMixin,\n GroupDMMixin,\n]);\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport { Channel } from \"./Channel.js\";\nimport { Mixin } from \"./Mixin.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 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 * A guild media channel.\n */\nexport class MediaChannel extends Channel<ChannelType.GuildMedia> {}\n\nMixin(MediaChannel, [\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 { Channel } from \"./Channel.js\";\nimport { Mixin } from \"./Mixin.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 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 * A private thread.\n */\nexport class PrivateThreadChannel extends Channel<ChannelType.PrivateThread> {}\n\nMixin(PrivateThreadChannel, [\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 type { ChannelType } from \"discord-api-types/v10\";\nimport { Channel } from \"./Channel.js\";\nimport { Mixin } from \"./Mixin.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 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 * A public thread.\n */\nexport class PublicThreadChannel extends Channel<ChannelType.PublicThread> {}\n\nMixin(PublicThreadChannel, [\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 { DiscordAPIError } from \"@discordjs/rest\";\nimport type { ChannelType } from \"discord-api-types/v10\";\nimport type { StageInstanceCreateOptions } from \"../managers/StageInstanceManager.js\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport type { StageInstance } from \"./StageInstance.js\";\nimport { Channel } from \"./Channel.js\";\nimport { Mixin } from \"./Mixin.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 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 * A guild stage channel.\n */\nexport class StageChannel extends Channel<ChannelType.GuildStageVoice> {\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 getGatewayClient().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 getGatewayClient().guilds.stageInstances(guildId).create(this.id, options);\n }\n}\n\nMixin(StageChannel, [\n BaseChannelMixin,\n TextChannelMixin,\n GuildChannelMixin,\n ChannelParentMixin,\n ChannelPermissionMixin,\n ChannelSlowmodeMixin,\n VoiceChannelMixin,\n ChannelWebhooksMixin,\n]);\n","import type { ChannelType } from \"discord-api-types/v10\";\nimport { Channel } from \"./Channel.js\";\nimport { Mixin } from \"./Mixin.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 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 * A guild text channel.\n */\nexport class TextChannel extends Channel<ChannelType.GuildText> {}\n\nMixin(TextChannel, [\n BaseChannelMixin,\n TextChannelMixin,\n GuildChannelMixin,\n ChannelParentMixin,\n ChannelPermissionMixin,\n ChannelSlowmodeMixin,\n ChannelTopicMixin,\n ChannelWebhooksMixin,\n ChannelThreadsMixin,\n]);\n","import {\n type ChannelType,\n type RESTPostAPISoundboardSendSoundJSONBody,\n} from \"discord-api-types/v10\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport type { SoundboardSound } from \"./SoundboardSound.js\";\nimport { Channel } from \"./Channel.js\";\nimport { Mixin } from \"./Mixin.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 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 * A guild voice channel.\n */\nexport class VoiceChannel extends Channel<ChannelType.GuildVoice> {\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 getGatewayClient().core.api.channels.sendSoundboardSound(this.id, body);\n }\n}\n\nMixin(VoiceChannel, [\n BaseChannelMixin,\n TextChannelMixin,\n GuildChannelMixin,\n ChannelParentMixin,\n ChannelPermissionMixin,\n ChannelSlowmodeMixin,\n VoiceChannelMixin,\n ChannelWebhooksMixin,\n]);\n","import type { CacheEntityName, CacheEntityTypes, EntityCache } from \"@wolfstar/plugin-cache\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport type { Guild } from \"../structures/Guild.js\";\nimport type { Structure } from \"../structures/Structure.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 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 * 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 Structure<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.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 (await this.getByKey(this.keyOf(data))) ?? this.hydrate(data);\n }\n\n /**\n * Gets a guild from the cache, to resolve the `guild` of a structure.\n *\n * @param guildId The ID of the guild, if the structure belongs to one.\n * @returns The guild, or `null` when there is no ID or the guild is not cached.\n */\n protected async cachedGuild(guildId: string | null | undefined): Promise<Guild | null> {\n return guildId ? ((await this.client.guilds.get(guildId)) ?? null) : 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.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.\n *\n * @param key The cache key of the entity.\n */\n protected async getByKey(key: string): Promise<Value | undefined> {\n const raw = await this.cache?.get(key);\n return raw === undefined ? undefined : this.hydrate(raw);\n }\n}\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport { applyGatewayDispatch } 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/AnnouncementChannel.js\";\nimport { AnnouncementThreadChannel } from \"../structures/AnnouncementThreadChannel.js\";\nimport { BaseChannel } from \"../structures/BaseChannel.js\";\nimport { isThreadChannelType, type ChannelRelations } from \"../structures/Channel.js\";\nimport { CategoryChannel } from \"../structures/CategoryChannel.js\";\nimport { DMChannel } from \"../structures/DMChannel.js\";\nimport { ForumChannel } from \"../structures/ForumChannel.js\";\nimport { GroupDMChannel } from \"../structures/GroupDMChannel.js\";\nimport { MediaChannel } from \"../structures/MediaChannel.js\";\nimport { PrivateThreadChannel } from \"../structures/PrivateThreadChannel.js\";\nimport { PublicThreadChannel } from \"../structures/PublicThreadChannel.js\";\nimport { StageChannel } from \"../structures/StageChannel.js\";\nimport { TextChannel } from \"../structures/TextChannel.js\";\nimport { VoiceChannel } from \"../structures/VoiceChannel.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// 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 async hydrate(data: CacheEntityTypes[\"channels\"]): Promise<AnyChannel> {\n return createChannel(data, { guild: await this.cachedGuild(channelGuildId(data)) });\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.\n *\n * @param channelId The ID of the channel.\n */\n public override async get(channelId: string): Promise<AnyChannel | undefined> {\n const channel = await super.get(channelId);\n if (channel) return channel;\n\n return this.client.threads.get(channelId);\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.core.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.core.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.core.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 {\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 { getGatewayClient } from \"../util/container.js\";\nimport type { Webhook } from \"./Webhook.js\";\nimport { SystemChannelFlagsBitField, type SystemChannelFlagsResolvable } from \"../util/flags.js\";\nimport { AnonymousGuild } from \"./AnonymousGuild.js\";\nimport type { GuildInvite } from \"./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 { kData, kPatch } from \"./Structure.js\";\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 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 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 getGatewayClient().guilds.emojis(this.id);\n }\n\n /**\n * The custom stickers of the guild.\n */\n public get stickers(): GuildStickerManager {\n return getGatewayClient().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 getGatewayClient().threads.fetchActive(this.id);\n }\n\n /**\n * Fetches the webhooks of the guild.\n */\n public fetchWebhooks(): Promise<Webhook[]> {\n return getGatewayClient().webhooks.fetchGuild(this.id);\n }\n\n /**\n * The scheduled events of the guild.\n */\n public get scheduledEvents(): GuildScheduledEventManager {\n return getGatewayClient().guilds.scheduledEvents(this.id);\n }\n\n /**\n * The live stages of the guild.\n */\n public get stageInstances(): StageInstanceManager {\n return getGatewayClient().guilds.stageInstances(this.id);\n }\n\n /**\n * The soundboard sounds of the guild.\n */\n public get soundboardSounds(): GuildSoundboardSoundManager {\n return getGatewayClient().guilds.soundboardSounds(this.id);\n }\n\n /**\n * The integrations of the guild.\n */\n public get integrations(): GuildIntegrationManager {\n return getGatewayClient().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 getGatewayClient().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 getGatewayClient().templates.create(this.id, options);\n }\n\n /**\n * Fetches the welcome screen of the guild.\n */\n public fetchWelcomeScreen(): Promise<WelcomeScreen> {\n return getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().guilds.editOnboarding(this.id, options);\n }\n\n /**\n * The bans of the guild.\n */\n public get bans(): GuildBanManager {\n return getGatewayClient().guilds.bans(this.id);\n }\n\n /**\n * The auto moderation rules of the guild.\n */\n public get autoModerationRules(): AutoModerationRuleManager {\n return getGatewayClient().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 getGatewayClient().guilds.fetchAuditLogs(this.id, options);\n }\n\n /**\n * The channels of the guild.\n */\n public get channels(): GuildChannelManager {\n return getGatewayClient().guilds.channels(this.id);\n }\n\n /**\n * The invites of the guild.\n */\n public get invites(): GuildInviteManager {\n return getGatewayClient().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 getGatewayClient().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 getGatewayClient().members.fetch(this.id, this.ownerId);\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 getGatewayClient().guilds.fetchPreview(this.id);\n }\n\n /**\n * Fetches the voice regions available to this guild.\n */\n public fetchVoiceRegions(): Promise<APIVoiceRegion[]> {\n return getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 type { GatewayClient } from \"../GatewayClient.js\";\nimport type { GuildEmoji } from \"../structures/GuildEmoji.js\";\nimport type { Role } from \"../structures/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 { EmojiURLOptions } from \"@discordjs/rest\";\nimport type { APIEmoji } from \"discord-api-types/v10\";\nimport { cdn } from \"../util/cdn.js\";\nimport { kData, snowflakeTimestamp, Structure } 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\n/**\n * An emoji: a custom one (with an ID) or a Unicode one.\n *\n * @typeParam Data The raw emoji data this structure wraps.\n */\nexport class Emoji<Data extends EmojiData = EmojiData> extends Structure<Data> {\n /**\n * The ID of the emoji, `null` for a Unicode emoji.\n */\n public get id(): string | null {\n return this[kData].id;\n }\n\n /**\n * The name of the emoji, or the emoji itself for a Unicode one. `null` for deleted custom emojis in reactions.\n */\n public get name(): string | null {\n return this[kData].name;\n }\n\n public 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 /**\n * When the custom emoji was created, `null` for a Unicode emoji.\n */\n public get createdTimestamp(): number | null {\n const { id } = this;\n return id ? snowflakeTimestamp(id) : null;\n }\n\n public get createdAt(): Date | null {\n const { createdTimestamp } = this;\n return createdTimestamp === null ? null : new Date(createdTimestamp);\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","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { GuildEmojiEditOptions } from \"../managers/GuildEmojiManager.js\";\nimport { GuildEmojiRoleManager } from \"../managers/GuildEmojiRoleManager.js\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport { Emoji } from \"./Emoji.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kPatch, kRelations } from \"./Structure.js\";\nimport { User } from \"./User.js\";\n\n/**\n * A custom emoji of a guild.\n */\nexport class GuildEmoji extends Emoji<CacheEntityTypes[\"emojis\"]> {\n declare public [kRelations]: { author?: User; guild?: Guild | null };\n\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(\n data: CacheEntityTypes[\"emojis\"],\n relations: { author?: User; guild?: Guild | null } = {},\n ) {\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 getGatewayClient().guilds.fetch(this.guildId);\n }\n\n /**\n * Whether the emoji is managed by an integration, e.g. Twitch.\n */\n public 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 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(getGatewayClient(), 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 getGatewayClient().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 getGatewayClient().guilds.emojis(this.guildId).fetchAuthor(this.id);\n }\n\n public async edit(options: GuildEmojiEditOptions): Promise<this> {\n const emoji = await getGatewayClient().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 getGatewayClient().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 { StickerExtension } from \"@discordjs/rest\";\nimport { StickerFormatType, type APISticker } from \"discord-api-types/v10\";\nimport type { GuildStickerEditOptions } from \"../managers/GuildStickerManager.js\";\nimport { cdn } from \"../util/cdn.js\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport type { StickerPack } from \"./StickerPack.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kPatch, kRelations, snowflakeTimestamp, Structure } from \"./Structure.js\";\nimport { User } from \"./User.js\";\n\n/**\n * A sticker: a standard one from a sticker pack, or a custom one of a guild.\n */\nexport class Sticker extends Structure<APISticker> {\n declare public [kRelations]: { user?: User; guild?: Guild | null };\n\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: { user?: User; guild?: Guild | null } = {}) {\n super(data, relations);\n }\n\n public override [kPatch](data: Readonly<Partial<APISticker>>): this {\n if (data.user) this.dropRelations(\"user\");\n return super[kPatch](data);\n }\n\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 description() {\n return this[kData].description;\n }\n\n /**\n * The autocomplete and suggestion tags of the sticker, comma separated.\n */\n public get tags() {\n return this[kData].tags;\n }\n\n /**\n * Whether it is a standard (pack) sticker or a guild one.\n */\n public get type() {\n return this[kData].type;\n }\n\n public get format() {\n return this[kData].format_type;\n }\n\n /**\n * Whether the sticker can be used, `false` when its guild lost the boosts it needs.\n */\n public 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 ? getGatewayClient().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 get createdTimestamp() {\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.format === StickerFormatType.GIF\n ? \"gif\"\n : this.format === 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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient()\n .guilds.stickers(this.requireGuildId())\n .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 getGatewayClient().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.format === sticker.format &&\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","import type { BaseImageURLOptions, ImageURLOptions } from \"@discordjs/rest\";\nimport type { APIGuildPreview } from \"discord-api-types/v10\";\nimport { cdn } from \"../util/cdn.js\";\nimport { GuildEmoji } from \"./GuildEmoji.js\";\nimport { Sticker } from \"./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 \"./User.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\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 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 { 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 { getGatewayClient } from \"../util/container.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { ReactionEmoji } from \"./ReactionEmoji.js\";\nimport { kData, kPatch, kRelations, Structure } from \"./Structure.js\";\n\n/**\n * An answer of an onboarding prompt, with the channels and roles it gives.\n */\nexport class GuildOnboardingPromptOption extends Structure<APIGuildOnboardingPromptOption> {\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 public get emoji(): ReactionEmoji | null {\n const { emoji } = this[kData];\n return 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 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) => new GuildOnboardingPromptOption(option));\n }\n}\n\n/**\n * The relations of a {@link GuildOnboarding}: its guild, when cached.\n */\nexport interface GuildOnboardingRelations {\n guild?: Guild | null;\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) => new GuildOnboardingPrompt(prompt));\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 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 getGatewayClient().guilds.editOnboarding(this.guildId, options);\n return this[kPatch](onboarding.toJSON());\n }\n}\n","import { GuildFeature, type APIGuildWelcomeScreen } from \"discord-api-types/v10\";\nimport type { GuildWelcomeScreenEditOptions } from \"../managers/GuildManager.js\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { ReactionEmoji } from \"./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 description: string;\n /**\n * The emoji shown next to the channel, if any.\n */\n emoji: ReactionEmoji | null;\n}\n\n/**\n * The relations of a {@link WelcomeScreen}: its guild, when cached.\n */\nexport interface WelcomeScreenRelations {\n guild?: Guild | null;\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 return this[kData].welcome_channels.map((channel) => ({\n channelId: channel.channel_id,\n description: channel.description,\n emoji:\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 getGatewayClient().guilds.editWelcomeScreen(this.guildId, options);\n return this[kPatch](screen.toJSON());\n }\n}\n","import type { ImageURLOptions } from \"@discordjs/rest\";\nimport { WebhookType, type APIWebhook } from \"discord-api-types/v10\";\nimport type {\n WebhookEditOptions,\n WebhookMessageCreateOptions,\n WebhookMessageEditOptions,\n WebhookThreadOptions,\n} from \"../managers/WebhookManager.js\";\nimport { cdn } from \"../util/cdn.js\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport type { MessagePayloadResolvable } from \"../util/messages.js\";\nimport type { Message } from \"./Message.js\";\nimport { kData, kPatch, snowflakeTimestamp, Structure } from \"./Structure.js\";\nimport { User } from \"./User.js\";\n\n/**\n * A webhook: an incoming one posting to a channel, a channel follower, or an application's.\n */\nexport class Webhook extends Structure<APIWebhook> {\n public get id() {\n return this[kData].id;\n }\n\n public get type() {\n return this[kData].type;\n }\n\n public get name(): string | null {\n return this[kData].name;\n }\n\n public get avatar(): string | null {\n return this[kData].avatar;\n }\n\n /**\n * The token to post with. Only incoming webhooks have one, and only their creator (or the guild's managers) see it.\n */\n public get token(): string | null {\n return this[kData].token ?? null;\n }\n\n public get guildId(): string | null {\n return this[kData].guild_id ?? null;\n }\n\n public get channelId(): string | null {\n return this[kData].channel_id;\n }\n\n public get applicationId(): string | null {\n return this[kData].application_id;\n }\n\n /**\n * The user who created the webhook, when the payload includes it.\n */\n public get owner(): User | null {\n const { user } = this[kData];\n return user ? new User(user) : null;\n }\n\n /**\n * The guild a channel follower webhook posts from.\n */\n public get sourceGuild() {\n return this[kData].source_guild ?? null;\n }\n\n /**\n * The channel a channel follower webhook posts from.\n */\n public get sourceChannel() {\n return this[kData].source_channel ?? null;\n }\n\n /**\n * The URL to post to, for webhooks with a token.\n */\n public get url(): string | null {\n const { token } = this;\n return (\n this[kData].url ?? (token ? `https://discord.com/api/webhooks/${this.id}/${token}` : null)\n );\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 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 * Sends a message through the webhook.\n *\n * @param options The message, or its content, and the thread to send it in.\n */\n public send(\n options: MessagePayloadResolvable<WebhookMessageCreateOptions> & WebhookThreadOptions,\n ): Promise<Message> {\n return getGatewayClient().webhooks.send(this.id, this.requireToken(), options);\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) : undefined;\n const webhook = await getGatewayClient().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 getGatewayClient().webhooks.delete(this.id, { token: this.token ?? undefined, reason });\n return this;\n }\n\n public fetchMessage(messageId: string, options?: WebhookThreadOptions): Promise<Message> {\n return getGatewayClient().webhooks.fetchMessage(\n this.id,\n this.requireToken(),\n messageId,\n options,\n );\n }\n\n public editMessage(\n messageId: string,\n options: MessagePayloadResolvable<WebhookMessageEditOptions> & WebhookThreadOptions,\n ): Promise<Message> {\n return getGatewayClient().webhooks.editMessage(\n this.id,\n this.requireToken(),\n messageId,\n options,\n );\n }\n\n public deleteMessage(messageId: string, options?: WebhookThreadOptions): Promise<void> {\n return getGatewayClient().webhooks.deleteMessage(\n this.id,\n this.requireToken(),\n messageId,\n options,\n );\n }\n\n private 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 {\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 { getGatewayClient } from \"../util/container.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kPatch, kRelations, Structure } 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\n/**\n * An auto moderation rule of a guild.\n */\nexport class AutoModerationRule extends Structure<APIAutoModerationRule> {\n declare public [kRelations]: AutoModerationRuleRelations;\n\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, 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 creatorId() {\n return this[kData].creator_id;\n }\n\n public get eventType() {\n return this[kData].event_type;\n }\n\n public get triggerType() {\n return this[kData].trigger_type;\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 enabled() {\n return this[kData].enabled;\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 getGatewayClient()\n .guilds.autoModerationRules(this.guildId)\n .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 getGatewayClient().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","import { autoModerationRuleKey, type CacheEntityTypes } 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/AutoModerationRule.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 async hydrate(\n data: CacheEntityTypes[\"autoModerationRules\"],\n ): Promise<AutoModerationRule> {\n return new AutoModerationRule(data, { guild: await this.cachedGuild(data.guild_id) });\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.core.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.core.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.core.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.core.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.core.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 { getGatewayClient } from \"../util/container.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kRelations, Structure } from \"./Structure.js\";\nimport { User } from \"./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 getGatewayClient().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 getGatewayClient().guilds.bans(this.guildId).remove(this.user.id, reason);\n return this;\n }\n}\n","import { banKey, 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/GuildBan.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 async hydrate(data: CacheEntityTypes[\"bans\"]): Promise<GuildBan> {\n const [user, guild] = await Promise.all([\n this.client.users.resolveData(data.user),\n this.cachedGuild(data.guild_id),\n ]);\n return new GuildBan(data, { user, guild });\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.core.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.core.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.core.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.core.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.core.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 type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kRelations, Structure } from \"./Structure.js\";\nimport { User } from \"./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}\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 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 getGatewayClient().guilds.integrations(this.guildId).delete(this.id, reason);\n return this;\n }\n}\n","import { integrationKey, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { Integration } from \"../structures/Integration.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 async hydrate(data: CacheEntityTypes[\"integrations\"]): Promise<Integration> {\n const [user, guild] = await Promise.all([\n data.user ? this.client.users.resolveData(data.user) : null,\n this.cachedGuild(data.guild_id),\n ]);\n return new Integration(data, { user, guild });\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.core.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.core.api.guilds.getIntegrations(this.guildId);\n return integrations.map((integration) => ({ ...integration, guild_id: this.guildId }));\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 { getGatewayClient } from \"../util/container.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kPatch, kRelations, snowflakeTimestamp, Structure } from \"./Structure.js\";\nimport { User } from \"./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 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 getGatewayClient()\n .guilds.scheduledEvents(this.guildId)\n .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 getGatewayClient()\n .guilds.scheduledEvents(this.guildId)\n .fetchSubscribers(this.id, options);\n }\n\n public async delete(reason?: string): Promise<this> {\n await getGatewayClient().guilds.scheduledEvents(this.guildId).delete(this.id, reason);\n return this;\n }\n}\n","import { scheduledEventKey, 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/GuildScheduledEvent.js\";\nimport type { GuildMember } from \"../structures/GuildMember.js\";\nimport type { User } from \"../structures/User.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 async hydrate(\n data: CacheEntityTypes[\"scheduledEvents\"],\n ): Promise<GuildScheduledEvent> {\n const [creator, guild, channel] = await Promise.all([\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 return new GuildScheduledEvent(data, {\n creator: creator ?? null,\n guild,\n channel: channel ?? null,\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.core.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.core.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.core.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.core.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.core.api.guilds.getScheduledEventUsers(\n this.guildId,\n eventId,\n {\n with_member: options.withMember ?? false,\n limit: options.limit,\n before: options.before,\n after: options.after,\n },\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.core.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 type { APISoundboardSound } from \"discord-api-types/v10\";\nimport type { SoundboardSoundEditOptions } from \"../managers/GuildSoundboardSoundManager.js\";\nimport { cdn } from \"../util/cdn.js\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kPatch, kRelations, snowflakeTimestamp, Structure } from \"./Structure.js\";\nimport { User } from \"./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\n/**\n * A soundboard sound: one of Discord's defaults, or a guild's.\n */\nexport class SoundboardSound extends Structure<APISoundboardSound> {\n declare public [kRelations]: SoundboardSoundRelations;\n\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, relations);\n }\n\n public override [kPatch](data: Readonly<Partial<APISoundboardSound>>): this {\n if (data.user) this.dropRelations(\"user\");\n return super[kPatch](data);\n }\n\n /**\n * The ID of the sound. Default sounds have small numeric IDs rather than snowflakes.\n */\n public get soundId() {\n return this[kData].sound_id;\n }\n\n public get name() {\n return this[kData].name;\n }\n\n /**\n * The volume, from 0 to 1.\n */\n public get volume() {\n return this[kData].volume;\n }\n\n public get emojiId(): string | null {\n return this[kData].emoji_id;\n }\n\n public get emojiName(): string | null {\n return this[kData].emoji_name;\n }\n\n /**\n * The ID of the guild, `null` for a default sound.\n */\n public get guildId(): string | null {\n return this[kData].guild_id ?? null;\n }\n\n /**\n * Whether the sound can be played; guild sounds can become unavailable when the guild loses boosts.\n */\n public get available() {\n return this[kData].available;\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 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 * When a guild sound was created. Default sounds have no snowflake, so theirs is `null`.\n */\n public get createdTimestamp(): number | null {\n return this.guildId ? snowflakeTimestamp(this.soundId) : null;\n }\n\n public edit(options: SoundboardSoundEditOptions): Promise<this> {\n return this.withGuild(async (guildId) => {\n const sound = await getGatewayClient()\n .guilds.soundboardSounds(guildId)\n .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 getGatewayClient().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","import { soundboardSoundKey, 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/SoundboardSound.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 async hydrate(\n data: CacheEntityTypes[\"soundboardSounds\"],\n ): Promise<SoundboardSound> {\n const [user, guild] = await Promise.all([\n data.user ? this.client.users.resolveData(data.user) : null,\n this.cachedGuild(data.guild_id),\n ]);\n return new SoundboardSound(data, { user, guild });\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.core.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.core.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.core.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.core.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.core.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 type { APIStageInstance, StageInstancePrivacyLevel } from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../managers/ChannelManager.js\";\nimport type { StageInstanceEditOptions } from \"../managers/StageInstanceManager.js\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport type { Guild } from \"./Guild.js\";\nimport type { GuildScheduledEvent } from \"./GuildScheduledEvent.js\";\nimport { kData, kPatch, kRelations, snowflakeTimestamp, Structure } 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}\n\n/**\n * A live stage: the topic of a stage channel while it is open.\n */\nexport class StageInstance extends Structure<APIStageInstance> {\n declare public [kRelations]: StageInstanceRelations;\n\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, 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 channelId() {\n return this[kData].channel_id;\n }\n\n public get topic() {\n return this[kData].topic;\n }\n\n public get privacyLevel() {\n return this[kData].privacy_level;\n }\n\n public get guildScheduledEventId(): string | null {\n return this[kData].guild_scheduled_event_id ?? 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 public get createdTimestamp() {\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 ? getGatewayClient().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 getGatewayClient()\n .guilds.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 getGatewayClient().guilds.stageInstances(this.guildId).delete(this.channelId, reason);\n return this;\n }\n}\n","import { stageInstanceKey, 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/StageInstance.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 async hydrate(data: CacheEntityTypes[\"stageInstances\"]): Promise<StageInstance> {\n const [guild, channel] = await Promise.all([\n this.cachedGuild(data.guild_id),\n this.client.channels.get(data.channel_id),\n ]);\n return new StageInstance(data, { guild, channel: channel ?? null });\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.core.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.core.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.core.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.core.api.stageInstances.get(channelId);\n }\n}\n","import { emojiKey, 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/GuildEmoji.js\";\nimport type { User } from \"../structures/User.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 async hydrate(data: CacheEntityTypes[\"emojis\"]): Promise<GuildEmoji> {\n const [author, guild] = await Promise.all([\n data.user ? this.client.users.resolveData(data.user) : undefined,\n this.cachedGuild(data.guild_id),\n ]);\n return new GuildEmoji(data, { author, guild });\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.core.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.core.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.core.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.core.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.core.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 {\n InviteType,\n type APIApplication,\n type APIExtendedInvite,\n type APIInviteChannel,\n type GatewayInviteCreateDispatchData,\n type InviteTargetType,\n} from \"discord-api-types/v10\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kPatch, kRelations, Structure } from \"./Structure.js\";\nimport { User } from \"./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}\n\n/**\n * The base of every invite: to a guild, to a group direct message, or a friend invite.\n *\n * @typeParam Data The raw invite data this structure wraps.\n */\nexport class BaseInvite<Data extends InviteData = InviteData> extends Structure<Data> {\n declare public [kRelations]: InviteRelations;\n\n protected override optimizeData(data: Partial<Data>): void {\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 super(data, relations);\n }\n\n public override [kPatch](data: Readonly<Partial<Data>>): this {\n if (data.inviter) this.dropRelations(\"inviter\");\n if (data.target_user) this.dropRelations(\"targetUser\");\n return super[kPatch](data);\n }\n\n public get code() {\n return this[kData].code;\n }\n\n /**\n * The URL of the invite.\n */\n public get url(): string {\n return `https://discord.gg/${this.code}`;\n }\n\n public 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, as the partial channel the API returns, if known.\n */\n public get channel(): APIInviteChannel | null {\n return 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 /**\n * What the invite targets in a voice channel: a stream, or an embedded application.\n */\n public get targetType(): InviteTargetType | null {\n return this[kData].target_type ?? 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 get approximateMemberCount(): number | null {\n return this[kData].approximate_member_count ?? null;\n }\n\n public get approximatePresenceCount(): number | null {\n return this[kData].approximate_presence_count ?? null;\n }\n\n /**\n * How many times the invite was used, `null` when the payload omits it.\n */\n public get uses(): number | null {\n return this[kData].uses ?? null;\n }\n\n /**\n * How many times the invite can be used, `0` for unlimited, `null` when the payload omits it.\n */\n public get maxUses(): number | null {\n return this[kData].max_uses ?? null;\n }\n\n /**\n * How long the invite lasts, in seconds, `0` for forever, `null` when the payload omits it.\n */\n public get maxAge(): number | null {\n return this[kData].max_age ?? null;\n }\n\n /**\n * Whether the invite only grants temporary membership, `null` when the payload omits it.\n */\n public get temporary(): boolean | null {\n return this[kData].temporary ?? null;\n }\n\n public 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 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 public toString(): string {\n return this.url;\n }\n\n public valueOf(): string {\n return this.code;\n }\n}\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 { getGatewayClient } from \"../util/container.js\";\nimport { BaseInvite } from \"./BaseInvite.js\";\nimport { InviteGuild } from \"./InviteGuild.js\";\nimport type { Guild } from \"./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 = getGatewayClient();\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 getGatewayClient().guilds.invites(guildId).delete(this.code, reason);\n return this;\n }\n}\n","import { inviteKey, 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/BaseInvite.js\";\nimport { GuildInvite } from \"../structures/GuildInvite.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 async hydrate(data: CacheEntityTypes[\"invites\"]): Promise<GuildInvite> {\n const { users } = this.client;\n const [inviter, targetUser, guild] = await Promise.all([\n data.inviter ? users.resolveData(data.inviter) : undefined,\n data.target_user ? users.resolveData(data.target_user) : undefined,\n this.cachedGuild(this.guildId),\n ]);\n return new GuildInvite(data, { inviter, targetUser, guild });\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.core.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.core.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.core.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.core.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.core.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 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/Sticker.js\";\nimport type { User } from \"../structures/User.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 async hydrate(data: CacheEntityTypes[\"stickers\"]): Promise<Sticker> {\n const [user, guild] = await Promise.all([\n data.user ? this.client.users.resolveData(data.user) : undefined,\n this.cachedGuild(data.guild_id),\n ]);\n return new Sticker(data, { user, guild });\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.core.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.core.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.core.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.core.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.core.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 { 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 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/AnonymousGuild.js\";\nimport { Guild, type GuildEditOptions } from \"../structures/Guild.js\";\nimport { GuildPreview } from \"../structures/GuildPreview.js\";\nimport { GuildAuditLogsEntry } from \"../structures/GuildAuditLogsEntry.js\";\nimport { GuildOnboarding } from \"../structures/GuildOnboarding.js\";\nimport type { Integration } from \"../structures/Integration.js\";\nimport { ReactionEmoji, type EmojiIdentifierResolvable } from \"../structures/ReactionEmoji.js\";\nimport { WelcomeScreen } from \"../structures/WelcomeScreen.js\";\nimport type { AutoModerationRule } from \"../structures/AutoModerationRule.js\";\nimport type { User } from \"../structures/User.js\";\nimport { Webhook } from \"../structures/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 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.core.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.core.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.core.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.core.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.core.api.guilds.getOnboarding(guildId);\n return new GuildOnboarding(onboarding, { guild: await this.cachedGuild(guildId) });\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.core.api.guilds.editOnboarding(guildId, body, {\n reason: options.reason,\n });\n return new GuildOnboarding(onboarding, { guild: await this.cachedGuild(guildId) });\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.core.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\n return {\n entries: log.audit_log_entries.map(\n (entry) =>\n new GuildAuditLogsEntry(\n { ...entry, guild_id: guildId },\n { executor: (entry.user_id && usersById.get(entry.user_id)) || null, guild },\n ),\n ),\n users,\n webhooks: log.webhooks.map((webhook) => new Webhook(webhook)),\n autoModerationRules: await Promise.all(\n log.auto_moderation_rules.map((rule) => rules.hydrate(rule)),\n ),\n threads: await Promise.all(\n log.threads.map((thread) => this.client.threads.hydrate(thread as APIThreadChannel)),\n ),\n integrations: log.integrations.map((integration) =>\n integrations.createStructure({ ...integration, guild_id: guildId }),\n ),\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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.api.guilds.get(guildId, { with_counts: true });\n }\n\n private store(guild: APIGuild): Promise<Guild> {\n return this._add(guild);\n }\n\n private async welcomeScreen(\n guildId: string,\n screen: APIGuildWelcomeScreen,\n ): Promise<WelcomeScreen> {\n return new WelcomeScreen(\n { ...screen, guild_id: guildId },\n { guild: await this.cachedGuild(guildId) },\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// 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/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 { getGatewayClient } from \"../util/container.js\";\nimport { GuildMemberFlagsBitField, type GuildMemberFlagsResolvable } from \"../util/flags.js\";\nimport type { MessageCreateOptions, MessagePayloadResolvable } from \"../util/messages.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 \"./DMChannel.js\";\nimport type { Message } from \"./Message.js\";\nimport type { Presence } from \"./Presence.js\";\nimport type { VoiceState } from \"./VoiceState.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kPatch, kRelations, Structure } from \"./Structure.js\";\nimport { User } from \"./User.js\";\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]: { user?: User; guild?: Guild | null };\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(\n data: CacheEntityTypes[\"members\"],\n relations: { user?: User; guild?: Guild | null } = {},\n ) {\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 getGatewayClient().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(\n getGatewayClient(),\n this.guildId,\n this.requireId(),\n this.roleIds,\n );\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 = getGatewayClient();\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 * 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 getGatewayClient().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 getGatewayClient().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 = getGatewayClient();\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 getGatewayClient().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 getGatewayClient().members.kick(this.guildId, this.requireId(), reason);\n return this;\n }\n\n public async ban(options?: BanOptions): Promise<this> {\n await getGatewayClient().members.ban(this.guildId, this.requireId(), options);\n return this;\n }\n\n public createDM(): Promise<DMChannel> {\n return getGatewayClient().users.createDM(this.requireId());\n }\n\n public deleteDM(): Promise<DMChannel> {\n return getGatewayClient().users.deleteDM(this.requireId());\n }\n\n public send(options: MessagePayloadResolvable<MessageCreateOptions>): Promise<Message> {\n return getGatewayClient().users.send(this.requireId(), options);\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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 { memberKey, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n type APIGuildMember,\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 } from \"../structures/GuildMember.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 * 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 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 public override async hydrate(data: CacheEntityTypes[\"members\"]): Promise<GuildMember> {\n const [user, guild] = await Promise.all([\n data.user ? this.client.users.resolveData(data.user) : undefined,\n this.cachedGuild(data.guild_id),\n ]);\n return new GuildMember(data, { user, guild });\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.core.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.core.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 * 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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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 // 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/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.core.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.core.api.channels.deleteOwnMessageReaction(\n this.channelId,\n this.messageId,\n this.emoji,\n );\n } else {\n await this.client.core.api.channels.deleteUserMessageReaction(\n this.channelId,\n this.messageId,\n this.emoji,\n userId,\n );\n }\n }\n}\n","import type { APIReaction } from \"discord-api-types/v10\";\nimport { ReactionUserManager } from \"../managers/ReactionUserManager.js\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport { ReactionEmoji } from \"./ReactionEmoji.js\";\nimport { kData, kPatch, Structure } from \"./Structure.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 * A reaction on a message: an emoji, how many users reacted with it, and whether the bot did.\n */\nexport class MessageReaction extends Structure<MessageReactionData> {\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 emoji(): ReactionEmoji {\n return new ReactionEmoji(this[kData].emoji);\n }\n\n /**\n * How many users reacted, super reactions included; `null` when unknown.\n */\n public 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 * Whether the bot reacted with a normal reaction.\n */\n public get me(): boolean {\n return this[kData].me;\n }\n\n /**\n * Whether the bot reacted with a super reaction.\n */\n public get meBurst(): boolean {\n return this[kData].me_burst;\n }\n\n /**\n * The colors of the super reaction animation, as `#rrggbb` strings.\n */\n public get burstColors(): readonly string[] {\n return this[kData].burst_colors;\n }\n\n /**\n * The users who reacted.\n */\n public get users(): ReactionUserManager {\n return new ReactionUserManager(\n getGatewayClient(),\n this.channelId,\n this.messageId,\n this.emoji.identifier,\n );\n }\n\n /**\n * Reacts with this emoji as the bot.\n */\n public async react(): Promise<this> {\n await getGatewayClient().messages.react(this.channelId, this.messageId, this.emoji.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 getGatewayClient().messages.removeReactionEmoji(\n this.channelId,\n this.messageId,\n this.emoji.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 getGatewayClient().messages.fetch(this.channelId, this.messageId, {\n force: true,\n });\n const identifier = this.emoji.identifier;\n const current = message.reactions.cache.find(\n (reaction) => reaction.emoji.identifier === 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 return this.emoji.id ?? this.emoji.name ?? \"\";\n }\n}\n","import type { APIReaction } from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { MessageReaction } from \"../structures/MessageReaction.js\";\nimport { ReactionEmoji, type EmojiIdentifierResolvable } from \"../structures/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 public constructor(\n client: GatewayClient,\n channelId: string,\n messageId: string,\n reactions: readonly APIReaction[],\n ) {\n this.client = client;\n this.channelId = channelId;\n this.messageId = messageId;\n this.#reactions = reactions;\n }\n\n /**\n * The reactions of the message.\n */\n public get cache(): MessageReaction[] {\n return this.#reactions.map(\n (reaction) =>\n new MessageReaction({\n ...reaction,\n channel_id: this.channelId,\n message_id: this.messageId,\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 this.cache.find((reaction) => reaction.emoji.identifier === identifier) ?? null;\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 type { APIAttachment } from \"discord-api-types/v10\";\nimport { AttachmentFlagsBitField } from \"../util/flags.js\";\nimport { kData, snowflakeTimestamp, Structure } from \"./Structure.js\";\n\n/**\n * A file attached to a message.\n */\nexport class Attachment extends Structure<APIAttachment> {\n public get id() {\n return this[kData].id;\n }\n\n /**\n * The name of the file.\n */\n public get name() {\n return this[kData].filename;\n }\n\n /**\n * The title of the file, if any.\n */\n public get title(): string | null {\n return this[kData].title ?? null;\n }\n\n /**\n * The description (alt text) of the file, if any.\n */\n public get description(): string | null {\n return this[kData].description ?? null;\n }\n\n /**\n * The media type of the file, if known.\n */\n public get contentType(): string | null {\n return this[kData].content_type ?? null;\n }\n\n /**\n * The size of the file, in bytes.\n */\n public get size() {\n return this[kData].size;\n }\n\n public get url() {\n return this[kData].url;\n }\n\n public get proxyURL() {\n return this[kData].proxy_url;\n }\n\n /**\n * The height of the file, if it is an image or a video.\n */\n public get height(): number | null {\n return this[kData].height ?? null;\n }\n\n /**\n * The width of the file, if it is an image or a video.\n */\n public get width(): number | null {\n return this[kData].width ?? null;\n }\n\n /**\n * Whether the attachment is ephemeral: it is deleted shortly after the message is, unless referenced elsewhere.\n */\n public 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 /**\n * The base64 encoded byte array of a voice message's sampled waveform.\n */\n public get waveform(): string | null {\n return this[kData].waveform ?? null;\n }\n\n public get flags() {\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","import 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 { kData, Structure } from \"./Structure.js\";\n\n/**\n * An embed of a received message. Use `@discordjs/builders`' `EmbedBuilder` to create embeds.\n */\nexport class Embed extends Structure<APIEmbed> {\n public get title(): string | null {\n return this[kData].title ?? null;\n }\n\n public get description(): string | null {\n return this[kData].description ?? null;\n }\n\n public get url(): string | null {\n return this[kData].url ?? null;\n }\n\n public get color(): number | null {\n return this[kData].color ?? null;\n }\n\n /**\n * The color as a `#rrggbb` string, `null` when the embed has none.\n */\n public get hexColor(): `#${string}` | null {\n const { color } = this;\n return color === null ? null : `#${color.toString(16).padStart(6, \"0\")}`;\n }\n\n /**\n * The ISO timestamp shown in the footer, if any.\n */\n public get timestamp(): string | null {\n return this[kData].timestamp ?? null;\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","import type { APIChannelMention, APIGuildMember, APIMessage, APIUser } from \"discord-api-types/v10\";\nimport { GuildMember } from \"./GuildMember.js\";\nimport { User } from \"./User.js\";\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. Roles and channels are IDs: resolve them with `client.roles` and\n * `client.channels`, since discord.js's synchronous cache lookups have no equivalent here.\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 public constructor(data: MessageMentionsData) {\n this.#data = data;\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 public get users(): User[] {\n return this.#data.mentions.map((user) => 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 return this.#data.mentions.flatMap(({ member, ...user }) =>\n member ? [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 const ids = new Set(this.crosspostedChannels.map((channel) => channel.id));\n for (const match of this.#data.content.matchAll(MessageMentions.ChannelsPattern)) {\n ids.add(match.groups!.id!);\n }\n\n return [...ids];\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 ? 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 [\n ...new Set(\n [...this.#data.content.matchAll(MessageMentions.UsersPattern)].map(\n (match) => match.groups!.id!,\n ),\n ),\n ];\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 type { APIPollAnswer } from \"discord-api-types/v10\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport { ReactionEmoji } from \"./ReactionEmoji.js\";\nimport { kData, Structure } from \"./Structure.js\";\nimport type { User } from \"./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 * An answer of a {@link Poll}.\n */\nexport class PollAnswer extends Structure<PollAnswerData> {\n public get id() {\n return this[kData].answer_id;\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 public get emoji(): ReactionEmoji | null {\n const { emoji } = this[kData].poll_media;\n return emoji ? 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 getGatewayClient().messages.fetchPollAnswerVoters(\n this.channelId,\n this.messageId,\n this.id,\n options,\n );\n }\n}\n","import type { APIPoll } from \"discord-api-types/v10\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport type { Message } from \"./Message.js\";\nimport { PollAnswer } from \"./PollAnswer.js\";\nimport { ReactionEmoji } from \"./ReactionEmoji.js\";\nimport { kData, Structure } 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 poll of a message.\n */\nexport class Poll extends Structure<PollData> {\n protected override optimizeData(data: Partial<PollData>): void {\n this.optimizeTimestamp(\"expiry\", data.expiry);\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 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 return new PollAnswer({\n ...answer,\n channel_id: this.channelId,\n message_id: this.messageId,\n count: count?.count,\n me_voted: count?.me_voted,\n });\n });\n }\n\n public get allowMultiselect() {\n return this[kData].allow_multiselect;\n }\n\n public get layoutType() {\n return this[kData].layout_type;\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 expiresTimestamp(): number | null {\n return this.optimizedTimestamp(\"expiry\");\n }\n\n public get expiresAt(): Date | null {\n const { expiresTimestamp } = this;\n return expiresTimestamp === null ? null : new Date(expiresTimestamp);\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 getGatewayClient().messages.endPoll(this.channelId, this.messageId);\n }\n}\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n ChannelType,\n MessageFlags,\n MessageReferenceType,\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 { getGatewayClient } from \"../util/container.js\";\nimport { isDeepEqual } from \"../util/equal.js\";\nimport { MessageFlagsBitField } from \"../util/flags.js\";\nimport type {\n MessageCreateOptions,\n MessageEditOptions,\n MessagePayloadResolvable,\n} from \"../util/messages.js\";\nimport type { PermissionsString } from \"../util/PermissionsBitField.js\";\nimport { Attachment } from \"./Attachment.js\";\nimport { Embed } from \"./Embed.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { GuildMember } from \"./GuildMember.js\";\nimport { MessageMentions } from \"./MessageMentions.js\";\nimport { Poll } from \"./Poll.js\";\nimport type { EmojiIdentifierResolvable } from \"./ReactionEmoji.js\";\nimport { kData, kPatch, kRelations, snowflakeTimestamp, Structure } from \"./Structure.js\";\nimport { User } from \"./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\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\n/**\n * A Discord message.\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 Structure<CacheEntityTypes[\"messages\"]> {\n declare public [kRelations]: MessageRelations;\n\n protected override optimizeData(data: Partial<CacheEntityTypes[\"messages\"]>): void {\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, relations);\n }\n\n public override [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 return super[kPatch](data);\n }\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 public get guildId(): string | null {\n return this[kData].guild_id ?? null;\n }\n\n public get content() {\n return this[kData].content;\n }\n\n public get type() {\n return this[kData].type;\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 return this[kRelations].author ?? new User(this[kData].author);\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 get webhookId(): string | null {\n return this[kData].webhook_id ?? null;\n }\n\n /**\n * The ID of the application that sent the message, for interaction responses and webhooks of an application.\n */\n public get applicationId(): string | null {\n return this[kData].application_id ?? null;\n }\n\n public get pinned() {\n return this[kData].pinned;\n }\n\n public get tts() {\n return this[kData].tts;\n }\n\n /**\n * The nonce the message was sent with, used to confirm it was sent.\n */\n public get nonce(): string | number | null {\n return this[kData].nonce ?? null;\n }\n\n /**\n * The position of the message in its thread, if it was sent in one.\n */\n public get position(): number | null {\n return this[kData].position ?? null;\n }\n\n public 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 public get mentions(): MessageMentions {\n return new MessageMentions(this[kData]);\n }\n\n public get reactions(): ReactionManager {\n return new ReactionManager(\n getGatewayClient(),\n this.channelId,\n this.id,\n this[kData].reactions ?? [],\n );\n }\n\n public get poll(): Poll | null {\n const { poll } = this[kData];\n return poll ? new Poll({ ...poll, channel_id: this.channelId, message_id: this.id }) : null;\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, when the payload includes it.\n */\n public get thread(): AnyThreadChannel | null {\n const { thread } = this[kData] as APIMessage & { thread?: APIThreadChannel };\n return thread ? getGatewayClient().threads.createStructure(thread) : null;\n }\n\n /**\n * The content with user mentions replaced by names, and `@everyone`/`@here` defused. Role and channel mentions are\n * kept, since resolving them would take the (asynchronous) cache.\n */\n public get cleanContent(): string {\n const members = new Map(\n this.mentions.members.map((member) => [member.id, member.displayName] as const),\n );\n const users = new Map(this.mentions.users.map((user) => [user.id, user.displayName] as const));\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(/@(everyone|here)/g, `@${ZeroWidthSpace}$1`);\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 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 getGatewayClient().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 ? getGatewayClient().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 getGatewayClient().messages.fetch(\n reference.channel_id ?? this.channelId,\n reference.message_id,\n );\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 = getGatewayClient();\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 * Fetches the message from the API and patches this structure with the result.\n */\n public async fetch(): Promise<this> {\n const message = await getGatewayClient().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 getGatewayClient().messages.edit(this.channelId, this.id, options);\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 = typeof options === \"string\" ? { content: options } : options;\n return getGatewayClient().messages.send(this.channelId, {\n ...payload,\n message_reference: {\n type: MessageReferenceType.Default,\n message_id: this.id,\n channel_id: this.channelId,\n fail_if_not_exists: false,\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 getGatewayClient().messages.forward(this.channelId, this.id, channelId);\n }\n\n public async delete(reason?: string): Promise<this> {\n await getGatewayClient().messages.delete(this.channelId, this.id, reason);\n return this;\n }\n\n public async pin(reason?: string): Promise<this> {\n await getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 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 getGatewayClient().members.fetchMe(guildId);\n return (await me.fetchPermissionsIn(this.channelId)).has(permission);\n }\n}\n","import type { RawFile } from \"@discordjs/rest\";\nimport type {\n RESTPatchAPIChannelMessageJSONBody,\n RESTPostAPIChannelMessageJSONBody,\n} from \"discord-api-types/v10\";\n\n/**\n * The options to send a message with: the REST body, plus the files to attach.\n */\nexport type MessageCreateOptions = RESTPostAPIChannelMessageJSONBody & { files?: RawFile[] };\n\n/**\n * The options to edit a message with: the REST body, plus the files to attach.\n */\nexport type MessageEditOptions = RESTPatchAPIChannelMessageJSONBody & { files?: RawFile[] };\n\n/**\n * Anything accepted where a message payload is expected: a string is the message content.\n */\nexport type MessagePayloadResolvable<Options extends { files?: RawFile[] }> = Options | string;\n\n/**\n * Splits message options into the REST body and the files, turning a plain string into `{ content }`.\n *\n * @param options The options, or the content.\n */\nexport function resolveMessageOptions<Options extends { files?: RawFile[] }>(\n options: MessagePayloadResolvable<Options>,\n): { body: Omit<Options, \"files\">; files: RawFile[] | undefined } {\n if (typeof options === \"string\") {\n return { body: { content: options } as unknown as Omit<Options, \"files\">, files: undefined };\n }\n\n const { files, ...body } = options;\n return { body, files };\n}\n","import { messageKey, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n MessageReferenceType,\n Routes,\n type APIMessage,\n type RESTGetAPIChannelMessagesPinsResult,\n type RESTPostAPIChannelMessagesThreadsJSONBody,\n type ThreadAutoArchiveDuration,\n} from \"discord-api-types/v10\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { Message } from \"../structures/Message.js\";\nimport { ReactionEmoji, type EmojiIdentifierResolvable } from \"../structures/ReactionEmoji.js\";\nimport { type User } from \"../structures/User.js\";\nimport {\n resolveMessageOptions,\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 async hydrate(data: CacheEntityTypes[\"messages\"]): Promise<Message> {\n const { author, member, guild_id: guildId } = data;\n const [resolvedAuthor, resolvedMember, guild, channel] = await Promise.all([\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 ]);\n return new Message(data, {\n author: resolvedAuthor,\n member: resolvedMember,\n guild,\n channel: channel ?? null,\n });\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.core.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 } = resolveMessageOptions(options);\n const message = await this.client.core.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 message_reference: {\n type: MessageReferenceType.Forward,\n channel_id: channelId,\n message_id: messageId,\n },\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 } = resolveMessageOptions(options);\n const message = await this.client.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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 { getGatewayClient } from \"../util/container.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 getGatewayClient().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 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 = getGatewayClient();\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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 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/Role.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 async hydrate(data: CacheEntityTypes[\"roles\"]): Promise<Role> {\n return new Role(data, { guild: await this.cachedGuild(data.guild_id) });\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.core.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.core.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.core.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.core.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.core.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.core.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.core.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 type { RawFile } from \"@discordjs/rest\";\nimport {\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/Message.js\";\nimport { Webhook } from \"../structures/Webhook.js\";\nimport { resolveId, type IdResolvable } from \"../util/channels.js\";\nimport { resolveMessageOptions, type MessagePayloadResolvable } from \"../util/messages.js\";\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 * The options to send a message through a webhook with: the REST body, plus the files to attach.\n */\nexport type WebhookMessageCreateOptions = RESTPostAPIWebhookWithTokenJSONBody & {\n files?: RawFile[];\n};\n\n/**\n * The options to edit a message sent by a webhook with: the REST body, plus the files to attach.\n */\nexport type WebhookMessageEditOptions = RESTPatchAPIWebhookWithTokenMessageJSONBody & {\n files?: RawFile[];\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 * 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, like discord.js's\n * `WebhookClient`: they work for 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.core.api.webhooks.get(webhookId, { token });\n return new Webhook(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.core.api.channels.getWebhooks(channelId);\n return webhooks.map((webhook) => new Webhook(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.core.api.guilds.getWebhooks(guildId);\n return webhooks.map((webhook) => new Webhook(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.core.api.channels.createWebhook(channelId, body, {\n reason: options.reason,\n });\n return new Webhook(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.core.api.webhooks.edit(webhookId, body, {\n token,\n reason: options.reason,\n });\n return new Webhook(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.core.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> & WebhookThreadOptions,\n ): Promise<Message> {\n const { threadId, ...payload } =\n typeof options === \"string\" ? { content: options, threadId: undefined } : options;\n const { body, files } = resolveMessageOptions<WebhookMessageCreateOptions>(payload);\n const message = await this.client.core.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.core.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> & WebhookThreadOptions,\n ): Promise<Message> {\n const { threadId, ...payload } =\n typeof options === \"string\" ? { content: options, threadId: undefined } : options;\n const { body, files } = resolveMessageOptions<WebhookMessageEditOptions>(payload);\n const message = await this.client.core.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.core.api.webhooks.deleteMessage(webhookId, token, messageId, {\n thread_id: options.threadId,\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 { getGatewayClient } from \"../util/container.js\";\nimport type { Guild } from \"./Guild.js\";\nimport { kData, kPatch, kRelations, Structure } from \"./Structure.js\";\nimport { User } from \"./User.js\";\n\n/**\n * The relations of a {@link GuildTemplate}: its source guild, when cached.\n */\nexport interface GuildTemplateRelations {\n guild?: Guild | null;\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 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 public get creator(): User {\n return 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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().templates.sync(this.guildId, this.code);\n return this[kPatch](template.toJSON());\n }\n\n public async delete(): Promise<this> {\n await getGatewayClient().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/Guild.js\";\nimport { GuildTemplate } from \"../structures/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.core.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.core.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.core.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.core.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.core.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.core.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.core.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 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 });\n }\n}\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { AnyChannel } from \"../managers/ChannelManager.js\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport type { Guild } from \"./Guild.js\";\nimport type { GuildMember } from \"./GuildMember.js\";\nimport { kData, kPatch, kRelations, Structure } from \"./Structure.js\";\nimport type { User } from \"./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}\n\n/**\n * The voice state of a guild member.\n */\nexport class VoiceState extends Structure<CacheEntityTypes[\"voiceStates\"]> {\n declare public [kRelations]: VoiceStateRelations;\n\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, relations);\n }\n\n public override [kPatch](data: Readonly<Partial<CacheEntityTypes[\"voiceStates\"]>>): this {\n if (data.member) this.dropRelations(\"member\");\n return super[kPatch](data);\n }\n\n /**\n * The ID of the guild this voice state is in, or `null` if the payload did not include it.\n */\n public get guildId(): string | null {\n return this[kData].guild_id ?? null;\n }\n\n /**\n * The ID of the voice or stage channel the member is connected to, or `null` if they are disconnected.\n */\n public get channelId(): string | null {\n return this[kData].channel_id;\n }\n\n /**\n * The ID of the user this voice state belongs to.\n */\n public get userId() {\n return this[kData].user_id;\n }\n\n /**\n * The ID of the member's voice session.\n */\n public get sessionId() {\n return this[kData].session_id;\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 deafened themselves.\n */\n public get selfDeaf() {\n return this[kData].self_deaf;\n }\n\n /**\n * Whether the member muted themselves.\n */\n public get selfMute() {\n return this[kData].self_mute;\n }\n\n /**\n * Whether the member's camera is enabled.\n */\n public get selfVideo() {\n return this[kData].self_video;\n }\n\n /**\n * Whether the member is streaming using \"Screen Share\".\n */\n public get streaming() {\n return this[kData].self_stream ?? false;\n }\n\n /**\n * Whether the member is suppressed from speaking. Only meaningful in stage channels.\n */\n public get suppress() {\n return this[kData].suppress;\n }\n\n /**\n * The timestamp at which the member requested to speak, or `null` if they did not. Only meaningful in stage\n * channels.\n */\n public get requestToSpeakTimestamp(): number | null {\n return this.optimizedTimestamp(\"request_to_speak_timestamp\");\n }\n\n /**\n * The time at which the member requested to speak, or `null` if they did not.\n */\n public get requestToSpeakAt(): Date | null {\n const { requestToSpeakTimestamp } = this;\n return requestToSpeakTimestamp === null ? null : new Date(requestToSpeakTimestamp);\n }\n\n /**\n * Whether the member is deafened, either by themselves or server-wide.\n */\n public 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 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 public fetchMember(): Promise<GuildMember> {\n return getGatewayClient().members.fetch(this.requireGuildId(), this.userId);\n }\n\n public fetchUser(): Promise<User> {\n return getGatewayClient().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 ? getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().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 getGatewayClient().core.api.voice.editVoiceState(this.requireGuildId(), body);\n } else {\n await getGatewayClient().core.api.voice.editUserVoiceState(\n this.requireGuildId(),\n target,\n body,\n );\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 = getGatewayClient();\n return (client.user?.id ?? client.id) === this.userId ? \"@me\" : this.userId;\n }\n}\n","import { voiceStateKey, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { VoiceState } from \"../structures/VoiceState.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 async hydrate(data: CacheEntityTypes[\"voiceStates\"]): Promise<VoiceState> {\n const { member, guild_id: guildId, user_id: userId } = data;\n const [resolvedMember, guild] = await Promise.all([\n member?.user && guildId\n ? this.client.members.resolveData({ ...member, guild_id: guildId })\n : guildId\n ? this.client.members.get(guildId, userId).then((cached) => cached ?? null)\n : null,\n this.cachedGuild(guildId),\n ]);\n return new VoiceState(data, { member: resolvedMember, guild });\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.core.api.voice.getVoiceState(guildId)\n : await client.core.api.voice.getUserVoiceState(guildId, target);\n return { ...state, guild_id: guildId };\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 type { ActivityType, GatewayActivity } from \"discord-api-types/v10\";\nimport { ActivityFlagsBitField } from \"../util/flags.js\";\nimport { RichPresenceAssets } from \"./RichPresenceAssets.js\";\nimport { kData, Structure } 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\n/**\n * An activity of a user's presence.\n */\nexport class Activity extends Structure<GatewayActivity> {\n /**\n * The name of the activity.\n */\n public get name() {\n return this[kData].name;\n }\n\n /**\n * The type of the activity.\n */\n public get type(): ActivityType {\n return this[kData].type;\n }\n\n /**\n * The URL of the stream, when the activity is being streamed.\n */\n public get url(): string | null {\n return this[kData].url ?? null;\n }\n\n /**\n * What the user is currently doing.\n */\n public 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 get state(): string | null {\n return this[kData].state ?? null;\n }\n\n /**\n * The ID of the application the activity belongs to.\n */\n public get applicationId(): string | null {\n return this[kData].application_id ?? 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 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 timestamp at which the activity was added to the user's session.\n */\n public get createdTimestamp(): number {\n return this[kData].created_at;\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","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport {\n PresenceUpdateStatus,\n type GatewayPresenceClientStatus,\n type PresenceUpdateReceiveStatus,\n} from \"discord-api-types/v10\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport { Activity } from \"./Activity.js\";\nimport type { Guild } from \"./Guild.js\";\nimport type { GuildMember } from \"./GuildMember.js\";\nimport { kData, kRelations, Structure } from \"./Structure.js\";\nimport type { User } from \"./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\n/**\n * The presence of a user in a guild: their status and activities.\n */\nexport class Presence extends Structure<CacheEntityTypes[\"presences\"]> {\n declare public [kRelations]: PresenceRelations;\n\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, 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 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 getGatewayClient().members.fetch(this.guildId, this.userId);\n }\n\n public fetchUser(): Promise<User> {\n return getGatewayClient().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","import { presenceKey, type CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport type { GatewayClient } from \"../GatewayClient.js\";\nimport { Presence } from \"../structures/Presence.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 async hydrate(data: CacheEntityTypes[\"presences\"]): Promise<Presence> {\n const [user, member, guild] = await Promise.all([\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 return new Presence(data, { user: user ?? null, member: member ?? null, guild });\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 { 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/AnnouncementThreadChannel.js\";\nimport type { PrivateThreadChannel } from \"../structures/PrivateThreadChannel.js\";\nimport type { PublicThreadChannel } from \"../structures/PublicThreadChannel.js\";\nimport type { ThreadMember } from \"../structures/ThreadMember.js\";\nimport {\n resolveMessageOptions,\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 async hydrate(data: CacheEntityTypes[\"threads\"]): Promise<AnyThreadChannel> {\n return createChannel(data, {\n guild: await this.cachedGuild(data.guild_id),\n }) as AnyThreadChannel;\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 = resolveMessageOptions(options.message);\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.core.api.channels.createThread(\n channelId,\n body as RESTPostAPIChannelThreadsJSONBody,\n undefined,\n { reason: options.reason },\n )\n : await this.client.core.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.core.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.core.api.channels.getJoinedPrivateArchivedThreads(channelId, query)\n : await this.client.core.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.core.api.channels.get(threadId) as Promise<APIThreadChannel>;\n }\n}\n","import type { CacheEntityTypes } from \"@wolfstar/plugin-cache\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport type { GuildMember } from \"./GuildMember.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}\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 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 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 * 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 getGatewayClient().threadMembers.remove(threadId, id);\n return this;\n }\n}\n","import { threadMemberKey, 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/ThreadMember.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 async hydrate(data: CacheEntityTypes[\"threadMembers\"]): Promise<ThreadMember> {\n const { member, guild_id: guildId, user_id: userId } = data;\n let guildMember = null;\n if (member?.user && guildId) {\n guildMember = await this.client.members.resolveData({ ...member, guild_id: guildId });\n } else if (guildId && userId) {\n guildMember = (await this.client.members.get(guildId, userId)) ?? null;\n }\n\n return new ThreadMember(data, { guildMember });\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.core.api.rest.get(Routes.threadMembers(threadId, userId), {\n query: new URLSearchParams({ with_member: \"true\" }),\n })) as APIThreadMember)\n : await this.client.core.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.core.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.core.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.core.api.threads.join(threadId);\n else await this.client.core.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.core.api.threads.leave(threadId);\n else await this.client.core.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.core.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/DMChannel.js\";\nimport type { Message } from \"../structures/Message.js\";\nimport { User } from \"../structures/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.core.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.core.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.core.api.users.get(userId);\n }\n}\n","import { InviteType } from \"discord-api-types/v10\";\nimport { BaseInvite, type InviteData } 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 */\nexport function createInvite(data: InviteData): BaseInvite {\n switch (data.type ?? (data.guild_id || data.guild ? InviteType.Guild : InviteType.Friend)) {\n case InviteType.Guild:\n return new GuildInvite(data);\n case InviteType.GroupDM:\n return new GroupDMInvite(data);\n default:\n return new BaseInvite(data);\n }\n}\n","import {\n GuildWidgetStyle,\n RouteBases,\n Routes,\n type APIGuildWidget,\n type APIGuildWidgetMember,\n} from \"discord-api-types/v10\";\nimport { getGatewayClient } from \"../util/container.js\";\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 getGatewayClient().fetchGuildWidget(this.id);\n }\n}\n","import type { BaseImageURLOptions } from \"@discordjs/rest\";\nimport type { APIStickerPack } from \"discord-api-types/v10\";\nimport { cdn } from \"../util/cdn.js\";\nimport { Sticker } from \"./Sticker.js\";\nimport { kData, snowflakeTimestamp, Structure } from \"./Structure.js\";\n\n/**\n * A pack of standard stickers.\n */\nexport class StickerPack extends Structure<APIStickerPack> {\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 description() {\n return this[kData].description;\n }\n\n /**\n * The ID of the pack's SKU.\n */\n public get skuId() {\n return this[kData].sku_id;\n }\n\n public get coverStickerId(): string | null {\n return this[kData].cover_sticker_id ?? null;\n }\n\n public get bannerId(): string | null {\n return this[kData].banner_asset_id ?? 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 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 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","import type { GatewayAutoModerationActionExecutionDispatchData } from \"discord-api-types/v10\";\nimport type { AnyChannel } from \"../managers/ChannelManager.js\";\nimport { getGatewayClient } from \"../util/container.js\";\nimport type { AutoModerationRule } from \"./AutoModerationRule.js\";\nimport type { Guild } from \"./Guild.js\";\nimport type { GuildMember } from \"./GuildMember.js\";\nimport { kData, kRelations, Structure } from \"./Structure.js\";\nimport type { User } from \"./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}\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 public fetchRule(): Promise<AutoModerationRule> {\n return getGatewayClient().guilds.autoModerationRules(this.guildId).fetch(this.ruleId);\n }\n\n public fetchMember(): Promise<GuildMember> {\n return getGatewayClient().members.fetch(this.guildId, this.userId);\n }\n\n public async fetchChannel(): Promise<AnyChannel | null> {\n const { channelId } = this;\n return channelId ? getGatewayClient().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 { getGatewayClient } from \"../util/container.js\";\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 getGatewayClient().core.api.users.edit(body);\n await getGatewayClient().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 = getGatewayClient().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 { getGatewayClient } from \"../util/container.js\";\nimport { GuildMember } from \"./GuildMember.js\";\nimport { kData, Structure } from \"./Structure.js\";\nimport type { User } from \"./User.js\";\n\n/**\n * A user starting to type in a channel, carried by the `typingStart` event.\n */\nexport class Typing extends Structure<GatewayTypingStartDispatchData> {\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 typing member, when the channel is in a guild.\n */\n public get member(): GuildMember | null {\n const { member, guild_id: guildId } = this[kData];\n // TODO: use GuildMemberMananger to resolve the member instead this\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 getGatewayClient().channels.fetch(this.channelId);\n }\n\n /**\n * Fetches the typing user.\n */\n public fetchUser(): Promise<User> {\n return getGatewayClient().users.fetch(this.userId);\n }\n}\n","import {\n GatewayDispatchEvents,\n type APIPartialEmoji,\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/AutoModerationActionExecution.js\";\nimport { ClientUser } from \"../structures/ClientUser.js\";\nimport { GuildAuditLogsEntry } from \"../structures/GuildAuditLogsEntry.js\";\nimport { kPatch } from \"../structures/Structure.js\";\nimport type { GuildEmoji } from \"../structures/GuildEmoji.js\";\nimport { GuildInvite } from \"../structures/GuildInvite.js\";\nimport type { Sticker } from \"../structures/Sticker.js\";\nimport { MessageReaction } from \"../structures/MessageReaction.js\";\nimport { PollAnswer } from \"../structures/PollAnswer.js\";\nimport type { ThreadMember } from \"../structures/ThreadMember.js\";\nimport { Typing } from \"../structures/Typing.js\";\nimport type { GatewayEventMap, GatewayEventName } from \"./events.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: \"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: \"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: \"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: \"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: \"channelCreate\",\n build: async (client, data) => [await client.channels.hydrate(data)],\n },\n [GatewayDispatchEvents.ChannelUpdate]: {\n event: \"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: \"channelDelete\",\n build: async (client, data) => [await client.channels.hydrate(data)],\n },\n\n [GatewayDispatchEvents.ChannelPinsUpdate]: {\n event: \"channelPinsUpdate\",\n build: (_client, data) => [data],\n },\n [GatewayDispatchEvents.WebhooksUpdate]: {\n event: \"webhooksUpdate\",\n build: (_client, data) => [data],\n },\n\n [GatewayDispatchEvents.ThreadCreate]: {\n event: \"threadCreate\",\n build: async (client, data) => [await client.threads.hydrate(data)],\n },\n [GatewayDispatchEvents.ThreadUpdate]: {\n event: \"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: \"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: \"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: \"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 ?? null,\n await client.threadMembers.hydrate(data),\n ],\n },\n [GatewayDispatchEvents.ThreadMembersUpdate]: {\n event: \"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 previous ?? [],\n (await cachedOrUndefined(client.threads.get(data.id))) ?? null,\n data,\n ],\n },\n\n [GatewayDispatchEvents.MessageCreate]: {\n event: \"messageCreate\",\n build: async (client, data) => [await client.messages.hydrate(data)],\n },\n [GatewayDispatchEvents.MessageUpdate]: {\n event: \"messageUpdate\",\n before: (client, data) => client.messages.get(data.channel_id, data.id),\n build: async (client, data, previous) => [\n previous ?? null,\n await client.messages.hydrate(data),\n ],\n },\n [GatewayDispatchEvents.MessageDelete]: {\n event: \"messageDelete\",\n before: (client, data) => client.messages.get(data.channel_id, data.id),\n build: (_client, data, previous) => [previous ?? null, data],\n },\n [GatewayDispatchEvents.MessageDeleteBulk]: {\n event: \"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) => [previous ?? [], data],\n },\n\n [GatewayDispatchEvents.MessageReactionAdd]: {\n event: \"messageReactionAdd\",\n build: async (client, data) => [\n await reactionOf(client, data),\n (await cachedOrUndefined(client.users.get(data.user_id))) ?? null,\n { userId: data.user_id, type: data.type, burst: data.burst },\n ],\n },\n [GatewayDispatchEvents.MessageReactionRemove]: {\n event: \"messageReactionRemove\",\n build: async (client, data) => [\n await reactionOf(client, data),\n (await cachedOrUndefined(client.users.get(data.user_id))) ?? null,\n { userId: data.user_id, type: data.type, burst: data.burst },\n ],\n },\n [GatewayDispatchEvents.MessageReactionRemoveAll]: {\n event: \"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))) ?? null,\n previous ?? [],\n data,\n ],\n },\n [GatewayDispatchEvents.MessageReactionRemoveEmoji]: {\n event: \"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: (_client, data, previous: MessageReaction | undefined) => [\n previous ?? partialReaction(data),\n ],\n },\n [GatewayDispatchEvents.MessagePollVoteAdd]: {\n event: \"messagePollVoteAdd\",\n build: async (client, data) => [await pollAnswerOf(client, data), data.user_id],\n },\n [GatewayDispatchEvents.MessagePollVoteRemove]: {\n event: \"messagePollVoteRemove\",\n build: async (client, data) => [await pollAnswerOf(client, data), data.user_id],\n },\n\n [GatewayDispatchEvents.GuildMemberAdd]: {\n event: \"guildMemberAdd\",\n build: async (client, data) => [await client.members.hydrate(data)],\n },\n [GatewayDispatchEvents.GuildMemberUpdate]: {\n event: \"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 ?? null,\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: \"guildMemberRemove\",\n before: (client, data) => client.members.get(data.guild_id, data.user.id),\n build: (_client, data, previous) => [previous ?? null, data],\n },\n\n [GatewayDispatchEvents.GuildRoleCreate]: {\n event: \"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: \"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: \"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: \"inviteCreate\",\n build: async (client, data) => [\n data.guild_id\n ? await client.guilds.invites(data.guild_id).hydrate(data)\n : new GuildInvite(data),\n ],\n },\n [GatewayDispatchEvents.InviteDelete]: {\n event: \"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: \"typingStart\",\n build: (_client, data) => [new Typing(data)],\n },\n [GatewayDispatchEvents.VoiceStateUpdate]: {\n event: \"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: \"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: \"guildScheduledEventCreate\",\n build: async (client, data) => [\n await client.guilds.scheduledEvents(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.GuildScheduledEventUpdate]: {\n event: \"guildScheduledEventUpdate\",\n before: (client, data) => client.guilds.scheduledEvents(data.guild_id).get(data.id),\n build: async (client, data, previous) => [\n previous ?? null,\n await client.guilds.scheduledEvents(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.GuildScheduledEventDelete]: {\n event: \"guildScheduledEventDelete\",\n build: async (client, data) => [\n await client.guilds.scheduledEvents(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.GuildScheduledEventUserAdd]: {\n event: \"guildScheduledEventUserAdd\",\n build: async (client, data) => [\n (await cachedOrUndefined(\n client.guilds.scheduledEvents(data.guild_id).get(data.guild_scheduled_event_id),\n )) ?? null,\n (await cachedOrUndefined(client.users.get(data.user_id))) ?? null,\n data,\n ],\n },\n [GatewayDispatchEvents.GuildScheduledEventUserRemove]: {\n event: \"guildScheduledEventUserRemove\",\n build: async (client, data) => [\n (await cachedOrUndefined(\n client.guilds.scheduledEvents(data.guild_id).get(data.guild_scheduled_event_id),\n )) ?? null,\n (await cachedOrUndefined(client.users.get(data.user_id))) ?? null,\n data,\n ],\n },\n [GatewayDispatchEvents.StageInstanceCreate]: {\n event: \"stageInstanceCreate\",\n build: async (client, data) => [\n await client.guilds.stageInstances(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.StageInstanceUpdate]: {\n event: \"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: \"stageInstanceDelete\",\n build: async (client, data) => [\n await client.guilds.stageInstances(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.GuildSoundboardSoundCreate]: {\n event: \"guildSoundboardSoundCreate\",\n build: async (client, data) => [\n await client.guilds.soundboardSounds(data.guild_id!).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.GuildSoundboardSoundUpdate]: {\n event: \"guildSoundboardSoundUpdate\",\n before: (client, data) => client.guilds.soundboardSounds(data.guild_id!).get(data.sound_id),\n build: async (client, data, previous) => [\n previous ?? null,\n await client.guilds.soundboardSounds(data.guild_id!).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.GuildSoundboardSoundDelete]: {\n event: \"guildSoundboardSoundDelete\",\n before: (client, data) => client.guilds.soundboardSounds(data.guild_id).get(data.sound_id),\n build: (_client, data, previous) => [previous ?? null, data],\n },\n [GatewayDispatchEvents.GuildSoundboardSoundsUpdate]: {\n event: \"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: \"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: \"guildBanAdd\",\n build: async (client, data) => [await client.guilds.bans(data.guild_id).hydrate(data)],\n },\n [GatewayDispatchEvents.GuildBanRemove]: {\n event: \"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: \"guildAuditLogEntryCreate\",\n build: async (client, data) => {\n const [executor, guild] = await Promise.all([\n data.user_id ? cachedOrUndefined(client.users.get(data.user_id)) : undefined,\n cachedOrUndefined(client.guilds.get(data.guild_id)),\n ]);\n return [new GuildAuditLogsEntry(data, { executor: executor ?? null, guild: guild ?? null })];\n },\n },\n [GatewayDispatchEvents.AutoModerationRuleCreate]: {\n event: \"autoModerationRuleCreate\",\n build: async (client, data) => [\n await client.guilds.autoModerationRules(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.AutoModerationRuleUpdate]: {\n event: \"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: \"autoModerationRuleDelete\",\n build: async (client, data) => [\n await client.guilds.autoModerationRules(data.guild_id).hydrate(data),\n ],\n },\n [GatewayDispatchEvents.GuildIntegrationsUpdate]: {\n event: \"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: \"integrationCreate\",\n build: async (client, data) => [await client.guilds.integrations(data.guild_id).hydrate(data)],\n },\n [GatewayDispatchEvents.IntegrationUpdate]: {\n event: \"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: \"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: \"autoModerationActionExecution\",\n build: async (client, data) => {\n const [user, guild] = await Promise.all([\n cachedOrUndefined(client.users.get(data.user_id)),\n cachedOrUndefined(client.guilds.get(data.guild_id)),\n ]);\n return [\n new AutoModerationActionExecution(data, { user: user ?? null, guild: guild ?? null }),\n ];\n },\n },\n [GatewayDispatchEvents.VoiceServerUpdate]: {\n event: \"voiceServerUpdate\",\n build: (_client, data) => [data],\n },\n\n [GatewayDispatchEvents.UserUpdate]: {\n event: \"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 ?? null, client.user];\n }\n\n return [previous ?? null, 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(previous, current, \"emojiCreate\", \"emojiUpdate\", \"emojiDelete\");\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(previous, current, \"stickerCreate\", \"stickerUpdate\", \"stickerDelete\");\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: string,\n update: string,\n remove: string,\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 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(data);\n return message.reactions.resolve(data.emoji) ?? partialReaction(data, true);\n}\n\nfunction partialReaction(data: ReactionData, emptied = false): MessageReaction {\n return new MessageReaction({\n channel_id: data.channel_id,\n message_id: data.message_id,\n emoji: data.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}\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 new PollAnswer({\n answer_id: data.answer_id,\n poll_media: {},\n channel_id: data.channel_id,\n message_id: data.message_id,\n })\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","/**\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","import {\n WebSocketManager,\n WebSocketShardEvents,\n type OptionalWebSocketManagerOptions,\n type ShardRange,\n} from \"@discordjs/ws\";\nimport { Client as DiscordCoreClient } from \"@discordjs/core\";\nimport { Client, container, type ClientOptions } from \"@wolfstar/http-framework\";\nimport { applyGatewayDispatch, type Cache } from \"@wolfstar/plugin-cache\";\nimport {\n GatewayDispatchEvents,\n GatewayOpcodes,\n type APIVoiceRegion,\n type GatewayDispatchPayload,\n type GatewayReadyDispatchData,\n type GatewayIntentBits,\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/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/BaseInvite.js\";\nimport type { ClientUser } from \"./structures/ClientUser.js\";\nimport { createInvite } from \"./structures/GroupDMInvite.js\";\nimport { Sticker } from \"./structures/Sticker.js\";\nimport type { Webhook } from \"./structures/Webhook.js\";\nimport type { GuildTemplate } from \"./structures/GuildTemplate.js\";\nimport { Widget } from \"./structures/Widget.js\";\nimport { StickerPack } from \"./structures/StickerPack.js\";\nimport { ActionsManager } from \"./actions/Action.js\";\nimport { dispatchPartition, DispatchQueue, type DispatchQueueStats } from \"./util/DispatchQueue.js\";\nimport { DispatchTimeoutError } from \"./util/errors.js\";\n\nexport interface GatewayClientOptions extends ClientOptions {\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 * 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\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/**\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 underlying `@discordjs/ws` manager, handling the shards' connections, resumes, and identify rate limits.\n */\n public readonly gateway: WebSocketManager;\n\n /** The discord.js core client, sharing this client's REST and gateway transports. */\n public 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 // 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 public constructor(options: GatewayClientOptions) {\n super(options);\n\n this.cache = options.cache;\n this.cacheFailure = options.cacheFailure ?? \"skip\";\n this.dispatchTimeout = options.dispatchTimeout === undefined ? 30_000 : options.dispatchTimeout;\n this.#shardCount = options.shardCount ?? null;\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 // The base client validated the token already, and scrubs it from `this.options`.\n token: (options.discordToken ?? process.env.DISCORD_TOKEN)!,\n intents: options.intents as GatewayIntentBits,\n rest: container.rest,\n shardCount: options.shardCount ?? null,\n shardIds: options.shardIds ?? null,\n });\n this.core = new DiscordCoreClient({ gateway: this.gateway, rest: container.rest });\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 public async destroy(): Promise<void> {\n await this.gateway.destroy();\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.core.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.core.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.core.api.invites.get(resolved, {\n with_counts: options.withCounts ?? true,\n guild_scheduled_event_id: options.guildScheduledEventId,\n });\n return createInvite(invite);\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.core.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.core.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.core.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 * Processes a gateway dispatch: emits it as `raw`, writes it into the cache, and emits the matching\n * {@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\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) await this.reconcileGuilds(payload.d, shardId);\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 await action?.handle(payload.d, state, shardId);\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 // 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,SA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