From 631e17a569fc145c6c34fa01cfe1738626e77b0f Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Tue, 16 May 2017 23:57:25 +0200 Subject: [PATCH] Fixed an issue where using .prune wouldn't work if there was a message older than 2 weeks in the last 100 messages. Also some string fixes --- .../Modules/Administration/Administration.cs | 16 +++++++++++----- .../Gambling/Commands/WaifuClaimCommands.cs | 2 ++ src/NadekoBot/Resources/CommandStrings.resx | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Administration.cs b/src/NadekoBot/Modules/Administration/Administration.cs index 8fd0bf6c..780fb29a 100644 --- a/src/NadekoBot/Modules/Administration/Administration.cs +++ b/src/NadekoBot/Modules/Administration/Administration.cs @@ -381,12 +381,14 @@ namespace NadekoBot.Modules.Administration { var user = await Context.Guild.GetCurrentUserAsync().ConfigureAwait(false); - var enumerable = (await Context.Channel.GetMessagesAsync().Flatten()).AsEnumerable(); - enumerable = enumerable.Where(x => x.Author.Id == user.Id); + var enumerable = (await Context.Channel.GetMessagesAsync().Flatten()) + .Where(x => x.Author.Id == user.Id && DateTime.Now - x.CreatedAt < twoWeeks); await Context.Channel.DeleteMessagesAsync(enumerable).ConfigureAwait(false); Context.Message.DeleteAfter(3); } + + private TimeSpan twoWeeks => TimeSpan.FromDays(14); // prune x [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] @@ -399,7 +401,8 @@ namespace NadekoBot.Modules.Administration return; await Context.Message.DeleteAsync().ConfigureAwait(false); int limit = (count < 100) ? count + 1 : 100; - var enumerable = (await Context.Channel.GetMessagesAsync(limit: limit).Flatten().ConfigureAwait(false)); + var enumerable = (await Context.Channel.GetMessagesAsync(limit: limit).Flatten().ConfigureAwait(false)) + .Where(x => DateTime.Now - x.CreatedAt < twoWeeks); if (enumerable.FirstOrDefault()?.Id == Context.Message.Id) enumerable = enumerable.Skip(1).ToArray(); else @@ -422,7 +425,8 @@ namespace NadekoBot.Modules.Administration count += 1; int limit = (count < 100) ? count : 100; - var enumerable = (await Context.Channel.GetMessagesAsync(limit: limit).Flatten()).Where(m => m.Author == user); + var enumerable = (await Context.Channel.GetMessagesAsync(limit: limit).Flatten()) + .Where(m => m.Author == user && DateTime.Now - m.CreatedAt < twoWeeks); await Context.Channel.DeleteMessagesAsync(enumerable).ConfigureAwait(false); Context.Message.DeleteAfter(3); @@ -437,7 +441,9 @@ namespace NadekoBot.Modules.Administration foreach (var role in roles) { send += $"\n**{role.Name}**\n"; - send += string.Join(", ", (await Context.Guild.GetUsersAsync()).Where(u => u.GetRoles().Contains(role)).Take(50).Select(u => u.Mention)); + send += string.Join(", ", (await Context.Guild.GetUsersAsync()) + .Where(u => u.GetRoles().Contains(role)) + .Take(50).Select(u => u.Mention)); } while (send.Length > 2000) diff --git a/src/NadekoBot/Modules/Gambling/Commands/WaifuClaimCommands.cs b/src/NadekoBot/Modules/Gambling/Commands/WaifuClaimCommands.cs index 3822c8c5..a37ef8cf 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/WaifuClaimCommands.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/WaifuClaimCommands.cs @@ -173,6 +173,8 @@ namespace NadekoBot.Modules.Gambling amount + CurrencySign); if (w.Affinity?.UserId == Context.User.Id) msg += "\n" + GetText("waifu_fulfilled", target, w.Price + CurrencySign); + else + msg = " " + msg; await Context.Channel.SendConfirmAsync(Context.User.Mention + msg).ConfigureAwait(false); } diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 94462d97..055e5207 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2038,7 +2038,7 @@ chucknorris cn - Shows a random Chuck Norris joke from <http://tambal.azurewebsites.net/joke/random> + Shows a random Chuck Norris joke from <http://api.icndb.com/jokes/random/> `{0}cn` @@ -3406,7 +3406,7 @@ Toggles if this role is displayed in the sidebar or not - `{0}rh Guests true` or `{0}rh "Space Wizards" true + `{0}rh Guests true` or `{0}rh "Space Wizards" true` buy