mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
add webhook#sendSlackMessage (#788)
This commit is contained in:
committed by
Schuyler Cebulskie
parent
9230b8866b
commit
e48d7d52f1
@@ -613,6 +613,19 @@ class RESTMethods {
|
||||
}).catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
sendSlackWebhookMessage(webhook, body) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.rest.makeRequest(
|
||||
'post',
|
||||
`${Constants.Endpoints.webhook(webhook.id, webhook.token)}/slack?wait=true`,
|
||||
false,
|
||||
body
|
||||
).then(data => {
|
||||
resolve(data);
|
||||
}).catch(reject);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = RESTMethods;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user