commit 5d34fd130d706857e8d7e92dc8bfce725c418e57
parent 4faf3bf476ff16e8de0fb4c235d1413f5b7ee5e7
Author: Demonstrandum <moi@knutsen.co>
Date: Sun, 17 May 2020 02:03:26 +0100
Report guild count.
Diffstat:
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/lib/main.ts b/lib/main.ts
@@ -178,7 +178,7 @@ export class SimpOMatic {
});
// Send messages on web-hooks.
- server(body => {
+ server(GLOBAL_CONFIG, body => {
if (body.ref === "refs/heads/master" || body.action) {
const embed = new MessageEmbed()
.setColor("#ef88c5")
diff --git a/lib/web.ts b/lib/web.ts
@@ -4,7 +4,7 @@ import process from 'process';
const PORT = Number(process.env.PORT) || 8080;
-export default handle_post => {
+export default (GLOBAL_CONFIG : Types.GlobalConfig, handle_post) => {
const request_listener: http.RequestListener = (req, res) => {
if (req.method === 'POST') {
console.log('Web-hook:');
@@ -30,7 +30,15 @@ export default handle_post => {
'Content-Type': 'text/html'
});
- res.write(read_file('./web/index.html').toString());
+ const guild_count = Object
+ .keys(GLOBAL_CONFIG.guilds)
+ .length
+ .toString();
+
+ const index_contents = read_file('./web/index.html')
+ .toString()
+ .replace(/{{\s*GUILD_COUNT\s*}}/g, guild_count);
+ res.write(index_contents);
res.end();
break;
default:
diff --git a/web/index.html b/web/index.html
@@ -99,6 +99,7 @@
alt="uwu"
src="https://discordemoji.com/assets/emoji/BlobUWU.png" />
</h1>
+ <p>Active in <span class="pink">{{GUILD_COUNT}}</span> Guilds!</p>
<p>
Maybe <span class="pink">Danny</span> will put
cool usage graphs here one day...