def filter_type(message: discord.Message, slot_1: str.lower, slot_2: str.lower=None):
matched_pokemon = []
assert_type(slot_1, message.server)
# Find all pokemon with the matched criteria
if slot_2:
assert_type(slot_2, message.server)
# If two slots are provided, search for pokemon with both types matching
for pokemon in pokedex.values():
if pokemon["types"] == [slot_1, slot_2]:
matched_pokemon.append(pokemon["locale_name"])
else:
# All pokemon have a type in their first slot, so check if these are equal
for pokemon in pokedex.values():
if pokemon["types"][0] == slot_1:
matched_pokemon.append(pokemon["locale_name"])
# There might not be any pokemon with the specified types
assert matched_pokemon, "Looks like there are no pokemon of type **{}**!".format(format_type(slot_1, slot_2))
await client.say(message, "**Pokemon with type {}**: ```\n{}```".format(
format_type(slot_1, slot_2), ", ".join(sorted(matched_pokemon))))
评论列表
文章目录