Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/deploy-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require('fs');
const path = require('path');

const commands = [];
const commandsPath = path.join(__dirname, 'commands');
const commandsPath = path.join(__dirname, 'slashcommands');
const commandFiles = fs.readdirSync(commandsPath).filter(f => f.endsWith('.js'));

for (const file of commandFiles) {
Expand Down
34 changes: 23 additions & 11 deletions src/slashcommands/uptime.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,37 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('uptime')
.setDescription('Display bot uptime'),
.setDescription('Displays how long the bot has been running.'),

async execute(interaction) {
try {
await interaction.deferReply();
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 uptime = process.uptime();
const hours = Math.floor(uptime / 3600);
const minutes = Math.floor((uptime % 3600) / 60);
const seconds = Math.floor(uptime % 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()
.setTitle('Bot Uptime')
.setDescription(`\`\`\`${hours}h ${minutes}m ${seconds}s\`\`\``)
.setColor('Green');
.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.editReply({ embeds: [embed] });
await interaction.reply({ embeds: [embed] });
} catch (error) {
console.error('Uptime command error:', error);
await interaction.editReply({
await interaction.reply({
content: 'Failed to fetch uptime. Please try again.',
ephemeral: true,
});
Expand Down