0
votes

I was making a discord bot with the prefix "!c", but I wanted that if people sent "!c" that an embed showed up so I fixed it by doing this:

client = commands.Bot(command_prefix='!')
client.remove_command("help")

@client.group()
async def c(ctx):
    YourEmbedCodeHere

I want to add a command "!c help" that it sends the same embed. I tried it by doing:

@c.group(invoke_without_command= True)
async def help(ctx):
   embed = discord.Embed(title="ChiBot", description="ChiBot by Chita! A very usefull moderation, level, invite and misc bot!", color=0x62e3f9)
   embed.add_field(name="Commands:", value="Do !help (command) to get help on that command!", inline=False)
   embed.add_field(name="Misc", value="!c help    !c randomimage    !c invite    !c echo", inline=False)
   embed.add_field(name="Moderation", value="!c ban    !c kick    !c warn    !c mute    !c unmute    !c warns      !c warnings", inline=False)
   embed.add_field(name="Levels", value="!c rank    !c dashboard   ", inline=False)
   embed.add_field(name="Invites", value="!c invites (help with setting it up)", inline=False)
   embed.set_footer(text="Created by Chita#8005")
   await ctx.send(embed=embed)

But when I try that, it sends double because "!c" is still a command for that same embed. How can I make it so it only sends 1 embed? And I want to add other "!c" commands as well so I need a solution to remove the !c embed if there is something behind the !c

Regards, Chita

2

2 Answers

1
votes

You can use the on_message event listener to check for that.

@client.listen('on_message')
async def foo(message):
   await client.wait_until_ready()
   ctx = await client.get_context(message)
   if message.content == '!c':
       await ctx.send(embed=embed) # send your embed here
       return #makes sure that we dont reply twice to `!c`

we are using client.wait_until_ready() so that the client doesn't respond to messages before it is connected.

Optionally, you can add

if message.author.bot:
    return

to make sure that we don't reply to bots.

Resources: on_message wait_until_ready

0
votes

You can try having the prefix stay as "!c" and have an on_message event to listen for a "!c" to send the embed. Something like this.

@client.event
async def on_message(message):
    if message.content == "!c":
        #Your embed code here
    await client.process_commands(message)

I hope this may be of help.