-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
67 lines (51 loc) · 1.59 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
const { Client, MessageEmbed } = require('discord.js');
const client = new Client();
const express = require('express');
const app = express();
require('dotenv').config()
const tip = require('./src/commands/tip');
const help = require('./src/commands/help');
const add = require('./src/commands/add');
const tipbot = require('@trustify/tipbot.ts');
console.log("tipbot", tipbot)
const DB_USER = process.env.DB_USER
const DB_PASSWORD = process.env.DB_PASSWORD
const DB_URL = process.env.DB_URL
const DB_PORT = process.env.DB_PORT
const DB_NAME = process.env.DB_NAME
tipbot.setDB(`postgresql://${DB_USER}:${DB_PASSWORD}@${DB_URL}:${DB_PORT}/${DB_NAME}`)
const TOKEN = process.env.TOKEN
app.use('/qr_codes', express.static(__dirname + '/qr_codes'));
// functions
var cmds = {
help,
tip,
add
}
const { COLOR, PREFIX } = require('./src/config');
client.on('message', async msg => {
try {
// Getting content, author and channel out of message object
let cont = msg.content,
author = msg.author
//ignore bots
if (author.bot) return;
if (cont.startsWith(PREFIX)) {
let cmd = cont.split(' ')[0].substr(PREFIX.length),
args = cont.split(' ').slice(1)
//call function
if (cmd in cmds) {
cmds[cmd](msg, args)
}
}
} catch (err) {
console.log(err)
}
})
client.login(TOKEN)
client.on('ready', () => {
console.log(`Bot started as ${client.user.username}`)
})
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});