.warnlogall command added
This commit is contained in:
parent
e9365b7753
commit
b08ad7cb77
@ -191,6 +191,39 @@ namespace NadekoBot.Modules.Administration
|
||||
await Context.Channel.EmbedAsync(embed);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[RequireUserPermission(GuildPermission.BanMembers)]
|
||||
public async Task WarnlogAll(int page = 1)
|
||||
{
|
||||
if (--page < 0)
|
||||
return;
|
||||
IGrouping<ulong, Warning>[] warnings;
|
||||
using (var uow = _db.UnitOfWork)
|
||||
{
|
||||
warnings = uow.Warnings.GetAll().GroupBy(x => x.UserId).ToArray();
|
||||
}
|
||||
|
||||
await Context.Channel.SendPaginatedConfirmAsync((DiscordSocketClient)Context.Client, page, async (curPage) =>
|
||||
{
|
||||
var ws = await Task.WhenAll(warnings.Skip(curPage * 15)
|
||||
.Take(15)
|
||||
.ToArray()
|
||||
.Select(async x =>
|
||||
{
|
||||
var all = x.Count();
|
||||
var forgiven = x.Count(y => y.Forgiven);
|
||||
var total = all - forgiven;
|
||||
return ((await Context.Guild.GetUserAsync(x.Key))?.ToString() ?? x.Key.ToString()) + $" | {total} ({all} - {forgiven})";
|
||||
}));
|
||||
|
||||
return new EmbedBuilder()
|
||||
.WithTitle(GetText("warnings_list"))
|
||||
.WithDescription(string.Join("\n", ws));
|
||||
|
||||
}, warnings.Length / 15);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[RequireUserPermission(GuildPermission.BanMembers)]
|
||||
|
@ -3258,6 +3258,15 @@
|
||||
<data name="warnlog_usage" xml:space="preserve">
|
||||
<value>`{0}warnlog @b1nzy`</value>
|
||||
</data>
|
||||
<data name="warnlogall_cmd" xml:space="preserve">
|
||||
<value>warnlogall</value>
|
||||
</data>
|
||||
<data name="warnlogall_desc" xml:space="preserve">
|
||||
<value>See a list of all warnings on the server. 15 users per page.</value>
|
||||
</data>
|
||||
<data name="warnlogall_usage" xml:space="preserve">
|
||||
<value>`{0}warnlogall` or `{0}warnlogall 2`</value>
|
||||
</data>
|
||||
<data name="warn_cmd" xml:space="preserve">
|
||||
<value>warn</value>
|
||||
</data>
|
||||
|
@ -66,15 +66,16 @@ namespace NadekoBot.Extensions
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
return ms;
|
||||
}
|
||||
|
||||
public static Task SendPaginatedConfirmAsync(this IMessageChannel channel, DiscordSocketClient client, int currentPage, Func<int, EmbedBuilder> pageFunc, int? lastPage = null, bool addPaginatedFooter = true) =>
|
||||
channel.SendPaginatedConfirmAsync(client, currentPage, (x) => Task.FromResult(pageFunc(x)), lastPage, addPaginatedFooter);
|
||||
/// <summary>
|
||||
/// danny kamisama
|
||||
/// </summary>
|
||||
public static async Task SendPaginatedConfirmAsync(this IMessageChannel channel, DiscordSocketClient client, int currentPage, Func<int, EmbedBuilder> pageFunc, int? lastPage = null, bool addPaginatedFooter = true)
|
||||
public static async Task SendPaginatedConfirmAsync(this IMessageChannel channel, DiscordSocketClient client, int currentPage, Func<int, Task<EmbedBuilder>> pageFunc, int? lastPage = null, bool addPaginatedFooter = true)
|
||||
{
|
||||
var embed = pageFunc(currentPage);
|
||||
var embed = await pageFunc(currentPage).ConfigureAwait(false);
|
||||
|
||||
if(addPaginatedFooter)
|
||||
if (addPaginatedFooter)
|
||||
embed.AddPaginatedFooter(currentPage, lastPage);
|
||||
|
||||
var msg = await channel.EmbedAsync(embed) as IUserMessage;
|
||||
@ -82,8 +83,8 @@ namespace NadekoBot.Extensions
|
||||
if (lastPage == 0)
|
||||
return;
|
||||
|
||||
|
||||
await msg.AddReactionAsync( arrow_left).ConfigureAwait(false);
|
||||
|
||||
await msg.AddReactionAsync(arrow_left).ConfigureAwait(false);
|
||||
await msg.AddReactionAsync(arrow_right).ConfigureAwait(false);
|
||||
|
||||
await Task.Delay(2000).ConfigureAwait(false);
|
||||
@ -96,7 +97,7 @@ namespace NadekoBot.Extensions
|
||||
{
|
||||
if (currentPage == 0)
|
||||
return;
|
||||
var toSend = pageFunc(--currentPage);
|
||||
var toSend = await pageFunc(--currentPage).ConfigureAwait(false);
|
||||
if (addPaginatedFooter)
|
||||
toSend.AddPaginatedFooter(currentPage, lastPage);
|
||||
await msg.ModifyAsync(x => x.Embed = toSend.Build()).ConfigureAwait(false);
|
||||
@ -105,7 +106,7 @@ namespace NadekoBot.Extensions
|
||||
{
|
||||
if (lastPage == null || lastPage > currentPage)
|
||||
{
|
||||
var toSend = pageFunc(++currentPage);
|
||||
var toSend = await pageFunc(++currentPage).ConfigureAwait(false);
|
||||
if (addPaginatedFooter)
|
||||
toSend.AddPaginatedFooter(currentPage, lastPage);
|
||||
await msg.ModifyAsync(x => x.Embed = toSend.Build()).ConfigureAwait(false);
|
||||
@ -315,7 +316,7 @@ namespace NadekoBot.Extensions
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Easy use of fast, efficient case-insensitive Contains check with StringComparison Member Types
|
||||
/// CurrentCulture, CurrentCultureIgnoreCase, InvariantCulture, InvariantCultureIgnoreCase, Ordinal, OrdinalIgnoreCase
|
||||
@ -482,4 +483,4 @@ namespace NadekoBot.Extensions
|
||||
: usr.GetAvatarUrl(ImageFormat.Auto);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -303,7 +303,7 @@
|
||||
"help_server_permission": "Requires {0} server permission.",
|
||||
"help_table_of_contents": "Table of contents",
|
||||
"help_usage": "Usage",
|
||||
"help_module": "Module: {0}",
|
||||
"help_module": "Module: {0}",
|
||||
"nsfw_autohentai_started": "Autohentai started. Reposting every {0}s with one of the following tags:\n{1}",
|
||||
"nsfw_tag": "Tag",
|
||||
"gambling_animal_race": "Animal race",
|
||||
@ -735,6 +735,7 @@
|
||||
"administration_warned_on_by": "On {0} at {1} by {2}",
|
||||
"administration_warnings_cleared": "All warnings have been cleared for {0}.",
|
||||
"administration_warnings_none": "No warning on this page.",
|
||||
"administration_warnings_list": "List of all warned users on the server.",
|
||||
"administration_warnlog_for": "Warnlog for {0}",
|
||||
"administration_warnpl_none": "No punishments set.",
|
||||
"administration_warn_cleared_by": "cleared by {0}",
|
||||
|
Loading…
Reference in New Issue
Block a user