Update bot

This commit is contained in:
Syxpi
2025-10-18 23:20:19 +02:00
commit c590dd1c64
4459 changed files with 650347 additions and 0 deletions

65
commands/dev/infra.js Normal file
View File

@@ -0,0 +1,65 @@
const os = require('os');
const fs = require('fs');
const cpuInfo = os.cpus()[0].model; // modèle du CPU
const cpuCores = os.cpus().length; // nombre de coeurs
const totalRAM = (os.totalmem() / (1024 ** 3)).toFixed(2); // en Go
const freeRAM = (os.freemem() / (1024 ** 3)).toFixed(2); // en Go
function getOS() {
const platform = os.platform(); // ex: win32, linux
const release = os.release(); // version du kernel / OS
switch (platform) {
case "win32":
return `Windows ${release}`;
case "darwin":
return `macOS ${release}`;
case "linux":
try {
const data = fs.readFileSync("/etc/os-release", "utf8");
const match = data.match(/PRETTY_NAME="(.+)"/);
if (match) return `${match[1]} (kernel ${release})`;
} catch {
return `Linux ${release}`;
}
default:
return `${platform} ${release}`;
}
}
const uptime = os.uptime(); // en secondes
function formatUptime(seconds) {
const days = Math.floor(seconds / 86400);
const hours = Math.floor((seconds % 86400) / 3600);
const minutes = Math.floor((seconds % 3600) / 60);
const secs = Math.floor(seconds % 60);
return `${days}j ${hours}h ${minutes}m ${secs}s`;
}
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
category: 'dev',
data: new SlashCommandBuilder()
.setName('infra')
.setDescription('Voir linfrastructure du bot'),
async execute(interaction) {
const embed = new EmbedBuilder()
.setTitle('Infrastructure du bot')
.setColor('Blue')
.addFields(
{ name: 'CPU', value: `${cpuInfo} (${cpuCores} coeurs)`, inline: true },
{ name: 'RAM', value: `${freeRAM} Go libres / ${totalRAM} Go totaux`, inline: true },
{ name: 'OS', value: getOS(), inline: true },
{ name: 'Uptime', value: formatUptime(uptime), inline: true }
)
.setTimestamp();
await interaction.reply({ embeds: [embed] });
}
};

37
commands/dev/reload.js Normal file
View File

@@ -0,0 +1,37 @@
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
module.exports = {
category: 'dev',
data: new SlashCommandBuilder()
.setName('reload')
.setDescription('Reloads a command.')
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addStringOption(option =>
option.setName('command')
.setDescription('The command to reload.')
.setRequired(true)),
async execute(interaction) {
if (!interaction.member.permissions.has(PermissionFlagsBits.Administrator)) {
return interaction.reply({ content: '❌ Only administrators can use this command.', embeds: [embed] });
}
const commandName = interaction.options.getString('command', true).toLowerCase();
const command = interaction.client.commands.get(commandName);
if (!command) {
return interaction.reply({ content: `There is no command with name \`${commandName}\`!`, embeds: [embed] });
}
delete require.cache[require.resolve(`../${command.category}/${command.data.name}.js`)];
try {
const newCommand = require(`../${command.category}/${command.data.name}.js`);
interaction.client.commands.set(newCommand.data.name, newCommand);
await interaction.reply({ content: `✅ Command \`${newCommand.data.name}\` was reloaded!`, });
} catch (error) {
console.error(error);
await interaction.reply({ content: `❌ Error while reloading \`${command.data.name}\`:\n\`${error.message}\``, embeds: [embed] });
}
},
};