-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Expand file tree
/
Copy pathAvatarDecorationData.ts
More file actions
52 lines (47 loc) · 1.48 KB
/
AvatarDecorationData.ts
File metadata and controls
52 lines (47 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { CDNRoutes, RouteBases, type APIAvatarDecorationData } from 'discord-api-types/v10';
import { Structure } from '../Structure.js';
import { kData } from '../utils/symbols.js';
import { isFieldSet } from '../utils/type-guards.js';
import type { Partialize } from '../utils/types.js';
/**
* Represents metadata of an avatar decoration of a User.
*
* @typeParam Omitted - Specify the properties that will not be stored in the raw data field as a union, implement via `DataTemplate`
*/
export class AvatarDecorationData<Omitted extends keyof APIAvatarDecorationData | '' = ''> extends Structure<
APIAvatarDecorationData,
Omitted
> {
/**
* The template used for removing data from the raw data stored for each Connection
*/
public static override readonly DataTemplate: Partial<APIAvatarDecorationData> = {};
/**
* @param data - The raw data received from the API for the connection
*/
public constructor(data: Partialize<APIAvatarDecorationData, Omitted>) {
super(data);
}
/**
* The id of the SKU this avatar decoration is part of.
*/
public get skuId() {
return this[kData].sku_id;
}
/**
* The asset of this avatar decoration.
*/
public get asset() {
return this[kData].asset;
}
/**
* Get the URL to the asset of this avatar decoration
*
* @returns the URL to the asset of this avatar decoration
*/
public assetURL() {
return isFieldSet(this[kData], 'asset', 'string')
? `${RouteBases.cdn}${CDNRoutes.avatarDecoration(this[kData].asset)}`
: null;
}
}