Advertisement
Guest User

Untitled

a guest
May 24th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import discord
  2. from discord.ext import commands
  3. import asyncio
  4. client = commands.Bot(command_prefix="/", self_bot=True)
  5.  
  6. @client.event
  7. async def on_ready():
  8. print("Message Eraser")
  9. print("______________________")
  10. print(f"Status: Online\nUser ID: {client.user.id}\nUser Name: {client.user.name}")
  11.  
  12. @client.command(hidden=True)
  13. async def purge(ctx, user_id: int):
  14. """Usage: /purge <user_id>"""
  15. user = await client.fetch_user(user_id)
  16. channel = user.dm_channel
  17. message_channel = await ctx.send(f"Beggining DM purge of {user}")
  18. msg_list = []
  19. async for message in channel.history():
  20. if message.author.id == client.user.id:
  21. try:
  22. await message.delete()
  23. msg_list.append("Message Deleted")
  24. except:
  25. pass
  26. await message_channel.edit(content=f"Successfully deleted {len(msg_list)} messages from {user}'s dms.'")
  27.  
  28. client.run("TOKEN", bot=False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement