added frankenbot
This commit is contained in:
48
bot/index.js
Normal file
48
bot/index.js
Normal file
@@ -0,0 +1,48 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user