Advertisement
aex-

Mass Discord Message Remover

Mar 4th, 2018
1,260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.93 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. # NOTE: I did not program this, Nor do i know the author.
  4. #       This was pulled and revamped from Retard MessengerTheGods Github
  5. #       I DO NOT CLAIM AUTHORSHIP OF THIS PROGRAM - Aex
  6.  
  7. # Instructions: Install Python3.
  8. #               run: pip install asyncio && pip install discord
  9. # Side Note: If you previously added Python2 to your path,
  10. #            Change directories to C:\Users\<USERNAME>\AppData\Local\Programs\Python\
  11. #            Run Program: python dban.py clear <AUTH_TOKEN>
  12.  
  13. # Error Handle: Sometimes Pastebin is retarded, and decides to take the qoute mark away from line 20.
  14. #               add a " to line 20.
  15. import os
  16. import sys
  17. import discord
  18. import asyncio
  19. import subprocess
  20.  
  21. cmd_prefix = sys.argv[1]
  22. auth_token = sys.argv[2]
  23.  
  24. def puts(string):
  25.     sys.stdout.write(string + "\n")
  26.  
  27. def run(cmd):
  28.     subprocess.call(cmd, shell=True)
  29.  
  30. client = discord.Client()
  31.  
  32. @client.event
  33. async def on_ready():
  34.     if (os.name == "nt"):
  35.         run('cls')
  36.  
  37.     elif (os.name == "posix"):
  38.         run('clear')
  39.        
  40.     puts('[D_DBAN] Logged in as: %s' % (client.user.name))
  41.     puts('[D_DBAN] User Identification: %s' % (client.user.id))
  42.     puts('[D_DBAN] Discord Version: %s' % (discord.__version__))
  43.     puts('----------')
  44.     puts('Connected to:')
  45.     for server in client.servers:
  46.         puts(server.name)
  47.  
  48. # Define commands
  49. @client.event
  50. async def on_message(message):
  51.     if message.author == client.user:
  52.         commands = []
  53.         z = 0
  54.         for index, a in enumerate(message.content):
  55.             if a == " ":
  56.                 commands.append(message.content[z:index])
  57.                 z = index+1
  58.         commands.append(message.content[z:])
  59.        
  60.         # MASS DELETE OWN MESSAGES
  61.         if commands[0] == cmd_prefix:
  62.             if len(commands) == 1:
  63.                 async for msg in client.logs_from(message.channel,limit=9999):
  64.                     if msg.author == client.user:  
  65.                         try:
  66.                             await client.delete_message(msg)
  67.                         except Exception as x:
  68.                             puts("[D_DBAN] A exception has occured. Passing Exception")
  69.                             pass
  70.  
  71.             elif len(commands) == 2:
  72.                 user_id = ''
  73.                 for channel in client.private_channels:
  74.                     if commands[1] in str(channel):
  75.                         if str(channel.type) == 'private':
  76.                             user_id = str(channel.id)
  77.                 async for msg in client.logs_from(discord.Object(id=user_id),limit=9999):
  78.                     if msg.author == client.user:
  79.                         try:
  80.                             await client.delete_message(msg)
  81.                         except Exception as x:
  82.                             puts("[D_DBAN] A exception has occured. Passing Exception")
  83.                             pass
  84.                            
  85. client.run(auth_token, bot=False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement