Discord Bot, using Py on Replit

Issue: I copied this right from the Replit Page, I followed the instructions and still it wont work. I did put in the DISCORD_BOT_SECRET as a variable along with my bot token.

What exactly is the issue here?

Error: Traceback (most recent call last):
File “main.py”, line 6, in
@client.event
NameError: name ‘client’ is not defined

Code:

import os
import discord

discord.Client(intents=discord.Intents.all())

@client.event
async def on_ready():
    print("I'm in")
    print(client.user)

@client.event
async def on_message(message):
    if message.author != client.user:
        await message.channel.send(message.content[::-1])

my_secret = os.environ['DISCORD_BOT_SECRET']
client.run(my_secret)

I believe you need to assign your discord.Client() call to a client variable.

1 Like

THANK YOU!!!
i was so lost n theres not much information on the subjectXD

hey! how exactly did you go about assigning to a client variable? I seem to be a bit overwhelemed/lost as well :sweat_smile:

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