-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
55 lines (46 loc) · 1.84 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
43
44
45
46
47
48
49
50
51
52
53
54
55
const Discord = require('discord.js');
const client = new Discord.Client();
const { token } = require('./config.json');
const { name } = require('./package.json');
const { version } = require('./package.json');
const { description } = require('./package.json');
const { author } = require('./package.json');
const { main } = require('./package.json');
const { license } = require('./package.json');
const { readdirSync } = require('fs');
const { join } = require('path');
client.commands = new Discord.Collection();
const prefix = '=';
const commandFiles = readdirSync(join(__dirname, "commands")).filter(file => file.endsWith(".js"));
for (const file of commandFiles) {
const command = require(join(__dirname, "commands", `${file}`));
client.commands.set(command.name, command);
}
client.on("error", console.error);
client.once('ready', () => {
console.log('============================================');
console.log('All Commands are now registered and ready!');
console.log('I\'m Online!');
console.log(`Name : ${name}`);
console.log(`Version : ${version}`);
console.log(`Description : ${description}`);
console.log(`Author : ${author}`);
console.log(`Main File : ${main}`);
console.log(`License : ${license}`);
client.user.setActivity('=help and =help2', { type: 'LISTENING'});
});
client.on("message", async message => {
if(message.author.bot) return;
if(message.channel.type === 'dm') return;
if(message.content.startsWith(prefix)) {
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if(!client.commands.has(command)) return;
try {
client.commands.get(command).run(client, message, args);
} catch (error) {
console.error(error);
}
}
});
client.login(token);