Merge branch 'master' into voice-rewrite

This commit is contained in:
Schuyler Cebulskie
2018-01-18 19:49:23 -05:00
28 changed files with 404 additions and 335 deletions

View File

@@ -15,7 +15,7 @@ const UserStore = require('../stores/UserStore');
const ChannelStore = require('../stores/ChannelStore');
const GuildStore = require('../stores/GuildStore');
const ClientPresenceStore = require('../stores/ClientPresenceStore');
const EmojiStore = require('../stores/EmojiStore');
const GuildEmojiStore = require('../stores/GuildEmojiStore');
const { Events, browser } = require('../util/Constants');
const DataResolver = require('../util/DataResolver');
const { Error, TypeError, RangeError } = require('../errors');
@@ -208,11 +208,11 @@ class Client extends BaseClient {
/**
* All custom emojis that the client has access to, mapped by their IDs
* @type {EmojiStore<Snowflake, Emoji>}
* @type {GuildEmojiStore<Snowflake, GuildEmoji>}
* @readonly
*/
get emojis() {
const emojis = new EmojiStore({ client: this });
const emojis = new GuildEmojiStore({ client: this });
for (const guild of this.guilds.values()) {
if (guild.available) for (const emoji of guild.emojis.values()) emojis.set(emoji.id, emoji);
}
@@ -287,6 +287,11 @@ class Client extends BaseClient {
* Obtains an invite from Discord.
* @param {InviteResolvable} invite Invite code or URL
* @returns {Promise<Invite>}
* @example
* client.fetchInvite('https://discord.gg/bRCvFy9')
* .then(invite => {
* console.log(`Obtained invite with code: ${invite.code}`);
* }).catch(console.error);
*/
fetchInvite(invite) {
const code = DataResolver.resolveInviteCode(invite);
@@ -299,6 +304,11 @@ class Client extends BaseClient {
* @param {Snowflake} id ID of the webhook
* @param {string} [token] Token for the webhook
* @returns {Promise<Webhook>}
* @example
* client.fetchWebhook('id', 'token')
* .then(webhook => {
* console.log(`Obtained webhook with name: ${webhook.name}`);
* }).catch(console.error);
*/
fetchWebhook(id, token) {
return this.api.webhooks(id, token).get().then(data => new Webhook(this, data));
@@ -307,6 +317,11 @@ class Client extends BaseClient {
/**
* Obtains the available voice regions from Discord.
* @returns {Collection<string, VoiceRegion>}
* @example
* client.fetchVoiceRegions()
* .then(regions => {
* console.log(`Available regions are: ${regions.map(region => region.name).join(', ')}`);
* }).catch(console.error);
*/
fetchVoiceRegions() {
return this.api.voice.regions.get().then(res => {
@@ -323,6 +338,10 @@ class Client extends BaseClient {
* will be removed from the caches. The default is based on {@link ClientOptions#messageCacheLifetime}
* @returns {number} Amount of messages that were removed from the caches,
* or -1 if the message cache lifetime is unlimited
* @example
* // Remove all messages older than 1800 seconds from the messages cache
* const amount = client.sweepMessages(1800);
* console.log(`Successfully removed ${amount} messages from the cache.`);
*/
sweepMessages(lifetime = this.options.messageCacheLifetime) {
if (typeof lifetime !== 'number' || isNaN(lifetime)) {
@@ -359,6 +378,11 @@ class Client extends BaseClient {
* Obtains the OAuth Application of the bot from Discord.
* @param {Snowflake} [id='@me'] ID of application to fetch
* @returns {Promise<ClientApplication>}
* @example
* client.fetchApplication('id')
* .then(application => {
* console.log(`Obtained application with name: ${application.name}`);
* }).catch(console.error);
*/
fetchApplication(id = '@me') {
return this.api.oauth2.applications(id).get()
@@ -374,7 +398,7 @@ class Client extends BaseClient {
* client.generateInvite(['SEND_MESSAGES', 'MANAGE_GUILD', 'MENTION_EVERYONE'])
* .then(link => {
* console.log(`Generated bot invite link: ${link}`);
* });
* }).catch(console.error);
*/
generateInvite(permissions) {
if (permissions) {

View File

@@ -12,7 +12,7 @@ class GuildEmojiCreateAction extends Action {
/**
* Emitted whenever a custom emoji is created in a guild.
* @event Client#emojiCreate
* @param {Emoji} emoji The emoji that was created
* @param {GuildEmoji} emoji The emoji that was created
*/
module.exports = GuildEmojiCreateAction;

View File

@@ -10,9 +10,9 @@ class GuildEmojiDeleteAction extends Action {
}
/**
* Emitted whenever a custom guild emoji is deleted.
* Emitted whenever a custom emoji is deleted in a guild.
* @event Client#emojiDelete
* @param {Emoji} emoji The emoji that was deleted
* @param {GuildEmoji} emoji The emoji that was deleted
*/
module.exports = GuildEmojiDeleteAction;

View File

@@ -10,10 +10,10 @@ class GuildEmojiUpdateAction extends Action {
}
/**
* Emitted whenever a custom guild emoji is updated.
* Emitted whenever a custom emoji is updated in a guild.
* @event Client#emojiUpdate
* @param {Emoji} oldEmoji The old emoji
* @param {Emoji} newEmoji The new emoji
* @param {GuildEmoji} oldEmoji The old emoji
* @param {GuildEmoji} newEmoji The new emoji
*/
module.exports = GuildEmojiUpdateAction;

View File

@@ -33,7 +33,7 @@ class MessageReactionAdd extends Action {
* Emitted whenever a reaction is added to a message.
* @event Client#messageReactionAdd
* @param {MessageReaction} messageReaction The reaction object
* @param {User} user The user that applied the emoji or reaction emoji
* @param {User} user The user that applied the guild or reaction emoji
*/
module.exports = MessageReactionAdd;