From 1b827fe13638279fe57c7a4f897b38e749ac06f6 Mon Sep 17 00:00:00 2001 From: Jan <66554238+vaporox@users.noreply.github.com> Date: Fri, 23 Apr 2021 02:18:07 +0200 Subject: [PATCH] refactor: add discord-api-types as a dependency (#5539) --- package-lock.json | 23 +++++-- package.json | 3 +- typings/index.d.ts | 156 ++++++--------------------------------------- 3 files changed, 37 insertions(+), 145 deletions(-) diff --git a/package-lock.json b/package-lock.json index 03972d4e3..0dd53df56 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2382,6 +2382,12 @@ "integrity": "sha512-Mv/TDa3nZ9sbc5soK+OoA74BsS3mL37yixCvUAQkiuA4Wz6YtwP/K47n2rv2ovzHZvoiQeA5FTQOschKkEwB0Q==", "dev": true }, + "discord-api-types": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.18.0.tgz", + "integrity": "sha512-KxS+opGqrNbzo+wb3SxOqfuv/xX2CyrwEjCQLTI68gzjbSMn55h6o7JtPkWAXItadkNrUWyDqMMsfOz8DnpiNA==", + "dev": true + }, "discord.js-docgen": { "version": "git+https://github.com/discordjs/docgen.git#d40f54cfd2d0f03ff92d7ecfb29cd82694ee2c11", "from": "git+https://github.com/discordjs/docgen.git", @@ -4208,7 +4214,8 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz", "integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=", - "dev": true + "dev": true, + "optional": true }, "handlebars": { "version": "4.7.6", @@ -4775,6 +4782,7 @@ "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", "dev": true, + "optional": true, "requires": { "is-docker": "^2.0.0" } @@ -6197,6 +6205,7 @@ "resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.1.tgz", "integrity": "sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==", "dev": true, + "optional": true, "requires": { "growly": "^1.3.0", "is-wsl": "^2.2.0", @@ -6210,7 +6219,8 @@ "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true + "dev": true, + "optional": true } } }, @@ -7437,7 +7447,8 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz", "integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==", - "dev": true + "dev": true, + "optional": true }, "signal-exit": { "version": "3.0.3", @@ -8454,9 +8465,9 @@ } }, "typescript": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.3.tgz", - "integrity": "sha512-tEu6DGxGgRJPb/mVPIZ48e69xCn2yRmCgYmDugAVwmJ6o+0u1RI18eO7E7WBTLYLaEVVOhwQmcdhQHweux/WPg==", + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz", + "integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==", "dev": true }, "typical": { diff --git a/package.json b/package.json index 3205e528d..0371a25b7 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "@types/node": "^12.12.6", "@types/ws": "^7.2.7", "cross-env": "^7.0.2", + "discord-api-types": "^0.18.0", "discord.js-docgen": "git+https://github.com/discordjs/docgen.git", "dtslint": "^4.0.4", "eslint": "^7.11.0", @@ -71,7 +72,7 @@ "lint-staged": "^10.4.2", "prettier": "^2.1.2", "tslint": "^6.1.3", - "typescript": "^4.0.3" + "typescript": "^4.2.4" }, "engines": { "node": ">=14.0.0" diff --git a/typings/index.d.ts b/typings/index.d.ts index bf01b3a4c..d4432bab1 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -29,6 +29,7 @@ declare enum OverwriteTypes { declare module 'discord.js' { import BaseCollection from '@discordjs/collection'; import { ChildProcess } from 'child_process'; + import { APIMessage as RawMessage, APIOverwrite as RawOverwrite } from 'discord-api-types/v8'; import { EventEmitter } from 'events'; import { PathLike } from 'fs'; import { Readable, Stream, Writable } from 'stream'; @@ -1230,7 +1231,7 @@ declare module 'discord.js' { options: PermissionOverwriteOption, initialPermissions: { allow?: PermissionResolvable; deny?: PermissionResolvable }, ): ResolvedOverwriteOptions; - public static resolve(overwrite: OverwriteResolvable, guild: Guild): RawOverwriteData; + public static resolve(overwrite: OverwriteResolvable, guild: Guild): RawOverwrite; } export class Permissions extends BitField { @@ -1812,30 +1813,22 @@ declare module 'discord.js' { message: MessageResolvable, content: APIMessageContentResolvable | APIMessage | MessageEmbed | MessageEmbed[], options?: WebhookEditMessageOptions, - ): Promise; - public editMessage( - message: MessageResolvable, - options: WebhookEditMessageOptions, - ): Promise; + ): Promise; + public editMessage(message: MessageResolvable, options: WebhookEditMessageOptions): Promise; public send( content: APIMessageContentResolvable | (WebhookMessageOptions & { split?: false }) | MessageAdditions, - ): Promise; - public send(options: WebhookMessageOptions & { split: true | SplitOptions }): Promise; - public send( - options: WebhookMessageOptions | APIMessage, - ): Promise; + ): Promise; + public send(options: WebhookMessageOptions & { split: true | SplitOptions }): Promise; + public send(options: WebhookMessageOptions | APIMessage): Promise; public send( content: StringResolvable, options: (WebhookMessageOptions & { split?: false }) | MessageAdditions, - ): Promise; + ): Promise; public send( content: StringResolvable, options: WebhookMessageOptions & { split: true | SplitOptions }, - ): Promise; - public send( - content: StringResolvable, - options: WebhookMessageOptions, - ): Promise; + ): Promise; + public send(content: StringResolvable, options: WebhookMessageOptions): Promise; } export class WebSocketManager extends EventEmitter { @@ -2167,32 +2160,25 @@ declare module 'discord.js' { message: MessageResolvable, content: APIMessageContentResolvable | APIMessage | MessageEmbed | MessageEmbed[], options?: WebhookEditMessageOptions, - ): Promise; - editMessage( - message: MessageResolvable, - options: WebhookEditMessageOptions, - ): Promise; + ): Promise; + editMessage(message: MessageResolvable, options: WebhookEditMessageOptions): Promise; send( content: APIMessageContentResolvable | (WebhookMessageOptions & { split?: false }) | MessageAdditions, - ): Promise; - send( - options: WebhookMessageOptions & { split: true | SplitOptions }, - ): Promise<(Message | WebhookRawMessageResponse)[]>; - send( - options: WebhookMessageOptions | APIMessage, - ): Promise; + ): Promise; + send(options: WebhookMessageOptions & { split: true | SplitOptions }): Promise<(Message | RawMessage)[]>; + send(options: WebhookMessageOptions | APIMessage): Promise; send( content: StringResolvable, options: (WebhookMessageOptions & { split?: false }) | MessageAdditions, - ): Promise; + ): Promise; send( content: StringResolvable, options: WebhookMessageOptions & { split: true | SplitOptions }, - ): Promise<(Message | WebhookRawMessageResponse)[]>; + ): Promise<(Message | RawMessage)[]>; send( content: StringResolvable, options: WebhookMessageOptions, - ): Promise; + ): Promise; sendSlackMessage(body: object): Promise; } @@ -2292,95 +2278,6 @@ declare module 'discord.js' { type APIMessageContentResolvable = string | number | boolean | bigint | symbol | readonly StringResolvable[]; - interface APIRawMessage { - id: Snowflake; - type: number; - content: string; - channel_id: Snowflake; - author: { - bot?: true; - id: Snowflake; - username: string; - avatar: string | null; - discriminator: string; - }; - attachments: { - id: Snowflake; - filename: string; - size: number; - url: string; - proxy_url: string; - height: number | null; - width: number | null; - }[]; - embeds: { - title?: string; - type?: 'rich' | 'image' | 'video' | 'gifv' | 'article' | 'link'; - description?: string; - url?: string; - timestamp?: string; - color?: number; - footer?: { - text: string; - icon_url?: string; - proxy_icon_url?: string; - }; - image?: { - url?: string; - proxy_url?: string; - height?: number; - width?: number; - }; - thumbnail?: { - url?: string; - proxy_url?: string; - height?: number; - width?: number; - }; - video?: { - url?: string; - height?: number; - width?: number; - }; - provider?: { name?: string; url?: string }; - author?: { - name?: string; - url?: string; - icon_url?: string; - proxy_icon_url?: string; - }; - fields?: { - name: string; - value: string; - inline?: boolean; - }[]; - }[]; - mentions: { - id: Snowflake; - username: string; - discriminator: string; - avatar: string | null; - bot?: true; - public_flags?: number; - member?: { - nick: string | null; - roles: Snowflake[]; - joined_at: string; - premium_since?: string | null; - deaf: boolean; - mute: boolean; - }; - }[]; - mention_roles: Snowflake[]; - pinned: boolean; - mention_everyone: boolean; - tts: boolean; - timestamp: string; - edited_timestamp: string | null; - flags: number; - webhook_id: Snowflake; - } - interface ApplicationAsset { name: string; id: Snowflake; @@ -3309,13 +3206,6 @@ declare module 'discord.js' { remainingTime: number; } - interface RawOverwriteData { - id: Snowflake; - allow: string; - deny: string; - type: number; - } - interface ReactionCollectorOptions extends CollectorOptions { max?: number; maxEmojis?: number; @@ -3443,16 +3333,6 @@ declare module 'discord.js' { embeds?: (MessageEmbed | object)[]; }; - type WebhookRawMessageResponse = Omit & { - author: { - bot: true; - id: Snowflake; - username: string; - avatar: string | null; - discriminator: '0000'; - }; - }; - type WebhookTypes = 'Incoming' | 'Channel Follower'; interface WebSocketOptions {