lc variadic
This commit is contained in:
parent
3de4fc0f75
commit
833a2383c4
@ -84,8 +84,7 @@ class Night(commands.Cog):
|
|||||||
print("synced")
|
print("synced")
|
||||||
await ctx.reply("synced")
|
await ctx.reply("synced")
|
||||||
|
|
||||||
@commands.hybrid_command(aliases=["lc"])
|
async def leetcode_one(self, ctx: commands.Context, /, url: str):
|
||||||
async def leetcode(self, ctx: commands.Context, url: str):
|
|
||||||
match = re.search(r"/problems/([a-z0-9\-]*)", url)
|
match = re.search(r"/problems/([a-z0-9\-]*)", url)
|
||||||
if not match:
|
if not match:
|
||||||
await ctx.reply("invalid url")
|
await ctx.reply("invalid url")
|
||||||
@ -115,7 +114,7 @@ class Night(commands.Cog):
|
|||||||
return
|
return
|
||||||
async for thread in threads(ctx.channel):
|
async for thread in threads(ctx.channel):
|
||||||
if thread.name == title:
|
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
|
return
|
||||||
thread = await ctx.channel.create_thread(name=title, type=discord.ChannelType.public_thread)
|
thread = await ctx.channel.create_thread(name=title, type=discord.ChannelType.public_thread)
|
||||||
message = await thread.send(f"https://leetcode.com/problems/{name}/")
|
message = await thread.send(f"https://leetcode.com/problems/{name}/")
|
||||||
@ -124,11 +123,11 @@ class Night(commands.Cog):
|
|||||||
return
|
return
|
||||||
await message.pin()
|
await message.pin()
|
||||||
|
|
||||||
@commands.command()
|
@commands.command(aliases=["lc"])
|
||||||
async def lcmany(self, ctx: commands.Context, *urls: str):
|
async def leetcode(self, ctx: commands.Context, *urls: str):
|
||||||
async with asyncio.TaskGroup() as tg:
|
async with asyncio.TaskGroup() as tg:
|
||||||
for url in urls:
|
for url in urls:
|
||||||
tg.create_task(self.leetcode(ctx, url))
|
tg.create_task(self.leetcode_one(ctx, url))
|
||||||
|
|
||||||
@commands.hybrid_command()
|
@commands.hybrid_command()
|
||||||
async def tex(self, ctx: commands.Context, *, code: Annotated[list[str], CodeblockConverter]):
|
async def tex(self, ctx: commands.Context, *, code: Annotated[list[str], CodeblockConverter]):
|
||||||
|
Loading…
Reference in New Issue
Block a user