48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
const { Client, Intents, Collection } = require('discord.js');
|
|
|
|
const fs = require('fs');
|
|
|
|
let bot = new Client({
|
|
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
|
|
disableEveryone: true
|
|
});
|
|
|
|
bot.commands = new Collection();
|
|
|
|
/* ===============
|
|
* File Import *
|
|
=============== */
|
|
fs.readdir('./Plugins/Commands/', (err, files) => {
|
|
if (err) console.log(err);
|
|
let jsfile = files.filter(f => f.split(".").pop() == "js")
|
|
if (jsfile.length <= 0) {
|
|
console.log("[sys-cmd]: Befehle konnten nicht gefunden werden");
|
|
return;
|
|
}
|
|
|
|
jsfile.forEach((f, i) => {
|
|
let props = require(`./Plugins/Commands/${f}`);
|
|
console.log(`[sys-cmd]: ${f} [loaded]`);
|
|
bot.commands.set(props.help.name, props);
|
|
});
|
|
});
|
|
|
|
|
|
bot.on('messageCreate', message => {
|
|
if (message.author.bot || message.channel.type === "DM") return;
|
|
|
|
//Command Handler & Message Handler
|
|
let prefix = "!";
|
|
|
|
if (!message.content.startsWith(prefix)) return;
|
|
|
|
let messageArray = message.content.split(" ");
|
|
let cmd = messageArray[0];
|
|
let args = messageArray.slice(1);
|
|
let commandfile = bot.commands.get(cmd.slice(prefix.length));
|
|
let settings = null;
|
|
|
|
if (commandfile) commandfile.run(bot, message, args);
|
|
});
|
|
|
|
bot.login(require("./json/token.json").token) |