尝试根据事件事件发送嵌入消息

时间:2021-01-09 00:57:20

标签: python discord discord.py discord.py-rewrite

我正在尝试为已删除的消息创建一个记录器,每当消息被删除时,都会根据一个事件来记录

snipe_message_author = None
snipe_message_id = None

@client.event
async def on_message_delete(message):

    global snipe_message_content
    global snipe_message_author
    global snipe_message_id

    snipe_message_content = message.content
    snipe_message_author = message.author.id
    snipe_message_id = message.id
    await asyncio.sleep(60)

    if message.id == snipe_message_id:
        snipe_message_author = None
        snipe_message_content = None
        snipe_message_id = None


@client.event
async def logs(ctx, message):
    if snipe_message_content==None:
        m == 1
    else:
        embed = discord.Embed(description=f"{snipe_message_content}")
        embed.set_footer(text=f"Sniped by {message.author.name}#{message.author.discriminator}")
        embed.set_author(name= f"<@{snipe_message_author}>")
        await message.channel.send(client.get_channel('channel id'), embed=embed)
        return

我在这部分遇到问题....

@client.event
async def logs(ctx, message):
    if snipe_message_content==None:
        m == 1
    else:
        embed = discord.Embed(description=f"{snipe_message_content}")
        embed.set_footer(text=f"Sniped by {message.author.name}#{message.author.discriminator}")
        embed.set_author(name= f"<@{snipe_message_author}>")
        await message.channel.send(client.get_channel('channnelid'), embed=embed)
        return

我尝试过使用不同的方法,但到目前为止都没有效果

1 个答案:

答案 0 :(得分:0)

你需要一个命令?

@client.command()
async def logs(ctx):
    global snipe_message_content
    if snipe_message_content==None:
        m = 1
    else:
        embed = discord.Embed(description=f"{snipe_message_content}")
        embed.set_footer(text=f"Sniped by {ctx.author.name}#{ctx.author.discriminator}")
        embed.set_author(name= f"<@{snipe_message_author}>")
        await ctx.send(embed=embed)