mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 06:28:53 +00:00
feat!: Updated command folder structure for new command handler
This commit is contained in:
1 parent
3da8275359
commit
421734be26
19 files changed
+122
-120
No files matched your search
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,62 @@
|
||||
const path = require('node:path');
|
||||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
const {
|
||||
embedColors,
|
||||
embedIcons,
|
||||
systemServerGuildIds
|
||||
} = require(path.resolve('./config.json'));
|
||||
|
||||
module.exports = {
|
||||
isSystemCommand: true,
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('guilds')
|
||||
.setDescription('Show list of guilds where bot is added.')
|
||||
.setDMPermission(false),
|
||||
run: async ({ interaction, client }) => {
|
||||
if (!systemServerGuildIds.includes(interaction.guildId)) {
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedIcons.warning} Oops!**\nNo permission to execute this command.\n\nThe command \`${interaction.commandName}\` cannot be executed in this server.`
|
||||
)
|
||||
.setColor(embedColors.colorWarning)
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
let guildsList = client.guilds.cache
|
||||
.map((guild) => {
|
||||
return {
|
||||
name: guild.name,
|
||||
memberCount: guild.memberCount
|
||||
};
|
||||
})
|
||||
.sort((a, b) => b.memberCount - a.memberCount)
|
||||
.slice(0, 50)
|
||||
.map(
|
||||
(guild, index) =>
|
||||
`${index + 1}. \`${guild.name} (#${guild.memberCount})\``
|
||||
)
|
||||
.join('\n');
|
||||
|
||||
let embedDescription = `**${embedIcons.bot} ${
|
||||
client.guilds.cache.size < 50
|
||||
? `Top ${client.guilds.cache.size} guilds`
|
||||
: 'Top 50 guilds'
|
||||
} by member count (${client.guilds.cache.size} total)**\n${guildsList}`;
|
||||
|
||||
if (embedDescription.length >= 4000) {
|
||||
embedDescription = `${embedDescription.slice(0, 3996)}...`;
|
||||
}
|
||||
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(embedDescription)
|
||||
.setColor(embedColors.colorInfo)
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,85 @@
|
||||
const path = require('node:path');
|
||||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
const { useQueue } = require('discord-player');
|
||||
const {
|
||||
embedColors,
|
||||
embedIcons,
|
||||
systemServerGuildIds
|
||||
} = require(path.resolve('./config.json'));
|
||||
const osu = require('node-os-utils');
|
||||
const packageJson = require(path.resolve('./package.json'));
|
||||
|
||||
module.exports = {
|
||||
isSystemCommand: true,
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('status')
|
||||
.setDescription('Show bot status.')
|
||||
.setDMPermission(false),
|
||||
run: async ({ interaction, client }) => {
|
||||
if (!systemServerGuildIds.includes(interaction.guildId)) {
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedIcons.warning} Oops!**\nNo permission to execute this command.\n\nThe command \`${interaction.commandName}\` cannot be executed in this server.`
|
||||
)
|
||||
.setColor(embedColors.colorWarning)
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
const interactionLatency = Date.now() - interaction.createdTimestamp;
|
||||
const uptimeInSeconds = process.uptime();
|
||||
let uptimeDate = new Date(0);
|
||||
uptimeDate.setSeconds(uptimeInSeconds.toFixed(0));
|
||||
const uptimeString = uptimeDate.toISOString().substring(11, 19);
|
||||
const nodeProcessMemUsageInMb = (
|
||||
process.memoryUsage().heapUsed /
|
||||
1024 /
|
||||
1024
|
||||
).toFixed(2);
|
||||
const usedMemoryInMB = Math.ceil(
|
||||
(await osu.mem.info()).usedMemMb
|
||||
).toLocaleString('en-US');
|
||||
const cpuUsage = await osu.cpu.usage();
|
||||
const cpuCores = await osu.cpu.count();
|
||||
const platform = await osu.os.platform();
|
||||
const releaseVersion = packageJson.version;
|
||||
const discordJsVersion = packageJson.dependencies['discord.js'];
|
||||
const discordPlayerVersion = packageJson.dependencies['discord-player'];
|
||||
const discordApiLatency = client.ws.ping;
|
||||
let activeVoiceConnections = 0;
|
||||
client.guilds.cache.forEach((guild) => {
|
||||
const queue = useQueue(guild.id);
|
||||
|
||||
if (queue) {
|
||||
activeVoiceConnections++;
|
||||
}
|
||||
});
|
||||
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedIcons.bot} System and bot status**\n` +
|
||||
`Uptime: \`${uptimeString}\`\n` +
|
||||
`Platform: \`${platform}\`\n` +
|
||||
`CPU cores: \`${cpuCores}\`\n` +
|
||||
`CPU usage: \`${cpuUsage}%\`\n` +
|
||||
`Node.js mem usage: \`${nodeProcessMemUsageInMb} MB\`\n` +
|
||||
`System mem usage: \`${usedMemoryInMB} MB\`\n` +
|
||||
`Bot version: \`v${releaseVersion}\`\n` +
|
||||
`Node.js version: \`${process.version}\`\n` +
|
||||
`Discord.js version: \`${discordJsVersion}\`\n` +
|
||||
`Discord-player version: \`${discordPlayerVersion}\`\n` +
|
||||
`Discord API latency: \`${discordApiLatency} ms\`\n` +
|
||||
`Interaction latency: \`${interactionLatency} ms\`\n` +
|
||||
`Active voice connections: \`${activeVoiceConnections}\`\n` +
|
||||
`Joined guilds: \`${client.guilds.cache.size}\``
|
||||
)
|
||||
.setColor(embedColors.colorInfo)
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user