Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

187
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda