Discord Bot Python Delete User Message After Executed [Closed]

How would I set up my commands so it would delete the author's message after the Discord Bot executed the command? For example:

#This is for the 'Ping' command.
if message.content.upper().startswith('!PING'):
userID = message.author.id
await client.send_message(message.channel, "<@%s> Pong!" % (userID))

This command is simple, you type !ping and the bot returned with "@mention Pong!". I want to delete the !ping sent by the user right after the bot sends out "@mention Pong!".

Okay, so all you have to do is add the following to the end of your code block:

await client.delete_message(message)

This should delete the 'authors' message after the bot has executed the command.

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest