-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
bot.js
100 lines (87 loc) · 2.27 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
const {
Client,
GatewayIntentBits: Intents,
Partials,
Options
} = require("discord.js");
const {
FrameClient,
Utilities,
Handlers
} = require('frame');
const fs = require("fs");
const path = require("path");
const bot = new FrameClient({
intents: [
Intents.Guilds,
Intents.GuildMessages,
Intents.GuildMessageReactions,
Intents.GuildMembers,
Intents.DirectMessages,
Intents.DirectMessageReactions
],
partials: [
Partials.Message,
Partials.User,
Partials.Channel,
Partials.GuildMember,
Partials.Reaction
],
makeCache: Options.cacheWithLimits({
MessageManager: 0,
ThreadManager: 0
})
}, {
prefix: process.env.PREFIX ? [process.env.PREFIX] : ["s!","sh!","sheep!","baa!"],
owner: process.env.OWNER,
statuses: [
async ()=> {
var guilds = (await bot.shard.broadcastEval(cli => cli.guilds.cache.size)).reduce((prev, val) => prev + val, 0);
return `/help | in ${guilds} guilds!`;
},
"/help | https://sheep.greysdawn.com"
]
});
bot.tc = require('tinycolor2');
bot.jimp = require('jimp');
bot.fetch = require('axios');
async function setup() {
var { db, stores } = await Handlers.DatabaseHandler(bot, __dirname + '/stores');
bot.db = db;
bot.stores = stores;
files = fs.readdirSync(__dirname + "/events");
files.forEach(f => bot.on(f.slice(0,-3), (...args) => require(__dirname + "/events/"+f)(...args,bot)));
bot.handlers = {};
bot.handlers.interaction = Handlers.InteractionHandler(bot, __dirname + '/commands');
bot.handlers.premium = require('./handlers/premium')(bot);
bot.utils = Utilities;
files = fs.readdirSync("./utils");
files.forEach(f => Object.assign(bot.utils, require("./utils/"+f)));
}
bot.on("ready", async ()=> {
console.log(`Logged in as ${bot.user.tag} (${bot.user.id})`);
bot.user.setActivity("/help | booting...");
})
bot.on('error', (err)=> {
console.log(`Error:\n${err.stack}`);
})
process.on("unhandledRejection", (e) => console.log(/*e.message ||*/ e));
process.on(`SIGTERM`, ()=> {
try {
bot.db?.end();
} catch(e) {
console.log(e.message);
}
process.exit();
})
process.on(`SIGINT`, ()=> {
try {
bot.db?.end();
} catch(e) {
console.log(e.message);
}
process.exit();
})
setup();
bot.login(process.env.TOKEN)
.catch(e => console.log("Trouble connecting...\n"+e));