Updated to docs format v3, adds support for interfaces

This commit is contained in:
Amish Shah
2016-08-18 13:07:42 +01:00
parent 4d4258b4e2
commit 18299970bd
6 changed files with 59 additions and 13 deletions

View File

@@ -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);
}
};