Add tracing to the !quote embed builder
This commit is contained in:
parent
954c6c2be3
commit
1b9d8732d5
1 changed files with 11 additions and 8 deletions
|
@ -268,29 +268,32 @@ namespace Geekbot.Bot.Commands.Utils.Quote
|
||||||
|
|
||||||
private EmbedBuilder QuoteBuilder(QuoteModel quote)
|
private EmbedBuilder QuoteBuilder(QuoteModel quote)
|
||||||
{
|
{
|
||||||
|
var getEmbedUserSpan = Transaction.StartChild("GetEmbedUser");
|
||||||
var user = Context.Client.GetUserAsync(quote.UserId.AsUlong()).Result;
|
var user = Context.Client.GetUserAsync(quote.UserId.AsUlong()).Result;
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
|
var getEmbedUserFromRepoSpan = Transaction.StartChild("GetEmbedUserFromRepo");
|
||||||
var fallbackUserFromRepo = _userRepository.Get(quote.UserId.AsUlong());
|
var fallbackUserFromRepo = _userRepository.Get(quote.UserId.AsUlong());
|
||||||
user = new UserPolyfillDto()
|
user = new UserPolyfillDto()
|
||||||
{
|
{
|
||||||
Username = fallbackUserFromRepo?.Username ?? "Unknown User",
|
Username = fallbackUserFromRepo?.Username ?? "Unknown User",
|
||||||
AvatarUrl = fallbackUserFromRepo?.AvatarUrl
|
AvatarUrl = fallbackUserFromRepo?.AvatarUrl
|
||||||
};
|
};
|
||||||
|
getEmbedUserFromRepoSpan.Finish();
|
||||||
}
|
}
|
||||||
|
getEmbedUserSpan.Finish();
|
||||||
|
|
||||||
|
var embedBuilderSpan = Transaction.StartChild("EmbedBuilder");
|
||||||
var eb = new EmbedBuilder();
|
var eb = new EmbedBuilder();
|
||||||
eb.WithColor(new Color(143, 167, 232));
|
eb.WithColor(new Color(143, 167, 232));
|
||||||
if (quote.InternalId == 0)
|
eb.Title = quote.InternalId == 0
|
||||||
{
|
? $"{user.Username} @ {quote.Time.Day}.{quote.Time.Month}.{quote.Time.Year}"
|
||||||
eb.Title = $"{user.Username} @ {quote.Time.Day}.{quote.Time.Month}.{quote.Time.Year}";
|
: $"#{quote.InternalId} | {user.Username} @ {quote.Time.Day}.{quote.Time.Month}.{quote.Time.Year}";
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
eb.Title = $"#{quote.InternalId} | {user.Username} @ {quote.Time.Day}.{quote.Time.Month}.{quote.Time.Year}";
|
|
||||||
}
|
|
||||||
eb.Description = quote.Quote;
|
eb.Description = quote.Quote;
|
||||||
eb.ThumbnailUrl = user.GetAvatarUrl();
|
eb.ThumbnailUrl = user.GetAvatarUrl();
|
||||||
if (quote.Image != null) eb.ImageUrl = quote.Image;
|
if (quote.Image != null) eb.ImageUrl = quote.Image;
|
||||||
|
embedBuilderSpan.Finish();
|
||||||
|
|
||||||
return eb;
|
return eb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue