[英]How to DM user using discord.js
I'm making a bot on Discord.js.我正在 Discord.js 上制作一个机器人。 The bot will give a role to every user.该机器人将为每个用户分配一个角色。 The problem is I want the bot DM the role to each user.问题是我希望机器人 DM 将角色分配给每个用户。 The code was just not working for me.该代码对我不起作用。
What I've tried:我试过的:
client.users.get('id').send('Blabla')
, but it didn't work. client.users.get('id').send('Blabla')
,但它没有用。
message.author.send("Blabla.")
would only send the message to the author. message.author.send("Blabla.")
只会将消息发送给作者。
message.channel.send("Blabla")
would only send the message to a channel. message.channel.send("Blabla")
只会将消息发送到频道。
client.users.get('id').send('Blabla')
did not work because in discord.js v12 you have to use the new cache system, in your case it's UserManager#cache
. client.users.get('id').send('Blabla')
不起作用,因为在 discord.js v12 中,您必须使用新的缓存系统,在您的情况下是UserManager#cache
。
So your solution is: client.users.cache.get('id').send('Blabla')
所以你的解决方案是: client.users.cache.get('id').send('Blabla')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.