Beispiel #1
0
        public static async Task <string> GetPlaylistIdByKeyword(string query)
        {
            if (string.IsNullOrWhiteSpace(MidnightBot.GetRndGoogleAPIKey()))
            {
                throw new ArgumentNullException(nameof(query));
            }

            var match = new Regex("(?:youtu\\.be\\/|list=)(?<id>[\\da-zA-Z\\-_]*)").Match(query);

            if (match.Length > 1)
            {
                return(match.Groups["id"].Value.ToString());
            }

            var link = "https://www.googleapis.com/youtube/v3/search?part=snippet" +
                       "&maxResults=1&type=playlist" +
                       $"&q={Uri.EscapeDataString (query)}" +
                       $"&key={MidnightBot.GetRndGoogleAPIKey ()}";

            var response = await GetResponseStringAsync(link).ConfigureAwait(false);

            var     data = JsonConvert.DeserializeObject <YoutubePlaylistSearch> (response);
            JObject obj  = JObject.Parse(response);

            return(data.items.Length > 0 ? data.items[0].id.playlistId.ToString() : null);
        }
Beispiel #2
0
        public static async Task <string> GetRelatedVideoId(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentNullException(nameof(id));
            }
            var match = new Regex("(?:youtu\\.be\\/|v=)(?<id>[\\da-zA-Z\\-_]*)").Match(id);

            if (match.Length > 1)
            {
                id = match.Groups["id"].Value;
            }
            var response = await GetResponseStringAsync(
                $"https://www.googleapis.com/youtube/v3/search?" +
                $"part=snippet&maxResults=1&type=video" +
                $"&relatedToVideoId={id}" +
                $"&key={MidnightBot.GetRndGoogleAPIKey()}").ConfigureAwait(false);

            JObject obj = JObject.Parse(response);

            var data = JsonConvert.DeserializeObject <YoutubeVideoSearch>(response);

            if (data.items.Length > 0)
            {
                var toReturn = "http://www.youtube.com/watch?v=" + data.items[0].id.videoId.ToString();
                return(toReturn);
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
        public static async Task <string> FindYoutubeUrlByKeywords(string keywords)
        {
            if (string.IsNullOrWhiteSpace(keywords))
            {
                throw new ArgumentNullException(nameof(keywords), "Query not specified.");
            }
            if (keywords.Length > 150)
            {
                throw new ArgumentException("Query is too long.");
            }

            //maybe it is already a youtube url, in which case we will just extract the id and prepend it with youtube.com?v=
            var match = new Regex("(?:youtu\\.be\\/|v=)(?<id>[\\da-zA-Z\\-_]*)").Match(keywords);

            if (match.Length > 1)
            {
                return($"https://www.youtube.com/watch?v={match.Groups["id"].Value}");
            }

            if (string.IsNullOrWhiteSpace(MidnightBot.GetRndGoogleAPIKey()))
            {
                throw new InvalidCredentialException("Google API Key is missing.");
            }
            var response = await GetResponseStringAsync(
                $"https://www.googleapis.com/youtube/v3/search?" +
                $"part=snippet&maxResults=1" +
                $"&q={Uri.EscapeDataString (keywords)}" +
                $"&key={MidnightBot.GetRndGoogleAPIKey ()}").ConfigureAwait(false);

            JObject obj = JObject.Parse(response);

            var data = JsonConvert.DeserializeObject <YoutubeVideoSearch> (response);

            if (data.items.Length > 0)
            {
                var toReturn = "http://www.youtube.com/watch?v=" + data.items[0].id.videoId.ToString();
                return(toReturn);
            }
            else
            {
                return(null);
            }
        }
Beispiel #4
0
        public static async Task <IList <string> > GetVideoIDs(string playlist, int number = 50)
        {
            if (string.IsNullOrWhiteSpace(MidnightBot.GetRndGoogleAPIKey()))
            {
                throw new ArgumentNullException(nameof(playlist));
            }
            if (number < 1)
            {
                throw new ArgumentOutOfRangeException();
            }
            string nextPageToken = null;

            List <string> toReturn = new List <string> ();

            do
            {
                var toGet = number > 50 ? 50 : number;
                number -= toGet;
                var link =
                    $"https://www.googleapis.com/youtube/v3/playlistItems?part=contentDetails" +
                    $"&maxResults={toGet}" +
                    $"&playlistId={playlist}" +
                    $"&key={MidnightBot.GetRndGoogleAPIKey ()}";
                if (!string.IsNullOrWhiteSpace(nextPageToken))
                {
                    link += $"&pageToken={nextPageToken}";
                }
                var response = await GetResponseStringAsync(link).ConfigureAwait(false);

                var data = await Task.Run(() => JsonConvert.DeserializeObject <PlaylistItemsSearch> (response)).ConfigureAwait(false);

                nextPageToken = data.nextPageToken;
                toReturn.AddRange(data.items.Select(i => i.contentDetails.videoId));
            } while (number > 0 && !string.IsNullOrWhiteSpace(nextPageToken));

            return(toReturn);
        }
Beispiel #5
0
        public override void Install(ModuleManager manager)
        {
            manager.CreateCommands("", cgb =>
            {
                cgb.AddCheck(PermissionChecker.Instance);

                commands.ForEach(cmd => cmd.Init(cgb));

                cgb.CreateCommand(Prefix + "we")
                .Description($"Zeigt Wetter-Daten für eine genannte Stadt und ein Land. BEIDES IST BENÖTIGT. Wetter Api ist sehr zufällig, wenn du einen Fehler machst. | `{Prefix}we Moskau RF`")
                .Parameter("city", ParameterType.Required)
                .Parameter("country", ParameterType.Required)
                .Do(async e =>
                {
                    var city     = e.GetArg("city").Replace(" ", "");
                    var country  = e.GetArg("country").Replace(" ", "");
                    var response = await SearchHelper.GetResponseStringAsync($"http://api.lawlypopzz.xyz/nadekobot/weather/?city={city}&country={country}").ConfigureAwait(false);

                    var obj = JObject.Parse(response)["weather"];

                    await e.Channel.SendMessage(
                        $@"🌍 **Wetter in** 【{obj["target"]}】
                        📏 **Lat,Long:** ({obj["latitude"]}, {obj["longitude"]}) ☁ **Condition:** {obj["condition"]}
                        😓 **Luftfeuchtigkeit:** {obj["humidity"]}% 💨 **Wind Geschwindigkeit:** {obj["windspeedk"]}km/h / {obj["windspeedm"]}mph 
                        🔆 **Temperatur:** {obj["centigrade"]}°C / {obj["fahrenheit"]}°F 🔆 **Gefühlt:** {obj["feelscentigrade"]}°C / {obj["feelsfahrenheit"]}°F
                        🌄 **Sonnenaufgang:** {obj["sunrise"]} 🌇 **Sonnenuntergang:** {obj["sunset"]}").ConfigureAwait(false);
                });



                cgb.CreateCommand(Prefix + "yt")
                .Parameter("query", ParameterType.Unparsed)
                .Description($"Durchsucht Youtube und zeigt das erste Ergebnis. | `{Prefix}yt query`")
                .Do(async e =>
                {
                    if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query"))))
                    {
                        return;
                    }

                    var link = await SearchHelper.FindYoutubeUrlByKeywords(e.GetArg("query")).ConfigureAwait(false);
                    if (string.IsNullOrWhiteSpace(link))
                    {
                        await e.Channel.SendMessage("Kein Ergebnis mit diesem Begriff gefunden.");
                        return;
                    }
                    var shortUrl = await SearchHelper.ShortenUrl(link).ConfigureAwait(false);
                    await e.Channel.SendMessage(shortUrl).ConfigureAwait(false);
                });

                cgb.CreateCommand(Prefix + "ani")
                .Alias(Prefix + "anime", Prefix + "aq")
                .Parameter("query", ParameterType.Unparsed)
                .Description($"Durchsucht anilist nach einem Anime und zeigt das erste Ergebnis. | `{Prefix}aq aquerion evol`")
                .Do(async e =>
                {
                    if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")).ConfigureAwait(false)))
                    {
                        return;
                    }
                    string result;
                    try
                    {
                        result = (await SearchHelper.GetAnimeData(e.GetArg("query")).ConfigureAwait(false)).ToString();
                    }
                    catch
                    {
                        await e.Channel.SendMessage("Anime konnte nicht gefunden werden.").ConfigureAwait(false);
                        return;
                    }

                    await e.Channel.SendMessage(result.ToString()).ConfigureAwait(false);
                });

                cgb.CreateCommand(Prefix + "imdb")
                .Parameter("query", ParameterType.Unparsed)
                .Description($"Durchsucht IMDB nach Filmen oder Serien und zeigt erstes Ergebnis. | `{Prefix}imdb query`")
                .Do(async e =>
                {
                    if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")).ConfigureAwait(false)))
                    {
                        return;
                    }
                    await e.Channel.SendIsTyping().ConfigureAwait(false);
                    string result;
                    try
                    {
                        var movie = ImdbScraper.ImdbScrape(e.GetArg("query"), true);
                        if (movie.Status)
                        {
                            result = movie.ToString();
                        }
                        else
                        {
                            result = "Film nicht gefunden.";
                        }
                    }
                    catch
                    {
                        await e.Channel.SendMessage("Film nicht gefunden.").ConfigureAwait(false);
                        return;
                    }
                    await e.Channel.SendMessage(result.ToString());
                });

                cgb.CreateCommand(Prefix + "mang")
                .Alias(Prefix + "manga").Alias(Prefix + "mq")
                .Parameter("query", ParameterType.Unparsed)
                .Description($"Durchsucht anilist nach einem Manga und zeigt das erste Ergebnis. | `{Prefix}mq query`")
                .Do(async e =>
                {
                    if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")).ConfigureAwait(false)))
                    {
                        return;
                    }
                    string result;
                    try
                    {
                        result = (await SearchHelper.GetMangaData(e.GetArg("query")).ConfigureAwait(false)).ToString();
                    }
                    catch
                    {
                        await e.Channel.SendMessage("Manga konnte nicht gefunden werden.").ConfigureAwait(false);
                        return;
                    }
                    await e.Channel.SendMessage(result).ConfigureAwait(false);
                });

                cgb.CreateCommand(Prefix + "randomcat")
                .Alias(Prefix + "meow")
                .Description($"Zeigt ein zufälliges Katzenbild. | `{Prefix}meow`")
                .Do(async e =>
                {
                    await e.Channel.SendMessage(JObject.Parse(
                                                    await SearchHelper.GetResponseStringAsync("http://www.random.cat/meow").ConfigureAwait(false))["file"].ToString())
                    .ConfigureAwait(false);
                });

                cgb.CreateCommand(Prefix + "randomdog")
                .Alias(Prefix + "woof")
                .Description($"Zeigt ein zufälliges Hundebild. | `{Prefix}woof`")
                .Do(async e =>
                {
                    await e.Channel.SendMessage("http://random.dog/" + await SearchHelper.GetResponseStringAsync("http://random.dog/woof").ConfigureAwait(false)).ConfigureAwait(false);
                });

                cgb.CreateCommand(Prefix + "i")
                .Description($"Zeigt das erste Ergebnis für eine Suche. Benutze ~ir für unterschiedliche Ergebnisse. | `{Prefix}i cute kitten`")
                .Parameter("query", ParameterType.Unparsed)
                .Do(async e =>
                {
                    IMG:
                    if (string.IsNullOrWhiteSpace(e.GetArg("query")))
                    {
                        return;
                    }
                    try
                    {
                        var reqString = $"https://www.googleapis.com/customsearch/v1?q={Uri.EscapeDataString (e.GetArg ("query"))}&cx=018084019232060951019%3Ahs5piey28-e&safe=medium&num=1&searchType=image&fields=items%2Flink&key={MidnightBot.GetRndGoogleAPIKey ()}";
                        var obj       = JObject.Parse(await SearchHelper.GetResponseStringAsync(reqString).ConfigureAwait(false));

                        await e.Channel.SendMessage(obj["items"][0]["link"].ToString()).ConfigureAwait(false);
                    }
                    catch (HttpRequestException exception)
                    {
                        if (exception.Message.Contains("403 (Forbidden)"))
                        {
                            await e.Channel.SendMessage("Limit erreicht!").ConfigureAwait(false);
                        }
                        else
                        {
                            goto IMG;
                        }
                    }
                });

                cgb.CreateCommand(Prefix + "ir")
                .Description($"Zeigt ein zufälliges Bild bei einem angegeben Suchwort. | `{Prefix}ir cute kitten`")
                .Parameter("query", ParameterType.Unparsed)
                .Do(async e =>
                {
                    var apikey = MidnightBot.GetRndGoogleAPIKey();
                    RANDOMIMG:
                    await e.Channel.SendIsTyping();
                    if (string.IsNullOrWhiteSpace(e.GetArg("query")))
                    {
                        return;
                    }
                    try
                    {
                        var reqString = $"https://www.googleapis.com/customsearch/v1?q={Uri.EscapeDataString(e.GetArg("query"))}&cx=018084019232060951019%3Ahs5piey28-e&safe=medium&num=1&searchType=image&start={rng.Next(1,50)}&fields=items%2Flink&key={apikey}";
                        var obj       = JObject.Parse(await SearchHelper.GetResponseStringAsync(reqString).ConfigureAwait(false));
                        var items     = obj["items"] as JArray;
                        await e.Channel.SendMessage(items[0]["link"].ToString()).ConfigureAwait(false);
                    }
                    catch (HttpRequestException exception)
                    {
                        if (exception.Message.Contains("403 (Forbidden)"))
                        {
                            await e.Channel.SendMessage("Tägliches Limit erreicht!").ConfigureAwait(false);
                        }
                        else
                        {
                            goto RANDOMIMG;
                        }
                    }
                });

                cgb.CreateCommand(Prefix + "lmgtfy")
                .Description($"Google etwas für einen Idioten. | `{Prefix}lmgtfy query`")
                .Parameter("ffs", ParameterType.Unparsed)
                .Do(async e =>
                {
                    if (e.GetArg("ffs") == null || e.GetArg("ffs").Length < 1)
                    {
                        return;
                    }
                    await e.Channel.SendMessage(await $"http://lmgtfy.com/?q={ Uri.EscapeUriString (e.GetArg ("ffs").ToString ()) }".ShortenUrl())
                    .ConfigureAwait(false);
                });

                cgb.CreateCommand(Prefix + "google")
                .Alias(Prefix + "g")
                .Description($"Gibt einen Google-Suchlink für einen Begriff zurück. | `{Prefix}google query`")
                .Parameter("terms", ParameterType.Unparsed)
                .Do(async e =>
                {
                    var terms = e.GetArg("terms")?.Trim();
                    if (string.IsNullOrWhiteSpace(terms))
                    {
                        return;
                    }
                    await e.Channel.SendMessage($"https://google.com/search?q={ HttpUtility.UrlEncode(terms).Replace(' ', '+') }")
                    .ConfigureAwait(false);
                });

                cgb.CreateCommand(Prefix + "hs")
                .Description($"Sucht eine Heartstone-Karte und zeigt ihr Bild. Braucht eine Weile zum beenden. | `{Prefix}hs Ysera`")
                .Parameter("name", ParameterType.Unparsed)
                .Do(async e =>
                {
                    var arg = e.GetArg("name");
                    if (string.IsNullOrWhiteSpace(arg))
                    {
                        await e.Channel.SendMessage("💢 Bitte gib einen Kartennamen ein.").ConfigureAwait(false);
                        return;
                    }
                    await e.Channel.SendIsTyping();
                    var headers = new Dictionary <string, string> {
                        { "X-Mashape-Key", MidnightBot.Creds.MashapeKey }
                    };
                    var res = await SearchHelper.GetResponseStringAsync($"https://omgvamp-hearthstone-v1.p.mashape.com/cards/search/{Uri.EscapeUriString (arg)}", headers)
                              .ConfigureAwait(false);
                    try
                    {
                        var items  = JArray.Parse(res);
                        var images = new List <Image> ();
                        if (items == null)
                        {
                            throw new KeyNotFoundException("Es wurde keine Karte mit diesem Namen gefunden.");
                        }
                        var cnt = 0;
                        items.Shuffle();
                        foreach (var item in items.TakeWhile(item => cnt++ < 4).Where(item => item.HasValues && item["img"] != null))
                        {
                            images.Add(
                                Image.FromStream(await SearchHelper.GetResponseStreamAsync(item["img"].ToString()).ConfigureAwait(false)));
                        }
                        if (items.Count > 4)
                        {
                            await e.Channel.SendMessage("⚠ Mehr als 4 Bilder gefunden. Zeige 4 Zufällige.").ConfigureAwait(false);
                        }
                        await e.Channel.SendFile(arg + ".png", (await images.MergeAsync()).ToStream(System.Drawing.Imaging.ImageFormat.Png))
                        .ConfigureAwait(false);
                    }
                    catch (Exception ex)
                    {
                        await e.Channel.SendMessage($"💢 Error {ex.Message}").ConfigureAwait(false);
                    }
                });

                cgb.CreateCommand(Prefix + "ud")
                .Description($"Durchsucht das Urban Dictionary nach einem Wort. | `{Prefix}ud Pineapple`")
                .Parameter("query", ParameterType.Unparsed)
                .Do(async e =>
                {
                    var arg = e.GetArg("query");
                    if (string.IsNullOrWhiteSpace(arg))
                    {
                        await e.Channel.SendMessage("💢 Bitte gib einen Suchbegriff ein.").ConfigureAwait(false);
                        return;
                    }
                    await e.Channel.SendIsTyping().ConfigureAwait(false);
                    var headers = new Dictionary <string, string> {
                        { "X-Mashape-Key", MidnightBot.Creds.MashapeKey }
                    };
                    var res = await SearchHelper.GetResponseStringAsync($"https://mashape-community-urban-dictionary.p.mashape.com/define?term={Uri.EscapeUriString (arg)}", headers).ConfigureAwait(false);
                    try
                    {
                        var items = JObject.Parse(res);
                        var sb    = new System.Text.StringBuilder();
                        sb.AppendLine($"`Term:` {items["list"][0]["word"].ToString ()}");
                        sb.AppendLine($"`Definition:` {items["list"][0]["definition"].ToString ()}");
                        sb.Append($"`Link:` <{await items["list"][0]["permalink"].ToString ().ShortenUrl ().ConfigureAwait (false)}>");
                        await e.Channel.SendMessage(sb.ToString());
                    }
                    catch
                    {
                        await e.Channel.SendMessage("💢 Keine Definition für den Begriff gefunden.").ConfigureAwait(false);
                    }
                });
                // thanks to Blaubeerwald
                cgb.CreateCommand(Prefix + "#")
                .Description($"Durchsucht Tagdef.com nach einem Hashtag. | `{Prefix}# ff`")
                .Parameter("query", ParameterType.Unparsed)
                .Do(async e =>
                {
                    var arg = e.GetArg("query");
                    if (string.IsNullOrWhiteSpace(arg))
                    {
                        await e.Channel.SendMessage("💢 Bitte gib einen Suchbegriff ein.").ConfigureAwait(false);
                        return;
                    }
                    await e.Channel.SendIsTyping();
                    var headers = new Dictionary <string, string> {
                        { "X-Mashape-Key", MidnightBot.Creds.MashapeKey }
                    };
                    var res = await SearchHelper.GetResponseStringAsync($"https://tagdef.p.mashape.com/one.{Uri.EscapeUriString (arg)}.json", headers).ConfigureAwait(false);
                    try
                    {
                        var items = JObject.Parse(res);
                        var sb    = new System.Text.StringBuilder();
                        sb.AppendLine($"`Hashtag:` {items["defs"]["def"]["hashtag"].ToString ()}");
                        sb.AppendLine($"`Definition:` {items["defs"]["def"]["text"].ToString ()}");
                        sb.Append($"`Link:` <{await items["defs"]["def"]["uri"].ToString ().ShortenUrl ().ConfigureAwait (false)}>");
                        await e.Channel.SendMessage(sb.ToString());
                    }
                    catch
                    {
                        await e.Channel.SendMessage("💢 Keine Definition gefunden.").ConfigureAwait(false);
                    }
                });

                cgb.CreateCommand(Prefix + "quote")
                .Description($"Zeigt ein zufälliges Zitat. | `{Prefix}quote`")
                .Do(async e =>
                {
                    var quote = MidnightBot.Config.Quotes[rng.Next(0, MidnightBot.Config.Quotes.Count)].ToString();
                    await e.Channel.SendMessage(quote).ConfigureAwait(false);
                });

                cgb.CreateCommand(Prefix + "catfact")
                .Description($"Zeigt einen zufälligen Katzenfakt von <http://catfacts-api.appspot.com/api/facts> | `{Prefix}catfact`")
                .Do(async e =>
                {
                    var response = await SearchHelper.GetResponseStringAsync("http://catfacts-api.appspot.com/api/facts").ConfigureAwait(false);
                    if (response == null)
                    {
                        return;
                    }
                    await e.Channel.SendMessage("`" + JObject.Parse(response)["facts"].ToString() + "`").ConfigureAwait(false);
                });

                cgb.CreateCommand(Prefix + "yomama")
                .Alias(Prefix + "ym")
                .Description($"Zeigt einen zufälligen Witz von <http://api.yomomma.info/> | `{Prefix}ym`")
                .Do(async e =>
                {
                    var response = await SearchHelper.GetResponseStringAsync("http://api.yomomma.info/").ConfigureAwait(false);
                    await e.Channel.SendMessage("`" + JObject.Parse(response)["joke"].ToString() + "` 😆").ConfigureAwait(false);
                });

                cgb.CreateCommand(Prefix + "randjoke")
                .Alias(Prefix + "rj")
                .Description($"Zeigt einen zufälligen Witz von <http://tambal.azurewebsites.net/joke/random> | `{Prefix}rj`")
                .Do(async e =>
                {
                    var response = await SearchHelper.GetResponseStringAsync("http://tambal.azurewebsites.net/joke/random").ConfigureAwait(false);
                    await e.Channel.SendMessage("`" + JObject.Parse(response)["joke"].ToString() + "` 😆").ConfigureAwait(false);
                });

                cgb.CreateCommand(Prefix + "chucknorris")
                .Alias(Prefix + "cn")
                .Description($"Zeigt einen zufälligen Chuck Norris Witz von <http://tambal.azurewebsites.net/joke/random> | `{Prefix}cn`")
                .Do(async e =>
                {
                    var response = await SearchHelper.GetResponseStringAsync("http://api.icndb.com/jokes/random/").ConfigureAwait(false);
                    await e.Channel.SendMessage("`" + JObject.Parse(response)["value"]["joke"].ToString() + "` 😆").ConfigureAwait(false);
                });

                cgb.CreateCommand(Prefix + "stardew")
                .Description($"Gibt einen Link zum Stardew Valley Wiki mit gegebenem Topic zurück. | `{Prefix}stardew Cow`")
                .Parameter("topic", ParameterType.Unparsed)
                .Do(async e =>
                {
                    var topic = e.GetArg("topic")?.Trim().ToLowerInvariant();
                    if (string.IsNullOrWhiteSpace(topic))
                    {
                        return;
                    }

                    var upperTopic = topic[0].ToString().ToUpper() + topic.Substring(1);
                    topic.Replace(" ", "_");

                    await e.Channel.SendMessage($"Ich habe nach: {upperTopic} gesucht und folgendes gefunden: http://stardewvalleywiki.com/{topic}").ConfigureAwait(false);
                });

                cgb.CreateCommand(Prefix + "magicitem")
                .Alias(Prefix + "mi")
                .Description($"Zeigt ein zufälliges Magic-Item von <https://1d4chan.org/wiki/List_of_/tg/%27s_magic_items> | `{Prefix}mi`")
                .Do(async e =>
                {
                    var magicItems = JsonConvert.DeserializeObject <List <MagicItem> > (File.ReadAllText("data/magicitems.json"));
                    var item       = magicItems[rng.Next(0, magicItems.Count)].ToString();

                    await e.Channel.SendMessage(item).ConfigureAwait(false);
                });

                cgb.CreateCommand(Prefix + "revav")
                .Description($"Gibt ein Google Reverse Image Search für das Profilbild einer Person zurück. | `{Prefix}revav \"@SomeGuy\"`")
                .Parameter("user", ParameterType.Unparsed)
                .Do(async e =>
                {
                    var usrStr = e.GetArg("user")?.Trim();

                    if (string.IsNullOrWhiteSpace(usrStr))
                    {
                        return;
                    }

                    var usr = e.Server.FindUsers(usrStr).FirstOrDefault();

                    if (usr == null || string.IsNullOrWhiteSpace(usr.AvatarUrl))
                    {
                        return;
                    }
                    await e.Channel.SendIsTyping();
                    await e.Channel.SendMessage($"https://images.google.com/searchbyimage?image_url={usr.AvatarUrl}").ConfigureAwait(false);
                });

                cgb.CreateCommand(Prefix + "revimg")
                .Description($"Gibt eine 'Google Reverse Image Search' für ein Bild von einem Link zurück. | `{Prefix}revav Image link`")
                .Parameter("image", ParameterType.Unparsed)
                .Do(async e =>
                {
                    var imgLink = e.GetArg("image")?.Trim();

                    if (string.IsNullOrWhiteSpace(imgLink))
                    {
                        return;
                    }
                    await e.Channel.SendMessage($"https://images.google.com/searchbyimage?image_url={imgLink}").ConfigureAwait(false);
                });

                cgb.CreateCommand(Prefix + "safebooru")
                .Description($"Zeigt ein zufälliges Hentai Bild von safebooru  mit einem gegebenen Tag. Ein Tag ist optional aber bevorzugt. Benutze + für mehrere Tags. | `{Prefix}safebooru yuri +kissing`")
                .Parameter("tag", ParameterType.Unparsed)
                .Do(async e =>
                {
                    var tag  = e.GetArg("tag")?.Trim() ?? "";
                    var link = await SearchHelper.GetSafebooruImageLink(tag).ConfigureAwait(false);
                    if (link == null)
                    {
                        await e.Channel.SendMessage("`Keine Ergebnisse.`");
                    }
                    else
                    {
                        await e.Channel.SendMessage(link).ConfigureAwait(false);
                    }
                });

                cgb.CreateCommand(Prefix + "pony")
                .Alias(Prefix + "broni")
                .Description($"Shows a random image from bronibooru with a given tag. Tag is optional but preferred. (multiple tags are appended with +) | `{Prefix}pony scootaloo`")
                .Parameter("tag", ParameterType.Unparsed)
                .Do(async e =>
                {
                    var tag   = e.GetArg("tag")?.Trim() ?? "";
                    var broni = await SearchHelper.GetBronibooruImageLink(tag).ConfigureAwait(false);
                    if (broni != null)
                    {
                        await e.Channel.SendMessage("Bronibooru: " + broni).ConfigureAwait(false);
                    }
                    await e.Channel.SendMessage("Search yielded no results.");
                });

                cgb.CreateCommand(Prefix + "wiki")
                .Description("Gibt einen Wikipedia-Link zurück.")
                .Parameter("query", ParameterType.Unparsed)
                .Do(async e =>
                {
                    var query  = e.GetArg("query");
                    var result = await SearchHelper.GetResponseStringAsync("https://en.wikipedia.org//w/api.php?action=query&format=json&prop=info&redirects=1&formatversion=2&inprop=url&titles=" + Uri.EscapeDataString(query));
                    var data   = JsonConvert.DeserializeObject <WikipediaApiModel> (result);
                    if (data.Query.Pages[0].Missing)
                    {
                        await e.Channel.SendMessage("`Diese Seite konnte nicht gefunden werden.`");
                    }
                    else
                    {
                        await e.Channel.SendMessage(data.Query.Pages[0].FullUrl);
                    }
                });

                cgb.CreateCommand(Prefix + "clr")
                .Description($"Zeigt dir die zum Hex zugehörige Farbe.\n**Benutzung**: `{Prefix}clr 00ff00`")
                .Parameter("color", ParameterType.Unparsed)
                .Do(async e =>
                {
                    var arg1 = e.GetArg("color")?.Trim()?.Replace("#", "");
                    if (string.IsNullOrWhiteSpace(arg1))
                    {
                        return;
                    }
                    var img = new Bitmap(50, 50);

                    var red   = Convert.ToInt32(arg1.Substring(0, 2), 16);
                    var green = Convert.ToInt32(arg1.Substring(2, 2), 16);
                    var blue  = Convert.ToInt32(arg1.Substring(4, 2), 16);
                    var brush = new SolidBrush(System.Drawing.Color.FromArgb(red, green, blue));

                    using (Graphics g = Graphics.FromImage(img))
                    {
                        g.FillRectangle(brush, 0, 0, 50, 50);
                        g.Flush();
                    }

                    await e.Channel.SendFile("arg1.png", img.ToStream());
                });

                cgb.CreateCommand(Prefix + "videocall")
                .Description($"Erstellt einen privaten <http://www.appear.in> Video Anruf Link für dich und andere erwähnte Personen. Der Link wird allen erwähnten Personen per persönlicher Nachricht geschickt. | `{Prefix}videocall \"@SomeGuy\"`")
                .Parameter("arg", ParameterType.Unparsed)
                .Do(async e =>
                {
                    try
                    {
                        var allUsrs      = e.Message.MentionedUsers.Union(new User[] { e.User });
                        var allUsrsArray = allUsrs as User[] ?? allUsrs.ToArray();
                        var str          = allUsrsArray.Aggregate("http://appear.in/", (current, usr) => current + Uri.EscapeUriString(usr.Name[0].ToString()));
                        str += new Random().Next();
                        foreach (var usr in allUsrsArray)
                        {
                            await usr.SendMessage(str).ConfigureAwait(false);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                });

                cgb.CreateCommand(Prefix + "av").Alias(Prefix + "avatar")
                .Parameter("mention", ParameterType.Required)
                .Description($"Zeigt den Avatar einer erwähnten Person. | `{Prefix}av @X`")
                .Do(async e =>
                {
                    var usr = e.Channel.FindUsers(e.GetArg("mention")).FirstOrDefault();
                    if (usr == null)
                    {
                        await e.Channel.SendMessage("Ungültiger Benutzer.").ConfigureAwait(false);
                        return;
                    }
                    await e.Channel.SendMessage(await usr.AvatarUrl.ShortenUrl()).ConfigureAwait(false);
                });
            });
        }