I tried everything at it would give me errors such as TypeError: Cannot read property 'setDeaf' of undefined Please and thank you.
const Discord = require('discord.js');
const config = require('../config.json')
module.exports.run = async (bot, message, args, config) => {
if(message.author.id !== "247227873734295562") return message.channel.send("no perms")
const mUser = message.mentions.members.first() || message.guild.members.get(args[0]);
let isDeafened = false;
if(!mUser) {
message.channel.send("You need to mention a user!")
}
if(mUser) {
mUser.voice.setDeaf(true)
}
}
module.exports.help = {
name: "d",
description: "Server deafens a mentioned user forever",
usage: `${config.prefix}d <@mention>`,
ex: `${config.prefix}d <@247227873734295562>`
}
Looking at your code and you getting that error seems to show, that mUser
doesn't have the property voice
. Which Discord.js version do you use?
mUser.voice.setDeaf(true)
was added in v12 . So, if you have an earlier version, you should use mUser.setDeaf(true)
instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.