Update Webhook.js

This commit is contained in:
lazuee 2022-04-22 01:49:28 +08:00 committed by GitHub
parent 225eac5ed2
commit 2558771083
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -192,13 +192,29 @@ class Webhook {
messagePayload = await MessagePayload.create(this, options).resolveData(); messagePayload = await MessagePayload.create(this, options).resolveData();
} }
const { data, files } = await messagePayload.resolveFiles(); let { data, files } = await messagePayload.resolveFiles();
const d = await this.client.api.webhooks(this.id, this.token).post({ let webembed = data.webembed;
delete data.webembed; //remove webembed
let d = await this.client.api.webhooks(this.id, this.token).post({
data, data,
files, files,
query: { thread_id: messagePayload.options.threadId, wait: true }, query: { thread_id: messagePayload.options.threadId, wait: true },
auth: false, 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; return this.client.channels?.cache.get(d.channel_id)?.messages._add(d, false) ?? d;
} }