您是如何做到的,所以您不必为描述discord机器人提到用户

时间:2019-12-07 07:36:11

标签: node.js discord

const { RichEmbed } = require("discord.js");
const { stripIndents } = require("common-tags");

module.exports = {
    name: "report",
    category: "moderation",
    description: "Reports a member",
    usage: "<mention, id>",
    run: async (client, message, args) => {

        if (message.deletable) message.delete();

        let rMember = message.mentions.members.first() || message.guild.members.get(args[0]);

        if (!rMember)
            return message.reply("Couldn't find that person?").then(m => m.delete(5000));

        if (rMember.hasPermission("BAN_MEMBERS") || rMember.user.bot)
            return message.channel.send("Can't report that member").then(m => m.delete(5000));


        if (!args[1])
            return message.channel.send("Please provide a reason for the Arrest").then(m => m.delete(5000));

        const channel = message.guild.channels.find(c => c.name === "arrest-log")

        if (!channel)
            return message.channel.send("Couldn't find a `#arrest-log` channel").then(m => m.delete(5000));

        const embed = new RichEmbed()
            .setColor("#ff0000")
            .setTimestamp()
            .setFooter(message.guild.name, message.guild.iconURL)
            .setAuthor("Arrest Log", rMember.user.displayAvatarURL )
            .setDescription(stripIndents`**> User:** ${rMember} 
            **> Arrested by:** ${message.member}
            **> Reason:** ${args.slice(1).join("")}`);

        return channel.send(embed);
    }
}

1 个答案:

答案 0 :(得分:0)

只需添加更多选项。添加一个选项以按名称查找,然后按名称过滤成员列表。也可以添加按ID查找选项,然后按ID过滤成员列表。