Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!