示例#1
0
        internal static async void ShinySpawnPokemon(SocketGuild guild, SocketTextChannel channel, string PokemonName)
        {
            PokeApiClient pokeClient = new PokeApiClient();
            Pokemon       poke       = await pokeClient.GetResourceAsync <Pokemon>(PokemonName);

            Spawned spawn = new Spawned()
            {
                channel = channel.Id,
                name    = poke.Name,
                shiny   = true
            };
            string result = JsonConvert.SerializeObject(spawn);

            Console.WriteLine(result);
            File.WriteAllText(@"Resources/Spawned.json", result);
            Console.WriteLine("Stored!");

            result = String.Empty;
            result = File.ReadAllText(@"Resources/Spawned.json");
            Spawned resultSpawn = JsonConvert.DeserializeObject <Spawned>(result);

            Console.WriteLine(resultSpawn.ToString());

            Console.WriteLine($"{poke.Name}");
            var embed = new EmbedBuilder();

            embed.WithTitle("A wild pokemon has appeared!");
            embed.WithDescription("Guess the pokemon and type p.catch <pokemon> to catch it");
            embed.WithImageUrl($"https://play.pokemonshowdown.com/sprites/xyani-shiny/" + spawn.name + ".gif");


            await channel.SendMessageAsync("", embed : embed.Build());
        }
示例#2
0
        internal static async void UserSentMessage(SocketGuildUser user, SocketTextChannel channel)
        {
            PokeApiClient pokeClient = new PokeApiClient();
            int           rand1      = RandomNumber(1, 30);
            int           rand2      = RandomNumber(1, 30);

            Console.WriteLine($"{rand1} - {rand2}");
            if (rand1 == rand2)
            {
                int shinyChance1 = RandomNumber(1, 5);
                int shinyChance2 = RandomNumber(1, 5);
                Console.WriteLine($"{shinyChance1} - {shinyChance2}");
                if (shinyChance1 == shinyChance2)
                {
                    int     pokeId = RandomNumber(1, 808);
                    Pokemon poke   = await pokeClient.GetResourceAsync <Pokemon>(pokeId);

                    Spawned spawn = new Spawned()
                    {
                        channel = channel.Id,
                        name    = poke.Name,
                        shiny   = true
                    };
                    string result = JsonConvert.SerializeObject(spawn);
                    Console.WriteLine(result);
                    File.WriteAllText(@"Resources/Spawned.json", result);
                    Console.WriteLine("Stored!");

                    result = String.Empty;
                    result = File.ReadAllText(@"Resources/Spawned.json");
                    Spawned resultSpawn = JsonConvert.DeserializeObject <Spawned>(result);
                    Console.WriteLine(resultSpawn.ToString());

                    Console.WriteLine($"{poke.Name}");
                    var embed = new EmbedBuilder();
                    embed.WithTitle("A wild pokemon has appeared!");
                    embed.WithDescription("Guess the pokemon and type p.catch <pokemon> to catch it");
                    embed.WithImageUrl($"https://play.pokemonshowdown.com/sprites/xyani-shiny/" + spawn.name + ".gif");

                    await channel.SendMessageAsync("", embed : embed.Build());
                }
                else
                {
                    int     pokeId = RandomNumber(1, 808);
                    Pokemon poke   = await pokeClient.GetResourceAsync <Pokemon>(pokeId);

                    Spawned spawn = new Spawned()
                    {
                        channel = channel.Id,
                        name    = poke.Name,
                        shiny   = false
                    };
                    string result = JsonConvert.SerializeObject(spawn);
                    Console.WriteLine(result);
                    File.WriteAllText(@"Resources/Spawned.json", result);
                    Console.WriteLine("Stored!");

                    result = String.Empty;
                    result = File.ReadAllText(@"Resources/Spawned.json");
                    Spawned resultSpawn = JsonConvert.DeserializeObject <Spawned>(result);
                    Console.WriteLine(resultSpawn.ToString());

                    Console.WriteLine($"{poke.Name}");
                    var embed = new EmbedBuilder();
                    embed.WithTitle("A wild pokemon has appeared!");
                    embed.WithDescription("Guess the pokemon and type p.catch <pokemon> to catch it");
                    embed.WithImageUrl($"http://play.pokemonshowdown.com/sprites/xyani/" + spawn.name + ".gif");

                    await channel.SendMessageAsync("", embed : embed.Build());
                }
            }
        }