Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ export const GuildFeatures = [
"DISCOVERABLE",
"ENABLED_DISCOVERABLE_BEFORE",
"ENABLED_MODERATION_EXPERIENCE_FOR_NON_COMMUNITY",
"ENHANCED_ROLE_COLORS",
"EXPOSED_TO_ACTIVITIES_WTP_EXPERIMENT",
"FEATURABLE",
"GUESTS_ENABLED",
Expand Down
14 changes: 12 additions & 2 deletions lib/routes/Guilds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,12 @@ export default class Guilds {
method: "POST",
path: Routes.GUILD_ROLES(guildID),
json: {
color: options?.color,
color: options?.color,
colors: {
primary_color: options?.colors?.primaryColor,
secondary_color: options?.colors?.secondaryColor,
tertiary_color: options?.colors?.tertiaryColor
},
hoist: options?.hoist,
icon,
mentionable: options?.mentionable,
Expand Down Expand Up @@ -955,7 +960,12 @@ export default class Guilds {
method: "PATCH",
path: Routes.GUILD_ROLE(guildID, roleID),
json: {
color: options.color,
color: options.color,
colors: {
primary_color: options.colors?.primaryColor,
secondary_color: options.colors?.secondaryColor,
tertiary_color: options.colors?.tertiaryColor
},
hoist: options.hoist,
icon,
mentionable: options.mentionable,
Expand Down
22 changes: 20 additions & 2 deletions lib/structures/Role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ import Base from "./Base";
import Permission from "./Permission";
import type Guild from "./Guild";
import type Client from "../Client";
import type { RawRole, RoleTags, EditRoleOptions } from "../types/guilds";
import type { RawRole, RoleTags, EditRoleOptions, RoleColors } from "../types/guilds";
import type { JSONRole } from "../types/json";
import { UncachedError } from "../util/Errors";

/** Represents a role in a guild. */
export default class Role extends Base {
private _cachedGuild?: Guild;
/** The color of this role. */
/**
* The color of this role.
* @deprecated Use {@link Role#colors | Role#colors.primaryColor} instead.
*/
color: number;
/** The colors of this role. */
colors: RoleColors;
/** The {@link Constants~RoleFlags | flags } for this role. */
flags: number;
/** The id of the guild this role is in. */
Expand All @@ -37,6 +42,11 @@ export default class Role extends Base {
constructor(data: RawRole, client: Client, guildID: string) {
super(data.id, client);
this.color = data.color;
this.colors = {
primaryColor: data.colors.primary_color,
secondaryColor: data.colors.secondary_color,
tertiaryColor: data.colors.tertiary_color
};
this.flags = data.flags;
this.guildID = guildID;
this.hoist = !!data.hoist;
Expand All @@ -57,6 +67,13 @@ export default class Role extends Base {
if (data.color !== undefined) {
this.color = data.color;
}
if (data.colors !== undefined) {
this.colors = {
primaryColor: data.colors.primary_color,
secondaryColor: data.colors.secondary_color,
tertiaryColor: data.colors.tertiary_color
};
}
if (data.hoist !== undefined) {
this.hoist = data.hoist;
}
Expand Down Expand Up @@ -132,6 +149,7 @@ export default class Role extends Base {
return {
...super.toJSON(),
color: this.color,
colors: this.colors,
guildID: this.guildID,
hoist: this.hoist,
icon: this.icon,
Expand Down
16 changes: 15 additions & 1 deletion lib/structures/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Clan from "./Clan";
import { EntitlementOwnerTypes, type ImageFormat } from "../Constants";
import * as Routes from "../util/Routes";
import type Client from "../Client";
import type { AvatarDecorationData, RawUser } from "../types/users";
import type { AvatarDecorationData, Collectibles, RawUser } from "../types/users";
import type { JSONUser } from "../types/json";
import type { SearchEntitlementsOptions } from "../types/applications";
import { UncachedError } from "../util/Errors";
Expand All @@ -26,6 +26,8 @@ export default class User extends Base {
bot: boolean;
/** The primary clan this user is in. */
clan: Clan | null;
/** The user's collectibles. */
collectibles: Collectibles | null;
/** The 4 digits after this user's username, if they have not been migrated. If migrated, this will be a single "0". */
discriminator: string;
/** The user's display name, if set. */
Expand All @@ -42,6 +44,7 @@ export default class User extends Base {
this.avatarDecorationData = null;
this.bot = !!data.bot;
this.clan = null;
this.collectibles = null;
this.discriminator = data.discriminator;
this.globalName = data.global_name;
this.publicFlags = 0;
Expand All @@ -66,6 +69,16 @@ export default class User extends Base {
if (data.banner !== undefined) {
this.banner = data.banner;
}
if (data.collectibles !== undefined) {
this.collectibles = data.collectibles ? {
nameplate: data.collectibles.nameplate ? {
asset: data.collectibles.nameplate.asset,
label: data.collectibles.nameplate.label,
palette: data.collectibles.nameplate.palette,
skuID: data.collectibles.nameplate.sku_id
} : undefined
} : null;
}
if (data.discriminator !== undefined) {
this.discriminator = data.discriminator;
}
Expand Down Expand Up @@ -185,6 +198,7 @@ export default class User extends Base {
avatarDecorationData: this.avatarDecorationData,
banner: this.banner,
bot: this.bot,
collectibles: this.collectibles,
discriminator: this.discriminator,
globalName: this.globalName,
publicFlags: this.publicFlags,
Expand Down
22 changes: 21 additions & 1 deletion lib/types/guilds.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ export interface RawGuild {
export interface RawInviteGuild extends Pick<RawGuild, "id" | "name" | "splash" | "banner" | "description" | "icon" | "features" | "verification_level" | "vanity_url_code" | "premium_subscription_count" | "nsfw_level"> {}

export interface RawRole {
/** @deprecated */
color: number;
colors: RawRoleColors;
flags: number;
hoist: boolean;
icon?: string | null;
Expand Down Expand Up @@ -137,6 +139,19 @@ export interface RoleTags {
premiumSubscriber: boolean;
subscriptionListingID?: string;
}

export interface RawRoleColors {
primary_color: number;
secondary_color: number | null;
tertiary_color: number | null;
}

export interface RoleColors {
primaryColor: number;
secondaryColor: number | null;
tertiaryColor: number | null;
}

export interface RawGuildEmoji extends Required<Omit<Emoji, "user" | "id">> { id: string; user?: RawUser; }
export interface GuildEmoji extends Omit<RawGuildEmoji, "user" | "id" | "require_colons"> { id: string; requireColons?: boolean; user?: User; }
export interface RawWelcomeScreen {
Expand Down Expand Up @@ -411,8 +426,13 @@ export interface CreateAnnouncementChannelOptions extends Omit<CreateChannelOpti
export interface CreateStageChannelOptions extends Omit<CreateChannelOptions<ChannelTypes.GUILD_STAGE_VOICE>, "defaultAutoArchiveDuration" | "nsfw" | "rtcRegion" | "topic" | "userLimit" | "videoQualityMode"> {}

export interface CreateRoleOptions {
/** The color of the role. */
/**
* The color of the role.
* @deprecated Use {@link CreateRoleOptions#colors | CreateRoleOptions#colors.primaryColor} instead.
*/
color?: number;
/** The colors of the role. */
colors?: Partial<RoleColors>;
/** If the role should be hoisted. */
hoist?: boolean;
/** The icon for the role (buffer, or full data url). Requires the `ROLE_ICONS` feature. */
Expand Down
8 changes: 6 additions & 2 deletions lib/types/json.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import type {
WelcomeScreen,
Sticker,
Presence,
IncidentActions
IncidentActions,
RoleColors
} from "./guilds";
import type {
ChannelMention,
Expand All @@ -46,7 +47,7 @@ import type {
MessageComponent
} from "./channels";
import type { ScheduledEventEntityMetadata } from "./scheduled-events";
import type { AvatarDecorationData } from "./users";
import type { AvatarDecorationData, Collectibles } from "./users";
import type {
ApplicationCommandTypes,
AutoModerationEventTypes,
Expand Down Expand Up @@ -634,7 +635,9 @@ export interface JSONPublicThreadChannel extends JSONThreadChannel {
type: ChannelTypes.PUBLIC_THREAD;
}
export interface JSONRole extends JSONBase {
/** @deprecated */
color: number;
colors: RoleColors;
guildID: string;
hoist: boolean;
icon: string | null;
Expand Down Expand Up @@ -755,6 +758,7 @@ export interface JSONUser extends JSONBase {
avatarDecorationData: AvatarDecorationData | null;
banner?: string | null;
bot: boolean;
collectibles: Collectibles | null;
discriminator: string;
globalName: string | null;
publicFlags: number;
Expand Down
27 changes: 26 additions & 1 deletion lib/types/users.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface RESTUser {
banner?: string | null;
bot?: boolean;
clan?: RawClan | null;
collectibles?: RawCollectibles | null;
discriminator: string;
email?: string | null;
flags?: number;
Expand All @@ -23,7 +24,7 @@ export interface RESTUser {
username: string;
verified?: boolean;
}
export interface RawUser extends Pick<RESTUser, "id" | "username" | "discriminator" | "avatar" | "avatar_decoration_data" | "bot" | "system" | "banner" | "accent_color" | "clan">, Required<Pick<RESTUser, "public_flags" | "global_name">> {}
export interface RawUser extends Pick<RESTUser, "id" | "username" | "discriminator" | "avatar" | "avatar_decoration_data" | "bot" | "system" | "banner" | "accent_color" | "clan" | "collectibles">, Required<Pick<RESTUser, "public_flags" | "global_name">> {}
export interface RawUserWithMember extends RawUser, Pick<RESTUser, "member"> {}
export interface RawOAuthUser extends Pick<RESTUser, "id" | "username" | "discriminator" | "avatar" | "avatar_decoration_data" | "bot" | "system" | "global_name">, Required<Pick<RESTUser, "banner" | "accent_color" | "locale" | "mfa_enabled" | "email" | "verified" | "flags" | "public_flags" | "clan">> {}
export interface RawExtendedUser extends Pick<RawOAuthUser, "avatar" | "avatar_decoration_data" | "bot" | "discriminator" | "email" | "flags" | "id" | "mfa_enabled" | "username" | "verified" | "global_name" | "clan"> {}
Expand Down Expand Up @@ -60,3 +61,27 @@ export interface AvatarDecorationData {
asset: string;
skuID: string;
}

export interface RawCollectibles {
nameplate?: RawNameplate;
}

export interface Collectibles {
nameplate?: Nameplate;
}

export interface RawNameplate {
asset: string;
label: string;
palette: NameplatePalette;
sku_id: string;
}

export interface Nameplate {
asset: string;
label: string;
palette: NameplatePalette;
skuID: string;
}

export type NameplatePalette = "crimson" | "berry" | "sky" | "teal" | "forest" | "bubble_gum" | "violet" | "cobalt" | "clover" | "lemon" | "white";