mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-03 22:15:37 +00:00
WIP
This commit is contained in:
1 parent
9e20805529
commit
26a5022280
24 files changed
+121
-45
No files matched your search
@@ -0,0 +1,54 @@
|
||||
import config from 'config';
|
||||
import {
|
||||
ChatInputCommandInteraction,
|
||||
EmbedAuthorData,
|
||||
EmbedBuilder,
|
||||
EmbedFooterData,
|
||||
InteractionResponse,
|
||||
Message,
|
||||
MessageComponentInteraction,
|
||||
EmbedField
|
||||
} from 'discord.js';
|
||||
import { EmbedOptions } from '../types/configTypes';
|
||||
|
||||
export type EmbedContext = {
|
||||
author?: EmbedAuthorData;
|
||||
title?: string;
|
||||
description: string;
|
||||
footer?: EmbedFooterData;
|
||||
thumbnail?: string;
|
||||
fields?: EmbedField[];
|
||||
};
|
||||
|
||||
abstract class BaseEmbed {
|
||||
embedOptions: EmbedOptions;
|
||||
context: EmbedContext;
|
||||
interaction: ChatInputCommandInteraction | MessageComponentInteraction;
|
||||
embed: EmbedBuilder;
|
||||
|
||||
constructor(interaction: ChatInputCommandInteraction | MessageComponentInteraction, context: EmbedContext) {
|
||||
this.embedOptions = config.get('embedOptions');
|
||||
this.context = context;
|
||||
this.interaction = interaction;
|
||||
this.embed = new EmbedBuilder();
|
||||
this.embed.setDescription(`${context.title ? `**${context.title}**\n` : ''}${context.description}`);
|
||||
context.author && this.embed.setAuthor(context.author);
|
||||
context.footer && this.embed.setFooter(context.footer);
|
||||
context.thumbnail && this.embed.setThumbnail(context.thumbnail);
|
||||
}
|
||||
|
||||
abstract send(): Promise<Message<boolean> | InteractionResponse<boolean>>;
|
||||
}
|
||||
|
||||
export class InfoEmbed extends BaseEmbed {
|
||||
constructor(interaction: ChatInputCommandInteraction | MessageComponentInteraction, context: EmbedContext) {
|
||||
super(interaction, context);
|
||||
|
||||
this.embed.setColor(this.embedOptions.colors.info);
|
||||
}
|
||||
|
||||
async send(): Promise<Message<boolean>> {
|
||||
const embeds = { embeds: [this.embed] };
|
||||
return await this.interaction.editReply(embeds);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user