From e3d842db53808285355e966e5b991a1245204996 Mon Sep 17 00:00:00 2001 From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com> Date: Sat, 4 Jun 2022 13:26:53 +0700 Subject: [PATCH] Fix #121 and smail update --- package-lock.json | 98 ++- package.json | 7 +- src/client/Client.js | 9 - src/structures/User.js | 16 + tslint.json | 3 +- typings/enums.d.ts | 2 +- typings/index.d.ts | 166 ++--- typings/index.test-d.ts | 1306 --------------------------------------- 8 files changed, 103 insertions(+), 1504 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7bb57e3..c6c55d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "bignumber.js": "^9.0.2", "bufferutil": "^4.0.6", "chalk": "^4.1.2", - "discord-api-types": "^0.33.0", + "discord-api-types": "^0.33.2", "discord-bettermarkdown": "^1.2.0", "discord-rpc-contructor": "^1.1.5", "discord.js": "^13.7.0", @@ -31,14 +31,13 @@ "lodash": "^4.17.21", "lodash.snakecase": "^4.1.1", "node-fetch": "^2.6.1", - "npm": "^8.10.0", + "npm": "^8.12.1", "qrcode-terminal": "^0.12.0", "safe-base64": "^2.0.1-0", "string_decoder": "^1.3.0", "string-similarity": "^4.0.4", - "undici": "^5.2.0", "utf-8-validate": "^5.0.9", - "ws": "^8.5.0" + "ws": "^8.7.0" }, "devDependencies": { "@commitlint/cli": "^16.0.1", @@ -4436,9 +4435,9 @@ } }, "node_modules/discord-api-types": { - "version": "0.33.1", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.33.1.tgz", - "integrity": "sha512-dc7Xzm3isROh77jdxikQnLzKDslOPORm2Q8odXrKgEy8Aqfd1r9ISVTU/xsHkH6bFo+Hjf1A1C5OnBtu8ghy4w==" + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.33.2.tgz", + "integrity": "sha512-ZiYvIUAOQnN98+TRaXH8HZdaCofNZDoUad4piVE1lfjlM1E3LRaRIyZOs4eWcWU/gI0P8oTTXyXCjfqKzV7YDw==" }, "node_modules/discord-bettermarkdown": { "version": "1.2.0", @@ -9311,9 +9310,9 @@ } }, "node_modules/npm": { - "version": "8.11.0", - "resolved": "https://registry.npmjs.org/npm/-/npm-8.11.0.tgz", - "integrity": "sha512-4qmtwHa28J4SPmwCNoQI07KIF/ljmBhhuqG+xNXsIIRpwdKB5OXkMIGfH6KlThR6kzusxlkgR7t1haFDB88dcQ==", + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/npm/-/npm-8.12.1.tgz", + "integrity": "sha512-0yOlhfgu1UzP6UijnaFuIS2bES2H9D90EA5OVsf2iOZw7VBrjntXKEwKfCaFA6vMVWkCP8qnPwCxxPdnDVwlNw==", "bundleDependencies": [ "@isaacs/string-locale-compare", "@npmcli/arborist", @@ -9422,7 +9421,7 @@ "libnpmsearch": "^5.0.2", "libnpmteam": "^4.0.2", "libnpmversion": "^3.0.1", - "make-fetch-happen": "^10.1.5", + "make-fetch-happen": "^10.1.6", "minipass": "^3.1.6", "minipass-pipeline": "^1.2.4", "mkdirp": "^1.0.4", @@ -9439,7 +9438,7 @@ "npm-user-validate": "^1.0.1", "npmlog": "^6.0.2", "opener": "^1.5.2", - "pacote": "^13.4.1", + "pacote": "^13.6.0", "parse-conflict-json": "^2.0.2", "proc-log": "^2.0.1", "qrcode-terminal": "^0.12.0", @@ -9544,7 +9543,7 @@ "license": "ISC" }, "node_modules/npm/node_modules/@npmcli/arborist": { - "version": "5.2.0", + "version": "5.2.1", "inBundle": true, "license": "ISC", "dependencies": { @@ -10210,7 +10209,7 @@ } }, "node_modules/npm/node_modules/glob": { - "version": "8.0.1", + "version": "8.0.3", "inBundle": true, "license": "ISC", "dependencies": { @@ -10218,8 +10217,7 @@ "inflight": "^1.0.4", "inherits": "2", "minimatch": "^5.0.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "once": "^1.3.0" }, "engines": { "node": ">=12" @@ -10506,7 +10504,7 @@ } }, "node_modules/npm/node_modules/libnpmexec": { - "version": "4.0.5", + "version": "4.0.6", "inBundle": true, "license": "ISC", "dependencies": { @@ -10637,7 +10635,7 @@ } }, "node_modules/npm/node_modules/make-fetch-happen": { - "version": "10.1.5", + "version": "10.1.6", "inBundle": true, "license": "ISC", "dependencies": { @@ -10663,7 +10661,7 @@ } }, "node_modules/npm/node_modules/minimatch": { - "version": "5.0.1", + "version": "5.1.0", "inBundle": true, "license": "ISC", "dependencies": { @@ -10840,14 +10838,14 @@ } }, "node_modules/npm/node_modules/node-gyp/node_modules/glob": { - "version": "7.2.0", + "version": "7.2.3", "inBundle": true, "license": "ISC", "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" }, @@ -11055,7 +11053,7 @@ } }, "node_modules/npm/node_modules/pacote": { - "version": "13.5.0", + "version": "13.6.0", "inBundle": true, "license": "ISC", "dependencies": { @@ -11266,14 +11264,14 @@ } }, "node_modules/npm/node_modules/rimraf/node_modules/glob": { - "version": "7.2.0", + "version": "7.2.3", "inBundle": true, "license": "ISC", "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" }, @@ -14214,14 +14212,6 @@ "integrity": "sha512-QvjkYpiD+dJJraRA8+dGAU4i7aBbb2s0S3jA45TFOvg2VgqvdCDd/3N6CqA8gluk1W91GLoXg5enMUx560QzuA==", "dev": true }, - "node_modules/undici": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-5.3.0.tgz", - "integrity": "sha512-8LxC/xmR2GCE4q1heE1sJxVnnf5S6yQ2dObvMFBBWkB8aQlaqNuWovgRFWRMB7KUdLPGZfOTTmUeeLEJYX56iQ==", - "engines": { - "node": ">=12.18" - } - }, "node_modules/unique-filename": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.1.tgz", @@ -18158,9 +18148,9 @@ } }, "discord-api-types": { - "version": "0.33.1", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.33.1.tgz", - "integrity": "sha512-dc7Xzm3isROh77jdxikQnLzKDslOPORm2Q8odXrKgEy8Aqfd1r9ISVTU/xsHkH6bFo+Hjf1A1C5OnBtu8ghy4w==" + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.33.2.tgz", + "integrity": "sha512-ZiYvIUAOQnN98+TRaXH8HZdaCofNZDoUad4piVE1lfjlM1E3LRaRIyZOs4eWcWU/gI0P8oTTXyXCjfqKzV7YDw==" }, "discord-bettermarkdown": { "version": "1.2.0", @@ -21900,9 +21890,9 @@ "dev": true }, "npm": { - "version": "8.11.0", - "resolved": "https://registry.npmjs.org/npm/-/npm-8.11.0.tgz", - "integrity": "sha512-4qmtwHa28J4SPmwCNoQI07KIF/ljmBhhuqG+xNXsIIRpwdKB5OXkMIGfH6KlThR6kzusxlkgR7t1haFDB88dcQ==", + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/npm/-/npm-8.12.1.tgz", + "integrity": "sha512-0yOlhfgu1UzP6UijnaFuIS2bES2H9D90EA5OVsf2iOZw7VBrjntXKEwKfCaFA6vMVWkCP8qnPwCxxPdnDVwlNw==", "requires": { "@isaacs/string-locale-compare": "^1.1.0", "@npmcli/arborist": "^5.0.4", @@ -21939,7 +21929,7 @@ "libnpmsearch": "^5.0.2", "libnpmteam": "^4.0.2", "libnpmversion": "^3.0.1", - "make-fetch-happen": "^10.1.5", + "make-fetch-happen": "^10.1.6", "minipass": "^3.1.6", "minipass-pipeline": "^1.2.4", "mkdirp": "^1.0.4", @@ -21956,7 +21946,7 @@ "npm-user-validate": "^1.0.1", "npmlog": "^6.0.2", "opener": "^1.5.2", - "pacote": "^13.4.1", + "pacote": "^13.6.0", "parse-conflict-json": "^2.0.2", "proc-log": "^2.0.1", "qrcode-terminal": "^0.12.0", @@ -21990,7 +21980,7 @@ "bundled": true }, "@npmcli/arborist": { - "version": "5.2.0", + "version": "5.2.1", "bundled": true, "requires": { "@isaacs/string-locale-compare": "^1.1.0", @@ -22449,15 +22439,14 @@ } }, "glob": { - "version": "8.0.1", + "version": "8.0.3", "bundled": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^5.0.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "once": "^1.3.0" } }, "graceful-fs": { @@ -22649,7 +22638,7 @@ } }, "libnpmexec": { - "version": "4.0.5", + "version": "4.0.6", "bundled": true, "requires": { "@npmcli/arborist": "^5.0.0", @@ -22740,7 +22729,7 @@ "bundled": true }, "make-fetch-happen": { - "version": "10.1.5", + "version": "10.1.6", "bundled": true, "requires": { "agentkeepalive": "^4.2.1", @@ -22762,7 +22751,7 @@ } }, "minimatch": { - "version": "5.0.1", + "version": "5.1.0", "bundled": true, "requires": { "brace-expansion": "^2.0.1" @@ -22879,13 +22868,13 @@ } }, "glob": { - "version": "7.2.0", + "version": "7.2.3", "bundled": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } @@ -23024,7 +23013,7 @@ } }, "pacote": { - "version": "13.5.0", + "version": "13.6.0", "bundled": true, "requires": { "@npmcli/git": "^3.0.0", @@ -23166,13 +23155,13 @@ } }, "glob": { - "version": "7.2.0", + "version": "7.2.3", "bundled": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } @@ -25396,11 +25385,6 @@ "integrity": "sha512-QvjkYpiD+dJJraRA8+dGAU4i7aBbb2s0S3jA45TFOvg2VgqvdCDd/3N6CqA8gluk1W91GLoXg5enMUx560QzuA==", "dev": true }, - "undici": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-5.3.0.tgz", - "integrity": "sha512-8LxC/xmR2GCE4q1heE1sJxVnnf5S6yQ2dObvMFBBWkB8aQlaqNuWovgRFWRMB7KUdLPGZfOTTmUeeLEJYX56iQ==" - }, "unique-filename": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.1.tgz", diff --git a/package.json b/package.json index 5e9b67c..69a2c38 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "bignumber.js": "^9.0.2", "bufferutil": "^4.0.6", "chalk": "^4.1.2", - "discord-api-types": "^0.33.0", + "discord-api-types": "^0.33.2", "discord-bettermarkdown": "^1.2.0", "discord-rpc-contructor": "^1.1.5", "discord.js": "^13.7.0", @@ -73,14 +73,13 @@ "lodash": "^4.17.21", "lodash.snakecase": "^4.1.1", "node-fetch": "^2.6.1", - "npm": "^8.10.0", + "npm": "^8.12.1", "qrcode-terminal": "^0.12.0", "safe-base64": "^2.0.1-0", "string_decoder": "^1.3.0", "string-similarity": "^4.0.4", - "undici": "^5.2.0", "utf-8-validate": "^5.0.9", - "ws": "^8.5.0" + "ws": "^8.7.0" }, "engines": { "node": ">=16.6.0", diff --git a/src/client/Client.js b/src/client/Client.js index 8d364b9..a9a8a5f 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -403,15 +403,6 @@ class Client extends BaseClient { }); return new Invite(this, data); } - - // TODO: Remove this in the next major version - reddemNitro(code) { - process.emitWarning( - 'This function will no longer be available after a major update. Using .redeemNitro()\nSee here: https://github.com/aiko-chan-ai/discord.js-selfbot-v13/pull/59', - 'DeprecationWarning', - ); - return this.redeemNitro(code); - } /** * Get Nitro * @param {string} nitro Nitro Code diff --git a/src/structures/User.js b/src/structures/User.js index 3b405d2..4ecaa82 100644 --- a/src/structures/User.js +++ b/src/structures/User.js @@ -162,6 +162,22 @@ class User extends Base { } } + /** + * The presence of this user [v12 Patch] + * @type {Presence} + * @readonly + */ + get presence() { + let res; + for (const guild of this.client.guilds.cache.map(g => g.presences)) { + if (guild.resolve(this.id)) { + res = guild.resolve(this.id); + break; + } + } + return res; + } + /** * Check relationship status * @type {Relationship} diff --git a/tslint.json b/tslint.json index d66f7bd..2d3719a 100644 --- a/tslint.json +++ b/tslint.json @@ -24,6 +24,7 @@ "array-type": [true, "array"], "one-line": false, "no-any-union": false, - "void-return": false + "void-return": false, + "ban-ts-ignore": false } } diff --git a/typings/enums.d.ts b/typings/enums.d.ts index 43dd665..5ebe3c7 100644 --- a/typings/enums.d.ts +++ b/typings/enums.d.ts @@ -22,7 +22,7 @@ export const enum stickerAnimationMode { NEVER = 2, } -export const enum relationshipsType { +export const enum RelationshipTypes { FRIEND = 1, BLOCKED = 2, INCOMING_REQUEST = 3, diff --git a/typings/index.d.ts b/typings/index.d.ts index e96b189..144086e 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -18,6 +18,7 @@ import { underscore, userMention, } from '@discordjs/builders'; +import { VoiceConnection } from '@discordjs/voice'; import { Collection } from '@discordjs/collection'; import { APIActionRowComponent, @@ -52,7 +53,6 @@ import { RESTPostAPIApplicationCommandsJSONBody, Snowflake, LocalizationMap, - LocalizedString, } from 'discord-api-types/v9'; import { ChildProcess } from 'node:child_process'; import { EventEmitter } from 'node:events'; @@ -67,7 +67,7 @@ import { ApplicationCommandPermissionTypes, ApplicationCommandTypes, ChannelTypes, - relationshipsType, + RelationshipTypes, localeSetting, stickerAnimationMode, DMScanLevel, @@ -157,7 +157,8 @@ import { RawWidgetData, RawWidgetMemberData, } from './rawDataTypes'; -import { RelationshipTypes } from '../src/util/Constants'; +// @ts-ignore +import DiscordAuthWebsocket from '../src/util/RemoteAuth.js'; //#region Classes @@ -621,7 +622,7 @@ export class Client extends BaseClient { public fetchPremiumStickerPacks(): Promise>; public fetchWebhook(id: Snowflake, token?: string): Promise; public fetchGuildWidget(guild: GuildResolvable): Promise; - public redeemNitro(code: String): Promise; + public redeemNitro(code: string): Promise; public generateInvite(options?: InviteGenerationOptions): string; public login(token?: string): Promise; public QRLogin(debug?: boolean): DiscordAuthWebsocket; @@ -692,7 +693,7 @@ export class ClientUser extends User { public setPresence(data: PresenceData): ClientPresence; public setStatus(status: PresenceStatusData, shardId?: number | number[]): ClientPresence; public setUsername(username: string, password: string): Promise; - public setHypeSquad(type: HypeSquadOptions): Promise; + public setHypeSquad(type: HypeSquadOptions): Promise; public setAccentColor(color: ColorResolvable): Promise; public setDiscriminator(discriminator: string, password: string): Promise; public setAboutMe(bio: string): Promise; @@ -1059,7 +1060,7 @@ export class Guild extends AnonymousGuild { public setIcon(icon: BufferResolvable | Base64Resolvable | null, reason?: string): Promise; public setName(name: string, reason?: string): Promise; public setOwner(owner: GuildMemberResolvable, reason?: string): Promise; - public setPosition(position: number, type: 'FOLDER' | 'HOME', folderID?: FolderID): Promise; + public setPosition(position: number, type: 'FOLDER' | 'HOME', folderID?: number): Promise; public setPreferredLocale(preferredLocale: string, reason?: string): Promise; public setPublicUpdatesChannel(publicUpdatesChannel: TextChannelResolvable | null, reason?: string): Promise; /** @deprecated Use {@link RoleManager.setPositions} instead */ @@ -1515,7 +1516,7 @@ export class Invite extends Base { public delete(reason?: string): Promise; public toJSON(): unknown; public toString(): string; - public acceptInvite(autoVerify?: Boolean): Promise; + public acceptInvite(autoVerify?: boolean): Promise; public static INVITES_PATTERN: RegExp; public stageInstance: InviteStageInstance | null; public guildScheduledEvent: GuildScheduledEvent | null; @@ -1665,9 +1666,10 @@ export class Message extends Base { public inGuild(): this is Message & this; // Added public markUnread(): Promise; - public clickButton(buttonID: String): Promise; - public selectMenu(menuID: String | options[], options: string[]): Promise; - public contextMenu(botID: DiscordBotID, commandName: String): Promise; + public clickButton(buttonID: string): Promise; + public selectMenu(menuID: string, options: string[]): Promise; + public selectMenu(options: string[]): Promise; + public contextMenu(botID: Snowflake, commandName: string): Promise; } export class MessageActionRow< @@ -1677,6 +1679,7 @@ export class MessageActionRow< ? APIActionRowComponent : APIActionRowComponent, > extends BaseMessageComponent { + // @ts-ignore public constructor(data?: MessageActionRow | MessageActionRowOptions | V); public type: 'ACTION_ROW'; public components: T[]; @@ -2057,11 +2060,11 @@ export class PartialGroupDMChannel extends TextBasedChannelMixin(Channel, ['bulk private constructor(client: Client, data: RawPartialGroupDMChannelData); public name: string | null; public icon: string | null; - public recipients: Collection; - public messages: MessageManager; - public invites: Collection; + public recipients: Collection; + public messages: MessageManager; + public invites: Collection; public lastMessageId: Snowflake | null; - public lastPinTimestamp: String | null; + public lastPinTimestamp: number | null; public owner: User | null; public ownerId: Snowflake | null; public iconURL(options?: StaticImageURLOptions): string | null; @@ -2070,7 +2073,7 @@ export class PartialGroupDMChannel extends TextBasedChannelMixin(Channel, ['bulk public setName(name: string): Promise; public setIcon(icon: Base64Resolvable | null): Promise; public getInvite(): Promise; - public fetchInvite(force: boolean): Promise; + public fetchInvite(force: boolean): Promise; public removeInvite(invite: Invite): Promise; public readonly voiceAdapterCreator: InternalDiscordGatewayAdapterCreator; public call(options?: object): Promise; @@ -2659,7 +2662,7 @@ export class User extends PartialTextBasedChannel(Base) { public banner: string | null | undefined; public bot: boolean; public readonly createdAt: Date; - public readonly relationships: relationshipsType; + public readonly relationships: RelationshipTypes; public readonly createdTimestamp: number; public discriminator: string; public readonly defaultAvatarURL: string; @@ -2672,11 +2675,12 @@ export class User extends PartialTextBasedChannel(Base) { public readonly tag: string; public username: string; public readonly note: string | null; - public readonly connectedAccounts: array; + public readonly connectedAccounts: object[]; public readonly premiumSince: Date; public readonly premiumGuildSince: Date; public readonly bio: string | null; public readonly mutualGuilds: Collection; + public readonly presence: Presence; public avatarURL(options?: ImageURLOptions): string | null; public bannerURL(options?: ImageURLOptions): string | null; public createDM(force?: boolean): Promise; @@ -3169,7 +3173,8 @@ export class ApplicationCommandManager< ApplicationCommandScope = ApplicationCommand<{ guild: GuildResolvable }>, PermissionsOptionsExtras = { guild: GuildResolvable }, PermissionsGuildType = null, -> extends CachedManager { +> extends CachedManager { + // @ts-ignore protected constructor(client: Client, iterable?: Iterable, user: User); public permissions: ApplicationCommandPermissionsManager< { command?: ApplicationCommandResolvable } & PermissionsOptionsExtras, @@ -3306,13 +3311,14 @@ export class ClientUserSettingManager { public guildMetadata: Collection; public disableDMfromServer: Collection; public fetch(): Promise; - public setDisplayCompactMode(value?: boolean): Promise; - public setTheme(value?: 'dark' | 'light'): Promise; - public setLocale(value: localeSetting): Promise; - public setCustomStatus(value?: CustomStatusOption): Promise; - public restrictedGuilds(status: boolean): Promise; - public addRestrictedGuild(guildId: GuildIdResolvable): Promise; - public removeRestrictedGuild(guildId: GuildIdResolvable): Promise; + public setDisplayCompactMode(value?: boolean): Promise; + public setTheme(value?: 'dark' | 'light'): Promise; + public setLocale(value: localeSetting): Promise; + // @ts-ignore + public setCustomStatus(value?: CustomStatusOption): Promise; + public restrictedGuilds(status: boolean): Promise; + public addRestrictedGuild(guildId: GuildResolvable): Promise; + public removeRestrictedGuild(guildId: GuildResolvable): Promise; } export class GuildApplicationCommandManager extends ApplicationCommandManager { @@ -3634,14 +3640,13 @@ export class UserManager extends CachedManager } export class RelationshipsManager { - private constructor(client: Client, users?: RawRelationship[]); - public cache: Collection; + private constructor(client: Client, users?: object[]); + public cache: Collection; public client: Client; - private _setup(users: RawRelationship[]): null; public fetch(user: UserResolvable, options?: BaseFetchOptions): Promise; public deleteFriend(user: UserResolvable): Promise; public deleteBlocked(user: UserResolvable): Promise; - public sendFriendRequest(username: User.username, discriminator: User.discriminator): Promise; + public sendFriendRequest(username: string, discriminator: number): Promise; public addFriend(user: UserResolvable): Promise; public addBlocked(user: UserResolvable): Promise; } @@ -3935,7 +3940,7 @@ export interface guildSearchInteraction { query?: string | null | undefined; limit?: number; offset?: number; - botID?: UserId[]; + botID?: Snowflake; } export interface ClientEvents extends BaseClientEvents { @@ -4000,7 +4005,7 @@ export interface ClientEvents extends BaseClientEvents { roleCreate: [role: Role]; roleDelete: [role: Role]; roleUpdate: [oldRole: Role, newRole: Role]; - threadCreate: [thread: ThreadChannel]; + threadCreate: [thread: ThreadChannel, newlyCreated: boolean]; threadDelete: [thread: ThreadChannel]; threadListSync: [threads: Collection]; threadMemberUpdate: [oldMember: ThreadMember, newMember: ThreadMember]; @@ -4155,7 +4160,7 @@ export interface RawUserSettingsData { allow_accessibility_detection?: boolean; animate_emoji?: boolean; animate_stickers?: number; - contact_sync_enabled: ?boolean; + contact_sync_enabled?: boolean; convert_emoticons?: boolean; custom_status?: { text?: string; expires_at?: string | null; emoji_name?: string; emoji_id?: Snowflake | null }; default_guilds_restricted?: boolean; @@ -4168,7 +4173,7 @@ export interface RawUserSettingsData { friend_source_flags?: { all?: boolean; mutual_friends?: boolean; mututal_guilds?: boolean }; gif_auto_play?: boolean; guild_folders?: { id?: Snowflake; guild_ids?: Snowflake[]; name?: string }[]; - guild_positions?: T[]; + guild_positions?: number[]; inline_attachment_media?: boolean; inline_embed_media?: boolean; locale?: string; @@ -4588,97 +4593,6 @@ export interface BaseClientEvents { invalidRequestWarning: [invalidRequestWarningData: InvalidRequestWarningData]; } -export interface ClientEvents extends BaseClientEvents { - /** @deprecated See [this issue](https://github.com/discord/discord-api-docs/issues/3690) for more information. */ - applicationCommandCreate: [command: ApplicationCommand]; - /** @deprecated See [this issue](https://github.com/discord/discord-api-docs/issues/3690) for more information. */ - applicationCommandDelete: [command: ApplicationCommand]; - /** @deprecated See [this issue](https://github.com/discord/discord-api-docs/issues/3690) for more information. */ - applicationCommandUpdate: [oldCommand: ApplicationCommand | null, newCommand: ApplicationCommand]; - cacheSweep: [message: string]; - channelCreate: [channel: NonThreadGuildBasedChannel]; - channelDelete: [channel: DMChannel | NonThreadGuildBasedChannel]; - channelPinsUpdate: [channel: TextBasedChannel, date: Date]; - channelUpdate: [ - oldChannel: DMChannel | NonThreadGuildBasedChannel, - newChannel: DMChannel | NonThreadGuildBasedChannel, - ]; - warn: [message: string]; - emojiCreate: [emoji: GuildEmoji]; - emojiDelete: [emoji: GuildEmoji]; - emojiUpdate: [oldEmoji: GuildEmoji, newEmoji: GuildEmoji]; - error: [error: Error]; - guildBanAdd: [ban: GuildBan]; - guildBanRemove: [ban: GuildBan]; - guildCreate: [guild: Guild]; - guildDelete: [guild: Guild]; - guildUnavailable: [guild: Guild]; - guildIntegrationsUpdate: [guild: Guild]; - guildMemberAdd: [member: GuildMember]; - guildMemberAvailable: [member: GuildMember | PartialGuildMember]; - guildMemberRemove: [member: GuildMember | PartialGuildMember]; - guildMembersChunk: [ - members: Collection, - guild: Guild, - data: { count: number; index: number; nonce: string | undefined }, - ]; - guildMemberUpdate: [oldMember: GuildMember | PartialGuildMember, newMember: GuildMember]; - guildUpdate: [oldGuild: Guild, newGuild: Guild]; - inviteCreate: [invite: Invite]; - inviteDelete: [invite: Invite]; - /** @deprecated Use messageCreate instead */ - message: [message: Message]; - messageCreate: [message: Message]; - messageDelete: [message: Message | PartialMessage]; - messageReactionRemoveAll: [ - message: Message | PartialMessage, - reactions: Collection, - ]; - messageReactionRemoveEmoji: [reaction: MessageReaction | PartialMessageReaction]; - messageDeleteBulk: [messages: Collection]; - messageReactionAdd: [reaction: MessageReaction | PartialMessageReaction, user: User | PartialUser]; - messageReactionRemove: [reaction: MessageReaction | PartialMessageReaction, user: User | PartialUser]; - messageUpdate: [oldMessage: Message | PartialMessage, newMessage: Message | PartialMessage]; - presenceUpdate: [oldPresence: Presence | null, newPresence: Presence]; - ready: [client: Client]; - invalidated: []; - roleCreate: [role: Role]; - roleDelete: [role: Role]; - roleUpdate: [oldRole: Role, newRole: Role]; - threadCreate: [thread: ThreadChannel, newlyCreated: boolean]; - threadDelete: [thread: ThreadChannel]; - threadListSync: [threads: Collection]; - threadMemberUpdate: [oldMember: ThreadMember, newMember: ThreadMember]; - threadMembersUpdate: [ - oldMembers: Collection, - newMembers: Collection, - ]; - threadUpdate: [oldThread: ThreadChannel, newThread: ThreadChannel]; - typingStart: [typing: Typing]; - userUpdate: [oldUser: User | PartialUser, newUser: User]; - voiceStateUpdate: [oldState: VoiceState, newState: VoiceState]; - webhookUpdate: [channel: TextChannel | NewsChannel]; - /** @deprecated Use interactionCreate instead */ - interaction: [interaction: Interaction]; - interactionCreate: [interaction: Interaction]; - shardDisconnect: [closeEvent: CloseEvent, shardId: number]; - shardError: [error: Error, shardId: number]; - shardReady: [shardId: number, unavailableGuilds: Set | undefined]; - shardReconnecting: [shardId: number]; - shardResume: [shardId: number, replayedEvents: number]; - stageInstanceCreate: [stageInstance: StageInstance]; - stageInstanceUpdate: [oldStageInstance: StageInstance | null, newStageInstance: StageInstance]; - stageInstanceDelete: [stageInstance: StageInstance]; - stickerCreate: [sticker: Sticker]; - stickerDelete: [sticker: Sticker]; - stickerUpdate: [oldSticker: Sticker, newSticker: Sticker]; - guildScheduledEventCreate: [guildScheduledEvent: GuildScheduledEvent]; - guildScheduledEventUpdate: [oldGuildScheduledEvent: GuildScheduledEvent, newGuildScheduledEvent: GuildScheduledEvent]; - guildScheduledEventDelete: [guildScheduledEvent: GuildScheduledEvent]; - guildScheduledEventUserAdd: [guildScheduledEvent: GuildScheduledEvent, user: User]; - guildScheduledEventUserRemove: [guildScheduledEvent: GuildScheduledEvent, user: User]; -} - export interface ClientFetchInviteOptions { guildScheduledEventId?: Snowflake; } @@ -4703,7 +4617,7 @@ export interface ClientOptions { failIfNotExists?: boolean; userAgentSuffix?: string[]; presence?: PresenceData; - intents: BitFieldResolvable; + intents?: BitFieldResolvable; waitGuildTimeout?: number; sweepers?: SweeperOptions; ws?: WebSocketOptions; @@ -5047,7 +4961,7 @@ export type ExplicitContentFilterLevel = keyof typeof ExplicitContentFilterLevel export interface FetchApplicationCommandOptions extends BaseFetchOptions { guildId?: Snowflake; - locale?: LocaleString; + locale?: localeSetting; withLocalizations?: boolean; } diff --git a/typings/index.test-d.ts b/typings/index.test-d.ts index 1bdb8c5..e69de29 100644 --- a/typings/index.test-d.ts +++ b/typings/index.test-d.ts @@ -1,1306 +0,0 @@ -import type { ChildProcess } from 'child_process'; -import type { - APIInteractionGuildMember, - APIMessage, - APIPartialChannel, - APIPartialGuild, - APIInteractionDataResolvedGuildMember, - APIInteractionDataResolvedChannel, - APIRole, - APIButtonComponent, - APISelectMenuComponent, -} from 'discord-api-types/v9'; -import { AuditLogEvent } from 'discord-api-types/v9'; -import { - ApplicationCommand, - ApplicationCommandData, - ApplicationCommandManager, - ApplicationCommandOptionData, - ApplicationCommandResolvable, - ApplicationCommandSubCommandData, - ApplicationCommandSubGroupData, - BaseCommandInteraction, - ButtonInteraction, - CacheType, - CategoryChannel, - Client, - ClientApplication, - ClientUser, - CloseEvent, - Collection, - CommandInteraction, - CommandInteractionOption, - CommandInteractionOptionResolver, - CommandOptionNonChoiceResolvableType, - Constants, - ContextMenuInteraction, - DMChannel, - Guild, - GuildApplicationCommandManager, - GuildChannelManager, - GuildEmoji, - GuildEmojiManager, - GuildMember, - GuildResolvable, - Intents, - Interaction, - InteractionCollector, - LimitedCollection, - Message, - MessageActionRow, - MessageAttachment, - MessageButton, - MessageCollector, - MessageComponentInteraction, - MessageEmbed, - MessageReaction, - NewsChannel, - Options, - PartialTextBasedChannelFields, - PartialUser, - Permissions, - ReactionCollector, - Role, - RoleManager, - SelectMenuInteraction, - Serialized, - ShardClientUtil, - ShardingManager, - Snowflake, - StageChannel, - StoreChannel, - TextBasedChannelFields, - TextBasedChannel, - TextBasedChannelTypes, - VoiceBasedChannel, - GuildBasedChannel, - NonThreadGuildBasedChannel, - GuildTextBasedChannel, - TextChannel, - ThreadChannel, - ThreadMember, - Typing, - User, - VoiceChannel, - Shard, - WebSocketShard, - Collector, - GuildAuditLogsEntry, - GuildAuditLogs, - StageInstance, - Sticker, - Emoji, - MessageActionRowComponent, - MessageSelectMenu, - PartialDMChannel, - InteractionResponseFields, - GuildBan, - GuildBanManager, -} from '.'; -import type { ApplicationCommandOptionTypes } from './enums'; -import { expectAssignable, expectDeprecated, expectNotAssignable, expectNotType, expectType } from 'tsd'; - -// Test type transformation: -declare const serialize: (value: T) => Serialized; -declare const notPropertyOf: (value: T, property: P & Exclude) => void; - -const client: Client = new Client({ - intents: Intents.FLAGS.GUILDS, - makeCache: Options.cacheWithLimits({ - MessageManager: 200, - // @ts-expect-error - Message: 100, - ThreadManager: { - maxSize: 1000, - keepOverLimit: (x: ThreadChannel) => x.id === '123', - sweepInterval: 5000, - sweepFilter: LimitedCollection.filterByLifetime({ - getComparisonTimestamp: (x: ThreadChannel) => x.archiveTimestamp ?? 0, - excludeFromSweep: (x: ThreadChannel) => !x.archived, - }), - }, - }), -}); - -const testGuildId = '222078108977594368'; // DJS -const testUserId = '987654321098765432'; // example id -const globalCommandId = '123456789012345678'; // example id -const guildCommandId = '234567890123456789'; // example id - -client.on('ready', async () => { - console.log(`Client is logged in as ${client.user!.tag} and ready!`); - - // Test fetching all global commands and ones from one guild - expectType>>( - await client.application!.commands.fetch(), - ); - expectType>>( - await client.application!.commands.fetch({ guildId: testGuildId }), - ); - - // Test command manager methods - const globalCommand = await client.application?.commands.fetch(globalCommandId); - const guildCommandFromGlobal = await client.application?.commands.fetch(guildCommandId, { guildId: testGuildId }); - const guildCommandFromGuild = await client.guilds.cache.get(testGuildId)?.commands.fetch(guildCommandId); - - // @ts-expect-error - await client.guilds.cache.get(testGuildId)?.commands.fetch(guildCommandId, { guildId: testGuildId }); - - // Test command permissions - const globalPermissionsManager = client.application?.commands.permissions; - const guildPermissionsManager = client.guilds.cache.get(testGuildId)?.commands.permissions; - const originalPermissions = await client.application?.commands.permissions.fetch({ guild: testGuildId }); - - // Permissions from global manager - await globalPermissionsManager?.add({ - command: globalCommandId, - guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - await globalPermissionsManager?.has({ command: globalCommandId, guild: testGuildId, permissionId: testGuildId }); - await globalPermissionsManager?.fetch({ guild: testGuildId }); - await globalPermissionsManager?.fetch({ command: globalCommandId, guild: testGuildId }); - await globalPermissionsManager?.remove({ command: globalCommandId, guild: testGuildId, roles: [testGuildId] }); - await globalPermissionsManager?.remove({ command: globalCommandId, guild: testGuildId, users: [testUserId] }); - await globalPermissionsManager?.remove({ - command: globalCommandId, - guild: testGuildId, - roles: [testGuildId], - users: [testUserId], - }); - await globalPermissionsManager?.set({ - command: globalCommandId, - guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - await globalPermissionsManager?.set({ - guild: testGuildId, - fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }], - }); - - // @ts-expect-error - await globalPermissionsManager?.add({ - command: globalCommandId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - // @ts-expect-error - await globalPermissionsManager?.has({ command: globalCommandId, permissionId: testGuildId }); - // @ts-expect-error - await globalPermissionsManager?.fetch(); - // @ts-expect-error - await globalPermissionsManager?.fetch({ command: globalCommandId }); - // @ts-expect-error - await globalPermissionsManager?.remove({ command: globalCommandId, roles: [testGuildId] }); - // @ts-expect-error - await globalPermissionsManager?.remove({ command: globalCommandId, users: [testUserId] }); - // @ts-expect-error - await globalPermissionsManager?.remove({ command: globalCommandId, roles: [testGuildId], users: [testUserId] }); - // @ts-expect-error - await globalPermissionsManager?.set({ - command: globalCommandId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - // @ts-expect-error - await globalPermissionsManager?.set({ - fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }], - }); - // @ts-expect-error - await globalPermissionsManager?.set({ - command: globalCommandId, - guild: testGuildId, - fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }], - }); - - // @ts-expect-error - await globalPermissionsManager?.add({ - guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - // @ts-expect-error - await globalPermissionsManager?.has({ guild: testGuildId, permissionId: testGuildId }); - // @ts-expect-error - await globalPermissionsManager?.remove({ guild: testGuildId, roles: [testGuildId] }); - // @ts-expect-error - await globalPermissionsManager?.remove({ guild: testGuildId, users: [testUserId] }); - // @ts-expect-error - await globalPermissionsManager?.remove({ guild: testGuildId, roles: [testGuildId], users: [testUserId] }); - // @ts-expect-error - await globalPermissionsManager?.set({ - guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - - // Permissions from guild manager - await guildPermissionsManager?.add({ - command: globalCommandId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - await guildPermissionsManager?.has({ command: globalCommandId, permissionId: testGuildId }); - await guildPermissionsManager?.fetch({}); - await guildPermissionsManager?.fetch({ command: globalCommandId }); - await guildPermissionsManager?.remove({ command: globalCommandId, roles: [testGuildId] }); - await guildPermissionsManager?.remove({ command: globalCommandId, users: [testUserId] }); - await guildPermissionsManager?.remove({ command: globalCommandId, roles: [testGuildId], users: [testUserId] }); - await guildPermissionsManager?.set({ - command: globalCommandId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - await guildPermissionsManager?.set({ - fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }], - }); - - await guildPermissionsManager?.add({ - command: globalCommandId, - // @ts-expect-error - guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - // @ts-expect-error - await guildPermissionsManager?.has({ command: globalCommandId, guild: testGuildId, permissionId: testGuildId }); - // @ts-expect-error - await guildPermissionsManager?.fetch({ guild: testGuildId }); - // @ts-expect-error - await guildPermissionsManager?.fetch({ command: globalCommandId, guild: testGuildId }); - // @ts-expect-error - await guildPermissionsManager?.remove({ command: globalCommandId, guild: testGuildId, roles: [testGuildId] }); - // @ts-expect-error - await guildPermissionsManager?.remove({ command: globalCommandId, guild: testGuildId, users: [testUserId] }); - await guildPermissionsManager?.remove({ - command: globalCommandId, - // @ts-expect-error - guild: testGuildId, - roles: [testGuildId], - users: [testUserId], - }); - // @ts-expect-error - await guildPermissionsManager?.set({ - command: globalCommandId, - guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - await guildPermissionsManager?.set({ - // @ts-expect-error - guild: testGuildId, - fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }], - }); - - // @ts-expect-error - await guildPermissionsManager?.add({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }); - // @ts-expect-error - await guildPermissionsManager?.has({ permissionId: testGuildId }); - // @ts-expect-error - await guildPermissionsManager?.remove({ roles: [testGuildId] }); - // @ts-expect-error - await guildPermissionsManager?.remove({ users: [testUserId] }); - // @ts-expect-error - await guildPermissionsManager?.remove({ roles: [testGuildId], users: [testUserId] }); - // @ts-expect-error - await guildPermissionsManager?.set({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }); - // @ts-expect-error - await guildPermissionsManager?.set({ - command: globalCommandId, - fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }], - }); - - // Permissions from cached global ApplicationCommand - await globalCommand?.permissions.add({ - guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - await globalCommand?.permissions.has({ guild: testGuildId, permissionId: testGuildId }); - await globalCommand?.permissions.fetch({ guild: testGuildId }); - await globalCommand?.permissions.remove({ guild: testGuildId, roles: [testGuildId] }); - await globalCommand?.permissions.remove({ guild: testGuildId, users: [testUserId] }); - await globalCommand?.permissions.remove({ guild: testGuildId, roles: [testGuildId], users: [testUserId] }); - await globalCommand?.permissions.set({ - guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - - await globalCommand?.permissions.add({ - // @ts-expect-error - command: globalCommandId, - guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - // @ts-expect-error - await globalCommand?.permissions.has({ command: globalCommandId, guild: testGuildId, permissionId: testGuildId }); - // @ts-expect-error - await globalCommand?.permissions.fetch({ command: globalCommandId, guild: testGuildId }); - // @ts-expect-error - await globalCommand?.permissions.remove({ command: globalCommandId, guild: testGuildId, roles: [testGuildId] }); - // @ts-expect-error - await globalCommand?.permissions.remove({ command: globalCommandId, guild: testGuildId, users: [testUserId] }); - await globalCommand?.permissions.remove({ - // @ts-expect-error - command: globalCommandId, - guild: testGuildId, - roles: [testGuildId], - users: [testUserId], - }); - await globalCommand?.permissions.set({ - // @ts-expect-error - command: globalCommandId, - guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - - // @ts-expect-error - await globalCommand?.permissions.add({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }); - // @ts-expect-error - await globalCommand?.permissions.has({ permissionId: testGuildId }); - // @ts-expect-error - await globalCommand?.permissions.fetch({}); - // @ts-expect-error - await globalCommand?.permissions.remove({ roles: [testGuildId] }); - // @ts-expect-error - await globalCommand?.permissions.remove({ users: [testUserId] }); - // @ts-expect-error - await globalCommand?.permissions.remove({ roles: [testGuildId], users: [testUserId] }); - // @ts-expect-error - await globalCommand?.permissions.set({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }); - - // Permissions from cached guild ApplicationCommand - await guildCommandFromGlobal?.permissions.add({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }); - await guildCommandFromGlobal?.permissions.has({ permissionId: testGuildId }); - await guildCommandFromGlobal?.permissions.fetch({}); - await guildCommandFromGlobal?.permissions.remove({ roles: [testGuildId] }); - await guildCommandFromGlobal?.permissions.remove({ users: [testUserId] }); - await guildCommandFromGlobal?.permissions.remove({ roles: [testGuildId], users: [testUserId] }); - await guildCommandFromGlobal?.permissions.set({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }); - - await guildCommandFromGlobal?.permissions.add({ - // @ts-expect-error - command: globalCommandId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - // @ts-expect-error - await guildCommandFromGlobal?.permissions.has({ command: guildCommandId, permissionId: testGuildId }); - // @ts-expect-error - await guildCommandFromGlobal?.permissions.remove({ command: guildCommandId, roles: [testGuildId] }); - // @ts-expect-error - await guildCommandFromGlobal?.permissions.remove({ command: guildCommandId, users: [testUserId] }); - await guildCommandFromGlobal?.permissions.remove({ - // @ts-expect-error - command: guildCommandId, - roles: [testGuildId], - users: [testUserId], - }); - await guildCommandFromGlobal?.permissions.set({ - // @ts-expect-error - command: guildCommandId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - - await guildCommandFromGlobal?.permissions.add({ - // @ts-expect-error - guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - // @ts-expect-error - await guildCommandFromGlobal?.permissions.has({ guild: testGuildId, permissionId: testGuildId }); - // @ts-expect-error - await guildCommandFromGlobal?.permissions.remove({ guild: testGuildId, roles: [testGuildId] }); - // @ts-expect-error - await guildCommandFromGlobal?.permissions.remove({ guild: testGuildId, users: [testUserId] }); - // @ts-expect-error - await guildCommandFromGlobal?.permissions.remove({ guild: testGuildId, roles: [testGuildId], users: [testUserId] }); - await guildCommandFromGlobal?.permissions.set({ - // @ts-expect-error - guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - - await guildCommandFromGuild?.permissions.add({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }); - await guildCommandFromGuild?.permissions.has({ permissionId: testGuildId }); - await guildCommandFromGuild?.permissions.fetch({}); - await guildCommandFromGuild?.permissions.remove({ roles: [testGuildId] }); - await guildCommandFromGuild?.permissions.remove({ users: [testUserId] }); - await guildCommandFromGuild?.permissions.remove({ roles: [testGuildId], users: [testUserId] }); - await guildCommandFromGuild?.permissions.set({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }); - - await guildCommandFromGuild?.permissions.add({ - // @ts-expect-error - command: globalCommandId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - // @ts-expect-error - await guildCommandFromGuild?.permissions.has({ command: guildCommandId, permissionId: testGuildId }); - // @ts-expect-error - await guildCommandFromGuild?.permissions.remove({ command: guildCommandId, roles: [testGuildId] }); - // @ts-expect-error - await guildCommandFromGuild?.permissions.remove({ command: guildCommandId, users: [testUserId] }); - await guildCommandFromGuild?.permissions.remove({ - // @ts-expect-error - command: guildCommandId, - roles: [testGuildId], - users: [testUserId], - }); - await guildCommandFromGuild?.permissions.set({ - // @ts-expect-error - command: guildCommandId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - - await guildCommandFromGuild?.permissions.add({ - // @ts-expect-error - guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - // @ts-expect-error - await guildCommandFromGuild?.permissions.has({ guild: testGuildId, permissionId: testGuildId }); - // @ts-expect-error - await guildCommandFromGuild?.permissions.remove({ guild: testGuildId, roles: [testGuildId] }); - // @ts-expect-error - await guildCommandFromGuild?.permissions.remove({ guild: testGuildId, users: [testUserId] }); - // @ts-expect-error - await guildCommandFromGuild?.permissions.remove({ guild: testGuildId, roles: [testGuildId], users: [testUserId] }); - await guildCommandFromGuild?.permissions.set({ - // @ts-expect-error - guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], - }); - - client.application?.commands.permissions.set({ - guild: testGuildId, - fullPermissions: originalPermissions?.map((permissions, id) => ({ permissions, id })) ?? [], - }); -}); - -client.on('guildCreate', async g => { - const channel = g.channels.cache.random(); - if (!channel) return; - - if (channel.isThread()) { - const fetchedMember = await channel.members.fetch('12345678'); - expectType(fetchedMember); - const fetchedMemberCol = await channel.members.fetch(true); - expectDeprecated(await channel.members.fetch(true)); - expectType>(fetchedMemberCol); - } - - 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 MessageAttachment('file.png'); - const embed = new MessageEmbed(); - 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: 'BUTTON' }); - expectType>(component); - expectType>(await component.reply({ fetchReply: true })); - - const buttonCollector = message.createMessageComponentCollector({ componentType: 'BUTTON' }); - expectType>>(buttonCollector); - expectAssignable<(test: ButtonInteraction<'cached'>) => 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: 'BUTTON' }); - expectAssignable>(message.awaitMessageComponent({ componentType: 'BUTTON' })); - expectAssignable>(channel.awaitMessageComponent({ componentType: 'BUTTON' })); - expectAssignable>(buttonCollector); - - // Verify that select menus interaction are inferred. - const selectMenuCollector = message.createMessageComponentCollector({ componentType: 'SELECT_MENU' }); - expectAssignable>(message.awaitMessageComponent({ componentType: 'SELECT_MENU' })); - expectAssignable>(channel.awaitMessageComponent({ componentType: 'SELECT_MENU' })); - 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. - - // @ts-expect-error - const interactionOptions = message.createMessageComponentCollector({ interactionType: 'APPLICATION_COMMAND' }); - - // Make sure filter parameters are properly inferred. - message.createMessageComponentCollector({ - filter: i => { - expectType(i); - return true; - }, - }); - - message.createMessageComponentCollector({ - componentType: 'BUTTON', - filter: i => { - expectType(i); - return true; - }, - }); - - message.createMessageComponentCollector({ - componentType: 'SELECT_MENU', - filter: i => { - expectType(i); - return true; - }, - }); - - message.awaitMessageComponent({ - filter: i => { - expectType(i); - return true; - }, - }); - - message.awaitMessageComponent({ - componentType: 'BUTTON', - filter: i => { - expectType(i); - return true; - }, - }); - - message.awaitMessageComponent({ - componentType: 'SELECT_MENU', - 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: 'BUTTON', - filter: i => { - expectType>(i); - return true; - }, - }); - - channel.awaitMessageComponent({ - componentType: 'SELECT_MENU', - filter: i => { - expectType>(i); - return true; - }, - }); -}); - -client.on('interaction', async interaction => { - expectType(interaction.guildId); - expectType(interaction.channelId); - expectType(interaction.member); - - if (!interaction.isCommand()) return; - - void new MessageActionRow(); - - void new MessageActionRow({}); - - const button = new MessageButton(); - - const actionRow = new MessageActionRow({ components: [button] }); - - await interaction.reply({ content: 'Hi!', components: [actionRow] }); - - // @ts-expect-error - interaction.reply({ content: 'Hi!', components: [[button]] }); - - // @ts-expect-error - await interaction.reply({ content: 'Hi!', components: [button] }); - - if (interaction.isMessageComponent()) { - expectType(interaction.channelId); - } -}); - -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); -expectType(loggedInClient.readyTimestamp); -expectType(loggedInClient.token); -expectType(loggedInClient.uptime); -expectType(loggedInClient.user); - -declare const loggedOutClient: Client; -expectType(loggedOutClient.application); -expectType(loggedOutClient.readyAt); -expectType(loggedOutClient.readyTimestamp); -expectType(loggedOutClient.token); -expectType(loggedOutClient.uptime); -expectType(loggedOutClient.user); - -expectType(serialize(undefined)); -expectType(serialize(null)); -expectType(serialize([1, 2, 3])); -expectType<{}>(serialize(new Set([1, 2, 3]))); -expectType<{}>( - serialize( - new Map([ - [1, '2'], - [2, '4'], - ]), - ), -); -expectType(serialize(new Permissions(Permissions.FLAGS.ATTACH_FILES))); -expectType(serialize(new Intents(Intents.FLAGS.GUILDS))); -expectAssignable( - serialize( - new Collection([ - [1, '2'], - [2, '4'], - ]), - ), -); -expectType(serialize(Symbol('a'))); -expectType(serialize(() => {})); -expectType(serialize(BigInt(42))); - -// Test type return of broadcastEval: -declare const shardClientUtil: ShardClientUtil; -declare const shardingManager: ShardingManager; - -expectType>(shardingManager.broadcastEval(() => 1)); -expectType>(shardClientUtil.broadcastEval(() => 1)); -expectType>(shardingManager.broadcastEval(async () => 1)); -expectType>(shardClientUtil.broadcastEval(async () => 1)); - -declare const dmChannel: DMChannel; -declare const threadChannel: ThreadChannel; -declare const newsChannel: NewsChannel; -declare const textChannel: TextChannel; -declare const storeChannel: StoreChannel; -declare const voiceChannel: VoiceChannel; -declare const guild: Guild; -declare const user: User; -declare const guildMember: GuildMember; - -// Test whether the structures implement send -expectType(dmChannel.send); -expectType(threadChannel); -expectType(newsChannel); -expectType(textChannel); -expectAssignable(user); -expectAssignable(guildMember); - -expectType(dmChannel.lastMessage); -expectType(threadChannel.lastMessage); -expectType(newsChannel.lastMessage); -expectType(textChannel.lastMessage); - -expectDeprecated(storeChannel.clone()); -expectDeprecated(categoryChannel.createChannel('Store', { type: 'GUILD_STORE' })); -expectDeprecated(guild.channels.create('Store', { type: 'GUILD_STORE' })); - -notPropertyOf(user, 'lastMessage'); -notPropertyOf(user, 'lastMessageId'); -notPropertyOf(guildMember, 'lastMessage'); -notPropertyOf(guildMember, 'lastMessageId'); - -// Test collector event parameters -declare const messageCollector: MessageCollector; -messageCollector.on('collect', (...args) => { - expectType<[Message]>(args); -}); - -declare const reactionCollector: ReactionCollector; -reactionCollector.on('dispose', (...args) => { - expectType<[MessageReaction, User]>(args); -}); - -// Make sure the properties are typed correctly, and that no backwards properties -// (K -> V and V -> K) exist: -expectType<'messageCreate'>(Constants.Events.MESSAGE_CREATE); -expectType<'close'>(Constants.ShardEvents.CLOSE); -expectType<1>(Constants.Status.CONNECTING); -expectType<0>(Constants.Opcodes.DISPATCH); -expectType<2>(Constants.ClientApplicationAssetTypes.BIG); - -declare const applicationCommandData: ApplicationCommandData; -declare const applicationCommandResolvable: ApplicationCommandResolvable; -declare const applicationCommandManager: ApplicationCommandManager; -{ - type ApplicationCommandScope = ApplicationCommand<{ guild: GuildResolvable }>; - - expectType>(applicationCommandManager.create(applicationCommandData)); - expectAssignable>(applicationCommandManager.create(applicationCommandData, '0')); - expectType>( - applicationCommandManager.edit(applicationCommandResolvable, applicationCommandData), - ); - expectType>( - applicationCommandManager.edit(applicationCommandResolvable, applicationCommandData, '0'), - ); - expectType>>( - applicationCommandManager.set([applicationCommandData]), - ); - expectType>>( - applicationCommandManager.set([applicationCommandData], '0'), - ); -} - -declare const applicationNonChoiceOptionData: ApplicationCommandOptionData & { - type: CommandOptionNonChoiceResolvableType; -}; -{ - // Options aren't allowed on this command type. - - // @ts-expect-error - applicationNonChoiceOptionData.choices; -} - -declare const applicationSubGroupCommandData: ApplicationCommandSubGroupData; -{ - expectType<'SUB_COMMAND_GROUP' | ApplicationCommandOptionTypes.SUB_COMMAND_GROUP>( - applicationSubGroupCommandData.type, - ); - expectType(applicationSubGroupCommandData.options); -} - -declare const guildApplicationCommandManager: GuildApplicationCommandManager; -expectType>>(guildApplicationCommandManager.fetch()); -expectType>>(guildApplicationCommandManager.fetch(undefined, {})); -expectType>(guildApplicationCommandManager.fetch('0')); - -declare const categoryChannel: CategoryChannel; -{ - expectType>(categoryChannel.createChannel('name', { type: 'GUILD_VOICE' })); - expectType>(categoryChannel.createChannel('name', { type: 'GUILD_TEXT' })); - expectType>(categoryChannel.createChannel('name', { type: 'GUILD_NEWS' })); - expectType>(categoryChannel.createChannel('name', { type: 'GUILD_STORE' })); - expectType>(categoryChannel.createChannel('name', { type: 'GUILD_STAGE_VOICE' })); - expectType>(categoryChannel.createChannel('name', {})); - expectType>(categoryChannel.createChannel('name')); -} - -declare const guildChannelManager: GuildChannelManager; -{ - type AnyChannel = TextChannel | VoiceChannel | CategoryChannel | NewsChannel | StoreChannel | StageChannel; - - expectType>(guildChannelManager.create('name')); - expectType>(guildChannelManager.create('name', {})); - expectType>(guildChannelManager.create('name', { type: 'GUILD_VOICE' })); - expectType>(guildChannelManager.create('name', { type: 'GUILD_CATEGORY' })); - expectType>(guildChannelManager.create('name', { type: 'GUILD_TEXT' })); - expectType>(guildChannelManager.create('name', { type: 'GUILD_NEWS' })); - expectType>(guildChannelManager.create('name', { type: 'GUILD_STORE' })); - expectType>(guildChannelManager.create('name', { type: 'GUILD_STAGE_VOICE' })); - - expectType>>(guildChannelManager.fetch()); - expectType>>(guildChannelManager.fetch(undefined, {})); - expectType>(guildChannelManager.fetch('0')); -} - -declare const roleManager: RoleManager; -expectType>>(roleManager.fetch()); -expectType>>(roleManager.fetch(undefined, {})); -expectType>(roleManager.fetch('0')); - -declare const guildEmojiManager: GuildEmojiManager; -expectType>>(guildEmojiManager.fetch()); -expectType>>(guildEmojiManager.fetch(undefined, {})); -expectType>(guildEmojiManager.fetch('0')); - -declare const guildBanManager: GuildBanManager; -{ - expectType>(guildBanManager.fetch('1234567890')); - expectType>(guildBanManager.fetch({ user: '1234567890' })); - expectType>(guildBanManager.fetch({ user: '1234567890', cache: true, force: false })); - expectType>>(guildBanManager.fetch()); - expectType>>(guildBanManager.fetch({})); - expectType>>(guildBanManager.fetch({ limit: 100, before: '1234567890' })); - // @ts-expect-error - guildBanManager.fetch({ cache: true, force: false }); - // @ts-expect-error - guildBanManager.fetch({ user: '1234567890', after: '1234567890', cache: true, force: false }); -} - -declare const typing: Typing; -expectType(typing.user); -if (typing.user.partial) expectType(typing.user.username); - -expectType(typing.channel); -if (typing.channel.partial) expectType(typing.channel.lastMessageId); - -expectType(typing.member); -expectType(typing.guild); - -if (typing.inGuild()) { - expectType(typing.channel.guild); - 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 .deleted deprecations -declare const emoji: Emoji; -declare const message: Message; -declare const role: Role; -declare const stageInstance: StageInstance; -declare const sticker: Sticker; -expectDeprecated(dmChannel.deleted); -expectDeprecated(textChannel.deleted); -expectDeprecated(voiceChannel.deleted); -expectDeprecated(newsChannel.deleted); -expectDeprecated(threadChannel.deleted); -expectDeprecated(emoji.deleted); -expectDeprecated(guildMember.deleted); -expectDeprecated(guild.deleted); -expectDeprecated(message.deleted); -expectDeprecated(role.deleted); -expectDeprecated(stageInstance.deleted); -expectDeprecated(sticker.deleted); - -// Test interactions -declare const interaction: Interaction; -declare const booleanValue: boolean; -if (interaction.inGuild()) { - expectType(interaction.guildId); -} else { - 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.inCachedGuild()) { - expectAssignable(interaction.member); - expectNotType>(interaction); - expectAssignable(interaction); - expectType(interaction.guildLocale); - } else if (interaction.inRawGuild()) { - expectAssignable(interaction.member); - expectNotAssignable>(interaction); - expectType(interaction.guildLocale); - } else if (interaction.inGuild()) { - expectType(interaction.guildLocale); - } else { - expectType(interaction.member); - expectNotAssignable>(interaction); - expectType(interaction.guildId); - } - - if (interaction.isContextMenu()) { - expectType(interaction); - if (interaction.inCachedGuild()) { - expectAssignable(interaction); - expectAssignable(interaction.guild); - expectAssignable>(interaction); - } else if (interaction.inRawGuild()) { - expectAssignable(interaction); - expectType(interaction.guild); - } else if (interaction.inGuild()) { - expectAssignable(interaction); - expectType(interaction.guild); - } - } - - if (interaction.isMessageContextMenu()) { - expectType(interaction.targetMessage); - if (interaction.inCachedGuild()) { - expectType>(interaction.targetMessage); - } else if (interaction.inRawGuild()) { - expectType(interaction.targetMessage); - } else if (interaction.inGuild()) { - expectType(interaction.targetMessage); - } - } - - if (interaction.isButton()) { - expectType(interaction); - expectType(interaction.component); - expectType(interaction.message); - if (interaction.inCachedGuild()) { - expectAssignable(interaction); - expectType(interaction.component); - expectType>(interaction.message); - expectType(interaction.guild); - expectAssignable>(interaction.reply({ fetchReply: true })); - } else if (interaction.inRawGuild()) { - expectAssignable(interaction); - expectType(interaction.component); - expectType(interaction.message); - expectType(interaction.guild); - expectType>(interaction.reply({ fetchReply: true })); - } else if (interaction.inGuild()) { - expectAssignable(interaction); - expectType(interaction.component); - expectType(interaction.message); - expectAssignable(interaction.guild); - expectType>(interaction.reply({ fetchReply: true })); - } - } - - if (interaction.isMessageComponent()) { - expectType(interaction); - expectType(interaction.component); - expectType(interaction.message); - if (interaction.inCachedGuild()) { - expectAssignable(interaction); - expectType(interaction.component); - expectType>(interaction.message); - expectType(interaction.guild); - expectAssignable>(interaction.reply({ fetchReply: true })); - } else if (interaction.inRawGuild()) { - expectAssignable(interaction); - expectType(interaction.component); - expectType(interaction.message); - expectType(interaction.guild); - expectType>(interaction.reply({ fetchReply: true })); - } else if (interaction.inGuild()) { - expectAssignable(interaction); - expectType(interaction.component); - expectType(interaction.message); - expectType(interaction.guild); - expectType>(interaction.reply({ fetchReply: true })); - } - } - - if (interaction.isSelectMenu()) { - expectType(interaction); - expectType(interaction.component); - expectType(interaction.message); - if (interaction.inCachedGuild()) { - expectAssignable(interaction); - expectType(interaction.component); - expectType>(interaction.message); - expectType(interaction.guild); - expectType>>(interaction.reply({ fetchReply: true })); - } else if (interaction.inRawGuild()) { - expectAssignable(interaction); - expectType(interaction.component); - expectType(interaction.message); - expectType(interaction.guild); - expectType>(interaction.reply({ fetchReply: true })); - } else if (interaction.inGuild()) { - expectAssignable(interaction); - expectType(interaction.component); - expectType(interaction.message); - expectType(interaction.guild); - expectType>(interaction.reply({ fetchReply: true })); - } - } - - if (interaction.isCommand()) { - if (interaction.inRawGuild()) { - expectNotAssignable>(interaction); - expectAssignable(interaction); - expectType>(interaction.reply({ fetchReply: true })); - expectType(interaction.options.getMember('test')); - expectType(interaction.options.getMember('test', true)); - - expectType(interaction.options.getChannel('test', true)); - expectType(interaction.options.getRole('test', true)); - } else if (interaction.inCachedGuild()) { - const msg = await interaction.reply({ fetchReply: true }); - const btn = await msg.awaitMessageComponent({ componentType: 'BUTTON' }); - - expectType>(msg); - expectType>(btn); - - expectType(interaction.options.getMember('test')); - expectAssignable(interaction); - expectType>>(interaction.reply({ fetchReply: true })); - - expectType(interaction.options.getChannel('test', true)); - expectType(interaction.options.getRole('test', true)); - } else { - // @ts-expect-error - consumeCachedCommand(interaction); - expectType(interaction); - expectType>(interaction.reply({ fetchReply: true })); - expectType(interaction.options.getMember('test')); - expectType(interaction.options.getMember('test', true)); - - expectType(interaction.options.getChannel('test', true)); - expectType(interaction.options.getRole('test', true)); - } - - expectType(interaction); - expectType, 'getFocused' | 'getMessage'>>(interaction.options); - expectType(interaction.options.data); - - const optionalOption = interaction.options.get('name'); - const requiredOption = interaction.options.get('name', true); - expectType(optionalOption); - expectType(requiredOption); - expectType(requiredOption.options); - - expectType(interaction.options.getString('name', booleanValue)); - expectType(interaction.options.getString('name', false)); - expectType(interaction.options.getString('name', true)); - - expectType(interaction.options.getSubcommand()); - expectType(interaction.options.getSubcommand(true)); - expectType(interaction.options.getSubcommand(booleanValue)); - expectType(interaction.options.getSubcommand(false)); - - expectType(interaction.options.getSubcommandGroup()); - expectType(interaction.options.getSubcommandGroup(true)); - expectType(interaction.options.getSubcommandGroup(booleanValue)); - expectType(interaction.options.getSubcommandGroup(false)); - } - - if (interaction.isRepliable()) { - expectAssignable(interaction); - interaction.reply('test'); - } - - if (interaction.isCommand() && interaction.isRepliable()) { - expectAssignable(interaction); - expectAssignable(interaction); - } -}); - -declare const shard: Shard; - -shard.on('death', process => { - expectType(process); -}); - -declare const webSocketShard: WebSocketShard; - -webSocketShard.on('close', event => { - expectType(event); -}); - -declare const collector: Collector; - -collector.on('collect', (collected, ...other) => { - expectType(collected); - expectType(other); -}); - -collector.on('dispose', (vals, ...other) => { - expectType(vals); - expectType(other); -}); - -collector.on('end', (collection, reason) => { - expectType>(collection); - expectType(reason); -}); - -expectType>(shard.eval(c => c.readyTimestamp)); - -// Test audit logs -expectType>>(guild.fetchAuditLogs({ type: 'MEMBER_KICK' })); -expectAssignable>>( - guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.MEMBER_KICK }), -); -expectType>>(guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick })); - -expectType>>(guild.fetchAuditLogs({ type: 'CHANNEL_CREATE' })); -expectAssignable>>( - guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.CHANNEL_CREATE }), -); -expectType>>( - guild.fetchAuditLogs({ type: AuditLogEvent.ChannelCreate }), -); - -expectType>>(guild.fetchAuditLogs({ type: 'INTEGRATION_UPDATE' })); -expectAssignable>>( - guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.INTEGRATION_UPDATE }), -); -expectType>>( - guild.fetchAuditLogs({ type: AuditLogEvent.IntegrationUpdate }), -); - -expectType>>(guild.fetchAuditLogs({ type: 'ALL' })); -expectType>>(guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.ALL })); -expectType>>(guild.fetchAuditLogs()); - -expectType | undefined>>( - guild.fetchAuditLogs({ type: 'MEMBER_KICK' }).then(al => al.entries.first()), -); -expectType | undefined>>( - guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.MEMBER_KICK }).then(al => al.entries.first()), -); -expectAssignable | undefined>>( - guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick }).then(al => al.entries.first()), -); - -expectType | undefined>>( - guild.fetchAuditLogs({ type: 'ALL' }).then(al => al.entries.first()), -); -expectType | undefined>>( - guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.ALL }).then(al => al.entries.first()), -); -expectType | undefined>>( - guild.fetchAuditLogs({ type: null }).then(al => al.entries.first()), -); -expectType | undefined>>( - guild.fetchAuditLogs().then(al => al.entries.first()), -); - -expectType>( - guild.fetchAuditLogs({ type: 'MEMBER_KICK' }).then(al => al.entries.first()?.extra), -); -expectType>( - guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick }).then(al => al.entries.first()?.extra), -); -expectType>( - guild.fetchAuditLogs({ type: 'STAGE_INSTANCE_CREATE' }).then(al => al.entries.first()?.extra), -); -expectType>( - guild.fetchAuditLogs({ type: 'MESSAGE_DELETE' }).then(al => al.entries.first()?.extra), -); - -expectType>( - guild.fetchAuditLogs({ type: 'MEMBER_KICK' }).then(al => al.entries.first()?.target), -); -expectType>( - guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick }).then(al => al.entries.first()?.target), -); -expectType>( - guild.fetchAuditLogs({ type: 'STAGE_INSTANCE_CREATE' }).then(al => al.entries.first()?.target), -); -expectType>( - guild.fetchAuditLogs({ type: 'MESSAGE_DELETE' }).then(al => al.entries.first()?.target), -); - -expectType>( - // @ts-expect-error Invalid audit log ID - guild.fetchAuditLogs({ type: 2000 }).then(al => al.entries.first()?.target), -); - -declare const TextBasedChannel: TextBasedChannel; -declare const TextBasedChannelTypes: TextBasedChannelTypes; -declare const VoiceBasedChannel: VoiceBasedChannel; -declare const GuildBasedChannel: GuildBasedChannel; -declare const NonThreadGuildBasedChannel: NonThreadGuildBasedChannel; -declare const GuildTextBasedChannel: GuildTextBasedChannel; - -expectType(TextBasedChannel); -expectType<'DM' | 'GUILD_NEWS' | 'GUILD_TEXT' | 'GUILD_PUBLIC_THREAD' | 'GUILD_PRIVATE_THREAD' | 'GUILD_NEWS_THREAD'>( - TextBasedChannelTypes, -); -expectType(VoiceBasedChannel); -expectType( - GuildBasedChannel, -); -expectType( - NonThreadGuildBasedChannel, -); -expectType(GuildTextBasedChannel);