mirror of
https://github.com/RPCS3/discord-bot.git
synced 2024-12-14 06:18:42 +00:00
retry getting thumbnail color if default value was saved before
This commit is contained in:
parent
74b77a3515
commit
b946c912bd
@ -420,8 +420,14 @@ namespace CompatBot.Commands
|
||||
[Description("Find games to download")]
|
||||
public Task Download(CommandContext ctx, [RemainingText] string game)
|
||||
{
|
||||
if (game?.ToUpperInvariant() == "RPCS3")
|
||||
var invariantTitle = game?.ToUpperInvariant();
|
||||
if (invariantTitle == "RPCS3")
|
||||
return CompatList.UpdatesCheck.CheckForRpcs3Updates(ctx.Client, ctx.Channel);
|
||||
|
||||
if (invariantTitle == "UNNAMED")
|
||||
game = "Persona 5";
|
||||
else if (invariantTitle == "KOT")
|
||||
game = invariantTitle;
|
||||
return Psn.SearchForGame(ctx, game, 3);
|
||||
}
|
||||
|
||||
|
@ -126,10 +126,16 @@ namespace CompatBot.Commands
|
||||
|
||||
if (string.IsNullOrEmpty(alteredSearch))
|
||||
alteredSearch = search;
|
||||
var jpSearch = alteredSearch;
|
||||
if (alteredSearch == "KOT")
|
||||
{
|
||||
alteredSearch = "kitten";
|
||||
jpSearch = "猫";
|
||||
}
|
||||
var msgTask = msg.UpdateOrCreateMessageAsync(ch, "⏳ Searching...");
|
||||
var psnResponseUSTask = titleId == null ? Client.SearchAsync("en-US", alteredSearch, Config.Cts.Token) : Client.ResolveContentAsync("en-US", titleId, 1, Config.Cts.Token);
|
||||
var psnResponseEUTask = titleId == null ? Client.SearchAsync("en-GB", alteredSearch, Config.Cts.Token) : Client.ResolveContentAsync("en-GB", titleId, 1, Config.Cts.Token);
|
||||
var psnResponseJPTask = titleId == null ? Client.SearchAsync("ja-JP", alteredSearch, Config.Cts.Token) : Client.ResolveContentAsync("ja-JP", titleId, 1, Config.Cts.Token);
|
||||
var psnResponseJPTask = titleId == null ? Client.SearchAsync("ja-JP", jpSearch, Config.Cts.Token) : Client.ResolveContentAsync("ja-JP", titleId, 1, Config.Cts.Token);
|
||||
await Task.WhenAll(msgTask, psnResponseUSTask, psnResponseEUTask, psnResponseJPTask).ConfigureAwait(false);
|
||||
var responseUS = await psnResponseUSTask.ConfigureAwait(false);
|
||||
var responseEU = await psnResponseEUTask.ConfigureAwait(false);
|
||||
|
@ -127,6 +127,7 @@ namespace CompatBot.Database.Providers
|
||||
info = db.TitleInfo.Add(info).Entity;
|
||||
await db.SaveChangesAsync(Config.Cts.Token).ConfigureAwait(false);
|
||||
}
|
||||
DiscordColor? analyzedColor = null;
|
||||
if (string.IsNullOrEmpty(info.ThumbnailEmbeddableUrl))
|
||||
{
|
||||
var em = await GetEmbeddableUrlAsync(client, contentId, info.ThumbnailUrl).ConfigureAwait(false);
|
||||
@ -134,14 +135,20 @@ namespace CompatBot.Database.Providers
|
||||
{
|
||||
info.ThumbnailEmbeddableUrl = eUrl;
|
||||
if (em.image is byte[] jpg)
|
||||
info.EmbedColor = ColorGetter.Analyze(jpg, defaultColor).Value;
|
||||
{
|
||||
analyzedColor = ColorGetter.Analyze(jpg, defaultColor);
|
||||
var c = analyzedColor.Value.Value;
|
||||
if (c != defaultColor.Value)
|
||||
info.EmbedColor = c;
|
||||
}
|
||||
await db.SaveChangesAsync(Config.Cts.Token).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
if (!info.EmbedColor.HasValue)
|
||||
if ((!info.EmbedColor.HasValue && !analyzedColor.HasValue)
|
||||
|| (info.EmbedColor.HasValue && info.EmbedColor.Value == defaultColor.Value))
|
||||
{
|
||||
var c = await GetImageColorAsync(info.ThumbnailEmbeddableUrl, defaultColor).ConfigureAwait(false);
|
||||
if (c.HasValue)
|
||||
if (c.HasValue && c.Value.Value != defaultColor.Value)
|
||||
{
|
||||
info.EmbedColor = c.Value.Value;
|
||||
await db.SaveChangesAsync(Config.Cts.Token).ConfigureAwait(false);
|
||||
|
Loading…
Reference in New Issue
Block a user