feat: add shared client theme support (#11454)

* feat: add shared client theme support

* Apply suggestion from @Qjuh

Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com>

* chore: tests

* chore: format

* chore: apply suggestions from code review

---------

Co-authored-by: Almeida <github@almeidx.dev>
Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Kshitij Anurag
2026-07-14 21:04:12 +01:00
committed by Jiralite
co-authored by Qjuh Almeida kodiakhq[bot]
parent 24a0606a74
commit 16fd248c64
4 changed files with 57 additions and 0 deletions
@@ -501,6 +501,34 @@ class Message extends Base {
} else {
this.call ??= null;
}
/**
* The shared client theme sent with this message
*
* @typedef {Object} SharedClientTheme
* @property {string[]} colors The hexadecimal-encoded colors of the theme (max of 5)
* @property {number} gradientAngle The direction of the theme's colors (0360)
* @property {number} baseMix The intensity of the theme's colors (0100)
* @property {?BaseThemeType} [baseTheme] The mode of the theme
*/
if (data.shared_client_theme) {
/**
* The shared client theme sent with this message
*
* @type {?SharedClientTheme}
*/
this.sharedClientTheme = {
colors: data.shared_client_theme.colors,
gradientAngle: data.shared_client_theme.gradient_angle,
baseMix: data.shared_client_theme.base_mix,
};
if ('base_theme' in data.shared_client_theme) {
this.sharedClientTheme.baseTheme = data.shared_client_theme.base_theme;
}
} else {
this.sharedClientTheme ??= null;
}
}
/**
@@ -237,6 +237,18 @@ class MessagePayload {
};
}
let shared_client_theme;
if (this.options.sharedClientTheme) {
shared_client_theme = isJSONEncodable(this.options.sharedClientTheme)
? this.options.sharedClientTheme.toJSON()
: {
colors: this.options.sharedClientTheme.colors,
gradient_angle: this.options.sharedClientTheme.gradientAngle,
base_mix: this.options.sharedClientTheme.baseMix,
base_theme: this.options.sharedClientTheme.baseTheme,
};
}
this.body = {
content,
tts,
@@ -259,6 +271,7 @@ class MessagePayload {
thread_name: threadName,
applied_tags: appliedTags,
poll,
shared_client_theme,
};
return this;
}
+5
View File
@@ -355,6 +355,11 @@
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/AuditLogEvent}
*/
/**
* @external BaseThemeType
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/BaseThemeType}
*/
/**
* @external ButtonStyle
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/ButtonStyle}
+11
View File
@@ -69,6 +69,7 @@ import {
APILabelComponent,
APIMessage,
APIMessageComponent,
APIMessageSharedClientTheme,
APIOverwrite,
APIPartialChannel,
APIPartialEmoji,
@@ -77,6 +78,7 @@ import {
APISelectMenuComponent,
APITemplateSerializedSourceGuild,
APIUser,
BaseThemeType,
ButtonStyle,
ChannelType,
ComponentType,
@@ -2393,6 +2395,13 @@ export interface MessageCall {
participants: readonly Snowflake[];
}
export interface SharedClientTheme {
baseMix: number;
baseTheme?: BaseThemeType | null;
colors: readonly string[];
gradientAngle: number;
}
export type MessageComponentType =
| ComponentType.Button
| ComponentType.ChannelSelect
@@ -2493,6 +2502,7 @@ export class Message<InGuild extends boolean = boolean> extends Base {
public tts: boolean;
public poll: Poll | null;
public call: MessageCall | null;
public sharedClientTheme: SharedClientTheme | null;
public type: MessageType;
public get url(): string;
public webhookId: Snowflake | null;
@@ -7414,6 +7424,7 @@ export interface MessageCreateOptions extends BaseMessageOptionsWithPoll {
reply?: ReplyOptions;
forward?: ForwardOptions;
stickers?: readonly StickerResolvable[];
sharedClientTheme?: JSONEncodable<APIMessageSharedClientTheme> | SharedClientTheme;
flags?:
| BitFieldResolvable<
Extract<MessageFlagsString, 'SuppressEmbeds' | 'SuppressNotifications' | 'IsComponentsV2'>,