forked from ErikBoesen/RoBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbhelper.js
72 lines (69 loc) · 2.56 KB
/
dbhelper.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
var config = require('./config.json'),
Discord = require('discord.js'),
bot = new Discord.Client();
const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database('./servers.sqlite');
bot.on('ready', () => {
db.serialize(() => {
db.run(`CREATE TABLE IF NOT EXISTS servers (
id VARCHAR(25) PRIMARY KEY,
prefix VARCHAR(10),
announcementChannel VARCHAR(25),
welcomeMessagesEnabled BOOLEAN,
welcomeMessage VARCHAR(200),
leaveMessagesEnabled BOOLEAN,
leaveMessage VARCHAR(200),
banMessagesEnabled BOOLEAN,
banMessage VARCHAR(200),
modLogs BOOLEAN,
modLogChannel VARCHAR(25),
joinRole VARCHAR(20),
botRole VARCHAR(20),
inviteLinkDeletion BOOLEAN,
mentionSpamProtection BOOLEAN,
givemeRoles BLOB)`);
bot.guilds.forEach(guild => {
console.log(`Inserting ${guild.name} into the database.`);
if (guild.channels.array() && guild.channels.array()[0]) {
db.run(`INSERT OR IGNORE INTO servers VALUES (
"${guild.id}",
"${config.prefix}",
"${guild.channels.array()[0].id}",
0,
"Welcome {user:username} to the server!",
0,
"{user:username} left the server :cry:",
0,
"{user:username} was banned from the server :hammer:",
0,
"${guild.channels.array()[0].id}",
"none",
"none",
0,
0,
"")`);
} else {
db.run(`INSERT OR IGNORE INTO servers VALUES (
"${guild.id}",
"${config.prefix}",
"none",
0,
"Welcome {user:username} to the server!",
0,
"{user:username} left the server :cry:",
0,
"{user:username} was banned from the server :hammer:",
0,
"none",
"none",
"none",
0,
0,
"")`);
}
});
});
console.log('Servers synced.');
});
bot.login(config.token)
;