fixed playername completion on /commands
This commit is contained in:
@@ -54,7 +54,7 @@ class SlashLeaderboard(commands.Cog):
|
|||||||
for server_choice in servers.keys():
|
for server_choice in servers.keys():
|
||||||
if(current.lower() in server_choice.lower()):
|
if(current.lower() in server_choice.lower()):
|
||||||
data.append(app_commands.Choice(name=server_choice, value=server_choice))
|
data.append(app_commands.Choice(name=server_choice, value=server_choice))
|
||||||
return data
|
return data[:25]
|
||||||
|
|
||||||
@leaderboard.autocomplete("board")
|
@leaderboard.autocomplete("board")
|
||||||
async def autocomplete_server(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice[str]]:
|
async def autocomplete_server(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice[str]]:
|
||||||
@@ -63,7 +63,7 @@ class SlashLeaderboard(commands.Cog):
|
|||||||
for board_choice in boards:
|
for board_choice in boards:
|
||||||
if(current.lower() in board_choice.lower()):
|
if(current.lower() in board_choice.lower()):
|
||||||
data.append(app_commands.Choice(name=board_choice, value=board_choice))
|
data.append(app_commands.Choice(name=board_choice, value=board_choice))
|
||||||
return data
|
return data[:25]
|
||||||
|
|
||||||
async def setup(client):
|
async def setup(client):
|
||||||
await client.add_cog(SlashLeaderboard(client))
|
await client.add_cog(SlashLeaderboard(client))
|
||||||
|
|||||||
+17
-2
@@ -51,6 +51,21 @@ class SlashStats(commands.Cog):
|
|||||||
await interaction.response.send_message(embed=botmessage)
|
await interaction.response.send_message(embed=botmessage)
|
||||||
|
|
||||||
|
|
||||||
|
@stats.autocomplete("playernames")
|
||||||
|
async def autocomplete_player(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice[str]]:
|
||||||
|
data = []
|
||||||
|
async with aiohttp.ClientSession() as session:
|
||||||
|
async with session.get('https://tone.sleepycat.date/v2/client/players') as r:
|
||||||
|
players = await r.json()
|
||||||
|
|
||||||
|
for player_choice in players.keys():
|
||||||
|
try:
|
||||||
|
if(current.lower() in players[player_choice]['username'].lower()):
|
||||||
|
data.append(app_commands.Choice(name=players[player_choice]['username'], value=players[player_choice]['username']))
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
return data[:25]
|
||||||
|
|
||||||
@stats.autocomplete("weapon")
|
@stats.autocomplete("weapon")
|
||||||
async def autocomplete_weapon(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice[str]]:
|
async def autocomplete_weapon(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice[str]]:
|
||||||
data = []
|
data = []
|
||||||
@@ -58,7 +73,7 @@ class SlashStats(commands.Cog):
|
|||||||
for weapon_choice in weaponlist:
|
for weapon_choice in weaponlist:
|
||||||
if(current.lower() in weapon_choice.lower()):
|
if(current.lower() in weapon_choice.lower()):
|
||||||
data.append(app_commands.Choice(name=weapon_choice, value=weapon_choice))
|
data.append(app_commands.Choice(name=weapon_choice, value=weapon_choice))
|
||||||
return data
|
return data[:25]
|
||||||
|
|
||||||
@stats.autocomplete("servername")
|
@stats.autocomplete("servername")
|
||||||
async def autocomplete_server(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice[str]]:
|
async def autocomplete_server(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice[str]]:
|
||||||
@@ -70,7 +85,7 @@ class SlashStats(commands.Cog):
|
|||||||
for server_choice in servers.keys():
|
for server_choice in servers.keys():
|
||||||
if(current.lower() in server_choice.lower()):
|
if(current.lower() in server_choice.lower()):
|
||||||
data.append(app_commands.Choice(name=server_choice, value=server_choice))
|
data.append(app_commands.Choice(name=server_choice, value=server_choice))
|
||||||
return data
|
return data[:25]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user