diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 5588e75dbc4b..6153c98734df 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -281,7 +281,7 @@ export class ActivityFlagsBitField extends BitField { } export abstract class AnonymousGuild extends BaseGuild { - protected constructor(client: Client, data: RawAnonymousGuildData, immediatePatch?: boolean); + protected constructor(client: Client, data: RawAnonymousGuildData, immediatePatch?: boolean); public banner: string | null; public description: string | null; public nsfwLevel: GuildNSFWLevel; @@ -294,7 +294,7 @@ export abstract class AnonymousGuild extends BaseGuild { } export abstract class Application extends Base { - protected constructor(client: Client, data: RawApplicationData); + protected constructor(client: Client, data: RawApplicationData); public get createdAt(): Date; public get createdTimestamp(): number; public description: string | null; @@ -308,7 +308,7 @@ export abstract class Application extends Base { } export class ApplicationCommand extends Base { - private constructor(client: Client, data: RawApplicationCommandData, guild?: Guild, guildId?: Snowflake); + private constructor(client: Client, data: RawApplicationCommandData, guild?: Guild, guildId?: Snowflake); public applicationId: Snowflake; public get createdAt(): Date; public get createdTimestamp(): number; @@ -373,8 +373,8 @@ export class ApplicationFlagsBitField extends BitField { } export abstract class Base { - public constructor(client: Client); - public readonly client: Client; + public constructor(client: Client); + public readonly client: Client; public toJSON(...props: Record[]): unknown; public valueOf(): string; } @@ -474,7 +474,7 @@ export class InteractionResponse { } export abstract class BaseGuild extends Base { - protected constructor(client: Client, data: RawBaseGuildData); + protected constructor(client: Client, data: RawBaseGuildData); public get createdAt(): Date; public get createdTimestamp(): number; public features: `${GuildFeature}`[]; @@ -490,7 +490,7 @@ export abstract class BaseGuild extends Base { } export class BaseGuildEmoji extends Emoji { - protected constructor(client: Client, data: RawGuildEmojiData, guild: Guild | GuildPreview); + protected constructor(client: Client, data: RawGuildEmojiData, guild: Guild | GuildPreview); public available: boolean | null; public get createdAt(): Date; public get createdTimestamp(): number; @@ -501,7 +501,7 @@ export class BaseGuildEmoji extends Emoji { } export class BaseGuildTextChannel extends TextBasedChannelMixin(GuildChannel, true) { - protected constructor(guild: Guild, data?: RawGuildChannelData, client?: Client, immediatePatch?: boolean); + protected constructor(guild: Guild, data?: RawGuildChannelData, client?: Client, immediatePatch?: boolean); public defaultAutoArchiveDuration?: ThreadAutoArchiveDuration; public rateLimitPerUser: number | null; public nsfw: boolean; @@ -553,7 +553,7 @@ export class BitField { } export class ButtonInteraction extends MessageComponentInteraction { - private constructor(client: Client, data: RawMessageButtonInteractionData); + private constructor(client: Client, data: RawMessageButtonInteractionData); public componentType: ComponentType.Button; public get component(): CacheTypeReducer< Cached, @@ -725,7 +725,7 @@ export class CategoryChannel extends GuildChannel { export type CategoryChannelResolvable = Snowflake | CategoryChannel; export abstract class BaseChannel extends Base { - public constructor(client: Client, data?: RawChannelData, immediatePatch?: boolean); + public constructor(client: Client, data?: RawChannelData, immediatePatch?: boolean); public get createdAt(): Date | null; public get createdTimestamp(): number | null; public id: Snowflake; @@ -805,7 +805,7 @@ export class Client extends BaseClient { } export class ClientApplication extends Application { - private constructor(client: Client, data: RawClientApplicationData); + private constructor(client: Client, data: RawClientApplicationData); public botPublic: boolean | null; public botRequireCodeGrant: boolean | null; public commands: ApplicationCommandManager; @@ -821,7 +821,7 @@ export class ClientApplication extends Application { } export class ClientPresence extends Presence { - private constructor(client: Client, data: RawPresenceData); + private constructor(client: Client, data: RawPresenceData); private _parse(data: PresenceData): RawPresenceData; public set(presence: PresenceData): ClientPresence; @@ -866,7 +866,7 @@ export interface CollectorEventTypes { } export abstract class Collector extends EventEmitter { - protected constructor(client: Client, options?: CollectorOptions<[V, ...F]>); + protected constructor(client: Client, options?: CollectorOptions<[V, ...F]>); private _timeout: NodeJS.Timeout | null; private _idletimeout: NodeJS.Timeout | null; private _endReason: string | null; @@ -930,7 +930,11 @@ export class AutocompleteInteraction exten } export class CommandInteractionOptionResolver { - private constructor(client: Client, options: CommandInteractionOption[], resolved: CommandInteractionResolvedData); + private constructor( + client: Client, + options: CommandInteractionOption[], + resolved: CommandInteractionResolvedData, + ); public readonly client: Client; public readonly data: readonly CommandInteractionOption[]; public readonly resolved: Readonly> | null; @@ -1035,7 +1039,7 @@ export class DMChannel extends TextBasedChannelMixin(BaseChannel, false, [ 'setRateLimitPerUser', 'setNSFW', ]) { - private constructor(client: Client, data?: RawDMChannelData); + private constructor(client: Client, data?: RawDMChannelData); public recipientId: Snowflake; public get recipient(): User | null; public type: ChannelType.DM; @@ -1044,7 +1048,7 @@ export class DMChannel extends TextBasedChannelMixin(BaseChannel, false, [ } export class Emoji extends Base { - protected constructor(client: Client, emoji: RawEmojiData); + protected constructor(client: Client, emoji: RawEmojiData); public animated: boolean | null; public get createdAt(): Date | null; public get createdTimestamp(): number | null; @@ -1057,7 +1061,7 @@ export class Emoji extends Base { } export class Guild extends AnonymousGuild { - private constructor(client: Client, data: RawGuildData); + private constructor(client: Client, data: RawGuildData); private _sortedRoles(): Collection; private _sortedChannels(channel: NonThreadGuildBasedChannel): Collection; @@ -1203,7 +1207,7 @@ export class GuildAuditLogsEntry< } export class GuildBan extends Base { - private constructor(client: Client, data: RawGuildBanData, guild: Guild); + private constructor(client: Client, data: RawGuildBanData, guild: Guild); public guild: Guild; public user: User; public get partial(): boolean; @@ -1212,7 +1216,7 @@ export class GuildBan extends Base { } export abstract class GuildChannel extends BaseChannel { - public constructor(guild: Guild, data?: RawGuildChannelData, client?: Client, immediatePatch?: boolean); + public constructor(guild: Guild, data?: RawGuildChannelData, client?: Client, immediatePatch?: boolean); private memberPermissions(member: GuildMember, checkAdmin: boolean): Readonly; private rolePermissions(role: Role, checkAdmin: boolean): Readonly; public get createdAt(): Date; @@ -1249,7 +1253,7 @@ export abstract class GuildChannel extends BaseChannel { } export class GuildEmoji extends BaseGuildEmoji { - private constructor(client: Client, data: RawGuildEmojiData, guild: Guild); + private constructor(client: Client, data: RawGuildEmojiData, guild: Guild); private _roles: Snowflake[]; public get deletable(): boolean; @@ -1265,7 +1269,7 @@ export class GuildEmoji extends BaseGuildEmoji { } export class GuildMember extends PartialTextBasedChannel(Base) { - private constructor(client: Client, data: RawGuildMemberData, guild: Guild); + private constructor(client: Client, data: RawGuildMemberData, guild: Guild); public avatar: string | null; public get bannable(): boolean; public get dmChannel(): DMChannel | null; @@ -1313,7 +1317,7 @@ export class GuildMember extends PartialTextBasedChannel(Base) { } export class GuildPreview extends Base { - private constructor(client: Client, data: RawGuildPreviewData); + private constructor(client: Client, data: RawGuildPreviewData); public approximateMemberCount: number; public approximatePresenceCount: number; public get createdAt(): Date; @@ -1336,7 +1340,7 @@ export class GuildPreview extends Base { } export class GuildScheduledEvent extends Base { - private constructor(client: Client, data: RawGuildScheduledEventData); + private constructor(client: Client, data: RawGuildScheduledEventData); public id: Snowflake; public guildId: Snowflake; public channelId: Snowflake | null; @@ -1386,7 +1390,7 @@ export class GuildScheduledEvent, data: RawGuildTemplateData); public createdTimestamp: number; public updatedTimestamp: number; public get url(): string; @@ -1410,13 +1414,13 @@ export class GuildTemplate extends Base { } export class GuildPreviewEmoji extends BaseGuildEmoji { - private constructor(client: Client, data: RawGuildEmojiData, guild: GuildPreview); + private constructor(client: Client, data: RawGuildEmojiData, guild: GuildPreview); public guild: GuildPreview; public roles: Snowflake[]; } export class Integration extends Base { - private constructor(client: Client, data: RawIntegrationData, guild: Guild); + private constructor(client: Client, data: RawIntegrationData, guild: Guild); public account: IntegrationAccount; public application: IntegrationApplication | null; public enabled: boolean | null; @@ -1440,7 +1444,7 @@ export class Integration extends Base { } export class IntegrationApplication extends Application { - private constructor(client: Client, data: RawIntegrationApplicationData); + private constructor(client: Client, data: RawIntegrationApplicationData); public bot: User | null; public termsOfServiceURL: string | null; public privacyPolicyURL: string | null; @@ -1486,7 +1490,7 @@ export type RepliableInteraction = Exclude export class BaseInteraction extends Base { // This a technique used to brand different cached types. Or else we'll get `never` errors on typeguard checks. private readonly _cacheType: Cached; - protected constructor(client: Client, data: RawInteractionData); + protected constructor(client: Client, data: RawInteractionData); public applicationId: Snowflake; public get channel(): CacheTypeReducer< Cached, @@ -1531,7 +1535,7 @@ export class InteractionCollector extends Collec T, [Collection] > { - public constructor(client: Client, options?: InteractionCollectorOptions); + public constructor(client: Client, options?: InteractionCollectorOptions); private _handleMessageDeletion(message: Message): void; private _handleChannelDeletion(channel: NonThreadGuildBasedChannel): void; private _handleGuildDeletion(guild: Guild): void; @@ -1559,7 +1563,7 @@ export class InteractionCollector extends Collec } export class InteractionWebhook extends PartialWebhookMixin() { - public constructor(client: Client, id: Snowflake, token: string); + public constructor(client: Client, id: Snowflake, token: string); public token: string; public send(options: string | MessagePayload | InteractionReplyOptions): Promise; public editMessage( @@ -1570,7 +1574,7 @@ export class InteractionWebhook extends PartialWebhookMixin() { } export class Invite extends Base { - private constructor(client: Client, data: RawInviteData); + private constructor(client: Client, data: RawInviteData); public channel: NonThreadGuildBasedChannel | PartialGroupDMChannel | null; public channelId: Snowflake | null; public code: string; @@ -1603,7 +1607,7 @@ export class Invite extends Base { /** @deprecated */ export class InviteStageInstance extends Base { - private constructor(client: Client, data: RawInviteStageInstance, channelId: Snowflake, guildId: Snowflake); + private constructor(client: Client, data: RawInviteStageInstance, channelId: Snowflake, guildId: Snowflake); public channelId: Snowflake; public guildId: Snowflake; public members: Collection; @@ -1615,7 +1619,7 @@ export class InviteStageInstance extends Base { } export class InviteGuild extends AnonymousGuild { - private constructor(client: Client, data: RawInviteGuildData); + private constructor(client: Client, data: RawInviteGuildData); public welcomeScreen: WelcomeScreen | null; } @@ -1658,7 +1662,7 @@ export interface MappedInteractionTypes { export class Message extends Base { private readonly _cacheType: InGuild; - private constructor(client: Client, data: RawMessageData); + private constructor(client: Client, data: RawMessageData); private _patch(data: RawPartialMessageData | RawMessageData): void; public activity: MessageActivity | null; @@ -1773,7 +1777,7 @@ export class MessageCollector extends Collector extends BaseInteraction { - protected constructor(client: Client, data: RawMessageComponentInteractionData); + protected constructor(client: Client, data: RawMessageComponentInteractionData); public type: InteractionType.MessageComponent; public get component(): CacheTypeReducer< Cached, @@ -1910,10 +1914,10 @@ export class MessagePayload { } export class MessageReaction { - private constructor(client: Client, data: RawMessageReactionData, message: Message); + private constructor(client: Client, data: RawMessageReactionData, message: Message); private _emoji: GuildEmoji | ReactionEmoji; - public readonly client: Client; + public readonly client: Client; public count: number; public get emoji(): GuildEmoji | ReactionEmoji; public me: boolean; @@ -1975,7 +1979,7 @@ export interface ModalMessageModalSubmitInteraction extends BaseInteraction { - private constructor(client: Client, data: APIModalSubmitInteraction); + private constructor(client: Client, data: APIModalSubmitInteraction); public type: InteractionType.ModalSubmit; public readonly customId: string; public readonly components: ActionRowModalData[]; @@ -2014,13 +2018,13 @@ export class NewsChannel extends BaseGuildTextChannel { } export class OAuth2Guild extends BaseGuild { - private constructor(client: Client, data: RawOAuth2GuildData); + private constructor(client: Client, data: RawOAuth2GuildData); public owner: boolean; public permissions: Readonly; } export class PartialGroupDMChannel extends BaseChannel { - private constructor(client: Client, data: RawPartialGroupDMChannelData); + private constructor(client: Client, data: RawPartialGroupDMChannelData); public type: ChannelType.GroupDM; public name: string | null; public icon: string | null; @@ -2030,7 +2034,7 @@ export class PartialGroupDMChannel extends BaseChannel { } export class PermissionOverwrites extends Base { - private constructor(client: Client, data: RawPermissionOverwriteData, channel: NonThreadGuildBasedChannel); + private constructor(client: Client, data: RawPermissionOverwriteData, channel: NonThreadGuildBasedChannel); public allow: Readonly; public readonly channel: NonThreadGuildBasedChannel; public deny: Readonly; @@ -2063,7 +2067,7 @@ export class PermissionsBitField extends BitField { } export class Presence extends Base { - protected constructor(client: Client, data?: RawPresenceData); + protected constructor(client: Client, data?: RawPresenceData); public activities: Activity[]; public clientStatus: ClientPresenceStatusData | null; public guild: Guild | null; @@ -2126,7 +2130,7 @@ export class RichPresenceAssets { } export class Role extends Base { - private constructor(client: Client, data: RawRoleData, guild: Guild); + private constructor(client: Client, data: RawRoleData, guild: Guild); public color: number; public get createdAt(): Date; public get createdTimestamp(): number; @@ -2167,7 +2171,7 @@ export class Role extends Base { } export class SelectMenuInteraction extends MessageComponentInteraction { - public constructor(client: Client, data: RawMessageSelectMenuInteractionData); + public constructor(client: Client, data: RawMessageSelectMenuInteractionData); public get component(): CacheTypeReducer< Cached, SelectMenuComponent, @@ -2212,7 +2216,7 @@ export class Shard extends EventEmitter { public worker: Worker | null; public eval(script: string): Promise; public eval(fn: (client: Client) => T): Promise; - public eval(fn: (client: Client, context: Serialized

) => T, context: P): Promise; + public eval(fn: (client: Client, context: Serialized

) => T, context: P): Promise; public fetchClientValue(prop: string): Promise; public kill(): void; public respawn(options?: { delay?: number; timeout?: number }): Promise; @@ -2231,7 +2235,7 @@ export class Shard extends EventEmitter { } export class ShardClientUtil { - private constructor(client: Client, mode: ShardingManagerMode); + private constructor(client: Client, mode: ShardingManagerMode); private _handleMessage(message: unknown): void; private _respond(type: string, message: unknown): void; private incrementMaxListeners(emitter: EventEmitter | ChildProcess): void; @@ -2245,11 +2249,11 @@ export class ShardClientUtil { public broadcastEval(fn: (client: Client) => Awaitable): Promise[]>; public broadcastEval(fn: (client: Client) => Awaitable, options: { shard: number }): Promise>; public broadcastEval( - fn: (client: Client, context: Serialized

) => Awaitable, + fn: (client: Client, context: Serialized

) => Awaitable, options: { context: P }, ): Promise[]>; public broadcastEval( - fn: (client: Client, context: Serialized

) => Awaitable, + fn: (client: Client, context: Serialized

) => Awaitable, options: { context: P; shard: number }, ): Promise>; public fetchClientValues(prop: string): Promise; @@ -2257,7 +2261,7 @@ export class ShardClientUtil { public respawnAll(options?: MultipleShardRespawnOptions): Promise; public send(message: unknown): Promise; - public static singleton(client: Client, mode: ShardingManagerMode): ShardClientUtil; + public static singleton(client: Client, mode: ShardingManagerMode): ShardClientUtil; public static shardIdForGuildId(guildId: Snowflake, shardCount: number): number; } @@ -2277,11 +2281,11 @@ export class ShardingManager extends EventEmitter { public broadcastEval(fn: (client: Client) => Awaitable): Promise[]>; public broadcastEval(fn: (client: Client) => Awaitable, options: { shard: number }): Promise>; public broadcastEval( - fn: (client: Client, context: Serialized

) => Awaitable, + fn: (client: Client, context: Serialized

) => Awaitable, options: { context: P }, ): Promise[]>; public broadcastEval( - fn: (client: Client, context: Serialized

) => Awaitable, + fn: (client: Client, context: Serialized

) => Awaitable, options: { context: P; shard: number }, ): Promise>; public createShard(id: number): Shard; @@ -2321,7 +2325,7 @@ export class DirectoryChannel extends BaseChannel { } export class StageInstance extends Base { - private constructor(client: Client, data: RawStageInstanceData, channel: StageChannel); + private constructor(client: Client, data: RawStageInstanceData, channel: StageChannel); public id: Snowflake; public guildId: Snowflake; public channelId: Snowflake; @@ -2341,7 +2345,7 @@ export class StageInstance extends Base { } export class Sticker extends Base { - private constructor(client: Client, data: RawStickerData); + private constructor(client: Client, data: RawStickerData); public get createdTimestamp(): number; public get createdAt(): Date; public available: boolean | null; @@ -2367,7 +2371,7 @@ export class Sticker extends Base { } export class StickerPack extends Base { - private constructor(client: Client, data: RawStickerPackData); + private constructor(client: Client, data: RawStickerPackData); public get createdTimestamp(): number; public get createdAt(): Date; public bannerId: Snowflake | null; @@ -2382,7 +2386,7 @@ export class StickerPack extends Base { } export class Sweepers { - public constructor(client: Client, options: SweeperOptions); + public constructor(client: Client, options: SweeperOptions); public readonly client: Client; public intervals: Record; public options: SweeperOptions; @@ -2451,7 +2455,7 @@ export class SystemChannelFlagsBitField extends BitField, data: RawTeamData); public id: Snowflake; public name: string; public icon: string | null; @@ -2500,7 +2504,7 @@ export class ThreadChannel extends TextBasedChannelMixin(BaseChannel, true, [ 'createWebhook', 'setNSFW', ]) { - private constructor(guild: Guild, data?: RawThreadChannelData, client?: Client, fromInteraction?: boolean); + private constructor(guild: Guild, data?: RawThreadChannelData, client?: Client, fromInteraction?: boolean); public archived: boolean | null; public get archivedAt(): Date | null; public archiveTimestamp: number | null; @@ -2587,7 +2591,7 @@ export class Typing extends Base { } export class User extends PartialTextBasedChannel(Base) { - protected constructor(client: Client, data: RawUserData); + protected constructor(client: Client, data: RawUserData); private _equals(user: APIUser): boolean; public accentColor: number | null | undefined; @@ -2664,7 +2668,7 @@ export function setPosition( position: number, relative: boolean, sorted: Collection, - client: Client, + client: Client, route: string, reason?: string, ): Promise<{ id: Snowflake; position: number }[]>; @@ -2689,7 +2693,7 @@ export interface CreateChannelOptions { fromInteraction?: boolean; } -export function createChannel(client: Client, data: APIChannel, options?: CreateChannelOptions): Channel; +export function createChannel(client: Client, data: APIChannel, options?: CreateChannelOptions): Channel; export function createComponent( data: APIMessageComponent & { type: T }, @@ -2798,7 +2802,7 @@ export class VoiceState extends Base { } export class Webhook extends WebhookMixin() { - private constructor(client: Client, data?: RawWebhookData); + private constructor(client: Client, data?: RawWebhookData); public avatar: string | null; public avatarURL(options?: ImageURLOptions): string | null; public channelId: Snowflake; @@ -2956,7 +2960,7 @@ export class WebSocketShard extends EventEmitter { } export class Widget extends Base { - private constructor(client: Client, data: RawWidgetData); + private constructor(client: Client, data: RawWidgetData); private _patch(data: RawWidgetData): void; public fetch(): Promise; public id: Snowflake; @@ -2967,7 +2971,7 @@ export class Widget extends Base { } export class WidgetMember extends Base { - private constructor(client: Client, data: RawWidgetMemberData); + private constructor(client: Client, data: RawWidgetMemberData); public id: string; public username: string; public discriminator: string; @@ -3194,7 +3198,7 @@ export abstract class BaseManager { } export abstract class DataManager extends BaseManager { - protected constructor(client: Client, holds: Constructable); + protected constructor(client: Client, holds: Constructable); public readonly holds: Constructable; public get cache(): Collection; public resolve(resolvable: Holds): Holds; @@ -3205,7 +3209,7 @@ export abstract class DataManager extends BaseManager { } export abstract class CachedManager extends DataManager { - protected constructor(client: Client, holds: Constructable); + protected constructor(client: Client, holds: Constructable); private _add(data: unknown, cache?: boolean, { id, extras }?: { id: K; extras: unknown[] }): Holds; } @@ -3219,7 +3223,7 @@ export class ApplicationCommandManager< PermissionsOptionsExtras = { guild: GuildResolvable }, PermissionsGuildType = null, > extends CachedManager { - protected constructor(client: Client, iterable?: Iterable); + protected constructor(client: Client, iterable?: Iterable); public permissions: ApplicationCommandPermissionsManager< { command?: ApplicationCommandResolvable } & PermissionsOptionsExtras, { command: ApplicationCommandResolvable } & PermissionsOptionsExtras, @@ -3307,7 +3311,7 @@ export class ApplicationCommandPermissionsManager< } export class BaseGuildEmojiManager extends CachedManager { - protected constructor(client: Client, iterable?: Iterable); + protected constructor(client: Client, iterable?: Iterable); public resolveIdentifier(emoji: EmojiIdentifierResolvable): string | null; } @@ -3323,7 +3327,7 @@ export class CategoryChannelChildManager extends DataManager { - private constructor(client: Client, iterable: Iterable); + private constructor(client: Client, iterable: Iterable); public fetch(id: Snowflake, options?: FetchChannelOptions): Promise; } @@ -3405,7 +3409,7 @@ export class GuildEmojiRoleManager extends DataManager { - private constructor(client: Client, iterable?: Iterable); + private constructor(client: Client, iterable?: Iterable); public create(options: GuildCreateOptions): Promise; public fetch(options: Snowflake | FetchGuildOptions): Promise; public fetch(options?: FetchGuildsOptions): Promise>; @@ -3543,7 +3547,7 @@ export class PermissionOverwriteManager extends CachedManager< PermissionOverwrites, PermissionOverwriteResolvable > { - private constructor(client: Client, iterable?: Iterable); + private constructor(client: Client, iterable?: Iterable); public set( overwrites: readonly OverwriteResolvable[] | Collection, reason?: string, @@ -3568,7 +3572,7 @@ export class PermissionOverwriteManager extends CachedManager< } export class PresenceManager extends CachedManager { - private constructor(client: Client, iterable?: Iterable); + private constructor(client: Client, iterable?: Iterable); } export class ReactionManager extends CachedManager { @@ -3632,7 +3636,7 @@ export class ThreadMemberManager extends CachedManager { - private constructor(client: Client, iterable?: Iterable); + private constructor(client: Client, iterable?: Iterable); private dmChannel(userId: Snowflake): DMChannel | null; public createDM(user: UserResolvable, options?: BaseFetchOptions): Promise; public deleteDM(user: UserResolvable): Promise; @@ -5332,7 +5336,7 @@ export type Partialize< M extends keyof T | null = null, E extends keyof T | '' = '', > = { - readonly client: Client; + readonly client: Client; id: Snowflake; partial: true; } & { diff --git a/packages/discord.js/typings/index.test-d.ts b/packages/discord.js/typings/index.test-d.ts index c70dfb5223db..2b6a4a41e575 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -165,8 +165,383 @@ const guildCommandId = '234567890123456789'; // example id declare const slashCommandBuilder: SlashCommandBuilder; declare const contextMenuCommandBuilder: ContextMenuCommandBuilder; -client.on('ready', async () => { - console.log(`Client is logged in as ${client.user!.tag} and ready!`); +client.on('channelCreate', ({ client }) => expectType>(client)); +client.on('channelDelete', ({ client }) => expectType>(client)); +client.on('channelPinsUpdate', ({ client }) => expectType>(client)); + +client.on('channelUpdate', ({ client: oldClient }, { client: newClient }) => { + expectType>(oldClient); + expectType>(newClient); +}); + +client.on('emojiCreate', ({ client }) => expectType>(client)); +client.on('emojiDelete', ({ client }) => expectType>(client)); + +client.on('emojiUpdate', ({ client: oldClient }, { client: newClient }) => { + expectType>(oldClient); + expectType>(newClient); +}); + +client.on('guildBanAdd', ({ client }) => expectType>(client)); +client.on('guildBanRemove', ({ client }) => expectType>(client)); +client.on('guildDelete', ({ client }) => expectType>(client)); +client.on('guildIntegrationsUpdate', ({ client }) => expectType>(client)); +client.on('guildMemberAdd', ({ client }) => expectType>(client)); +client.on('guildMemberAvailable', ({ client }) => expectType>(client)); + +client.on('guildMemberRemove', member => { + expectType>(member.client); + if (member.partial) return expectType(member.joinedAt); + expectType(member.joinedAt); +}); + +client.on('guildMembersChunk', (members, { client }) => { + expectType>(members.first()!.client); + expectType>(client); +}); + +client.on('guildMemberUpdate', ({ client: oldClient }, { client: newClient }) => { + expectType>(oldClient); + expectType>(newClient); +}); + +client.on('guildScheduledEventCreate', ({ client }) => expectType>(client)); +client.on('guildScheduledEventDelete', ({ client }) => expectType>(client)); + +client.on('guildScheduledEventUpdate', (oldGuildScheduledEvent, { client }) => { + expectType>(oldGuildScheduledEvent!.client); + expectType>(client); +}); + +client.on('guildScheduledEventUserAdd', ({ client: oldClient }, { client: newClient }) => { + expectType>(oldClient); + expectType>(newClient); +}); + +client.on('guildScheduledEventUserRemove', ({ client: oldClient }, { client: newClient }) => { + expectType>(oldClient); + expectType>(newClient); +}); + +client.on('guildUnavailable', ({ client }) => expectType>(client)); + +client.on('guildUpdate', ({ client: oldClient }, { client: newClient }) => { + expectType>(oldClient); + expectType>(newClient); +}); + +client.on('interactionCreate', async interaction => { + expectType>(interaction.client); + expectType(interaction.guildId); + expectType(interaction.channelId); + expectType(interaction.member); + + if (interaction.type === InteractionType.MessageComponent) { + expectType(interaction.channelId); + } + + if (interaction.type !== InteractionType.ApplicationCommand) return; + + void new ActionRowBuilder(); + + const button = new ButtonBuilder(); + + const actionRow = new ActionRowBuilder({ + type: ComponentType.ActionRow, + components: [button.toJSON()], + }); + + actionRow.toJSON(); + + await interaction.reply({ content: 'Hi!', components: [actionRow] }); + + // @ts-expect-error + interaction.reply({ content: 'Hi!', components: [[button]] }); + + void new ActionRowBuilder({}); + + // @ts-expect-error + await interaction.reply({ content: 'Hi!', components: [button] }); + + await interaction.reply({ + content: 'test', + components: [ + { + components: [ + { + custom_id: 'abc', + label: 'abc', + style: ButtonStyle.Primary, + type: ComponentType.Button, + }, + ], + type: ComponentType.ActionRow, + }, + ], + }); + + // This is for testing never type resolution + if (!interaction.inGuild()) { + return; + } + + if (interaction.inRawGuild()) { + expectNotType(interaction); + return; + } + + if (interaction.inCachedGuild()) { + expectNotType(interaction); + return; + } +}); + +client.on('inviteCreate', ({ client }) => expectType>(client)); +client.on('inviteDelete', ({ client }) => expectType>(client)); + +// This is to check that stuff is the right type +declare const assertIsMessage: (m: Promise) => void; + +client.on('messageCreate', async message => { + const { client, channel } = message; + expectType>(client); + assertIsMessage(channel.send('string')); + assertIsMessage(channel.send({})); + assertIsMessage(channel.send({ embeds: [] })); + + const attachment = new AttachmentBuilder('file.png'); + const embed = new EmbedBuilder(); + assertIsMessage(channel.send({ files: [attachment] })); + assertIsMessage(channel.send({ embeds: [embed] })); + assertIsMessage(channel.send({ embeds: [embed], files: [attachment] })); + + if (message.inGuild()) { + expectAssignable>(message); + const component = await message.awaitMessageComponent({ componentType: ComponentType.Button }); + expectType>(component); + expectType>(await component.reply({ fetchReply: true })); + + const buttonCollector = message.createMessageComponentCollector({ componentType: ComponentType.Button }); + expectType>>(buttonCollector); + expectAssignable< + ( + test: ButtonInteraction<'cached'>, + items: Collection>, + ) => boolean | Promise + >(buttonCollector.filter); + expectType(message.channel); + expectType(message.guild); + expectType(message.member); + } + + expectType(message.channel); + expectNotType(message.channel); + + // @ts-expect-error + channel.send(); + // @ts-expect-error + channel.send({ another: 'property' }); + + // Check collector creations. + + // Verify that buttons interactions are inferred. + const buttonCollector = message.createMessageComponentCollector({ componentType: ComponentType.Button }); + expectAssignable>(message.awaitMessageComponent({ componentType: ComponentType.Button })); + expectAssignable>(channel.awaitMessageComponent({ componentType: ComponentType.Button })); + expectAssignable>(buttonCollector); + + // Verify that select menus interaction are inferred. + const selectMenuCollector = message.createMessageComponentCollector({ componentType: ComponentType.SelectMenu }); + expectAssignable>( + message.awaitMessageComponent({ componentType: ComponentType.SelectMenu }), + ); + expectAssignable>( + channel.awaitMessageComponent({ componentType: ComponentType.SelectMenu }), + ); + expectAssignable>(selectMenuCollector); + + // Verify that message component interactions are default collected types. + const defaultCollector = message.createMessageComponentCollector(); + expectAssignable>(message.awaitMessageComponent()); + expectAssignable>(channel.awaitMessageComponent()); + expectAssignable>(defaultCollector); + + // Verify that additional options don't affect default collector types. + const semiDefaultCollector = message.createMessageComponentCollector({ time: 10000 }); + expectType>(semiDefaultCollector); + const semiDefaultCollectorChannel = message.createMessageComponentCollector({ time: 10000 }); + expectType>(semiDefaultCollectorChannel); + + // Verify that interaction collector options can't be used. + message.createMessageComponentCollector({ + // @ts-expect-error + interactionType: InteractionType.ApplicationCommand, + }); + + // Make sure filter parameters are properly inferred. + message.createMessageComponentCollector({ + filter: i => { + expectType(i); + return true; + }, + }); + + message.createMessageComponentCollector({ + componentType: ComponentType.Button, + filter: i => { + expectType(i); + return true; + }, + }); + + message.createMessageComponentCollector({ + componentType: ComponentType.SelectMenu, + filter: i => { + expectType(i); + return true; + }, + }); + + message.awaitMessageComponent({ + filter: i => { + expectType(i); + return true; + }, + }); + + message.awaitMessageComponent({ + componentType: ComponentType.Button, + filter: i => { + expectType(i); + return true; + }, + }); + + message.awaitMessageComponent({ + componentType: ComponentType.SelectMenu, + filter: i => { + expectType(i); + return true; + }, + }); + + const webhook = await message.fetchWebhook(); + + if (webhook.isChannelFollower()) { + expectAssignable(webhook.sourceGuild); + expectAssignable(webhook.sourceChannel); + } else if (webhook.isIncoming()) { + expectType(webhook.token); + } + + expectNotType(webhook.sourceGuild); + expectNotType(webhook.sourceChannel); + expectNotType(webhook.token); + + channel.awaitMessageComponent({ + filter: i => { + expectType>(i); + return true; + }, + }); + + channel.awaitMessageComponent({ + componentType: ComponentType.Button, + filter: i => { + expectType>(i); + return true; + }, + }); + + channel.awaitMessageComponent({ + componentType: ComponentType.SelectMenu, + filter: i => { + expectType>(i); + return true; + }, + }); + + // Check that both builders and builder data can be sent in messages + const row = new ActionRowBuilder(); + const buttonsRow: ActionRowData = { + type: ComponentType.ActionRow, + components: [ + new ButtonBuilder(), + { type: ComponentType.Button, label: 'test', style: ButtonStyle.Primary, customId: 'test' }, + { + type: ComponentType.Button, + label: 'another test', + style: ButtonStyle.Link, + url: 'https://discord.js.org', + }, + ], + }; + const selectsRow: ActionRowData = { + type: ComponentType.ActionRow, + components: [ + new SelectMenuBuilder(), + { + type: ComponentType.SelectMenu, + label: 'select menu', + options: [{ label: 'test', value: 'test' }], + customId: 'test', + }, + ], + }; + + const embedData = { description: 'test', color: 0xff0000 }; + channel.send({ components: [row, buttonsRow, selectsRow], embeds: [embed, embedData] }); +}); + +client.on('messageDelete', ({ client }) => expectType>(client)); + +client.on('messageDeleteBulk', (messages, { client }) => { + expectType>(messages.first()!.client); + expectType>(client); +}); + +client.on('messageReactionAdd', async (reaction, { client }) => { + expectType>(reaction.client); + expectType>(client); + + if (reaction.partial) { + expectType(reaction.count); + reaction = await reaction.fetch(); + } + + expectType(reaction.count); + if (reaction.message.partial) return expectType(reaction.message.content); + expectType(reaction.message.content); +}); + +client.on('messageReactionRemove', ({ client: oldClient }, { client: newClient }) => { + expectType>(oldClient); + expectType>(newClient); +}); + +client.on('messageReactionRemoveAll', async (message, reactions) => { + console.log(`messageReactionRemoveAll - id: ${message.id} (${message.id.length})`); + if (message.partial) message = await message.fetch(); + console.log(`messageReactionRemoveAll - content: ${message.content}`); + expectType>(message.client); + expectType>(reactions.first()!.client); +}); + +client.on('messageReactionRemoveEmoji', ({ client }) => expectType>(client)); + +client.on('messageUpdate', ({ client: oldClient }, { client: newClient }) => { + expectType>(oldClient); + expectType>(newClient); +}); + +client.on('presenceUpdate', (oldPresence, { client }) => { + expectType>(oldPresence!.client); + expectType>(client); +}); + +client.on('ready', async client => { + expectType>(client); + console.log(`Client is logged in as ${client.user.tag} and ready!`); // Test fetching all global commands and ones from one guild expectType>>( @@ -601,311 +976,71 @@ client.on('ready', async () => { await guildCommandFromGuild?.permissions.remove({ // @ts-expect-error command: guildCommandId, - roles: [testGuildId], - users: [testUserId], - token: 'VeryRealToken', - }); - await guildCommandFromGuild?.permissions.set({ - // @ts-expect-error - command: guildCommandId, - permissions: [{ type: ApplicationCommandPermissionType.Role, id: testGuildId, permission: true }], - token: 'VeryRealToken', - }); - - await guildCommandFromGuild?.permissions.add({ - // @ts-expect-error - guild: testGuildId, - permissions: [{ type: ApplicationCommandPermissionType.Role, id: testGuildId, permission: true }], - token: 'VeryRealToken', - }); - // @ts-expect-error - await guildCommandFromGuild?.permissions.has({ guild: testGuildId, permissionId: testGuildId }); - // @ts-expect-error - await guildCommandFromGuild?.permissions.remove({ guild: testGuildId, roles: [testGuildId], token: 'VeryRealToken' }); - // @ts-expect-error - await guildCommandFromGuild?.permissions.remove({ guild: testGuildId, users: [testUserId], token: 'VeryRealToken' }); - await guildCommandFromGuild?.permissions.remove({ - // @ts-expect-error - guild: testGuildId, - roles: [testGuildId], - users: [testUserId], - token: 'VeryRealToken', - }); - await guildCommandFromGuild?.permissions.set({ - // @ts-expect-error - guild: testGuildId, - permissions: [{ type: ApplicationCommandPermissionType.Role, id: testGuildId, permission: true }], - token: 'VeryRealToken', - }); -}); - -client.on('guildCreate', async g => { - const channel = g.channels.cache.random(); - if (!channel) return; - - if (channel.type === ChannelType.GuildText) { - const row: ActionRowData = { - type: ComponentType.ActionRow, - components: [ - new ButtonBuilder(), - { type: ComponentType.Button, style: ButtonStyle.Primary, label: 'string', customId: 'foo' }, - { type: ComponentType.Button, style: ButtonStyle.Link, label: 'test', url: 'test' }, - { type: ComponentType.SelectMenu, customId: 'foo' }, - new SelectMenuBuilder(), - // @ts-expect-error - { type: ComponentType.TextInput, style: TextInputStyle.Paragraph, customId: 'foo', label: 'test' }, - // @ts-expect-error - new TextInputBuilder(), - ], - }; - - const row2 = new ActionRowBuilder({ - type: ComponentType.ActionRow, - components: [ - { type: ComponentType.Button, style: ButtonStyle.Primary, label: 'string', customId: 'foo' }, - { type: ComponentType.Button, style: ButtonStyle.Link, label: 'test', url: 'test' }, - { type: ComponentType.SelectMenu, customId: 'foo' }, - ], - }); - - channel.send({ components: [row, row2] }); - } - - channel.setName('foo').then(updatedChannel => { - console.log(`New channel name: ${updatedChannel.name}`); - }); - - // @ts-expect-error no options - expectNotType>(g.members.add(testUserId)); - - // @ts-expect-error no access token - expectNotType>(g.members.add(testUserId, {})); - - expectNotType>( - // @ts-expect-error invalid role resolvable - g.members.add(testUserId, { accessToken: 'totallyRealAccessToken', roles: [g.roles.cache] }), - ); - - expectType>( - g.members.add(testUserId, { accessToken: 'totallyRealAccessToken', fetchWhenExisting: false }), - ); - - expectType>(g.members.add(testUserId, { accessToken: 'totallyRealAccessToken' })); - - expectType>( - g.members.add(testUserId, { - accessToken: 'totallyRealAccessToken', - mute: true, - deaf: false, - roles: [g.roles.cache.first()!], - force: true, - fetchWhenExisting: true, - }), - ); -}); - -client.on('messageReactionRemoveAll', async message => { - console.log(`messageReactionRemoveAll - id: ${message.id} (${message.id.length})`); - - if (message.partial) message = await message.fetch(); - - console.log(`messageReactionRemoveAll - content: ${message.content}`); -}); - -// This is to check that stuff is the right type -declare const assertIsMessage: (m: Promise) => void; - -client.on('messageCreate', async message => { - const { channel } = message; - assertIsMessage(channel.send('string')); - assertIsMessage(channel.send({})); - assertIsMessage(channel.send({ embeds: [] })); - - const attachment = new AttachmentBuilder('file.png'); - const embed = new EmbedBuilder(); - assertIsMessage(channel.send({ files: [attachment] })); - assertIsMessage(channel.send({ embeds: [embed] })); - assertIsMessage(channel.send({ embeds: [embed], files: [attachment] })); - - if (message.inGuild()) { - expectAssignable>(message); - const component = await message.awaitMessageComponent({ componentType: ComponentType.Button }); - expectType>(component); - expectType>(await component.reply({ fetchReply: true })); - - const buttonCollector = message.createMessageComponentCollector({ componentType: ComponentType.Button }); - expectType>>(buttonCollector); - expectAssignable< - ( - test: ButtonInteraction<'cached'>, - items: Collection>, - ) => boolean | Promise - >(buttonCollector.filter); - expectType(message.channel); - expectType(message.guild); - expectType(message.member); - } - - expectType(message.channel); - expectNotType(message.channel); - - // @ts-expect-error - channel.send(); - // @ts-expect-error - channel.send({ another: 'property' }); - - // Check collector creations. - - // Verify that buttons interactions are inferred. - const buttonCollector = message.createMessageComponentCollector({ componentType: ComponentType.Button }); - expectAssignable>(message.awaitMessageComponent({ componentType: ComponentType.Button })); - expectAssignable>(channel.awaitMessageComponent({ componentType: ComponentType.Button })); - expectAssignable>(buttonCollector); - - // Verify that select menus interaction are inferred. - const selectMenuCollector = message.createMessageComponentCollector({ componentType: ComponentType.SelectMenu }); - expectAssignable>( - message.awaitMessageComponent({ componentType: ComponentType.SelectMenu }), - ); - expectAssignable>( - channel.awaitMessageComponent({ componentType: ComponentType.SelectMenu }), - ); - expectAssignable>(selectMenuCollector); - - // Verify that message component interactions are default collected types. - const defaultCollector = message.createMessageComponentCollector(); - expectAssignable>(message.awaitMessageComponent()); - expectAssignable>(channel.awaitMessageComponent()); - expectAssignable>(defaultCollector); - - // Verify that additional options don't affect default collector types. - const semiDefaultCollector = message.createMessageComponentCollector({ time: 10000 }); - expectType>(semiDefaultCollector); - const semiDefaultCollectorChannel = message.createMessageComponentCollector({ time: 10000 }); - expectType>(semiDefaultCollectorChannel); - - // Verify that interaction collector options can't be used. - message.createMessageComponentCollector({ - // @ts-expect-error - interactionType: InteractionType.ApplicationCommand, - }); - - // Make sure filter parameters are properly inferred. - message.createMessageComponentCollector({ - filter: i => { - expectType(i); - return true; - }, - }); - - message.createMessageComponentCollector({ - componentType: ComponentType.Button, - filter: i => { - expectType(i); - return true; - }, + roles: [testGuildId], + users: [testUserId], + token: 'VeryRealToken', }); - - message.createMessageComponentCollector({ - componentType: ComponentType.SelectMenu, - filter: i => { - expectType(i); - return true; - }, + await guildCommandFromGuild?.permissions.set({ + // @ts-expect-error + command: guildCommandId, + permissions: [{ type: ApplicationCommandPermissionType.Role, id: testGuildId, permission: true }], + token: 'VeryRealToken', }); - message.awaitMessageComponent({ - filter: i => { - expectType(i); - return true; - }, + await guildCommandFromGuild?.permissions.add({ + // @ts-expect-error + guild: testGuildId, + permissions: [{ type: ApplicationCommandPermissionType.Role, id: testGuildId, permission: true }], + token: 'VeryRealToken', }); - - message.awaitMessageComponent({ - componentType: ComponentType.Button, - filter: i => { - expectType(i); - return true; - }, + // @ts-expect-error + await guildCommandFromGuild?.permissions.has({ guild: testGuildId, permissionId: testGuildId }); + // @ts-expect-error + await guildCommandFromGuild?.permissions.remove({ guild: testGuildId, roles: [testGuildId], token: 'VeryRealToken' }); + // @ts-expect-error + await guildCommandFromGuild?.permissions.remove({ guild: testGuildId, users: [testUserId], token: 'VeryRealToken' }); + await guildCommandFromGuild?.permissions.remove({ + // @ts-expect-error + guild: testGuildId, + roles: [testGuildId], + users: [testUserId], + token: 'VeryRealToken', }); - - message.awaitMessageComponent({ - componentType: ComponentType.SelectMenu, - filter: i => { - expectType(i); - return true; - }, + await guildCommandFromGuild?.permissions.set({ + // @ts-expect-error + guild: testGuildId, + permissions: [{ type: ApplicationCommandPermissionType.Role, id: testGuildId, permission: true }], + token: 'VeryRealToken', }); +}); - const webhook = await message.fetchWebhook(); - - if (webhook.isChannelFollower()) { - expectAssignable(webhook.sourceGuild); - expectAssignable(webhook.sourceChannel); - } else if (webhook.isIncoming()) { - expectType(webhook.token); - } - - expectNotType(webhook.sourceGuild); - expectNotType(webhook.sourceChannel); - expectNotType(webhook.token); +client.on('roleCreate', ({ client }) => expectType>(client)); +client.on('roleDelete', ({ client }) => expectType>(client)); - channel.awaitMessageComponent({ - filter: i => { - expectType>(i); - return true; - }, - }); +client.on('roleUpdate', ({ client: oldClient }, { client: newClient }) => { + expectType>(oldClient); + expectType>(newClient); +}); - channel.awaitMessageComponent({ - componentType: ComponentType.Button, - filter: i => { - expectType>(i); - return true; - }, - }); +client.on('stageInstanceCreate', ({ client }) => expectType>(client)); +client.on('stageInstanceDelete', ({ client }) => expectType>(client)); - channel.awaitMessageComponent({ - componentType: ComponentType.SelectMenu, - filter: i => { - expectType>(i); - return true; - }, - }); +client.on('stageInstanceUpdate', (oldStageInstance, { client }) => { + expectType>(oldStageInstance!.client); + expectType>(client); +}); - // Check that both builders and builder data can be sent in messages - const row = new ActionRowBuilder(); - const buttonsRow: ActionRowData = { - type: ComponentType.ActionRow, - components: [ - new ButtonBuilder(), - { type: ComponentType.Button, label: 'test', style: ButtonStyle.Primary, customId: 'test' }, - { - type: ComponentType.Button, - label: 'another test', - style: ButtonStyle.Link, - url: 'https://discord.js.org', - }, - ], - }; - const selectsRow: ActionRowData = { - type: ComponentType.ActionRow, - components: [ - new SelectMenuBuilder(), - { - type: ComponentType.SelectMenu, - label: 'select menu', - options: [{ label: 'test', value: 'test' }], - customId: 'test', - }, - ], - }; +client.on('stickerCreate', ({ client }) => expectType>(client)); +client.on('stickerDelete', ({ client }) => expectType>(client)); - const embedData = { description: 'test', color: 0xff0000 }; - channel.send({ components: [row, buttonsRow, selectsRow], embeds: [embed, embedData] }); +client.on('stickerUpdate', ({ client: oldClient }, { client: newClient }) => { + expectType>(oldClient); + expectType>(newClient); }); client.on('threadCreate', thread => { + expectType>(thread.client); + if (thread.type === ChannelType.GuildPrivateThread) { expectType(thread.createdTimestamp); expectType(thread.createdAt); @@ -915,7 +1050,17 @@ client.on('threadCreate', thread => { } }); +client.on('threadDelete', ({ client }) => expectType>(client)); + +client.on('threadListSync', (threads, { client }) => { + expectType>(threads.first()!.client); + expectType>(client); +}); + client.on('threadMembersUpdate', (addedMembers, removedMembers, thread) => { + expectType>(addedMembers.first()!.client); + expectType>(removedMembers.first()!.client); + expectType>(thread.client); expectType>(addedMembers); expectType>(removedMembers); expectType(thread); @@ -931,63 +1076,98 @@ client.on('threadMembersUpdate', (addedMembers, removedMembers, thread) => { } }); -client.on('interactionCreate', async interaction => { - expectType(interaction.guildId); - expectType(interaction.channelId); - expectType(interaction.member); +client.on('threadMemberUpdate', ({ client: oldClient }, { client: newClient }) => { + expectType>(oldClient); + expectType>(newClient); +}); - if (interaction.type === InteractionType.MessageComponent) { - expectType(interaction.channelId); - } +client.on('threadUpdate', ({ client: oldClient }, { client: newClient }) => { + expectType>(oldClient); + expectType>(newClient); +}); - if (interaction.type !== InteractionType.ApplicationCommand) return; +client.on('typingStart', ({ client }) => expectType>(client)); - void new ActionRowBuilder(); +client.on('userUpdate', ({ client: oldClient }, { client: newClient }) => { + expectType>(oldClient); + expectType>(newClient); +}); - const button = new ButtonBuilder(); +client.on('voiceStateUpdate', ({ client: oldClient }, { client: newClient }) => { + expectType>(oldClient); + expectType>(newClient); +}); - const actionRow = new ActionRowBuilder({ - type: ComponentType.ActionRow, - components: [button.toJSON()], +client.on('webhookUpdate', ({ client }) => expectType>(client)); + +client.on('guildCreate', async g => { + expectType>(g.client); + const channel = g.channels.cache.random(); + if (!channel) return; + + if (channel.type === ChannelType.GuildText) { + const row: ActionRowData = { + type: ComponentType.ActionRow, + components: [ + new ButtonBuilder(), + { type: ComponentType.Button, style: ButtonStyle.Primary, label: 'string', customId: 'foo' }, + { type: ComponentType.Button, style: ButtonStyle.Link, label: 'test', url: 'test' }, + { type: ComponentType.SelectMenu, customId: 'foo' }, + new SelectMenuBuilder(), + // @ts-expect-error + { type: ComponentType.TextInput, style: TextInputStyle.Paragraph, customId: 'foo', label: 'test' }, + // @ts-expect-error + new TextInputBuilder(), + ], + }; + + const row2 = new ActionRowBuilder({ + type: ComponentType.ActionRow, + components: [ + { type: ComponentType.Button, style: ButtonStyle.Primary, label: 'string', customId: 'foo' }, + { type: ComponentType.Button, style: ButtonStyle.Link, label: 'test', url: 'test' }, + { type: ComponentType.SelectMenu, customId: 'foo' }, + ], + }); + + channel.send({ components: [row, row2] }); + } + + channel.setName('foo').then(updatedChannel => { + console.log(`New channel name: ${updatedChannel.name}`); }); - actionRow.toJSON(); + // @ts-expect-error no options + expectNotType>(g.members.add(testUserId)); - await interaction.reply({ content: 'Hi!', components: [actionRow] }); + // @ts-expect-error no access token + expectNotType>(g.members.add(testUserId, {})); - // @ts-expect-error - interaction.reply({ content: 'Hi!', components: [[button]] }); + expectNotType>( + // @ts-expect-error invalid role resolvable + g.members.add(testUserId, { accessToken: 'totallyRealAccessToken', roles: [g.roles.cache] }), + ); - void new ActionRowBuilder({}); + expectType>( + g.members.add(testUserId, { accessToken: 'totallyRealAccessToken', fetchWhenExisting: false }), + ); - // @ts-expect-error - await interaction.reply({ content: 'Hi!', components: [button] }); + expectType>(g.members.add(testUserId, { accessToken: 'totallyRealAccessToken' })); - await interaction.reply({ - content: 'test', - components: [ - { - components: [ - { - custom_id: 'abc', - label: 'abc', - style: ButtonStyle.Primary, - type: ComponentType.Button, - }, - ], - type: ComponentType.ActionRow, - }, - ], - }); + expectType>( + g.members.add(testUserId, { + accessToken: 'totallyRealAccessToken', + mute: true, + deaf: false, + roles: [g.roles.cache.first()!], + force: true, + fetchWhenExisting: true, + }), + ); }); client.login('absolutely-valid-token'); -// Test client conditional types -client.on('ready', client => { - expectType>(client); -}); - declare const loggedInClient: Client; expectType(loggedInClient.application); expectType(loggedInClient.readyAt); @@ -1289,22 +1469,6 @@ if (typing.inGuild()) { expectType(typing.guild); } -// Test partials structures -client.on('guildMemberRemove', member => { - if (member.partial) return expectType(member.joinedAt); - expectType(member.joinedAt); -}); - -client.on('messageReactionAdd', async reaction => { - if (reaction.partial) { - expectType(reaction.count); - reaction = await reaction.fetch(); - } - expectType(reaction.count); - if (reaction.message.partial) return expectType(reaction.message.content); - expectType(reaction.message.content); -}); - // Test interactions declare const interaction: Interaction; declare const booleanValue: boolean; @@ -1314,23 +1478,6 @@ if (interaction.inGuild()) { expectType(interaction.guildId); } -client.on('interactionCreate', interaction => { - // This is for testing never type resolution - if (!interaction.inGuild()) { - return; - } - - if (interaction.inRawGuild()) { - expectNotType(interaction); - return; - } - - if (interaction.inCachedGuild()) { - expectNotType(interaction); - return; - } -}); - client.on('interactionCreate', async interaction => { if (interaction.type === InteractionType.MessageComponent) { expectType(interaction);