[Python] discord.py - getting command message which called interaction

Discussão em 'Python' iniciado por Stack, Outubro 6, 2024.

  1. Stack

    Stack Membro Participativo

    I'm trying to get command message data which called interaction.

    In API document, found there is message attribute in Interaction, but it only works in component type.

    So, is there any way to get command message data from interaction like ctx?

    here is code:

    bot = commands.Bot(command_prefix=".", intents=discord.Intents.default())

    @bot.tree.command(name="delete")
    async def moveTab(interaction):
    # interaction.message is null, not supported in interaction
    ref = interaction.message.reference

    if not ref:
    await interaction.reply("please select target by replying to it")
    return

    target = await interaction.channel.fetch_message(ref.message_id)
    await target.delete()

    Continue reading...

Compartilhe esta Página