Can't get lastMessage from other users #5428
-
I'm trying to retrieve the latest message of a particular user by mentioning them, but it only works if I mention myself or if they mention themself. According to the console, the user's lastMessageId is null even though they sent a message recently. Is there some permission in discord I'm missing? Is this a bug? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
I believe |
Beta Was this translation helpful? Give feedback.
-
You cannot fetch messages from specific users (and search is not available for bot accounts). You also cannot fetch messages from multiple channels at once, so to get actually most recent message from a user, you would have to fetch unspecified amount of messages from unspecified amount of channels, in worst case ending up with fetching all messages in a server and getting no results. There isn't really a reliable way to get last message a user has sent. |
Beta Was this translation helpful? Give feedback.
lastMessageID
is dependant on cache. Cache is empty when you start the bot, and API does not send you every message from every channel when you log your bot in. Library caches messages that were received since the bot started up, but to get anything beyond that, you have to fetch messages.You cannot fetch messages from specific users (and search is not available for bot accounts). You also cannot fetch messages from multiple channels at once, so to get actually most recent message from a user, you would have to fetch unspecified amount of messages from unspecified amount of channels, in worst case ending up with fetching all messages in a server and getting no results.
There isn't really…