Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
475 views
in Technique[技术] by (71.8m points)

javascript - 如何通过Discord.js将DM发送给特定的角色持有者(How to send DM to a specific role holders via Discord.js)

Hello i want to send DM to user with specific role,

(您好,我想将DM发送给具有特定角色的用户,)

i tried this code did not worked.

(我试过这段代码没有用。)

:

(:)

const args = message.content.split(" ");
const roleArgs = args.slice(0, 1);
const messageArgs = args.slice(1)

const role = message.guild.roles.find(role => role.name.toLowerCase() === roleArgs.join(" ").toLowerCase())
if (!role) return message.reply('There is not such a role!');

for (let i = 0; i < message.guild.members.size; i++) {
    if (message.guild.members[i].roles.has(role.id)) {
        message.guild.members[i].user.send(messageArgs.join(" "))
    }
}

!dm @role (message)

(!dm @role(消息))

  ask by unhitchedsum translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...