blob: c1de60f1a8de7156f68cc9822daa9ca2a842d002 [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
pineafan63fc5e22022-08-04 22:04:10 +010014 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
Skyler Grey75ea9172022-08-06 10:22:23 +010015 // @ts-expect-error
pineafan4f164f32022-02-26 22:07:12 +000016 // This *is* meant to be an accessor rather than a property
pineafanbd02b4a2022-08-05 22:01:38 +010017 override get title() {
18 if (!this._emoji) return this._title;
pineafan4f164f32022-02-26 22:07:12 +000019 return `${getEmojiByName(this._emoji)} ${this._title}`;
20 }
21
pineafanbd02b4a2022-08-05 22:01:38 +010022 override set title(title: string) {
pineafan4f164f32022-02-26 22:07:12 +000023 this._title = title;
24 }
25
Skyler Grey75ea9172022-08-06 10:22:23 +010026 override setTitle(title: string) {
27 this._title = title;
28 return this;
29 }
30 setEmoji(emoji: string) {
31 this._emoji = emoji;
32 return this;
33 }
34 setStatus(color: "Danger" | "Warning" | "Success") {
35 this.setColor(colors[color]);
36 return this;
37 }
pineafan4f164f32022-02-26 22:07:12 +000038}
39
Skyler Grey75ea9172022-08-06 10:22:23 +010040export default EmojiEmbed;