Discord机器人检查机器人是否删除了邮件

时间:2018-11-21 18:31:50

标签: python discord discord.py

我想让不和谐的机器人仅在用户删除了消息(不是机器人)后才发送回复消息。我正在使用message.author.bot进行查找,但是删除邮件似乎并不相同。到目前为止,我有这个:

@client.event
async def on_message_delete(message):
  if message.author.bot:
    return
  await client.send_message(message.channel, "<@{}>'s message was deleted".format(message.author.id))

1 个答案:

答案 0 :(得分:1)

也许这是您问题的答案

@client.event
async def on_message_delete(message, member):
    if message.author.id == client.user.id): #Checks the ID, if AuthorID = BotID, return. Else, continue.
        author : message.author #Defines the message author
        content : message.content #Defines the message content
        channel : message.channel #Defines the message channel
        logchannel = discord.utils.get(member.guild.channels, name='<XYZ>') #Defines the logs channel
        await logchannel.send(channel, '{}: {}'.format(author, content)) #Send the message.