Hello. I’d like to ask for help/advice. I’ve been trying to code a Discord bot to do a Timed mute, but there seems to be an error which I don’t know how to fix.
The error:
if (fn(val, key, this))
^
TypeError: fn is not a function
Here is my coding:
switch (args[0]) {
case ‘mute’:
let person = message.guild.roles.cache.find(message.mentions.users.first() || message.guild.roles.cache.find(args[1]))
if (!person) return message.reply("Person does not exist/Couldn't find member");
let mainrole = message.guild.roles.find(role => role.name === "Berries");
let muterole = message.guild.roles.find(role => role.name === "Muted D:");
if (!muterole) return message.reply("Unable to find muterole");
let time = args[2];
if (!time) {
return message.reply("Time not specified");
}
person.removeRole(mainrole.id);
person.addRole(muterole.id);
message.channel.send(`@${person.user.tag} has been muted for ${ms(ms(time))}`);
setTimeout(function () {
person.addRole(mainrole.id);
person.removeRole(muterole.id);
message.channel.send(`@${person.user.tag} has been unmuted!`)
}, ms(time));
break;
I’m a begginer actually, and I don’t know what’s wrong with my coding. I would very appreciate any kind of help or explanation!