Skip to content

Commit

Permalink
feat(bot): allow status embed to have no buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Mar 15, 2023
1 parent 8e55176 commit 421cbd3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/components/DiscordBot/commands/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,13 @@ export const generateStatusMessage = (
}

//Attempting to instantiate buttons
const buttonsRow = new ActionRowBuilder<ButtonBuilder>();
let buttonsRow: ActionRowBuilder<ButtonBuilder> | undefined;
try {
if (Array.isArray(embedConfigJson?.buttons)) {
if (Array.isArray(embedConfigJson?.buttons) && embedConfigJson.buttons.length) {
if (embedConfigJson.buttons.length > 5) {
throw new Error(`Over limit of 5 buttons.`);
}
buttonsRow = new ActionRowBuilder<ButtonBuilder>();
for (const cfgButton of embedConfigJson.buttons) {
if (!isValidButtonConfig(cfgButton)) {
throw new Error(`Invalid button in Discord Status Embed Config.
Expand Down Expand Up @@ -220,7 +221,7 @@ export const generateStatusMessage = (

return {
embeds: [embed],
components: [buttonsRow],
components: buttonsRow ? [buttonsRow] : undefined,
};
}

Expand Down

0 comments on commit 421cbd3

Please sign in to comment.