add quote as context menu command
This commit is contained in:
parent
c9b73d8350
commit
047f24964b
|
@ -11,7 +11,9 @@ class Utils(MyCog):
|
|||
def __init__(self, bot):
|
||||
super().__init__(bot)
|
||||
self.bot = bot
|
||||
|
||||
self.context_menu_quote = app_commands.ContextMenu(name="Quote", callback=self.quote_message)
|
||||
bot.tree.add_command(self.context_menu_quote)
|
||||
|
||||
@app_commands.command(name="quote")
|
||||
async def quote(self, interaction: discord.Interaction, link: str):
|
||||
"""
|
||||
|
@ -49,5 +51,26 @@ class Utils(MyCog):
|
|||
ephemeral=True)
|
||||
|
||||
|
||||
async def quote_message(self, interaction: discord.Interaction, message: discord.Message):
|
||||
""""
|
||||
Citer un message
|
||||
"""
|
||||
embed = discord.Embed(
|
||||
description=message.content,
|
||||
timestamp=message.created_at.astimezone(pytz.timezone('Europe/Berlin')),
|
||||
color=discord.Color.random()
|
||||
)
|
||||
embed.set_author(
|
||||
name=f"{message.author.name}",
|
||||
url=message.jump_url,
|
||||
icon_url=message.author.display_avatar.url
|
||||
)
|
||||
|
||||
embed.set_footer(text=f"Quoted by {interaction.user.name}")
|
||||
await interaction.channel.send(embed=embed)
|
||||
await interaction.response.send_message("Citation opérée avec succès !",
|
||||
ephemeral=True)
|
||||
|
||||
|
||||
async def setup(bot):
|
||||
await bot.add_cog(Utils(bot))
|
||||
|
|
Loading…
Reference in New Issue