Ajoute une vérification de l'interaction dans la fonction say_message et implémente l'autocomplétion pour le nom court dans la commande show_character.
This commit is contained in:
parent
b55ac3ae73
commit
9eb30bb00c
2 changed files with 7 additions and 1 deletions
|
@ -71,7 +71,7 @@ async def say_message(userid:int, guildid:int, shortname:str, message:str,channe
|
||||||
webhook = None
|
webhook = None
|
||||||
# print("ok2")
|
# print("ok2")
|
||||||
print(channel.guild)
|
print(channel.guild)
|
||||||
if channel.guild is None or bot.user.id not in [m.id for m in channel.guild.members] or not channel.permissions_for(channel.guild.me).manage_webhooks:
|
if interaction_res is not None and (channel.guild is None or bot.user.id not in [m.id for m in channel.guild.members] or not channel.permissions_for(channel.guild.me).manage_webhooks):
|
||||||
await interaction_res.send_message(f"**{full_name}({short_name})**: {message}")
|
await interaction_res.send_message(f"**{full_name}({short_name})**: {message}")
|
||||||
return
|
return
|
||||||
if discord.utils.get(await channel.webhooks(),name=short_name) is None:
|
if discord.utils.get(await channel.webhooks(),name=short_name) is None:
|
||||||
|
|
|
@ -80,6 +80,12 @@ class PersoCommands(app_commands.Group):
|
||||||
return
|
return
|
||||||
embed = await perso_embed(self.bot,row)
|
embed = await perso_embed(self.bot,row)
|
||||||
await interaction.response.send_message(f"Affichage de {row["nom_complet"]}({row["nom_court"]})",embed=embed)
|
await interaction.response.send_message(f"Affichage de {row["nom_complet"]}({row["nom_court"]})",embed=embed)
|
||||||
|
@show_character.autocomplete(name="short_name")
|
||||||
|
async def autocomplete_short_name(self,interaction:discord.Interaction):
|
||||||
|
res = await self.bot.db.execute("SELECT nom_court FROM personnages WHERE uuid=? AND (guild_id=? OR guild_id IS NULL)",(interaction.user.id,interaction.guild.id))
|
||||||
|
rows = await res.fetchall()
|
||||||
|
await res.close()
|
||||||
|
return [app_commands.OptionChoice(name=row["nom_court"],value=row["nom_court"]) for row in rows]
|
||||||
@app_commands.command(name="lister",description="Liste tous les personnages")
|
@app_commands.command(name="lister",description="Liste tous les personnages")
|
||||||
async def list_characters(self,interaction:discord.Interaction):
|
async def list_characters(self,interaction:discord.Interaction):
|
||||||
#admin
|
#admin
|
||||||
|
|
Loading…
Reference in a new issue