我想知道Discord bot是否有可能检查机器人尝试DM的特定用户是否接受直接消息。现在这是我的代码:
exports.run = (client, message) => {
try {
message.author.send(`:ok_hand:`);
} catch (err) {
message.reply('Cannot send Direct Messages to your user!');
}
}
但我希望代码能够在尝试向用户发送消息之前判断用户是否正在接受直接消息。这可行吗?
答案 0 :(得分:2)
不可能。找出是否可以发送DM的唯一方法是尝试发送消息 而不是使用try catch,你可以使用promises中的catch来捕获错误并做一些事情。
message.author.send('')
.catch(() => message.reply("Can't send DM to your user!"));