Exemple #1
0
        public async Task UrbanDictionary(CommandContext ctx, [Description("The word(s) to search for on Urban Dictionary")] params string[] searchText)
        {
            var joinedSearch = "term=" + String.Join(" ", searchText);

            var uriBuilder = new UriBuilder("http://api.urbandictionary.com/v0/define");
            var parameters = System.Web.HttpUtility.ParseQueryString(joinedSearch);

            uriBuilder.Query = parameters.ToString();

            string json;

            using (var client = new HttpClient())
            {
                json = await client.GetStringAsync(uriBuilder.ToString());
            }

            var urbanResponse = Urban.FromJson(json);

            DiscordEmbedBuilder builder;

            if (urbanResponse.List.Count == 0)
            {
                builder = new DiscordEmbedBuilder()
                {
                    Author = new DiscordEmbedBuilder.EmbedAuthor()
                    {
                        Name = "Urban Dictionary",
                        Url  = "https://www.urbandictionary.com/"
                    },
                    Title = $"Urban Definition of \"{joinedSearch}\" not found"
                };
            }
            else
            {
                var urbanDefinition = urbanResponse.List[0];

                var uriBuilderSite = new UriBuilder("http://api.urbandictionary.com/v0/define");
                parameters       = System.Web.HttpUtility.ParseQueryString(joinedSearch);
                uriBuilder.Query = parameters.ToString();

                builder = new DiscordEmbedBuilder()
                {
                    Author = new DiscordEmbedBuilder.EmbedAuthor()
                    {
                        Name = "Urban Dictionary",
                        Url  = "https://www.urbandictionary.com/"
                    },
                    Title       = $"Urban Definition of \"{urbanDefinition.Word}\"",
                    Description = urbanDefinition.Definition,
                    Color       = DiscordColor.MidnightBlue,
                    Url         = uriBuilderSite.ToString()
                };
            }
            await ctx.RespondAsync(embed : builder.Build());
        }
        public Entity BuildEntity(Entity e, EntityWorld entityWorld, params object[] args)
        {
            Point     position   = args[0] as Point;
            int       population = (int)args[1];
            float     birdsRate  = (float)args[2];
            GeoEntity geoEntity  = entityWorld.GetComponentFromPool <GeoEntity>();

            geoEntity.Position = position;

            Urban urban = entityWorld.GetComponentFromPool <Urban>();

            urban.Population = population;
            urban.BirdsRate  = birdsRate;

            e.AddComponent(geoEntity);
            e.AddComponent(urban);
            return(e);
        }
Exemple #3
0
        public async Task SearchUrbanDictionary(EduardoContext context, string searchQuery)
        {
            string json = await NetworkHelper.GetStringAsync($"http://api.urbandictionary.com/v0/define?term={searchQuery.Replace(' ', '+')}");

            Urban data = JsonConvert.DeserializeObject <Urban>(json);

            if (!data.List.Any())
            {
                await context.Channel.SendMessageAsync(Format.Bold($"Couldn't find anything related to {searchQuery}"));

                return;
            }

            UrbanList termInfo = data.List[new Random().Next(0, data.List.Count)];

            await context.Channel.SendMessageAsync(embed : new EmbedBuilder()
                                                   .WithColor(Color.Gold)
                                                   .AddField($"Definition of {termInfo.Word}", termInfo.Definition)
                                                   .AddField("Example", termInfo.Example)
                                                   .WithFooter($"Related Terms: {string.Join(", ", data.Tags) ?? "No related terms."}")
                                                   .Build());
        }
 partial void UpdateRoomImageLink(Urban.Data.RoomImageLink instance);
 partial void DeleteBuilding(Urban.Data.Building instance);
