KOOKIIEStudios / PalCON-Discord

A Python-based Discord bot for PalWorld server administration via RCON
MIT License
18 stars 3 forks source link

Integer Error? #1

Closed alexraskin closed 7 months ago

alexraskin commented 7 months ago

Hello, I am not sure what version of python you are using (I am using 3.12) but I got an error when passing the PORT to the Console client

raised an exception: TypeError: 'str' object cannot be interpreted as an integer

It's odd because it's set as an int in the env file.

As a work around, I just cast the str to an int.

self.port: int = int(port)

Maybe I am missing something.

https://github.com/KOOKIIEStudios/PalCON-Discord/blob/1e597b922d40dbd69ab1809f5e5505112753b50e/client.py#L33

Thanks for the awesome work!

Bratah123 commented 7 months ago

That's an interesting error, I'm personally on python 3.12.1 (The latest version)

image

and don't see anything too breaking in the latest python patch that would cause this problem.

Are you on an older version of the bot? What operating system are you on?

It might also be good to note, that the method you sent to that link to in client.py isn't actually used in the bot anywhere as it's supposed to be for testing

Thanks for your cooperation!

KOOKIIEStudios commented 7 months ago

I'm using 3.12 as well, and the TOML parser in the standard library interpreted the data type properly for me

I genuinely have no clue why it might be throwing errors for you 🤔

KOOKIIEStudios commented 7 months ago

Can't help but notice that your repo uses env rather than toml

os.envron uses strings only (see the docs) so if you're getting this issue with your repo and not this repo specifically, that might be the reason.

os.environ A mapping object where keys and values are strings that represent the process environment.

os.getenv(key, default=None) Return the value of the environment variable key as a string if it exists, or default if it doesn’t. key is a string. Note that since getenv() uses os.environ, the mapping of getenv() is similarly also captured on import, and the function may not reflect future environment changes.

Do let us know whether this is just an issue with your port of our source code to your own bot, or if it's affecting a clone of our project running on your device!

alexraskin commented 7 months ago

os.envron uses strings only (see the docs) so if you're getting this issue with your repo and not this repo specifically, that might be the reason.

This was the problem! Thank you both for the quick reply! ❤️

Again nice work on the bot!

KOOKIIEStudios commented 7 months ago

Glad to be of help and glad you liked it

In that case, I'll mark this issue as closed!