diff --git a/locales/en/bot.json b/locales/en/bot.json index f4dcece..231fb76 100644 --- a/locales/en/bot.json +++ b/locales/en/bot.json @@ -293,7 +293,8 @@ "metadata": { "name": "status", "description": "Show operational status of the bot." - } + }, + "openSourceButtonLabel": "GitHub" }, "stop": { "metadata": { diff --git a/locales/no/bot.json b/locales/no/bot.json index 1313243..201ce6d 100644 --- a/locales/no/bot.json +++ b/locales/no/bot.json @@ -293,7 +293,8 @@ "metadata": { "name": "status", "description": "Vis driftsstatus for botten." - } + }, + "openSourceButtonLabel": "GitHub" }, "stop": { "metadata": { diff --git a/locales/resources.d.ts b/locales/resources.d.ts index 897b4dc..a9d7115 100644 --- a/locales/resources.d.ts +++ b/locales/resources.d.ts @@ -295,6 +295,7 @@ interface Resources { name: 'status'; description: 'Show operational status of the bot.'; }; + openSourceButtonLabel: 'GitHub'; }; stop: { metadata: { diff --git a/src/interactions/commands/info/status.ts b/src/interactions/commands/info/status.ts index 074c429..1f51ca2 100644 --- a/src/interactions/commands/info/status.ts +++ b/src/interactions/commands/info/status.ts @@ -1,6 +1,15 @@ // @ts-ignore import { version } from '../../../../package.json'; -import { EmbedBuilder, SlashCommandBuilder } from 'discord.js'; +import { + APIActionRowComponent, + APIButtonComponent, + APIMessageActionRowComponent, + ButtonBuilder, + ButtonStyle, + ComponentType, + EmbedBuilder, + SlashCommandBuilder +} from 'discord.js'; import { BaseSlashCommandInteraction } from '../../../classes/interactions'; import { getBotStatistics, getDiscordStatus, getPlayerStatistics, getSystemStatus } from '../../../common/statusUtils'; import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes'; @@ -24,6 +33,22 @@ class StatusCommand extends BaseSlashCommandInteraction { ]); const discordStatusEmbedString = getDiscordStatus(client!, translator); + const components: APIMessageActionRowComponent[] = []; + if (this.botOptions.openSourceUrl && this.botOptions.openSourceUrl !== '') { + const openSourceButton: APIButtonComponent = new ButtonBuilder() + .setURL(this.botOptions.openSourceUrl) + .setStyle(ButtonStyle.Link) + .setEmoji(this.embedOptions.icons.openSource) + .setLabel(translator('commands.status.openSourceButtonLabel')) + .toJSON(); + components.push(openSourceButton); + } + + const embedActionRow: APIActionRowComponent = { + type: ComponentType.ActionRow, + components + }; + logger.debug('Responding with info embed.'); return await interaction.editReply({ embeds: [ @@ -54,7 +79,8 @@ class StatusCommand extends BaseSlashCommandInteraction { } ) .setColor(this.embedOptions.colors.info) - ] + ], + components: components.length > 0 ? [embedActionRow] : [] }); } } diff --git a/src/types/configTypes.d.ts b/src/types/configTypes.d.ts index b36d1d5..e86e179 100644 --- a/src/types/configTypes.d.ts +++ b/src/types/configTypes.d.ts @@ -5,6 +5,7 @@ export type BotOptions = { name: string; botInviteUrl: string; serverInviteUrl: string; + openSourceUrl: string; }; export type CustomLoggerOptions = { @@ -49,6 +50,7 @@ export type EmbedOptions = { rule: string; support: string; bot: string; + openSource: string; server: string; discord: string; audioPlaying: string;