-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathbot.js
87 lines (75 loc) · 2.06 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
require('dotenv').config();
const {
GatewayIntentBits: Intents,
Partials,
Options
} = require("discord.js");
const {
FrameClient,
Utilities,
Handlers
} = require('frame');
const fs = require("fs");
const bot = new FrameClient({
intents: [
Intents.Guilds,
Intents.GuildMessages,
Intents.GuildMessageReactions,
Intents.DirectMessages,
Intents.DirectMessageReactions
],
partials: [
Partials.Message,
Partials.User,
Partials.Channel,
Partials.GuildMember,
Partials.Reaction
],
makeCache: Options.cacheWithLimits({
MessageManager: 0,
ThreadManager: 0
})
}, {
invite: process.env.INVITE,
statuses: [
(bot) => `/help | in ${bot.guilds.cache.size} guilds!`,
(bot) => `/help | serving ${bot.users.cache.size} users!`
]
});
bot.chars = process.env.CHARS;
bot.formatTime = (date) => {
if(typeof date == "string") date = new Date(date);
return `${(date.getMonth()+1) < 10 ? "0"+(date.getMonth()+1) : (date.getMonth()+1)}.${(date.getDate()) < 10 ? "0"+(date.getDate()) : (date.getDate())}.${date.getFullYear()} at ${date.getHours() < 10 ? "0"+date.getHours() : date.getHours()}:${date.getMinutes() < 10 ? "0"+date.getMinutes() : date.getMinutes()}`
}
async function setup() {
var { db, stores } = await Handlers.DatabaseHandler(bot, __dirname + '/stores');
bot.db = db;
bot.stores = stores;
var files;
bot.handlers = {};
bot.handlers.interaction = Handlers.InteractionHandler(bot, __dirname + '/slashcommands');
files = fs.readdirSync(__dirname + "/handlers");
for(var f of files) {
var n = f.slice(0, -3);
bot.handlers[n] = require(__dirname + "/handlers/"+f)(bot)
}
bot.utils = Utilities;
var ut = require('./utils');
bot.utils = Object.assign(bot.utils, ut);
}
bot.on("ready", async ()=> {
console.log(`Logged in as ${bot.user.tag} (${bot.user.id})`);
})
bot.on('error', (err)=> {
console.log(`Error:\n${err.stack}`);
})
process.on("unhandledRejection", (e) => console.log(e));
setup()
.then(async () => {
try {
await bot.login(process.env.TOKEN);
} catch(e) {
console.log("Trouble connecting...\n"+e)
}
})
.catch(e => console.log(e))