lc variadic

This commit is contained in:
AF 2024-05-17 12:10:20 +00:00
parent 3de4fc0f75
commit 833a2383c4
Signed by: alisa
SSH Key Fingerprint: SHA256:vNY4pdIZvO1FYJKHROkdHLtvyopizvZVAEwg9AF6h04

View File

@ -84,8 +84,7 @@ class Night(commands.Cog):
print("synced")
await ctx.reply("synced")
@commands.hybrid_command(aliases=["lc"])
async def leetcode(self, ctx: commands.Context, url: str):
async def leetcode_one(self, ctx: commands.Context, /, url: str):
match = re.search(r"/problems/([a-z0-9\-]*)", url)
if not match:
await ctx.reply("invalid url")
@ -115,7 +114,7 @@ class Night(commands.Cog):
return
async for thread in threads(ctx.channel):
if thread.name == title:
await ctx.reply(f"exists: {thread.jump_url}")
message = await ctx.reply(f"exists: {thread.jump_url}", delete_after=60)
return
thread = await ctx.channel.create_thread(name=title, type=discord.ChannelType.public_thread)
message = await thread.send(f"https://leetcode.com/problems/{name}/")
@ -124,11 +123,11 @@ class Night(commands.Cog):
return
await message.pin()
@commands.command()
async def lcmany(self, ctx: commands.Context, *urls: str):
@commands.command(aliases=["lc"])
async def leetcode(self, ctx: commands.Context, *urls: str):
async with asyncio.TaskGroup() as tg:
for url in urls:
tg.create_task(self.leetcode(ctx, url))
tg.create_task(self.leetcode_one(ctx, url))
@commands.hybrid_command()
async def tex(self, ctx: commands.Context, *, code: Annotated[list[str], CodeblockConverter]):