mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 02:23:31 +01:00
add webhook#sendSlackMessage (#788)
This commit is contained in:
committed by
Schuyler Cebulskie
parent
9230b8866b
commit
e48d7d52f1
File diff suppressed because one or more lines are too long
@@ -613,6 +613,19 @@ class RESTMethods {
|
|||||||
}).catch(reject);
|
}).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;
|
module.exports = RESTMethods;
|
||||||
|
|||||||
@@ -75,12 +75,12 @@ class Webhook {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a message with this webhook
|
* Send a message with this webhook
|
||||||
* @param {StringResolvable} content The content to send
|
* @param {StringResolvable} content The content to send.
|
||||||
* @param {MessageOptions} [options={}] The options to provide
|
* @param {MessageOptions} [options={}] The options to provide.
|
||||||
* @returns {Promise<Message|Message[]>}
|
* @returns {Promise<Message|Message[]>}
|
||||||
* @example
|
* @example
|
||||||
* // send a message
|
* // send a message
|
||||||
* webook.sendMessage('hello!')
|
* webhook.sendMessage('hello!')
|
||||||
* .then(message => console.log(`Sent message: ${message.content}`))
|
* .then(message => console.log(`Sent message: ${message.content}`))
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
@@ -88,6 +88,27 @@ class Webhook {
|
|||||||
return this.client.rest.methods.sendWebhookMessage(this, content, options);
|
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
|
* Send a text-to-speech message with this webhook
|
||||||
* @param {StringResolvable} content The content to send
|
* @param {StringResolvable} content The content to send
|
||||||
|
|||||||
Reference in New Issue
Block a user