简体   繁体   中英

How do I delete the ?Say command message after sending the response in this code?

I just added the ?say command to my code and I also want the bot to delete my message I sent.

This is the say command:

@client.command(aliases = ['Say'])
async def say(ctx, *args):
    response = ""

    for arg in args:
        response = response + " " + arg

    await ctx.channel.send(response)

If you want to delete the message that you've sent to run the command, you can use await ctx.message.delete() .

@client.command(aliases = ['Say'])
async def say(ctx, *args):
    response = ""

    for arg in args:
        response = response + " " + arg

    await ctx.channel.send(response)
    await ctx.message.delete()

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM