-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (31 loc) · 1.49 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
const colors = require('colors')
const fetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args));
const consolePrefix = `${'['.blue}${'dbd-soft-ui'.yellow}${']'.blue} `
module.exports.register = async function (client, data) {
if (client === undefined) return console.log(`${consolePrefix} ${'Client has not been specified!'.red}`)
if (data === undefined) return console.log(consolePrefix + "No Data has been entered!");
client.dlu = {
key: data.key,
dashboard_url: data.dashboard_url,
}
console.log(consolePrefix + "Log collection is " + colors.brightGreen("ACTIVE"))
await send(client, {
title: "Bot Started",
description: `[${new Date().toLocaleString()}] Log collection is ACTIVE and sends to ${client.dlu.dashboard_url}`,
})
}
module.exports.send = async function (client, data) {
if (client === undefined) return console.log(`${consolePrefix} ${'Client has not been specified!'.red}`)
if (data === undefined) return console.log(consolePrefix + "No Data has been entered!");
await send(client, {
title: data.title,
description: `[${new Date().toLocaleString()}] ${data.description}`,
})
}
async function send(client, data) {
await fetch(client.dlu.dashboard_url + "/stats/logs/update", {
method: "post",
body: JSON.stringify(data),
headers: { "Content-Type": "application/json", "Authorization": "Bearer " + client.dlu.key }
}).catch(err => console.log(err))
}