Traceback error while creating discord bot

Hi everyone

I’m a little stuck on traceback error whenever i run my discord bot program on repl.it, if anyone can help, i’ll kindly appreciate that

Python is strongly, dynamically typed, so an error like this is due to the “strongly” part.

Working backwards from the error stack, you’ll see some “hints” as to whats going on.
It expects a string when you call client.run except it receives a NoneType instead. This is only possible if os.getenv('TOKEN') returns NoneType.

So why does os.getenv('TOKEN') return a NoneType? Its because there isn’t an environment variable set as TOKEN. If your following a tutorial (specifically this one) its actually out of date, as Repl.it changed how secrets work.

To set secrets, don’t use a .env file, instead use the UI to set your TOKEN variable

More info on using this feature is here:


Just as future reference, be careful following 100% along with video tutorials, as they can easily become out of date over time.

1 Like

Thank you so much for your reply

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.