Replit Issue with Coding Discord Bot

Hey guys I just started to learn how to code a Discord Bot using the link:

I am at timestamp 19:14 where he runs the Discord Bot and it works perfectly for him, but I have the same exact code as him and I am still getting an error. An image is attached:

Please help me if you can ASAP!

Hi there. Please post your actual code so people who read your post can review it or perhaps even try it.

I am having the same issue. Maybe the discord bot API has changed?

Hey, I did some research and I actually managed to fix the problem here is what I fixed:

intents = discord.Intents.all()
intents.message_content = True
intents.members = True
client = commands.Bot(command_prefix=“mm!”, intents=intents)

1 Like

I too have same problem but can anyone explain how it works or why that error occurs!

can u pls explain how!

Could you explain please?

Also, it fixed the problem, but it gives me this error now:

Traceback (most recent call last):
File “main.py”, line 8 in
client = commands.Bot(command_prefix=“mm!”, intents=intents)
NameError: name “commands” is not defined

My code is below:

import os
import discord
my_secret = os.environ[‘Token’]

intents = discord.Intents.all()
intents.message_content = True
intents.members = True
client = commands.Bot(command_prefix=“mm!”, intents=intents)

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(my_secret)

I request to freecodecamp team that please look into this problem because this causes an major issue while taking any reference from this discord bot making youtube video or writing the whole code, the code is outdated by the way. so please look into it.

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