-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
45 lines (36 loc) · 1.32 KB
/
index.js
File metadata and controls
45 lines (36 loc) · 1.32 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
const Discord = require("discord.js")
const config = require("./config.json")
const client = new Discord.Client({
intents: config.discord.intents,
partials: config.discord.partials
})
client.functions = {
noop: function noop(){
null
},
wait: function wait(time){
new Promise(resolve => setTimeout(resolve,time))
},
deleteIn: function deleteIn(time, messageId) {
return new Promise(resolve => setTimeout(resolve, time)).then(() => message.channel.messages.fetch(messageId).then(m =>m.delete()).catch(() => null))
},
cutChars: function cutChars(input, limit) {
return input.length > limit ? `${input.slice(0, limit)}... ${input.slice(limit).length} chars more` : input
}
}
const fs = require('fs')
client.commands = new Discord.Collection()
const cmdFiles = fs.readdirSync('./commands/')
for(const file of cmdFiles){
const command = require(`./commands/${file}`)
client.commands.set(command.data.name, command)
}
const cmdParser = require("./commandParser.js")
client.on("ready", () => {
console.log(`Ready on client ${client.user.tag}!`)
client.commands.map(cmd => console.log(`Loaded command with name ${cmd.data.name}`))
})
client.on("messageCreate", (message) => {
cmdParser(client, message)
})
client.login(config.tokens.bot)