TheCodedProf | f86ba09 | 2023-01-27 17:10:07 -0500 | [diff] [blame] | 1 | import { EmbedBuilder } 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 | |
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 | c729e76 | 2023-01-02 22:11:34 +0000 | [diff] [blame] | 13 | description = ""; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 14 | |
PineaFan | df4996f | 2023-01-01 14:20:06 +0000 | [diff] [blame] | 15 | _generateTitle() { |
PineaFan | 5d98a4b | 2023-01-19 16:15:47 +0000 | [diff] [blame] | 16 | if (this._emoji && !this._title) return getEmojiByName(this._emoji) |
PineaFan | df4996f | 2023-01-01 14:20:06 +0000 | [diff] [blame] | 17 | if (this._emoji) { return `${getEmojiByName(this._emoji)} ${this._title}`; } |
PineaFan | 5d98a4b | 2023-01-19 16:15:47 +0000 | [diff] [blame] | 18 | if (this._title) { return this._title }; |
| 19 | return ""; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 20 | } |
| 21 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 22 | override setTitle(title: string) { |
| 23 | this._title = title; |
PineaFan | 5d98a4b | 2023-01-19 16:15:47 +0000 | [diff] [blame] | 24 | const proposedTitle = this._generateTitle(); |
| 25 | if (proposedTitle) super.setTitle(proposedTitle); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 26 | return this; |
| 27 | } |
PineaFan | c729e76 | 2023-01-02 22:11:34 +0000 | [diff] [blame] | 28 | override setDescription(description: string) { |
| 29 | this.description = description; |
| 30 | super.setDescription(description); |
| 31 | return this; |
| 32 | } |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 33 | setEmoji(emoji: string) { |
| 34 | this._emoji = emoji; |
PineaFan | 5d98a4b | 2023-01-19 16:15:47 +0000 | [diff] [blame] | 35 | const proposedTitle = this._generateTitle(); |
| 36 | if (proposedTitle) super.setTitle(proposedTitle); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 37 | return this; |
| 38 | } |
| 39 | setStatus(color: "Danger" | "Warning" | "Success") { |
| 40 | this.setColor(colors[color]); |
| 41 | return this; |
| 42 | } |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 43 | } |
| 44 | |
PineaFan | df4996f | 2023-01-01 14:20:06 +0000 | [diff] [blame] | 45 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 46 | export default EmojiEmbed; |