-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
31 lines (21 loc) · 775 Bytes
/
bot.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
let users = $("#users");
let servers = $("#servers");
let sentences = $("#sentences");
const serverLink = "https://speakeasyserver-vkd5vb5lca-uc.a.run.app/";
updateValues();
async function updateValues() {
return fetch(serverLink+"bot-stats").then(results => {
return results.json();
}).then(stats => {
// console.log(stats);
let userCount = addCommas(stats.data.users);
let serverCount = addCommas(stats.data.servers);
let sentenceCount = addCommas(stats.data.rated);
users.html(userCount + " users");
servers.html(serverCount + " servers");
sentences.html(sentenceCount + " sentences rated")
});
}
function addCommas(n) {
return n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}