Merge remote-tracking branch 'refs/remotes/Kwoth/master' into dev

This commit is contained in:
appelemac 2016-06-15 15:47:50 +02:00
commit c7ce776075
9 changed files with 32 additions and 73 deletions

View File

@ -722,11 +722,13 @@ namespace NadekoBot.Modules.Administration
var avatarAddress = e.GetArg("img");
var imageStream = await SearchHelper.GetResponseStreamAsync(avatarAddress).ConfigureAwait(false);
var image = System.Drawing.Image.FromStream(imageStream);
// Save the image to disk.
image.Save("data/avatar.png", System.Drawing.Imaging.ImageFormat.Png);
await client.CurrentUser.Edit(NadekoBot.Creds.Password, avatar: image.ToStream()).ConfigureAwait(false);
// Send confirm.
await e.Channel.SendMessage("New avatar set.").ConfigureAwait(false);
// Save the image to disk.
image.Save("data/avatar.png", System.Drawing.Imaging.ImageFormat.Png);
});
cgb.CreateCommand(Prefix + "setgame")
@ -1000,6 +1002,21 @@ namespace NadekoBot.Modules.Administration
await e.Channel.SendMessage("```xl\n" + string.Join("\n", arr.GroupBy(item => (i++) / 3).Select(ig => string.Join("", ig.Select(el => $"• {el,-35}")))) + "\n```");
});
cgb.CreateCommand(Prefix + "leave")
.Description("Leaves a server with a supplied ID.\n**Usage**: `.leave 493243292839`")
.Parameter("num", ParameterType.Required)
.AddCheck(SimpleCheckers.OwnerOnly())
.Do(async e =>
{
var srvr = NadekoBot.Client.Servers.Where(s => s.Id.ToString() == e.GetArg("num").Trim()).FirstOrDefault();
if (srvr == null)
{
return;
}
await srvr.Leave();
await e.Channel.SendMessage("`Done.`");
});
});
}

View File

@ -32,8 +32,8 @@ namespace NadekoBot.Modules.Administration.Commands
internal override void Init(CommandGroupBuilder cgb)
{
cgb.CreateCommand(Module.Prefix + "aar")
.Alias(Module.Prefix + "autoassignrole")
cgb.CreateCommand(Module.Prefix + "autoassignrole")
.Alias(Module.Prefix + "aar")
.Description($"Automaticaly assigns a specified role to every user who joins the server. Type `.aar` to disable, `.aar Role Name` to enable")
.Parameter("role", ParameterType.Unparsed)
.AddCheck(new SimpleCheckers.ManageRoles())
@ -42,6 +42,7 @@ namespace NadekoBot.Modules.Administration.Commands
if (!e.Server.CurrentUser.ServerPermissions.ManageRoles)
{
await e.Channel.SendMessage("I do not have the permission to manage roles.");
return;
}
var r = e.GetArg("role")?.Trim();

View File

@ -67,7 +67,7 @@ namespace NadekoBot.Modules.Administration.Commands
});
cgb.CreateCommand(Module.Prefix + "lsar")
.Description("Lits all self-assignable roles.")
.Description("Lists all self-assignable roles.")
.Parameter("roles", ParameterType.Multiple)
.Do(async e =>
{

View File

@ -262,28 +262,6 @@ namespace NadekoBot.Modules.Conversations
await e.Channel.SendMessage("I can't find a message mentioning you.").ConfigureAwait(false);
});
cgb.CreateCommand("hide")
.Description("Hides Nadeko in plain sight!11!!")
.Do(async e =>
{
using (var ms = Resources.hidden.ToStream(ImageFormat.Png))
{
await client.CurrentUser.Edit(NadekoBot.Creds.Password, avatar: ms).ConfigureAwait(false);
}
await e.Channel.SendMessage("*hides*").ConfigureAwait(false);
});
cgb.CreateCommand("unhide")
.Description("Unhides Nadeko in plain sight!1!!1")
.Do(async e =>
{
using (var fs = new FileStream("data/avatar.png", FileMode.Open))
{
await client.CurrentUser.Edit(NadekoBot.Creds.Password, avatar: fs).ConfigureAwait(false);
}
await e.Channel.SendMessage("*unhides*").ConfigureAwait(false);
});
cgb.CreateCommand("dump")
.Description("Dumps all of the invites it can to dump.txt.** Owner Only.**")
.Do(async e =>

View File

@ -2,7 +2,6 @@
using Discord.Commands;
using NadekoBot.Classes;
using NadekoBot.Extensions;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
@ -79,10 +78,7 @@ namespace NadekoBot.Modules.Games.Commands.Trivia
await Task.Delay(QuestionDurationMiliseconds - HintTimeoutMiliseconds, token).ConfigureAwait(false);
}
catch (TaskCanceledException)
{
Console.WriteLine("Trivia cancelled");
}
catch (TaskCanceledException) { } //means someone guessed the answer
GameActive = false;
if (!triviaCancelSource.IsCancellationRequested)
await channel.Send($":clock2: :question: **Time's up!** The correct answer was **{CurrentQuestion.Answer}**").ConfigureAwait(false);

