Update Bot (j'ai plus le repo sur GitHub)

Qui c'est la conne qui a delete le repo sur GitHub? C'EST MOIIIII
This commit is contained in:
2026-02-09 14:36:26 +01:00
parent eab4419e12
commit ad2014b7b2
586 changed files with 58986 additions and 25205 deletions

View File

@@ -1,65 +1,54 @@
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
const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require('discord.js');
const { formatUptime } = require('../../utils/helpers');
const { colors } = require('../../utils/constants');
function getOS() {
const platform = os.platform(); // ex: win32, linux
const release = os.release(); // version du kernel / OS
const platform = os.platform();
const release = os.release();
switch (platform) {
case "win32":
return `Windows ${release}`;
case "darwin":
return `macOS ${release}`;
case "linux":
case 'win32': return `Windows ${release}`;
case 'darwin': return `macOS ${release}`;
case 'linux':
try {
const data = fs.readFileSync("/etc/os-release", "utf8");
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}`;
} 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'),
.setDescription('Voir l\'infrastructure du bot')
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
async execute(interaction) {
const cpuInfo = os.cpus()[0].model;
const cpuCores = os.cpus().length;
const totalRAM = (os.totalmem() / (1024 ** 3)).toFixed(2);
const freeRAM = (os.freemem() / (1024 ** 3)).toFixed(2);
const usedRAM = (totalRAM - freeRAM).toFixed(2);
const ramUsagePercent = ((usedRAM / totalRAM) * 100).toFixed(1);
const uptime = os.uptime();
const embed = new EmbedBuilder()
.setTitle('Infrastructure du bot')
.setColor('Blue')
.setTitle('🖥️ Infrastructure du Bot')
.setColor(colors.info)
.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 }
{ name: '💻 CPU', value: `${cpuInfo}\n${cpuCores} cœurs`, inline: true },
{ name: '💾 RAM', value: `${usedRAM} Go / ${totalRAM} Go\n${ramUsagePercent}% utilisée`, inline: true },
{ name: '🖥️ OS', value: getOS(), inline: true },
{ name: '⏱️ Uptime Système', value: formatUptime(uptime), inline: true },
{ name: '📊 Node.js', value: process.version, inline: true },
{ name: '📦 Architecture', value: os.arch(), inline: true }
)
.setFooter({ text: interaction.client.user.username, iconURL: interaction.client.user.displayAvatarURL() })
.setTimestamp();
await interaction.reply({ embeds: [embed] });
}
};
},
};

View File

@@ -1,37 +1,40 @@
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
const { SlashCommandBuilder, PermissionFlagsBits, MessageFlags } = require('discord.js');
module.exports = {
category: 'dev',
data: new SlashCommandBuilder()
.setName('reload')
.setDescription('Reloads a command.')
.setDescription('Recharge une commande.')
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addStringOption(option =>
option.setName('command')
.setDescription('The command to reload.')
.setDescription('La commande à recharger.')
.setRequired(true)),
async execute(interaction) {
if (!interaction.member.permissions.has(PermissionFlagsBits.Administrator)) {
return interaction.reply({ content: '❌ Only administrators can use this command.', embeds: [embed] });
return interaction.reply({ content: '❌ Seuls les administrateurs peuvent utiliser cette commande.', flags: MessageFlags.Ephemeral });
}
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] });
return interaction.reply({ content: `❌ Aucune commande nommée \`${commandName}\` n'a été trouvée !`, flags: MessageFlags.Ephemeral });
}
delete require.cache[require.resolve(`../${command.category}/${command.data.name}.js`)];
try {
const newCommand = require(`../${command.category}/${command.data.name}.js`);
// Supprimer du cache
const commandPath = `../${command.category}/${command.data.name}.js`;
delete require.cache[require.resolve(commandPath)];
// Recharger
const newCommand = require(commandPath);
interaction.client.commands.set(newCommand.data.name, newCommand);
await interaction.reply({ content: `✅ Command \`${newCommand.data.name}\` was reloaded!`, });
await interaction.reply({ content: `✅ Commande \`${newCommand.data.name}\` rechargée avec succès !`, flags: MessageFlags.Ephemeral });
} catch (error) {
console.error(error);
await interaction.reply({ content: `❌ Error while reloading \`${command.data.name}\`:\n\`${error.message}\``, embeds: [embed] });
await interaction.reply({ content: `❌ Erreur lors du rechargement de \`${command.data.name}\`:\n\`${error.message}\``, flags: MessageFlags.Ephemeral });
}
},
};
};