简体   繁体   中英

How to mute a mentioned member? (discord.js)

I've tried to servermute a mentioned member, but it won't work.

const person = member.guild.member(message.mentions.users.first())
person.voice.setMute(true);

When I do "!mute" without a player mentioned it reacts (tested it with a reply message), but when I mention someone the bot just does nothing. I also have a command to mute all members in a voicechannel and it works fine.

for (const [memberID, member] of message.member.voice.channel.members) {
                member.voice.setMute(true);
            }

The issue here is the method you're using for getting the guild member is doesn't work. When using <message>.mentions.members.first() , you're already given a guild member. Along with this, you're checking for .users , which doesn't work

const person = message.mentions.members.first() // Note the .members
person.voice.setMute(true);

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM