Add Discord API reported Latency to ping command
This commit is contained in:
parent
adc0443dbd
commit
8ecace27b3
|
@ -51,25 +51,30 @@ namespace DeukBot4.MessageHandlers.CommandHandler
|
||||||
{
|
{
|
||||||
new EmbedFieldBuilder()
|
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"
|
Value = $"{(int)(t1 - request.OriginalMessage.CreatedAt).TotalMilliseconds} ms"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
eb.Footer = new EmbedFooterBuilder()
|
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 t2 = DateTimeOffset.UtcNow;
|
||||||
var m = await request.SendMessageAsync("", embed: eb.Build());
|
var m = await request.SendMessageAsync("", embed: eb.Build());
|
||||||
eb.Fields.Add(new EmbedFieldBuilder()
|
eb.Fields.Add(new EmbedFieldBuilder()
|
||||||
{
|
{
|
||||||
Name = "Time handling embed creation",
|
Name = "Measured Time handling embed creation",
|
||||||
Value = $"{(t2 - t1).TotalMilliseconds} ms"
|
Value = $"{(t2 - t1).TotalMilliseconds} ms"
|
||||||
});
|
});
|
||||||
eb.Fields.Add(new EmbedFieldBuilder()
|
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"
|
Value = $"{(int)(m.CreatedAt - t2).TotalMilliseconds} ms"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue