.waifulb now has pages

This commit is contained in:
Master Kwoth 2017-06-14 17:28:57 +02:00
parent 3d76207887
commit 182ade0ad7
4 changed files with 13 additions and 7 deletions

View File

@ -377,12 +377,17 @@ namespace NadekoBot.Modules.Gambling
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task WaifuLeaderboard() public async Task WaifuLeaderboard(int page = 1)
{ {
page--;
if (page < 0)
return;
IList<WaifuInfo> waifus; IList<WaifuInfo> waifus;
using (var uow = _db.UnitOfWork) using (var uow = _db.UnitOfWork)
{ {
waifus = uow.Waifus.GetTop(9); waifus = uow.Waifus.GetTop(9, page * 9);
} }
if (waifus.Count == 0) if (waifus.Count == 0)
@ -400,7 +405,7 @@ namespace NadekoBot.Modules.Gambling
var w = waifus[i]; var w = waifus[i];
var j = i; var j = i;
embed.AddField(efb => efb.WithName("#" + (j + 1) + " - " + w.Price + _bc.CurrencySign).WithValue(w.ToString()).WithIsInline(false)); embed.AddField(efb => efb.WithName("#" + ((page * 9) + j + 1) + " - " + w.Price + _bc.CurrencySign).WithValue(w.ToString()).WithIsInline(false));
} }
await Context.Channel.EmbedAsync(embed).ConfigureAwait(false); await Context.Channel.EmbedAsync(embed).ConfigureAwait(false);

View File

@ -3037,10 +3037,10 @@
<value>waifus waifulb</value> <value>waifus waifulb</value>
</data> </data>
<data name="waifuleaderboard_desc" xml:space="preserve"> <data name="waifuleaderboard_desc" xml:space="preserve">
<value>Shows top 9 waifus.</value> <value>Shows top 9 waifus. You can specify another page to show other waifus.</value>
</data> </data>
<data name="waifuleaderboard_usage" xml:space="preserve"> <data name="waifuleaderboard_usage" xml:space="preserve">
<value>`{0}waifus`</value> <value>`{0}waifus` or `{0}waifulb 3`</value>
</data> </data>
<data name="divorce_cmd" xml:space="preserve"> <data name="divorce_cmd" xml:space="preserve">
<value>divorce</value> <value>divorce</value>

View File

@ -5,7 +5,7 @@ namespace NadekoBot.Services.Database.Repositories
{ {
public interface IWaifuRepository : IRepository<WaifuInfo> public interface IWaifuRepository : IRepository<WaifuInfo>
{ {
IList<WaifuInfo> GetTop(int count); IList<WaifuInfo> GetTop(int count, int skip = 0);
WaifuInfo ByWaifuUserId(ulong userId); WaifuInfo ByWaifuUserId(ulong userId);
IList<WaifuInfo> ByClaimerUserId(ulong userId); IList<WaifuInfo> ByClaimerUserId(ulong userId);
} }

View File

@ -29,7 +29,7 @@ namespace NadekoBot.Services.Database.Repositories.Impl
.ToList(); .ToList();
} }
public IList<WaifuInfo> GetTop(int count) public IList<WaifuInfo> GetTop(int count, int skip = 0)
{ {
if (count < 0) if (count < 0)
throw new ArgumentOutOfRangeException(nameof(count)); throw new ArgumentOutOfRangeException(nameof(count));
@ -40,6 +40,7 @@ namespace NadekoBot.Services.Database.Repositories.Impl
.Include(wi => wi.Affinity) .Include(wi => wi.Affinity)
.Include(wi => wi.Claimer) .Include(wi => wi.Claimer)
.OrderByDescending(wi => wi.Price) .OrderByDescending(wi => wi.Price)
.Skip(skip)
.Take(count) .Take(count)
.ToList(); .ToList();
} }