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

197
Vistas
Error TypeError: GroupChat.setMessagesAdminsOnly is not a function

When I try running my WhatsApp Bots using whatsapp-web.js module and making if Admins using a .setSMAO (Send Messages Admin Only) true, it will automatically set the Group Settings Send Messages to Admin Only

I search the methods on https://docs.wwebjs.dev/GroupChat.html and found GroupChat.setMessagesAdminsOnly();

I tried adding it and then test it but instead of working, I just met this error

GroupChat.setMessagesAdminsOnly();
          ^

TypeError: GroupChat.setMessagesAdminsOnly is not a function
    at Client.<anonymous> (D:\WhatsApp Bots keenan\bot.js:240:14)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

The code:

client.on('message', async msg => {
    const chat = await msg.getChat();
    const contact = await msg.getContact();

    if (msg.body == '.setSMAO true') {
        if (chat.isGroup) {
            let chat = await msg.getChat();
            GroupChat.setMessagesAdminsOnly();
            msg.reply('Successfully changed the Group Settings.');
            console.log('[CHANGED_SEND_MESSAGE_TO_ADMIN_ONLY] There was an Admin that changed the Group Settings Send Message to Admin Only');
        } else {
            msg.reply('This command only works on Group or the Bot didn't have an Admin Permissions!');
        }
    } 
});

What did I do? Did I just typing it wrong?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

GroupChat is an class/constructor for chats where Messages can appear, similar to Chat. And instances of them will be returned on a message with message.getChat().

You already did the right part with the check for chat.isGroup, so all you have to do afterwards is calling groupChatInstance.setMessagesAdminsOnly() which is possible on the same referrence by replacing GroupChat.setMessagesAdminsOnly() with chat.setMessagesAdminsOnly().

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