0
votes

here is the full code of my bot, just to show you that I have not used help in any place else except the help command. It's so confusing lol.

import asyncio
from discord.ext import commands

#todo
#Eco bot
#Leveling bot
#Help



#bot
token = 'token'
bot = commands.Bot(command_prefix='w')
#getting ID's

# list of banned words
filtered_words = ['bad words']

#help command
@bot.command(aliases=['help'])
async def help(ctx):
    author = ctx.message.author

    embed = discord.Embed(
        colour = Discord.Colour.blue
    )

    embed.set_author(name='help')
    embed.add_feild(name='clear', value='Alises: c, clean. Deleted a specified number of messages in the chat history.', inline=False)

@bot.event
async def on_ready():
    print("Hello I am online and ready!")
    #Bot status
    await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f"{len(bot.guilds)} server(s)"))

# Group message clearing (purge)
@bot.command(aliases=['c', 'clear'])
@commands.has_permissions(manage_messages = True)
async def clean(ctx, amount: int):
    amount += 1
    await ctx.channel.purge(limit = amount)
    amount -= 1
    msg = f"You've deleted {amount} messages"
    await ctx.send(msg, delete_after=10)

# auto mod
@bot.event
async def on_message(msg):
    for word in filtered_words:
        if word in msg.content:
            await msg.delete()
    await bot.process_commands(msg)

@bot.event
async def on_message_delete(msg):
    if msg.author.id != 835676293625282601:
        channel = bot.get_channel(398176354392342529)
        del_msg = await channel.send(":eyes:")
        await del_msg.send(del_msg)
        await asynciaito.sleep(10)
        await del_msg.delete()

bot.run(token)

The problem is these lines, it says help is already defined, but it isn't? I've had the same problem with the clean command when I used clear instead of clean. it just kept saying that the command was already being used. it's so confusing to me lol.

@bot.command(aliases=['help'])
async def help(ctx):
    author = ctx.message.author

    embed = discord.Embed(
        colour = Discord.Colour.blue
    )

    embed.set_author(name='help')
    embed.add_feild(name='clear', value='Alises: c, clean. Deleted a specified number of messages in the chat history.', inline=False)

below is the error code:

discord.ext.commands.errors.CommandRegistrationError: The command help is already an existing command or alias.
2
You can disable the default one with bot = commands.Bot(command_prefix="w", help_command=None) - Weylyn

2 Answers

1
votes

Since help is already a command, you'll want to remove it. You can do this before your on_ready event.

bot.remove_command('help')

Here is a SO question you can refer to if you get confused

1
votes

Help is a reserved keyword, try naming your function something like help_1(): (or something more meaningful) https://en.wikipedia.org/wiki/Reserved_word#:~:text=In%20a%20computer%20language%2C%20a,word%20may%20have%20no%20meaning.