feat(GuildMember): Support edit guild Avatar, Banner, Bio

This commit is contained in:
March 7th
2022-08-04 19:26:16 +07:00
parent 710cb59e48
commit 54e1dbb6b0
6 changed files with 85 additions and 12 deletions

View File

@@ -347,6 +347,51 @@ class GuildMember extends Base {
return this.edit({ nick }, reason);
}
/**
* Sets the guild avatar of the logged in client.
* @param {?(BufferResolvable|Base64Resolvable)} avatar The new avatar
* @returns {Promise<GuildMember>}
*/
setAvatar(avatar) {
if (this.user.id !== this.client.user.id) {
throw new Error('ONLY_ME');
}
if (this.client.user.nitroType !== 'NITRO_BOOST') {
throw new Error('NITRO_BOOST_REQUIRED', 'avatar');
}
return this.edit({ avatar });
}
/**
* Sets the guild banner of the logged in client.
* @param {?(BufferResolvable|Base64Resolvable)} banner The new banner
* @returns {Promise<GuildMember>}
*/
setBanner(banner) {
if (this.user.id !== this.client.user.id) {
throw new Error('ONLY_ME');
}
if (this.client.user.nitroType !== 'NITRO_BOOST') {
throw new Error('NITRO_BOOST_REQUIRED', 'banner');
}
return this.edit({ banner });
}
/**
* Set Guild About me
* @param {string | null} bio Bio to set
* @returns {Promise<GuildMember>}
*/
setAboutMe(bio = null) {
if (this.user.id !== this.client.user.id) {
throw new Error('ONLY_ME');
}
if (this.client.user.nitroType !== 'NITRO_BOOST') {
throw new Error('NITRO_BOOST_REQUIRED', 'bio');
}
return this.edit({ bio });
}
/**
* Creates a DM channel between the client and this member.
* @param {boolean} [force=false] Whether to skip the cache check and request the API