more patting, better nullchecks, commschannel, greeted stats

osu stuff coming one of these days
This commit is contained in:
Master Kwoth
2016-02-02 15:53:01 +01:00
parent 4938b1b5fe
commit f1cfad1556
7 changed files with 59 additions and 25 deletions

View File

@ -448,17 +448,19 @@ namespace NadekoBot.Modules {
Server commsServer = null;
User commsUser = null;
Channel commsChannel = null;
cgb.CreateCommand(".commsuser")
.Description("Sets a user for through-bot communication. Only works if server is set.**Owner only**.")
.Description("Sets a user for through-bot communication. Only works if server is set. Resets commschannel.**Owner only**.")
.Parameter("name", ParameterType.Unparsed)
.Do(async e => {
if (e.User.Id != NadekoBot.OwnerID) return;
commsUser = commsServer?.FindUsers(e.GetArg("name")).FirstOrDefault();
if (commsUser != null)
if (commsUser != null) {
commsChannel = null;
await e.Send("User for comms set.");
else
await e.Send("No such user.");
} else
await e.Send("No server specified or user.");
});
cgb.CreateCommand(".commsserver")
@ -473,13 +475,29 @@ namespace NadekoBot.Modules {
await e.Send("No such server.");
});
cgb.CreateCommand(".commschannel")
.Description("Sets a channel for through-bot communication. Only works if server is set. Resets commsuser.**Owner only**.")
.Parameter("ch", ParameterType.Unparsed)
.Do(async e => {
if (e.User.Id != NadekoBot.OwnerID) return;
commsChannel = commsServer?.FindChannels(e.GetArg("ch")).FirstOrDefault();
if (commsServer != null) {
commsUser = null;
await e.Send("Server for comms set.");
} else
await e.Send("No server specified or channel is invalid.");
});
cgb.CreateCommand(".send")
.Description("Send a message to someone on a different server through the bot.**Owner only.**\n **Usage**: .send Message text multi word!")
.Parameter("msg", ParameterType.Unparsed)
.Do(async e => {
if (e.User.Id != NadekoBot.OwnerID) return;
try {
await commsUser.SendMessage(e.GetArg("msg"));
if (commsUser != null)
await commsUser.SendMessage(e.GetArg("msg"));
else if (commsChannel != null)
await commsChannel.SendMessage(e.GetArg("msg"));
} catch (Exception) {
await e.Send("Sending failed.");
}

View File

@ -192,8 +192,11 @@ namespace NadekoBot.Modules {
.Do(async e => {
var user = e.GetArg("user");
if (user == null || e.Message.MentionedUsers.Count() == 0) return;
await e.Send($"{e.Message.MentionedUsers.First().Mention} http://i.imgur.com/eOJlnwP.gif");
string[] pats = new string[] { "http://i.imgur.com/IiQwK12.gif",
"http://i.imgur.com/JCXj8yD.gif",
"http://i.imgur.com/qqBl2bm.gif",
"http://i.imgur.com/eOJlnwP.gif" };
await e.Send($"{e.Message.MentionedUsers.First().Mention} {pats[new Random().Next(0, pats.Length)]}");
});
cgb.CreateCommand("are you real")
@ -341,7 +344,7 @@ namespace NadekoBot.Modules {
.Description("Useless. Writes calling @X to chat.\n**Usage**: @NadekoBot call @X ")
.Parameter("who", ParameterType.Required)
.Do(async e => {
await e.Send("Calling " + e.Args[0] + "...");
await e.Send("Calling " + e.Args[0].Replace("@everyone","[everyone]") + "...");
});
cgb.CreateCommand("hide")
.Description("Hides nadeko in plain sight!11!!")

View File

@ -12,13 +12,16 @@ using NadekoBot.Extensions;
namespace NadekoBot.Modules {
class Searches : DiscordModule {
public Searches() : base() {
// commands.Add(new OsuCommands());
}
public override void Install(ModuleManager manager) {
var client = NadekoBot.client;
manager.CreateCommands("", cgb => {
commands.ForEach(cmd => cmd.Init(cgb));
cgb.CreateCommand("~yt")
.Parameter("query", Discord.Commands.ParameterType.Unparsed)
.Description("Queries youtubes and embeds the first result")