这是我的代码!错误 - message.guild.members.get 不是函数。
我正在使用 Visual Studio Code,但很快我将把这个单独的命令文件上传到 repl.it
module.exports = {
name: 'mute',
description: 'Mutes the Member',
execute(message, args, Discord) {
let tomute = message.guild.member(message.mentions.users.first() ||
message.guild.members.get(args[0]));
if (!tomute) return
message.reply('Error! Could not able to Find the Member!');
if (tomute.hasPermission("MANAGE_MESSAGES")) return
message.reply("Error! You Can't Mute Them"); let muterole =
message.guild.roles.find(muterole => muterole.name === "Muted");
//start of create role
if (!muterole) {
try {
muterole = message.guild.createRole({
name: "Muted",
color: "#000000",
permissions: []
})
message.guild.channels.forEach(async (channel, id) => {
await channel.overwritePermissions(muterole, {
SEND_MESSAGES: false,
ADD_REACTIONS: false
});
});
} catch (e) {
console.log(e.stack);
}
} if (!args[1]) {
memberTarget.roles.add(muteRole.id);
const newEmbed = new Discord.MessageEmbed()
.setColor('ff0000')
.setTitle('Muted!')
.setDescription(`${member} has been Muted!`)
.message.channel.send('newEmbed');
return
}
memberTarget.roles.add(muteRole);
const newEmbed = new Discord.MessageEmbed()
.setColor('ff0000')
.setTitle('Muted!')
.setDescription(`${member} has been Muted!`)
.message.channel.send('newEmbed');
setTimeout(function () {
memberTarget.roles.remove(muteRole);
}, ms(args[1]));
}
}
答案 0 :(得分:0)
您的代码已过时 (v11),您应该将代码更新到 v12
更新:
.get() => .cache.get();
.find() => .cache.find();
.createRole() => .roles.create();
.channels.forEach() => .channels.cache.forEach();
discord.js 将 v11 更新到 v12 的官方指南,here