3

I have added this code:

@client.command(pass_context=True)
async def name(ctx):
username = ctx.message.author.display_name

On to the end of my line of code, and I get this error when trying to get the bot online:

AttributeError: 'Client' object has no attribute 'command'

2 Answers 2

1

You need to use discord.ext.commands.Bot instead of discord.Client. Bot is a subclass of Client, so you can also use all of the Client functionality with a Bot instance

from discord.ext.commands import Bot

bot = Bot("!")

@bot.command()
async def test(ctx):
    await ctx.send("Command executed")

await bot.run("TOKEN")
Sign up to request clarification or add additional context in comments.

2 Comments

I'm now getting another error. ModuleNotFoundError: No module named 'Bot'
Sounds like you tried just import Bot and not the full from discord.ext.commands import Bot
0
client = discord.Client(intents=intents ) 

Check this :)

client=commands.Bot(command_prefix=".")

This resolves my isssue :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.