refactor(*): use async functions (#6210)

This commit is contained in:
Sugden
2021-08-02 00:47:43 +01:00
committed by GitHub
parent 626ff85ae7
commit e2e4f6518b
29 changed files with 298 additions and 399 deletions

View File

@@ -166,15 +166,13 @@ class Webhook {
}
const { data, files } = await messagePayload.resolveFiles();
return this.client.api
.webhooks(this.id, this.token)
.post({
data,
files,
query: { thread_id: messagePayload.options.threadId, wait: true },
auth: false,
})
.then(d => this.client.channels?.cache.get(d.channel_id)?.messages._add(d, false) ?? d);
const d = await this.client.api.webhooks(this.id, this.token).post({
data,
files,
query: { thread_id: messagePayload.options.threadId, wait: true },
auth: false,
});
return this.client.channels?.cache.get(d.channel_id)?.messages._add(d, false) ?? d;
}
/**
@@ -195,17 +193,15 @@ class Webhook {
* }).catch(console.error);
* @see {@link https://api.slack.com/messaging/webhooks}
*/
sendSlackMessage(body) {
async sendSlackMessage(body) {
if (!this.token) throw new Error('WEBHOOK_TOKEN_UNAVAILABLE');
return this.client.api
.webhooks(this.id, this.token)
.slack.post({
query: { wait: true },
auth: false,
data: body,
})
.then(data => data.toString() === 'ok');
const data = await this.client.api.webhooks(this.id, this.token).slack.post({
query: { wait: true },
auth: false,
data: body,
});
return data.toString() === 'ok';
}
/**