Search code examples
pythondiscorddiscord.py

Discord.py How do I delete a singular message in the rewrite


I want to delete a singular message when triggered but I cannot figure it out. I got purge working with await ctx.channel.purge but that's not what I want since that requires an amount

The old version was written like await self.bot.delete_message(ctx.message) but that now brings the error object has no attribute 'bot'

Reading the documentation all I could find was Message.delete but that brings the error: NameError: name 'Message' is not defined

I am sure this is a simple solution but I cannot work it out. Thanks in advance

My current code is:

@commands.command(pass_context=True)
async def say(self, ctx, *args):
   '''Make Bot repeat your messages'''
    mesg = ' '.join(args)
    await Message.delete(ctx.message)
    await ctx.send(mesg)`

Solution

  • If you are talking about the message that triggered the command, then you can do:

    await ctx.message.delete()