-1

这是我的清除命令,我希望我的清除忽略引脚,有人知道我该怎么做吗?

这是我现在得到的:

    } else if (message.content.toLowerCase().startsWith(`${PREFIX}purge`)) {
        if (!message.member.hasPermission('MANAGE_MESSAGES')) return message.channel.send("You don\'t have permissions to do this command")
        if (!message.guild.me.hasPermission('MANAGE_MESSAGES')) return message.channel.send("I don\'t have permissions to do this command")
        if (!args[1]) return message.channel.send("You need to specify a number of messages to purge")
        if (isNaN(args[1])) return message.channel.send("That isn\'t a valid amount of messages to purge")
        if (args[1] > 100 || args[1] < 2) return message.channel.send("Make sure that your amount is ranging 2 - 100")
        try {
            await message.channel.bulkDelete(fetch(message).filter(message => !message.pinned)).size
        } catch {
            return message.channel.send("You can only bulk delete messages within 14 days of age")
        }
        var embed = new Discord.MessageEmbed()
        .setAuthor(`${message.author.username} - (${message.author.id})`, message.author.displayAvatarURL())
        .setThumbnail(message.author.displayAvatarURL())
        .setColor('#FFAE00')
        .setDescription(`
**Deleted:** ${args[1]}
**Action:** Purge
**Channel:** ${message.channel}
**Time:** ${moment().format('llll')}
        `)
        const channel = message.guild.channels.cache.find(c => c.name === "audit-log")
        channel.send(embed)
    }
})

await message.channel.bulkDelete(fetch(message).filter(message => !message.pinned)).size

顺便说一句,最后一行不起作用,但我认为我需要修改

4

1 回答 1

3

用这个:

await message.channel.bulkDelete(
  (await message.channel.messages.fetch({limit: args[1]}))
    .filter(m => !m.pinned)
)

请注意,如果有固定消息,它将删除的消息少于args[1]

于 2020-07-17T00:33:45.783 回答