Finish preliminary rework, ready to test

This commit is contained in:
Dark 2021-06-02 04:07:50 +02:00
parent 57893e7f76
commit d0a1beb809
No known key found for this signature in database
GPG key ID: 2CD6ACB6B0A87B8A
177 changed files with 854 additions and 707 deletions

View file

@ -1,5 +1,6 @@
import { utilityCmd } from "../types";
import { noop, trimLines } from "../../../utils";
import { Message } from "discord.js";
const { performance } = require("perf_hooks");
@ -15,12 +16,12 @@ export const PingCmd = utilityCmd({
for (let i = 0; i < 4; i++) {
const start = performance.now();
const message = await msg.channel.createMessage(`Calculating ping... ${i + 1}`);
const message = await msg.channel.send(`Calculating ping... ${i + 1}`);
times.push(performance.now() - start);
messages.push(message);
if (msgToMsgDelay === undefined) {
msgToMsgDelay = message.timestamp - msg.timestamp;
msgToMsgDelay = message.createdTimestamp - msg.createdTimestamp;
}
}
@ -28,25 +29,19 @@ export const PingCmd = utilityCmd({
const lowest = Math.round(Math.min(...times));
const mean = Math.round(times.reduce((total, ms) => total + ms, 0) / times.length);
const shard = pluginData.client.shards.get(pluginData.client.guildShardMap[pluginData.guild.id])!;
// const shard = pluginData.client.shards.get(pluginData.client.guildShardMap[pluginData.guild.id])!; FIXME sharding stuff
msg.channel.createMessage(
msg.channel.send(
trimLines(`
**Ping:**
Lowest: **${lowest}ms**
Highest: **${highest}ms**
Mean: **${mean}ms**
Time between ping command and first reply: **${msgToMsgDelay!}ms**
Shard latency: **${shard.latency}ms**
`),
`), // Omitted line: Shard latency: **${shard.latency}ms**
);
// Clean up test messages
pluginData.client
.deleteMessages(
messages[0].channel.id,
messages.map(m => m.id),
)
.catch(noop);
msg.channel.bulkDelete(messages).catch(noop);
},
});