-
-
Notifications
You must be signed in to change notification settings - Fork 99
/
embed.ts
140 lines (138 loc) · 3.7 KB
/
embed.ts
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import { Bot } from "../bot.ts";
import { SnakeCasedPropertiesDeep } from "../types/util.ts";
import { EmbedTypes } from "../types/embeds/embedTypes.ts";
import { Embed } from "../types/embeds/embed.ts";
export function transformEmbed(bot: Bot, payload: SnakeCasedPropertiesDeep<Embed>): DiscordenoEmbed {
return {
title: payload.title,
type: payload.type,
description: payload.description,
url: payload.url,
timestamp: payload.timestamp ? Date.parse(payload.timestamp) : undefined,
color: payload.color,
footer: payload.footer
? {
text: payload.footer.text,
iconUrl: payload.footer.icon_url,
proxyIconUrl: payload.footer.proxy_icon_url,
}
: undefined,
image: payload.image
? {
url: payload.image.url,
proxyUrl: payload.image.proxy_url,
height: payload.image.height,
width: payload.image.width,
}
: undefined,
thumbnail: payload.thumbnail
? {
url: payload.thumbnail.url,
proxyUrl: payload.thumbnail.proxy_url,
height: payload.thumbnail.height,
width: payload.thumbnail.width,
}
: undefined,
video: payload.video
? {
url: payload.video.url,
proxyUrl: payload.video.proxy_url,
height: payload.video.height,
width: payload.video.width,
}
: undefined,
provider: payload.provider,
author: payload.author
? {
name: payload.author.name,
url: payload.author.url,
iconUrl: payload.author.icon_url,
proxyIconUrl: payload.author.proxy_icon_url,
}
: undefined,
fields: payload.fields,
};
}
export interface DiscordenoEmbed {
/** Title of embed */
title?: string;
/** Type of embed (always "rich" for webhook embeds) */
type?: EmbedTypes;
/** Description of embed */
description?: string;
/** Url of embed */
url?: string;
/** Timestamp of embed content */
timestamp?: number;
/** Color code of the embed */
color?: number;
/** Footer information */
footer?: {
/** Footer text */
text: string;
/** Url of footer icon (only supports http(s) and attachments) */
iconUrl?: string;
/** A proxied url of footer icon */
proxyIconUrl?: string;
};
/** Image information */
image?: {
/** Source url of image (only supports http(s) and attachments) */
url?: string;
/** A proxied url of the image */
proxyUrl?: string;
/** Height of image */
height?: number;
/** Width of image */
width?: number;
};
/** Thumbnail information */
thumbnail?: {
/** Source url of thumbnail (only supports http(s) and attachments) */
url?: string;
/** A proxied url of the thumbnail */
proxyUrl?: string;
/** Height of thumbnail */
height?: number;
/** Width of thumbnail */
width?: number;
};
/** Video information */
video?: {
/** Source url of video */
url?: string;
/** A proxied url of the video */
proxyUrl?: string;
/** Height of video */
height?: number;
/** Width of video */
width?: number;
};
/** Provider information */
provider?: {
/** Name of provider */
name?: string;
/** Url of provider */
url?: string;
};
/** Author information */
author?: {
/** Name of author */
name?: string;
/** Url of author */
url?: string;
/** Url of author icon (only supports http(s) and attachments) */
iconUrl?: string;
/** A proxied url of author icon */
proxyIconUrl?: string;
};
/** Fields information */
fields?: {
/** Name of the field */
name: string;
/** Value of the field */
value: string;
/** Whether or not this field should display inline */
inline?: boolean;
}[];
}