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
This commit is contained in:
parent
1cd7852674
commit
631e17a569
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -2038,7 +2038,7 @@
|
||||
<value>chucknorris cn</value>
|
||||
</data>
|
||||
<data name="chucknorris_desc" xml:space="preserve">
|
||||
<value>Shows a random Chuck Norris joke from <http://tambal.azurewebsites.net/joke/random></value>
|
||||
<value>Shows a random Chuck Norris joke from <http://api.icndb.com/jokes/random/></value>
|
||||
</data>
|
||||
<data name="chucknorris_usage" xml:space="preserve">
|
||||
<value>`{0}cn`</value>
|
||||
@ -3406,7 +3406,7 @@
|
||||
<value>Toggles if this role is displayed in the sidebar or not</value>
|
||||
</data>
|
||||
<data name="rolehoist_usage" xml:space="preserve">
|
||||
<value>`{0}rh Guests true` or `{0}rh "Space Wizards" true</value>
|
||||
<value>`{0}rh Guests true` or `{0}rh "Space Wizards" true`</value>
|
||||
</data>
|
||||
<data name="buy_cmd" xml:space="preserve">
|
||||
<value>buy</value>
|
||||
|
Loading…
Reference in New Issue
Block a user