我已经浏览了关于Stack Overflow的所有相关主题,并尝试了所有内容,但是代码无法正常工作: 因此,我正在关注有关如何使用Discord上的机器人使成员静音的YouTube教程,这是错误消息:
case "mute":
let person = m.mentions.members.first() || m.guild.members.fetch(args[1]); //m.guild.member(
//console.log(person);
if (!person) return m.reply("I don't know who this is, bro.");
let mainrole = m.guild.roles.cache.find((role) => role.name === "Main");
let muterole = m.guild.roles.cache.find((role) => role.name === "Mute");
if (!muterole) return m.reply("Sorry they simply don't exsit.");
let time = args[2];
console.log(time);
if (!time) return m.reply("That's not a time. How did you even do it?");
person.removeRole(mainrole.id);
person.addRole(muterole.id);
// person.remove("Main");
// person.add("Mute");
m.channel.send(
`@${person.user.tag} has now been mute for ${ms(ms(time))}`
);
setTimeout(() => {
person.addRole(mainRole.id);
person.removeRole(muterole.id); //switching the order and see how that looks like
m.channel.send(`@${person.user.tag} has been unmuted, good job!`);
}, ms(time));
这是我的代码,如果需要,可以将其他部分删除。
const date = moment('200421', 'yymmdd').format('MM-DD-YYYY');
console.log(date);
让我想知道ms模块或discord.js的导入是否有问题? 请发送帮助! 谢谢!