Just append card url instead of downloading.

This commit is contained in:
fkndean 2016-11-27 20:17:46 -05:00
parent d363af4dfe
commit 7ad43e8345

View File

@ -194,20 +194,6 @@ $@"🌍 **Weather for** 【{obj["target"]}】
await msg.Channel.SendMessageAsync(await NadekoBot.Google.ShortenUrl(arg).ConfigureAwait(false));
}
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
public async Task Google(IUserMessage umsg, [Remainder] string terms = null)
{
var channel = (ITextChannel)umsg.Channel;
terms = terms?.Trim();
if (string.IsNullOrWhiteSpace(terms))
return;
await channel.SendMessageAsync($"https://google.com/search?q={ WebUtility.UrlEncode(terms).Replace(' ', '+') }")
.ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
public async Task MagicTheGathering(IUserMessage umsg, [Remainder] string name = null)
@ -230,21 +216,16 @@ $@"🌍 **Weather for** 【{obj["target"]}】
try
{
var items = JArray.Parse(response).Shuffle().ToList();
var images = new List<Image>();
if (items == null)
throw new KeyNotFoundException("Cannot find a card by that name");
using (var sr = await http.GetStreamAsync(items[0]["editions"][0]["image_url"].ToString()))
{
var imgStream = new MemoryStream();
await sr.CopyToAsync(imgStream);
imgStream.Position = 0;
images.Add(new Image(imgStream));
}
var ms = new MemoryStream();
images.Merge().SaveAsJpeg(ms);
ms.Position = 0;
await channel.SendFileAsync(ms, arg + ".jpg", null).ConfigureAwait(false);
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
{