* Add reasons

* How could I forget

* Hopefully fix conflicts
This commit is contained in:
Pg Biel
2017-07-26 22:14:04 -03:00
committed by Crawl
parent 27196c2f9f
commit eef87e5d97
6 changed files with 78 additions and 50 deletions

View File

@@ -604,15 +604,17 @@ class Guild {
/**
* Edit the level of the explicit content filter.
* @param {number} explicitContentFilter The new level of the explicit content filter
* @param {string} [reason] Reason for changing the level of the guild's explicit content filter
* @returns {Promise<Guild>}
*/
setExplicitContentFilter(explicitContentFilter) {
return this.edit({ explicitContentFilter });
setExplicitContentFilter(explicitContentFilter, reason) {
return this.edit({ explicitContentFilter }, reason);
}
/**
* Edit the name of the guild.
* @param {string} name The new name of the guild
* @param {string} [reason] Reason for changing the guild's name
* @returns {Promise<Guild>}
* @example
* // Edit the guild name
@@ -620,13 +622,14 @@ class Guild {
* .then(updated => console.log(`Updated guild name to ${guild.name}`))
* .catch(console.error);
*/
setName(name) {
return this.edit({ name });
setName(name, reason) {
return this.edit({ name }, reason);
}
/**
* Edit the region of the guild.
* @param {string} region The new region of the guild
* @param {string} [reason] Reason for changing the guild's region
* @returns {Promise<Guild>}
* @example
* // Edit the guild region
@@ -634,13 +637,14 @@ class Guild {
* .then(updated => console.log(`Updated guild region to ${guild.region}`))
* .catch(console.error);
*/
setRegion(region) {
return this.edit({ region });
setRegion(region, reason) {
return this.edit({ region }, reason);
}
/**
* Edit the verification level of the guild.
* @param {number} verificationLevel The new verification level of the guild
* @param {string} [reason] Reason for changing the guild's verification level
* @returns {Promise<Guild>}
* @example
* // Edit the guild verification level
@@ -648,13 +652,14 @@ class Guild {
* .then(updated => console.log(`Updated guild verification level to ${guild.verificationLevel}`))
* .catch(console.error);
*/
setVerificationLevel(verificationLevel) {
return this.edit({ verificationLevel });
setVerificationLevel(verificationLevel, reason) {
return this.edit({ verificationLevel }, reason);
}
/**
* Edit the AFK channel of the guild.
* @param {ChannelResolvable} afkChannel The new AFK channel
* @param {string} [reason] Reason for changing the guild's AFK channel
* @returns {Promise<Guild>}
* @example
* // Edit the guild AFK channel
@@ -662,13 +667,14 @@ class Guild {
* .then(updated => console.log(`Updated guild AFK channel to ${guild.afkChannel}`))
* .catch(console.error);
*/
setAFKChannel(afkChannel) {
return this.edit({ afkChannel });
setAFKChannel(afkChannel, reason) {
return this.edit({ afkChannel }, reason);
}
/**
* Edit the AFK timeout of the guild.
* @param {number} afkTimeout The time in seconds that a user must be idle to be considered AFK
* @param {string} [reason] Reason for changing the guild's AFK timeout
* @returns {Promise<Guild>}
* @example
* // Edit the guild AFK channel
@@ -676,13 +682,14 @@ class Guild {
* .then(updated => console.log(`Updated guild AFK timeout to ${guild.afkTimeout}`))
* .catch(console.error);
*/
setAFKTimeout(afkTimeout) {
return this.edit({ afkTimeout });
setAFKTimeout(afkTimeout, reason) {
return this.edit({ afkTimeout }, reason);
}
/**
* Set a new guild icon.
* @param {Base64Resolvable} icon The new icon of the guild
* @param {string} [reason] Reason for changing the guild's icon
* @returns {Promise<Guild>}
* @example
* // Edit the guild icon
@@ -690,13 +697,14 @@ class Guild {
* .then(updated => console.log('Updated the guild icon'))
* .catch(console.error);
*/
setIcon(icon) {
return this.edit({ icon });
setIcon(icon, reason) {
return this.edit({ icon }, reason);
}
/**
* Sets a new owner of the guild.
* @param {GuildMemberResolvable} owner The new owner of the guild
* @param {string} [reason] Reason for setting the new owner
* @returns {Promise<Guild>}
* @example
* // Edit the guild owner
@@ -704,13 +712,14 @@ class Guild {
* .then(updated => console.log(`Updated the guild owner to ${updated.owner.username}`))
* .catch(console.error);
*/
setOwner(owner) {
return this.edit({ owner });
setOwner(owner, reason) {
return this.edit({ owner }, reason);
}
/**
* Set a new guild splash screen.
* @param {Base64Resolvable} splash The new splash screen of the guild
* @param {string} [reason] Reason for changing the guild's splash screen
* @returns {Promise<Guild>}
* @example
* // Edit the guild splash
@@ -718,8 +727,8 @@ class Guild {
* .then(updated => console.log('Updated the guild splash'))
* .catch(console.error);
*/
setSplash(splash) {
return this.edit({ splash });
setSplash(splash, reason) {
return this.edit({ splash }, reason);
}
/**
@@ -948,7 +957,9 @@ class Guild {
* Creates a new custom emoji in the guild.
* @param {BufferResolvable|Base64Resolvable} attachment The image for the emoji
* @param {string} name The name for the emoji
* @param {Collection<Snowflake, Role>|Role[]} [roles] Roles to limit the emoji to
* @param {Object} [options] Options
* @param {Collection<Snowflake, Role>|Role[]} [options.roles] Roles to limit the emoji to
* @param {string} [options.reason] Reason for creating the emoji
* @returns {Promise<Emoji>} The created emoji
* @example
* // Create a new emoji from a url
@@ -961,11 +972,11 @@ class Guild {
* .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`))
* .catch(console.error);
*/
createEmoji(attachment, name, roles) {
createEmoji(attachment, name, { roles, reason } = {}) {
if (typeof attachment === 'string' && attachment.startsWith('data:')) {
const data = { image: attachment, name };
if (roles) data.roles = roles.map(r => r.id ? r.id : r);
return this.client.api.guilds(this.id).emojis.post({ data })
return this.client.api.guilds(this.id).emojis.post({ data, reason })
.then(emoji => this.client.actions.GuildEmojiCreate.handle(this, emoji).emoji);
} else {
return this.client.resolver.resolveBuffer(attachment)
@@ -979,11 +990,12 @@ class Guild {
/**
* Delete an emoji.
* @param {Emoji|string} emoji The emoji to delete
* @param {string} [reason] Reason for deleting the emoji
* @returns {Promise}
*/
deleteEmoji(emoji) {
deleteEmoji(emoji, reason) {
if (!(emoji instanceof Emoji)) emoji = this.emojis.get(emoji);
return this.client.api.guilds(this.id).emojis(emoji.id).delete()
return this.client.api.guilds(this.id).emojis(emoji.id).delete({ reason })
.then(() => this.client.actions.GuildEmojiDelete.handle(emoji).data);
}