-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathindex.js
More file actions
109 lines (53 loc) · 1.98 KB
/
Copy pathindex.js
File metadata and controls
109 lines (53 loc) · 1.98 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
const {
Client,
GatewayIntentBits,
Collection,
PermissionsBitField
} = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.DirectMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
]
});
const fs = require('fs');
const mongoose = require('mongoose');
const {token,prefix, mongo} = require('./settings/config');
client.commands = new Collection();
client.aliases = new Collection()
mongoose.set("strictQuery", false);
mongoose.connect(mongo).catch((e)=> {
console.log(e)
process.exit()
}).then(()=> {
console.log('Connected To Mongo')
});
const commandFiles = fs.readdirSync('./commands')
let date = new Date()
for (const folder of commandFiles) {
const option = fs.readdirSync(`./commands/${folder}`).filter(f=> f.endsWith('.js'))
option.forEach(item=> {
const command = require(`./commands/${folder}/${item}`);
console.log(`\x1b[36m%s\x1b[0m`,`[${date.toLocaleString()}] ${command.name}`)
client.commands.set(command.name, command);
})
}
client.on("ready", async () => {
console.log(`\x1b[31m%s\x1b[0m`,`${client.user.username} Is Ready`)
})
client.on("messageCreate", async message => {
if (!prefix.find(e=> message.content.startsWith(e)) || message.author.bot || message.mentions.users.get('1312750746776637452') == client.user) return;
const args = message.content.slice("-".length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();
const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
if (!command) return;
try {
command.execute(client, message, args);
} catch (error) {
console.error(error);
message.reply('There was an error trying to execute that command!');
}
})
client.login(token)