Tiamat: Fix monster embed length too long
This commit is contained in:
parent
dcfe01b58f
commit
71a6e740fb
@ -1,6 +1,7 @@
|
||||
from redbot.core import commands
|
||||
import discord
|
||||
import requests
|
||||
from itertools import islice
|
||||
|
||||
class Tiamat(commands.Cog):
|
||||
""" Get information from D&D 5e's srd """
|
||||
@ -21,15 +22,19 @@ class Tiamat(commands.Cog):
|
||||
initial_embed.add_field(name="AC", value=data["armor_class"])
|
||||
for ability in ["strength", "dexterity", "constitution", "intelligence", "wisdom", "charisma"]:
|
||||
initial_embed.add_field(name=ability, value=data[ability], inline=True)
|
||||
attack_embed = discord.Embed(title="Actions")
|
||||
attack_embeds = []
|
||||
for i, action_group in enumerate(chunk(data["actions"], 3)):
|
||||
attack_embed = discord.Embed(title=f"Actions [{i}]")
|
||||
for action in data["actions"]:
|
||||
attack_embed.add_field(name=action["name"], value=action["desc"])
|
||||
attack_embeds.append(attack_embed)
|
||||
legendary_embed = None
|
||||
if "legendary_actions" in data:
|
||||
legendary_embed = discord.Embed(title="Legendary Actions")
|
||||
for action in data["legendary_actions"]:
|
||||
legendary_embed.add_field(name=action["name"], value=action["desc"])
|
||||
await ctx.send(embed=initial_embed)
|
||||
for attack_embed in attack_embeds:
|
||||
await ctx.send(embed=attack_embed)
|
||||
if legendary_embed is not None:
|
||||
await ctx.send(embed=legendary_embed)
|
||||
@ -101,3 +106,8 @@ class Tiamat(commands.Cog):
|
||||
await ctx.send(embed=embed)
|
||||
except KeyError:
|
||||
await ctx.send("Error: item is not a weapon")
|
||||
|
||||
|
||||
def chunk(it, size):
|
||||
it = iter(it)
|
||||
return iter(lambda: tuple(islice(it, size)), ())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user