mirror of
https://github.com/RPCS3/discord-bot.git
synced 2025-04-01 11:51:45 +00:00
return first game if filtering by score didn't work out
This commit is contained in:
parent
cda055882a
commit
993cc54c98
@ -342,6 +342,10 @@ namespace CompatBot.Commands
|
||||
[Command("download"), Cooldown(1, 10, CooldownBucketType.Channel)]
|
||||
[Description("Find games to download")]
|
||||
public Task Download(CommandContext ctx, [RemainingText] string game)
|
||||
=> Psn.SearchForGame(ctx, game);
|
||||
{
|
||||
if (game?.ToUpperInvariant() == "RPCS3")
|
||||
return CompatList.UpdatesCheck.CheckForRpcs3Updates(ctx.Client, ctx.Channel);
|
||||
return Psn.SearchForGame(ctx, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,14 +132,16 @@ namespace CompatBot.Commands
|
||||
if (included == null)
|
||||
return null;
|
||||
|
||||
return (
|
||||
from i in included
|
||||
var games = (from i in included
|
||||
where (i.Type == "game" || i.Type == "legacy-sku") && (i.Attributes.TopCategory != "demo" && i.Attributes.GameContentType != "Demo")
|
||||
let m = new {score = search.GetFuzzyCoefficientCached(i.Attributes.Name), item = i}
|
||||
where m.score > 0.3 || (i.Attributes.Name?.StartsWith(search, StringComparison.InvariantCultureIgnoreCase) ?? false)
|
||||
orderby m.score descending
|
||||
select m.item
|
||||
).FirstOrDefault();
|
||||
select i).ToList();
|
||||
return (from i in games
|
||||
let m = new {score = search.GetFuzzyCoefficientCached(i.Attributes.Name), item = i}
|
||||
where m.score > 0.3 || (i.Attributes.Name?.StartsWith(search, StringComparison.InvariantCultureIgnoreCase) ?? false)
|
||||
orderby m.score descending
|
||||
select m.item
|
||||
).FirstOrDefault() ??
|
||||
games.FirstOrDefault();
|
||||
}
|
||||
|
||||
private static async Task TryDeleteThumbnailCache(CommandContext ctx, List<(string contentId, string link)> linksToRemove)
|
||||
|
Loading…
x
Reference in New Issue
Block a user