40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
# cmd_discord/quote.py
|
|
|
|
import discord
|
|
from discord.ext import commands
|
|
import globals
|
|
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 []
|
|
globals.log(f"'quote' command initiated with arguments: {args}", "DEBUG")
|
|
|
|
result = await cc.handle_quote_command(
|
|
db_conn=globals.init_db_conn,
|
|
is_discord=True,
|
|
ctx=ctx,
|
|
args=args,
|
|
game_name=None
|
|
)
|
|
|
|
globals.log(f"'quote' result: {result}", "DEBUG")
|
|
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))
|