Skip to content

Commit

Permalink
Add withCounts support to getInvite(), lint code
Browse files Browse the repository at this point in the history
  • Loading branch information
abalabahaha committed May 13, 2017
1 parent 375e431 commit 85ff415
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
13 changes: 8 additions & 5 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<Invite>}
*/
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));
}

/**
Expand Down Expand Up @@ -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
});
Expand All @@ -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();
}
Expand Down Expand Up @@ -1307,7 +1310,7 @@ class Client extends EventEmitter {
* @arg {String} [reason] The reason to be displayed in audit logs
* @returns {Promise<Guild>}
*/
editGuild(guildID, options) {
editGuild(guildID, options, reason) {
return this.requestHandler.request("PATCH", Endpoints.GUILD(guildID), true, {
name: options.name,
region: options.region,
Expand Down
2 changes: 1 addition & 1 deletion lib/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 9 additions & 1 deletion lib/structures/Invite.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ 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
* @prop {Number?} maxAge How long the invite lasts in seconds
* @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) {
Expand All @@ -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);
Expand All @@ -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() {
Expand Down

0 comments on commit 85ff415

Please sign in to comment.