Exemplo n.º 1
0
        public async Task UrbanAsync(EventContext e)
        {
            if (string.IsNullOrEmpty(e.Arguments.ToString()))
            {
                return;
            }

            UrbanDictionaryApi   api   = new UrbanDictionaryApi(UrbanKey);
            UrbanDictionaryEntry entry = await api.GetEntryAsync(e.Arguments.ToString());

            if (entry != null)
            {
                await new EmbedBuilder()
                {
                    Author = new EmbedAuthor()
                    {
                        Name    = entry.Term,
                        IconUrl = "http://cdn9.staztic.com/app/a/291/291148/urban-dictionary-647813-l-140x140.png",
                        Url     = "http://www.urbandictionary.com/define.php?term=" + e.Arguments.ToString(),
                    },
                    Description = e.Locale.GetString("miki_module_general_urban_author", entry.Author)
                }.AddField(e.Locale.GetString("miki_module_general_urban_definition"), entry.Definition, true)
                .AddField(e.Locale.GetString("miki_module_general_urban_example"), entry.Example, true)
                .AddField(e.Locale.GetString("miki_module_general_urban_rating"), "👍 " + entry.ThumbsUp.ToFormattedString() + "  👎 " + entry.ThumbsDown.ToFormattedString(), true)
                .ToEmbed().QueueToChannelAsync(e.Channel);
            }
            else
            {
                await e.ErrorEmbed(e.Locale.GetString("error_term_invalid"))
                .ToEmbed().QueueToChannelAsync(e.Channel);
            }
        }
Exemplo n.º 2
0
        public async Task UrbanAsync(EventContext e)
        {
            if (string.IsNullOrEmpty(e.arguments))
            {
                return;
            }

            Locale               locale = new Locale(e.Channel.Id);
            UrbanDictionaryApi   api    = new UrbanDictionaryApi(Global.Config.UrbanKey);
            UrbanDictionaryEntry entry  = await api.GetEntryAsync(e.arguments);

            if (entry != null)
            {
                IDiscordEmbed embed = Utils.Embed
                                      .SetAuthor(entry.Term,
                                                 "http://cdn9.staztic.com/app/a/291/291148/urban-dictionary-647813-l-140x140.png",
                                                 "http://www.urbandictionary.com/define.php?term=" + e.arguments)
                                      .SetDescription(locale.GetString("miki_module_general_urban_author", entry.Author));

                embed.AddInlineField(locale.GetString("miki_module_general_urban_definition"), entry.Definition);
                embed.AddInlineField(locale.GetString("miki_module_general_urban_example"), entry.Example);
                embed.AddInlineField(locale.GetString("miki_module_general_urban_rating"), "👍 " + entry.ThumbsUp + "  👎 " + entry.ThumbsDown);

                embed.QueueToChannel(e.Channel);
            }
            else
            {
                e.ErrorEmbed(e.GetResource("error_term_invalid"))
                .QueueToChannel(e.Channel.Id);
            }
        }