我需要让一个用户的PM频道来查看我的bot之前发送给该用户的消息。我已经从标准频道的命令消息中得到了他们的用户对象。在
到目前为止,我一直在努力:
@client.event
async def in_msg(msg):
user = msg.author
privateChannel = client.get_channel(user.id) # not working
if privateChannel is not None:
await doSomethingWithChannel(privateChannel, user)
else:
privateChannel = await client.start_private_message(user)
await firstMessageToUser(privateChannel, user)
但是,用户的DM频道似乎与他们的用户id无关。我现在该怎么办?在
您的用户对象本身成为pm的目的地。在
所以,
privateChannel = user
目前没有任何简单的方法可以做到这一点。在新版本中可能会有一个
user.dm_channel
的计划,但现在我们必须做的是循环使用client.private_channels
并寻找用户:相关问题 更多 >
编程相关推荐