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

@ -63,9 +63,9 @@ class GuildForumThreadManager extends ThreadManager {
let messagePayload; let messagePayload;
if (message instanceof MessagePayload) { if (message instanceof MessagePayload) {
messagePayload = message.resolveData(); messagePayload = await message.resolveData();
} else { } else {
messagePayload = MessagePayload.create(this, message).resolveData(); messagePayload = await MessagePayload.create(this, message).resolveData();
} }
let { data: body, files } = await messagePayload.resolveFiles(); let { data: body, files } = await messagePayload.resolveFiles();

View File

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