Baileys icon indicating copy to clipboard operation
Baileys copied to clipboard

[BUG] TypeError: Cannot read properties of undefined (reading 'isEmpty')

Open RedTNT-Official opened this issue 1 year ago • 3 comments

Describe the bug After a while with the #14 issue, the error has now changed

To Reproduce Steps to reproduce the behavior:

  1. Created a new connection.
  2. Tried to send a message.

Expected behavior The message is sent and the bot doesn't crash.

Environment (please complete the following information):

  • Is this on a server? Yes
  • What do your connectOptions look like?
makeWASocket({
    ...this.opts?.baileysOpts,
    logger: P({ level: "silent" }),
    auth: state,
    browser: Browsers.appropriate("Desktop"),
    getMessage: async (key) => {
        const { id } = key;
        return tempStore[id!]?.message!;
    }
});
  • Do you have multiple clients on the same IP? Not
  • Are you using a proxy? Not

Additional context The error doesn't appear if I send the message on my own chat

RedTNT-Official avatar Apr 25 '23 19:04 RedTNT-Official

you are getting the message incorrectly you should look for the specific message you could use like this in the example

Example Baileys

async function getMessage(key: WAMessageKey): Promise<WAMessageContent | undefined> {
		if(store) {
			const msg = await store.loadMessage(key.remoteJid!, key.id!)
			return msg?.message || undefined
		}

		// only if store is present
		return proto.Message.fromObject({})
	}

andresayac avatar Apr 26 '23 00:04 andresayac

I'm using an object as store, thats why I'm getting it that way

RedTNT-Official avatar Apr 26 '23 00:04 RedTNT-Official

Could you provide more information about the error? I'm not really understanding it.

andresayac avatar Apr 26 '23 02:04 andresayac