[英]how to send DM message to user with his ID Node js
我想用discord js bot发送DM消息并发送带有我想要的人ID的消息
client.sendmessage('person id','Hellow world');
You can get the user from the client.users.cache
collection.您可以从
client.users.cache
集合中获取用户。
client.users.cache.get('<User ID>').send('Hello World');
Note that you will not be able to use this method on any user that is not in the client's cache.请注意,您将无法对不在客户端缓存中的任何用户使用此方法。 This means you cannot use this function to DM a user who does not share at least one guild with the user unless you use
UserManager.fetch()
:这意味着除非您使用
UserManager.fetch()
否则您不能使用此功能向不与用户共享至少一个公会的用户发送消息:
client.users.fetch('<User ID>').then((user) => user.send('Hello World'));
UserManager.fetch()
will directly request the user's data from Discord's API. UserManager.fetch()
将直接从 Discord 的 API 请求用户的数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.