Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

65
Vistas
I'm looking to mute someone in discord.js v13 and i have problem in creating VoiceState object

This is my first discord bot and I'm trying to mute someone. Based on my understanding I think I need to invoke the [.setMute()][1] function of the VoiceState and I'm trying to create a voiceState object where I dont understand what the data means.

Heres my execute function for the command. [ /mute <@USER> <SECONDS(optional)> ]

    async execute(interaction) {
    const targetUser = interaction.options.getUser('target');

    if (interaction.options.getNumber('seconds') !== null) {
        const seconds = interaction.options.getNumber('seconds');
    } else {
        const seconds = 60;
    }

    console.log(targetUser);
    
    const data = {} // APIVoiceState but idk what to put here
    const voiceState = new VoiceState(interaction.guild, data );
    console.log(voiceState);
    voiceState.selfMute(true);

    await interaction.reply('supposed to mute!');

Command Builder code if anyone needs it:

const data = new SlashCommandBuilder()
.setName('mute')
.setDescription('mute @user <seconds>  server mutes the specified user for specified number of seconds')
.addUserOption(option =>
    option.setName('target')
        .setDescription('user to mute')
        .setRequired(true))
.addNumberOption(option =>
    option.setName('seconds')
        .setDescription('Time in seconds the user stays muted (default: 60)'));
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

No need to create a new VoiceState object, once a GuildMember joins a voice channel the API automatically offers the object, we just need to edit the GuildMember's data using the GuildMemberEditData by passing the property mute() to it, so to utilize GuildMemberEditData#mute() method we can just go like:

  const targetUser = interaction.options.getMember('target');
  targetUser.edit({mute : true})

Please note that you can only use it on a GuildMember object and not on an User object which you are getting targetUser as, I strongly recommend to edit that.

Aliter

You can go ahead and get the GuildMember's voiceState and use setMute() on that via the GuildMember#voice method then further use the VoiceState#setMute() method on it, in that case our code would be something like this:

 const targetUser = interaction.options.getMember('target');
 targetUser.voice.setMute(true);
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda