blob: 542fc187c20c021d2c760cb3a25d333674c4f807 [file] [log] [blame]
TheCodedProff86ba092023-01-27 17:10:07 -05001import { EmbedBuilder } from "discord.js";
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() {
Skyler Greyda16adf2023-03-05 10:22:12 +000016 if (this._emoji && !this._title) return getEmojiByName(this._emoji);
17 if (this._emoji) {
18 return `${getEmojiByName(this._emoji)} ${this._title}`;
19 }
20 if (this._title) {
21 return this._title;
22 }
PineaFan5d98a4b2023-01-19 16:15:47 +000023 return "";
pineafan4f164f32022-02-26 22:07:12 +000024 }
25
Skyler Grey75ea9172022-08-06 10:22:23 +010026 override setTitle(title: string) {
27 this._title = title;
PineaFan5d98a4b2023-01-19 16:15:47 +000028 const proposedTitle = this._generateTitle();
29 if (proposedTitle) super.setTitle(proposedTitle);
Skyler Grey75ea9172022-08-06 10:22:23 +010030 return this;
31 }
PineaFanc729e762023-01-02 22:11:34 +000032 override setDescription(description: string) {
33 this.description = description;
34 super.setDescription(description);
35 return this;
36 }
Skyler Grey75ea9172022-08-06 10:22:23 +010037 setEmoji(emoji: string) {
38 this._emoji = emoji;
PineaFan5d98a4b2023-01-19 16:15:47 +000039 const proposedTitle = this._generateTitle();
40 if (proposedTitle) super.setTitle(proposedTitle);
Skyler Grey75ea9172022-08-06 10:22:23 +010041 return this;
42 }
43 setStatus(color: "Danger" | "Warning" | "Success") {
44 this.setColor(colors[color]);
45 return this;
46 }
pineafan4f164f32022-02-26 22:07:12 +000047}
48
Skyler Grey75ea9172022-08-06 10:22:23 +010049export default EmojiEmbed;