Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- from discord.ext import commands
- import asyncio
- client = commands.Bot(command_prefix="/", self_bot=True)
- @client.event
- async def on_ready():
- print("Message Eraser")
- print("______________________")
- print(f"Status: Online\nUser ID: {client.user.id}\nUser Name: {client.user.name}")
- @client.command(hidden=True)
- async def purge(ctx, user_id: int):
- """Usage: /purge <user_id>"""
- user = await client.fetch_user(user_id)
- channel = user.dm_channel
- message_channel = await ctx.send(f"Beggining DM purge of {user}")
- msg_list = []
- async for message in channel.history():
- if message.author.id == client.user.id:
- try:
- await message.delete()
- msg_list.append("Message Deleted")
- except:
- pass
- await message_channel.edit(content=f"Successfully deleted {len(msg_list)} messages from {user}'s dms.'")
- client.run("TOKEN", bot=False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement