72 lines
3.1 KiB
Python
72 lines
3.1 KiB
Python
import discord, json
|
|
from discord.ext import commands
|
|
from discord_slash import cog_ext
|
|
from discord_slash import SlashCommandOptionType as scot
|
|
|
|
from utils import getParams, cap
|
|
|
|
params = getParams()
|
|
|
|
class LookupCog(commands.Cog):
|
|
def __init__(self, bot):
|
|
"""Runs lookup commands."""
|
|
self.bot = bot
|
|
|
|
# Looks up a spell
|
|
@cog_ext.cog_slash(**params["spell"])
|
|
async def spell(self, ctx, query):
|
|
spell = self.bot.lookupFuncs.spellFunc(cap(query))
|
|
if len(spell) > 2000:
|
|
await ctx.send(spell[:2000])
|
|
await ctx.send(spell[2000:])
|
|
else:
|
|
await ctx.send(spell)
|
|
|
|
# Looks up a monster
|
|
@cog_ext.cog_slash(**params["monster"])
|
|
async def monster(self, ctx, query):
|
|
title, text1, text2, text3, text4, text5 = self.bot.lookupFuncs.monsterFunc(cap(query))
|
|
em1 = discord.Embed(title = title, description = text1, colour=0xDEADBF)
|
|
|
|
# Sends the received information. Separates into separate messages if
|
|
# there is too much text
|
|
await ctx.send(embed = em1)
|
|
if text2 != "":
|
|
if len(text2) < 2048:
|
|
em2 = discord.Embed(title = "Special Abilities", description = text2, colour=0xDEADBF)
|
|
await ctx.send(embed = em2)
|
|
else:
|
|
em2 = discord.Embed(title = "Special Abilities", description = text2[:2048], colour=0xDEADBF)
|
|
await ctx.send(embed = em2)
|
|
em2_2 = discord.Embed(title = "", description = text2[2048:], colour=0xDEADBF)
|
|
await ctx.send(embed = em2_2)
|
|
if text3 != "":
|
|
if len(text3) < 2048:
|
|
em3 = discord.Embed(title = "Actions", description = text3, colour=0xDEADBF)
|
|
await ctx.send(embed = em3)
|
|
else:
|
|
em3 = discord.Embed(title = "Actions", description = text3[:2048], colour=0xDEADBF)
|
|
await ctx.send(embed = em3)
|
|
em3_2 = discord.Embed(title = "", description = text3[2048:], colour=0xDEADBF)
|
|
await ctx.send(embed = em3_2)
|
|
if text4 != "":
|
|
if len(text4) < 2048:
|
|
em4 = discord.Embed(title = "Reactions", description = text4, colour=0xDEADBF)
|
|
await ctx.send(embed = em4)
|
|
else:
|
|
em4 = discord.Embed(title = "Reactions", description = text4[:2048], colour=0xDEADBF)
|
|
await ctx.send(embed = em4)
|
|
em4_2 = discord.Embed(title = "", description = text4[2048:], colour=0xDEADBF)
|
|
await ctx.send(embed = em4_2)
|
|
if text5 != "":
|
|
if len(text5) < 2048:
|
|
em5 = discord.Embed(title = "Legendary Actions", description = text5, colour=0xDEADBF)
|
|
await ctx.send(embed = em5)
|
|
else:
|
|
em5 = discord.Embed(title = "Legendary Actions", description = text5[:2048], colour=0xDEADBF)
|
|
await ctx.send(embed = em5)
|
|
em5_2 = discord.Embed(title = "", description = text5[2048:], colour=0xDEADBF)
|
|
await ctx.send(embed = em5_2)
|
|
|
|
def setup(bot):
|
|
bot.add_cog(LookupCog(bot)) |