bard-ai icon indicating copy to clipboard operation
bard-ai copied to clipboard

🐛 [BUG]: Working with Windows, Crashing on Linux

Open XCraftTM opened this issue 2 years ago • 13 comments

Prerequisites

  • [X] I have searched the issues and believe that it has not already been reported
  • [X] It occurs on the latest version of bard-ai
  • [X] I have read the FAQ and there are no solutions there

Bug Description

So i coded a Discord Bot in Discord.JS in CJS and imported it correctly and everything works when using it in Windows, but when i upload it to a Linux Server(Running Ubuntu 20) it crashes when using Bard.Chat().ask() trying to ask something...

Reproduction Steps

Using:

const Bard = await import("bard-ai").catch(e => {
   throw "Missing Module: The Package 'bard-ai' was not found, please install it manually using 'npm i bard-ai'"
});
await Bard.init(config.aicookie);
let conv = new Bard.Chat();
await conv.ask("A MSG");

After i start the Bot it Gives this Error:

node:events:492
      throw er; // Unhandled 'error' event
      ^

Error: Google Bard encountered an error )]}'

38
[["wrb.fr",null,null,null,null,[9]]]
55
[["di",81],["af.httprm",80,"-1146363392943947525",2]]
25
[["e",4,null,null,130]]
.
    at queryBard (file:///Bot/node_modules/bard-ai/index.js:88:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Chat.ask (file:///Bot/node_modules/bard-ai/index.js:147:23)
    at async Object.execute (/Bot/events/ready.js:87:9) // This Being the Lines i sent Above: await conv.ask()
Emitted 'error' event on Client instance at:
    at emitUnhandledRejectionOrErr (node:events:395:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:84:21)

Node.js v18.17.0

Other information

No response

Occurance Rate

I can reproduce this bug 100% of the time.

XCraftTM avatar Jul 24 '23 19:07 XCraftTM

It appears that Bard is not responding correctly. Are you sure that config.aicookie is defined in your new environment?

EvanZhouDev avatar Jul 25 '23 00:07 EvanZhouDev

Yeah it is... i checked it multiple times and it does work on windows but not on the ubuntu server. The config is a JSON file that i imported using require...

XCraftTM avatar Jul 25 '23 03:07 XCraftTM

I have already pretty much created a CRE... But everything i have tried doesn't work... it throws the same error as of the start of this issue. I tried reimporting the Module, Making a new Project, trying a new File, Trying a ES6 Project, importing it using the import() function... Even just putting the Cookie Secret as a string into the function... Do you guys have any idea how i might be able to fix this?

XCraftTM avatar Jul 26 '23 13:07 XCraftTM

Weirdly enough i have now tried running this Project in a Ubuntu 20 VM on my PC and it works there.. So i think there might be something wrong with my Server i am running it on....

XCraftTM avatar Jul 26 '23 13:07 XCraftTM

Hello, This error happens to me when I try to use the chat function without passing the ids form the export function first. Other than that it works.

MarwanRadwan7 avatar Aug 01 '23 21:08 MarwanRadwan7

Any updates? Closing otherwise.

EvanZhouDev avatar Aug 02 '23 20:08 EvanZhouDev

I still haven't found a solution for the issue but i do want to use it without a id...

XCraftTM avatar Aug 02 '23 20:08 XCraftTM

Try with bard-ai v2. Just released.

EvanZhouDev avatar Aug 02 '23 20:08 EvanZhouDev

There are quite a few breaking changes though 😅

Overall, the experience should be more streamlined and modern.

EvanZhouDev avatar Aug 02 '23 20:08 EvanZhouDev

It did? Okay i will test that... i will report tomorrow if it works or not...

XCraftTM avatar Aug 02 '23 20:08 XCraftTM

file:///Bot/node_modules/bard-ai/index.js:242
        const answer = chatData[4][0];
                               ^

TypeError: Cannot read properties of null (reading '4')
    at #query (file:///Bot/node_modules/bard-ai/index.js:242:32)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Chat.ask (file:///Bot/node_modules/bard-ai/index.js:344:32)
    at async /Bot/test.js:7:17

Node.js v18.17.0

Getting this error now... but works on my PC again... No idea why it happens...

Using:

import("bard-ai").then(async ({ default: Bard }) => {
    let bard = new Bard({
        "__Secure-1PSID": "COOKIE SECRET",    
        "__Secure-1PSIDTS": "COOKIE SECRET",
        });
    let conv = bard.createChat();
    console.log(await conv.ask("test"));
});

XCraftTM avatar Aug 03 '23 05:08 XCraftTM

Can you give a minimal recreation of your problem?

Like complete code to recreate the problem you are having.

EvanZhouDev avatar Aug 03 '23 17:08 EvanZhouDev

The Code i sent is everything i tested it with...

XCraftTM avatar Aug 03 '23 18:08 XCraftTM