Started work on converting all commands to slash-commands

This commit is contained in:
NikolajDanger
2021-03-29 00:55:31 +02:00
parent e6e6b9b9b9
commit 232f97d0c8
11 changed files with 363 additions and 179 deletions

View File

@ -1,7 +1,19 @@
import discord
import discord, json
from discord.ext import commands
from discord_slash import cog_ext
from discord_slash import SlashCommandOptionType as scot
from funcs import spellFunc, monsterFunc, cap
from utils import Options
with open("resources/slashParameters.json", "r") as f:
params = json.load(f)
options = Options()
if options.testing:
for p in params:
params[p]["guild_ids"] = options.guildIds
class LookupCog(commands.Cog):
@ -10,9 +22,9 @@ class LookupCog(commands.Cog):
self.client = client
# Looks up a spell
@commands.command()
async def spell(self, ctx, *, content):
spell = spellFunc(cap(content))
@cog_ext.cog_slash(**params["spell"])
async def spell(self, ctx, query):
spell = spellFunc(cap(query))
if len(spell) > 2000:
await ctx.send(spell[:2000])
await ctx.send(spell[2000:])
@ -20,12 +32,12 @@ class LookupCog(commands.Cog):
await ctx.send(spell)
# Looks up a monster
@commands.command()
async def monster(self, ctx, *, content):
title, text1, text2, text3, text4, text5 = monsterFunc(cap(content))
@cog_ext.cog_slash(**params["monster"])
async def monster(self, ctx, query):
title, text1, text2, text3, text4, text5 = monsterFunc(cap(query))
em1 = discord.Embed(title = title, description = text1, colour=0xDEADBF)
# Sends the received information. Seperates into seperate messages if
# Sends the received information. Separates into separate messages if
# there is too much text
await ctx.send(embed = em1)
if text2 != "":