admin管理员组

文章数量:1291188

I would have liked to add to my bot discord a feature to mutate everyone in a vocal lounge when I launch an order but I do not find how. My bot was programmed using Node.js with discord.js. Can someone help me? Thank you :)

My code :

const Discord = require("discord.js");

module.exports.run = async (client, message, args) => {
  if(!message.member.hasPermission("MANAGE_MESSAGES")) return message.channel.send("Vous n'\avez pas les permissions pour utiliser cette mande !");
  let voiceChannel =  message.guild.channels
  .filter(function (channel) { return channel.id === '540093524570406912' })
  .first()
  voiceChannel
  .join()
  .then(function (connection) {
      connection.members.setMute(true);
     })
}

module.exports.help = {
  name:"start"
}

I would have liked to add to my bot discord a feature to mutate everyone in a vocal lounge when I launch an order but I do not find how. My bot was programmed using Node.js with discord.js. Can someone help me? Thank you :)

My code :

const Discord = require("discord.js");

module.exports.run = async (client, message, args) => {
  if(!message.member.hasPermission("MANAGE_MESSAGES")) return message.channel.send("Vous n'\avez pas les permissions pour utiliser cette mande !");
  let voiceChannel =  message.guild.channels
  .filter(function (channel) { return channel.id === '540093524570406912' })
  .first()
  voiceChannel
  .join()
  .then(function (connection) {
      connection.members.setMute(true);
     })
}

module.exports.help = {
  name:"start"
}

Regards,

Quentin S

Share Improve this question asked Mar 9, 2019 at 19:52 QuentinQuentin 3052 gold badges3 silver badges13 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

setMute

client.on('message', (message) => {
    if (message.content == '/muteAll') {
        let channel = message.member.voiceChannel;
        for (let member of channel.members) {
            member[1].setMute(true)
        }
     }
});

setMute is a method on GuildMember.voice (VoiceState) now. Documentation

client.on('message', (message) => {
    const channel = message.channel
    const members = channel.members
    if (message.content.startsWith("/muteall")) {
        members.forEach(member => {
            member.voice.setMute(true)
            member.voice.setDeaf(true)
        });
        message.channel.send('Server muted');
    } else if (message.content.startsWith("/unmuteall")) {
        members.forEach(member => {
            member.voice.setMute(false)
            member.voice.setDeaf(false)
        });
        message.channel.send('Server unmuted');
    }
});

I've created this bot for this https://github./Roshanjossey/discord-mute-voice-channel-bot

本文标签: javascriptMute everyone in a voice channel with a Discord Bot with DiscordjsStack Overflow