Merge pull request 'Fixed user autocompletes (#153)' (#159) from #153 into 0.3

Reviewed-on: sh-edraft.de/kd_discord_bot#159
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
Closes #153
This commit is contained in:
Sven Heidemann 2023-01-04 11:30:11 +01:00
commit 47415af868

View File

@ -67,6 +67,8 @@ class UserGroup(DiscordCommandABC):
'ontime': self._t.transform('modules.base.user.atr.ontime')
}
self._atr_list = [(key, self._atr_dict[key]) for key in self._atr_dict]
@commands.hybrid_group()
@commands.guild_only()
async def user(self, ctx: Context):
@ -177,8 +179,7 @@ class UserGroup(DiscordCommandABC):
@get.autocomplete('atr')
async def get_autocomplete(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]:
atr_list = [self._atr_dict["xp"], self._atr_dict["ontime"]]
return [app_commands.Choice(name=atr, value=atr) for atr in atr_list]
return [app_commands.Choice(name=key, value=value) for key, value in self._atr_list]
@user.command()
@commands.guild_only()
@ -217,8 +218,8 @@ class UserGroup(DiscordCommandABC):
@set.autocomplete('atr')
async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]:
atr_list = [self._atr_dict["xp"]]
return [app_commands.Choice(name=atr, value=atr) for atr in atr_list]
atr_list = [('xp', self._atr_dict['xp'])]
return [app_commands.Choice(name=key, value=value) for key, value in atr_list]
@user.command()
@commands.guild_only()
@ -254,5 +255,4 @@ class UserGroup(DiscordCommandABC):
@remove.autocomplete('atr')
async def remove_autocomplete(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]:
atr_list = [self._atr_dict["xp"], self._atr_dict["ontime"]]
return [app_commands.Choice(name=atr, value=atr) for atr in atr_list]
return [app_commands.Choice(name=value, value=key) for key, value in self._atr_list]