当前,代码使用时仅返回一个错误-使用不带任何参数的命令时,“未指定违反者”。所有其他一切都不起作用。如果僵尸程序在静音期间重启,该命令能否正常工作?
const Discord = require('discord.js');
const customisation = require('../customisation.json');
const ms = require("ms");
exports.run = async (client, message, args) => {
let tomute = message.mentions.users.first() || message.guild.members.get(args[0]);
if(!tomute) return message.reply("No violator specified.");
let user = message.mentions.users.first();
let muteRole = client.guilds.get(message.guild.id).roles.find('name', 'Muted');
if(message.author.id === message.mentions.users.first()) return message.reply("You can't mute yourself");
if (!message.member.hasPermission("MANAGE_ROLES_OR_PERMISSIONS")) return message.reply("❌**Error:** You don't have the **Manage Roles** permission!");
if (!muteRole) {
try {
muteRole = await message.guild.createRole({
name:"Muted",
color: "#000000",
permissions:[]
});
message.guild.channels.forEach(async (channel, id) => {
await channel.overwritePermissions(muteRole, {
SEND_MESSAGES: false,
MANAGE_MESSAGES: false,
ADD_REACTIONS: false
});
});
} catch(e) {
console.log(e.stack);
}
}
let reason = args[2];
if (reason.length < 1) reason = 'No reason Supplied';
if (message.mentions.users.size < 1) return message.reply('You must mention someone to mute them.').catch(console.error);
let mutetime = args[1];
if(!mutetime) return message.reply("You didnt specify a time for temporary mute.");
if (!message.guild.member(client.user).hasPermission('MANAGE_ROLES_OR_PERMISSIONS')) return message.reply(':x: I do not have the correct permissions.').catch(console.error);
let logchannel = message.guild.channels.find('name', 'logs');
message.guild.member(tomute).roles.add(muteRole);
setTimeout(function(){
message.guild.member(tomute).roles.remove(muteRole)
message.channel.send(`<@${tomute.id}> has been unmuted`)
}, ms(mutetime));
}