Finish preliminary rework, ready to test
This commit is contained in:
parent
57893e7f76
commit
d0a1beb809
177 changed files with 854 additions and 707 deletions
|
@ -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);
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue