mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
Updated to docs format v3, adds support for interfaces
This commit is contained in:
@@ -1,12 +1,43 @@
|
||||
function sendMessage(content, options = {}) {
|
||||
return this.client.rest.methods.sendMessage(this, content, options.tts);
|
||||
/**
|
||||
* Interface for classes that have text-channel-like features
|
||||
* @interface
|
||||
*/
|
||||
class TextBasedChannel {
|
||||
/**
|
||||
* Send a message to this channel
|
||||
* @param {String} content the content to send
|
||||
* @param {MessageOptions} [options={}] the options to provide
|
||||
* @returns {Promise<Message>}
|
||||
* @example
|
||||
* // send a message
|
||||
* channel.sendMessage('hello!')
|
||||
* .then(message => console.log(`Sent message: ${message.content}`))
|
||||
* .catch(console.log);
|
||||
*/
|
||||
sendMessage(content, options = {}) {
|
||||
return this.client.rest.methods.sendMessage(this, content, options.tts);
|
||||
}
|
||||
/**
|
||||
* Send a text-to-speech message to this channel
|
||||
* @param {String} content the content to send
|
||||
* @returns {Promise<Message>}
|
||||
* @example
|
||||
* // send a TTS message
|
||||
* channel.sendTTSMessage('hello!')
|
||||
* .then(message => console.log(`Sent tts message: ${message.content}`))
|
||||
* .catch(console.log);
|
||||
*/
|
||||
sendTTSMessage(content) {
|
||||
return this.client.rest.methods.sendMessage(this, content, true);
|
||||
}
|
||||
}
|
||||
|
||||
function sendTTSMessage(content) {
|
||||
return this.client.rest.methods.sendMessage(this, content, true);
|
||||
function applyProp(structure, prop) {
|
||||
structure.prototype[prop] = TextBasedChannel.prototype[prop];
|
||||
}
|
||||
|
||||
exports.applyToClass = structure => {
|
||||
structure.prototype.sendMessage = sendMessage;
|
||||
structure.prototype.sendTTSMessage = sendTTSMessage;
|
||||
for (const prop of ['sendMessage', 'sendTTSMessage']) {
|
||||
applyProp(structure, prop);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user