mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-01-31 09:09:00 +03:00
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>
|
<value>Rename members who attempt to hoist themselves</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Page" xml:space="preserve">
|
<data name="Page" xml:space="preserve">
|
||||||
<value>page</value>
|
<value>Page</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="PageNotFound" xml:space="preserve">
|
<data name="PageNotFound" xml:space="preserve">
|
||||||
<value>Page not found!</value>
|
<value>Page not found!</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="PagesAllowed" xml:space="preserve">
|
<data name="PagesAllowed" xml:space="preserve">
|
||||||
<value>There are total pages</value>
|
<value>There are {0} total pages</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Next" xml:space="preserve">
|
<data name="Next" xml:space="preserve">
|
||||||
<value>Next</value>
|
<value>Next</value>
|
||||||
|
|
|
@ -562,13 +562,13 @@
|
||||||
<value>Переименовывать участников, которые пытаются поднять себя</value>
|
<value>Переименовывать участников, которые пытаются поднять себя</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Page" xml:space="preserve">
|
<data name="Page" xml:space="preserve">
|
||||||
<value>страница</value>
|
<value>Страница</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="PageNotFound" xml:space="preserve">
|
<data name="PageNotFound" xml:space="preserve">
|
||||||
<value>Страница не найдена!</value>
|
<value>Страница не найдена!</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="PagesAllowed" xml:space="preserve">
|
<data name="PagesAllowed" xml:space="preserve">
|
||||||
<value>Всего страниц существует</value>
|
<value>Всего есть {0} страниц(-ы)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Next" xml:space="preserve">
|
<data name="Next" xml:space="preserve">
|
||||||
<value>Далее</value>
|
<value>Далее</value>
|
||||||
|
|
|
@ -568,7 +568,7 @@
|
||||||
<value>если я был бы html, я бы сказал 404</value>
|
<value>если я был бы html, я бы сказал 404</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="PagesAllowed" xml:space="preserve">
|
<data name="PagesAllowed" xml:space="preserve">
|
||||||
<value>ну а если быть точнее, тут всего страниц</value>
|
<value>ну а если быть точнее, тут всего {0} страниц(-ы)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Next" xml:space="preserve">
|
<data name="Next" xml:space="preserve">
|
||||||
<value>следующее</value>
|
<value>следующее</value>
|
||||||
|
|
|
@ -85,37 +85,43 @@ public class SettingsCommandGroup : CommandGroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> SendSettingsListAsync(JsonNode cfg, IUser currentUser, int page, CancellationToken ct = default) {
|
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();
|
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} ");
|
const int optionsPerPage = 10;
|
||||||
for (var i = 1; i <= totalPages; i++) footer.Append(i == page ? "●" : "○");
|
|
||||||
|
|
||||||
var embed = new EmbedBuilder().WithSmallTitle(Messages.SettingsListTitle, currentUser)
|
var totalPages = (AllOptions.Length + optionsPerPage - 1) / optionsPerPage;
|
||||||
.WithDescription(builder.ToString())
|
var lastOptionOnPage = Math.Min(optionsPerPage * page, AllOptions.Length);
|
||||||
.WithColour(ColorsList.Default)
|
var firstOptionOnPage = optionsPerPage * page - optionsPerPage;
|
||||||
.WithFooter(footer.ToString())
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
if (optionsPerList * page - optionsPerList >= AllOptions.Length) {
|
if (firstOptionOnPage >= AllOptions.Length) {
|
||||||
embed = new EmbedBuilder().WithSmallTitle(Messages.PageNotFound, currentUser)
|
var embed = new EmbedBuilder().WithSmallTitle(Messages.PageNotFound, currentUser)
|
||||||
.WithDescription($"{Messages.PagesAllowed}: {Markdown.Bold(totalPages.ToString())}")
|
.WithDescription(string.Format(Messages.PagesAllowed, Markdown.Bold(totalPages.ToString())))
|
||||||
.WithColour(ColorsList.Red)
|
.WithColour(ColorsList.Red)
|
||||||
.Build();
|
.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>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in a new issue