pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 1 | import { MessageEmbed } from "discord.js"; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 2 | import getEmojiByName from "./getEmojiByName.js"; |
| 3 | |
| 4 | const colors = { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 5 | Danger: 0xf27878, |
| 6 | Warning: 0xf2d478, |
| 7 | Success: 0x68d49e |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 8 | }; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 9 | |
| 10 | class EmojiEmbed extends MessageEmbed { |
pineafan | bd02b4a | 2022-08-05 22:01:38 +0100 | [diff] [blame] | 11 | _title = ""; |
| 12 | _emoji: string | null = null; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 13 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 14 | // @ts-expect-error |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 15 | // This *is* meant to be an accessor rather than a property |
pineafan | bd02b4a | 2022-08-05 22:01:38 +0100 | [diff] [blame] | 16 | override get title() { |
| 17 | if (!this._emoji) return this._title; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 18 | return `${getEmojiByName(this._emoji)} ${this._title}`; |
| 19 | } |
| 20 | |
pineafan | bd02b4a | 2022-08-05 22:01:38 +0100 | [diff] [blame] | 21 | override set title(title: string) { |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 22 | this._title = title; |
| 23 | } |
| 24 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 25 | 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 | } |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 37 | } |
| 38 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 39 | export default EmojiEmbed; |