fix: 🐛 webhook resolveData #626

💀
This commit is contained in:
Elysia
2023-04-20 16:58:32 +07:00
parent 3cc4c5135e
commit f0f22f8cab
2 changed files with 11 additions and 5 deletions

View File

@@ -188,9 +188,9 @@ class Webhook {
let messagePayload;
if (options instanceof MessagePayload) {
messagePayload = options.resolveData();
messagePayload = await options.resolveData();
} else {
messagePayload = MessagePayload.create(this, options).resolveData();
messagePayload = await MessagePayload.create(this, options).resolveData();
}
const { data, files } = await messagePayload.resolveFiles();
@@ -199,6 +199,7 @@ class Webhook {
files,
query: { thread_id: messagePayload.options.threadId, wait: true },
auth: false,
webhook: true,
});
return this.client.channels?.cache.get(d.channel_id)?.messages._add(d, false) ?? d;
}
@@ -228,6 +229,7 @@ class Webhook {
query: { wait: true },
auth: false,
data: body,
webhook: true,
});
return data.toString() === 'ok';
}
@@ -256,6 +258,7 @@ class Webhook {
data: { name, avatar, channel_id: channel },
reason,
auth: !this.token || Boolean(channel),
webhook: true,
});
this.name = data.name;
@@ -304,6 +307,7 @@ class Webhook {
thread_id: cacheOrOptions.threadId,
},
auth: false,
webhook: true,
});
return this.client.channels?.cache.get(data.channel_id)?.messages._add(data, cacheOrOptions.cache) ?? data;
}
@@ -335,6 +339,7 @@ class Webhook {
thread_id: messagePayload.options.threadId,
},
auth: false,
webhook: true,
});
const messageManager = this.client.channels?.cache.get(d.channel_id)?.messages;
@@ -354,7 +359,7 @@ class Webhook {
* @returns {Promise<void>}
*/
async delete(reason) {
await this.client.api.webhooks(this.id, this.token).delete({ reason, auth: !this.token });
await this.client.api.webhooks(this.id, this.token).delete({ reason, auth: !this.token, webhook: true });
}
/**
@@ -374,6 +379,7 @@ class Webhook {
thread_id: threadId,
},
auth: false,
webhook: true,
});
}