fix: Add Open source button to /status

This commit is contained in:
Marius Begby committed 2023-12-19 11:36:00 +01:00
1 parent 4f29399a8e
commit fa84e2925e
5 files changed
+35 -4

No files matched your search

+2 -1
View File
@@ -293,7 +293,8 @@
"metadata": {
"name": "status",
"description": "Show operational status of the bot."
}
},
"openSourceButtonLabel": "GitHub"
},
"stop": {
"metadata": {
+2 -1
View File
@@ -293,7 +293,8 @@
"metadata": {
"name": "status",
"description": "Vis driftsstatus for botten."
}
},
"openSourceButtonLabel": "GitHub"
},
"stop": {
"metadata": {
+1
View File
@@ -295,6 +295,7 @@ interface Resources {
name: 'status';
description: 'Show operational status of the bot.';
};
openSourceButtonLabel: 'GitHub';
};
stop: {
metadata: {
+28 -2
View File
@@ -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<APIMessageActionRowComponent> = {
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] : []
});
}
}
+2
View File
@@ -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;