我希望我的机器人对服务器中的所有成员进行DM管理,但是我不知道如何执行此操作。如果可以的话,我将不胜感激!
Discord.js v12
答案 0 :(得分:1)
message.guild.members.cache.forEach(member => { // Looping through each member of the guild.
// Trying to send a message to the member.
// This method might fail because of the member's privacy settings, so we're using .catch
member.send("Hello, this is my message!").catch(e => console.error(`Couldn't DM member ${member.user.tag}`));
});