-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
57 lines (39 loc) · 1.94 KB
/
index.ts
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
import fs from 'fs/promises'
//import fs = require('fs/promises') // We're not doing Sync calls anymore, Ferny. Bonk.
import {Client as eris} from 'eris'
import { loadCommands, commandHolder } from './core/commands.ts'
import { loadEvents } from './core/events.ts'
// import { sanitaryInteraction } from './constructors/interaction'
import { msg } from './core/msg.ts'
import { sanitzeScripts } from './core/sanitize.ts'
import {setup} from './core/setup.js'
import { Database as db } from './core/database.ts'
import { DataTypes, Sequelize } from 'sequelize'
const fileExists = async path => !!(await fs.stat(path).catch(e => false))
let client = null,
config = null
const Database = new db()
const checkSetup = async () => {
if (await fileExists('./config.json') === false) {await setup()}
config = JSON.parse((await fs.readFile('./config.json')).toString())
// config = (await import('./config.json', {assert:{type:'json'}})).default
msg.debug("System", "Loading Events.")
client = new eris(config.__protected.Bot.Token, {compress: true, seedVoiceConnections: true, intents:['allNonPrivileged']})
client.on('interactionCreate', (interaction: any) => {
//TODO: passing interaction through willy nilly is a bad idea, we should create a proper safety net.
//SEE: constructor/interaction.ts
// if (interaction.type !== 3) commandHolder[interaction.data.name].runCommand(client, new sanitaryInteraction(client, interaction))
commandHolder[interaction.data.name].runCommand(interaction)
})
client.on('debug', d => msg.debug("Eris", d))
client.on('ready', async () => {
msg.info("Eris", "Ready as " + client.user.username + "#" + client.user.discriminator)
loadCommands(client, config)
})
await loadEvents(client, config)
await client.connect()
}
checkSetup()
msg.info("System", "Starting, Please wait...")
msg.debug("System", "Verifying setup process.")
export {msg, sanitzeScripts, Database}