Add Discord API reported Latency to ping command

This commit is contained in:
Deukhoofd 2018-10-09 21:32:08 +02:00
parent adc0443dbd
commit 8ecace27b3
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 9 additions and 4 deletions

View File

@ -51,25 +51,30 @@ namespace DeukBot4.MessageHandlers.CommandHandler
{
new EmbedFieldBuilder()
{
Name = "Ping between Message and Command Handling",
Name = "Discord Reported Latency",
Value = $"{Program.Client.Latency} ms"
},
new EmbedFieldBuilder()
{
Name = "Measured Ping between Message and Command Handling",
Value = $"{(int)(t1 - request.OriginalMessage.CreatedAt).TotalMilliseconds} ms"
}
};
eb.Footer = new EmbedFooterBuilder()
{
Text = "Ping can be off a bit due to Discord timestamping"
Text = "Measured Ping can be off a bit due to Discord timestamping"
};
var t2 = DateTimeOffset.UtcNow;
var m = await request.SendMessageAsync("", embed: eb.Build());
eb.Fields.Add(new EmbedFieldBuilder()
{
Name = "Time handling embed creation",
Name = "Measured Time handling embed creation",
Value = $"{(t2 - t1).TotalMilliseconds} ms"
});
eb.Fields.Add(new EmbedFieldBuilder()
{
Name = "Ping between Bot and Discord",
Name = "Measured Ping between Bot and Discord",
Value = $"{(int)(m.CreatedAt - t2).TotalMilliseconds} ms"
});