From 026f84fef5a728ea6adfc66e0bfa4c1e04379e39 Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Fri, 25 Mar 2022 22:14:29 +0200 Subject: [PATCH] add untested attestation feature --- src/common.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/common.js b/src/common.js index fe581bd..beb2ce8 100644 --- a/src/common.js +++ b/src/common.js @@ -1,3 +1,4 @@ +import { gatewayServer } from "./commonservers.js"; import { discordToken, logContextMap, watchedGuildIds } from "./config.js"; import DiscordClient from "./DiscordClient.js"; import WatchedGuild from "./WatchedGuild.js"; @@ -50,4 +51,33 @@ bot.once("READY", () => { watchedGuild.discordConnect(bot); guildMap.set(id, watchedGuild); }); + + bot.on("MESSAGE_CREATE", (message) => { + if (message.content === "!:bridge-attest") { + let clientsString = ""; + gatewayServer.wss.clients.forEach((client) => { + if (client.state && client.state.authenticated && client.state.user && client.state.user.username) { + clientsString += `**${client.state.user.username}** |`; + } + }); + + bot.api(["POST", `/channels/${message.channel_id}/messages`], { + embeds: [ + { + title: "Bridge Attestation", + fields: [ + { + name: "Connected Clients Count", + value: gatewayServer.wss.clients.size + }, + { + name: "Connected Clients", + value: clientsString === "" ? "[no connected clients]" : clientsString + } + ] + } + ] + }) + } + }); });