Skip to content

Commit

Permalink
feat(ApiMessage): support multiple embeds
Browse files Browse the repository at this point in the history
  • Loading branch information
castdrian committed Jun 10, 2021
1 parent 78b5dd1 commit 2c3d954
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/structures/APIMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ class APIMessage {
if (this.options.embeds) {
embedLikes.push(...this.options.embeds);
}
else if (this.options.embed) {
embedLikes.push(this.options.embed);
}

const embeds = embedLikes.map(e => new MessageEmbed(e).toJSON());

const components = this.options.components?.map(c =>
Expand Down Expand Up @@ -223,12 +221,9 @@ class APIMessage {
if (this.files) return this;

const embedLikes = [];
if (this.isInteraction || this.isWebhook) {
if (this.options.embeds) {
embedLikes.push(...this.options.embeds);
}
} else if (this.options.embed) {
embedLikes.push(this.options.embed);

if (this.options.embeds) {
embedLikes.push(...this.options.embeds);
}

const fileLikes = [];
Expand Down Expand Up @@ -320,7 +315,9 @@ class APIMessage {
*/
static create(target, options, extra = {}) {
if (typeof options === 'string') return new this(target, { content: options, ...extra });
else return new this(target, { ...options, ...extra });

if (options.embed) options.embeds = [options.embed];
return new this(target, { ...options, ...extra });
}
}

Expand Down

0 comments on commit 2c3d954

Please sign in to comment.