blob: c0f17aecdd8a749846f5490678daf24f93bb52dc [file] [log] [blame]
PineaFandf4996f2023-01-01 14:20:06 +00001import { EmbedBuilder } from "@discordjs/builders";
pineafan4f164f32022-02-26 22:07:12 +00002import getEmojiByName from "./getEmojiByName.js";
3
4const colors = {
Skyler Grey75ea9172022-08-06 10:22:23 +01005 Danger: 0xf27878,
6 Warning: 0xf2d478,
7 Success: 0x68d49e
pineafan63fc5e22022-08-04 22:04:10 +01008};
pineafan4f164f32022-02-26 22:07:12 +00009
TheCodedProf21c08592022-09-13 14:14:43 -040010class EmojiEmbed extends EmbedBuilder {
pineafanbd02b4a2022-08-05 22:01:38 +010011 _title = "";
12 _emoji: string | null = null;
PineaFanc729e762023-01-02 22:11:34 +000013 description = "";
pineafan4f164f32022-02-26 22:07:12 +000014
PineaFandf4996f2023-01-01 14:20:06 +000015 _generateTitle() {
16 if (this._emoji) { return `${getEmojiByName(this._emoji)} ${this._title}`; }
17 return this._title;
pineafan4f164f32022-02-26 22:07:12 +000018 }
19
Skyler Grey75ea9172022-08-06 10:22:23 +010020 override setTitle(title: string) {
21 this._title = title;
PineaFandf4996f2023-01-01 14:20:06 +000022 super.setTitle(this._generateTitle());
Skyler Grey75ea9172022-08-06 10:22:23 +010023 return this;
24 }
PineaFanc729e762023-01-02 22:11:34 +000025 override setDescription(description: string) {
26 this.description = description;
27 super.setDescription(description);
28 return this;
29 }
Skyler Grey75ea9172022-08-06 10:22:23 +010030 setEmoji(emoji: string) {
31 this._emoji = emoji;
PineaFandf4996f2023-01-01 14:20:06 +000032 super.setTitle(this._generateTitle());
Skyler Grey75ea9172022-08-06 10:22:23 +010033 return this;
34 }
35 setStatus(color: "Danger" | "Warning" | "Success") {
36 this.setColor(colors[color]);
37 return this;
38 }
pineafan4f164f32022-02-26 22:07:12 +000039}
40
PineaFandf4996f2023-01-01 14:20:06 +000041
Skyler Grey75ea9172022-08-06 10:22:23 +010042export default EmojiEmbed;