所以今天我试图通过ping机器人DM来使其成为特定的人,例如:!dm@土豆你好
使用此:
if (message.content.startsWith(prefix + 'dm')) {
let args = message.content.split(" ")[2];
let user = message.mentions.users.first()
if (!user) return message.channel.send("**Please mention a user**")
if (!message.member.roles.cache.has('814454313438806016')) {
return message.channel.send('You do not have the permissions to use this command.')
}
if (!args[0])
return message.reply("Nothing to say?").then(m => m.delete(5000));
if (args[0].toLowerCase() === "embed") {
const embed = new MessageEmbed()
.setDescription(args.slice(1).join(" "))
.setTimestamp()
.setColor('WHITE');
message.channel.send(embed);
} else {
message.channel.send('**Done**')
user.send(args.join(" "));
}
}
SMH,它不起作用,我希望你们能帮助我
控制台链接屏幕截图:https://prnt.sc/10kzxie
Tbh,您的代码中没有太多错误,只是有一点点问题。使用以下内容,如果仍然存在问题,请发表评论!
if (message.content.startsWith(prefix + 'dm')) {
let args = message.content.slice(prefix.length).split(/ +/g);
let member = message.mentions.members.first()
if (!member) return message.channel.send("**Please mention a member**")
if (!message.member.roles.cache.has('814454313438806016')) {
return message.channel.send('You do not have the permissions to use this command.')
}
if (!args[0]){
return message.reply("Nothing to say?").then(m => m.delete(5000));
}
if (args[0].toLowerCase() === "embed") {
const embed = new MessageEmbed()
.setDescription(args.slice(2).join(" "))
.setTimestamp()
.setColor('WHITE');
message.channel.send('**Done**')
member.send(embed);
} else {
message.channel.send('**Done**')
member.send(args.splice(1).join(" "));
}
}