add untested attestation feature

This commit is contained in:
hippoz 2022-03-25 22:14:29 +02:00
parent 9683c4f41c
commit 026f84fef5
No known key found for this signature in database
GPG key ID: 7C52899193467641

View file

@ -1,3 +1,4 @@
import { gatewayServer } from "./commonservers.js";
import { discordToken, logContextMap, watchedGuildIds } from "./config.js"; import { discordToken, logContextMap, watchedGuildIds } from "./config.js";
import DiscordClient from "./DiscordClient.js"; import DiscordClient from "./DiscordClient.js";
import WatchedGuild from "./WatchedGuild.js"; import WatchedGuild from "./WatchedGuild.js";
@ -50,4 +51,33 @@ bot.once("READY", () => {
watchedGuild.discordConnect(bot); watchedGuild.discordConnect(bot);
guildMap.set(id, watchedGuild); 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
}
]
}
]
})
}
});
}); });