Reputation: 35
import discord
import asyncio
client = discord.Client()
@client.event
async def on_ready():
print ("I’m Now Online")
@client.event
async def on_message(message):
if message.author == client.user:
return
elif message.content.startswith("deletethis"):
I’m wonder how I could be able to add to this to delete the above command when the author of the message sends the command above. May someone help create one? I’ve tried my self by brain and didn’t find anything online so I’m looking for some help maybe.
Upvotes: 2
Views: 7419
Reputation: 836
for async just do
await client.delete_message(message)
otherwise for rewrite just do
await message.delete()
Finished code:
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith("deletethis"):
await asyncio.sleep(1)
await message.delete()
Upvotes: 3