blob: 69058aee6c82f1d51d310f7164eaf11ddc8f5c8e [file] [log] [blame]
pineafan63fc5e22022-08-04 22:04:10 +01001import { MessageEmbed } 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
10class EmojiEmbed extends MessageEmbed {
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
pineafanbd02b4a2022-08-05 22:01:38 +010021 override set title(title: string) {
pineafan4f164f32022-02-26 22:07:12 +000022 this._title = title;
23 }
24
Skyler Grey75ea9172022-08-06 10:22:23 +010025 override setTitle(title: string) {
26 this._title = title;
27 return this;
28 }
29 setEmoji(emoji: string) {
30 this._emoji = emoji;
31 return this;
32 }
33 setStatus(color: "Danger" | "Warning" | "Success") {
34 this.setColor(colors[color]);
35 return this;
36 }
pineafan4f164f32022-02-26 22:07:12 +000037}
38
Skyler Grey75ea9172022-08-06 10:22:23 +010039export default EmojiEmbed;