blob: 65e11fabf10ba7ea2f8dc1933c56422d6e8ec15c [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 = {
5 "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
pineafan4f164f32022-02-26 22:07:12 +000015 // @ts-ignore
16 // 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
pineafanbd02b4a2022-08-05 22:01:38 +010026 override setTitle(title: string) { this._title = title; return this; }
pineafan63fc5e22022-08-04 22:04:10 +010027 setEmoji(emoji: string) { this._emoji = emoji; return this; }
pineafanbd02b4a2022-08-05 22:01:38 +010028 setStatus(color: "Danger" | "Warning" | "Success") { this.setColor(colors[color]); return this; }
pineafan4f164f32022-02-26 22:07:12 +000029}
30
31export default EmojiEmbed;