From f7e9463a941a3ed8715d4e73575a36bbdab7799f Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 11 Jan 2017 14:05:57 +0100 Subject: [PATCH] .savechat moved to utility module --- .../Modules/Administration/Administration.cs | 18 ---------------- src/NadekoBot/Modules/Utility/Utility.cs | 21 ++++++++++++++++++- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Administration.cs b/src/NadekoBot/Modules/Administration/Administration.cs index e0a9bf0b..cf431be1 100644 --- a/src/NadekoBot/Modules/Administration/Administration.cs +++ b/src/NadekoBot/Modules/Administration/Administration.cs @@ -486,24 +486,6 @@ namespace NadekoBot.Modules.Administration await Context.Channel.DeleteMessagesAsync(enumerable).ConfigureAwait(false); } - [NadekoCommand, Usage, Description, Aliases] - [RequireContext(ContextType.Guild)] - [OwnerOnly] - public async Task SaveChat(int cnt) - { - var sb = new StringBuilder(); - var msgs = new List(cnt); - await Context.Channel.GetMessagesAsync(cnt).ForEachAsync(dled => msgs.AddRange(dled)).ConfigureAwait(false); - - var title = $"Chatlog-{Context.Guild.Name}/#{Context.Channel.Name}-{DateTime.Now}.txt"; - var grouping = msgs.GroupBy(x => $"{x.CreatedAt.Date:dd.MM.yyyy}") - .Select(g => new { date = g.Key, messages = g.OrderBy(x => x.CreatedAt).Select(s => $"【{s.Timestamp:HH:mm:ss}】{s.Author}:" + s.ToString()) }); - await (Context.User as IGuildUser).SendFileAsync( - await JsonConvert.SerializeObject(grouping, Formatting.Indented).ToStream().ConfigureAwait(false), -title, title).ConfigureAwait(false); - } - - [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] [RequireUserPermission(GuildPermission.MentionEveryone)] diff --git a/src/NadekoBot/Modules/Utility/Utility.cs b/src/NadekoBot/Modules/Utility/Utility.cs index b7d437d0..4a581108 100644 --- a/src/NadekoBot/Modules/Utility/Utility.cs +++ b/src/NadekoBot/Modules/Utility/Utility.cs @@ -13,6 +13,8 @@ using System.Net.Http; using System.Collections.Concurrent; using System.Threading; using ImageSharp; +using System.Collections.Generic; +using Newtonsoft.Json; namespace NadekoBot.Modules.Utility { @@ -82,7 +84,7 @@ namespace NadekoBot.Modules.Utility old.Change(Timeout.Infinite, Timeout.Infinite); return t; }); - + await channel.SendFileAsync(images, "magicalgirl.jpg", $"Rotating **{role.Name}** role's color.").ConfigureAwait(false); } @@ -326,5 +328,22 @@ namespace NadekoBot.Modules.Utility .WithIsInline(false)))) .ConfigureAwait(false); } + + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + [OwnerOnly] + public async Task SaveChat(int cnt) + { + var sb = new StringBuilder(); + var msgs = new List(cnt); + await Context.Channel.GetMessagesAsync(cnt).ForEachAsync(dled => msgs.AddRange(dled)).ConfigureAwait(false); + + var title = $"Chatlog-{Context.Guild.Name}/#{Context.Channel.Name}-{DateTime.Now}.txt"; + var grouping = msgs.GroupBy(x => $"{x.CreatedAt.Date:dd.MM.yyyy}") + .Select(g => new { date = g.Key, messages = g.OrderBy(x => x.CreatedAt).Select(s => $"【{s.Timestamp:HH:mm:ss}】{s.Author}:" + s.ToString()) }); + await Context.User.SendFileAsync( + await JsonConvert.SerializeObject(grouping, Formatting.Indented).ToStream().ConfigureAwait(false), title, title).ConfigureAwait(false); + } } } \ No newline at end of file