Replit not recognizing commands.Bot for discord?

Question:
Replit not recognizing commands.Bot for discord?
Repl link:
https://replit.com/@Geodafence/bot-code
code snippet

1 Like

I believe the error you’re encountering stems from attempting to utilize both discord.Client and commands.Bot simultaneously. To address this issue, consider using the following code snippet instead:

from discord.ext import commands
import discord

client = commands.Bot(command_prefix="!", intents=discord.Intents.default()) # default intents.

thank you @Sky ima try that

1 Like

Please, let me know if it works!

1 Like

sadly no, it boots up properly but gives this warning


then when I try to do a command nothing happens

1 Like

The issue you are encountering is actually within your Discord bot configuration. To resolve this, please follow these steps:

  1. Go to your developer portal and select your bot.
  2. Click on the “Bot” tab.
  3. Scroll down to “Privileged Gateway Intents” and enable the “Message Content Intent.”
1 Like

thank you! Ima test that rq

1 Like

Certainly, I’m here to assist you. Please feel free to reach out if you require any further help or have additional questions.

1 Like

uh so it still is being goofy, even though I set everything to true

1 Like

Ah, have you reset the token and reconfigured the program to align with the new bot token?

1 Like

oh whoops no, forgot

1 Like

even after resetting the token, kicking and re inviting the bot with the commands perm, and some other things, it still gives this error and refuses to notice commands

1 Like

I would appreciate it if you could share your complete code with me, but please remember to redact or conceal your token for security reasons.

here it is

1 Like

Could you please provide the code formatted in Python codeblocks?

1 Like

how do I do that? Do you mean the format button?

Just send me your Repl link :).

oh ok
https://replit.com/@Geodafence/bot-code

1 Like

Try this code:

import os

import discord
from discord.ext import commands

my_secret = os.environ['DISCORD_BOT_SECRET']
print("running commands line")

prefix = "!"
intents = discord.Intents.all()
intents.message_content = True
client = commands.Bot(command_prefix=prefix, intents=intents)

@client.event
async def on_ready():
    print(f"{client.user} is online.")

@client.command(help="just checks if the bot is running")
async def ping(ctx):
  ctx.send("pong")
  print("detected command")

client.run(my_secret)

I removed the discord.Client & replaced on_connect with on_ready, I also added made it so the message content intent was set as True.

2 Likes

that seemed to work, thank you so much!

1 Like