-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
71 lines (58 loc) · 1.92 KB
/
index.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const Discord = require("discord.js");
const client = new Discord.Client();
const settings = require("./settings.json");
const fs = require("fs");
const { createLogger, format, transports } = require("winston");
const { combine, splat, timestamp, printf } = format;
const logger = createLogger({
format: combine(
splat(),
timestamp(),
printf(({ level, message, timestamp, ...metadata }) => {
let msg = `[${timestamp}] [${level}]: ${message} `;
if (Object.keys(metadata).length) msg += JSON.stringify(metadata);
return msg;
})
),
transports: [
new transports.Console(),
new transports.File({
filename: "error.log",
level: "error",
}),
new transports.File({ filename: "chalkbot.log" }),
],
});
client.logger = logger;
client.commands = new Discord.Collection();
client.kretacommands = new Discord.Collection();
client.json = require("./loginDatas.json");
logger.info("Chalkbot indul...");
fs.readdir("./commands/", (err, files) => {
logger.info(`${files.length} Kréta-parancs betöltése...`);
files.forEach((f) => {
let props = require(`./commands/${f}`);
let commandName = f.split(".")[0];
client.kretacommands.set(commandName, props);
logger.info(`${f} betöltve!`);
});
});
fs.readdir("./notkretaCommands/", (err, files) => {
logger.info(`${files.length} nem-Kréta parancs betöltése...`);
files.forEach((f) => {
let props = require(`./notkretaCommands/${f}`);
let commandName = f.split(".")[0];
client.commands.set(commandName, props);
logger.info(`${f} betöltve!`);
});
});
fs.readdir("./events/", (err, files) => {
logger.info(`${files.length} esemény betöltése...`);
files.forEach((f) => {
let eventFunction = require(`./events/${f}`);
let eventName = f.split(".")[0];
client.on(eventName, (...arg) => eventFunction.run(client, ...arg));
logger.info(`${f} betöltve!`);
});
});
client.login(settings.token);