问题
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