Add client.getMessage() (#428)

* Add client.getMessage

* Add shortcuts

* build it..

* Add missing ~ in note docs

* ............
This commit is contained in:
Manuel Kraus
2016-06-16 00:31:02 +02:00
committed by abal
parent 0f4566dd23
commit 0e4612d7ab
11 changed files with 212 additions and 67 deletions

View File

@@ -515,6 +515,35 @@ var Client = (function (_EventEmitter) {
return this.internal.getChannelLogs(where, limit, options).then(dataCallback(callback), errorCallback(callback));
};
/**
* Gets a single message of a server
* @param {ChannelResolvable} channel to get the message from
* @param {function(err: Error, msg: Message} [callback] callback to the method
* @returns {Promise<Message, Error>} Resolves with a message if the request was successful, otherwise rejects with an error.
* @example
* // get message object off a snowflake and log its content - callback
* client.getMessage(channel, '192696158886428672', function(err, msg) {
* if(!err) {
* console.log(msg.content);
* } else {
* console.log("couldn't get the message");
* }
* }
* @example
* //get message object off a snowflake and log its content - promise
* client.getMessage(channel, '192696158886428672')
* .then(msg => {
* console.log(msg.content);
* })
* .catch(err => console.log("couldn't get the message"));
*/
Client.prototype.getMessage = function getMessage(channel, messageID) {
var callback = arguments.length <= 2 || arguments[2] === undefined ? function () /*err, msg*/{} : arguments[2];
return this.internal.getMessage(channel, messageID).then(dataCallback(callback), errorCallback(callback));
};
/**
* Gets the banned users of a server (if the client has permission to)
* @param {ServerResolvable} server server to get banned users of