mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 01:53:30 +01:00
Add client.getMessage() (#428)
* Add client.getMessage * Add shortcuts * build it.. * Add missing ~ in note docs * ............
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user