mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 14:38:49 +00:00
Status transcription
This commit is contained in:
5 files changed
+155
-43
No files matched your search
@@ -225,5 +225,39 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"statistics": {
|
||||||
|
"botStatus": {
|
||||||
|
"title": "{{icon}} **Bot status**",
|
||||||
|
"joinedServers": "**{{count}}** Joined servers",
|
||||||
|
"joinedServers_one": "**1** Joined server",
|
||||||
|
"totalMembers": "**{{count}}** Total members",
|
||||||
|
"releaseVersion": "**{{version}}** Release version"
|
||||||
|
},
|
||||||
|
"queueStatus": {
|
||||||
|
"title": "{{icon}} **Queue status**",
|
||||||
|
"voiceConnections": "**{{count}}** Voice connections",
|
||||||
|
"voiceConnections_one": "**1** Voice connection",
|
||||||
|
"tracksInQueues": "**{{count}}** Tracks in queues",
|
||||||
|
"tracksInQueues_one": "**1** Track in queues",
|
||||||
|
"usersListening": "**{{count}}** Users listening",
|
||||||
|
"usersListening_one": "**1** User listening"
|
||||||
|
},
|
||||||
|
"systemStatus": {
|
||||||
|
"title": "{{icon}} **System status**",
|
||||||
|
"uptime": "**{{value}}** Uptime",
|
||||||
|
"cpu": "**{{value, number(minimumFractionDigits: 2)}}%** CPU usage",
|
||||||
|
"cpuDetailed": "**{{usage}}% @ {{cores}} cores** CPU usage",
|
||||||
|
"memory": "**{{value, number}} MB** Memory usage",
|
||||||
|
"memoryDetailed": "**{{used, number}} / {{total, number}} MB** Memory usage",
|
||||||
|
"platform": "**{{value}}** Platform"
|
||||||
|
},
|
||||||
|
"discordStatus": {
|
||||||
|
"title": "{{icon}} **Discord status**",
|
||||||
|
"apiLatency": "**{{value, number}} ms** Discord API latency"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"title": "{{icon}} **Dependencies**"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Vendored
+34
@@ -226,6 +226,40 @@ interface Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"statistics": {
|
||||||
|
"botStatus": {
|
||||||
|
"title": "{{icon}} **Bot status**",
|
||||||
|
"joinedServers": "**{{count}}** Joined servers",
|
||||||
|
"joinedServers_one": "**1** Joined server",
|
||||||
|
"totalMembers": "**{{count}}** Total members",
|
||||||
|
"releaseVersion": "**{{version}}** Release version"
|
||||||
|
},
|
||||||
|
"queueStatus": {
|
||||||
|
"title": "{{icon}} **Queue status**",
|
||||||
|
"voiceConnections": "**{{count}}** Voice connections",
|
||||||
|
"voiceConnections_one": "**1** Voice connection",
|
||||||
|
"tracksInQueues": "**{{count}}** Tracks in queues",
|
||||||
|
"tracksInQueues_one": "**1** Track in queues",
|
||||||
|
"usersListening": "**{{count}}** Users listening",
|
||||||
|
"usersListening_one": "**1** User listening"
|
||||||
|
},
|
||||||
|
"systemStatus": {
|
||||||
|
"title": "{{icon}} **System status**",
|
||||||
|
"uptime": "**{{value}}** Uptime",
|
||||||
|
"cpu": "**{{value, number(minimumFractionDigits: 2)}}%** CPU usage",
|
||||||
|
"cpuDetailed": "**{{usage}}% @ {{cores}} cores** CPU usage",
|
||||||
|
"memory": "**{{value, number}} MB** Memory usage",
|
||||||
|
"memoryDetailed": "**{{used, number}} / {{total, number}} MB** Memory usage",
|
||||||
|
"platform": "**{{value}}** Platform"
|
||||||
|
},
|
||||||
|
"discordStatus": {
|
||||||
|
"title": "{{icon}} **Discord status**",
|
||||||
|
"apiLatency": "**{{value, number}} ms** Discord API latency"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"title": "{{icon}} **Dependencies**"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+48
-24
@@ -2,54 +2,78 @@ import osu from 'node-os-utils';
|
|||||||
import { ExtendedClient } from '../types/clientTypes';
|
import { ExtendedClient } from '../types/clientTypes';
|
||||||
import { fetchTotalGuildStatistics, fetchTotalPlayerStatistics } from '../utils/shardUtils';
|
import { fetchTotalGuildStatistics, fetchTotalPlayerStatistics } from '../utils/shardUtils';
|
||||||
import { getUptimeFormatted } from '../utils/system/getUptimeFormatted';
|
import { getUptimeFormatted } from '../utils/system/getUptimeFormatted';
|
||||||
|
import { TFunction } from 'i18next';
|
||||||
|
|
||||||
export async function getBotStatistics(client: ExtendedClient, version: string): Promise<string> {
|
export async function getBotStatistics(
|
||||||
|
client: ExtendedClient,
|
||||||
|
version: string,
|
||||||
|
translator: TFunction
|
||||||
|
): Promise<string> {
|
||||||
const releaseVersion: string = version;
|
const releaseVersion: string = version;
|
||||||
const { totalGuildCount, totalMemberCount } = await fetchTotalGuildStatistics(client);
|
const { totalGuildCount, totalMemberCount } = await fetchTotalGuildStatistics(client);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
`**${totalGuildCount.toLocaleString('en-US')}** Joined servers\n` +
|
translator('statistics.botStatus.joinedServers', {
|
||||||
`**${totalMemberCount.toLocaleString('en-US')}** Total members\n` +
|
count: totalGuildCount
|
||||||
`**v${releaseVersion}** Release version`
|
}) +
|
||||||
|
'\n' +
|
||||||
|
translator('statistics.botStatus.totalMembers', {
|
||||||
|
count: totalMemberCount
|
||||||
|
}) +
|
||||||
|
'\n' +
|
||||||
|
translator('statistics.botStatus.releaseVersion', {
|
||||||
|
version: `v${releaseVersion}`
|
||||||
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getPlayerStatistics(client: ExtendedClient): Promise<string> {
|
export async function getPlayerStatistics(client: ExtendedClient, translator: TFunction): Promise<string> {
|
||||||
const { totalVoiceConnections, totalTracksInQueues, totalListeners } = await fetchTotalPlayerStatistics(client);
|
const { totalVoiceConnections, totalTracksInQueues, totalListeners } = await fetchTotalPlayerStatistics(client);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
`**${totalVoiceConnections.toLocaleString('en-US')}** Voice connections\n` +
|
translator('statistics.queueStatus.voiceConnections', {
|
||||||
`**${totalTracksInQueues.toLocaleString('en-US')}** Tracks in queues\n` +
|
count: totalVoiceConnections
|
||||||
`**${totalListeners.toLocaleString('en-US')}** Users listening`
|
}) +
|
||||||
|
'\n' +
|
||||||
|
translator('statistics.queueStatus.tracksInQueues', {
|
||||||
|
count: totalTracksInQueues
|
||||||
|
}) +
|
||||||
|
'\n' +
|
||||||
|
translator('statistics.queueStatus.usersListening', {
|
||||||
|
count: totalListeners
|
||||||
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getSystemStatus(executionId: string, extended: boolean): Promise<string> {
|
export async function getSystemStatus(executionId: string, extended: boolean, translator: TFunction): Promise<string> {
|
||||||
|
const uptimeString: string = getUptimeFormatted({ executionId });
|
||||||
|
const usedMemoryInMB: number = Math.ceil((await osu.mem.info()).usedMemMb);
|
||||||
|
const cpuUsage: number = await osu.cpu.usage();
|
||||||
if (!extended) {
|
if (!extended) {
|
||||||
const uptimeString: string = getUptimeFormatted({ executionId });
|
|
||||||
const usedMemoryInMB: string = Math.ceil((await osu.mem.info()).usedMemMb).toLocaleString('en-US');
|
|
||||||
const cpuUsage: number = await osu.cpu.usage();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
`**${uptimeString}** Uptime\n` + `**${cpuUsage}%** CPU usage\n` + `**${usedMemoryInMB} MB** Memory usage`
|
translator('statistics.systemStatus.uptime', { value: uptimeString }) +
|
||||||
|
'\n' +
|
||||||
|
translator('statistics.systemStatus.cpu', { value: cpuUsage }) +
|
||||||
|
'\n' +
|
||||||
|
translator('statistics.systemStatus.memory', { value: usedMemoryInMB })
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const uptimeString: string = getUptimeFormatted({ executionId });
|
const totalMemoryInMb: number = Math.ceil((await osu.mem.info()).totalMemMb);
|
||||||
const totalMemoryInMb: string = Math.ceil((await osu.mem.info()).totalMemMb).toLocaleString('en-US');
|
|
||||||
const cpuCores: number = osu.cpu.count();
|
const cpuCores: number = osu.cpu.count();
|
||||||
const platform: string = osu.os.platform();
|
const platform: string = osu.os.platform();
|
||||||
const usedMemoryInMB: string = Math.ceil((await osu.mem.info()).usedMemMb).toLocaleString('en-US');
|
|
||||||
const cpuUsage: number = await osu.cpu.usage();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
`**${platform}** Platform\n` +
|
translator('statistics.systemStatus.platform', { value: platform }) +
|
||||||
`**${uptimeString}** Uptime\n` +
|
'\n' +
|
||||||
`**${cpuUsage}% @ ${cpuCores} cores** CPU usage\n` +
|
translator('statistics.systemStatus.uptime', { value: uptimeString }) +
|
||||||
`**${usedMemoryInMB} / ${totalMemoryInMb} MB** Memory usage`
|
'\n' +
|
||||||
|
translator('statistics.systemStatus.cpuDetailed', { usage: cpuUsage, cores: cpuCores }) +
|
||||||
|
'\n' +
|
||||||
|
translator('statistics.systemStatus.memoryDetailed', { used: usedMemoryInMB, total: totalMemoryInMb })
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDiscordStatus(client: ExtendedClient): string {
|
export function getDiscordStatus(client: ExtendedClient, translator: TFunction): string {
|
||||||
return `**${client!.ws.ping} ms** Discord API latency`;
|
return translator('statistics.discordStatus.apiLatency', { value: client.ws.ping });
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
|||||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||||
import { getBotStatistics, getDiscordStatus, getPlayerStatistics, getSystemStatus } from '../../../common/statusUtils';
|
import { getBotStatistics, getDiscordStatus, getPlayerStatistics, getSystemStatus } from '../../../common/statusUtils';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { localizeCommand } from '../../../common/localeUtil';
|
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||||
|
|
||||||
class StatusCommand extends BaseSlashCommandInteraction {
|
class StatusCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -15,31 +15,42 @@ class StatusCommand extends BaseSlashCommandInteraction {
|
|||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction, client } = params;
|
const { executionId, interaction, client } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
const [botStatisticsEmbedString, playerStatisticsEmbedString, systemStatusEmbedString] = await Promise.all([
|
const [botStatisticsEmbedString, playerStatisticsEmbedString, systemStatusEmbedString] = await Promise.all([
|
||||||
getBotStatistics(client!, version),
|
getBotStatistics(client!, version, translator),
|
||||||
getPlayerStatistics(client!),
|
getPlayerStatistics(client!, translator),
|
||||||
getSystemStatus(executionId, false)
|
getSystemStatus(executionId, false, translator)
|
||||||
]);
|
]);
|
||||||
const discordStatus = getDiscordStatus(client!);
|
const discordStatusEmbedString = getDiscordStatus(client!, translator);
|
||||||
|
|
||||||
logger.debug('Responding with info embed.');
|
logger.debug('Responding with info embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(`**${this.embedOptions.icons.bot} Bot status**\n` + botStatisticsEmbedString)
|
.setDescription(
|
||||||
|
translator('statistics.botStatus.title', { icon: this.embedOptions.icons.bot }) +
|
||||||
|
'\n' +
|
||||||
|
botStatisticsEmbedString
|
||||||
|
)
|
||||||
.addFields(
|
.addFields(
|
||||||
{
|
{
|
||||||
name: `**${this.embedOptions.icons.queue} Queue status**`,
|
name: translator('statistics.queueStatus.title', {
|
||||||
|
icon: this.embedOptions.icons.queue
|
||||||
|
}),
|
||||||
value: playerStatisticsEmbedString
|
value: playerStatisticsEmbedString
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: `**${this.embedOptions.icons.server} System status**`,
|
name: translator('statistics.systemStatus.title', {
|
||||||
|
icon: this.embedOptions.icons.server
|
||||||
|
}),
|
||||||
value: systemStatusEmbedString
|
value: systemStatusEmbedString
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: `**${this.embedOptions.icons.discord} Discord status**`,
|
name: translator('statistics.discordStatus.title', {
|
||||||
value: discordStatus
|
icon: this.embedOptions.icons.discord
|
||||||
|
}),
|
||||||
|
value: discordStatusEmbedString
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.setColor(this.embedOptions.colors.info)
|
.setColor(this.embedOptions.colors.info)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
|||||||
import { getBotStatistics, getDiscordStatus, getPlayerStatistics, getSystemStatus } from '../../../common/statusUtils';
|
import { getBotStatistics, getDiscordStatus, getPlayerStatistics, getSystemStatus } from '../../../common/statusUtils';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { checkValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
import { checkValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
||||||
import { localizeCommand } from '../../../common/localeUtil';
|
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||||
|
|
||||||
class SystemStatusCommand extends BaseSlashCommandInteraction {
|
class SystemStatusCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -17,15 +17,16 @@ class SystemStatusCommand extends BaseSlashCommandInteraction {
|
|||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction, client } = params;
|
const { executionId, interaction, client } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
const translator = useServerTranslator(interaction);
|
||||||
|
|
||||||
await this.runValidators({ interaction, executionId }, [checkValidGuildId]);
|
await this.runValidators({ interaction, executionId }, [checkValidGuildId]);
|
||||||
|
|
||||||
const [botStatisticsEmbedString, playerStatisticsEmbedString, systemStatusEmbedString] = await Promise.all([
|
const [botStatisticsEmbedString, playerStatisticsEmbedString, systemStatusEmbedString] = await Promise.all([
|
||||||
getBotStatistics(client!, version),
|
getBotStatistics(client!, version, translator),
|
||||||
getPlayerStatistics(client!),
|
getPlayerStatistics(client!, translator),
|
||||||
getSystemStatus(executionId, false)
|
getSystemStatus(executionId, false, translator)
|
||||||
]);
|
]);
|
||||||
const discordStatusEmbedString = getDiscordStatus(client!);
|
const discordStatusEmbedString = getDiscordStatus(client!, translator);
|
||||||
const dependenciesEmbedString = this.getDependencies();
|
const dependenciesEmbedString = this.getDependencies();
|
||||||
|
|
||||||
logger.debug('Responding with info embed.');
|
logger.debug('Responding with info embed.');
|
||||||
@@ -35,19 +36,27 @@ class SystemStatusCommand extends BaseSlashCommandInteraction {
|
|||||||
.setDescription(`**${this.embedOptions.icons.bot} Bot status**\n` + botStatisticsEmbedString)
|
.setDescription(`**${this.embedOptions.icons.bot} Bot status**\n` + botStatisticsEmbedString)
|
||||||
.addFields(
|
.addFields(
|
||||||
{
|
{
|
||||||
name: `**${this.embedOptions.icons.queue} Queue status**`,
|
name: translator('statistics.queueStatus.title', {
|
||||||
|
icon: this.embedOptions.icons.queue
|
||||||
|
}),
|
||||||
value: playerStatisticsEmbedString
|
value: playerStatisticsEmbedString
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: `**${this.embedOptions.icons.server} System status**`,
|
name: translator('statistics.systemStatus.title', {
|
||||||
|
icon: this.embedOptions.icons.server
|
||||||
|
}),
|
||||||
value: systemStatusEmbedString
|
value: systemStatusEmbedString
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: `**${this.embedOptions.icons.discord} Discord status**`,
|
name: translator('statistics.discordStatus.title', {
|
||||||
|
icon: this.embedOptions.icons.discord
|
||||||
|
}),
|
||||||
value: discordStatusEmbedString
|
value: discordStatusEmbedString
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: `**${this.embedOptions.icons.bot} Dependencies**`,
|
name: translator('statistics.dependencies.title', {
|
||||||
|
icon: this.embedOptions.icons.bot
|
||||||
|
}),
|
||||||
value: dependenciesEmbedString
|
value: dependenciesEmbedString
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in new issue
Block a user