cleanup, made randserver require 10 servers

This commit is contained in:
Master Kwoth 2016-01-21 01:43:08 +01:00
parent b969f1ff73
commit 3b122c0c9d

View File

@ -23,14 +23,6 @@ namespace NadekoBot.Modules
commands.Add(new CopyCommand()); commands.Add(new CopyCommand());
} }
private CommandBuilder CreateCommand(CommandGroupBuilder cbg, string txt)
{
CommandBuilder cb = cbg.CreateCommand(txt);
return cb;
}
private CommandBuilder AliasCommand(CommandBuilder cb, string txt) => cb.Alias(new string[] { "," + txt, "-" + txt });
public override void Install(ModuleManager manager) public override void Install(ModuleManager manager)
{ {
Random rng = new Random(); Random rng = new Random();
@ -60,7 +52,7 @@ namespace NadekoBot.Modules
commands.ForEach(cmd => cmd.Init(cgb)); commands.ForEach(cmd => cmd.Init(cgb));
CreateCommand(cgb, "uptime") cgb.CreateCommand("uptime")
.Description("Shows how long is Nadeko running for.") .Description("Shows how long is Nadeko running for.")
.Do(async e => { .Do(async e => {
var time = (DateTime.Now - Process.GetCurrentProcess().StartTime); var time = (DateTime.Now - Process.GetCurrentProcess().StartTime);
@ -68,7 +60,7 @@ namespace NadekoBot.Modules
await e.Send(str); await e.Send(str);
}); });
CreateCommand(cgb, "die") cgb.CreateCommand("die")
.Description("Works only for the owner. Shuts the bot down.") .Description("Works only for the owner. Shuts the bot down.")
.Do(async e => .Do(async e =>
{ {
@ -90,6 +82,11 @@ namespace NadekoBot.Modules
cgb.CreateCommand("randserver") cgb.CreateCommand("randserver")
.Description("Generates an invite to a random server and prints some stats.") .Description("Generates an invite to a random server and prints some stats.")
.Do(async e => { .Do(async e => {
if (client.Servers.Count() < 10) {
await e.Send("I need to be connected to at least 10 servers for this command to work.");
return;
}
if (randServerSW.ElapsedMilliseconds / 1000 < 1800) { if (randServerSW.ElapsedMilliseconds / 1000 < 1800) {
await e.Send("You have to wait " + (1800 - randServerSW.ElapsedMilliseconds / 1000) + " more seconds to use this function."); await e.Send("You have to wait " + (1800 - randServerSW.ElapsedMilliseconds / 1000) + " more seconds to use this function.");
return; return;
@ -128,7 +125,7 @@ namespace NadekoBot.Modules
}); });
}); });
*/ */
CreateCommand(cgb, "do you love me") cgb.CreateCommand("do you love me")
.Description("Replies with positive answer only to the bot owner.") .Description("Replies with positive answer only to the bot owner.")
.Do(async e => { .Do(async e => {
if (e.User.Id == NadekoBot.OwnerID) if (e.User.Id == NadekoBot.OwnerID)
@ -137,7 +134,7 @@ namespace NadekoBot.Modules
await e.Send(e.User.Mention + ", Don't be silly."); await e.Send(e.User.Mention + ", Don't be silly.");
}); });
CreateCommand(cgb, "how are you") cgb.CreateCommand("how are you")
.Description("Replies positive only if bot owner is online.") .Description("Replies positive only if bot owner is online.")
.Do(async e => .Do(async e =>
{ {
@ -159,7 +156,7 @@ namespace NadekoBot.Modules
} }
}); });
CreateCommand(cgb, "insult") cgb.CreateCommand("insult")
.Parameter("mention", ParameterType.Required) .Parameter("mention", ParameterType.Required)
.Description("Only works for owner. Insults @X person.\n**Usage**: @NadekoBot insult @X.") .Description("Only works for owner. Insults @X person.\n**Usage**: @NadekoBot insult @X.")
.Do(async e => .Do(async e =>
@ -187,7 +184,7 @@ namespace NadekoBot.Modules
} }
}); });
CreateCommand(cgb, "praise") cgb.CreateCommand("praise")
.Description("Only works for owner. Praises @X person.\n**Usage**: @NadekoBot praise @X.") .Description("Only works for owner. Praises @X person.\n**Usage**: @NadekoBot praise @X.")
.Parameter("mention", ParameterType.Required) .Parameter("mention", ParameterType.Required)
.Do(async e => .Do(async e =>
@ -263,7 +260,7 @@ namespace NadekoBot.Modules
await e.Send(str); await e.Send(str);
}); });
CreateCommand(cgb, "rip") cgb.CreateCommand("rip")
.Description("Shows a grave image.Optional parameter [@X] instructs her to put X's name on the grave.\n**Usage**: @NadekoBot rip [@X]") .Description("Shows a grave image.Optional parameter [@X] instructs her to put X's name on the grave.\n**Usage**: @NadekoBot rip [@X]")
.Parameter("user", ParameterType.Unparsed) .Parameter("user", ParameterType.Unparsed)
.Do(async e => .Do(async e =>
@ -325,7 +322,7 @@ namespace NadekoBot.Modules
else await e.Send("Not for you, only my Master <3"); else await e.Send("Not for you, only my Master <3");
}); });
CreateCommand(cgb, "ls") cgb.CreateCommand("ls")
.Description("Shows all saved items.") .Description("Shows all saved items.")
.Do(async e => .Do(async e =>
{ {
@ -363,7 +360,7 @@ namespace NadekoBot.Modules
else else
await e.Send("I can't find a message mentioning you."); await e.Send("I can't find a message mentioning you.");
}); });
CreateCommand(cgb, "cs") cgb.CreateCommand("cs")
.Description("Deletes all saves") .Description("Deletes all saves")
.Do(async e => .Do(async e =>
{ {
@ -371,7 +368,7 @@ namespace NadekoBot.Modules
await e.Send("Cleared all saves."); await e.Send("Cleared all saves.");
}); });
CreateCommand(cgb, "bb") cgb.CreateCommand("bb")
.Description("Says bye to someone. **Usage**: @NadekoBot bb @X") .Description("Says bye to someone. **Usage**: @NadekoBot bb @X")
.Parameter("ppl", ParameterType.Unparsed) .Parameter("ppl", ParameterType.Unparsed)
.Do(async e => .Do(async e =>
@ -384,7 +381,8 @@ namespace NadekoBot.Modules
await e.Send(str); await e.Send(str);
}); });
AliasCommand(CreateCommand(cgb, "req"), "request") cgb.CreateCommand("req")
.Alias("request")
.Description("Requests a feature for nadeko.\n**Usage**: @NadekoBot req new_feature") .Description("Requests a feature for nadeko.\n**Usage**: @NadekoBot req new_feature")
.Parameter("all", ParameterType.Unparsed) .Parameter("all", ParameterType.Unparsed)
.Do(async e => .Do(async e =>
@ -403,7 +401,7 @@ namespace NadekoBot.Modules
await e.Send("Thank you for your request."); await e.Send("Thank you for your request.");
}); });
CreateCommand(cgb, "lr") cgb.CreateCommand("lr")
.Description("PMs the user all current nadeko requests.") .Description("PMs the user all current nadeko requests.")
.Do(async e => .Do(async e =>
{ {
@ -414,7 +412,7 @@ namespace NadekoBot.Modules
await e.User.Send("No requests atm."); await e.User.Send("No requests atm.");
}); });
CreateCommand(cgb, "dr") cgb.CreateCommand("dr")
.Description("Deletes a request. Only owner is able to do this.") .Description("Deletes a request. Only owner is able to do this.")
.Parameter("reqNumber", ParameterType.Required) .Parameter("reqNumber", ParameterType.Required)
.Do(async e => .Do(async e =>
@ -440,7 +438,7 @@ namespace NadekoBot.Modules
else await e.Send("You don't have permission to do that."); else await e.Send("You don't have permission to do that.");
}); });
CreateCommand(cgb, "rr") cgb.CreateCommand("rr")
.Description("Resolves a request. Only owner is able to do this.") .Description("Resolves a request. Only owner is able to do this.")
.Parameter("reqNumber", ParameterType.Required) .Parameter("reqNumber", ParameterType.Required)
.Do(async e => .Do(async e =>
@ -468,14 +466,14 @@ namespace NadekoBot.Modules
else await e.Send("You don't have permission to do that."); else await e.Send("You don't have permission to do that.");
}); });
CreateCommand(cgb, "call") cgb.CreateCommand("call")
.Description("Useless. Writes calling @X to chat.\n**Usage**: @NadekoBot call @X ") .Description("Useless. Writes calling @X to chat.\n**Usage**: @NadekoBot call @X ")
.Parameter("who", ParameterType.Required) .Parameter("who", ParameterType.Required)
.Do(async e => .Do(async e =>
{ {
await e.Send("Calling " + e.Args[0] + "..."); await e.Send("Calling " + e.Args[0] + "...");
}); });
CreateCommand(cgb, "hide") cgb.CreateCommand("hide")
.Description("Hides nadeko in plain sight!11!!") .Description("Hides nadeko in plain sight!11!!")
.Do(async e => .Do(async e =>
{ {
@ -496,7 +494,7 @@ namespace NadekoBot.Modules
} }
}); });
CreateCommand(cgb, "unhide") cgb.CreateCommand("unhide")
.Description("Unhides nadeko in plain sight!1!!1") .Description("Unhides nadeko in plain sight!1!!1")
.Do(async e => .Do(async e =>
{ {