pikachub2005 / replapi-it

A node package that can do anything replit
https://replit.com/@PikachuB2005/replapi-it
9 stars 4 forks source link

Dumb-dumb needs help^^ #3

Open Acendro opened 1 year ago

Acendro commented 1 year ago

Hi there,

I was excited to test the api, but I can't get it to work properly. So console.log(me) gives me a bunch of information on my account so I assume my SID is entered correctly As a next step I wanted to log out all the repls I have but the command me.repls returns ReplManager { cache: Collection(0) [Map] {} } So this is where I'm stuck. I can't loop over the ReplManager object and me.repls[0] = undefined Is there any way to directly connect to a specific Repl I own? like me.repls['REPL_NAME'] or something. Or is the ReplManager not showing anything because my Repls are private? I'm kinda just starting out with hosting some private project at replit and would really appreciate you help.

Thanks in advance =)

const Client = require('replapi-it');
const client = new Client('MY_SUPER_SECRET_SID');

client.on('ready', async () => {
  let me = await client.user
  console.log(me);
  console.log(me.repls);
})

I also tried

let my_repls = await me.repls;
console.log(my_repls);

with no success =(

pikachub2005 commented 1 year ago

Hey @Acendro! You need to use the manager's fetch method.

const Client = require('replapi-it');
const client = new Client('MY_SUPER_SECRET_SID');

client.on('ready', async () => {
  let me = client.user;
  let repls = await me.repls.fetch(); // Returns a Collection, which is just a Map with extra methods
  console.log(repls);
})

If you want to get a specific repl by it's url, you should be able to use

let repl = await client.repls.fetch('/@username/repl-slug', {url: true});
Acendro commented 1 year ago

Hey @pikachub2005,

everything works as intended. Awesome stuff, thanks a lot =)

Acendro commented 1 year ago

Can I start another file than main.py?

[...]
let cons = repl.console;
console.log("STARTING");
await cons.run();
await cons.send("python test.py");

Is what I tried after reading crosis.js but it doesn't work =( await cons.run(); starts main.py but await cons.send("python test.py");doesn't seem to do anything Is it even possible? Do I maybe need to alter my .replit file for it to work?

gooddavvy commented 1 year ago

@Acendro That's not possible in my opinion.