mirror of
https://github.com/RPCS3/discord-bot.git
synced 2025-02-02 16:31:52 +00:00
show that no game updates available inside the same embed
This commit is contained in:
parent
d924cda609
commit
674ea98969
@ -30,14 +30,8 @@ namespace CompatBot.Commands
|
||||
}
|
||||
|
||||
var updateInfo = await Client.GetTitleUpdatesAsync(productId, Config.Cts.Token).ConfigureAwait(false);
|
||||
if (updateInfo?.Tag?.Packages?.Length > 0)
|
||||
{
|
||||
var embed = await updateInfo.AsEmbedAsync(ctx.Client).ConfigureAwait(false);
|
||||
await ctx.RespondAsync(embed: embed).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
await ctx.RespondAsync("No updates were found").ConfigureAwait(false);
|
||||
var embed = await updateInfo.AsEmbedAsync(ctx.Client, productId).ConfigureAwait(false);
|
||||
await ctx.RespondAsync(embed: embed).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,31 +16,32 @@ namespace CompatBot.Utils.ResultFormatters
|
||||
private const long UnderGB = 1000 * 1024 * 1024;
|
||||
|
||||
|
||||
public static async Task<DiscordEmbed> AsEmbedAsync(this TitlePatch patch, DiscordClient client)
|
||||
public static async Task<DiscordEmbed> AsEmbedAsync(this TitlePatch patch, DiscordClient client, string productCode)
|
||||
{
|
||||
var pkgs = patch.Tag?.Packages;
|
||||
var title = pkgs?.Select(p => p.ParamSfo?.Title).LastOrDefault(t => !string.IsNullOrEmpty(t)) ?? patch.TitleId;
|
||||
var thumbnailUrl = await client.GetThumbnailUrlAsync(patch.TitleId).ConfigureAwait(false);
|
||||
var pkgs = patch?.Tag?.Packages;
|
||||
var title = pkgs?.Select(p => p.ParamSfo?.Title).LastOrDefault(t => !string.IsNullOrEmpty(t)) ?? ThumbnailProvider.GetTitleName(productCode) ?? productCode;
|
||||
var thumbnailUrl = await client.GetThumbnailUrlAsync(productCode).ConfigureAwait(false);
|
||||
var result = new DiscordEmbedBuilder
|
||||
{
|
||||
Title = title,
|
||||
Color = Config.Colors.DownloadLinks,
|
||||
ThumbnailUrl = thumbnailUrl,
|
||||
};
|
||||
if (pkgs.Length > 1)
|
||||
if (pkgs?.Length > 1)
|
||||
{
|
||||
result.Description = $"Total download size of all packages is {pkgs.Sum(p => p.Size).AsStorageUnit()}";
|
||||
foreach (var pkg in pkgs)
|
||||
{
|
||||
result.AddField($"Update v{pkg.Version} ({pkg.Size.AsStorageUnit()})", $"⏬ [{GetLinkName(pkg.Url)}]({pkg.Url})");
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
else if (pkgs?.Length == 1)
|
||||
{
|
||||
result.Title = $"{title} update v{pkgs[0].Version} ({pkgs[0].Size.AsStorageUnit()})";
|
||||
result.Description = $"⏬ [{Path.GetFileName(GetLinkName(pkgs[0].Url))}]({pkgs[0].Url})";
|
||||
}
|
||||
else
|
||||
result.Description = "No updates were found";
|
||||
return result.Build();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user