From 04c905d2873f5794b33afec2f3a0efbcf6365802 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 30 Dec 2022 11:45:41 +0100 Subject: [PATCH] Fixed user autocompletes #153 --- kdb-bot/src/modules/base/command/user_group.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kdb-bot/src/modules/base/command/user_group.py b/kdb-bot/src/modules/base/command/user_group.py index 66a9eeff..17ec3c9d 100644 --- a/kdb-bot/src/modules/base/command/user_group.py +++ b/kdb-bot/src/modules/base/command/user_group.py @@ -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): @@ -176,8 +178,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() @@ -216,8 +217,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() @@ -253,5 +254,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]