UNPKG

nyxo.js

Version:

Complete Next-Generation Discord Bot Framework with Type-Safe API, Auto-Caching, and Real-Time Gateway

1,177 lines (1,175 loc) 417 kB
import "reflect-metadata"; import * as _nyxojs_core56 from "@nyxojs/core"; import * as _nyxojs_core33 from "@nyxojs/core"; import * as _nyxojs_core52 from "@nyxojs/core"; import * as _nyxojs_core53 from "@nyxojs/core"; import * as _nyxojs_core15 from "@nyxojs/core"; import * as _nyxojs_core5 from "@nyxojs/core"; import * as _nyxojs_core10 from "@nyxojs/core"; import * as _nyxojs_core30 from "@nyxojs/core"; import * as _nyxojs_core50 from "@nyxojs/core"; import * as _nyxojs_core2 from "@nyxojs/core"; import { ActionRowEntity, AnyChannelEntity, AnyInteractionCommandOptionEntity, AnyInteractionEntity, AnySimpleInteractionCommandOptionEntity, ApplicationCommandInteractionDataEntity, ApplicationCommandType, ApplicationEntity, ApplicationFlags, ApplicationIntegrationType, ApplicationRoleConnectionEntity, AttachmentEntity, AutoArchiveDuration, AutoModerationActionEntity, AutoModerationEventType, AutoModerationKeywordMatchType, AutoModerationKeywordPresetType, AutoModerationRuleEntity, AutoModerationRuleTriggerMetadataEntity, AutoModerationRuleTriggerType, BanEntity, BitField, BitwisePermissionFlags, ChannelEntity, ChannelFlags, ChannelType, ComponentType, ConnectionEntity, ConnectionService, DefaultReactionEntity, EmojiEntity, EntitlementEntity, EntitlementType, FollowedChannelEntity, FormattedChannel, FormattedCustomEmoji, FormattedRole, FormattedUser, ForumLayoutType, ForumTagEntity, GuildApplicationCommandPermissionEntity, GuildEntity, GuildFeature, GuildMemberEntity, GuildMemberFlags, GuildOnboardingEntity, GuildScheduledEventEntity, GuildScheduledEventStatus, GuildScheduledEventType, GuildWidgetEntity, GuildWidgetSettingsEntity, IntegrationEntity, InteractionCallbackAutocompleteEntity, InteractionCallbackMessagesEntity, InteractionCallbackModalEntity, InteractionCallbackResponseEntity, InteractionContextType, InteractionDataEntity, InteractionEntity, InteractionResolvedDataEntity, InteractionResponseEntity, InteractionType, InviteEntity, InviteTargetType, InviteType, InviteWithMetadataEntity, Link, Locale, MessageComponentInteractionDataEntity, MessageEntity, MessageFlags, MessageType, ModalSubmitInteractionDataEntity, OverwriteEntity, RoleEntity, RoleFlags, SelectMenuOptionEntity, Snowflake, SortOrderType, SoundboardSoundEntity, StageInstanceEntity, StageInstancePrivacyLevel, StickerEntity, StickerFormatType, StickerItemEntity, StickerPackEntity, StickerType, SubscriptionEntity, SubscriptionStatus, SystemChannelFlags, ThreadMemberEntity, ThreadMetadataEntity, UserEntity, UserFlags, VideoQualityMode, VoiceRegionEntity, VoiceStateEntity, WebhookEntity, WebhookType, WelcomeScreenEntity } from "@nyxojs/core"; import * as _nyxojs_gateway29 from "@nyxojs/gateway"; import * as _nyxojs_gateway0 from "@nyxojs/gateway"; import { AutoModerationActionExecutionEntity, ChannelPinsUpdateEntity, Gateway, GatewayEvents, GatewayReceiveEvents, GuildAuditLogEntryCreateEntity, GuildBanEntity, GuildCreateEntity, GuildEmojisUpdateEntity, GuildMembersChunkEntity, GuildScheduledEventUserAddRemoveEntity, GuildStickersUpdateEntity, InviteCreateEntity, MessageCreateEntity, MessagePollVoteEntity, MessageReactionAddEntity, MessageReactionRemoveAllEntity, MessageReactionRemoveEmojiEntity, MessageReactionRemoveEntity, PresenceEntity, ReadyEntity, ThreadListSyncEntity, ThreadMembersUpdateEntity, TypingStartEntity, VoiceChannelEffectSendAnimationType, VoiceChannelEffectSendEntity, VoiceServerUpdateEntity } from "@nyxojs/gateway"; import * as _nyxojs_rest32 from "@nyxojs/rest"; import { ActivityInstanceEntity, AnimatedImageOptions, ApplicationCoverUrl, ApplicationEmojiUpdateOptions, ApplicationIconUrl, ApplicationUpdateOptions, AutoModerationRuleUpdateOptions, AvatarDecorationUrl, ChannelInviteCreateOptions, ChannelPermissionUpdateOptions, ChannelPositionsUpdateOptions, CreateMessageSchema, DefaultUserAvatarUrl, EditMessageSchema, EmojiUrl, EntitlementOwnerType, EventUpdateOptions, EventUsersFetchParams, FileInput, ForumThreadCreateOptions, GetGuildPruneCountQuerySchema, GroupDmCreateOptions, GuildBanCreateOptions, GuildBansBulkOptions, GuildBansBulkResponse, GuildBansFetchParams, GuildChannelUpdateOptions, GuildEmojiUpdateOptions, GuildMemberAddOptions, GuildMemberUpdateOptions, GuildMembersFetchParams, GuildMembersSearchParams, GuildOnboardingUpdateOptions, GuildPruneOptions, GuildRoleCreateOptions, GuildRoleUpdateOptions, GuildSoundUpdateOptions, GuildStickerUpdateOptions, GuildUpdateOptions, GuildWelcomeScreenUpdateOptions, GuildWidgetUpdateOptions, ImageOptions, MessagesFetchParams, OtherVoiceStateUpdateOptions, PollVotersFetchParams, ReactionsFetchParams, Rest, RestEvents, RoleIconUrl, RolePositionsUpdateOptions, StageUpdateOptions, StickerFormatOptions, StickerPackBannerUrl, StickerUrl, ThreadCreateOptions, ThreadFromMessageCreateOptions, ThreadUpdateOptions, UserAvatarUrl, UserBannerUrl, UserGuildsFetchParams, UserRoleConnectionUpdateOptions, UserUpdateOptions, VoiceStateUpdateOptions, WebhookCreateOptions, WebhookExecuteOptions, WebhookExecuteParams, WebhookMessageEditOptions, WebhookUpdateOptions, WidgetStyle } from "@nyxojs/rest"; import { Store } from "@nyxojs/store"; import { EventEmitter } from "eventemitter3"; import { z } from "zod/v4"; export * from "@nyxojs/builders"; export * from "@nyxojs/core"; export * from "@nyxojs/gateway"; export * from "@nyxojs/rest"; export * from "@nyxojs/store"; //#region src/types/globals.types.d.ts /** * Utilitaire pour convertir une chaîne de caractères snake_case en camelCase. * * @typeParam S - Chaîne source en snake_case */ type CamelCase<S extends string> = S extends `${infer P}_${infer Q}` ? `${P}${Capitalize<CamelCase<Q>>}` : S; /** * Utilitaire pour mettre en majuscule la première lettre d'une chaîne. * * @typeParam S - Chaîne source */ type Capitalize<S extends string> = S extends `${infer P}${infer Q}` ? `${Uppercase<P>}${Q}` : S; /** * Convertit récursivement les clés snake_case en camelCase tout en préservant les types originaux. * * @typeParam T - Type source dont les propriétés seront converties */ type PropsToCamel<T> = T extends Array<infer U> ? PropsToCamel<U>[] : T extends object ? { [K in keyof T as CamelCase<K & string>]: PropsToCamel<T[K]> } : T; /** * Enforces property naming with configurable type handling. * * @typeParam T - Source type whose properties will be preserved * @typeParam PreserveValueTypes - Whether to preserve original value types (default: false) * * @remarks * Preserves all property keys from the source type without transformation. * By default, sets all property values to `any` to simplify type constraints. * Set second type parameter to `true` to preserve original value types. * * Useful for: * - Creating type-safe mappings between objects * - Enforcing type consistency in implementations * - Reducing type verbosity while maintaining structure * - Creating partial implementations with flexible property types */ type Enforce<T extends object, PreserveValueTypes extends boolean = false> = { [K in keyof T]-?: PreserveValueTypes extends true ? T[K] extends null | undefined ? NonNullable<T[K]> : T[K] : any }; /** * Represents a value that can be either the type itself or a Promise resolving to that type. * * This utility type is useful for flexible API designs that accept both synchronous * and asynchronous values, allowing functions to work with either direct values * or promises without additional type declarations. * * @typeParam T - The underlying value type * @remarks * When working with Promisable values, you typically want to use `Promise.resolve()` * to normalize the input to a Promise, or `await` the value to ensure you're working * with the resolved type in an async context. */ type Promisable<T> = T | Promise<T>; /** * Represents a guild-based entity, which includes a guild ID. * This is useful for entities that are specific to a guild context. */ type GuildBased<T extends object> = T & { /** * The ID of the guild this entity belongs to. */ guild_id: string; }; /** * Represents all events that can be emitted by the client. * This interface combines events from both REST and Gateway APIs, along with client-specific events. */ interface ClientEvents extends RestEvents, GatewayEvents { /** * Emitted when the client has successfully connected to Discord and is ready to process events. * This event indicates that all initial data (guilds, channels, etc.) has been received. * @param ready Object containing information about the ready state */ ready: [ready: Ready]; /** * Emitted when permissions for an application command are updated. * @param permissions The updated application command permissions */ applicationCommandPermissionsUpdate: [permissions: GuildApplicationCommandPermissionEntity]; /** * Emitted when a new Auto Moderation rule is created in a guild. * @param rule The newly created Auto Moderation rule */ autoModerationRuleCreate: [rule: AutoModeration]; /** * Emitted when an Auto Moderation rule is updated in a guild. * @param oldRule The rule before the update * @param newRule The rule after the update */ autoModerationRuleUpdate: [oldRule: AutoModeration | null, newRule: AutoModeration]; /** * Emitted when an Auto Moderation rule is deleted from a guild. * @param rule The deleted Auto Moderation rule */ autoModerationRuleDelete: [rule: AutoModeration | null]; /** * Emitted when an Auto Moderation rule is triggered and an action is executed. * @param execution Information about the executed action */ autoModerationActionExecution: [execution: AutoModerationActionExecution]; /** * Emitted when a new guild channel is created. * @param channel The newly created channel */ channelCreate: [channel: AnyChannel]; /** * Emitted when a channel is updated (name, topic, permissions, etc.). * @param oldChannel The channel before the update * @param newChannel The channel after the update */ channelUpdate: [oldChannel: AnyChannel | null, newChannel: AnyChannel]; /** * Emitted when a channel is deleted. * @param channel The deleted channel */ channelDelete: [channel: AnyChannel | null]; /** * Emitted when a message is pinned or unpinned in a channel. * @param pinUpdate Information about the pin update */ channelPinsUpdate: [pinUpdate: ChannelPinsUpdateEntity]; /** * Emitted when a new thread is created or when the client is added to a private thread. * @param thread The newly created thread or private thread the client was added to */ threadCreate: [thread: AnyThreadChannel]; /** * Emitted when a thread is updated (name, archived status, auto archive duration, etc.). * @param oldThread The thread before the update * @param newThread The thread after the update */ threadUpdate: [oldThread: AnyThreadChannel | null, newThread: AnyThreadChannel]; /** * Emitted when a thread is deleted. * @param thread The deleted thread */ threadDelete: [thread: AnyThreadChannel | null]; /** * Emitted when gaining access to a channel, containing all active threads in that channel. * This helps synchronize thread state when joining a guild or gaining access to a channel. * @param threads Collection of active threads in the channel */ threadListSync: [threads: ThreadListSyncEntity]; /** * Emitted when the thread member object for the current user is updated. * @param oldMember The thread member before the update * @param newMember The thread member after the update */ threadMemberUpdate: [oldMember: ThreadMember | null, newMember: ThreadMember]; /** * Emitted when users are added to or removed from a thread. * @param update Information about the members update */ threadMembersUpdate: [update: ThreadMembersUpdateEntity]; /** * Emitted when a new entitlement (subscription or one-time purchase) is created. * @param entitlement The newly created entitlement */ entitlementCreate: [entitlement: Entitlement]; /** * Emitted when an entitlement is updated. * @param oldEntitlement The entitlement before the update or null if it was created * @param newEntitlement The entitlement after the update */ entitlementUpdate: [oldEntitlement: Entitlement | null, newEntitlement: Entitlement]; /** * Emitted when an entitlement is deleted. * @param entitlement The deleted entitlement */ entitlementDelete: [entitlement: Entitlement | null]; /** * Emitted in three scenarios: * 1. When the client is connecting to a previously unavailable guild * 2. When a guild becomes available after being unavailable * 3. When the client user joins a new guild * @param guild The guild that became available or was joined */ guildCreate: [guild: Guild]; /** * Emitted when a guild's settings or properties are updated. * @param oldGuild The guild before the update * @param newGuild The guild after the update */ guildUpdate: [oldGuild: Guild | null, newGuild: Guild]; /** * Emitted when: * 1. A guild becomes unavailable due to an outage * 2. The client user leaves or is removed from a guild * @param guild The guild that became unavailable or was left */ guildDelete: [guild: Guild | null]; /** * Emitted when a new audit log entry is created in a guild. * @param entry The newly created audit log entry */ guildAuditLogEntryCreate: [entry: GuildAuditLogEntry]; /** * Emitted when a user is banned from a guild. * @param ban Information about the ban, including the user and the guild */ guildBanAdd: [ban: Ban]; /** * Emitted when a user is unbanned from a guild. * @param ban Information about the removed ban */ guildBanRemove: [ban: Ban]; /** * Emitted when a guild's emojis are updated (added, removed, or modified). * @param emojis Information about the updated emojis */ guildEmojisUpdate: [emojis: GuildEmojisUpdateEntity]; /** * Emitted when a new emoji is created in a guild. * @param emoji The newly created emoji */ emojiCreate: [emoji: Emoji]; /** * Emitted when an emoji is updated (name, roles, etc.). * @param oldEmoji The emoji before the update * @param newEmoji The emoji after the update */ emojiUpdate: [oldEmoji: Emoji | null, newEmoji: Emoji]; /** * Emitted when an emoji is deleted from a guild. * @param emoji The deleted emoji */ emojiDelete: [emoji: Emoji | null]; /** * Emitted when a guild's stickers are updated (added, removed, or modified). * @param stickers Information about the updated stickers */ guildStickersUpdate: [stickers: GuildStickersUpdateEntity]; /** * Emitted when a sticker is created in a guild. * @param sticker The newly created sticker */ stickerCreate: [sticker: Sticker]; /** * Emitted when a sticker is updated (name, tags, etc.). * @param oldSticker The sticker before the update * @param newSticker The sticker after the update */ stickerUpdate: [oldSticker: Sticker | null, newSticker: Sticker]; /** * Emitted when a sticker is deleted from a guild. * @param sticker The deleted sticker */ stickerDelete: [sticker: Sticker | null]; /** * Emitted when a guild's integrations are updated. * @param integrations Information about the updated integrations */ /** * Emitted when a new user joins a guild. * @param member The member who joined the guild */ guildMemberAdd: [member: GuildMember]; /** * Emitted when a user leaves or is removed from a guild. * @param member The member who was removed from the guild */ guildMemberRemove: [member: GuildMember | null]; /** * Emitted when a guild member is updated (roles, nickname, etc.). * @param oldMember The member before the update * @param newMember The member after the update */ guildMemberUpdate: [oldMember: GuildMember | null, newMember: GuildMember]; /** * Emitted in response to a Guild Request Members request. * @param members The chunk of requested guild members */ guildMembersChunk: [members: GuildMembersChunkEntity]; /** * Emitted when a role is created in a guild. * @param role The newly created role */ guildRoleCreate: [role: Role]; /** * Emitted when a guild role is updated. * @param oldRole The role before the update * @param newRole The role after the update */ guildRoleUpdate: [oldRole: Role | null, newRole: Role]; /** * Emitted when a guild role is deleted. * @param role The deleted role */ guildRoleDelete: [role: Role | null]; /** * Emitted when a scheduled event is created in a guild. * @param event The newly created scheduled event */ guildScheduledEventCreate: [event: ScheduledEvent]; /** * Emitted when a scheduled event is updated in a guild. * @param oldEvent The scheduled event before the update * @param newEvent The scheduled event after the update */ guildScheduledEventUpdate: [oldEvent: ScheduledEvent | null, newEvent: ScheduledEvent]; /** * Emitted when a scheduled event is deleted from a guild. * @param event The deleted scheduled event */ guildScheduledEventDelete: [event: ScheduledEvent | null]; /** * Emitted when a user subscribes to a guild scheduled event. * @param subscription Information about the subscription */ guildScheduledEventUserAdd: [subscription: GuildScheduledEventUserAddRemoveEntity]; /** * Emitted when a user unsubscribes from a guild scheduled event. * @param subscription Information about the removed subscription */ guildScheduledEventUserRemove: [subscription: GuildScheduledEventUserAddRemoveEntity]; /** * Emitted when a soundboard sound is created in a guild. * @param sound The newly created soundboard sound */ guildSoundboardSoundCreate: [sound: SoundboardSound]; /** * Emitted when a soundboard sound is updated in a guild. * @param oldSound The soundboard sound before the update * @param newSound The soundboard sound after the update */ guildSoundboardSoundUpdate: [oldSound: SoundboardSound | null, newSound: SoundboardSound]; /** * Emitted when a soundboard sound is deleted from a guild. * @param sound The deleted soundboard sound */ guildSoundboardSoundDelete: [sound: SoundboardSound | null]; /** * Emitted when a guild's soundboard sounds are updated as a whole. * @param sounds Information about the updated soundboard sounds */ guildSoundboardSoundsUpdate: [sounds: SoundboardSound[]]; /** * Emitted in response to a Request Soundboard Sounds request. * @param sounds The requested soundboard sounds */ soundboardSounds: [sounds: SoundboardSound[]]; /** * Emitted when a guild integration is created. * @param integration The newly created integration */ integrationCreate: [integration: Integration]; /** * Emitted when a guild integration is updated. * @param oldIntegration The integration before the update * @param newIntegration The integration after the update */ integrationUpdate: [oldIntegration: Integration | null, newIntegration: Integration]; /** * Emitted when a guild integration is deleted. * @param integration The deleted integration */ integrationDelete: [integration: Integration | null]; /** * Emitted when an invite to a channel is created. * @param invite The newly created invite */ inviteCreate: [invite: Invite]; /** * Emitted when an invite to a channel is deleted. * @param invite The deleted invite */ inviteDelete: [invite: Invite | null]; /** * Emitted when a message is sent in a channel the client can see. * @param message The created message */ messageCreate: [message: Message]; /** * Emitted when a message is edited. * @param oldMessage The message before the update * @param newMessage The message after the update */ messageUpdate: [oldMessage: Message | null, newMessage: Message]; /** * Emitted when a message is deleted. * @param message The deleted message */ messageDelete: [message: Message | null]; /** * Emitted when multiple messages are deleted at once (bulk delete). * @param messages The deleted messages */ messageDeleteBulk: [messages: (Message | null)[]]; /** * Emitted when a user adds a reaction to a message. * @param reaction Information about the added reaction */ messageReactionAdd: [reaction: MessageReaction]; /** * Emitted when a user removes a reaction from a message. * @param reaction Information about the removed reaction */ messageReactionRemove: [reaction: MessageReaction]; /** * Emitted when all reactions are removed from a message. * @param removal Information about the removal */ messageReactionRemoveAll: [removal: MessageReactionRemoveAll]; /** * Emitted when all reactions of a specific emoji are removed from a message. * @param removal Information about the emoji reaction removal */ messageReactionRemoveEmoji: [removal: MessageReactionRemoveEmoji]; /** * Emitted when a user's presence (status, activity) is updated. * @param oldPresence The presence before the update * @param newPresence The presence after the update */ presenceUpdate: [oldPresence: PresenceEntity | null, newPresence: PresenceEntity]; /** * Emitted when a user starts typing in a channel. * @param typing Information about the typing activity */ typingStart: [typing: TypingStartEntity]; /** * Emitted when properties about the user (username, avatar, etc.) change. * @param oldUser The user before the update * @param newUser The user after the update */ userUpdate: [oldUser: User | null, newUser: User]; /** * Emitted when someone sends an effect in a voice channel the client is connected to. * @param effect Information about the sent effect */ voiceChannelEffectSend: [effect: VoiceChannelEffect]; /** * Emitted when a user joins, leaves, or moves between voice channels. * @param oldState The voice state before the update * @param newState The voice state after the update */ voiceStateUpdate: [oldState: VoiceState | null, newState: VoiceState]; /** * Emitted when a guild's voice server is updated. * This usually happens when a guild becomes available for voice connections. * @param server Information about the voice server update */ voiceServerUpdate: [server: VoiceServerUpdateEntity]; /** * Emitted when a webhook is created, updated, or deleted in a guild channel. * @param webhook Information about the webhook update */ webhooksUpdate: [oldWebhook: Webhook | null, newWebhook: Webhook]; /** * Emitted when a user uses an interaction with the client, such as an Application Command. * @param interaction The created interaction */ interactionCreate: [interaction: AnyInteraction]; /** * Emitted when a stage instance (stage channel event) is created. * @param instance The created stage instance */ stageInstanceCreate: [instance: StageInstance]; /** * Emitted when a stage instance is updated. * @param oldInstance The stage instance before the update * @param newInstance The stage instance after the update */ stageInstanceUpdate: [oldInstance: StageInstance | null, newInstance: StageInstance]; /** * Emitted when a stage instance is deleted or closed. * @param instance The deleted stage instance */ stageInstanceDelete: [instance: StageInstance | null]; /** * Emitted when a premium app subscription is created. * @param subscription The created premium app subscription */ subscriptionCreate: [subscription: Subscription]; /** * Emitted when a premium app subscription is updated. * @param oldSubscription The subscription before the update * @param newSubscription The subscription after the update */ subscriptionUpdate: [oldSubscription: Subscription | null, newSubscription: Subscription]; /** * Emitted when a premium app subscription is deleted. * @param subscription The deleted subscription */ subscriptionDelete: [subscription: Subscription | null]; /** * Emitted when a user votes on a message poll. * @param vote Information about the poll vote */ messagePollVoteAdd: [vote: MessagePollVote]; /** * Emitted when a user removes their vote from a message poll. * @param vote Information about the removed poll vote */ messagePollVoteRemove: [vote: MessagePollVote]; } //#endregion //#region src/classes/user.class.d.ts /** * Represents a Discord user, providing methods to interact with and retrieve user data. * * The User class serves as a comprehensive wrapper around Discord's user API, offering: * - Access to user profile information (username, avatar, banner, etc.) * - Methods to interact with user connections and relationships * - Guild membership management and information * - Direct message functionality and conversation management * - Application role connection handling * * This class transforms snake_case API responses into camelCase properties for * a more JavaScript-friendly interface while maintaining type safety. * * @see {@link https://discord.com/developers/docs/resources/user} */ declare class User extends BaseClass<UserEntity> implements Enforce<PropsToCamel<UserEntity>> { /** * Gets the user's unique identifier (Snowflake). * * This ID is permanent and will not change for the lifetime of the user account. * It can be used for API operations, mentions, and persistent references. * * @returns The user's ID as a Snowflake string */ readonly id: string; /** * Gets the user's username. * * Usernames are not unique across Discord (unlike the combination of username and discriminator). * They must be between 2 and 32 characters and follow Discord's username requirements. * * @returns The user's username * @see {@link https://discord.com/developers/docs/resources/user#usernames-and-nicknames} */ readonly username: string; /** * Gets the user's discriminator (the four digits after the #). * * The discriminator is a 4-digit number (displayed as a string) that allows Discord * to differentiate between users with the same username. * * @returns The user's discriminator as a string */ readonly discriminator: string; /** * Gets the user's global display name. * * This is the user's chosen display name that appears across Discord. * For bots, this is typically the application name. * * @returns The user's global display name, or null if not set */ readonly globalName: string | null; /** * Gets the user's avatar hash. * * This hash is used to construct the URL for the user's avatar image. * Use `getAvatarUrl()` or `getDisplayAvatarUrl()` methods to get the full URL. * * @returns The user's avatar hash, or null if using the default avatar */ readonly avatar: string | null; /** * Indicates whether the user is a bot account. * * Bot accounts have different rate limits, permission requirements, * and behavior compared to normal user accounts. * * @returns True if the user is a bot, false otherwise */ readonly bot: boolean; /** * Indicates whether the user is an Official Discord System user. * * System users are special accounts used by Discord for system messages * and official communications. * * @returns True if the user is a system account, false otherwise */ readonly system: boolean; /** * Indicates whether the user has two-factor authentication enabled. * * When MFA is enabled, additional verification is required for sensitive actions. * * @returns True if the user has MFA enabled, false otherwise */ readonly mfaEnabled: boolean; /** * Gets the user's banner hash. * * This hash is used to construct the URL for the user's profile banner. * Use `getBannerUrl()` method to get the full URL. * * @returns The user's banner hash, or null if no banner is set */ readonly banner: string | null | undefined; /** * Gets the user's accent color as an integer. * * This color is used as a fallback when the user has no banner set. * The value is an integer representation of a hexadecimal color code. * * @returns The accent color as an integer, or null if not set */ readonly accentColor: number | null | undefined; /** * Gets the user's chosen locale (language setting). * * This controls the language of Discord's user interface for this user. * * @returns The user's locale, or null if not available */ readonly locale: _nyxojs_core56.Locale | undefined; /** * Indicates whether the user's email has been verified. * * Requires the 'email' OAuth2 scope to access. * * @returns True if the email is verified, false otherwise */ readonly verified: boolean; /** * Gets the user's email address. * * Requires the 'email' OAuth2 scope to access. * * @returns The user's email address, or null if not available */ readonly email: string | null | undefined; /** * Gets the flags on the user's account as a BitField. * * These flags represent account features, badges, and participation * in various Discord programs. * * @returns A BitField of user flags * @see {@link https://discord.com/developers/docs/resources/user#user-object-user-flags} */ readonly flags: BitField<UserFlags>; /** * Gets the user's Nitro subscription level. * * Different Nitro tiers provide different benefits to users. * * @returns The premium type, or null if the user doesn't have Nitro * @see {@link https://discord.com/developers/docs/resources/user#user-object-premium-types} */ readonly premiumType: _nyxojs_core56.PremiumType | undefined; /** * Gets the public flags on the user's account as a BitField. * * These are flags that are publicly visible to other users, * representing badges and account features. * * @returns A BitField of public user flags * @see {@link https://discord.com/developers/docs/resources/user#user-object-user-flags} */ readonly publicFlags: BitField<UserFlags>; /** * Gets the user's avatar decoration data. * * Avatar decorations are special frames that can appear around a user's avatar. * This method returns the data in camelCase format for easier access. * * @returns The avatar decoration data in camelCase format, or null if not set */ readonly avatarDecorationData: _nyxojs_core56.AvatarDecorationDataEntity | null | undefined; /** * Gets the user's tag, which is a combination of username and discriminator. * * The tag is in the format `username#discriminator` and provides a unique * identifier for the user across Discord. * * @returns The user's tag in the format `username#discriminator` */ get tag(): `${string}#${string}`; /** * Gets the user's display name, prioritizing their global name if available. * * This is the name that should typically be shown in user interfaces * when referencing this user. * * @returns The user's global name if set, otherwise their username */ get displayName(): string; /** * Gets the Date object representing when this user account was created. * * This is calculated from the user's ID, which contains a timestamp. * * @returns The Date when this user was created */ get createdAt(): Date; /** * Gets the Unix timestamp (in milliseconds) of when this user account was created. * * This is useful for comparing account ages or for formatting with * custom date libraries. * * @returns The creation timestamp in milliseconds */ get createdTimestamp(): number; /** * Gets the URL for the user's avatar decoration. * * Avatar decorations are special frames that can appear around a user's avatar. * * @returns The URL for the avatar decoration, or null if the user doesn't have one */ get avatarDecorationUrl(): AvatarDecorationUrl | null; /** * Checks if this user has any Nitro subscription. * * @returns True if the user has any Nitro subscription, false otherwise */ get isPremium(): boolean; /** * Checks if this User instance represents the current authenticated user. * * This is useful for determining if operations that require self-authorization * can be performed. * * @returns True if this user is the current authenticated user, false otherwise */ get isSelf(): boolean; /** * Gets the user's account age in days. * * @returns The number of days since the user account was created */ get accountAge(): number; /** * Gets the URL for the user's avatar with specified options. * * If the user doesn't have a custom avatar, this returns null. * Use `getDisplayAvatarUrl()` to always get a valid avatar URL. * * @param options - Options for the avatar image (size, format, etc.) * @returns The URL for the user's avatar, or null if they use the default avatar * @see {@link https://discord.com/developers/docs/reference#image-formatting} */ getAvatarUrl(options?: z.input<typeof AnimatedImageOptions>): UserAvatarUrl | null; /** * Gets the URL for the user's default avatar. * * This is the avatar assigned by Discord when the user hasn't set a custom one. * * @returns The URL for the default avatar */ getDefaultAvatarUrl(): DefaultUserAvatarUrl; /** * Gets the display avatar URL, either the user's custom avatar or their default avatar. * * This method always returns a valid avatar URL, prioritizing the custom avatar * if available. * * @param options - Options for the avatar image (size, format, etc.) * @returns The URL for the user's display avatar * @see {@link https://discord.com/developers/docs/reference#image-formatting} */ getDisplayAvatarUrl(options?: z.input<typeof AnimatedImageOptions>): UserAvatarUrl | DefaultUserAvatarUrl; /** * Gets the URL for the user's profile banner with specified options. * * @param options - Options for the banner image (size, format, etc.) * @returns The URL for the user's banner, or null if they don't have one * @see {@link https://discord.com/developers/docs/reference#image-formatting} */ getBannerUrl(options?: z.input<typeof AnimatedImageOptions>): UserBannerUrl | null; /** * Gets the hex color code representation of the user's accent color. * * @param withHash - Whether to include the # prefix * @returns The hex color code, or null if not set */ getAccentColorHex(withHash?: boolean): string | null; /** * Fetches a user by their ID. * * This method retrieves information about any user on Discord by their ID, * including their username, avatar, and discriminator. * * @param userId - The ID of the user to fetch * @returns A promise resolving to the User instance * @throws Error if the user ID is missing or the user couldn't be fetched * @see {@link https://discord.com/developers/docs/resources/user#get-user} */ fetchUser(userId: Snowflake): Promise<User>; /** * Fetches the user's external account connections. * * This method retrieves information about the current user's connected * third-party accounts, such as Twitch, YouTube, or Steam. * * @returns A promise resolving to an array of connection entities in camelCase format * @throws Error if this isn't the current authenticated user * @see {@link https://discord.com/developers/docs/resources/user#get-current-user-connections} */ fetchConnections(): Promise<ConnectionEntity[]>; /** * Creates or returns an existing DM channel with this user. * * This method establishes a direct message channel between the current user and * this user, or returns an existing DM channel if one already exists. * * @returns A promise resolving to the DM channel * @throws Error if the DM cannot be created * @see {@link https://discord.com/developers/docs/resources/user#create-dm} */ createDmChannel(): Promise<DmChannel>; /** * Sends a direct message to this user. * * This is a convenience method that creates a DM channel and sends a message * in a single call. * * @param content - The content of the message to send * @returns A promise resolving to the sent message * @throws Error if the DM cannot be created or the message cannot be sent */ send(content: string): Promise<Message>; /** * Creates a new group DM channel with multiple users. * * This method establishes a group direct message conversation with multiple users, * requiring OAuth2 access tokens from those users. * * @param options - Options for creating the group DM * @returns A promise resolving to the group DM channel * @throws Error if this isn't the current authenticated user or options are invalid * @see {@link https://discord.com/developers/docs/resources/user#create-group-dm} */ createGroupDmChannel(options: GroupDmCreateOptions): Promise<DmChannel>; /** * Fetches the guilds (servers) the current user is a member of. * * This method retrieves information about the guilds that the current * user has joined, with optional pagination support. * * @param query - Query parameters for filtering and pagination * @returns A promise resolving to an array of Guild objects * @throws Error if this isn't the current authenticated user * @see {@link https://discord.com/developers/docs/resources/user#get-current-user-guilds} */ fetchGuilds(query?: UserGuildsFetchParams): Promise<Guild[]>; /** * Fetches this user's member information for a specific guild. * * This method retrieves detailed information about this user's membership * in a specific guild, including roles, nickname, and join date. * * @param guildId - The ID of the guild to get member data from * @returns A promise resolving to the GuildMember object * @throws Error if the user is not in the guild or you lack permissions * @see {@link https://discord.com/developers/docs/resources/guild#get-guild-member} */ fetchGuildMember(guildId: Snowflake): Promise<GuildMember>; /** * Fetches the application role connection for this user. * * This method retrieves information about how this user's account is * connected to an application for the purpose of linked roles. * * @param applicationId - The ID of the application to get the role connection for * @returns A promise resolving to the application role connection entity * @throws Error if this isn't the current authenticated user * @see {@link https://discord.com/developers/docs/resources/user#get-current-user-application-role-connection} */ fetchApplicationRoleConnection(applicationId: Snowflake): Promise<ApplicationRoleConnectionEntity>; /** * Updates the application role connection for this user. * * This method updates metadata about how this user's account is * connected to an application for the purpose of linked roles. * * @param applicationId - The ID of the application to update the role connection for * @param connection - The role connection data to update * @returns A promise resolving to the updated application role connection entity * @throws Error if this isn't the current authenticated user * @see {@link https://discord.com/developers/docs/resources/user#update-current-user-application-role-connection} */ updateApplicationRoleConnection(applicationId: Snowflake, connection: UserRoleConnectionUpdateOptions): Promise<ApplicationRoleConnectionEntity>; /** * Leaves a guild. * * This method removes the current user from a guild they are a member of. * For bots, this is equivalent to the bot being kicked from the guild. * * @param guildId - The ID of the guild to leave * @returns A promise resolving to true if successful, false otherwise * @throws Error if this isn't the current authenticated user * @see {@link https://discord.com/developers/docs/resources/user#leave-guild} */ leaveGuild(guildId: Snowflake): Promise<boolean>; /** * Updates the current user's account settings. * * This method allows modifying various aspects of the current user's profile, * such as their username, avatar, and banner. * * @param options - Options for modifying the current user * @returns A promise resolving to the updated User instance * @throws Error if this isn't the current authenticated user or options are invalid * @see {@link https://discord.com/developers/docs/resources/user#modify-current-user} */ updateProfile(options: UserUpdateOptions): Promise<User>; /** * Formats this user as a mention string. * * This returns a string that, when sent in a message, will create a mention * that pings and highlights the user. * * @returns The formatted user mention */ toString(): FormattedUser; /** * Checks if this user has a specific flag on their account. * * @param flag - The flag to check for * @returns True if the user has the flag, false otherwise * @see {@link https://discord.com/developers/docs/resources/user#user-object-user-flags} */ hasFlag(flag: UserFlags): boolean; /** * Checks if this user has a specific public flag on their account. * * @param flag - The public flag to check for * @returns True if the user has the public flag, false otherwise * @see {@link https://discord.com/developers/docs/resources/user#user-object-user-flags} */ hasPublicFlag(flag: UserFlags): boolean; /** * Checks if this user has a banner set. * * @returns True if the user has a banner, false otherwise */ hasBanner(): boolean; /** * Checks if this user has an avatar decoration. * * @returns True if the user has an avatar decoration, false otherwise */ hasAvatarDecoration(): boolean; /** * Checks if the user's username is valid according to Discord's requirements. * * This validates the username against Discord's rules, which include * length restrictions and forbidden substrings. * * @returns True if the username is valid, false otherwise * @see {@link https://discord.com/developers/docs/resources/user#usernames-and-nicknames} */ hasValidUsername(): boolean; /** * Refreshes this user's data from the API. * * @returns A promise resolving to the updated User instance * @throws Error if the user couldn't be fetched */ refresh(): Promise<User>; /** * Checks if this user is a member of a specific guild. * * @param guildId - The ID of the guild to check * @returns A promise resolving to true if the user is a member, false otherwise */ isMemberOf(guildId: Snowflake): Promise<boolean>; /** * Gets detailed information about this user's service connections. * * This is a convenience method that filters connections by type and provides * easier access to connection properties. * * @param type - Optional connection type to filter by * @returns A promise resolving to the filtered connections * @throws Error if this isn't the current authenticated user * @see {@link https://discord.com/developers/docs/resources/user#connection-object} */ getServiceConnections(type?: ConnectionService): Promise<ConnectionEntity[]>; } //#endregion //#region src/classes/emoji.class.d.ts /** * Represents a Discord Emoji object. * * The Emoji class serves as a comprehensive wrapper around Discord's emoji API, offering: * - Access to emoji properties (name, ID, animated status, etc.) * - Methods for creating, updating, and deleting emojis * - Tools for generating emoji URLs and formatted strings * - Utilities for checking permissions and availability * * Discord supports three main types of emoji: * - Standard emoji: Unicode emoji with null ID * - Guild emoji: Custom emoji belonging to a specific guild * - Application-owned emoji: Custom emoji that can only be used by a specific application * * This class transforms snake_case API responses into camelCase properties for * a more JavaScript-friendly interface while maintaining type safety. * * @see {@link https://discord.com/developers/docs/resources/emoji} */ declare class Emoji extends BaseClass<GuildBased<EmojiEntity>> implements Enforce<PropsToCamel<GuildBased<EmojiEntity>>> { /** * Gets the unique identifier (Snowflake) of this emoji. * * This will be null for standard Unicode emoji. * Custom emoji (both guild and application-owned) will have a snowflake ID. * * @returns The emoji's ID as a Snowflake string, or null for standard emoji */ readonly id: string | null; /** * Gets the ID of the guild where this emoji belongs. * * For guild emojis, this identifies the guild that owns the emoji. * For application emojis, this will be undefined. * * @returns The guild ID, or undefined if not a guild emoji */ readonly guildId: string; /** * Gets the name of the emoji. * * For custom emoji, this is the name assigned when created (e.g., "serverboost"). * For standard emoji, this is the Unicode character (e.g., "🔥"). * * @returns The emoji's name as a string, or null if not available */ readonly name: string | null; /** * Gets the array of role IDs that are allowed to use this emoji. * * If no roles are specified, the emoji is available to all members in the guild. * This property is only relevant for guild emojis with role restrictions. * * @returns Array of role IDs, or undefined if no restrictions */ readonly roles: string[] | undefined; /** * Gets the User object for the user that created this emoji. * * This field is only returned when the client has permissions to view it, * typically requiring MANAGE_GUILD_EXPRESSIONS or CREATE_GUILD_EXPRESSIONS permissions. * * @returns The User object for the creator, or undefined if not available */ readonly user: User | undefined; /** * Indicates whether this emoji must be wrapped in colons to be used in chat. * * True for most custom emoji that require the format `:emoji_name:`. * This applies to custom emoji, not to standard Unicode emoji. * * @returns True if colons are required, false otherwise */ readonly requireColons: boolean; /** * Indicates whether this emoji is managed by an integration. * * Managed emoji cannot be modified or deleted by regular users. * These are typically created by integrations such as Twitch or Soundboard. * * @returns True if the emoji is managed, false otherwise */ readonly managed: boolean; /** * Indicates whether this emoji is animated. * * Animated emoji have a .gif format and play their animation when used. * They use the format `<a:name:id>` in messages. * * @returns True if the emoji is animated, false otherwise */ readonly animated: boolean; /** * Indicates whether this emoji can be used. * * May be false due to loss of Server Boosts if it's a guild emoji. * When a guild loses the number of boosts required for certain emoji slots, * those emoji become unavailable but are not deleted. * * @returns True if the emoji is available for use, false otherwise */ readonly available: boolean; /** * Gets the Date object representing when this emoji was created. * * This is calculated from the emoji's ID, which contains a timestamp. * This will only work for custom emojis with an ID. * * @returns The Date when this emoji was created, or null for standard emoji */ get createdAt(): Date | null; /** * Gets the Unix timestamp (in milliseconds) of when this emoji was created. * * This is useful for comparing emoji ages or for formatting with * custom date libraries. * * @returns The creation timestamp in milliseconds, or null for standard emoji */ get createdTimestamp(): number | null; /** * Checks if this emoji is a standard Unicode emoji. * * Standard emoji are Unicode characters like 🔥 or 👍, * as opposed to custom Discord emoji. * * @returns True if this is a standard emoji, false if it's a custom emoji */ get isUnicode(): boolean; /** * Checks if this emoji is a custom emoji. * * Custom emoji are created by Discord users or applications, * as opposed to standard Unicode emoji. * * @returns True if this is a custom emoji, false if it's a standard emoji */ get isCustom(): boolean; /** * Checks if this emoji is restricted to specific roles. * * When restricted, only members with at least one of the specified roles * can use the emoji. * * @returns True if the emoji has role restrictions, false otherwise */ get isRoleRestricted(): boolean; /** * Checks if this emoji belongs to a guild (server). * * Guild emoji are associated with a specific server, * as opposed to application-owned emoji. * * @returns True if this is a guild emoji, false otherwise */ get isGuildEmoji(): boolean; /** * Gets the URL for this emoji with specified options. * * This method generates a proper CDN URL for the emoji, * allowing customization of size and format. * Only works for custom emoji, not for standard Unicode emoji. * * @param options - Options for the emoji image (size, format, etc.) * @returns The URL for the emoji, or null for standard emoji */ getUrl(options?: z.input<typeof AnimatedImageOptions>): EmojiUrl | null; /** * Gets the Markdown for this emoji to be used in messages. * * This method returns the formatted string that will render * the emoji when sent in a Discord mes