Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(*): document and support embeds field in message create endpoint #5792

Merged
merged 14 commits into from
Jun 11, 2021
Prev Previous commit
Next Next commit
fix: (ApiMessage): only accept embeds field
adrifcastr committed Jun 11, 2021
commit 047a3bae4d15c1fff99d2dc0fc25a1a74f9db3f1
7 changes: 4 additions & 3 deletions src/structures/APIMessage.js
Original file line number Diff line number Diff line change
@@ -312,9 +312,10 @@ class APIMessage {
* @returns {MessageOptions|WebhookMessageOptions}
*/
static create(target, options, extra = {}) {
if (typeof options !== 'object' || options === null) return new this(target, { content: options, ...extra });
if (options.embed) options.embeds = [options.embed];
return new this(target, { ...options, ...extra });
return new this(
target,
typeof options !== 'object' || options === null ? { content: options, ...extra } : { ...options, ...extra },
);
}
}

2 changes: 0 additions & 2 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
@@ -3240,7 +3240,6 @@ declare module 'discord.js' {
interface MessageEditOptions {
attachments?: MessageAttachment[];
content?: string | null;
embed?: MessageEmbed | MessageEmbedOptions | null;
embeds?: (MessageEmbed | MessageEmbedOptions)[] | null;
code?: string | boolean;
files?: (FileOptions | BufferResolvable | Stream | MessageAttachment)[];
@@ -3337,7 +3336,6 @@ declare module 'discord.js' {
tts?: boolean;
nonce?: string | number;
content?: string;
embed?: MessageEmbed | MessageEmbedOptions;
embeds?: (MessageEmbed | MessageEmbedOptions)[];
components?: MessageActionRow[] | MessageActionRowOptions[] | MessageActionRowComponentResolvable[][];
allowedMentions?: MessageMentionOptions;