-
Notifications
You must be signed in to change notification settings - Fork 59
/
bot.js
149 lines (134 loc) · 3.25 KB
/
bot.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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// Copyright 2020 Cytrus-RE Developers
// You may use the code, but please do credit us.
"use strict"
// Check if the Node version is 12+
if (Number(process.version.slice(1).split(".")[0]) < 16) throw new Error("Tsuyo requires Node v16 or higher. Re-run the bot with Node v16 or higher.")
require("dotenv").config({
path: ".env"
})
if (process.env.PREBOOT) eval(process.env.PREBOOT) // Execute anything in the preboot variable
// Define NPM modules
const {
Client,
Collection,
Intents
} = require("discord.js")
const Enmap = require("enmap")
const {
ReactionRole
} = require("reaction-role")
// Define client
const client = new Client({
disableEveryone: true,
disabledEvents: ["TYPING_START"],
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]
})
// Define time of startup
client.starttime = new Date()
// Define databases/objects
client.profiles = new Enmap({
name: "profiles"
})
client.logins = new Enmap({
name: "logins"
})
client.spotify = new Enmap({
name: "spotify"
})
client.settings = new Enmap({
name: "settings"
})
client.notes = new Enmap({
name: "notes"
})
client.bugs = new Enmap({
name: "bugreports"
})
client.starboard = new Enmap({
name: "starboardmid"
})
client.warns = new Enmap({
name: "warns"
})
client.tags = new Enmap({
name: "tags"
})
client.points = new Enmap({
name: "points"
})
client.pings = new Enmap({
name: "pings"
})
client.pingwords = new Enmap({
name: "pingwords"
})
client.inventory = new Enmap({
name: "inventory"
})
client.garden = new Enmap({
name: "garden"
})
client.money = new Enmap({
name: "money"
})
client.cooldown = new Enmap({
name: "cooldown"
})
client.badges = new Enmap({
name: "badges"
})
client.reputation = new Enmap({
name: "reputation"
})
client.fish = new Enmap({
name: "fish"
})
client.flags = new Enmap({
name: "flags"
})
client.badges = new Enmap({
name: "badges"
})
client.money = new Enmap({
name: "money"
})
client.profile = new Enmap({
name: "profile"
})
client.life = new Enmap({
name: "life"
})
client.tags = new Enmap({
name: "tags"
})
client.uses = new Enmap({
name: "commandpop"
})
client.commands = new Collection()
client.aliases = new Collection()
//client.users = new Collection()
client.music = {}
client.levelCache = {}
// Import files
client.logger = require("./modules/logger")
client.config = require("./config")
client.errors = require("./modules/errors")
require("./modules/commands")(client) // Import command module
require("./modules/events")(client) // Import events module
require("./modules/_functions")(client) // Import functions
require("./modules/webhooks")(client) // Import functions
// Cache the permissions
for (let i = 0; i < client.config.permLevels.length; i++) {
let currentlevel = client.config.permLevels[i]
client.levelCache[currentlevel.name] = currentlevel.level
}
process.env.SESSION_SECRET = ""
for (let i = 0; i <= 1500; i++) {
process.env.SESSION_SECRET +=
Math.random().toString(16).slice(2, 8).toUpperCase().slice(-6) + i
}
client.login(process.env.BOT_TOKEN)
console.log("Logged into Discord API!")
//const ReactionRoles = new ReactionRole(process.env.BOT_TOKEN, process.env.MONGODB_URI)
//ReactionRoles.init()
module.exports = client