Display tags in a readable format when listing

This commit is contained in:
2026-04-20 06:21:31 +03:00
parent 94c5ec1767
commit a57d06ea63
+10 -1
View File
@@ -105,6 +105,15 @@ def tokenize(multimod: str):
raise TokenError(f"{action_tokens[action[0]] or setting_tokens[action[0]]} tokens expected in action group, got {len(action)}") raise TokenError(f"{action_tokens[action[0]] or setting_tokens[action[0]]} tokens expected in action group, got {len(action)}")
return tokenized return tokenized
def detokenize(items):
result = []
for item in items:
if isinstance(item, list):
result.append(detokenize(item))
else:
result.append(item)
return " ".join(result)
@bot.event @bot.event
async def on_ready(): async def on_ready():
print(f'We have logged in as {bot.user}') print(f'We have logged in as {bot.user}')
@@ -149,7 +158,7 @@ async def list_(interaction: nextcord.Interaction):
string = "" string = ""
if tag_db[str(interaction.guild_id)]: if tag_db[str(interaction.guild_id)]:
for i, tag in enumerate(tag_db[str(interaction.guild_id)]): for i, tag in enumerate(tag_db[str(interaction.guild_id)]):
string += f"{i}. `{tag}`\n" string += f"{i} - `{detokenize(tag["condition"]) + " {" + detokenize(tag["action"]) + "}"}`\n"
else: else:
string = "No tags for this server." string = "No tags for this server."
await interaction.send(embed=nextcord.Embed(color=nextcord.Color.blue(), title="Tag list", description=string)) await interaction.send(embed=nextcord.Embed(color=nextcord.Color.blue(), title="Tag list", description=string))