简体   繁体   English

如何使用他的 ID Node js 向用户发送 DM 消息

[英]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.

相关问题 如何通过搜索他的 ID 来获取整个用户 - NODE.JS - How to get an entire User by searching for his ID - NODE.JS 如何向对消息做出反应的用户发送 dm [DISCORD.JS] - How do I get send a dm to the user who reacted to a message [DISCORD.JS] 使用Node.js和Passport进行身份验证后,如何将用户重定向至带有其ID的主页? - How to redirect user to home page with his ID after authentication using Node.js and Passport? 有没有办法获取在他的消息上创建线程的用户 ID? discord.js - Is there a way to get the user ID whose Thread was created on his message? discord.js 如何使机器人发送直接消息给某人机器人没有它在mutal服务器并拥有他的id - How to make bot send Direct Message To Someone that the bot don't have it in mutal servers and have his id 发送 DM,然后在新用户加入后对消息做出反应 - Send a DM and then reacts to the message once a new user joins 如何将元素ID发送到Node JS文件 - How to send element id to node js file 我如何检查用户是否对机器人的消息做出反应,然后在他没有或他做了时发送消息(全部在 DM 中) - How can I check if a user reacted to the bot's message and then send a message if he didn't or if he did ( all in DM's ) 如何从 dm 获得用户回复? (不和谐节点 js 机器人) - How can you get user responses from a dm? (Discord Node js bot) 如何使用 discord.js 机器人 dm 用户 - How to dm a user with a discord.js bot
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM