blob: a7926df237a2cbbad8fdaa406f3cf2d09ef18488 [file] [log] [blame]
TheCodedProf21c08592022-09-13 14:14:43 -04001import { 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;
pineafan4f164f32022-02-26 22:07:12 +000013
Skyler Grey75ea9172022-08-06 10:22:23 +010014 // @ts-expect-error
pineafan4f164f32022-02-26 22:07:12 +000015 // This *is* meant to be an accessor rather than a property
pineafanbd02b4a2022-08-05 22:01:38 +010016 override get title() {
17 if (!this._emoji) return this._title;
pineafan4f164f32022-02-26 22:07:12 +000018 return `${getEmojiByName(this._emoji)} ${this._title}`;
19 }
20
Skyler Grey75ea9172022-08-06 10:22:23 +010021 override setTitle(title: string) {
22 this._title = title;
23 return this;
24 }
25 setEmoji(emoji: string) {
26 this._emoji = emoji;
27 return this;
28 }
29 setStatus(color: "Danger" | "Warning" | "Success") {
30 this.setColor(colors[color]);
31 return this;
32 }
pineafan4f164f32022-02-26 22:07:12 +000033}
34
Skyler Grey75ea9172022-08-06 10:22:23 +010035export default EmojiEmbed;