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

Method run

commands/general/mediastats.js:5–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3
4class MediaStatsCommand extends Command {
5 async run() {
6 if (!this.permissions.has("EMBED_LINKS")) {
7 this.success = false;
8 return this.getString("permissions.noEmbedLinks");
9 }
10 await this.acknowledge();
11 const embed = {
12 embeds: [
13 {
14 author: {
15 name: this.getString("commands.responses.mediastats.header"),
16 iconURL: this.client.user.avatarURL(),
17 },
18 color: 0xff0000,
19 description: this.getString("commands.responses.mediastats.connected", {
20 params: { length: connections.size.toString() },
21 }),
22 fields: [{ name: "", value: "" }],
23 },
24 ],
25 };
26 embed.embeds[0].fields = [];
27 let i = 0;
28 for (const connection of connections.values()) {
29 const count = await connection.getCount().catch(() => {});
30 if (!count) continue;
31 embed.embeds[0].fields.push({
32 name: this.getString("commands.responses.mediastats.server", {
33 params: { num: (connection.name ? `${i++} (${connection.name})` : i++).toString() },
34 }),
35 value: this.getString("commands.responses.mediastats.runningJobs", { params: { count: count.toString() } }),
36 });
37 }
38 return embed;
39 }
40
41 static description = "Gets some statistics about the media servers";
42 static aliases = ["imgstat", "imstats", "imgstats", "imstat", "imagestats", "mstat", "mstats"];

Callers

nothing calls this directly

Calls 3

getStringMethod · 0.80
acknowledgeMethod · 0.80
getCountMethod · 0.80

Tested by

no test coverage detected