-
Notifications
You must be signed in to change notification settings - Fork 3
/
stark.js
26 lines (22 loc) · 1.21 KB
/
stark.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const { Client, Collection } = require("discord.js");
const client = global.client = new Client({ fetchAllMembers: true });
const config = require("./config.json");
const mongoose = require("mongoose")
const fs = require("fs");
client.commands = new Collection();
client.aliases = new Collection();
fs.readdirSync("./commands").filter(file => file.endsWith(".js")).forEach(file => {
let command = require(`./commands/${file}`);
client.commands.set(command.conf.command, command);
console.log(`[Command] ${file.replace(".js", "")} command loaded.`);
command.conf.aliases.forEach(aliases => {
client.aliases.set(aliases, command)
});
});
fs.readdirSync("./events").filter(file => file.endsWith(".js")).forEach(file => {
let event = require(`./events/${file}`);
client.on(event.conf.event, event.execute);
console.log(`[Event] ${file.replace(".js", "")} event loaded.`);
});
mongoose.connect(``, {useNewUrlParser: true, useUnifiedTopology: true}).then(c => console.log(`MongoDB connected!`)).catch(err => console.error(`Failed to connect to MongoDB!`));
client.login(config.Token).then(c => console.log(`Logged in as ${client.user.tag}!`)).catch(err => console.error(`Failed to login to the bot!`));