From 986f766e8e14260bde8d7432738c199a12f235c5 Mon Sep 17 00:00:00 2001 From: M_Viper Date: Wed, 7 Feb 2024 14:42:01 +0000 Subject: [PATCH] Dateien nach "handlers" hochladen --- handlers/command.js | 36 ++++++++++++++++++++++++++++++++++++ handlers/giveaways.json | 1 + handlers/ready.js | 8 ++++++++ 3 files changed, 45 insertions(+) create mode 100644 handlers/command.js create mode 100644 handlers/giveaways.json create mode 100644 handlers/ready.js diff --git a/handlers/command.js b/handlers/command.js new file mode 100644 index 0000000..324e64c --- /dev/null +++ b/handlers/command.js @@ -0,0 +1,36 @@ +const { readdirSync } = require("fs"); + +const ascii = require("ascii-table"); + +// Create a new Ascii table +let table = new ascii("Commands"); +table.setHeading("Command", "Load status"); + +module.exports = (client) => { + // Read every commands subfolder + readdirSync("./commands/").forEach(dir => { + // Filter so we only have .js command files + const commands = readdirSync(`./commands/${dir}/`).filter(file => file.endsWith(".js")); + + // Loop over the commands, and add all of them to a collection + // If there's no name found, prevent it from returning an error, + // By using a cross in the table we made. + for (let file of commands) { + let pull = require(`../commands/${dir}/${file}`); + + if (pull.name) { + client.commands.set(pull.name, pull); + table.addRow(file, '✅'); + } else { + table.addRow(file, `❌ -> es fehlt ein help.name oder help.name ist kein String.`); + continue; + } + + // If there's an aliases key, read the aliases. + if (pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach(alias => client.aliases.set(alias, pull.name)); + } + }); + + // Log the table + console.log(table.toString()); +} \ No newline at end of file diff --git a/handlers/giveaways.json b/handlers/giveaways.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/handlers/giveaways.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/handlers/ready.js b/handlers/ready.js new file mode 100644 index 0000000..910fa85 --- /dev/null +++ b/handlers/ready.js @@ -0,0 +1,8 @@ +const { default_prefix } = require('../config'); +module.exports = async bot => { + console.log(`${bot.user.username} ist ab sofort verfügbar!`) + let totalUsers = bot.guilds.cache.reduce((acc, value) => acc + value.memberCount, 0) + var activities = [ `${bot.guilds.cache.size} servers`, `${totalUsers} users!` ], i = 0; + setInterval(() => bot.user.setActivity(`${default_prefix}help | ${activities[i++ % activities.length]}`, { type: "WATCHING" }),50000) + +}; \ No newline at end of file