forked from cappig/MC-status-bot
-
Notifications
You must be signed in to change notification settings - Fork 3
/
updatedb.js
85 lines (81 loc) · 2.79 KB
/
updatedb.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
const mongoose = require('mongoose')
const ServerSchema = require('./database/ServerSchema')
const run = async () => {
// Connect to database
await mongoose
.connect('mongodb://bot:[email protected]:25569/mcstatus', { useNewUrlParser: true, useUnifiedTopology: true })
.then(() => console.log('Connected to database!'))
.catch((err) => console.log(err.stack || err))
let serversno = 0
await ServerSchema.find()
.then((result) => {
result.forEach(async (server) => {
serversno++
server.checker = {
channel: {
status: 'offline',
members: '0'
},
notification: {
status: 'offline',
members: '0'
}
}
server.config = {
notifications: {
webhook: {
enabled: false,
url: 'http://nice.webhook.mcstatusbot.site/',
content: '[ip] is [status]',
for: { online: false, offline: false }
},
email: {
enabled: false,
emails: ['[email protected]'],
subject: '[ip] is [status]',
content: 'hello, this is an automated email saying [ip] is [status]',
for: { online: false, offline: false }
}
},
chart: {
enabled: true,
embed: {
uptime: {
title: "[ip]'s uptime",
description:
'[ip] was up for [uptime] minutes and down for [downtime] minutes. This means that [ip] has a uptime percentage of [onlinepercent] and downtime percentage of [offlinepercent]',
color: '#FFFFF'
},
playersonline: {
title: 'Number of players online on [ip]',
description: 'There have been a maximum of [maxplayers] players online at once, and a minimum of [minplayers].',
color: '#FFFFF'
},
mostactive: {
title: 'Most active players on [ip] in the last 24 hours',
description: '[mostactive] was the most active player with [mostactiveminutes] minutes spent online in the last 24 hours.',
color: '#FFFFF'
}
},
graph: {
text: {
title: '253, 253, 253',
time: '253, 253, 253',
state: '253, 253, 253'
},
line: {
fill: '8, 174, 228',
border: '39, 76, 113'
}
}
}
}
await server.save()
console.log('updated: ' + server._id)
})
console.log('updated servers: ' + serversno)
})
.catch((err) => console.log(err.stack || err))
return true
}
run()