mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
fix: .h fixed, .xp fixed, pagination in .lb fixed
This commit is contained in:
@@ -776,7 +776,7 @@ public partial class Gambling : GamblingModule<GamblingService>
|
|||||||
await using var uow = _db.GetDbContext();
|
await using var uow = _db.GetDbContext();
|
||||||
|
|
||||||
var cleanRichest = await uow.Set<DiscordUser>()
|
var cleanRichest = await uow.Set<DiscordUser>()
|
||||||
.GetTopRichest(_client.CurrentUser.Id, 0, 10_000);
|
.GetTopRichest(_client.CurrentUser.Id, 0, 1000);
|
||||||
|
|
||||||
var sg = (SocketGuild)ctx.Guild!;
|
var sg = (SocketGuild)ctx.Guild!;
|
||||||
return cleanRichest.Where(x => sg.GetUser(x.UserId) is not null).ToList();
|
return cleanRichest.Where(x => sg.GetUser(x.UserId) is not null).ToList();
|
||||||
@@ -787,10 +787,14 @@ public partial class Gambling : GamblingModule<GamblingService>
|
|||||||
return await uow.Set<DiscordUser>().GetTopRichest(_client.CurrentUser.Id, curPage);
|
return await uow.Set<DiscordUser>().GetTopRichest(_client.CurrentUser.Id, curPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var res = Response()
|
||||||
|
.Paginated();
|
||||||
|
|
||||||
await Response()
|
await Response()
|
||||||
.Paginated()
|
.Paginated()
|
||||||
.PageItems(GetTopRichest)
|
.PageItems(GetTopRichest)
|
||||||
|
.TotalElements(900)
|
||||||
.PageSize(9)
|
.PageSize(9)
|
||||||
.CurrentPage(page)
|
.CurrentPage(page)
|
||||||
.Page((toSend, curPage) =>
|
.Page((toSend, curPage) =>
|
||||||
|
@@ -10,7 +10,7 @@ using JsonSerializer = System.Text.Json.JsonSerializer;
|
|||||||
|
|
||||||
namespace NadekoBot.Modules.Help;
|
namespace NadekoBot.Modules.Help;
|
||||||
|
|
||||||
public sealed class Help : NadekoModule<HelpService>
|
public sealed partial class Help : NadekoModule<HelpService>
|
||||||
{
|
{
|
||||||
public const string PATREON_URL = "https://patreon.com/nadekobot";
|
public const string PATREON_URL = "https://patreon.com/nadekobot";
|
||||||
public const string PAYPAL_URL = "https://paypal.me/Kwoth";
|
public const string PAYPAL_URL = "https://paypal.me/Kwoth";
|
||||||
@@ -72,7 +72,7 @@ public sealed class Help : NadekoModule<HelpService>
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var topLevelModules = new List<ModuleInfo>();
|
var topLevelModules = new List<ModuleInfo>();
|
||||||
foreach (var m in _cmds.Modules.GroupBy(x => x.GetTopLevelModule()).Select(x => x.Key))
|
foreach (var m in _cmds.Modules.GroupBy(x => x.GetTopLevelModule()).OrderBy(x => x.Key.Name).Select(x => x.Key))
|
||||||
{
|
{
|
||||||
var result = await _perms.CheckPermsAsync(ctx.Guild,
|
var result = await _perms.CheckPermsAsync(ctx.Guild,
|
||||||
ctx.Channel,
|
ctx.Channel,
|
||||||
@@ -80,6 +80,11 @@ public sealed class Help : NadekoModule<HelpService>
|
|||||||
m.Name,
|
m.Name,
|
||||||
null);
|
null);
|
||||||
|
|
||||||
|
#if GLOBAL_NADEKO
|
||||||
|
if (m.Preconditions.Any(x => x is NoPublicBotAttribute))
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (result.IsAllowed)
|
if (result.IsAllowed)
|
||||||
topLevelModules.Add(m);
|
topLevelModules.Add(m);
|
||||||
}
|
}
|
||||||
@@ -100,13 +105,13 @@ public sealed class Help : NadekoModule<HelpService>
|
|||||||
return embed;
|
return embed;
|
||||||
}
|
}
|
||||||
|
|
||||||
items.OrderBy(module => module.Name)
|
items
|
||||||
.ToList()
|
.ToList()
|
||||||
.ForEach(module => embed.AddField($"{GetModuleEmoji(module.Name)} {module.Name}",
|
.ForEach(module => embed.AddField($"{GetModuleEmoji(module.Name)} {module.Name}",
|
||||||
GetModuleDescription(module.Name)
|
GetModuleDescription(module.Name)
|
||||||
+ "\n"
|
+ "\n"
|
||||||
+ Format.Code(GetText(strs.module_footer(prefix, module.Name.ToLowerInvariant()))),
|
+ Format.Code(GetText(strs.module_footer(prefix, module.Name.ToLowerInvariant()))),
|
||||||
true));
|
true));
|
||||||
|
|
||||||
return embed;
|
return embed;
|
||||||
})
|
})
|
||||||
@@ -311,7 +316,7 @@ public sealed class Help : NadekoModule<HelpService>
|
|||||||
{
|
{
|
||||||
string cmdName;
|
string cmdName;
|
||||||
if (cmd.Aliases.Count > 1)
|
if (cmd.Aliases.Count > 1)
|
||||||
cmdName = Format.Code(prefix +cmd.Aliases[0]) + " | " + Format.Code(prefix + cmd.Aliases[1]);
|
cmdName = Format.Code(prefix + cmd.Aliases[0]) + " | " + Format.Code(prefix + cmd.Aliases[1]);
|
||||||
else
|
else
|
||||||
cmdName = Format.Code(prefix + cmd.Aliases.First());
|
cmdName = Format.Code(prefix + cmd.Aliases.First());
|
||||||
|
|
||||||
@@ -355,17 +360,16 @@ public sealed class Help : NadekoModule<HelpService>
|
|||||||
public async Task H([Leftover] CommandInfo com = null)
|
public async Task H([Leftover] CommandInfo com = null)
|
||||||
{
|
{
|
||||||
var channel = ctx.Channel;
|
var channel = ctx.Channel;
|
||||||
|
|
||||||
if (com is null)
|
if (com is null)
|
||||||
{
|
{
|
||||||
var ch = channel is ITextChannel ? await ctx.User.CreateDMChannelAsync() : channel;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var ch = channel is ITextChannel ? await ctx.User.CreateDMChannelAsync() : channel;
|
||||||
var data = await GetHelpString();
|
var data = await GetHelpString();
|
||||||
if (data == default)
|
if (data == default)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
await Response().Text(data).SendAsync();
|
await Response().Channel(ch).Text(data).SendAsync();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await ctx.OkAsync();
|
await ctx.OkAsync();
|
||||||
|
@@ -1,149 +1,156 @@
|
|||||||
namespace NadekoBot.Modules.Patronage;
|
using NadekoBot.Modules.Patronage;
|
||||||
|
|
||||||
[OnlyPublicBot]
|
namespace NadekoBot.Modules.Help;
|
||||||
public partial class Patronage : NadekoModule
|
|
||||||
|
public partial class Help
|
||||||
{
|
{
|
||||||
private readonly PatronageService _service;
|
[OnlyPublicBot]
|
||||||
private readonly PatronageConfig _pConf;
|
public partial class Patronage : NadekoModule
|
||||||
|
|
||||||
public Patronage(PatronageService service, PatronageConfig pConf)
|
|
||||||
{
|
{
|
||||||
_service = service;
|
private readonly PatronageService _service;
|
||||||
_pConf = pConf;
|
private readonly PatronageConfig _pConf;
|
||||||
}
|
|
||||||
|
|
||||||
[Cmd]
|
public Patronage(PatronageService service, PatronageConfig pConf)
|
||||||
[Priority(2)]
|
|
||||||
public Task Patron()
|
|
||||||
=> InternalPatron(ctx.User);
|
|
||||||
|
|
||||||
[Cmd]
|
|
||||||
[Priority(0)]
|
|
||||||
[OwnerOnly]
|
|
||||||
public Task Patron(IUser user)
|
|
||||||
=> InternalPatron(user);
|
|
||||||
|
|
||||||
[Cmd]
|
|
||||||
[Priority(0)]
|
|
||||||
[OwnerOnly]
|
|
||||||
public async Task PatronMessage(PatronTier tierAndHigher, string message)
|
|
||||||
{
|
|
||||||
_ = ctx.Channel.TriggerTypingAsync();
|
|
||||||
var result = await _service.SendMessageToPatronsAsync(tierAndHigher, message);
|
|
||||||
|
|
||||||
await Response()
|
|
||||||
.Confirm(strs.patron_msg_sent(
|
|
||||||
Format.Code(tierAndHigher.ToString()),
|
|
||||||
Format.Bold(result.Success.ToString()),
|
|
||||||
Format.Bold(result.Failed.ToString())))
|
|
||||||
.SendAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
// [OwnerOnly]
|
|
||||||
// public async Task PatronGift(IUser user, int amount)
|
|
||||||
// {
|
|
||||||
// // i can't figure out a good way to gift more than one month at the moment.
|
|
||||||
//
|
|
||||||
// if (amount < 1)
|
|
||||||
// return;
|
|
||||||
//
|
|
||||||
// var patron = _service.GiftPatronAsync(user, amount);
|
|
||||||
//
|
|
||||||
// var eb = _sender.CreateEmbed();
|
|
||||||
//
|
|
||||||
// await Response().Embed(eb.WithDescription($"Added **{days}** days of Patron benefits to {user.Mention}!")
|
|
||||||
// .AddField("Tier", Format.Bold(patron.Tier.ToString()), true)
|
|
||||||
// .AddField("Amount", $"**{patron.Amount / 100.0f:N1}$**", true)
|
|
||||||
// .AddField("Until", TimestampTag.FromDateTime(patron.ValidThru.AddDays(1)))).SendAsync();
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
private async Task InternalPatron(IUser user)
|
|
||||||
{
|
|
||||||
if (!_pConf.Data.IsEnabled)
|
|
||||||
{
|
{
|
||||||
await Response().Error(strs.patron_not_enabled).SendAsync();
|
_service = service;
|
||||||
return;
|
_pConf = pConf;
|
||||||
}
|
}
|
||||||
|
|
||||||
var patron = await _service.GetPatronAsync(user.Id);
|
[Cmd]
|
||||||
var quotaStats = await _service.GetUserQuotaStatistic(user.Id);
|
[Priority(2)]
|
||||||
|
public Task Patron()
|
||||||
|
=> InternalPatron(ctx.User);
|
||||||
|
|
||||||
var eb = _sender.CreateEmbed()
|
[Cmd]
|
||||||
.WithAuthor(user)
|
[Priority(0)]
|
||||||
.WithTitle(GetText(strs.patron_info))
|
[OwnerOnly]
|
||||||
.WithOkColor();
|
public Task Patron(IUser user)
|
||||||
|
=> InternalPatron(user);
|
||||||
|
|
||||||
if (quotaStats.Commands.Count == 0
|
[Cmd]
|
||||||
&& quotaStats.Groups.Count == 0
|
[Priority(0)]
|
||||||
&& quotaStats.Modules.Count == 0)
|
[OwnerOnly]
|
||||||
|
public async Task PatronMessage(PatronTier tierAndHigher, string message)
|
||||||
{
|
{
|
||||||
eb.WithDescription(GetText(strs.no_quota_found));
|
_ = ctx.Channel.TriggerTypingAsync();
|
||||||
|
var result = await _service.SendMessageToPatronsAsync(tierAndHigher, message);
|
||||||
|
|
||||||
|
await Response()
|
||||||
|
.Confirm(strs.patron_msg_sent(
|
||||||
|
Format.Code(tierAndHigher.ToString()),
|
||||||
|
Format.Bold(result.Success.ToString()),
|
||||||
|
Format.Bold(result.Failed.ToString())))
|
||||||
|
.SendAsync();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// [OwnerOnly]
|
||||||
|
// public async Task PatronGift(IUser user, int amount)
|
||||||
|
// {
|
||||||
|
// // i can't figure out a good way to gift more than one month at the moment.
|
||||||
|
//
|
||||||
|
// if (amount < 1)
|
||||||
|
// return;
|
||||||
|
//
|
||||||
|
// var patron = _service.GiftPatronAsync(user, amount);
|
||||||
|
//
|
||||||
|
// var eb = _sender.CreateEmbed();
|
||||||
|
//
|
||||||
|
// await Response().Embed(eb.WithDescription($"Added **{days}** days of Patron benefits to {user.Mention}!")
|
||||||
|
// .AddField("Tier", Format.Bold(patron.Tier.ToString()), true)
|
||||||
|
// .AddField("Amount", $"**{patron.Amount / 100.0f:N1}$**", true)
|
||||||
|
// .AddField("Until", TimestampTag.FromDateTime(patron.ValidThru.AddDays(1)))).SendAsync();
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
private async Task InternalPatron(IUser user)
|
||||||
{
|
{
|
||||||
eb.AddField(GetText(strs.tier), Format.Bold(patron.Tier.ToFullName()), true)
|
if (!_pConf.Data.IsEnabled)
|
||||||
.AddField(GetText(strs.pledge), $"**{patron.Amount / 100.0f:N1}$**", true);
|
|
||||||
|
|
||||||
if (patron.Tier != PatronTier.None)
|
|
||||||
eb.AddField(GetText(strs.expires), patron.ValidThru.AddDays(1).ToShortAndRelativeTimestampTag(), true);
|
|
||||||
|
|
||||||
eb.AddField(GetText(strs.quotas), "", false);
|
|
||||||
|
|
||||||
if (quotaStats.Commands.Count > 0)
|
|
||||||
{
|
{
|
||||||
var text = GetQuotaList(quotaStats.Commands);
|
await Response().Error(strs.patron_not_enabled).SendAsync();
|
||||||
if (!string.IsNullOrWhiteSpace(text))
|
return;
|
||||||
eb.AddField(GetText(strs.commands), text, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (quotaStats.Groups.Count > 0)
|
var patron = await _service.GetPatronAsync(user.Id);
|
||||||
|
var quotaStats = await _service.GetUserQuotaStatistic(user.Id);
|
||||||
|
|
||||||
|
var eb = _sender.CreateEmbed()
|
||||||
|
.WithAuthor(user)
|
||||||
|
.WithTitle(GetText(strs.patron_info))
|
||||||
|
.WithOkColor();
|
||||||
|
|
||||||
|
if (quotaStats.Commands.Count == 0
|
||||||
|
&& quotaStats.Groups.Count == 0
|
||||||
|
&& quotaStats.Modules.Count == 0)
|
||||||
{
|
{
|
||||||
var text = GetQuotaList(quotaStats.Groups);
|
eb.WithDescription(GetText(strs.no_quota_found));
|
||||||
if (!string.IsNullOrWhiteSpace(text))
|
}
|
||||||
eb.AddField(GetText(strs.groups), text, true);
|
else
|
||||||
|
{
|
||||||
|
eb.AddField(GetText(strs.tier), Format.Bold(patron.Tier.ToFullName()), true)
|
||||||
|
.AddField(GetText(strs.pledge), $"**{patron.Amount / 100.0f:N1}$**", true);
|
||||||
|
|
||||||
|
if (patron.Tier != PatronTier.None)
|
||||||
|
eb.AddField(GetText(strs.expires),
|
||||||
|
patron.ValidThru.AddDays(1).ToShortAndRelativeTimestampTag(),
|
||||||
|
true);
|
||||||
|
|
||||||
|
eb.AddField(GetText(strs.quotas), "", false);
|
||||||
|
|
||||||
|
if (quotaStats.Commands.Count > 0)
|
||||||
|
{
|
||||||
|
var text = GetQuotaList(quotaStats.Commands);
|
||||||
|
if (!string.IsNullOrWhiteSpace(text))
|
||||||
|
eb.AddField(GetText(strs.commands), text, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (quotaStats.Groups.Count > 0)
|
||||||
|
{
|
||||||
|
var text = GetQuotaList(quotaStats.Groups);
|
||||||
|
if (!string.IsNullOrWhiteSpace(text))
|
||||||
|
eb.AddField(GetText(strs.groups), text, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (quotaStats.Modules.Count > 0)
|
||||||
|
{
|
||||||
|
var text = GetQuotaList(quotaStats.Modules);
|
||||||
|
if (!string.IsNullOrWhiteSpace(text))
|
||||||
|
eb.AddField(GetText(strs.modules), text, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (quotaStats.Modules.Count > 0)
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var text = GetQuotaList(quotaStats.Modules);
|
await Response().User(ctx.User).Embed(eb).SendAsync();
|
||||||
if (!string.IsNullOrWhiteSpace(text))
|
_ = ctx.OkAsync();
|
||||||
eb.AddField(GetText(strs.modules), text, true);
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await Response().Error(strs.cant_dm).SendAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetQuotaList(IReadOnlyDictionary<string, FeatureQuotaStats> featureQuotaStats)
|
||||||
|
{
|
||||||
|
var text = string.Empty;
|
||||||
|
foreach (var (key, q) in featureQuotaStats)
|
||||||
|
{
|
||||||
|
text += $"\n\t`{key}`\n";
|
||||||
|
if (q.Hourly != default)
|
||||||
|
text += $" {GetEmoji(q.Hourly)} {q.Hourly.Cur}/{q.Hourly.Max} per hour\n";
|
||||||
|
if (q.Daily != default)
|
||||||
|
text += $" {GetEmoji(q.Daily)} {q.Daily.Cur}/{q.Daily.Max} per day\n";
|
||||||
|
if (q.Monthly != default)
|
||||||
|
text += $" {GetEmoji(q.Monthly)} {q.Monthly.Cur}/{q.Monthly.Max} per month\n";
|
||||||
|
}
|
||||||
|
|
||||||
try
|
return text;
|
||||||
{
|
|
||||||
await Response().User(ctx.User).Embed(eb).SendAsync();
|
|
||||||
_ = ctx.OkAsync();
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
await Response().Error(strs.cant_dm).SendAsync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetEmoji((uint Cur, uint Max) limit)
|
||||||
|
=> limit.Cur < limit.Max
|
||||||
|
? "✅"
|
||||||
|
: "⚠️";
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetQuotaList(IReadOnlyDictionary<string, FeatureQuotaStats> featureQuotaStats)
|
|
||||||
{
|
|
||||||
var text = string.Empty;
|
|
||||||
foreach (var (key, q) in featureQuotaStats)
|
|
||||||
{
|
|
||||||
text += $"\n\t`{key}`\n";
|
|
||||||
if (q.Hourly != default)
|
|
||||||
text += $" {GetEmoji(q.Hourly)} {q.Hourly.Cur}/{q.Hourly.Max} per hour\n";
|
|
||||||
if (q.Daily != default)
|
|
||||||
text += $" {GetEmoji(q.Daily)} {q.Daily.Cur}/{q.Daily.Max} per day\n";
|
|
||||||
if (q.Monthly != default)
|
|
||||||
text += $" {GetEmoji(q.Monthly)} {q.Monthly.Cur}/{q.Monthly.Max} per month\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
private string GetEmoji((uint Cur, uint Max) limit)
|
|
||||||
=> limit.Cur < limit.Max
|
|
||||||
? "✅"
|
|
||||||
: "⚠️";
|
|
||||||
}
|
}
|
@@ -1194,7 +1194,7 @@ public class XpService : INService, IReadyExecutor, IExecNoCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
//avatar
|
//avatar
|
||||||
if (stats.User.AvatarId is not null && template.User.Icon.Show)
|
if (template.User.Icon.Show)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>true</ImplicitUsings>
|
<ImplicitUsings>true</ImplicitUsings>
|
||||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||||
<Version>5.0.3</Version>
|
<Version>5.0.4</Version>
|
||||||
|
|
||||||
<!-- Output/build -->
|
<!-- Output/build -->
|
||||||
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
|
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
|
||||||
|
@@ -4,7 +4,6 @@ using System.Diagnostics.CodeAnalysis;
|
|||||||
namespace NadekoBot.Common;
|
namespace NadekoBot.Common;
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
|
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
|
||||||
[SuppressMessage("Style", "IDE0022:Use expression body for methods")]
|
|
||||||
public sealed class NoPublicBotAttribute : PreconditionAttribute
|
public sealed class NoPublicBotAttribute : PreconditionAttribute
|
||||||
{
|
{
|
||||||
public override Task<PreconditionResult> CheckPermissionsAsync(
|
public override Task<PreconditionResult> CheckPermissionsAsync(
|
||||||
|
@@ -25,7 +25,7 @@ public partial class ResponseBuilder
|
|||||||
|
|
||||||
public async Task SendAsync(bool ephemeral = false)
|
public async Task SendAsync(bool ephemeral = false)
|
||||||
{
|
{
|
||||||
var lastPage = (_paginationBuilder.TotalElements - 1)
|
var lastPage = (_paginationBuilder.Elems - 1)
|
||||||
/ _paginationBuilder.ItemsPerPage;
|
/ _paginationBuilder.ItemsPerPage;
|
||||||
|
|
||||||
var items = (await _paginationBuilder.ItemsFunc(currentPage)).ToArray();
|
var items = (await _paginationBuilder.ItemsFunc(currentPage)).ToArray();
|
||||||
|
@@ -396,7 +396,7 @@ public sealed class SourcedPaginatedResponseBuilder<T> : PaginatedResponseBuilde
|
|||||||
|
|
||||||
public Func<int, Task<SimpleInteractionBase>>? InteractionFunc { get; private set; }
|
public Func<int, Task<SimpleInteractionBase>>? InteractionFunc { get; private set; }
|
||||||
|
|
||||||
public int TotalElements { get; private set; } = 1;
|
public int Elems { get; private set; } = 1;
|
||||||
public int ItemsPerPage { get; private set; } = 9;
|
public int ItemsPerPage { get; private set; } = 9;
|
||||||
public bool AddPaginatedFooter { get; private set; } = true;
|
public bool AddPaginatedFooter { get; private set; } = true;
|
||||||
public bool IsEphemeral { get; private set; }
|
public bool IsEphemeral { get; private set; }
|
||||||
@@ -411,10 +411,16 @@ public sealed class SourcedPaginatedResponseBuilder<T> : PaginatedResponseBuilde
|
|||||||
public SourcedPaginatedResponseBuilder<T> Items(IReadOnlyCollection<T> col)
|
public SourcedPaginatedResponseBuilder<T> Items(IReadOnlyCollection<T> col)
|
||||||
{
|
{
|
||||||
items = col;
|
items = col;
|
||||||
TotalElements = col.Count;
|
Elems = col.Count;
|
||||||
ItemsFunc = (i) => Task.FromResult(items.Skip(i * ItemsPerPage).Take(ItemsPerPage));
|
ItemsFunc = (i) => Task.FromResult(items.Skip(i * ItemsPerPage).Take(ItemsPerPage));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SourcedPaginatedResponseBuilder<T> TotalElements(int i)
|
||||||
|
{
|
||||||
|
Elems = i;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public SourcedPaginatedResponseBuilder<T> PageItems(Func<int, Task<IEnumerable<T>>> func)
|
public SourcedPaginatedResponseBuilder<T> PageItems(Func<int, Task<IEnumerable<T>>> func)
|
||||||
{
|
{
|
||||||
|
@@ -113,7 +113,7 @@ public static class ServiceCollectionExtensions
|
|||||||
typeof(IInputTransformer),
|
typeof(IInputTransformer),
|
||||||
typeof(INService)
|
typeof(INService)
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach (var svc in a.GetTypes()
|
foreach (var svc in a.GetTypes()
|
||||||
.Where(type => type.IsClass && types.Any(t => type.IsAssignableTo(t)) && !type.HasAttribute<DIIgnoreAttribute>()
|
.Where(type => type.IsClass && types.Any(t => type.IsAssignableTo(t)) && !type.HasAttribute<DIIgnoreAttribute>()
|
||||||
#if GLOBAL_NADEKO
|
#if GLOBAL_NADEKO
|
||||||
|
@@ -10,7 +10,12 @@ public static class UserExtensions
|
|||||||
|
|
||||||
// This method is only used for the xp card
|
// This method is only used for the xp card
|
||||||
public static Uri? RealAvatarUrl(this DiscordUser usr)
|
public static Uri? RealAvatarUrl(this DiscordUser usr)
|
||||||
=> Uri.TryCreate(CDN.GetDefaultUserAvatarUrl(usr.UserId), UriKind.Absolute, out var uri)
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(usr.AvatarId))
|
||||||
|
return new Uri(CDN.GetUserAvatarUrl(usr.UserId, usr.AvatarId, 128, ImageFormat.Png));
|
||||||
|
|
||||||
|
return Uri.TryCreate(CDN.GetDefaultUserAvatarUrl(usr.UserId), UriKind.Absolute, out var uri)
|
||||||
? uri
|
? uri
|
||||||
: null;
|
: null;
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user