Discord.py get message from DM

吃可爱长大的小学妹 提交于 2019-12-11 08:46:10

问题


I try to make my bot to get message from DM using this syntax:

for wolf in wolf_list_id:
   poll_message = await self.client.get_message(wolf, react_message.id)

The wolf contains the id of user, but the get_message syntax can't take the id from wolf. Any ideas?


回答1:


like said the doc, the client.get_message methods must take as parameter an channel object and an id.
In case of DM channel, you can pass an user or member object.

For get an user by id, you can use client.get_user_info methods:

user = await client.get_user_info("123456789")

And after, with your userobject, you can get message with ID

message = await client.get_message(user, "135792468")


So, for fix your code, if wolf is a string id, you can use this following code:

for wolf in wolf_list_id:
    user = await self.client.get_user_info(wolf)
    poll_message = await self.client.get_message(user, react_message.id)


来源:https://stackoverflow.com/questions/53371935/discord-py-get-message-from-dm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!