Discord Bot Help

Hello,
I just got finished watching the video and the bot didn’t work but I was told in the comments to replace os.getenv(‘TOKEN’) with os.environ(‘TOKEN’) and it reduced my error codes down to only one which was:
Traceback (most recent call last):
File “main.py”, line 18, in
client.run(os.environ(‘TOKEN’))
TypeError: ‘_Environ’ object is not callable
Which I can’t seem to trouble shoot.

Hi @ExtremeCoder !

Welcome to the forum!

It would be nice to see your full code.

Also, if you built this in replit then you will need to use the secrets tab because you can’t create an .env file anymore.

Hello!
Here is the entire code:

import discord
import os

client = discord.Client()

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('$hello'):
        await message.channel.send('Hello!')

client.run(os.environ('token'))

it is just a simple bot for me and my friends to mess around with.
Also I saw that it doesn’t use the env and that you have to use replits secrets folder but im not sure how to use it then implement it into my code.

The problem is, you are telling the computer to access something that doesn’t exist.

It can’t access the token variable because you haven’t supplied it yet.

You will need to click on the secrets tab on the left side and add your key and value for your bot. Click add new secret and it should display a welcome message when running.

Screen Shot 2021-05-30 at 11.24.02 AM

It works now and im super exited! Thanks!

1 Like

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