diff --git a/NadekoBot/Modules/Searches.cs b/NadekoBot/Modules/Searches.cs index 4b181446..3ca9f82b 100644 --- a/NadekoBot/Modules/Searches.cs +++ b/NadekoBot/Modules/Searches.cs @@ -184,22 +184,51 @@ namespace NadekoBot.Modules { } }); - //todo when moved from parse - /* - cgb.CreateCommand("~osubind") - .Description("Bind discord user to osu name\n**Usage**: ~osubind My osu name") - .Parameter("osu_name", ParameterType.Unparsed) - .Do(async e => { - var userName = e.GetArg("user_name"); - var osuName = e.GetArg("osu_name"); - var usr = e.Server.FindUsers(userName).FirstOrDefault(); - if (usr == null) { - await e.Send("Cannot find that discord user."); - return; - } - }); - */ - }); + + cgb.CreateCommand("~ud") + .Description("Searches Urban Dictionary for a word\n**Usage**:~ud Pineapple") + .Parameter("query", ParameterType.Unparsed) + .Do(async e => { + var arg = e.GetArg("query"); + if (string.IsNullOrWhiteSpace(arg)) + { + await e.Send("💢 Please enter a search term."); + return; + } + await e.Channel.SendIsTyping(); + var res = await SearchHelper.GetResponseAsync($"https://mashape-community-urban-dictionary.p.mashape.com/define?term={Uri.EscapeUriString(arg)}", + new Tuple[] { + new Tuple("X-Mashape-Key", NadekoBot.creds.MashapeKey) + }); + try + { + var items = JObject.Parse(res); + await e.Send($"`Term:` {items["list"][0]["word"].ToString()}\n"); + await e.Send($"`Definition:` {items["list"][0]["definition"].ToString()}\n"); + await e.Send($"`Link:` <{await items["list"][0]["permalink"].ToString().ShortenUrl()}>"); + } + catch (Exception ex) + { + await e.Channel.SendMessage("💢 Exception: " + ex.Message); + } + }); + + //todo when moved from parse + /* + cgb.CreateCommand("~osubind") + .Description("Bind discord user to osu name\n**Usage**: ~osubind My osu name") + .Parameter("osu_name", ParameterType.Unparsed) + .Do(async e => { + var userName = e.GetArg("user_name"); + var osuName = e.GetArg("osu_name"); + var usr = e.Server.FindUsers(userName).FirstOrDefault(); + if (usr == null) { + await e.Send("Cannot find that discord user."); + return; + } + }); + */ + }); } } }