Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deleteMessage in group chat #1452

Closed
loic-hamdi opened this issue Oct 30, 2023 · 5 comments
Closed

deleteMessage in group chat #1452

loic-hamdi opened this issue Oct 30, 2023 · 5 comments
Labels
bug Something isn't working needs triage

Comments

@loic-hamdi
Copy link

Hi, For some reasons I can't delete messages in group chat anymore.
Is it still working on your side?

Where do you get the data from for:chatId and id ?

https://github.com/wppconnect-team/wa-js/blob/main/src/chat/functions/deleteMessage.ts#L47

https://wppconnect.io/wa-js/functions/chat.deleteMessage.html

@loic-hamdi loic-hamdi added bug Something isn't working needs triage labels Oct 30, 2023
@loic-hamdi
Copy link
Author

loic-hamdi commented Nov 1, 2023

@icleitoncosta
@edgardmessias
Hi guys, sorry for the direct tag, I please need your help on this one as it is breaking in my current app.

Could you please test if deleting messages (normal chat & groups) still works on your side?

Thank you in advance.

@edgardmessias
Copy link
Contributor

@loic-hamdi , could you post the example of code that you are using?

@loic-hamdi
Copy link
Author

@loic-hamdi , could you post the example of code that you are using?

I use this package https://pub.dev/packages/whatsapp_bot_flutter that is basically a communication bridge between Dart and wa-js.

The dart code in the package is as follow:

  /// Delete message
  /// Set revoke: true if you want to delete for everyone in group chat
  Future deleteMessage({
    required String phone,
    required String messageId,
    bool deleteMediaInDevice = false,
    bool revoke = false,
  }) async {
    return await wpClient.evaluateJs(
      '''WPP.chat.deleteMessage(${phone.phoneParse},${messageId.jsParse}, $deleteMediaInDevice, $revoke);''',
      methodName: "deleteMessage",
    );
  }

The JS equivalent as you can see is:
WPP.chat.deleteMessage(${phone.phoneParse},${messageId.jsParse}, $deleteMediaInDevice, $revoke);

If I try to delete a message in a group:

Future<dynamic> deleteMessageInGroup(WhatsappClient client, Message message) async {
  final messageId = message.id!.serialized;
  final phone = message.id!.serialized.split('_').last;
  final r = await executeWAFunction(() => client.chat.deleteMessage(phone: phone, messageId: messageId, deleteMediaInDevice: true, revoke: true));
  return r;
}

The future (promise in JS) returns this error message:
{id: false_120363178483272749@g.us_3A7A39E4C00345DE91E3F_15216763775@c.us, sendMsgResult: ERROR_UNKNOWN, isDeleted: false}

@loic-hamdi
Copy link
Author

@edgardmessias Did you have a chance to look at it?
Thanks in advance

@icleitoncosta
Copy link
Contributor

Hello, the functions are working fine within WAJS.

I don't have knowledge of Flutter or Dart, as I've never used these languages. However, wouldn't the error be related to phoneParse and jsParse, perhaps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

3 participants