removed duplicate command registration
This commit is contained in:
@@ -116,22 +116,6 @@ def ensure_poll_task(ctx: interactions.SlashContext, job_id: str) -> None:
|
|||||||
return
|
return
|
||||||
poll_tasks[job_id] = asyncio.create_task(poll_job_updates(ctx, job_id))
|
poll_tasks[job_id] = asyncio.create_task(poll_job_updates(ctx, job_id))
|
||||||
|
|
||||||
@bot.listen()
|
|
||||||
async def on_startup():
|
|
||||||
await get_session()
|
|
||||||
print(f"discord adapter configured for backend {BACKEND_URL}")
|
|
||||||
|
|
||||||
@bot.listen()
|
|
||||||
async def on_shutdown():
|
|
||||||
global http_session
|
|
||||||
for task in list(poll_tasks.values()):
|
|
||||||
task.cancel()
|
|
||||||
poll_tasks.clear()
|
|
||||||
if http_session is not None and not http_session.closed:
|
|
||||||
await http_session.close()
|
|
||||||
http_session = None
|
|
||||||
|
|
||||||
|
|
||||||
@interactions.slash_command(name="youtube", description="submit a youtube download to the backend")
|
@interactions.slash_command(name="youtube", description="submit a youtube download to the backend")
|
||||||
@interactions.slash_option(
|
@interactions.slash_option(
|
||||||
name="url",
|
name="url",
|
||||||
@@ -215,14 +199,31 @@ async def status(ctx: interactions.SlashContext):
|
|||||||
prefix = "active" if active else "last"
|
prefix = "active" if active else "last"
|
||||||
await dm(ctx, f"{prefix} job: {format_status_message(job)}")
|
await dm(ctx, f"{prefix} job: {format_status_message(job)}")
|
||||||
|
|
||||||
|
@bot.listen()
|
||||||
|
async def on_startup():
|
||||||
|
await get_session()
|
||||||
|
print(f"discord adapter configured for backend {BACKEND_URL}")
|
||||||
|
print(f"{bot.application_commands.count} registered commands:")
|
||||||
|
for i, x in enumerate(bot.application_commands,start=1):
|
||||||
|
print(f" {i}. {x.name}")
|
||||||
|
|
||||||
|
@bot.listen()
|
||||||
|
async def on_shutdown():
|
||||||
|
global http_session
|
||||||
|
for task in list(poll_tasks.values()):
|
||||||
|
task.cancel()
|
||||||
|
poll_tasks.clear()
|
||||||
|
if http_session is not None and not http_session.closed:
|
||||||
|
await http_session.close()
|
||||||
|
http_session = None
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
api_token = getenv("DISCORD_BOT_TOKEN")
|
api_token = getenv("DISCORD_BOT_TOKEN")
|
||||||
if not api_token:
|
if not api_token:
|
||||||
raise ValueError("API token not set. Retrieve from your Discord bot.")
|
raise ValueError("API token not set. Retrieve from your Discord bot.")
|
||||||
bot.add_command(youtube)
|
# bot.add_command(youtube)
|
||||||
bot.add_command(status)
|
# bot.add_command(status)
|
||||||
bot.add_command(interrupt)
|
# bot.add_command(interrupt)
|
||||||
bot.start(api_token)
|
bot.start(api_token)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user