added monster command to tiamat
This commit is contained in:
parent
91481ac886
commit
45c9b4a137
0
tiamat/__init__.py
Normal file
0
tiamat/__init__.py
Normal file
33
tiamat/tiamat.py
Normal file
33
tiamat/tiamat.py
Normal file
@ -0,0 +1,33 @@
|
||||
from redbot.core import commands
|
||||
import discord
|
||||
import requests
|
||||
|
||||
class Tiamat(commands.Cog):
|
||||
""" Get information from D&D 5e's srd """
|
||||
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
def monster(self, ctx, *args):
|
||||
name = '-'.join(args).lower()
|
||||
data = requests.get(f"https://www.dnd5eapi.co/api/monsters/{name}").json()
|
||||
if "error" in data:
|
||||
await ctx.send(f"{' '.join(args)} not found, check that the name is spelled right and that the creature "
|
||||
f"is in the System Reference Document")
|
||||
else:
|
||||
initial_embed = discord.Embed(title=data["name"])
|
||||
for ability in ["strength", "dexterity", "constitution", "intelligence", "wisdom", "charisma"]:
|
||||
initial_embed.add_field(name=ability, value=data[ability], inline=True)
|
||||
initial_embed.add_field(name="AC", value=data["armor_class"])
|
||||
attack_embed = discord.Embed(title="Actions")
|
||||
for action in data["actions"]:
|
||||
attack_embed.add_field(name=action["name"], value=action["desc"])
|
||||
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(initial_embed)
|
||||
await ctx.send(attack_embed)
|
||||
if legendary_embed is not None:
|
||||
await ctx.send(legendary_embed)
|
||||
Loading…
x
Reference in New Issue
Block a user