.prune is heavily nerfed
This commit is contained in:
parent
9f9ef8923b
commit
b3ef288a27
@ -359,17 +359,16 @@ namespace NadekoBot.Modules {
|
|||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(".leaveall")
|
cgb.CreateCommand(".leaveall")
|
||||||
.Description("Nadeko leaves all servers")
|
.Description("Nadeko leaves all servers **OWNER ONLY**")
|
||||||
.Do(e => {
|
.Do(e => {
|
||||||
if (e.User.Id == NadekoBot.OwnerID)
|
if (e.User.Id == NadekoBot.OwnerID)
|
||||||
NadekoBot.client.Servers.ForEach(async s => { if (s.Name == e.Server.Name) return; await s.Leave(); });
|
NadekoBot.client.Servers.ForEach(async s => { if (s.Name == e.Server.Name) return; await s.Leave(); });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
ConcurrentDictionary<Server, bool> pruneDict = new ConcurrentDictionary<Server, bool>();
|
ConcurrentDictionary<Server, bool> pruneDict = new ConcurrentDictionary<Server, bool>();
|
||||||
cgb.CreateCommand(".prune")
|
cgb.CreateCommand(".prune")
|
||||||
.Parameter("num", ParameterType.Required)
|
.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 => {
|
.Do(async e => {
|
||||||
if (!e.User.ServerPermissions.ManageMessages) return;
|
if (!e.User.ServerPermissions.ManageMessages) return;
|
||||||
if (pruneDict.ContainsKey(e.Server))
|
if (pruneDict.ContainsKey(e.Server))
|
||||||
@ -379,24 +378,13 @@ namespace NadekoBot.Modules {
|
|||||||
await e.Send("Incorrect amount.");
|
await e.Send("Incorrect amount.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pruneDict.TryAdd(e.Server, true);
|
if (num > 10)
|
||||||
await Task.Factory.StartNew(async () => {
|
num = 10;
|
||||||
try {
|
var msgs = await e.Channel.DownloadMessages(num);
|
||||||
Message last = null;
|
foreach (var m in msgs) {
|
||||||
while (num > 0) {
|
await m.Delete();
|
||||||
var msgs = await e.Channel.DownloadMessages(num, last?.Id);
|
await Task.Delay(500);
|
||||||
last = msgs.LastOrDefault();
|
}
|
||||||
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")
|
cgb.CreateCommand(".die")
|
||||||
|
@ -128,6 +128,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Classes\DBHandler.cs" />
|
<Compile Include="Classes\DBHandler.cs" />
|
||||||
|
<Compile Include="Classes\FlowersHandler.cs" />
|
||||||
<Compile Include="Classes\Music\MusicControls.cs" />
|
<Compile Include="Classes\Music\MusicControls.cs" />
|
||||||
<Compile Include="Classes\Music\StreamRequest.cs" />
|
<Compile Include="Classes\Music\StreamRequest.cs" />
|
||||||
<Compile Include="Classes\Music\SoundCloud.cs" />
|
<Compile Include="Classes\Music\SoundCloud.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user