Merge remote-tracking branch 'upstream/dev' into dev

This commit is contained in:
fkndean
2016-11-28 06:04:54 -05:00
6 changed files with 83 additions and 7 deletions

View File

@@ -274,7 +274,7 @@ namespace NadekoBot.Modules.Administration
return;
}
var sendGreetEnabled = ServerGreetCommands.SetGreetMessage(channel.Guild.Id, ref text);
var sendGreetEnabled = ServerGreetCommands.SetGreetDmMessage(channel.Guild.Id, ref text);
await channel.SendMessageAsync("🆗 New DM greet message **set**.").ConfigureAwait(false);
if (!sendGreetEnabled)

View File

@@ -208,6 +208,46 @@ $@"🌍 **Weather for** 【{obj["target"]}】
.ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
public async Task MagicTheGathering(IUserMessage umsg, [Remainder] string name = null)
{
var channel = (ITextChannel)umsg.Channel;
var arg = name;
if (string.IsNullOrWhiteSpace(arg))
{
await channel.SendMessageAsync("💢 `Please enter a card name to search for.`").ConfigureAwait(false);
return;
}
await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false);
string response = "";
using (var http = new HttpClient())
{
http.DefaultRequestHeaders.Clear();
response = await http.GetStringAsync($"https://api.deckbrew.com/mtg/cards?name={Uri.EscapeUriString(arg)}")
.ConfigureAwait(false);
try
{
var items = JArray.Parse(response).Shuffle().ToList();
if (items == null)
throw new KeyNotFoundException("Cannot find a card by that name");
var msg = $@"```css
[☕ Magic The Gathering]: {items[0]["name"].ToString()}
[Store URL]: {await _google.ShortenUrl(items[0]["store_url"].ToString())}
[Cost]: {items[0]["cost"].ToString()}
[Description]: {items[0]["text"].ToString()}
```
{items[0]["editions"][0]["image_url"].ToString()}";
await channel.SendMessageAsync(msg).ConfigureAwait(false);
}
catch
{
await channel.SendMessageAsync($"💢 Error could not find the card {arg}").ConfigureAwait(false);
}
}
}
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
public async Task Hearthstone(IUserMessage umsg, [Remainder] string name = null)