discord - 在 discord.js 中,我可以使用 Discord Bot 向用户发送直接消息吗?

标签 discord discord.js

我想使用 Discord Bot 向用户发送私有(private)消息。

用户与机器人不在同一台服务器上。

如果我可以使用 author.sendMessage,我该如何初始化(查找)作者变量?

我可以找到具有用户 ID 的用户吗?

感谢您的阅读。

最佳答案

对于任何对如何使用 Discord.js v12 执行此操作感兴趣的人,方法如下:

client.users.cache.get('<id>').send('<message>');
希望这对某人有帮助!

关于discord - 在 discord.js 中,我可以使用 Discord Bot 向用户发送直接消息吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49358108/

相关文章:

javascript - Node JS : How do I request multiple source codes from different websites?

python - 将上下文传递给后台任务discord.py

javascript - Discord.js SQLITE_ERROR : table scores has no column named points

javascript - Discord.js 从 URL 读取数据

node.js - Discord Bot 数据库 (JAVASCRIPT)

javascript - .joinedAt 属性总是在discord.js 中返回未定义

python - Reset_cooldown Discord.py

javascript - 如何计算 react Discord js

javascript - Discordjs 我的 react 收集器在我不希望它触发时触发

Node.js - 我不断收到以下错误 : Error: ffmpeg stream: write EPIPE