Guide on creating discord bot is not working

Okay, so I decided to try to make a discord bot cause I was bored and my other friends were so I decided I would too. End up finding this video and following along, when I run into a problem. Since the tutorial is a little outdated, repl it changed how to keep a part of your code a secret for stuff like discord bot tokens. Now I can’t create a file for the token and so have to break from the tutorial slightly and get help from the comments.

Most comments were talking about the replacement of env files and how they have ‘secrets’ now. Most people are saying to put the word “TOKEN” as the key, and then your actual discord bot token in ‘Value’

I did that and the other steps they mentioned and none of those worked. I’ll paste the code below:

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'])

Whenever I have

 ['TOKEN']

It seems to create a lot of errors.

However, when I do

('TOKEN')

it seems to have only 1 error.

Here are the errors:

['TOKEN']: 

('TOKEN'):

TOKEN error 2

Definetly is a lot smaller. However I have no idea how to fix this. I felt like I’ve tried everything. At first when I did ‘()’ it would say _Environ is not callable
or something along those lines, but I found out that for some reason on the discord portals thing, ‘bot’ was not checkmarked. So I checkmarked it and now i’m getting these errors.

Any help would be appreciated, thanks in advance!

Edit: Turns out the error had nothing to do with me changing the discord checkmark thing. I didnt think about looking up the error and turns out i forgot a ‘)’ at the end. So currently im looking at an error that says:

TOKEN error 3

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