clean up webhooks and fix sending messages with webhooks (#1078)

* clean up webhooks and fix sending messages with webhooks

* whoops

* fix up options

* Update Webhook.js

* Update Webhook.js

* Update Webhook.js
This commit is contained in:
Gus Caplan
2017-01-10 15:52:12 -06:00
committed by Schuyler Cebulskie
parent 47707d245d
commit c37cd3fd91
2 changed files with 87 additions and 72 deletions

View File

@@ -562,7 +562,8 @@ class RESTMethods {
return this.rest.makeRequest('delete', Constants.Endpoints.webhook(webhook.id, webhook.token), false);
}
sendWebhookMessage(webhook, content, { avatarURL, tts, disableEveryone, embeds } = {}, file = null) {
sendWebhookMessage(webhook, content, { avatarURL, tts, disableEveryone, embeds, username } = {}, file = null) {
username = username || webhook.name;
if (typeof content !== 'undefined') content = this.client.resolver.resolveString(content);
if (content) {
if (disableEveryone || (typeof disableEveryone === 'undefined' && this.client.options.disableEveryone)) {
@@ -570,13 +571,12 @@ class RESTMethods {
}
}
return this.rest.makeRequest('post', `${Constants.Endpoints.webhook(webhook.id, webhook.token)}?wait=true`, false, {
username: webhook.name,
username,
avatar_url: avatarURL,
content,
tts,
file,
embeds,
});
}, file);
}
sendSlackWebhookMessage(webhook, body) {