A Discord Bot connected to your Pterodactyl API.

fix: run lint fix

authored by cosmeak.dev and committed by

Cosmeak e55d9305 cc189c9d

+287 -287
+22 -22
bin/command.deploy.js
··· 9 9 const __dirname = path.dirname(__filename); 10 10 11 11 (async () => { 12 - const commands = []; 13 - const commandsPath = path.join(__dirname, "..", "src", "commands"); 14 - const commandFiles = fs.readdirSync(commandsPath).filter((file) => file.endsWith(".js")); 15 - for (const file of commandFiles) { 16 - const filePath = path.join(commandsPath, file); 17 - const command = await import(filePath); 18 - if (command.default?.data && command.default?.execute) { 19 - commands.push(command.default.data.toJSON()); 20 - } 21 - } 22 - const rest = new REST({ version: "10" }).setToken(process.env.BOT_TOKEN); 23 - try { 24 - console.log(`Started refreshing ${commands.length} application (/) commands`); 25 - const data = await rest.put( 26 - Routes.applicationGuildCommands(process.env.CLIENT_ID, process.env.GUILD_ID), 27 - { body: commands }, 28 - ); 29 - console.log(`Successfully reloaded ${data.length} application (/) commands.`); 30 - } 31 - catch (error) { 32 - console.error(error); 33 - } 12 + const commands = []; 13 + const commandsPath = path.join(__dirname, "..", "src", "commands"); 14 + const commandFiles = fs.readdirSync(commandsPath).filter((file) => file.endsWith(".js")); 15 + for (const file of commandFiles) { 16 + const filePath = path.join(commandsPath, file); 17 + const command = await import(filePath); 18 + if (command.default?.data && command.default?.execute) { 19 + commands.push(command.default.data.toJSON()); 20 + } 21 + } 22 + const rest = new REST({ version: "10" }).setToken(process.env.BOT_TOKEN); 23 + try { 24 + console.log(`Started refreshing ${commands.length} application (/) commands`); 25 + const data = await rest.put( 26 + Routes.applicationGuildCommands(process.env.CLIENT_ID, process.env.GUILD_ID), 27 + { body: commands }, 28 + ); 29 + console.log(`Successfully reloaded ${data.length} application (/) commands.`); 30 + } 31 + catch (error) { 32 + console.error(error); 33 + } 34 34 })();
+5 -5
src/commands/Backups.js
··· 1 1 import { SlashCommandBuilder } from "discord.js"; 2 2 3 3 export default { 4 - data: new SlashCommandBuilder() 5 - .setName("backups") 6 - .setDescription("Show all your backups"), 7 - async execute(interaction) { 4 + data: new SlashCommandBuilder() 5 + .setName("backups") 6 + .setDescription("Show all your backups"), 7 + async execute(interaction) { 8 8 9 - }, 9 + }, 10 10 };
+18 -18
src/commands/CreateBackup.js
··· 5 5 // config(); 6 6 7 7 export default { 8 - data: new SlashCommandBuilder() 9 - .setName("create-backup") 10 - .setDescription("Create a new backup for a server") 11 - .addStringOption((option) => 12 - option.setName("server-id") 13 - .setDescription("Your server identifier") 14 - .setRequired(true), 15 - ), 16 - async execute(interaction) { 17 - const serverId = interaction.options.get("server-id").value; 18 - const server = await fecthClientServerInfo(serverId); 19 - const embed = new EmbedBuilder() 20 - .setTitle(`Server: ${server.name}`) 21 - .setDescription("New embed for a serve") 22 - .setColor("Blurple") 23 - .setTimestamp(); 8 + data: new SlashCommandBuilder() 9 + .setName("create-backup") 10 + .setDescription("Create a new backup for a server") 11 + .addStringOption((option) => 12 + option.setName("server-id") 13 + .setDescription("Your server identifier") 14 + .setRequired(true), 15 + ), 16 + async execute(interaction) { 17 + const serverId = interaction.options.get("server-id").value; 18 + const server = await fecthClientServerInfo(serverId); 19 + const embed = new EmbedBuilder() 20 + .setTitle(`Server: ${server.name}`) 21 + .setDescription("New embed for a serve") 22 + .setColor("Blurple") 23 + .setTimestamp(); 24 24 25 - return interaction.reply({ embeds: [embed] }); 26 - }, 25 + return interaction.reply({ embeds: [embed] }); 26 + }, 27 27 };
+5 -5
src/commands/Help.js
··· 1 1 import { SlashCommandBuilder } from "discord.js"; 2 2 3 3 export default { 4 - data: new SlashCommandBuilder() 5 - .setName("help") 6 - .setDescription("Show all available commands"), 7 - async execute(interaction) { 4 + data: new SlashCommandBuilder() 5 + .setName("help") 6 + .setDescription("Show all available commands"), 7 + async execute(interaction) { 8 8 9 - }, 9 + }, 10 10 };
+30 -30
src/commands/Power.js
··· 2 2 import postServerPower from "../functions/postServerPower.js"; 3 3 4 4 export default { 5 - data: new SlashCommandBuilder() 6 - .setName("power") 7 - .setDescription("Provide a way to up or down a server") 8 - .addStringOption((option) => 9 - option.setName("server-id") 10 - .setDescription("Your server identifier") 11 - .setRequired(true), 12 - ) 13 - .addStringOption((option) => 14 - option.setName("state") 15 - .setDescription("Choose a state for your server") 16 - .setChoices( 17 - { name: "start", value: "start" }, 18 - { name: "stop", value: "stop" }, 19 - { name: "restart", value: "restart" }, 20 - { name: "kill", value: "kill" }, 21 - ) 22 - .setRequired(true), 23 - ), 24 - async execute(interaction) { 25 - const state = interaction.options.get("state").value; 26 - const id = interaction.options.get("server-id").value; 5 + data: new SlashCommandBuilder() 6 + .setName("power") 7 + .setDescription("Provide a way to up or down a server") 8 + .addStringOption((option) => 9 + option.setName("server-id") 10 + .setDescription("Your server identifier") 11 + .setRequired(true), 12 + ) 13 + .addStringOption((option) => 14 + option.setName("state") 15 + .setDescription("Choose a state for your server") 16 + .setChoices( 17 + { name: "start", value: "start" }, 18 + { name: "stop", value: "stop" }, 19 + { name: "restart", value: "restart" }, 20 + { name: "kill", value: "kill" }, 21 + ) 22 + .setRequired(true), 23 + ), 24 + async execute(interaction) { 25 + const state = interaction.options.get("state").value; 26 + const id = interaction.options.get("server-id").value; 27 27 28 - try { 29 - await postServerPower(id, state); 30 - } 31 - catch (error) { 32 - return interaction.reply({ content: error, ephemeral: true }); 33 - } 28 + try { 29 + await postServerPower(id, state); 30 + } 31 + catch (error) { 32 + return interaction.reply({ content: error, ephemeral: true }); 33 + } 34 34 35 - return interaction.reply(`**${state}** request as been sent to the server with success!`); 36 - }, 35 + return interaction.reply(`**${state}** request as been sent to the server with success!`); 36 + }, 37 37 };
+5 -5
src/commands/Safemode.js
··· 1 1 import { SlashCommandBuilder } from "discord.js"; 2 2 3 3 export default { 4 - data: new SlashCommandBuilder() 5 - .setName("safemode") 6 - .setDescription("Turn servers into safemode - Kill/Stop and backup servers"), 7 - async execute(interaction) { 4 + data: new SlashCommandBuilder() 5 + .setName("safemode") 6 + .setDescription("Turn servers into safemode - Kill/Stop and backup servers"), 7 + async execute(interaction) { 8 8 9 - }, 9 + }, 10 10 };
+10 -10
src/commands/SendCommand.js
··· 4 4 // config(); 5 5 6 6 export default { 7 - data: new SlashCommandBuilder() 8 - .setName("send") 9 - .setDescription("Send a command to your server") 10 - .addStringOption((option) => 11 - option.setName("server-id") 12 - .setDescription("Your server identifier") 13 - .setRequired(true), 14 - ), 15 - async execute(interaction) { 7 + data: new SlashCommandBuilder() 8 + .setName("send") 9 + .setDescription("Send a command to your server") 10 + .addStringOption((option) => 11 + option.setName("server-id") 12 + .setDescription("Your server identifier") 13 + .setRequired(true), 14 + ), 15 + async execute(interaction) { 16 16 17 - }, 17 + }, 18 18 };
+24 -24
src/commands/Server.js
··· 5 5 import convertMilliseconds from "../functions/convertMilliseconds.js"; 6 6 7 7 export default { 8 - data: new SlashCommandBuilder() 9 - .setName("server") 10 - .setDescription("Show informations about a server and control it") 11 - .addStringOption((option) => 12 - option.setName("server-id") 13 - .setDescription("Your server identifier") 14 - .setRequired(true), 15 - ), 16 - async execute(interaction) { 17 - const server = await fecthClientServerInfo(interaction.options.get("server-id").value); 18 - const embed = new EmbedBuilder() 19 - .setTitle(`${server.name} • ${server.identifier}`) 20 - .setDescription(server.description ? server.description : "No description...") 21 - .addFields( 22 - { name: "Status", value: (server.stats.current_state === "offline" ? "🔴 " : (server.stats.current_state === "running" ? "🟢 " : "🟠 ")) + capitalizeFirstLetter(server.stats.current_state), inline: true }, 23 - { name: "CPU", value: `${server.stats.resources.cpu_absolute}%`, inline: true }, 24 - { name: "Memory", value: bytesToSize(server.stats.resources.memory_bytes), inline: true }, 25 - { name: "Disk", value: bytesToSize(server.stats.resources.disk_bytes), inline: true }, 26 - { name: "Uptime", value: convertMilliseconds(server.stats.resources.uptime), inline: true }, 27 - ) 28 - .setColor(server.stats.current_state === "offline" ? "Red" : (server.stats.current_state === "running" ? "Green" : "Orange")) 29 - .setTimestamp(); 8 + data: new SlashCommandBuilder() 9 + .setName("server") 10 + .setDescription("Show informations about a server and control it") 11 + .addStringOption((option) => 12 + option.setName("server-id") 13 + .setDescription("Your server identifier") 14 + .setRequired(true), 15 + ), 16 + async execute(interaction) { 17 + const server = await fecthClientServerInfo(interaction.options.get("server-id").value); 18 + const embed = new EmbedBuilder() 19 + .setTitle(`${server.name} • ${server.identifier}`) 20 + .setDescription(server.description ? server.description : "No description...") 21 + .addFields( 22 + { name: "Status", value: (server.stats.current_state === "offline" ? "🔴 " : (server.stats.current_state === "running" ? "🟢 " : "🟠 ")) + capitalizeFirstLetter(server.stats.current_state) }, 23 + { name: "Uptime", value: convertMilliseconds(server.stats.resources.uptime) }, 24 + { name: "CPU", value: `${server.stats.resources.cpu_absolute}%`, inline: true }, 25 + { name: "Memory", value: bytesToSize(server.stats.resources.memory_bytes), inline: true }, 26 + { name: "Disk", value: bytesToSize(server.stats.resources.disk_bytes), inline: true }, 27 + ) 28 + .setColor(server.stats.current_state === "offline" ? "Red" : (server.stats.current_state === "running" ? "Green" : "Orange")) 29 + .setTimestamp(); 30 30 31 - return interaction.reply({ embeds: [embed] }); 32 - }, 31 + return interaction.reply({ embeds: [embed] }); 32 + }, 33 33 };
+22 -22
src/commands/Servers.js
··· 4 4 config(); 5 5 6 6 export default { 7 - data: new SlashCommandBuilder() 8 - .setName("servers") 9 - .setDescription("Show information about your servers"), 10 - async execute(interaction) { 11 - const response = await axios.get(`${process.env.PTERO_HOST}/api/client/`, { 12 - "headers": { 13 - "Accept": "application/json", 14 - "Authorization": `Bearer ${process.env.PTERO_TOKEN}`, 15 - }, 16 - }); 7 + data: new SlashCommandBuilder() 8 + .setName("servers") 9 + .setDescription("Show information about your servers"), 10 + async execute(interaction) { 11 + const response = await axios.get(`${process.env.PTERO_HOST}/api/client/`, { 12 + "headers": { 13 + "Accept": "application/json", 14 + "Authorization": `Bearer ${process.env.PTERO_TOKEN}`, 15 + }, 16 + }); 17 17 18 - console.log(response); 18 + console.log(response); 19 19 20 - let message = ""; 21 - response.data.data.forEach((server) => { 22 - message += `**${server.attributes.name}** [ ${server.attributes.identifier} ]\n\n`; 23 - }); 20 + let message = ""; 21 + response.data.data.forEach((server) => { 22 + message += `**${server.attributes.name}** [ ${server.attributes.identifier} ]\n\n`; 23 + }); 24 24 25 - const embed = new EmbedBuilder() 26 - .setTitle("Your servers") 27 - .setDescription(message) 28 - .setColor("Blurple") 29 - .setTimestamp(); 25 + const embed = new EmbedBuilder() 26 + .setTitle("Your servers") 27 + .setDescription(message) 28 + .setColor("Blurple") 29 + .setTimestamp(); 30 30 31 - return interaction.reply({ embeds: [embed] }); 32 - }, 31 + return interaction.reply({ embeds: [embed] }); 32 + }, 33 33 };
+5 -5
src/events/ClientReady.js
··· 4 4 config(); 5 5 6 6 export default { 7 - name: Events.ClientReady, 8 - once: true, 9 - async execute(client) { 10 - Logger.success(`Ready! Logged in as ${client.user.tag}`); 11 - }, 7 + name: Events.ClientReady, 8 + once: true, 9 + async execute(client) { 10 + Logger.success(`Ready! Logged in as ${client.user.tag}`); 11 + }, 12 12 };
+6 -6
src/events/Debug.js
··· 4 4 config(); 5 5 6 6 export default { 7 - name: Events.Debug, 8 - execute(debug) { 9 - if (process.env.BOT_MODE === "debug") { 10 - Logger.info(debug); 11 - } 12 - }, 7 + name: Events.Debug, 8 + execute(debug) { 9 + if (process.env.BOT_MODE === "debug") { 10 + Logger.info(debug); 11 + } 12 + }, 13 13 };
+4 -4
src/events/Error.js
··· 2 2 import { Logger } from "../services/Logger.js"; 3 3 4 4 export default { 5 - name: Events.Error, 6 - execute(error) { 7 - Logger.error(error); 8 - }, 5 + name: Events.Error, 6 + execute(error) { 7 + Logger.error(error); 8 + }, 9 9 };
+21 -21
src/events/InteractionCreate.js
··· 2 2 import { Logger } from "../services/Logger.js"; 3 3 4 4 export default { 5 - name: Events.InteractionCreate, 6 - async execute(interaction) { 7 - if (!interaction.isChatInputCommand()) return; 8 - const command = interaction.client.commands.get(interaction.commandName); 9 - if (!command) { 10 - Logger.error(`No command matching ${interaction.commandName} was found.`); 11 - return; 12 - } 13 - try { 14 - await command.execute(interaction); 15 - } 16 - catch (error) { 17 - Logger.error(error); 18 - if (interaction.replied || interaction.deferred) { 19 - await interaction.followUp({ content: "There was an error while executing this command!", ephemeral: true }); 20 - } 21 - else { 22 - await interaction.reply({ content: "There was an error while executing this command!", ephemeral: true }); 23 - } 24 - } 25 - }, 5 + name: Events.InteractionCreate, 6 + async execute(interaction) { 7 + if (!interaction.isChatInputCommand()) return; 8 + const command = interaction.client.commands.get(interaction.commandName); 9 + if (!command) { 10 + Logger.error(`No command matching ${interaction.commandName} was found.`); 11 + return; 12 + } 13 + try { 14 + await command.execute(interaction); 15 + } 16 + catch (error) { 17 + Logger.error(error); 18 + if (interaction.replied || interaction.deferred) { 19 + await interaction.followUp({ content: "There was an error while executing this command!", ephemeral: true }); 20 + } 21 + else { 22 + await interaction.reply({ content: "There was an error while executing this command!", ephemeral: true }); 23 + } 24 + } 25 + }, 26 26 };
+4 -4
src/events/Warn.js
··· 3 3 4 4 // When the client is ready, run this code (only once) 5 5 export default { 6 - name: Events.Warn, 7 - execute(warn) { 8 - Logger.warn(warn); 9 - }, 6 + name: Events.Warn, 7 + execute(warn) { 8 + Logger.warn(warn); 9 + }, 10 10 };
+5 -5
src/functions/bytesToSize.js
··· 1 1 export default (bytes) => { 2 - const sizes = ["Bytes", "KB", "MB", "GB", "TB"]; 3 - if (bytes === 0) return "n/a"; 4 - const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)), 10); 5 - if (i === 0) return `${bytes} ${sizes[i]})`; 6 - return `${(bytes / (1024 ** i)).toFixed(1)} ${sizes[i]}`; 2 + const sizes = ["Bytes", "KB", "MB", "GB", "TB"]; 3 + if (bytes === 0) return "n/a"; 4 + const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)), 10); 5 + if (i === 0) return `${bytes} ${sizes[i]})`; 6 + return `${(bytes / (1024 ** i)).toFixed(1)} ${sizes[i]}`; 7 7 };
+1 -1
src/functions/capitalizeFirstLetter.js
··· 1 1 export default (string) => { 2 - return string.charAt(0).toUpperCase() + string.slice(1); 2 + return string.charAt(0).toUpperCase() + string.slice(1); 3 3 };
+8 -8
src/functions/convertMilliseconds.js
··· 1 1 export default (ms) => { 2 - const days = Math.floor(ms / (24 * 60 * 60 * 1000)); 3 - const daysms = ms % (24 * 60 * 60 * 1000); 4 - const hours = Math.floor(daysms / (60 * 60 * 1000)); 5 - const hoursms = ms % (60 * 60 * 1000); 6 - const minutes = Math.floor(hoursms / (60 * 1000)); 7 - const minutesms = ms % (60 * 1000); 8 - const secondes = Math.floor(minutesms / 1000); 9 - return `${days}days ${hours}h ${minutes}min ${secondes}s`; 2 + const days = Math.floor(ms / (24 * 60 * 60 * 1000)); 3 + const daysms = ms % (24 * 60 * 60 * 1000); 4 + const hours = Math.floor(daysms / (60 * 60 * 1000)); 5 + const hoursms = ms % (60 * 60 * 1000); 6 + const minutes = Math.floor(hoursms / (60 * 1000)); 7 + const minutesms = ms % (60 * 1000); 8 + const secondes = Math.floor(minutesms / 1000); 9 + return `${days} days ${hours}h ${minutes}min ${secondes}s`; 10 10 };
+14 -14
src/functions/fetchClientServerInfo.js
··· 3 3 config(); 4 4 5 5 export default async (id) => { 6 - const headers = { 7 - "Accept": "application/json", 8 - "Content-Type": "application/json", 9 - "Authorization": `Bearer ${process.env.PTERO_TOKEN}`, 10 - }; 6 + const headers = { 7 + "Accept": "application/json", 8 + "Content-Type": "application/json", 9 + "Authorization": `Bearer ${process.env.PTERO_TOKEN}`, 10 + }; 11 11 12 - let response = await axios.get(`${process.env.PTERO_HOST}/api/client/servers/${id}`, { 13 - "headers": headers, 14 - }); 12 + let response = await axios.get(`${process.env.PTERO_HOST}/api/client/servers/${id}`, { 13 + "headers": headers, 14 + }); 15 15 16 - const server = response.data.attributes; 16 + const server = response.data.attributes; 17 17 18 - response = await axios.get(`${process.env.PTERO_HOST}/api/client/servers/${id}/resources`, { 19 - "headers": headers, 20 - }); 18 + response = await axios.get(`${process.env.PTERO_HOST}/api/client/servers/${id}/resources`, { 19 + "headers": headers, 20 + }); 21 21 22 - server.stats = response.data.attributes; 22 + server.stats = response.data.attributes; 23 23 24 - return server; 24 + return server; 25 25 };
+16 -16
src/functions/postServerPower.js
··· 3 3 config(); 4 4 5 5 export default async (id, signal) => { 6 - try { 7 - await axios.post(`${process.env.PTERO_HOST}/api/client/servers/${id}/power`, { 8 - "headers": { 9 - "Accept": "application/json", 10 - "Content-Type": "application/json", 11 - "Authorization": `Bearer ${process.env.PTERO_TOKEN}`, 12 - }, 13 - "body": { 14 - "signal": signal, 15 - }, 16 - }); 17 - } 18 - catch (error) { 19 - console.log(error.request.data.errors); 20 - throw "An error occured with the request to your API..."; 21 - } 6 + try { 7 + await axios.post(`${process.env.PTERO_HOST}/api/client/servers/${id}/power`, { 8 + "headers": { 9 + "Accept": "application/json", 10 + "Content-Type": "application/json", 11 + "Authorization": `Bearer ${process.env.PTERO_TOKEN}`, 12 + }, 13 + "body": { 14 + "signal": signal, 15 + }, 16 + }); 17 + } 18 + catch (error) { 19 + console.log(error.request.data.errors); 20 + throw "An error occured with the request to your API..."; 21 + } 22 22 };
+46 -46
src/services/Bot.js
··· 10 10 const __dirname = path.dirname(__filename); 11 11 12 12 class Bot { 13 - constructor() { 14 - // Set bot token 15 - this.token = process.env.BOT_TOKEN; 16 - // Create a new client instance 17 - this.client = new Client({ 18 - intents: [ 19 - GatewayIntentBits.Guilds, 20 - GatewayIntentBits.GuildMembers, 21 - GatewayIntentBits.GuildMessages, 22 - ], 23 - }); 24 - } 13 + constructor() { 14 + // Set bot token 15 + this.token = process.env.BOT_TOKEN; 16 + // Create a new client instance 17 + this.client = new Client({ 18 + intents: [ 19 + GatewayIntentBits.Guilds, 20 + GatewayIntentBits.GuildMembers, 21 + GatewayIntentBits.GuildMessages, 22 + ], 23 + }); 24 + } 25 25 26 - async run() { 27 - // Log in to Discord with your token 28 - await this.client.login(this.token); 29 - // Launch registration of all slash commands 30 - await this.registerCommands(); 31 - // Launch registration of events 32 - await this.registerEvents(); 33 - } 26 + async run() { 27 + // Log in to Discord with your token 28 + await this.client.login(this.token); 29 + // Launch registration of all slash commands 30 + await this.registerCommands(); 31 + // Launch registration of events 32 + await this.registerEvents(); 33 + } 34 34 35 - async registerCommands() { 36 - // Create a new collection instance for commands 37 - this.client.commands = new Collection(); 38 - const commandsPath = path.join(__dirname, "..", "commands"); 39 - const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith(".js")); 40 - for (const file of commandFiles) { 41 - const filePath = path.join(commandsPath, file); 42 - let command = await import(filePath); 43 - command = command.default; 44 - // Set a new item in the Collection with the key as the command name and the value as the exported module 45 - if (command?.data && command?.execute) this.client.commands.set(command.data.name, command); 46 - else Logger.warn(`The command at ${filePath} is missing a required "data" or "execute" property.`); 47 - } 48 - } 35 + async registerCommands() { 36 + // Create a new collection instance for commands 37 + this.client.commands = new Collection(); 38 + const commandsPath = path.join(__dirname, "..", "commands"); 39 + const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith(".js")); 40 + for (const file of commandFiles) { 41 + const filePath = path.join(commandsPath, file); 42 + let command = await import(filePath); 43 + command = command.default; 44 + // Set a new item in the Collection with the key as the command name and the value as the exported module 45 + if (command?.data && command?.execute) this.client.commands.set(command.data.name, command); 46 + else Logger.warn(`The command at ${filePath} is missing a required "data" or "execute" property.`); 47 + } 48 + } 49 49 50 - async registerEvents() { 51 - const eventsPath = path.join(__dirname, "..", "events"); 52 - const eventsFiles = fs.readdirSync(eventsPath).filter((file) => file.endsWith(".js")); 50 + async registerEvents() { 51 + const eventsPath = path.join(__dirname, "..", "events"); 52 + const eventsFiles = fs.readdirSync(eventsPath).filter((file) => file.endsWith(".js")); 53 53 54 - for (const file of eventsFiles) { 55 - const filePath = path.join(eventsPath, file); 56 - let event = await import(filePath); 57 - event = event.default; 58 - if (event.once) this.client.once(event.name, (...args) => event.execute(...args)); 59 - else this.client.on(event.name, (...args) => event.execute(...args)); 60 - } 61 - } 62 - }; 54 + for (const file of eventsFiles) { 55 + const filePath = path.join(eventsPath, file); 56 + let event = await import(filePath); 57 + event = event.default; 58 + if (event.once) this.client.once(event.name, (...args) => event.execute(...args)); 59 + else this.client.on(event.name, (...args) => event.execute(...args)); 60 + } 61 + } 62 + } 63 63 64 64 export { Bot };
+16 -16
src/services/Logger.js
··· 1 1 import { yellow, gray, red, cyan, green, bold } from "colorette"; 2 2 3 3 class Logger { 4 - static log(string) { 5 - return console.log(gray(string)); 6 - } 7 - static warn(string) { 8 - return console.warn(yellow(`${bold("[WARN]")} ${string}`)); 9 - } 10 - static error(string) { 11 - return console.error(red(`${bold("[ERROR]")} ${string}`)); 12 - } 13 - static info(string) { 14 - return console.info(cyan(`${bold("[INFO]")} ${string}`)); 15 - } 16 - static success(string) { 17 - return console.log(green(string)); 18 - } 19 - }; 4 + static log(string) { 5 + return console.log(gray(string)); 6 + } 7 + static warn(string) { 8 + return console.warn(yellow(`${bold("[WARN]")} ${string}`)); 9 + } 10 + static error(string) { 11 + return console.error(red(`${bold("[ERROR]")} ${string}`)); 12 + } 13 + static info(string) { 14 + return console.info(cyan(`${bold("[INFO]")} ${string}`)); 15 + } 16 + static success(string) { 17 + return console.log(green(string)); 18 + } 19 + } 20 20 21 21 export { Logger };