-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
55 lines (41 loc) · 1.64 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
const fs = require('fs');
// jeśli nie ma config.json, tworzy na podstawie config_example
if (!fs.existsSync('config/config.json')){
fs.copyFile("config/config_example.json", "config/config.json", (err2)=>{})
}
const cfg = require('./config/config.json')
const token = cfg.token
// domyślny token
if (token=="token"){ console.log("check config/config.json"); return }
// jeśli nie ma dmList to tworzy pusty plik
if (!fs.existsSync('./data/dmList.json')){fs.writeFileSync('./data/dmList.json', '{}')}
var dm_list = require('./data/dmList.json');
const tableData = require('./utils/tableData.js');
const pngCreate = require('./utils/pngCreate.js');
const {Client, GatewayIntentBits, Partials} = require("discord.js");
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.MessageContent,
],
partials: [Partials.Message, Partials.Channel]
});
// przygotowanie komend
var commands = {}
for(let a of fs.readdirSync('./commands')){
commands[a.replace('.js', '')] = require('./commands/' + a)
}
require('./events/interaction.js')({client, cmd:commands, dm_list, tableData, pngCreate})
// Main
client.on("ready", async () => {
process.stdout.write(` ${client.user.username} Logged in`);
//console.log(client.user.username + " Logged in");
// skrypt co przerwe wysyła powiadomienie o lekcji
require('./utils/alertLekcjeLoop.js')(client, dm_list, tableData)
// tworzenie komend aplikacji
require('./events/interactionCreate.js')(client)
});
client.on('error', console.error);
client.login(token)