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:
@@ -4,7 +4,6 @@ using System.Diagnostics.CodeAnalysis;
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
|
||||
[SuppressMessage("Style", "IDE0022:Use expression body for methods")]
|
||||
public sealed class NoPublicBotAttribute : PreconditionAttribute
|
||||
{
|
||||
public override Task<PreconditionResult> CheckPermissionsAsync(
|
||||
|
@@ -25,7 +25,7 @@ public partial class ResponseBuilder
|
||||
|
||||
public async Task SendAsync(bool ephemeral = false)
|
||||
{
|
||||
var lastPage = (_paginationBuilder.TotalElements - 1)
|
||||
var lastPage = (_paginationBuilder.Elems - 1)
|
||||
/ _paginationBuilder.ItemsPerPage;
|
||||
|
||||
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 int TotalElements { get; private set; } = 1;
|
||||
public int Elems { get; private set; } = 1;
|
||||
public int ItemsPerPage { get; private set; } = 9;
|
||||
public bool AddPaginatedFooter { get; private set; } = true;
|
||||
public bool IsEphemeral { get; private set; }
|
||||
@@ -411,10 +411,16 @@ public sealed class SourcedPaginatedResponseBuilder<T> : PaginatedResponseBuilde
|
||||
public SourcedPaginatedResponseBuilder<T> Items(IReadOnlyCollection<T> col)
|
||||
{
|
||||
items = col;
|
||||
TotalElements = col.Count;
|
||||
Elems = col.Count;
|
||||
ItemsFunc = (i) => Task.FromResult(items.Skip(i * ItemsPerPage).Take(ItemsPerPage));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SourcedPaginatedResponseBuilder<T> TotalElements(int i)
|
||||
{
|
||||
Elems = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SourcedPaginatedResponseBuilder<T> PageItems(Func<int, Task<IEnumerable<T>>> func)
|
||||
{
|
||||
|
@@ -113,7 +113,7 @@ public static class ServiceCollectionExtensions
|
||||
typeof(IInputTransformer),
|
||||
typeof(INService)
|
||||
];
|
||||
|
||||
|
||||
foreach (var svc in a.GetTypes()
|
||||
.Where(type => type.IsClass && types.Any(t => type.IsAssignableTo(t)) && !type.HasAttribute<DIIgnoreAttribute>()
|
||||
#if GLOBAL_NADEKO
|
||||
|
@@ -10,7 +10,12 @@ public static class UserExtensions
|
||||
|
||||
// This method is only used for the xp card
|
||||
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
|
||||
: null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user