backport: Guild#{fetchEmbed,setEmbed} (#2778)

*  backport: Guild Embeds

* fix: Added missing return

* docs: Updated typings
This commit is contained in:
Kyra
2018-08-28 17:33:51 +02:00
committed by Isabella
parent 3345c77ce2
commit 091b4fc214
3 changed files with 52 additions and 0 deletions

View File

@@ -530,6 +530,26 @@ class Guild {
return this.client.rest.methods.fetchVoiceRegions(this.id);
}
/**
* The Guild Embed object
* @typedef {Object} GuildEmbedData
* @property {boolean} enabled Whether the embed is enabled
* @property {?ChannelResolvable} channel The embed channel
*/
/**
* Fetches the guild embed.
* @returns {Promise<GuildEmbedData>}
* @example
* // Fetches the guild embed
* guild.fetchEmbed()
* .then(embed => console.log(`The embed is ${embed.enabled ? 'enabled' : 'disabled'}`))
* .catch(console.error);
*/
fetchEmbed() {
return this.client.rest.methods.fetchEmbed(this.id);
}
/**
* Fetch audit logs for this guild.
* @param {Object} [options={}] Options for fetching audit logs
@@ -1025,6 +1045,17 @@ class Guild {
return this.client.rest.methods.updateChannelPositions(this.id, channelPositions);
}
/**
* Edits the guild's embed.
* @param {GuildEmbedData} embed The embed for the guild
* @param {string} [reason] Reason for changing the guild's embed
* @returns {Promise<Guild>}
*/
setEmbed(embed, reason) {
return this.client.rest.methods.updateEmbed(this.id, embed, reason)
.then(() => this);
}
/**
* Creates a new role in the guild with given information.
* @param {RoleData} [data] The data to update the role with