Finished new response system

This commit is contained in:
Kwoth
2024-05-02 06:47:01 +00:00
parent a25adefc65
commit fc4858830c
102 changed files with 1811 additions and 1818 deletions

View File

@@ -60,12 +60,12 @@ public partial class Permissions
.Page((pageItems, _) =>
{
if (pageItems.Count == 0)
return new EmbedBuilder()
return _sender.CreateEmbed()
.WithOkColor()
.WithTitle(title)
.WithDescription(GetText(strs.empty_page));
return new EmbedBuilder()
return _sender.CreateEmbed()
.WithTitle(title)
.WithDescription(allItems.Join('\n'))
.WithOkColor();

View File

@@ -61,7 +61,7 @@ public partial class Permissions
else
await Response().Confirm(strs.cmdcd_add(Format.Bold(name), Format.Bold(secs.ToString()))).SendAsync();
}
[Cmd]
[RequireContext(ContextType.Guild)]
[Priority(0)]
@@ -80,7 +80,7 @@ public partial class Permissions
{
if (--page < 0)
return;
var channel = (ITextChannel)ctx.Channel;
var localSet = _service.GetCommandCooldowns(ctx.Guild.Id);
@@ -88,17 +88,21 @@ public partial class Permissions
await Response().Confirm(strs.cmdcd_none).SendAsync();
else
{
await ctx.SendPaginatedConfirmAsync(page, curPage =>
{
var items = localSet.Skip(curPage * 15)
.Take(15)
.Select(x => $"{Format.Code(x.CommandName)}: {x.Seconds.Seconds().Humanize(maxUnit: TimeUnit.Second, culture: Culture)}");
await Response()
.Paginated()
.Items(localSet)
.PageSize(15)
.CurrentPage(page)
.Page((items, _) =>
{
var output = items.Select(x =>
$"{Format.Code(x.CommandName)}: {x.Seconds.Seconds().Humanize(maxUnit: TimeUnit.Second, culture: Culture)}");
return new EmbedBuilder()
.WithOkColor()
.WithDescription(items.Join("\n"));
}, localSet.Count, 15);
return _sender.CreateEmbed()
.WithOkColor()
.WithDescription(output.Join("\n"));
})
.SendAsync();
}
}
}

View File

@@ -29,9 +29,9 @@ public partial class Permissions
[RequireContext(ContextType.Guild)]
public async Task FilterList()
{
var embed = new EmbedBuilder()
.WithOkColor()
.WithTitle("Server filter settings");
var embed = _sender.CreateEmbed()
.WithOkColor()
.WithTitle("Server filter settings");
var config = await _service.GetFilterSettings(ctx.Guild.Id);
@@ -41,14 +41,14 @@ public partial class Permissions
async Task<string> GetChannelListAsync(IReadOnlyCollection<ulong> channels)
{
var toReturn = (await channels
.Select(async cid =>
{
var ch = await ctx.Guild.GetChannelAsync(cid);
return ch is null
? $"{cid} *missing*"
: $"<#{cid}>";
})
.WhenAll())
.Select(async cid =>
{
var ch = await ctx.Guild.GetChannelAsync(cid);
return ch is null
? $"{cid} *missing*"
: $"<#{cid}>";
})
.WhenAll())
.Join('\n');
if (string.IsNullOrWhiteSpace(toReturn))
@@ -312,13 +312,16 @@ public partial class Permissions
var fws = fwHash.ToArray();
await ctx.SendPaginatedConfirmAsync(page,
curPage => new EmbedBuilder()
.WithTitle(GetText(strs.filter_word_list))
.WithDescription(string.Join("\n", fws.Skip(curPage * 10).Take(10)))
.WithOkColor(),
fws.Length,
10);
await Response()
.Paginated()
.Items(fws)
.PageSize(10)
.CurrentPage(page)
.Page((items, _) => _sender.CreateEmbed()
.WithTitle(GetText(strs.filter_word_list))
.WithDescription(string.Join("\n", items))
.WithOkColor())
.SendAsync();
}
}
}

View File

@@ -30,7 +30,7 @@ public partial class Permissions
return;
}
var embed = new EmbedBuilder().WithOkColor();
var embed = _sender.CreateEmbed().WithOkColor();
if (blockedModule.Any())
embed.AddField(GetText(strs.blocked_modules), string.Join("\n", _service.BlockedModules));