-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
90 lines (78 loc) · 3.13 KB
/
index.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
console.log("Booting...")
require("dotenv").config()
require('canvas').registerFont('./fonts/COMIC.TTF', { family: 'Comic Sans MS' });
const fs = require("fs")
const Sentry = require("@sentry/node")
const Tracing = require("@sentry/tracing")
const { keep_alive } = require("./keep_alive");
const mongo = require("./db.js")
const Discord = require("discord.js")
const client = new Discord.Client({ intents: ["GUILDS","GUILD_MEMBERS","GUILD_BANS","GUILD_EMOJIS_AND_STICKERS","GUILD_INTEGRATIONS","GUILD_WEBHOOKS","GUILD_INVITES","GUILD_VOICE_STATES","GUILD_PRESENCES","GUILD_MESSAGES","GUILD_MESSAGE_REACTIONS","GUILD_MESSAGE_TYPING","DIRECT_MESSAGES","DIRECT_MESSAGE_REACTIONS","DIRECT_MESSAGE_TYPING"]})
client.db = mongo
client.tempcheck = require("./tempCheck.js")(client)
client.Sentry = Sentry
client.commands = new Discord.Collection()
fs.readdir("./commands/", (err, files) => {
files.forEach((file) => {
let path = `./commands/${file}`
fs.readdir(path, (err, files) => {
if (err) console.error(err)
let jsfile = files.filter((f) => f.split(".").pop() === "js")
if (jsfile.length <= 0) {
console.error(`Couldn't find commands in the ${file} category.`)
return
}
jsfile.forEach((f, i) => {
let props = require(`./commands/${file}/${f}`)
props.category = file
try {
client.commands.set(props.name, props)
if (props.aliases) props.aliases.forEach((alias) => client.commands.set(alias, props))
} catch (err) {
if (err) console.error(err)
}
})
})
})
})
client.slashCommands = new Discord.Collection()
fs.readdir("./slashCommands/", (err, files) => {
files.forEach((file) => {
let path = `./slashCommands/${file}`
fs.readdir(path, (err, files) => {
if (err) console.error(err)
let jsfile = files.filter((f) => f.split(".").pop() === "js")
if (jsfile.length <= 0) {
console.error(`Couldn't find slash commands in the ${file} category.`)
}
jsfile.forEach((f, i) => {
let props = require(`./slashCommands/${file}/${f}`)
props.category = file
try {
client.slashCommands.set(props.command.name, props)
} catch (err) {
if (err) console.error(err)
}
})
})
})
})
const eventFiles = fs.readdirSync("./events").filter((file) => file.endsWith(".js"))
for (const file of eventFiles) {
require(`./events/${file}`)(client)
}
client.botAdmin = (id) => {
if (["263472056753061889","606022064792535070"].includes(id)) return true
return false
}
client.on("ready", async() => {
console.log("Connected!")
client.user.setActivity(`SneekyJoe being awesome.`, {type: "WATCHING"})
Sentry.init({
dsn: process.env.SENTRY,
tracesSampleRate: 1.0,
})
})
client.login(process.env.TOKEN)
client.on("error", (err) => console.error(err))
module.exports = { client }