-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.js
42 lines (37 loc) · 1.3 KB
/
main.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
const {Collection, Intents, Client} = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES,Intents.FLAGS.GUILD_MESSAGE_REACTIONS] });
const fs = require('fs');
const token = require('./config.json');
client.on('ready', () => {
console.log(`Logged in as user: ${client.user.tag}, ID: ${client.user.id}`);
client.user.setStatus('online');
client.user.setActivity("Managing Giveaways", {
type: "PLAYING",
});
});
client.on('messageCreate', msg => {
if (!msg.channel.guild) {
return;
}
});
fs.readdir("./events/", (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
const event = require(`./events/${file}`);
let eventName = file.split(".")[0];
console.log(`Loading event ${eventName}`);
client.on(eventName, event.bind(null, client));
});
});
client.commands = new Collection();
fs.readdir("./commands/", (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
if (!file.endsWith(".js")) return;
let props = require(`./commands/${file}`);
let commandName = file.split(".")[0];
console.log(`Loaded ${commandName}`);
client.commands.set(commandName, props);
});
});
client.login(token.token);