async def spawn(self, ctx): """Spawn a puzzle for tokens and points""" if ctx.channel.id not in (822268790666428426, 822268757707194378, 825907437847576618, 819320462538440765): return await ctx.send( "Wrong channel! Use <#822268790666428426> <#822268757707194378> or <#825907437847576618> instead. Join https://discord.gg/CU6vqsNvKb to participate!" ) mem = await self.bot.mongo.fetch_member_info(ctx.author) amount = random.randint(2, 20) points_amount = round(10 * mem.event_multiplier / 100, 2) * 2 def scramble(word): foo = list(word) random.shuffle(foo) return "".join(foo) species = self.bot.data.random_spawn() print(species.name) embed = discord.Embed( title= f"Unscramble this pokemon for {amount} tokens and {points_amount} points.", description=f"{scramble(species.name)}", ) await ctx.send(content=f"> <@!{ctx.author.id}>", embed=embed) def check_winner(message): return (ctx.author.id == message.author.id and message.channel.id == ctx.channel.id) try: message = await self.bot.wait_for("message", timeout=30, check=lambda m: check_winner(m)) except: return await ctx.send( f"Challenge skipped. The pokemon was **{species.name}**. You can start another one with `>spawn`" ) if models.deaccent(message.content.lower().replace( "′", "'")) not in species.correct_guesses: return await message.channel.send( f"Challenge skipped. The pokemon was **{species.name}**. You can start another one with `>spawn`" ) embed = discord.Embed( title=f"{species.name} was correct!", description= f"You won **{amount}** tokens and **{points_amount}** points.", ) await self.bot.mongo.update_member( ctx.author, {"$inc": { "balance": amount, "points": points_amount }}, ) return await message.reply(embed=embed)
async def spawn(self, ctx): amount = random.randint(2, 20) def scramble(word): foo = list(word) random.shuffle(foo) return "".join(foo) species = self.bot.data.random_spawn() embed = discord.Embed( title=f"Unscramble this pokemon for {amount} tokens", description=f"{scramble(species.name)}", ) await ctx.send(content=f"> <@!{ctx.author.id}>", embed=embed) def check_winner(message): return (ctx.author.id == message.author.id and message.channel.id == ctx.channel.id) try: message = await self.bot.wait_for("message", timeout=30, check=lambda m: check_winner(m)) except: return await ctx.send( f"Challenge skipped. The pokemon was **{species.name}**. You can start another one with `>spawn`" ) if models.deaccent(message.content.lower().replace( "′", "'")) not in species.correct_guesses: return await message.channel.send( f"Challenge skipped. The pokemon was **{species.name}**. You can start another one with `>spawn`" ) embed = discord.Embed( title=f"{species.name} was correct!", description=f"You won **{amount}** tokens!", ) await self.bot.mongo.update_member( ctx.author, {"$inc": { "balance": amount }}, ) return await message.reply(embed=embed)
async def on_message(self, message): if ( message.author.bot and message.author != self.bot.user and deaccent(message.author.display_name) == "Poketwo" and len(message.embeds) > 0 and "Trade between" in message.embeds[0].title ): try: await message.delete() except discord.HTTPException: await message.channel.send( "**Warning:** A trading embed by a bot pretending to be Pokétwo was identified. Unattentive players are scammed using fake bots every day. Please make sure you are trading what you intended to." ) else: await message.channel.send( "**Warning:** A trading embed by a bot pretending to be Pokétwo was identified and deleted for safety. Unattentive players are scammed using fake bots every day. Please make sure you are trading what you intended to." )
async def catch(self, ctx, *, guess: str): """Catch a wild pokémon.""" # Retrieve correct species and level from tracker if not await self.bot.redis.hexists("wild", ctx.channel.id): return species_id = await self.bot.redis.hget("wild", ctx.channel.id) species = self.bot.data.species_by_number(int(species_id)) if ( models.deaccent(guess.lower().replace("′", "'")) not in species.correct_guesses ): return await ctx.send("That is the wrong pokémon!") # Correct guess, add to database if ctx.channel.id == 759559123657293835: if ctx.author.id in self.caught_users[ctx.channel.id]: return await ctx.send("You have already caught this pokémon!") self.caught_users[ctx.channel.id].add(ctx.author.id) else: await self.bot.redis.hdel("wild", ctx.channel.id) member = await self.bot.mongo.fetch_member_info(ctx.author) shiny = member.determine_shiny(species) level = min(max(int(random.normalvariate(20, 10)), 1), 100) moves = [x.move.id for x in species.moves if level >= x.method.level] random.shuffle(moves) await self.bot.mongo.db.pokemon.insert_one( { "owner_id": ctx.author.id, "species_id": species.id, "level": level, "xp": 0, "nature": mongo.random_nature(), "iv_hp": mongo.random_iv(), "iv_atk": mongo.random_iv(), "iv_defn": mongo.random_iv(), "iv_satk": mongo.random_iv(), "iv_sdef": mongo.random_iv(), "iv_spd": mongo.random_iv(), "moves": moves[:4], "shiny": shiny, "idx": await self.bot.mongo.fetch_next_idx(ctx.author), } ) if shiny: await self.bot.mongo.update_member( ctx.author, {"$inc": {"shinies_caught": 1}} ) message = f"Congratulations {ctx.author.mention}! You caught a level {level} {species}!" memberp = await self.bot.mongo.fetch_pokedex( ctx.author, species.dex_number, species.dex_number + 1 ) if str(species.dex_number) not in memberp.pokedex: message += " Added to Pokédex. You received 35 Pokécoins!" await self.bot.mongo.update_member( ctx.author, { "$set": {f"pokedex.{species.dex_number}": 1}, "$inc": {"balance": 35}, }, ) else: inc_bal = 0 if memberp.pokedex[str(species.dex_number)] + 1 == 10: message += f" This is your 10th {species}! You received 350 Pokécoins." inc_bal = 350 elif memberp.pokedex[str(species.dex_number)] + 1 == 100: message += ( f" This is your 100th {species}! You received 3500 Pokécoins." ) inc_bal = 3500 elif memberp.pokedex[str(species.dex_number)] + 1 == 1000: message += ( f" This is your 1000th {species}! You received 35000 Pokécoins." ) inc_bal = 35000 await self.bot.mongo.update_member( ctx.author, { "$inc": {"balance": inc_bal, f"pokedex.{species.dex_number}": 1}, }, ) if member.shiny_hunt == species.dex_number: if shiny: message += f"\n\nShiny streak reset." await self.bot.mongo.update_member( ctx.author, {"$set": {"shiny_streak": 0}} ) else: message += f"\n\n+1 Shiny chain! (**{member.shiny_streak + 1}**)" await self.bot.mongo.update_member( ctx.author, {"$inc": {"shiny_streak": 1}} ) if shiny: message += "\n\nThese colors seem unusual... ✨" self.bot.dispatch("catch", ctx.author, species) await ctx.send(message)
async def hardspawn(self, ctx): amount = random.randint(10, 30) def scramble(word): foo = list(word.lower()) random.shuffle(foo) return "".join(foo) species = self.bot.data.random_spawn() gamemode = random.randint(1, 2) if gamemode == 0: embed = discord.Embed( title=f"Unscramble this pokemon for {amount} tokens", description=f"{scramble(species.name)}", ) elif gamemode == 1: embed = discord.Embed( title=f"Guess this pokemon for {amount} tokens", description= f"Hint: The first letter is **{species.name[0]}**. \n \n {helper.homoglyph_convert(species.name, species.description)}", ) else: embed = discord.Embed( title=f"Guess this pokemon for {amount} tokens", description= f"Hint: The pokemon is **{helper.hintify(species.name)}**. \n \n", ) embed.add_field( name="Appearance", value= f"Height: {species.height} m\nWeight: {species.weight} kg", ) embed.add_field(name="Types", value="\n".join(species.types)) await ctx.send(content=f"> <@!{ctx.author.id}>", embed=embed) def check_winner(message): return (ctx.author.id == message.author.id and message.channel.id == ctx.channel.id) try: message = await self.bot.wait_for("message", timeout=30, check=lambda m: check_winner(m)) except: return await ctx.send( f"Challenge skipped. The pokemon was **{species.name}**. You can start another one with `>spawn`" ) if models.deaccent(message.content.lower().replace( "′", "'")) not in species.correct_guesses: return await message.channel.send( f"Challenge skipped. The pokemon was **{species.name}**. You can start another one with `>spawn`" ) embed = discord.Embed( title=f"{species.name} was correct!", description=f"You won **{amount}** tokens!", ) await self.bot.mongo.update_member( ctx.author, {"$inc": { "balance": amount }}, ) return await message.reply(embed=embed)
def check_winner(message): return (ctx.author.id == message.author.id or message.author.id == user.id) and models.deaccent( message.content.lower().replace( "′", "'")) in species.correct_guesses