import discord
from discord.ext import commands
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv("TOKEN")
client = commands.Bot(command_prefix=["."],help_command=None)
@client.event
async def on_ready():
print("Ready")
@client.command(invoke_without_command=True)
async def help(ctx):
embed = discord.Embed(title="**Help List**",description="Help shows this command",color=discord.Color.blurple())
await ctx.send(embed=embed)
@help.command()
async def changeprefix(ctx):
embed = discord.Embed(title="**Changeprefix**",description=".Changeprefix <newprefix>",color=discord.Color.blurple())
await ctx.send(embed=embed)
client.run(TOKEN)
The error I'm getting: Traceback (most recent call last): File "c:/Users/trymk/OneDrive/Documents/python/discord/Help2.py", line 22, in @help.command() AttributeError: 'Command' object has no attribute 'command'
A cleaner way of doing it. I suggest at Line 13
change it to: async def help(ctx,*,specific=None):
Change the help
command as such:
@client.command(invoke_without_command=True)
async def help(ctx,*,specific=None):
if specific==None:
embed = discord.Embed(title="**Help List**",description="Help shows this command",color=discord.Color.blurple())
elif specifc=="changeprefix":
embed = discord.Embed(title="**Changeprefix**",description=".Changeprefix <newprefix>",color=discord.Color.blurple())
else:
embed = discord.Embed(title="**Command Not Found**",color=discord.Color.red())
await ctx.send(embed=embed)
You can then run the command in discord like .help changeprefix
You can also expand for other commands by doing another elif
The reason for the error at @help.command()
is because your help
command, the command object, doesn't support or have a method called command
. You can view a list of attributes and methods on the documentation for discord.ext.commands here.
I'm not sure exactly what your question is but I'd suggest trying the answer by Fishball Nooodles as I think their answer might resolve your issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.