mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 11:33:30 +01:00
fix(typings): return types for 'Webhook(Client)#send()' (#4876)
* feat(Typings): add 'APIRawMessage' interface * fix(Typings): return type for WebhookFields#send() * fix(Typings): types for APIRawMessage props * refactor(Typings): exclude oauth props from API * feat(Typings): add WebhookRawMessageResponse type * refactor(Typings): use WebhookRawMessageResponse
This commit is contained in:
118
typings/index.d.ts
vendored
118
typings/index.d.ts
vendored
@@ -2092,18 +2092,25 @@ declare module 'discord.js' {
|
|||||||
edit(options: WebhookEditData): Promise<Webhook>;
|
edit(options: WebhookEditData): Promise<Webhook>;
|
||||||
send(
|
send(
|
||||||
content: APIMessageContentResolvable | (WebhookMessageOptions & { split?: false }) | MessageAdditions,
|
content: APIMessageContentResolvable | (WebhookMessageOptions & { split?: false }) | MessageAdditions,
|
||||||
): Promise<Message>;
|
): Promise<Message | WebhookRawMessageResponse>;
|
||||||
send(options: WebhookMessageOptions & { split: true | SplitOptions }): Promise<Message[]>;
|
send(
|
||||||
send(options: WebhookMessageOptions | APIMessage): Promise<Message | Message[]>;
|
options: WebhookMessageOptions & { split: true | SplitOptions },
|
||||||
|
): Promise<(Message | WebhookRawMessageResponse)[]>;
|
||||||
|
send(
|
||||||
|
options: WebhookMessageOptions | APIMessage,
|
||||||
|
): Promise<Message | WebhookRawMessageResponse | (Message | WebhookRawMessageResponse)[]>;
|
||||||
send(
|
send(
|
||||||
content: StringResolvable,
|
content: StringResolvable,
|
||||||
options: (WebhookMessageOptions & { split?: false }) | MessageAdditions,
|
options: (WebhookMessageOptions & { split?: false }) | MessageAdditions,
|
||||||
): Promise<Message>;
|
): Promise<Message | WebhookRawMessageResponse>;
|
||||||
send(
|
send(
|
||||||
content: StringResolvable,
|
content: StringResolvable,
|
||||||
options: WebhookMessageOptions & { split: true | SplitOptions },
|
options: WebhookMessageOptions & { split: true | SplitOptions },
|
||||||
): Promise<Message[]>;
|
): Promise<(Message | WebhookRawMessageResponse)[]>;
|
||||||
send(content: StringResolvable, options: WebhookMessageOptions): Promise<Message | Message[]>;
|
send(
|
||||||
|
content: StringResolvable,
|
||||||
|
options: WebhookMessageOptions,
|
||||||
|
): Promise<Message | WebhookRawMessageResponse | (Message | WebhookRawMessageResponse)[]>;
|
||||||
sendSlackMessage(body: object): Promise<boolean>;
|
sendSlackMessage(body: object): Promise<boolean>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2198,6 +2205,95 @@ declare module 'discord.js' {
|
|||||||
|
|
||||||
type APIMessageContentResolvable = string | number | boolean | bigint | symbol | readonly StringResolvable[];
|
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 {
|
interface ApplicationAsset {
|
||||||
name: string;
|
name: string;
|
||||||
id: Snowflake;
|
id: Snowflake;
|
||||||
@@ -3207,6 +3303,16 @@ declare module 'discord.js' {
|
|||||||
split?: boolean | SplitOptions;
|
split?: boolean | SplitOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type WebhookRawMessageResponse = Omit<APIRawMessage, 'author'> & {
|
||||||
|
author: {
|
||||||
|
bot: true;
|
||||||
|
id: Snowflake;
|
||||||
|
username: string;
|
||||||
|
avatar: string | null;
|
||||||
|
discriminator: '0000';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
type WebhookTypes = 'Incoming' | 'Channel Follower';
|
type WebhookTypes = 'Incoming' | 'Channel Follower';
|
||||||
|
|
||||||
interface WebSocketOptions {
|
interface WebSocketOptions {
|
||||||
|
|||||||
Reference in New Issue
Block a user