-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
72 lines (65 loc) · 2.02 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
const {
Client,
Options,
Collection,
GatewayIntentBits,
Partials,
ActivityType,
} = require('discord.js');
const fs = require('fs');
const config = require('./settings/config.json');
let intents = [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.MessageContent,
];
// Creates a new client and a commands collection.
const ayanami = new Client({
presence: {
activities: [
{
type: ActivityType.Custom,
name: 'Real life is a shit-tier game',
},
],
},
intents: intents,
partials: [Partials.Channel],
makeCache: Options.cacheWithLimits({
MessageManager: 25,
}),
});
ayanami.logger = require('./modules/logger');
ayanami.commands = new Collection();
ayanami.msgCommands = new Collection();
// Handle SlashCommands
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
let command = require(`./commands/${file}`);
ayanami.commands.set(command.data.name, command);
}
// Handle Message Commands
const msgCommandFiles = fs.readdirSync('./msgCommands').filter(file => file.endsWith('.js'));
for (const file of msgCommandFiles) {
let command = require(`./msgCommands/${file}`);
ayanami.msgCommands.set(command.name, command);
}
// Require and attach each event file to the appropriate event
const eventFiles = fs.readdirSync('./events').filter(file => file.endsWith('.js'));
for (const file of eventFiles) {
let event = require(`./events/${file}`);
let eventName = file.split('.')[0];
// Load events and require the client name before the event outputs
if (eventName !== 'ready') ayanami.on(eventName, event.bind(null, ayanami));
else ayanami.once(eventName, event.bind(null, ayanami));
delete require.cache[require.resolve(`./events/${file}`)];
}
ayanami.login(config.token).catch(err => {
console.error(err);
ayanami.logger.error(err);
});