PineaFan | df4996f | 2023-01-01 14:20:06 +0000 | [diff] [blame^] | 1 | import { EmbedBuilder } from "@discordjs/builders"; |
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 | |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 10 | class EmojiEmbed extends EmbedBuilder { |
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 | |
PineaFan | df4996f | 2023-01-01 14:20:06 +0000 | [diff] [blame^] | 14 | _generateTitle() { |
15 | if (this._emoji) { return `${getEmojiByName(this._emoji)} ${this._title}`; } | ||||
16 | return this._title; | ||||
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 17 | } |
18 | |||||
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 19 | override setTitle(title: string) { |
20 | this._title = title; | ||||
PineaFan | df4996f | 2023-01-01 14:20:06 +0000 | [diff] [blame^] | 21 | super.setTitle(this._generateTitle()); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 22 | return this; |
23 | } | ||||
24 | setEmoji(emoji: string) { | ||||
25 | this._emoji = emoji; | ||||
PineaFan | df4996f | 2023-01-01 14:20:06 +0000 | [diff] [blame^] | 26 | super.setTitle(this._generateTitle()); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 27 | return this; |
28 | } | ||||
29 | setStatus(color: "Danger" | "Warning" | "Success") { | ||||
30 | this.setColor(colors[color]); | ||||
31 | return this; | ||||
32 | } | ||||
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 33 | } |
34 | |||||
PineaFan | df4996f | 2023-01-01 14:20:06 +0000 | [diff] [blame^] | 35 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 36 | export default EmojiEmbed; |