View File

@ -63,30 +63,12 @@ namespace NadekoBot.Modules.Trello
}
};
manager.CreateCommands("trello ", cgb =>
manager.CreateCommands("", cgb =>
{
cgb.AddCheck(PermissionChecker.Instance);
cgb.CreateCommand("join")
.Alias("j")
.Description("Joins a server")
.Parameter("code", Discord.Commands.ParameterType.Required)
.Do(async e =>
{
if (!NadekoBot.IsOwner(e.User.Id) || NadekoBot.IsBot) return;
try
{
await (await client.GetInvite(e.GetArg("code")).ConfigureAwait(false)).Accept()
.ConfigureAwait(false);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
});
cgb.CreateCommand("bind")
cgb.CreateCommand(Prefix + "bind")
.Description("Bind a trello bot to a single channel. " +
"You will receive notifications from your board when something is added or edited." +
"\n**Usage**: bind [board_id]")
@ -109,7 +91,7 @@ namespace NadekoBot.Modules.Trello
}
});
cgb.CreateCommand("unbind")
cgb.CreateCommand(Prefix + "unbind")
.Description("Unbinds a bot from the channel and board.")
.Do(async e =>
{
@ -122,8 +104,8 @@ namespace NadekoBot.Modules.Trello
});
cgb.CreateCommand("lists")
.Alias("list")
cgb.CreateCommand(Prefix + "lists")
.Alias(Prefix + "list")
.Description("Lists all lists yo ;)")
.Do(async e =>
{
@ -133,7 +115,7 @@ namespace NadekoBot.Modules.Trello
.ConfigureAwait(false);
});
cgb.CreateCommand("cards")
cgb.CreateCommand(Prefix + "cards")
.Description("Lists all cards from the supplied list. You can supply either a name or an index.")
.Parameter("list_name", Discord.Commands.ParameterType.Unparsed)
.Do(async e =>

View File

@ -48,21 +48,6 @@ namespace NadekoBot
{
Console.OutputEncoding = Encoding.Unicode;
//var lines = File.ReadAllLines("data/input.txt");
//HashSet<dynamic> list = new HashSet<dynamic>();
//for (int i = 0; i < lines.Length; i += 3) {
// dynamic obj = new JArray();
// obj.Text = lines[i];
// obj.Author = lines[i + 1];
// if (obj.Author.StartsWith("-"))
// obj.Author = obj.Author.Substring(1, obj.Author.Length - 1).Trim();
// list.Add(obj);
//}
//File.WriteAllText("data/quotes.json", Newtonsoft.Json.JsonConvert.SerializeObject(list, Formatting.Indented));
//Console.ReadKey();
// generate credentials example so people can know about the changes i make
try
{
File.WriteAllText("data/config_example.json", JsonConvert.SerializeObject(new Configuration(), Formatting.Indented));