mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
Add client.getMessage() (#428)
* Add client.getMessage * Add shortcuts * build it.. * Add missing ~ in note docs * ............
This commit is contained in:
@@ -788,6 +788,34 @@ export default class InternalClient {
|
||||
});
|
||||
}
|
||||
|
||||
// def getMessage
|
||||
getMessage(_channel, messageID) {
|
||||
return this.resolver.resolveChannel(_channel)
|
||||
.then(channel => {
|
||||
if(!this.user.bot) {
|
||||
return Promise.reject(new Error("Only OAuth bot accounts can use this function"));
|
||||
}
|
||||
|
||||
if(!(channel instanceof TextChannel || channel instanceof PMChannel)) {
|
||||
return Promise.reject(new Error("Provided channel is not a Text or PMChannel"));
|
||||
}
|
||||
|
||||
var msg = channel.messages.get("id", messageID);
|
||||
if(msg) {
|
||||
return Promise.resolve(msg);
|
||||
}
|
||||
|
||||
return this.apiRequest(
|
||||
"get",
|
||||
`${Endpoints.CHANNEL_MESSAGES(channel.id)}/${messageID}`,
|
||||
true
|
||||
)
|
||||
.then(res => channel.messages.add(
|
||||
new Message(res, channel, this.client)
|
||||
));
|
||||
})
|
||||
}
|
||||
|
||||
// def getBans
|
||||
getBans(server) {
|
||||
server = this.resolver.resolveServer(server);
|
||||
|
||||
Reference in New Issue
Block a user