50 lines
No EOL
1.3 KiB
JavaScript
50 lines
No EOL
1.3 KiB
JavaScript
const Discord = require('discord.js');
|
|
const botConfig = require('./botconfig.json');
|
|
const client = new Discord.Client();
|
|
const fs = require("fs");
|
|
|
|
client.commands = new Discord.Collection();
|
|
|
|
fs.readdir("./commands/", (err, files) => {
|
|
if(err) console.log(err);
|
|
var jsFiles = files.filter(f => f.split(".").pop() === "js");
|
|
if(jsFiles.length <= 0) {
|
|
console.log("No files found");
|
|
return;
|
|
}
|
|
jsFiles.forEach((f, i) =>{
|
|
var fileGet = require(`./commands/${f}`);
|
|
console.log(`Command Loaded > ${f}`);
|
|
|
|
client.commands.set(fileGet.help.name, fileGet)
|
|
});
|
|
});
|
|
|
|
|
|
client.on("ready", async () => {
|
|
console.log(`Logged in as ${client.user.tag}!`);
|
|
client.user.setStatus('available')
|
|
client.user.setPresence({
|
|
game: {
|
|
name: 'MC-Hostingwijzer.nl',
|
|
type: "PLAYING",
|
|
}
|
|
});
|
|
});
|
|
|
|
client.on("message", async message => {
|
|
|
|
if(message.author.bot) return;
|
|
if(message.channel.type === "dm") return;
|
|
var prefix = botConfig.prefix;
|
|
if (!message.content.startsWith(prefix)) return;
|
|
var messageArray = message.content.split(" ");
|
|
var command = messageArray[0];
|
|
var arguments = messageArray.slice(1);
|
|
var commands = client.commands.get(command.slice(prefix.length));
|
|
if (commands) commands.run(client,message, arguments)
|
|
});
|
|
|
|
|
|
|
|
client.login(botConfig.token); |