blob: a326fc52b51fadda4e897c6a3a3708a6b843a914 [file] [log] [blame]
Samuel Shuert27bf3cd2023-03-03 15:51:25 -05001import { EmbedBuilder } 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
TheCodedProf21c08592022-09-13 14:14:43 -040010class EmojiEmbed extends EmbedBuilder {
pineafanbd02b4a2022-08-05 22:01:38 +010011 _title = "";
12 _emoji: string | null = null;
PineaFanc729e762023-01-02 22:11:34 +000013 description = "";
pineafan4f164f32022-02-26 22:07:12 +000014
PineaFandf4996f2023-01-01 14:20:06 +000015 _generateTitle() {
Samuel Shuert27bf3cd2023-03-03 15:51:25 -050016 if (this._emoji && !this._title) return getEmojiByName(this._emoji)
PineaFandf4996f2023-01-01 14:20:06 +000017 if (this._emoji) { return `${getEmojiByName(this._emoji)} ${this._title}`; }
Samuel Shuert27bf3cd2023-03-03 15:51:25 -050018 if (this._title) { return this._title };
19 return "";
pineafan4f164f32022-02-26 22:07:12 +000020 }
21
Skyler Grey75ea9172022-08-06 10:22:23 +010022 override setTitle(title: string) {
23 this._title = title;
Samuel Shuert27bf3cd2023-03-03 15:51:25 -050024 const proposedTitle = this._generateTitle();
25 if (proposedTitle) super.setTitle(proposedTitle);
Skyler Grey75ea9172022-08-06 10:22:23 +010026 return this;
27 }
PineaFanc729e762023-01-02 22:11:34 +000028 override setDescription(description: string) {
29 this.description = description;
30 super.setDescription(description);
31 return this;
32 }
Skyler Grey75ea9172022-08-06 10:22:23 +010033 setEmoji(emoji: string) {
34 this._emoji = emoji;
Samuel Shuert27bf3cd2023-03-03 15:51:25 -050035 const proposedTitle = this._generateTitle();
36 if (proposedTitle) super.setTitle(proposedTitle);
Skyler Grey75ea9172022-08-06 10:22:23 +010037 return this;
38 }
39 setStatus(color: "Danger" | "Warning" | "Success") {
40 this.setColor(colors[color]);
41 return this;
42 }
pineafan4f164f32022-02-26 22:07:12 +000043}
44
PineaFandf4996f2023-01-01 14:20:06 +000045
Skyler Grey75ea9172022-08-06 10:22:23 +010046export default EmojiEmbed;