add webhook#sendSlackMessage (#788)

This commit is contained in:
Gus Caplan
2016-10-10 00:56:18 -05:00
committed by Schuyler Cebulskie
parent 9230b8866b
commit e48d7d52f1
3 changed files with 38 additions and 4 deletions

View File

@@ -75,12 +75,12 @@ class Webhook {
/**
* Send a message with this webhook
* @param {StringResolvable} content The content to send
* @param {MessageOptions} [options={}] The options to provide
* @param {StringResolvable} content The content to send.
* @param {MessageOptions} [options={}] The options to provide.
* @returns {Promise<Message|Message[]>}
* @example
* // send a message
* webook.sendMessage('hello!')
* webhook.sendMessage('hello!')
* .then(message => console.log(`Sent message: ${message.content}`))
* .catch(console.error);
*/
@@ -88,6 +88,27 @@ class Webhook {
return this.client.rest.methods.sendWebhookMessage(this, content, options);
}
/**
* Send a raw slack message with this webhook
* @param {Object} body The raw body to send.
* @returns {Promise}
* @example
* // send a slack message
* webhook.sendSlackMessage({
* 'username': 'Wumpus',
* 'attachments': [{
* 'pretext': 'this looks pretty cool',
* 'color': '#F0F',
* 'footer_icon': 'http://snek.s3.amazonaws.com/topSnek.png',
* 'footer': 'Powered by sneks',
* 'ts': new Date().getTime() / 1000
* }]
* }).catch(console.log);
*/
sendSlackMessage(body) {
return this.client.rest.methods.sendSlackWebhookMessage(this, body);
}
/**
* Send a text-to-speech message with this webhook
* @param {StringResolvable} content The content to send