This repository has been archived by the owner on Jun 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
78 lines (71 loc) · 2.23 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
*
* @author: nukestye
* @version: v1
*
*/
/*
* TODO:
* - Add more Public commands.
*/
const prefix = process.env.PREFIX
const owner = process.env.OWNER
const discord = process.env.DISCORD
const fs = require('fs')
const log = console.log
// Setting up the way to get commands
const { CommandoClient } = require('discord.js-commando')
const path = require('path')
// reading events
fs.readdir('./src/events/', (err, files) => {
if (err) return console.error(err)
files.forEach((file) => {
const eventFunction = require(`./src/events/${file}`)
if (eventFunction.disabled) return
const event = eventFunction.event || file.split('.')[0]
const emitter = (typeof eventFunction.emitter === 'string' ? client[eventFunction.emitter] : eventFunction.emitter) || client
const { once } = eventFunction
try {
emitter[once ? 'once' : 'on'](event, (...args) => eventFunction.run(...args))
} catch (error) {
console.error(error.stack)
}
})
})
const client = global.client = new CommandoClient({
commandPrefix: `${prefix}`,
owner: `${owner}`,
invite: `${discord}`,
unknownCommandResponse: false
})
// Registing the commands
client.registry
.registerDefaultTypes()
// The different fields for cmds
.registerGroups([
['mod', 'Moderation Commands'],
['public', 'Public Commands']
])
.registerDefaultGroups()
// Basic cmds can be disabled like {"cmd: false"}
.registerDefaultCommands()
// commands in "/src/commands" will be counted
.registerCommandsIn(path.join(__dirname, '/src/commands'))
// list of activities that the bot goes through
const activityArray = [`${prefix}help | `]
// Bot lanuch code
client.once('ready', () => {
log(`Logged in as ${client.user.tag} in ${client.guilds.size} guild(s)!`)
setInterval(() => {
const index = Math.floor(Math.random() * (activityArray.length)) // generates a random number between 1 and the length of the activities array list
client.user.setActivity(
activityArray[index],
{
type: 'PLAYING'
}) // sets bot"s activities to one of the phrases in the arraylist.
}, 5000) // updates every 10000ms = 10s
})
// If an error print it out
client.on('error', console.error)
// Login in using the token in config
client.login(process.env.TOKEN)