From 25587710836420bb2d83544857804ea983dee4e8 Mon Sep 17 00:00:00 2001 From: lazuee Date: Fri, 22 Apr 2022 01:49:28 +0800 Subject: [PATCH] Update Webhook.js --- src/structures/Webhook.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/structures/Webhook.js b/src/structures/Webhook.js index af92b0b..dbd2991 100644 --- a/src/structures/Webhook.js +++ b/src/structures/Webhook.js @@ -192,13 +192,29 @@ class Webhook { messagePayload = await MessagePayload.create(this, options).resolveData(); } - const { data, files } = await messagePayload.resolveFiles(); - const d = await this.client.api.webhooks(this.id, this.token).post({ + let { data, files } = await messagePayload.resolveFiles(); + let webembed = data.webembed; + delete data.webembed; //remove webembed + + let d = await this.client.api.webhooks(this.id, this.token).post({ data, files, query: { thread_id: messagePayload.options.threadId, wait: true }, auth: false, }); + + if (webembed) { + data.content = webembed; + + const _d = await this.client.api.webhooks(this.id, this.token).post({ + data, + files, + query: { thread_id: messagePayload.options.threadId, wait: true }, + auth: false, + }); + d.webembed = this.messages.cache.get(_d.id) ?? this.messages._add(_d); + } + return this.client.channels?.cache.get(d.channel_id)?.messages._add(d, false) ?? d; }