Skip to content

Commit

Permalink
fixed autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
CBCicada committed Mar 22, 2024
1 parent e43dd52 commit 6fd8835
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cogs/copypasta/copypasta.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(self,bot):
self.id_lst.append(row[0])
self.name_lst.append(row[1])
self.pasta_lst.append(row[2])
print(self.name_lst)


@subcommand(id={'description': "copypasta id"})
Expand All @@ -36,7 +37,7 @@ async def byid(self, ctx: SlashContext, id: int) -> None:



@subcommand(name={'description': "copypasta name"})
@subcommand(name={'description': "copypasta name","autocomplete" : True})
async def byname(self, ctx: SlashContext, name: str) -> None:
"""copypasta by name"""
for exist_name in self.name_lst:
Expand All @@ -48,7 +49,12 @@ async def byname(self, ctx: SlashContext, name: str) -> None:
@byname.autocomplete("name")
async def find_name(self, ctx: interactions.AutocompleteContext):
'''Autocomplete that provides challenge categories for chal create'''
await ctx.send(self.name_lst)
current = ctx.kwargs.get("name")
new_lst = []
for exist_name in self.name_lst:
if current in exist_name:
new_lst.append(exist_name)
await ctx.send(new_lst[:25])

@subcommand()
async def random(self, ctx: SlashContext) -> None:
Expand Down

0 comments on commit 6fd8835

Please sign in to comment.