OokamiPupV2/cmd_discord/quote.py

42 lines
1.1 KiB
Python

# cmd_discord/quote.py
import discord
from discord.ext import commands
import globals
from globals import logger
import cmd_common.common_commands as cc
class QuoteCog(commands.Cog):
"""Handles the '!quote' command."""
def __init__(self, bot):
self.bot = bot
@commands.command(name="quote")
async def cmd_quote_text(self, ctx, *, arg_str: str = ""):
"""Handles various quote-related subcommands."""
if not globals.init_db_conn:
await ctx.reply("Database is unavailable, sorry.")
return
args = arg_str.split() if arg_str else []
logger.debug(f"'quote' command initiated with arguments: {args}")
result = await cc.handle_quote_command(
db_conn=globals.init_db_conn,
is_discord=True,
ctx=ctx,
args=args,
game_name=None
)
logger.debug(f"'quote' result: {result}")
if hasattr(result, "to_dict"):
await ctx.reply(embed=result)
else:
await ctx.reply(result)
async def setup(bot):
await bot.add_cog(QuoteCog(bot))