diff --git a/main-bot.py b/main-bot.py index 8725aa3..39bb947 100644 --- a/main-bot.py +++ b/main-bot.py @@ -71,7 +71,7 @@ async def say_message(userid:int, guildid:int, shortname:str, message:str,channe webhook = None # print("ok2") 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}") return if discord.utils.get(await channel.webhooks(),name=short_name) is None: diff --git a/perso_commands.py b/perso_commands.py index 86d89f0..c2d6776 100644 --- a/perso_commands.py +++ b/perso_commands.py @@ -80,6 +80,12 @@ class PersoCommands(app_commands.Group): return embed = await perso_embed(self.bot,row) 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") async def list_characters(self,interaction:discord.Interaction): #admin