await prune task of deleting messages

There was an issue where it would sometimes delete once or twice or sometimes does not delete at all or would return 404 error
This commit is contained in:
Kevin 2016-12-04 04:54:10 -05:00 committed by GitHub
parent 240e242eaf
commit 149a9e49bc

View File

@ -643,7 +643,7 @@ namespace NadekoBot.Modules.Administration
var enumerable = (await umsg.Channel.GetMessagesAsync()).AsEnumerable(); var enumerable = (await umsg.Channel.GetMessagesAsync()).AsEnumerable();
enumerable = enumerable.Where(x => x.Author.Id == user.Id); enumerable = enumerable.Where(x => x.Author.Id == user.Id);
await umsg.Channel.DeleteMessagesAsync(enumerable); await umsg.Channel.DeleteMessagesAsync(enumerable).ConfigureAwait(false);
} }
// prune x // prune x
@ -656,7 +656,7 @@ namespace NadekoBot.Modules.Administration
await (msg as IUserMessage).DeleteAsync(); await (msg as IUserMessage).DeleteAsync();
int limit = (count < 100) ? count : 100; int limit = (count < 100) ? count : 100;
var enumerable = (await msg.Channel.GetMessagesAsync(limit: limit)); var enumerable = (await msg.Channel.GetMessagesAsync(limit: limit));
await msg.Channel.DeleteMessagesAsync(enumerable); await msg.Channel.DeleteMessagesAsync(enumerable).ConfigureAwait(false);
} }
//prune @user [x] //prune @user [x]
@ -668,7 +668,7 @@ namespace NadekoBot.Modules.Administration
var channel = (ITextChannel)msg.Channel; var channel = (ITextChannel)msg.Channel;
int limit = (count < 100) ? count : 100; int limit = (count < 100) ? count : 100;
var enumerable = (await msg.Channel.GetMessagesAsync(limit: limit)).Where(m => m.Author == user); var enumerable = (await msg.Channel.GetMessagesAsync(limit: limit)).Where(m => m.Author == user);
await msg.Channel.DeleteMessagesAsync(enumerable); await msg.Channel.DeleteMessagesAsync(enumerable).ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]