我想获取来自特定用户的最后一条消息。
用户应该能够说出命令和要获取最后一条消息的用户的id,然后机器人应该发送回message.content
或message.embed
。
发布于 2019-05-08 17:45:42
您可以使用User
的lastMessage
属性,并使用它,如下所示...
/*
* within an async function,
* inside command code,
* assuming 'args' is an array of arguments
*/
try {
const user = await client.fetchUser(args[1]);
if (!user) return message.channel.send('Oh no, invalid user ID.');
const lastMessage = user.lastMessage;
if (!lastMessage) return message.channel.send('No messages from this user found.');
message.channel.send({lastMessage.content, lastMessage.embed, lastMessage.attachments});
} catch(err) {
console.error(err);
}
https://stackoverflow.com/questions/56045912
复制相似问题