What
Implement /uptime slash command showing bot runtime, process info, and memory usage.
Why
- User value: Server admins want to monitor bot health and stability
- Educational: Demonstrates
process.uptime(), process.memoryUsage(), and dynamic embed fields
- Completeness: Pairs with
/ping for basic bot diagnostics
Implementation Reference
Command exists in PR #8 but needs issue tracking. Implementation:
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('uptime')
.setDescription('Displays how long the bot has been running.'),
async execute(interaction) {
const totalSeconds = process.uptime();
const days = Math.floor(totalSeconds / (3600 * 24));
const hours = Math.floor((totalSeconds % (3600 * 24)) / 3600);
const minutes = Math.floor((totalSeconds % 3600) / 60);
const seconds = Math.floor(totalSeconds % 60);
const uptimeString = [];
if (days > 0) uptimeString.push(`**${days}** day${days === 1 ? '' : 's'}`);
if (hours > 0) uptimeString.push(`**${hours}** hour${hours === 1 ? '' : 's'}`);
if (minutes > 0) uptimeString.push(`**${minutes}** minute${minutes === 1 ? '' : 's'}`);
if (seconds > 0 || uptimeString.length === 0) uptimeString.push(`**${seconds}** second${seconds === 1 ? '' : 's'}`);
const embed = new EmbedBuilder()
.setColor(0x00FFAB)
.setTitle('⏱️ Bot Uptime')
.setDescription(`The bot has been online for:\n${uptimeString.join(', ')}`)
.addFields(
{ name: '🚀 Process ID', value: `\`${process.pid}\``, inline: true },
{ name: '💻 Memory Usage', value: `\`${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB\``, inline: true }
)
.setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: interaction.user.displayAvatarURL() })
.setTimestamp();
await interaction.reply({ embeds: [embed] });
},
};
Acceptance Criteria
Labels
enhancement
good first issue
help wanted
What
Implement
/uptimeslash command showing bot runtime, process info, and memory usage.Why
process.uptime(),process.memoryUsage(), and dynamic embed fields/pingfor basic bot diagnosticsImplementation Reference
Command exists in PR #8 but needs issue tracking. Implementation:
Acceptance Criteria
src/slashcommands/uptime.jsnpm run deployLabels
enhancementgood first issuehelp wanted