Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在创建一个机器人,我希望它向指定用户发送私人消息。
例如:
!message @user Welcome to the server!
这将发送“欢迎来到服务器!” 给@用户。
Discord.js 有一个名为 message#mentions 的属性,你可以这样做
var user = message.mentions.users.first();
undefined如果没有提到用户,或者UserResovleable你可以在哪里 返回,这将返回
undefined
UserResovleable
user.send("Welcome to the server!"); // or for example console.log(user.id);