forked from TeamInklings/Octobot
Signed-off-by: Macintosh II <95250141+mctaylors@users.noreply.github.com>
This commit is contained in:
parent
8f95e4cd2c
commit
a6df26af67
4 changed files with 35 additions and 29 deletions
|
@ -562,13 +562,13 @@
|
|||
<value>Rename members who attempt to hoist themselves</value>
|
||||
</data>
|
||||
<data name="Page" xml:space="preserve">
|
||||
<value>page</value>
|
||||
<value>Page</value>
|
||||
</data>
|
||||
<data name="PageNotFound" xml:space="preserve">
|
||||
<value>Page not found!</value>
|
||||
</data>
|
||||
<data name="PagesAllowed" xml:space="preserve">
|
||||
<value>There are total pages</value>
|
||||
<value>There are {0} total pages</value>
|
||||
</data>
|
||||
<data name="Next" xml:space="preserve">
|
||||
<value>Next</value>
|
||||
|
|
|
@ -562,13 +562,13 @@
|
|||
<value>Переименовывать участников, которые пытаются поднять себя</value>
|
||||
</data>
|
||||
<data name="Page" xml:space="preserve">
|
||||
<value>страница</value>
|
||||
<value>Страница</value>
|
||||
</data>
|
||||
<data name="PageNotFound" xml:space="preserve">
|
||||
<value>Страница не найдена!</value>
|
||||
</data>
|
||||
<data name="PagesAllowed" xml:space="preserve">
|
||||
<value>Всего страниц существует</value>
|
||||
<value>Всего есть {0} страниц(-ы)</value>
|
||||
</data>
|
||||
<data name="Next" xml:space="preserve">
|
||||
<value>Далее</value>
|
||||
|
|
|
@ -568,7 +568,7 @@
|
|||
<value>если я был бы html, я бы сказал 404</value>
|
||||
</data>
|
||||
<data name="PagesAllowed" xml:space="preserve">
|
||||
<value>ну а если быть точнее, тут всего страниц</value>
|
||||
<value>ну а если быть точнее, тут всего {0} страниц(-ы)</value>
|
||||
</data>
|
||||
<data name="Next" xml:space="preserve">
|
||||
<value>следующее</value>
|
||||
|
|
|
@ -85,37 +85,43 @@ public class SettingsCommandGroup : CommandGroup {
|
|||
}
|
||||
|
||||
private async Task<Result> SendSettingsListAsync(JsonNode cfg, IUser currentUser, int page, CancellationToken ct = default) {
|
||||
var builder = new StringBuilder();
|
||||
var description = new StringBuilder();
|
||||
var footer = new StringBuilder();
|
||||
const int optionsPerList = 7;
|
||||
var totalPages = (AllOptions.Length + optionsPerList - 1)/optionsPerList;
|
||||
for (var i = optionsPerList * page - optionsPerList; i <= optionsPerList * page - 1; i++) {
|
||||
try {
|
||||
builder.AppendLine($"Settings{AllOptions[i].Name}".Localized())
|
||||
.Append(Markdown.InlineCode(AllOptions[i].Name))
|
||||
.Append(": ")
|
||||
.AppendLine(AllOptions[i].Display(cfg))
|
||||
.AppendLine();
|
||||
} catch { /* hilariously ignored */ }
|
||||
}
|
||||
|
||||
footer.Append($"{Messages.Page} {page}/{totalPages} ");
|
||||
for (var i = 1; i <= totalPages; i++) footer.Append(i == page ? "●" : "○");
|
||||
const int optionsPerPage = 10;
|
||||
|
||||
var embed = new EmbedBuilder().WithSmallTitle(Messages.SettingsListTitle, currentUser)
|
||||
.WithDescription(builder.ToString())
|
||||
.WithColour(ColorsList.Default)
|
||||
.WithFooter(footer.ToString())
|
||||
.Build();
|
||||
var totalPages = (AllOptions.Length + optionsPerPage - 1) / optionsPerPage;
|
||||
var lastOptionOnPage = Math.Min(optionsPerPage * page, AllOptions.Length);
|
||||
var firstOptionOnPage = optionsPerPage * page - optionsPerPage;
|
||||
|
||||
if (optionsPerList * page - optionsPerList >= AllOptions.Length) {
|
||||
embed = new EmbedBuilder().WithSmallTitle(Messages.PageNotFound, currentUser)
|
||||
.WithDescription($"{Messages.PagesAllowed}: {Markdown.Bold(totalPages.ToString())}")
|
||||
if (firstOptionOnPage >= AllOptions.Length) {
|
||||
var embed = new EmbedBuilder().WithSmallTitle(Messages.PageNotFound, currentUser)
|
||||
.WithDescription(string.Format(Messages.PagesAllowed, Markdown.Bold(totalPages.ToString())))
|
||||
.WithColour(ColorsList.Red)
|
||||
.Build();
|
||||
}
|
||||
|
||||
return await _feedbackService.SendContextualEmbedResultAsync(embed, ct);
|
||||
return await _feedbackService.SendContextualEmbedResultAsync(embed, ct);
|
||||
} else {
|
||||
footer.Append($"{Messages.Page} {page}/{totalPages} ");
|
||||
for (var i = 0; i < totalPages; i++) footer.Append(i + 1 == page ? "●" : "○");
|
||||
|
||||
for (var i = firstOptionOnPage; i < lastOptionOnPage; i++) {
|
||||
var optionName = AllOptions[i].Name;
|
||||
var optionValue = AllOptions[i].Display(cfg);
|
||||
|
||||
description.AppendLine($"- {$"Settings{optionName}".Localized()}")
|
||||
.Append($" - {Markdown.InlineCode(optionName)}: ")
|
||||
.AppendLine(optionValue);
|
||||
}
|
||||
|
||||
var embed = new EmbedBuilder().WithSmallTitle(Messages.SettingsListTitle, currentUser)
|
||||
.WithDescription(description.ToString())
|
||||
.WithColour(ColorsList.Default)
|
||||
.WithFooter(footer.ToString())
|
||||
.Build();
|
||||
|
||||
return await _feedbackService.SendContextualEmbedResultAsync(embed, ct);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Reference in a new issue