chore: release v2.8.8

- User.themeColors
- Update ClientBuild
This commit is contained in:
March 7th
2022-10-26 19:38:09 +07:00
parent f8246be0aa
commit 0c3d922096
7 changed files with 89 additions and 8 deletions

View File

@@ -5,6 +5,7 @@ const Invite = require('./Invite');
const { Message } = require('./Message');
const User = require('./User');
const { Util } = require('..');
const { Error: Error_ } = require('../errors');
const { Opcodes, NitroType, HypeSquadType } = require('../util/Constants');
const DataResolver = require('../util/DataResolver');
const PurchasedFlags = require('../util/PurchasedFlags');
@@ -487,6 +488,31 @@ class ClientUser extends User {
}
return collection;
}
/**
* Change Theme color
* @param {ColorResolvable} primary The primary color of the user's profile
* @param {ColorResolvable} accent The accent color of the user's profile
* @returns {Promise<ClientUser>}
*/
async setThemeColors(primary, accent) {
if (!primary || !accent) throw new Error('PRIMARY_COLOR or ACCENT_COLOR are required.');
// Check nitro
if (this.nitroType !== 'NITRO_BOOST') {
throw new Error_('NITRO_BOOST_REQUIRED', 'themeColors');
}
primary = Util.resolveColor(primary) || this.themeColors[0];
accent = Util.resolveColor(accent) || this.themeColors[1];
const data_ = await this.client.api.users['@me'].profile.patch({
data: {
theme_colors: [primary, accent],
},
});
this._ProfilePatch({
user_profile: data_,
});
return this;
}
}
module.exports = ClientUser;

View File

@@ -122,6 +122,24 @@ class GuildMember extends Base {
*/
this.bio = data.bio;
}
if ('theme_colors' in data) {
/**
* The member's theme colors (Profile theme) [Primary, Accent]
* <info>The user must be force fetched for this property to be present or be updated</info>
* @type {?Array<number>}
*/
this.themeColors = data.theme_colors;
}
}
/**
* The hexadecimal version of the user theme color, with a leading hash [Primary, Accent]
* <info>The user must be force fetched for this property to be present or be updated</info>
* @type {?Array<string>}
* @readonly
*/
get hexThemeColor() {
return this.themeColors?.map(c => `#${c.toString(16).padStart(6, '0')}`) || null;
}
_clone() {
@@ -540,6 +558,14 @@ class GuildMember extends Base {
);
}
/**
* Get profile guildMember
* @returns {Promise<User>}
*/
getProfile() {
return this.user.getProfile(this.guild.id);
}
/**
* When concatenated with a string, this automatically returns the user's mention instead of the GuildMember object.
* @returns {string}

View File

@@ -233,10 +233,6 @@ class User extends Base {
this.premiumGuildSince = date.getTime();
}
if ('bio' in data.user_profile || 'bio' in data.user) {
this.bio = data.user_profile.bio || data.user.bio;
}
if ('premium_type' in data) {
const nitro = NitroType[data.premium_type ?? 0];
/**
@@ -246,6 +242,16 @@ class User extends Base {
this.nitroType = nitro ?? `UNKNOWN_TYPE_${data.premium_type}`;
}
if ('user_profile' in data) {
this.bio = data.user_profile.bio;
/**
* The user's theme colors (Profile theme) [Primary, Accent]
* <info>The user must be force fetched for this property to be present or be updated</info>
* @type {?Array<number>}
*/
this.themeColors = data.user_profile.theme_colors;
}
if ('guild_member_profile' in data && 'guild_member' in data) {
const guild = this.client.guilds.cache.get(data.guild_member_profile.guild_id);
const member = guild?.members._add(data.guild_member);
@@ -442,6 +448,16 @@ class User extends Base {
});
}
/**
* The hexadecimal version of the user theme color, with a leading hash [Primary, Accent]
* <info>The user must be force fetched for this property to be present or be updated</info>
* @type {?Array<string>}
* @readonly
*/
get hexThemeColor() {
return this.themeColors?.map(c => `#${c.toString(16).padStart(6, '0')}`) || null;
}
/**
* The Discord "tag" (e.g. `hydrabolt#0001`) for this user
* @type {?string}