How can I access a .txt file in glitch

So im using npm path, the .join function to find a .txt under a folder, how can I access this txt file via the join function?

Hey @Not-A-Wirus-exe can you show us the code you’re currently using and any errors you’re encountering, or provide your project name?

You have named the socks.txt file => socks.text, when it should be socks.txt, try changing that, and it should work!

wow, I feel so stupid, but im getting an API error which states error fetching poll data, im trying in on this test poll, with only IP duplication checking

my project name is strawpoll-bot

@Not-A-Wirus-exe I’m not finding that project anymore – have you renamed it or deleted it?

sorry, it was private, it’s open now

Rad, I’ll take a look!

Oof, I think it might be a problem with the package itself. I fiddled with it a bit (including moving the socks.txt file to the root of the directory, directly adjacent to the server files, so that we could access it using the __dirname variable, just like in the example) and I’m getting the same error that you are.

I googled the error and found that someone posted the same error (under the same circumstances, it seems) as an issue on the package in 2018 and it hasn’t been responded to.

A couple of things that might help …

Function

The usage doc for the botPoll function shows an example:

botPoll('http://www.strawpoll.me/15100511', 1, true, join(__dirname, 'socks.txt'));
  • If you leave __dirname in there, it should resolve to /app which is your project folder, then join will make it /app/socks.txt.

  • You have put the socks.txt file into a folder called socks, so the join should look like join(__dirname, 'socks/socks.txt')

  • Or you can hardcode it, without the join() function, to '/app/socks/socks.txt'

Your fixed function call:

botPoll('https://www.strawpoll.me/18404789', 2, true, join(__dirname, 'socks/socks.txt'))

Looping

The botPoll already does a GET request to the strawpoll for every entry in socks.txt.

If you put this in a loop, your bot is repeating those requests with the same IPs, which makes it badly behaved.

This will likely trigger strawpoll’s rate limits or bans on glitch servers.

1 Like

@mishavee I ran this code and was still getting the error that @Not-A-Wirus-exe mentioned (but maybe I missed something) – did it work for you?

I decided I didn’t want to run this code, considering what it is trying to do :stuck_out_tongue:

Fair point – perhaps I should have delved a little deeper into my understanding of it :joy:

Lol, I feel ya, it’s an old thing anyways lol

Yeah, the API is probably old