Exemple #6
0
        public static string UrbanToCode(Urban urban)
        {
            switch (urban)
            {
            case Urban.Auckland: return("auckland");

            case Urban.AucklandCentral: return("auckland-central");

            case Urban.NorthShore: return("north-shore");

            case Urban.Waitakere: return("waitakere");

            case Urban.Hunua: return("hunua");

            case Urban.Manukau: return("manukau");

            case Urban.Masterton: return("masterton");

            case Urban.TeKuiti: return("tekuiti");

            case Urban.Dannevirke: return("dannevirke");

            case Urban.Napier: return("napier");

            case Urban.Thames: return("thames");

            case Urban.Dargaville: return("dargaville");

            case Urban.NewPlymouth: return("new-plymouth");

            case Urban.Tokoroa: return("tokoroa");

            case Urban.Gisborne: return("gisborne");

            case Urban.PalmerstonN: return("palmerston-north");

            case Urban.Wanganui: return("wanganui");

            case Urban.Hamilton: return("hamilton");

            case Urban.Paraparaumu: return("paraparaumu");

            case Urban.Wellington: return("wellington");

            case Urban.WellingtonCity: return("wellington-city");

            case Urban.WesternHills: return("western-hills");

            case Urban.LowerHutt: return("lower-hutt");

            case Urban.UpperHutt: return("upper-hutt");

            case Urban.Wainuiomata: return("wainuiomata");

            case Urban.Porirua: return("porirua");

            case Urban.Kapiti: return("kapiti");

            case Urban.Hastings: return("hastings");

            case Urban.Rotorua: return("rotorua");

            case Urban.Whakatane: return("whakatane");

            case Urban.Kaitaia: return("kaitaia");

            case Urban.Taumarunui: return("taumarunui");

            case Urban.Whangarei: return("whangarei");

            case Urban.Kerikeri: return("kerikeri");

            case Urban.Taupo: return("taupo");

            case Urban.Whitianga: return("whitianga");

            case Urban.Levin: return("levin");

            case Urban.Tauranga: return("tauranga");

            case Urban.Alexandra: return("alexandra");

            case Urban.Kaikoura: return("kaikoura");

            case Urban.Ashburton: return("ashburton");

            case Urban.Motueka: return("motueka");

            case Urban.Blenheim: return("blenheim");

            case Urban.Nelson: return("nelson");

            case Urban.Christchurch: return("christchurch");

            case Urban.ChristchurchEasternSuburbs: return("eastern-suburbs");

            case Urban.PortHills: return("port-hills");

            case Urban.BanksPeninsula: return("banks-peninsula");

            case Urban.Oamaru: return("oamaru");

            case Urban.Dunedin: return("dunedin");

            case Urban.Queenstown: return("queenstown");

            case Urban.Gore: return("gore");

            case Urban.Reefton: return("reefton");

            case Urban.Greymouth: return("greymouth");

            case Urban.Timaru: return("timaru");

            case Urban.Hokitika: return("hokitika");

            case Urban.Wanaka: return("wanaka");

            case Urban.Invercargill: return("invercargill");

            case Urban.Westport: return("westport");

            default: throw new InvalidEnumArgumentException("urban", (int)urban, typeof(Urban));
            }
        }
 partial void DeleteRoomType(Urban.Data.RoomType instance);
 partial void InsertRoomType(Urban.Data.RoomType instance);
 partial void InsertRoomReservationDates(Urban.Data.RoomReservationDates instance);
 partial void InsertRoomReservationComments(Urban.Data.RoomReservationComments instance);
 partial void DeleteRoom(Urban.Data.Room instance);
 partial void UpdateRoom(Urban.Data.Room instance);
 partial void InsertRoom(Urban.Data.Room instance);
 partial void DeleteFiles(Urban.Data.Files instance);
 partial void UpdateFiles(Urban.Data.Files instance);
 partial void InsertFiles(Urban.Data.Files instance);
 partial void DeleteRoomImageLink(Urban.Data.RoomImageLink instance);
 partial void UpdateRoomReservation(Urban.Data.RoomReservation instance);
 partial void InsertRoomAvailability(Urban.Data.RoomAvailability instance);
 partial void DeleteRoomReservationComments(Urban.Data.RoomReservationComments instance);
 partial void DeleteRoomAvailability(Urban.Data.RoomAvailability instance);
 partial void DeleteRoomReservationDates(Urban.Data.RoomReservationDates instance);
 partial void InsertRoomComments(Urban.Data.RoomComments instance);
 partial void UpdateRoomType(Urban.Data.RoomType instance);
 partial void UpdateRoomComments(Urban.Data.RoomComments instance);
 partial void InsertBuilding(Urban.Data.Building instance);
 partial void InsertRoomImageLink(Urban.Data.RoomImageLink instance);
 partial void DeleteRoomComments(Urban.Data.RoomComments instance);
 partial void UpdateBuilding(Urban.Data.Building instance);