samuri51 / chillybot

a turntable bot created by a moderator of straight_chillin11
12 stars 12 forks source link

Cannot read properties of undefined (reading 'description') #62

Closed blueyshark closed 4 months ago

blueyshark commented 4 months ago
(node:1632) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
unable to join the room the room due to: TypeError: Cannot read properties of undefined (reading 'description')

Hello there. Trying to run chillybot in a 'deepcuts' room - it throws those errors at me. The odd thing is, I could get it to work a couple of times but now it just send up an error. I'm running the bot on a debian server.

Any ideas? Thanks.

samuri51 commented 4 months ago

how old is your nodejs ? i just tried to run the bot and it's not giving me this error

samuri51 commented 4 months ago

this is being thrown by line 4669, detail = data.room.description; //used to get room description

not sure why that would be null unless they changed how the data on the site works

you can try changing it to this:

detail = data.room?.description; //used to get room description

that should at least get rid of that error

blueyshark commented 4 months ago

That seems to have worked. The bot in question is 'philharmony' in the Hosono Lounge. It used to be run by the golang bot, but the dev seems to have run out of time to work on it any longer, so I'm giving Chilly a try, thanks. nodejs is up-to-date, fresh install.

Edit: Interesting - I booted the bot in order to restart it to reload some configuration changes; it now throws up a similar error:

(node:2554) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
unable to join the room the room due to: TypeError: Cannot read properties of undefined (reading 'name')
samuri51 commented 4 months ago

its reading in null data for some reason. ill have to take a look later to see if the site metadata changed. for now u can keep adding those question marks to the things it says, that will make it stop evaluating a null expression at that point.

ie it cant read the name property of description because description doesnt exist for some reason.

these errors are in the room changed event

blueyshark commented 4 months ago

OK I'll give it a try. Thanks for such a swift response, was not expecting it and that's very generous of you.

Edit: I changed these three lines:

        //set information 
        detail = data.room?.description; //used to get room description
        roomName = data.room?.name; //gets your rooms name
        ttRoomName = data.room?.shortcut; //gets room shortcut

But I've now come across an error regarding 'metadata' and there's quite a few lines in the script with that so I'm not sure which is causing the error:

(node:2960) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
unable to join the room the room due to: TypeError: Cannot read properties of undefined (reading 'metadata')

Thanks again and good luck with a fix.

samuri51 commented 4 months ago

i went in my room and ran /roominfo, that shouldve failed if the site metadata didnt load in when the bot started up so it deffo at least works sometimes.

that tells me either the site isnt giving u the data or somethings fked up on your end. gonna need to do more testing tho

blueyshark commented 4 months ago

Right; it did work for me too, briefly. It stopped working again once I booted the bot and tried to run the script again.

samuri51 commented 4 months ago

weird, it shouldn't be working intermittently unless smethings messed up on the site end.

i see the api hasnt changed in like 3 years so that either works or not

if u have a pc running windows u can try to run it from there to eliminate something in your linux environment

shouldnt be an issue tho...

im running mine from gcp and its been fine. albeit i only go to the site nowadays like once every couple months

samuri51 commented 4 months ago

Untitled

metadata is lookin good here. i got someone to try on and their bot too and they don't have a problem. i'm guessing there's something wrong with the way your environment is set up

blueyshark commented 4 months ago

Interesting thanks. I'm using dietpi, a pared down version of debian for sbcs (although my server is an old thin client). When I was using a golang bot, I was able to install the GO runtime using dietpi's installer script, and only do a little customising to get it all working. Hopefully I can manage the same thing here! Would you have a vague idea where I could start, when checking and setting environment for the js? Appreciate your speedy replies 🙌

samuri51 commented 4 months ago

i guess i would start with making sure the js version of the ttapj is being used and not the golang one.

not totally sure tbh, the things always kinda just worked! lol

worst comes to worst im hosting the thing as a free project on gcp. currently paying like 99 cents a month for it and no issues

samuri51 commented 4 months ago

another idea... run it from a docker container, thats how it runs in the cloud.

also make sure the pi can contact the website

ive had ppl running the thing from a pi before and its worked fine so im not sure why it wouldnt work

blueyshark commented 4 months ago

Yes, I was considering docker just so all the dependencies etc are in the same place. Might try that later.

blueyshark commented 4 months ago

So I have chillybot running in a docker, great, thanks for the pointer. But it seems to be ignoring var getonstage = true; I have var whenToGetOnStage = 2;

edit: chillybot did get on stage once I went on - how would I get it to jump on stage when I'm not online?

edit2: is there a quick way to reload chillybot's js configs (without haveing to stop the docker, restart etc?

edit3: WELP. Seems like even with the docker container, I get the same issue after I've booted chillybot and try to restart via docker.

root@MMServer03:/mnt/dietpi_userdata/ttfmbot_dockerfile# docker run -p 3000:3000 my-node-app
unable to join the room the room due to: TypeError: Cannot read property 'description' of undefined
samuri51 commented 4 months ago

whentogetoffstage has to be at least two higher than on because the bot counts as one person.

it also doesnt kick in unless autodjing is enabled

/autodj puts the bot on manually and i believe if autondj is on the bot jumps on once stage users drop to zero

interesting about the error. docker is like a shell, the container it runs in still has to allow it to do its thing.

if u got another pc i would try running it from there to eliminate some network issue

if its debian i cant help much, not an expert on that

gcp has a free project tier tho and thats what i use as an option

blueyshark commented 4 months ago

I think it must be something to do with booting the bot. This morning, I attempted to start chillybot, and hey presto, it works as normal. I won't boot the bot, as it seems that this causes the issue. If stop the docker process, and restart, then chillybot behaves too. So maybe there's a post-booted cooldown I wasn't aware of.

Edit: so all's well with chillybot so far - but it seems to be ignoring some of the variables entered, including var SONGSTATS = false; var autoBop = true;

samuri51 commented 4 months ago

ignoring them? if you type /botstatus does it say theyre enabled?

samuri51 commented 4 months ago

everythings working good on my bot, haven't heard that one before

blueyshark commented 4 months ago

I think we can close this issue.

Thanks again @samuri51 for all your assistance!

samuri51 commented 4 months ago

i didnt know you were booting the bot, dont do that. theyve changed it so thats a ban that gets longer and longer. think the first boot is like a 1 hr ban now. that explains why the bot cant read the data, as it is just a normal user account