.prune is heavily nerfed

This commit is contained in:
Master Kwoth 2016-02-09 23:45:34 +01:00
parent 9f9ef8923b
commit b3ef288a27
2 changed files with 11 additions and 22 deletions

View File

@ -359,17 +359,16 @@ namespace NadekoBot.Modules {
});
cgb.CreateCommand(".leaveall")
.Description("Nadeko leaves all servers")
.Description("Nadeko leaves all servers **OWNER ONLY**")
.Do(e => {
if (e.User.Id == NadekoBot.OwnerID)
NadekoBot.client.Servers.ForEach(async s => { if (s.Name == e.Server.Name) return; await s.Leave(); });
});
ConcurrentDictionary<Server, bool> pruneDict = new ConcurrentDictionary<Server, bool>();
cgb.CreateCommand(".prune")
.Parameter("num", ParameterType.Required)
.Description("Prunes a number of messages from the current channel.\n**Usage**: .prune 50")
.Description("Prunes a number of messages from the current channel.\n**Usage**: .prune 5")
.Do(async e => {
if (!e.User.ServerPermissions.ManageMessages) return;
if (pruneDict.ContainsKey(e.Server))
@ -379,24 +378,13 @@ namespace NadekoBot.Modules {
await e.Send("Incorrect amount.");
return;
}
pruneDict.TryAdd(e.Server, true);
await Task.Factory.StartNew(async () => {
try {
Message last = null;
while (num > 0) {
var msgs = await e.Channel.DownloadMessages(num, last?.Id);
last = msgs.LastOrDefault();
if (num > 10)
num = 10;
var msgs = await e.Channel.DownloadMessages(num);
foreach (var m in msgs) {
await m.Delete();
await Task.Delay(500);
}
num -= 100;
}
} catch (Exception) { await e.Send("Failed pruning. Make sure the bot has correct permissions."); }
}, TaskCreationOptions.LongRunning);
bool throwAway;
pruneDict.TryRemove(e.Server, out throwAway);
});
cgb.CreateCommand(".die")

View File

@ -128,6 +128,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Classes\DBHandler.cs" />
<Compile Include="Classes\FlowersHandler.cs" />
<Compile Include="Classes\Music\MusicControls.cs" />
<Compile Include="Classes\Music\StreamRequest.cs" />
<Compile Include="Classes\Music\SoundCloud.cs" />