-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
index.js
82 lines (71 loc) · 2.3 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
72
73
74
75
76
77
78
79
80
81
82
const fs = require("fs");
const Discord = require('discord.js');
const Canvas = require('canvas');
const request = require("request");
const config = require("./config.json");
require('dotenv').config();
const TicTacToe = require('discord-tictactoe');
const { fips } = require("crypto");
const bot = new Discord.Client({ ws: { intents: Discord.Intents.ALL } });
bot.aliases = new Discord.Collection();
bot.dsd = new Discord.Collection();
bot.admin = new Discord.Collection();
bot.newbie = new Discord.Collection();
bot.misc = new Discord.Collection();
//exports
// add stuff you need from the main file into this object
// then use
/*
const index = require('./index');
const something = index.something;
*/
module.exports = {
client: bot,
};
// add events by using this format
/*
module.exports = parameter => {
code
}
module.exports.help = {
event: 'EVENTNAME
}
*/
fs.readdir('./events', (err, files) => {
if (err) return console.log(err);
let jsFiles = files.filter(file => file.split('.').pop() === 'js');
jsFiles.forEach(file => {
const prop = require(`./events/${file}`);
bot.on(prop.help.event, prop);
});
});
//commands
//add commands by either adding them into the folders, or create a new folder.
//When adding new folders, the folders must match up with the collections unless there is no collection in which you have to edit line number 66 and add that folder
fs.readdir('./commands/', (err, files) => {
const folders = files.filter(item => !item.includes('.'));
folders.forEach(folder => {
fs.readdir(`./commands/${folder}`, (er, f) => {
const jsFiles = f.filter(file => file.split('.').pop() === 'js');
if (jsFiles.length <= 0) {
console.log(`${folder} conversions couldn't load`);
return;
}
console.log(`loading ${jsFiles.length} ${folder} commands...`);
jsFiles.forEach(singleFile => {
let props = require(`./commands/${folder}/${singleFile}`);
//console.log(`${singleFile} loaded`);
bot[folder].set(props.help.name, props);
props.help.aliases.forEach(alias => {
bot.aliases.set(alias, props.help.name);
});
});
});
});
});
//from the package TicTackToe for the game tictactoe
new TicTacToe({
language: 'en',
command: '*ttt'
}, bot);
bot.login(process.env.TOKEN);