MCPcopy Create free account
hub / github.com/esmBot/esmBot / getServers

Function getServers

src/utils/misc.ts:171–197  ·  view source on GitHub ↗
(bot: Client)

Source from the content-addressed store, hash-verified

169}
170
171export function getServers(bot: Client): Promise<number> {
172 return new Promise((resolve, reject) => {
173 if (process.env.CLUSTER_TYPE === "node") {
174 const listener = (packet: { data: { type: string; serverCount: number } }) => {
175 if (packet.data?.type === "countResponse") {
176 clearTimeout(timeout);
177 resolve(packet.data.serverCount);
178 process.off("message", listener);
179 }
180 };
181 process.on("message", listener);
182
183 const timeout = setTimeout(() => {
184 process.off("message", listener);
185 reject(Error("Timed out while getting server count"));
186 }, 3000);
187
188 process.send?.({
189 data: {
190 type: "getCount",
191 },
192 });
193 } else {
194 resolve(bot.guilds.size);
195 }
196 });
197}
198
199// copied from eris
200export function cleanMessage(message: Message, content: string) {

Callers 2

runMethod · 0.85
runMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected