mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-03 22:15:37 +00:00
organize command files into one folder
This commit is contained in:
1 parent
e85cd4dfc2
commit
676c915e6e
26 files changed
+158
-168
No files matched your search
@@ -0,0 +1,88 @@
|
||||
// @ts-ignore
|
||||
import { version } from '../../../package.json';
|
||||
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';
|
||||
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
|
||||
|
||||
class StatusCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = localizeCommand(new SlashCommandBuilder().setName('status'));
|
||||
super(data);
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction, client } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const [botStatisticsEmbedString, playerStatisticsEmbedString, systemStatusEmbedString] = await Promise.all([
|
||||
getBotStatistics(client!, version, translator),
|
||||
getPlayerStatistics(client!, translator),
|
||||
getSystemStatus(executionId, false, translator)
|
||||
]);
|
||||
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: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
translator('statistics.botStatus.title', { icon: this.embedOptions.icons.bot }) +
|
||||
'\n' +
|
||||
botStatisticsEmbedString
|
||||
)
|
||||
.addFields(
|
||||
{
|
||||
name: translator('statistics.queueStatus.title', {
|
||||
icon: this.embedOptions.icons.queue
|
||||
}),
|
||||
value: playerStatisticsEmbedString
|
||||
},
|
||||
{
|
||||
name: translator('statistics.systemStatus.title', {
|
||||
icon: this.embedOptions.icons.server
|
||||
}),
|
||||
value: systemStatusEmbedString
|
||||
},
|
||||
{
|
||||
name: translator('statistics.discordStatus.title', {
|
||||
icon: this.embedOptions.icons.discord
|
||||
}),
|
||||
value: discordStatusEmbedString
|
||||
}
|
||||
)
|
||||
.setColor(this.embedOptions.colors.info)
|
||||
],
|
||||
components: components.length > 0 ? [embedActionRow] : []
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default new StatusCommand();
|
||||
Reference in new issue
Block a user