我正在执行禁令。我成功禁止该人,但问题是他写的消息没有被删除。那么有没有办法实现呢?像是在14天前删除特定成员的邮件吗?
const Discord = require('discord.js')
module.exports = {
name: 'ban',
description: 'Ban member from the server. Permissions applied.',
usage: '<Username | UserID> <reason>',
cooldown: 1,
guildOnly: true,
execute(client, message, args) {
let target = message.mentions.members.first() || message.guild.members.cache.get(args[0]);
if (!target) return message.channel.send('Please mention a user to be banned!')
let reason;
let arg = message.content.split(' ').slice(2);
if (arg.length == 0) {
reason = 'No reason specified.'
}
else {
reason = arg.join(' ')
}
if(!message.member.hasPermission('BAN_MEMBERS')) return message.channel.send('You dont have the permission to use this command!');
if(target.id === message.author.id) return message.channel.send('You cannot ban yourself!');
if(target.user.bot) return message.channel.send('Sorry we dont ban other bots. Please do so manually!')
if(target.permissions.has('MUTE_MEMBERS') && message.member != message.guild.owner) return message.channel.send('You have not BAN_MEMBERS permissions')
if(!message.guild.member(target).bannable) return message.channel.send("Sorry cant ban that user!");
const embed = new Discord.MessageEmbed()
.setTitle('You have been **banned!**')
.addField('Server Name: ', `**${message.guild.name}**`)
.addField('Banned by:', `**${message.author.username}**`)
.addField('Reason: ', `**${reason}**`)
.setColor('RANDOM')
.setThumbnail(`${message.guild.iconURL()}`)
.setTimestamp()
message.delete()
target.send(embed).then(() => {
message.channel.send(`${target.user.tag} has been banned!`)
}).then(() => {
message.guild.member(target).ban({days: 7})//message.channel.send(`${member.user.tag} has been kicked!`)
})
}
}
答案 0 :(得分:0)
GuildMember#ban()
中的一个选项是删除邮件的天数(0到7之间)
因此您可以使用:
message.guild.member(target).ban({ days: 4 })
.then(console.log)
.catch(console.error);
例如。