discord.py如何从DM通道获取日志

时间:2017-04-22 15:54:12

标签: python python-3.5 discord

我正在尝试检测我的机器人发送给用户的最后一条消息是否与它需要发送的消息相同(Python 3.5)。

我尝试使用client.logs_from(channel,limit=1),但我不确定如何从DM获取日志。

1 个答案:

答案 0 :(得分:1)

client.logs_from在其频道参数中接受PrivateChannel个实例。假设您已经知道要检查哪个用户的PM频道(听起来像你这样做),它就像这样简单:

# PrivateChannel instance is privateCh

newMsg = 'your message here'
async for msg in client.log_from(privateCh, limit=1):
    if newMsg != msg.content:
        await client.send_message(privateCh, newMsg)
相关问题