51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
# cmd_discord/howl.py
|
|
from discord.ext import commands
|
|
import globals
|
|
import cmd_common.common_commands as cc
|
|
|
|
def setup(bot):
|
|
"""
|
|
Registers the '!quote' command for Discord.
|
|
"""
|
|
@bot.command(name="quote")
|
|
async def cmd_quote_text(ctx, *, arg_str: str = ""):
|
|
"""
|
|
Handle the '!quote' command with multiple subcommands.
|
|
|
|
Usage:
|
|
- !quote
|
|
-> Retrieves a random (non-removed) quote.
|
|
- !quote <number>
|
|
-> Retrieves a specific quote by its ID.
|
|
- !quote add <quote text>
|
|
-> Adds a new quote and replies with its quote number.
|
|
- !quote remove <number>
|
|
-> Removes the specified quote.
|
|
- !quote restore <number>
|
|
-> Restores a previously removed quote.
|
|
- !quote info <number>
|
|
-> Displays stored information about the quote.
|
|
- !quote search [keywords]
|
|
-> Searches for the best matching quote.
|
|
- !quote latest
|
|
-> Retrieves the latest (most recent) non-removed quote.
|
|
"""
|
|
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)
|