diff --git a/typings/index.d.ts b/typings/index.d.ts index c512c14f5..bb43409db 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -17,17 +17,23 @@ import { Collection } from '@discordjs/collection'; import { ChildProcess } from 'child_process'; import { APIActionRowComponent, + APIApplicationCommand, + APIApplicationCommandInteractionData, + APIApplicationCommandInteractionDataOption, + APIApplicationCommandPermission, + APIAuditLogChange, + APIEmoji, APIInteractionDataResolvedChannel, APIInteractionDataResolvedGuildMember, APIInteractionGuildMember, APIMessage, APIMessageComponent, APIOverwrite, + APIPartialChannel, APIPartialEmoji, + APIPartialGuild, APIRole, - APISticker, - APIStickerItem, - APIStickerPack, + APITemplateSerializedSourceGuild, APIUser, GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData, @@ -35,6 +41,7 @@ import { } from 'discord-api-types/v9'; import { EventEmitter } from 'events'; import { Stream } from 'stream'; +import { MessagePort, Worker } from 'worker_threads'; import * as WebSocket from 'ws'; import { ActivityTypes, @@ -59,11 +66,69 @@ import { VerificationLevels, WebhookTypes, } from './enums'; +import { + RawActivityData, + RawAnonymousGuildData, + RawApplicationCommandData, + RawApplicationData, + RawBaseGuildData, + RawChannelData, + RawClientApplicationData, + RawCommandInteractionData, + RawDMChannelData, + RawEmojiData, + RawGuildAuditLogData, + RawGuildAuditLogEntryData, + RawGuildBanData, + RawGuildChannelData, + RawGuildData, + RawGuildEmojiData, + RawGuildMemberData, + RawGuildPreviewData, + RawGuildTemplateData, + RawIntegrationApplicationData, + RawIntegrationData, + RawInteractionData, + RawInviteData, + RawInviteGuildData, + RawInviteStageInstance, + RawMessageAttachementData, + RawMessageButtonInteractionData, + RawMessageComponentInteractionData, + RawMessageData, + RawMessagePayloadData, + RawMessageReactionData, + RawMessageSelectMenuInteractionData, + RawOAuth2GuildData, + RawPartialGroupDMChannelData, + RawPartialMessageData, + RawPermissionOverwriteData, + RawPresenceData, + RawReactionEmojiData, + RawRichPresenceAssets, + RawRoleData, + RawStageInstanceData, + RawStickerData, + RawStickerPackData, + RawTeamData, + RawTeamMemberData, + RawThreadChannelData, + RawThreadMemberData, + RawTypingData, + RawUserData, + RawVoiceRegionData, + RawVoiceStateData, + RawWebhookData, + RawWelcomeChannelData, + RawWelcomeScreenData, + RawWidgetData, + RawWidgetMemberData, +} from './rawDataTypes'; //#region Classes export class Activity { - public constructor(presence: Presence, data?: unknown); + public constructor(presence: Presence, data?: RawActivityData); public applicationId: Snowflake | null; public assets: RichPresenceAssets | null; public buttons: string[]; @@ -97,7 +162,7 @@ export class ActivityFlags extends BitField { } export abstract class AnonymousGuild extends BaseGuild { - public constructor(client: Client, data: unknown, immediatePatch?: boolean); + public constructor(client: Client, data: RawAnonymousGuildData, immediatePatch?: boolean); public banner: string | null; public description: string | null; public nsfwLevel: NSFWLevel; @@ -109,7 +174,7 @@ export abstract class AnonymousGuild extends BaseGuild { } export abstract class Application extends Base { - public constructor(client: Client, data: unknown); + public constructor(client: Client, data: RawApplicationData); public readonly createdAt: Date; public readonly createdTimestamp: number; public description: string | null; @@ -124,7 +189,7 @@ export abstract class Application extends Base { } export class ApplicationCommand extends Base { - public constructor(client: Client, data: unknown, guild?: Guild, guildId?: Snowflake); + public constructor(client: Client, data: RawApplicationCommandData, guild?: Guild, guildId?: Snowflake); public applicationId: Snowflake; public readonly createdAt: Date; public readonly createdTimestamp: number; @@ -175,7 +240,7 @@ export class BaseClient extends EventEmitter { } export abstract class BaseGuild extends Base { - public constructor(client: Client, data: unknown); + public constructor(client: Client, data: RawBaseGuildData); public readonly createdAt: Date; public readonly createdTimestamp: number; public features: GuildFeatures[]; @@ -191,7 +256,7 @@ export abstract class BaseGuild extends Base { } export class BaseGuildEmoji extends Emoji { - public constructor(client: Client, data: unknown, guild: Guild | GuildPreview); + public constructor(client: Client, data: RawGuildEmojiData, guild: Guild | GuildPreview); public available: boolean | null; public readonly createdAt: Date; public readonly createdTimestamp: number; @@ -202,7 +267,7 @@ export class BaseGuildEmoji extends Emoji { } export class BaseGuildVoiceChannel extends GuildChannel { - public constructor(guild: Guild, data?: unknown); + public constructor(guild: Guild, data?: RawGuildChannelData); public readonly members: Collection; public readonly full: boolean; public readonly joinable: boolean; @@ -238,11 +303,12 @@ export class BitField { public toJSON(): N extends number ? number : string; public valueOf(): N; public [Symbol.iterator](): IterableIterator; - public static FLAGS: unknown; + public static FLAGS: Record; public static resolve(bit?: BitFieldResolvable): number | bigint; } export class ButtonInteraction extends MessageComponentInteraction { + public constructor(client: Client, data: RawMessageButtonInteractionData); public componentType: 'BUTTON'; } @@ -254,7 +320,7 @@ export class CategoryChannel extends GuildChannel { export type CategoryChannelResolvable = Snowflake | CategoryChannel; export class Channel extends Base { - public constructor(client: Client, data?: unknown, immediatePatch?: boolean); + public constructor(client: Client, data?: RawChannelData, immediatePatch?: boolean); public readonly createdAt: Date; public readonly createdTimestamp: number; public deleted: boolean; @@ -331,6 +397,7 @@ export class Client extends BaseClient { } export class ClientApplication extends Application { + public constructor(client: Client, data: RawClientApplicationData); public botPublic: boolean | null; public botRequireCodeGrant: boolean | null; public commands: ApplicationCommandManager; @@ -402,6 +469,7 @@ export abstract class Collector extends EventEmi } export class CommandInteraction extends Interaction { + public constructor(client: Client, data: RawCommandInteractionData); public readonly command: ApplicationCommand | ApplicationCommand<{ guild: GuildResolvable }> | null; public readonly channel: TextChannel | DMChannel | NewsChannel | PartialDMChannel | ThreadChannel | null; public channelId: Snowflake; @@ -420,7 +488,10 @@ export class CommandInteraction extends Interaction { public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise; public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise; public reply(options: string | MessagePayload | InteractionReplyOptions): Promise; - private transformOption(option: unknown, resolved: unknown): CommandInteractionOption; + private transformOption( + option: APIApplicationCommandInteractionDataOption, + resolved: APIApplicationCommandInteractionData['resolved'], + ): CommandInteractionOption; } export class CommandInteractionOptionResolver { @@ -499,7 +570,7 @@ export class DiscordAPIError extends Error { } export class DMChannel extends TextBasedChannel(Channel, ['bulkDelete']) { - public constructor(client: Client, data?: unknown); + public constructor(client: Client, data?: RawDMChannelData); public messages: MessageManager; public recipient: User; public type: 'DM'; @@ -507,7 +578,7 @@ export class DMChannel extends TextBasedChannel(Channel, ['bulkDelete']) { } export class Emoji extends Base { - public constructor(client: Client, emoji: unknown); + public constructor(client: Client, emoji: RawEmojiData); public animated: boolean | null; public readonly createdAt: Date | null; public readonly createdTimestamp: number | null; @@ -521,7 +592,7 @@ export class Emoji extends Base { } export class Guild extends AnonymousGuild { - public constructor(client: Client, data: unknown); + public constructor(client: Client, data: RawGuildData); private _sortedRoles(): Collection; private _sortedChannels(channel: Channel): Collection; @@ -619,7 +690,7 @@ export class Guild extends AnonymousGuild { } export class GuildAuditLogs { - public constructor(guild: Guild, data: unknown); + public constructor(guild: Guild, data: RawGuildAuditLogData); private webhooks: Collection; private integrations: Collection; @@ -635,7 +706,7 @@ export class GuildAuditLogs { } export class GuildAuditLogsEntry { - public constructor(logs: GuildAuditLogs, guild: Guild, data: unknown); + public constructor(logs: GuildAuditLogs, guild: Guild, data: RawGuildAuditLogEntryData); public action: GuildAuditLogsAction; public actionType: GuildAuditLogsActionType; public changes: AuditLogChange[] | null; @@ -665,7 +736,7 @@ export class GuildAuditLogsEntry { } export class GuildBan extends Base { - public constructor(client: Client, data: unknown, guild: Guild); + public constructor(client: Client, data: RawGuildBanData, guild: Guild); public guild: Guild; public user: User; public readonly partial: boolean; @@ -674,7 +745,7 @@ export class GuildBan extends Base { } export class GuildChannel extends Channel { - public constructor(guild: Guild, data?: unknown, client?: Client); + public constructor(guild: Guild, data?: RawGuildChannelData, client?: Client); private memberPermissions(member: GuildMember): Readonly; private rolePermissions(role: Role): Readonly; @@ -709,7 +780,7 @@ export class GuildChannel extends Channel { } export class GuildEmoji extends BaseGuildEmoji { - public constructor(client: Client, data: unknown, guild: Guild); + public constructor(client: Client, data: RawGuildEmojiData, guild: Guild); private _roles: Snowflake[]; public readonly deletable: boolean; @@ -725,7 +796,7 @@ export class GuildEmoji extends BaseGuildEmoji { } export class GuildMember extends PartialTextBasedChannel(Base) { - public constructor(client: Client, data: unknown, guild: Guild); + public constructor(client: Client, data: RawGuildMemberData, guild: Guild); public readonly bannable: boolean; public deleted: boolean; public readonly displayColor: number; @@ -761,7 +832,7 @@ export class GuildMember extends PartialTextBasedChannel(Base) { } export class GuildPreview extends Base { - public constructor(client: Client, data: unknown); + public constructor(client: Client, data: RawGuildPreviewData); public approximateMemberCount: number; public approximatePresenceCount: number; public readonly createdAt: Date; @@ -783,7 +854,7 @@ export class GuildPreview extends Base { } export class GuildTemplate extends Base { - public constructor(client: Client, data: unknown); + public constructor(client: Client, data: RawGuildTemplateData); public readonly createdTimestamp: number; public readonly updatedTimestamp: number; public readonly url: string; @@ -797,7 +868,7 @@ export class GuildTemplate extends Base { public updatedAt: Date; public guild: Guild | null; public guildId: Snowflake; - public serializedGuild: unknown; + public serializedGuild: APITemplateSerializedSourceGuild; public unSynced: boolean | null; public createGuild(name: string, icon?: BufferResolvable | Base64Resolvable): Promise; public delete(): Promise; @@ -807,7 +878,7 @@ export class GuildTemplate extends Base { } export class GuildPreviewEmoji extends BaseGuildEmoji { - public constructor(client: Client, data: unknown, guild: GuildPreview); + public constructor(client: Client, data: RawGuildEmojiData, guild: GuildPreview); public guild: GuildPreview; public roles: Snowflake[]; } @@ -829,7 +900,7 @@ export class RateLimitError extends Error { } export class Integration extends Base { - public constructor(client: Client, data: unknown, guild: Guild); + public constructor(client: Client, data: RawIntegrationData, guild: Guild); public account: IntegrationAccount; public application: IntegrationApplication | null; public enabled: boolean; @@ -848,6 +919,7 @@ export class Integration extends Base { } export class IntegrationApplication extends Application { + public constructor(client: Client, data: RawIntegrationApplicationData); public bot: User | null; public termsOfServiceURL: string | null; public privacyPolicyURL: string | null; @@ -864,7 +936,7 @@ export class Intents extends BitField { } export class Interaction extends Base { - public constructor(client: Client, data: unknown); + public constructor(client: Client, data: RawInteractionData); public applicationId: Snowflake; public readonly channel: Channel | PartialDMChannel | null; public channelId: Snowflake | null; @@ -920,7 +992,7 @@ export class InteractionWebhook extends PartialWebhookMixin() { } export class Invite extends Base { - public constructor(client: Client, data: unknown); + public constructor(client: Client, data: RawInviteData); public channel: GuildChannel | PartialGroupDMChannel; public code: string; public readonly deletable: boolean; @@ -948,7 +1020,7 @@ export class Invite extends Base { } export class InviteStageInstance extends Base { - public constructor(client: Client, data: unknown, channelId: Snowflake, guildId: Snowflake); + public constructor(client: Client, data: RawInviteStageInstance, channelId: Snowflake, guildId: Snowflake); public channelId: Snowflake; public guildId: Snowflake; public members: Collection; @@ -960,7 +1032,7 @@ export class InviteStageInstance extends Base { } export class InviteGuild extends AnonymousGuild { - public constructor(client: Client, data: unknown); + public constructor(client: Client, data: RawInviteGuildData); public welcomeScreen: WelcomeScreen | null; } @@ -975,9 +1047,15 @@ export class LimitedCollection extends Collection { } export class Message extends Base { - public constructor(client: Client, data: unknown, channel: TextChannel | DMChannel | NewsChannel | ThreadChannel); - private _patch(data: unknown, partial?: boolean): Message; - private _update(data: unknown, partial?: boolean): Message; + public constructor( + client: Client, + data: RawMessageData, + channel: TextChannel | DMChannel | NewsChannel | ThreadChannel, + ); + private _patch(data: RawPartialMessageData, partial: true): Message; + private _patch(data: RawMessageData, partial?: boolean): Message; + private _update(data: RawPartialMessageData, partial: true): Message; + private _update(data: RawMessageData, partial?: boolean): Message; public activity: MessageActivity | null; public applicationId: Snowflake | null; @@ -1059,7 +1137,7 @@ export class MessageActionRow extends BaseMessageComponent { } export class MessageAttachment { - public constructor(attachment: BufferResolvable | Stream, name?: string, data?: unknown); + public constructor(attachment: BufferResolvable | Stream, name?: string, data?: RawMessageAttachementData); public attachment: BufferResolvable | Stream; public contentType: string | null; @@ -1110,6 +1188,7 @@ export class MessageCollector extends Collector { } export class MessageComponentInteraction extends Interaction { + public constructor(client: Client, data: RawMessageComponentInteractionData); public readonly channel: TextChannel | DMChannel | NewsChannel | PartialDMChannel | ThreadChannel | null; public readonly component: MessageActionRowComponent | Exclude | null; public componentType: MessageComponentType; @@ -1210,7 +1289,7 @@ export class MessageMentions { export class MessagePayload { public constructor(target: MessageTarget, options: MessageOptions | WebhookMessageOptions); - public data: unknown | null; + public data: RawMessagePayloadData | null; public readonly isUser: boolean; public readonly isWebhook: boolean; public readonly isMessage: boolean; @@ -1233,7 +1312,7 @@ export class MessagePayload { } export class MessageReaction { - public constructor(client: Client, data: unknown, message: Message); + public constructor(client: Client, data: RawMessageReactionData, message: Message); private _emoji: GuildEmoji | ReactionEmoji; public readonly client: Client; @@ -1272,7 +1351,7 @@ export class MessageSelectMenu extends BaseMessageComponent { } export class NewsChannel extends TextBasedChannel(GuildChannel) { - public constructor(guild: Guild, data?: unknown); + public constructor(guild: Guild, data?: RawGuildChannelData); public defaultAutoArchiveDuration?: ThreadAutoArchiveDuration; public messages: MessageManager; public nsfw: boolean; @@ -1291,19 +1370,20 @@ export class NewsChannel extends TextBasedChannel(GuildChannel) { } export class OAuth2Guild extends BaseGuild { + public constructor(client: Client, data: RawOAuth2GuildData); public owner: boolean; public permissions: Readonly; } export class PartialGroupDMChannel extends Channel { - public constructor(client: Client, data: unknown); + public constructor(client: Client, data: RawPartialGroupDMChannelData); public name: string; public icon: string | null; public iconURL(options?: StaticImageURLOptions): string | null; } export class PermissionOverwrites extends Base { - public constructor(client: Client, data: object, channel: GuildChannel); + public constructor(client: Client, data: RawPermissionOverwriteData, channel: GuildChannel); public allow: Readonly; public readonly channel: GuildChannel; public deny: Readonly; @@ -1334,7 +1414,7 @@ export class Permissions extends BitField { } export class Presence extends Base { - public constructor(client: Client, data?: unknown); + public constructor(client: Client, data?: RawPresenceData); public activities: Activity[]; public clientStatus: ClientPresenceStatusData | null; public guild: Guild | null; @@ -1376,13 +1456,13 @@ export class ReactionCollector extends Collector; public eval(fn: (client: Client) => T): Promise; public fetchClientValue(prop: string): Promise; @@ -1478,7 +1559,7 @@ export class ShardClientUtil { public readonly count: number; public readonly ids: number[]; public mode: ShardingManagerMode; - public parentPort: unknown | null; + public parentPort: MessagePort | null; public broadcastEval(fn: (client: Client) => Awaited): Promise[]>; public broadcastEval(fn: (client: Client) => Awaited, options: { shard: number }): Promise>; public broadcastEval( @@ -1552,7 +1633,7 @@ export class StageChannel extends BaseGuildVoiceChannel { } export class StageInstance extends Base { - public constructor(client: Client, data: unknown, channel: StageChannel); + public constructor(client: Client, data: RawStageInstanceData, channel: StageChannel); public id: Snowflake; public deleted: boolean; public guildId: Snowflake; @@ -1570,7 +1651,7 @@ export class StageInstance extends Base { } export class Sticker extends Base { - public constructor(client: Client, data: APISticker | APIStickerItem); + public constructor(client: Client, data: RawStickerData); public readonly createdTimestamp: number; public readonly createdAt: Date; public available: boolean | null; @@ -1596,7 +1677,7 @@ export class Sticker extends Base { } export class StickerPack extends Base { - public constructor(client: Client, data: APIStickerPack); + public constructor(client: Client, data: RawStickerPackData); public readonly createdTimestamp: number; public readonly createdAt: Date; public bannerId: Snowflake; @@ -1611,7 +1692,7 @@ export class StickerPack extends Base { } export class StoreChannel extends GuildChannel { - public constructor(guild: Guild, data?: unknown, client?: Client); + public constructor(guild: Guild, data?: RawGuildChannelData, client?: Client); public nsfw: boolean; public type: 'GUILD_STORE'; } @@ -1622,7 +1703,7 @@ export class SystemChannelFlags extends BitField { } export class Team extends Base { - public constructor(client: Client, data: unknown); + public constructor(client: Client, data: RawTeamData); public id: Snowflake; public name: string; public icon: string | null; @@ -1639,7 +1720,7 @@ export class Team extends Base { } export class TeamMember extends Base { - public constructor(team: Team, data: unknown); + public constructor(team: Team, data: RawTeamMemberData); public team: Team; public readonly id: Snowflake; public permissions: string[]; @@ -1650,7 +1731,7 @@ export class TeamMember extends Base { } export class TextChannel extends TextBasedChannel(GuildChannel) { - public constructor(guild: Guild, data?: unknown, client?: Client); + public constructor(guild: Guild, data?: RawGuildChannelData, client?: Client); public defaultAutoArchiveDuration?: ThreadAutoArchiveDuration; public messages: MessageManager; public nsfw: boolean; @@ -1670,7 +1751,7 @@ export class TextChannel extends TextBasedChannel(GuildChannel) { } export class ThreadChannel extends TextBasedChannel(Channel) { - public constructor(guild: Guild, data?: object, client?: Client, fromInteraction?: boolean); + public constructor(guild: Guild, data?: RawThreadChannelData, client?: Client, fromInteraction?: boolean); public archived: boolean | null; public readonly archivedAt: Date | null; public archiveTimestamp: number | null; @@ -1713,7 +1794,7 @@ export class ThreadChannel extends TextBasedChannel(Channel) { } export class ThreadMember extends Base { - public constructor(thread: ThreadChannel, data?: object); + public constructor(thread: ThreadChannel, data?: RawThreadMemberData); public flags: ThreadMemberFlags; public readonly guildMember: GuildMember | null; public id: Snowflake; @@ -1734,7 +1815,7 @@ export class Typing extends Base { public constructor( channel: TextChannel | PartialDMChannel | NewsChannel | ThreadChannel, user: PartialUser, - data?: object, + data?: RawTypingData, ); public channel: TextChannel | PartialDMChannel | NewsChannel | ThreadChannel; public user: PartialUser; @@ -1749,7 +1830,7 @@ export class Typing extends Base { } export class User extends PartialTextBasedChannel(Base) { - public constructor(client: Client, data: unknown); + public constructor(client: Client, data: RawUserData); public avatar: string | null; public bot: boolean; public readonly createdAt: Date; @@ -1845,7 +1926,7 @@ export class VoiceChannel extends BaseGuildVoiceChannel { } export class VoiceRegion { - public constructor(data: unknown); + public constructor(data: RawVoiceRegionData); public custom: boolean; public deprecated: boolean; public id: string; @@ -1856,7 +1937,7 @@ export class VoiceRegion { } export class VoiceState extends Base { - public constructor(guild: Guild, data: unknown); + public constructor(guild: Guild, data: RawVoiceStateData); public readonly channel: VoiceChannel | StageChannel | null; public channelId: Snowflake | null; public readonly deaf: boolean | null; @@ -1883,16 +1964,16 @@ export class VoiceState extends Base { } export class Webhook extends WebhookMixin() { - public constructor(client: Client, data?: unknown); + public constructor(client: Client, data?: RawWebhookData); public avatar: string; public avatarURL(options?: StaticImageURLOptions): string | null; public channelId: Snowflake; public client: Client; public guildId: Snowflake; public name: string; - public owner: User | unknown | null; - public sourceGuild: Guild | unknown | null; - public sourceChannel: Channel | unknown | null; + public owner: User | APIUser | null; + public sourceGuild: Guild | APIPartialGuild | null; + public sourceChannel: Channel | APIPartialChannel | null; public token: string | null; public type: WebhookType; } @@ -1992,8 +2073,8 @@ export class WebSocketShard extends EventEmitter { } export class Widget extends Base { - public constructor(client: Client, data: object); - private _patch(data: object): void; + public constructor(client: Client, data: RawWidgetData); + private _patch(data: RawWidgetData): void; public fetch(): Promise; public id: Snowflake; public instantInvite?: string; @@ -2003,7 +2084,7 @@ export class Widget extends Base { } export class WidgetMember extends Base { - public constructor(client: Client, data: object); + public constructor(client: Client, data: RawWidgetMemberData); public id: string; public username: string; public discriminator: string; @@ -2020,7 +2101,8 @@ export class WidgetMember extends Base { } export class WelcomeChannel extends Base { - private _emoji: unknown; + constructor(guild: Guild, data: RawWelcomeChannelData); + private _emoji: Omit; public channelId: Snowflake; public guild: Guild | InviteGuild; public description: string; @@ -2029,6 +2111,7 @@ export class WelcomeChannel extends Base { } export class WelcomeScreen extends Base { + constructor(guild: Guild, data: RawWelcomeScreenData); public readonly enabled: boolean; public guild: Guild | InviteGuild; public description: string | null; @@ -2164,7 +2247,7 @@ export class ApplicationCommandManager< PermissionsOptionsExtras = { guild: GuildResolvable }, PermissionsGuildType = null, > extends CachedManager { - public constructor(client: Client, iterable?: Iterable); + public constructor(client: Client, iterable?: Iterable); public permissions: ApplicationCommandPermissionsManager< { command?: ApplicationCommandResolvable } & PermissionsOptionsExtras, { command: ApplicationCommandResolvable } & PermissionsOptionsExtras, @@ -2196,7 +2279,9 @@ export class ApplicationCommandManager< commands: ApplicationCommandData[], guildId: Snowflake, ): Promise>; - private static transformCommand(command: ApplicationCommandData): unknown; + private static transformCommand( + command: ApplicationCommandData, + ): Omit; } export class ApplicationCommandPermissionsManager< @@ -2239,21 +2324,25 @@ export class ApplicationCommandPermissionsManager< }, ): Promise>; private permissionsPath(guildId: Snowflake, commandId?: Snowflake): unknown; - private static transformPermissions(permissions: ApplicationCommandPermissionData, received?: boolean): unknown; + private static transformPermissions( + permissions: ApplicationCommandPermissionData, + received: true, + ): Omit & { type: keyof ApplicationCommandPermissionTypes }; + private static transformPermissions(permissions: ApplicationCommandPermissionData): APIApplicationCommandPermission; } export class BaseGuildEmojiManager extends CachedManager { - public constructor(client: Client, iterable?: Iterable); + public constructor(client: Client, iterable?: Iterable); public resolveIdentifier(emoji: EmojiIdentifierResolvable): string | null; } export class ChannelManager extends CachedManager { - public constructor(client: Client, iterable: Iterable); + public constructor(client: Client, iterable: Iterable); public fetch(id: Snowflake, options?: FetchChannelOptions): Promise; } export class GuildApplicationCommandManager extends ApplicationCommandManager { - public constructor(guild: Guild, iterable?: Iterable); + public constructor(guild: Guild, iterable?: Iterable); public guild: Guild; public create(command: ApplicationCommandData): Promise; public delete(command: ApplicationCommandResolvable): Promise; @@ -2268,7 +2357,7 @@ export class GuildChannelManager extends CachedManager< GuildChannel | ThreadChannel, GuildChannelResolvable > { - public constructor(guild: Guild, iterable?: Iterable); + public constructor(guild: Guild, iterable?: Iterable); public readonly channelCountWithoutThreads: number; public guild: Guild; public create(name: string, options: GuildChannelCreateOptions & { type: 'GUILD_VOICE' }): Promise; @@ -2301,7 +2390,7 @@ export class GuildChannelManager extends CachedManager< } export class GuildEmojiManager extends BaseGuildEmojiManager { - public constructor(guild: Guild, iterable?: Iterable); + public constructor(guild: Guild, iterable?: Iterable); public guild: Guild; public create( attachment: BufferResolvable | Base64Resolvable, @@ -2326,14 +2415,14 @@ export class GuildEmojiRoleManager extends DataManager { - public constructor(client: Client, iterable?: Iterable); + public constructor(client: Client, iterable?: Iterable); public create(name: string, options?: GuildCreateOptions): Promise; public fetch(options: Snowflake | FetchGuildOptions): Promise; public fetch(options?: FetchGuildsOptions): Promise>; } export class GuildMemberManager extends CachedManager { - public constructor(guild: Guild, iterable?: Iterable); + public constructor(guild: Guild, iterable?: Iterable); public guild: Guild; public add( user: UserResolvable, @@ -2354,7 +2443,7 @@ export class GuildMemberManager extends CachedManager { - public constructor(guild: Guild, iterable?: Iterable); + public constructor(guild: Guild, iterable?: Iterable); public guild: Guild; public create(user: UserResolvable, options?: BanOptions): Promise; public fetch(options: UserResolvable | FetchBanOptions): Promise; @@ -2363,7 +2452,7 @@ export class GuildBanManager extends CachedManager { - public constructor(guild: Guild, iterable?: Iterable); + public constructor(guild: Guild, iterable?: Iterable); public guild: Guild; public create(channel: GuildChannelResolvable, options?: CreateInviteOptions): Promise; public fetch(options: InviteResolvable | FetchInviteOptions): Promise; @@ -2372,7 +2461,7 @@ export class GuildInviteManager extends DataManager { - public constructor(guild: Guild, iterable?: Iterable); + public constructor(guild: Guild, iterable?: Iterable); public guild: Guild; public create( file: BufferResolvable | Stream | FileOptions | MessageAttachment, @@ -2408,7 +2497,7 @@ export class GuildMemberRoleManager extends DataManager { - public constructor(channel: TextChannel | DMChannel | ThreadChannel, iterable?: Iterable); + public constructor(channel: TextChannel | DMChannel | ThreadChannel, iterable?: Iterable); public channel: TextBasedChannelFields; public cache: Collection; public crosspost(message: MessageResolvable): Promise; @@ -2430,7 +2519,7 @@ export class PermissionOverwriteManager extends CachedManager< PermissionOverwrites, PermissionOverwriteResolvable > { - public constructor(client: Client, iterable?: Iterable); + public constructor(client: Client, iterable?: Iterable); public set( overwrites: readonly OverwriteResolvable[] | Collection, reason?: string, @@ -2455,24 +2544,24 @@ export class PermissionOverwriteManager extends CachedManager< } export class PresenceManager extends CachedManager { - public constructor(client: Client, iterable?: Iterable); + public constructor(client: Client, iterable?: Iterable); } export class ReactionManager extends CachedManager { - public constructor(message: Message, iterable?: Iterable); + public constructor(message: Message, iterable?: Iterable); public message: Message; public removeAll(): Promise; } export class ReactionUserManager extends CachedManager { - public constructor(reaction: MessageReaction, iterable?: Iterable); + public constructor(reaction: MessageReaction, iterable?: Iterable); public reaction: MessageReaction; public fetch(options?: FetchReactionUsersOptions): Promise>; public remove(user?: UserResolvable): Promise; } export class RoleManager extends CachedManager { - public constructor(guild: Guild, iterable?: Iterable); + public constructor(guild: Guild, iterable?: Iterable); public readonly everyone: Role; public readonly highest: Role; public guild: Guild; @@ -2485,7 +2574,7 @@ export class RoleManager extends CachedManager } export class StageInstanceManager extends CachedManager { - public constructor(guild: Guild, iterable?: Iterable); + public constructor(guild: Guild, iterable?: Iterable); public guild: Guild; public create(channel: StageChannel | Snowflake, options: StageInstanceCreateOptions): Promise; public fetch(channel: StageChannel | Snowflake, options?: BaseFetchOptions): Promise; @@ -2494,7 +2583,7 @@ export class StageInstanceManager extends CachedManager extends CachedManager { - public constructor(channel: TextChannel | NewsChannel, iterable?: Iterable); + public constructor(channel: TextChannel | NewsChannel, iterable?: Iterable); public channel: TextChannel | NewsChannel; public create(options: ThreadCreateOptions): Promise; public fetch(options: ThreadChannelResolvable, cacheOptions?: BaseFetchOptions): Promise; @@ -2504,7 +2593,7 @@ export class ThreadManager extends CachedManager { - public constructor(thread: ThreadChannel, iterable?: Iterable); + public constructor(thread: ThreadChannel, iterable?: Iterable); public thread: ThreadChannel; public add(member: UserResolvable | '@me', reason?: string): Promise; public fetch(cache?: boolean): Promise>; @@ -2512,12 +2601,12 @@ export class ThreadMemberManager extends CachedManager { - public constructor(client: Client, iterable?: Iterable); + public constructor(client: Client, iterable?: Iterable); public fetch(id: Snowflake, options?: BaseFetchOptions): Promise; } export class VoiceStateManager extends CachedManager { - public constructor(guild: Guild, iterable?: Iterable); + public constructor(guild: Guild, iterable?: Iterable); public guild: Guild; } @@ -2580,7 +2669,7 @@ export interface WebhookFields extends PartialWebhookFields { readonly createdTimestamp: number; delete(reason?: string): Promise; edit(options: WebhookEditData, reason?: string): Promise; - sendSlackMessage(body: object): Promise; + sendSlackMessage(body: unknown): Promise; } //#endregion @@ -2809,9 +2898,9 @@ export type ApplicationFlagsString = | 'EMBEDDED'; export interface AuditLogChange { - key: string; - old?: unknown; - new?: unknown; + key: APIAuditLogChange['key']; + old?: APIAuditLogChange['old_value']; + new?: APIAuditLogChange['new_value']; } export type Awaited = T | PromiseLike; diff --git a/typings/rawDataTypes.d.ts b/typings/rawDataTypes.d.ts new file mode 100644 index 000000000..90a19b6e8 --- /dev/null +++ b/typings/rawDataTypes.d.ts @@ -0,0 +1,207 @@ +// These are aggregate types that are used in the typings file but do not exist as actual exported values. +// To prevent them from showing up in an editor, they are imported from here instead of exporting them there directly. + +import { + APIApplication, + APIApplicationCommand, + APIApplicationCommandInteraction, + APIAttachment, + APIAuditLog, + APIAuditLogEntry, + APIBan, + APIChannel, + APIEmoji, + APIExtendedInvite, + APIGuild, + APIGuildIntegration, + APIGuildIntegrationApplication, + APIGuildMember, + APIGuildPreview, + APIGuildWelcomeScreen, + APIGuildWelcomeScreenChannel, + APIGuildWidget, + APIGuildWidgetMember, + APIInteractionDataResolvedChannel, + APIInteractionDataResolvedGuildMember, + APIInteractionGuildMember, + APIInvite, + APIInviteStageInstance, + APIMessage, + APIMessageButtonInteractionData, + APIMessageComponentInteraction, + APIMessageSelectMenuInteractionData, + APIOverwrite, + APIPartialChannel, + APIPartialEmoji, + APIPartialGuild, + APIReaction, + APIRole, + APIStageInstance, + APISticker, + APIStickerItem, + APIStickerPack, + APITeam, + APITeamMember, + APITemplate, + APIThreadMember, + APIUnavailableGuild, + APIUser, + APIVoiceRegion, + APIWebhook, + GatewayActivity, + GatewayActivityAssets, + GatewayActivityEmoji, + GatewayGuildBanAddDispatchData, + GatewayGuildMemberAddDispatchData, + GatewayGuildMemberUpdateDispatchData, + GatewayInteractionCreateDispatchData, + GatewayInviteCreateDispatchData, + GatewayInviteDeleteDispatchData, + GatewayMessageReactionAddDispatchData, + GatewayMessageUpdateDispatchData, + GatewayPresenceUpdate, + GatewayReadyDispatchData, + GatewayTypingStartDispatchData, + GatewayVoiceState, + RESTAPIPartialCurrentUserGuild, + RESTGetAPIWebhookWithTokenResult, + RESTPatchAPIChannelMessageJSONBody, + RESTPatchAPICurrentGuildMemberNicknameJSONBody, + RESTPatchAPIInteractionFollowupJSONBody, + RESTPatchAPIInteractionOriginalResponseJSONBody, + RESTPatchAPIWebhookWithTokenJSONBody, + RESTPostAPIChannelMessageJSONBody, + RESTPostAPIInteractionCallbackFormDataBody, + RESTPostAPIInteractionFollowupJSONBody, + RESTPostAPIWebhookWithTokenJSONBody, + Snowflake, +} from 'discord-api-types/v9'; +import { GuildChannel, Guild, PermissionOverwrites } from '.'; + +export type RawActivityData = GatewayActivity; + +export type RawApplicationData = RawClientApplicationData | RawIntegrationApplicationData; +export type RawClientApplicationData = GatewayReadyDispatchData['application'] | APIMessage['application']; +export type RawIntegrationApplicationData = APIGuildIntegrationApplication | Partial; + +export type RawApplicationCommandData = APIApplicationCommand; + +export type RawChannelData = + | RawGuildChannelData + | RawThreadChannelData + | RawDMChannelData + | RawPartialGroupDMChannelData; +export type RawDMChannelData = APIChannel | APIInteractionDataResolvedChannel; +export type RawGuildChannelData = APIChannel | APIInteractionDataResolvedChannel | Required; +export type RawPartialGroupDMChannelData = APIChannel | Required; +export type RawThreadChannelData = APIChannel | APIInteractionDataResolvedChannel; + +export type RawEmojiData = + | RawGuildEmojiData + | RawReactionEmojiData + | GatewayActivityEmoji + | Omit, 'animated'>; +export type RawGuildEmojiData = APIEmoji; +export type RawReactionEmojiData = APIEmoji | APIPartialEmoji; + +export type RawGuildAuditLogData = APIAuditLog; + +export type RawGuildAuditLogEntryData = APIAuditLogEntry; + +export type RawGuildBanData = GatewayGuildBanAddDispatchData | APIBan; + +export type RawGuildData = APIGuild | APIUnavailableGuild; +export type RawAnonymousGuildData = RawGuildData | RawInviteGuildData; +export type RawBaseGuildData = RawAnonymousGuildData | RawOAuth2GuildData; +export type RawInviteGuildData = APIPartialGuild; +export type RawOAuth2GuildData = RESTAPIPartialCurrentUserGuild; + +export type RawGuildMemberData = + | APIGuildMember + | APIInteractionGuildMember + | APIInteractionDataResolvedGuildMember + | GatewayGuildMemberAddDispatchData + | GatewayGuildMemberUpdateDispatchData + | Required + | { user: { id: Snowflake } }; +export type RawThreadMemberData = APIThreadMember; + +export type RawGuildPreviewData = APIGuildPreview; + +export type RawGuildTemplateData = APITemplate; + +export type RawIntegrationData = APIGuildIntegration; + +export type RawInteractionData = GatewayInteractionCreateDispatchData; +export type RawCommandInteractionData = APIApplicationCommandInteraction; +export type RawMessageComponentInteractionData = APIMessageComponentInteraction; +export type RawMessageButtonInteractionData = APIMessageButtonInteractionData; +export type RawMessageSelectMenuInteractionData = APIMessageSelectMenuInteractionData; + +export type RawInviteData = + | APIExtendedInvite + | APIInvite + | (GatewayInviteCreateDispatchData & { channel: GuildChannel; guild: Guild }) + | (GatewayInviteDeleteDispatchData & { channel: GuildChannel; guild: Guild }); + +export type RawInviteStageInstance = APIInviteStageInstance; + +export type RawMessageData = APIMessage; +export type RawPartialMessageData = GatewayMessageUpdateDispatchData; + +export type RawMessageAttachementData = APIAttachment; + +export type RawMessagePayloadData = + | RESTPostAPIChannelMessageJSONBody + | RESTPatchAPIChannelMessageJSONBody + | RESTPostAPIWebhookWithTokenJSONBody + | RESTPatchAPIWebhookWithTokenJSONBody + | RESTPostAPIInteractionCallbackFormDataBody + | RESTPatchAPIInteractionOriginalResponseJSONBody + | RESTPostAPIInteractionFollowupJSONBody + | RESTPatchAPIInteractionFollowupJSONBody; + +export type RawMessageReactionData = APIReaction | GatewayMessageReactionAddDispatchData; + +export type RawPermissionOverwriteData = APIOverwrite | PermissionOverwrites; + +export type RawPresenceData = GatewayPresenceUpdate; + +export type RawRoleData = APIRole; + +export type RawRichPresenceAssets = GatewayActivityAssets; + +export type RawStageInstanceData = + | APIStageInstance + | (Partial & Pick); + +export type RawStickerData = APISticker | APIStickerItem; + +export type RawStickerPackData = APIStickerPack; + +export type RawTeamData = APITeam; + +export type RawTeamMemberData = APITeamMember; + +export type RawTypingData = GatewayTypingStartDispatchData; + +export type RawUserData = + | (APIUser & { member?: Omit }) + | (GatewayPresenceUpdate['user'] & Pick); + +export type RawVoiceRegionData = APIVoiceRegion; + +export type RawVoiceStateData = GatewayVoiceState | Omit; + +export type RawWebhookData = + | APIWebhook + | RESTGetAPIWebhookWithTokenResult + | (Partial & Required>); + +export type RawWelcomeChannelData = APIGuildWelcomeScreenChannel; + +export type RawWelcomeScreenData = APIGuildWelcomeScreen; + +export type RawWidgetData = APIGuildWidget; + +export type RawWidgetMemberData = APIGuildWidgetMember; diff --git a/typings/index.ts b/typings/tests.ts similarity index 99% rename from typings/index.ts rename to typings/tests.ts index 050167d25..ef80380c3 100644 --- a/typings/index.ts +++ b/typings/tests.ts @@ -54,7 +54,7 @@ import { Typing, User, VoiceChannel, -} from '..'; +} from '.'; const client: Client = new Client({ intents: Intents.FLAGS.GUILDS,