From 85ff415d3f251272b2737dc26c44e166707fd400 Mon Sep 17 00:00:00 2001 From: abalabahaha Date: Sat, 13 May 2017 14:54:10 -0700 Subject: [PATCH] Add withCounts support to getInvite(), lint code --- lib/Client.js | 13 ++++++++----- lib/Constants.js | 2 +- lib/structures/Invite.js | 10 +++++++++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/Client.js b/lib/Client.js index 94b801970..a880d5749 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -784,10 +784,13 @@ class Client extends EventEmitter { /** * Get info on an invite * @arg {String} inviteID The ID of the invite + * @arg {Boolean} [withCounts] Whether to fetch additional invite info or not (approximate member counts, approximate presences, channel counts, etc.) * @returns {Promise} */ - getInvite(inviteID) { - return this.requestHandler.request("GET", Endpoints.INVITE(inviteID), true).then((invite) => new Invite(invite, this)); + getInvite(inviteID, withCounts) { + return this.requestHandler.request("GET", Endpoints.INVITE(inviteID), true, { + with_counts: withCounts + }).then((invite) => new Invite(invite, this)); } /** @@ -1071,7 +1074,7 @@ class Client extends EventEmitter { * @arg {String} [reason] The reason to be displayed in audit logs * @returns {Promise} */ - deleteMessage(channelID, messageID) { + deleteMessage(channelID, messageID, reason) { return this.requestHandler.request("DELETE", Endpoints.CHANNEL_MESSAGE(channelID, messageID), true, { reason }); @@ -1084,7 +1087,7 @@ class Client extends EventEmitter { * @arg {String} [reason] The reason to be displayed in audit logs * @returns {Promise} */ - deleteMessages(channelID, messageIDs) { + deleteMessages(channelID, messageIDs, reason) { if(messageIDs.length === 0) { return Promise.resolve(); } @@ -1307,7 +1310,7 @@ class Client extends EventEmitter { * @arg {String} [reason] The reason to be displayed in audit logs * @returns {Promise} */ - editGuild(guildID, options) { + editGuild(guildID, options, reason) { return this.requestHandler.request("PATCH", Endpoints.GUILD(guildID), true, { name: options.name, region: options.region, diff --git a/lib/Constants.js b/lib/Constants.js index f4898e7ad..05c2fc6a9 100644 --- a/lib/Constants.js +++ b/lib/Constants.js @@ -50,7 +50,7 @@ module.exports.Permissions = { manageChannels: 1 << 4, manageGuild: 1 << 5, addReactions: 1 << 6, - viewAuditLogs: 1 << 7, // Coming soon™ + viewAuditLogs: 1 << 7, readMessages: 1 << 10, sendMessages: 1 << 11, sendTTSMessages: 1 << 12, diff --git a/lib/structures/Invite.js b/lib/structures/Invite.js index 27288c461..ed9b39e3a 100644 --- a/lib/structures/Invite.js +++ b/lib/structures/Invite.js @@ -13,6 +13,8 @@ const Base = require("./Base"); * @prop {String} guild.name The name of the invite's guild * @prop {String?} guild.splash The hash of the invite splash screen * @prop {String?} guild.icon The hash of the guild icon +* @prop {Number?} guild.textChannelCount The number of text channels in the guild +* @prop {Number?} guild.voiceChannelCount The number of voice channels in the guild * @prop {User?} inviter The invite creator * @prop {Number?} uses The number of invite uses * @prop {Number?} maxUses The max number of invite uses @@ -20,6 +22,8 @@ const Base = require("./Base"); * @prop {Boolean?} temporary Whether the invite is temporary or not * @prop {Number?} createdAt Timestamp of invite creation * @prop {Boolean?} revoked Whether the invite was revoked or not +* @prop {Number?} presenceCount The **approximate** presence count for the guild +* @prop {Number?} memberCount The **approximate** member count for the guild */ class Invite extends Base { constructor(data, client) { @@ -31,7 +35,9 @@ class Invite extends Base { splash: data.guild.splash, icon: data.guild.icon, id: data.guild.id, - name: data.guild.name + name: data.guild.name, + textChannelCount: data.guild.text_channel_count !== undefined ? data.guild.text_channel_count : null, + voiceChannelCount: data.guild.voice_channel_count !== undefined ? data.guild.voice_channel_count : null }; if(data.inviter) { this.inviter = client.users.add(data.inviter, client); @@ -42,6 +48,8 @@ class Invite extends Base { this.temporary = data.temporary !== undefined ? data.temporary : null; this._createdAt = data.created_at !== undefined ? data.created_at : null; this.revoked = data.revoked !== undefined ? data.revoked : null; + this.presenceCount = data.approximate_presence_count !== undefined ? data.approximate_presence_count : null; + this.memberCount = data.approximate_member_count !== undefined ? data.approximate_member_count : null; } get createdAt() {