Ask coding questions

← Back to all posts
Discord Bot
aidenssn

So I don't know what I'm really doing since I'm not experienced but anyways, I'm trying to find a way for me to use just 1 repl.it tab in order to make my discord bot work but if I do something like this : import discord
import os

client = discord.Client()

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

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

client.run(os.getenv('TOKEN'))

It only command that works is the code listed to the closest to this string : client.run(os.getenv('TOKEN')).How should I solve this issue?

(Thank you in advance :D)

Voters
ch1ck3n
aidenssn
Comments
hotnewtop
19wintersp

Have you created a ".env" file and placed your API token in it? For example, if my API token was "asdfghjkl", the ".env" file would look like this:

aidenssn

@19wintersp yes I have set up my .env file

19wintersp

@aidenssn What errors are you getting? Can you paste the full error for me?