├── LICENSE ├── README.md ├── collect └── collect.py ├── del └── del.py ├── log_discord ├── log_discord.py └── log_discord.service ├── nuke └── nuke.py └── requirements.txt /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Cody Zacharias 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Discord Scripts 2 | 3 | [![Python 3.5](https://img.shields.io/badge/Python-3.5-blue.svg)](https://www.python.org/download/releases/3.0/) 4 | [![GitHub license](https://img.shields.io/github/license/haccer/discord-scripts.svg)](https://github.com/haccer/discord-scripts/blob/master/LICENSE) 5 | 6 | A collection of Discord scripts I made a while ago for other people. 7 | Replace the "your_token_goes_here" with your Discord token. A short tutorial to get your Discord token is located [here](https://github.com/TheRacingLion/Discord-SelfBot/wiki/Discord-Token-Tutorial). 8 | 9 | ## Requirements 10 | 11 | - Python 3.5 12 | - `pip3 install -r requirements.txt` 13 | 14 | ## del.py 15 | 16 | A delete script to mass delete your messages from a channel. 17 | 18 | ### Usage 19 | 20 | You can delete a specific number of messages by entering `.del number`, or you can delete every message by just entering `.del` in the channel. 21 | 22 | Example: `.del 50` will delete last 50 messages in the channel. 23 | 24 | ## log_discord.py 25 | 26 | A proof-of-concept script to log Discord chatrooms. This can relay logged messages to a private Discord channel and/or save them to a text file. This is very useful for spying on people. 27 | 28 | ### Usage & Configuration 29 | 30 | Instructions on how to configure this for your needs are annotated in the script: 31 | 32 | ```python 33 | @c.event 34 | async def on_message(message): 35 | # Replace '412905214533838722' with the Discord channel ID you want to log. 36 | if message.channel.id == "412905214533838722": 37 | await log_discord(message, "replace with relay channel id", "name_of_file.txt") 38 | ``` 39 | 40 | Copy this _if_ statement for each channel you want to log, replacing the default values with your own. 41 | 42 | #### Example Logging Multiple Channels 43 | 44 | ```python 45 | @c.event 46 | async def on_message(message): 47 | if message.channel.id == "452307014715179022": 48 | await log_discord(message, "452307600785276933", "log_452307014715179022.txt") 49 | if message.channel.id == "532307014715171337": 50 | await log_discord(message, "265407600785277777", "log_532307014715171337.txt") 51 | ``` 52 | 53 | ## collect.py 54 | 55 | A script that will collect and save the last ~11k messages from a channel. 56 | 57 | ### Usage 58 | 59 | Same usage as del.py -- the scrape is triggered by `.del` to let the users who see it think you are just deleting your messages. 60 | -------------------------------------------------------------------------------- /collect/collect.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # Usage: .del (number) or .del 3 | from time import strftime, localtime 4 | import asyncio 5 | import discord 6 | import re 7 | 8 | c = discord.Client() 9 | token = "ENTER TOKEN HERE" 10 | 11 | @c.event 12 | async def on_ready(): 13 | welcome = "Logged in as {0.name} - {0.id}\n".format(c.user) 14 | # Make bot appear offline 15 | await c.change_presence(status=discord.Status.invisible) 16 | print(welcome) 17 | 18 | @c.event 19 | async def on_message(message): 20 | # Triggered by .del to make them think we're just deleting messages. 21 | if message.content.startswith('.del') and message.author == c.user: 22 | 23 | # Delete trigger message 24 | await c.delete_message(message) 25 | 26 | if re.search(r'\d+$', message.content) is not None: 27 | t = int(message.content[len('.del'):].strip()) 28 | else: 29 | t = 9999 30 | 31 | async for m in c.logs_from(message.channel,limit=t): 32 | try: 33 | # Discord timestamp is always UTC 34 | timestamp = m.timestamp.strftime("%Y-%m-%d %H:%M:%S") 35 | log = "{0.author.id} {1} UTC <{0.author}> {0.content}".format(m, timestamp) 36 | if message.attachments: 37 | log += " {}".format(message.attachments[0]['url']) 38 | 39 | print(log, file=open("{0.channel.id}_#{0.channel.name}.txt".format(message), "a", encoding="utf-8")) 40 | except: 41 | pass 42 | c.run(token, bot=False) 43 | -------------------------------------------------------------------------------- /del/del.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # Usage: .del (number) or .del 3 | import asyncio 4 | import discord 5 | import re 6 | 7 | c = discord.Client() 8 | token = "INSERT_TOKEN_HERE" 9 | 10 | @c.event 11 | async def on_ready(): 12 | welcome = "Logged in as {0.name} - {0.id}".format(c.user) 13 | print(welcome) 14 | 15 | @c.event 16 | async def on_message(message): 17 | if message.content.startswith('.del') and message.author == c.user: 18 | if re.search(r'\d+$', message.content) is not None: 19 | t = int(message.content[len('.del'):].strip()) 20 | else: 21 | t = 9999 22 | async for m in message.channel.history(limit=t): 23 | try: 24 | if m.author == c.user: 25 | await m.delete() 26 | except: pass 27 | 28 | c.run(token, bot=False) 29 | -------------------------------------------------------------------------------- /log_discord/log_discord.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | ''' 3 | Author: Cody (@now) 4 | 5 | This Python script will log chat in Discord chatrooms. 6 | and relay logs to a private Discord channel and/or save 7 | them to a text file. This is useful for spying on people. 8 | ''' 9 | from time import strftime, localtime 10 | import asyncio 11 | import discord 12 | import re 13 | 14 | c = discord.Client() 15 | 16 | # Your Discord token 17 | token = "your_token_goes_here" 18 | 19 | @c.event 20 | async def on_ready(): 21 | welcome = "Logged in as {0.name} - {0.id}\n".format(c.user) 22 | # Make the log bot appear offline. 23 | await c.change_presence(status=discord.Status.invisible) 24 | print(welcome) 25 | 26 | async def format_message(message): 27 | # Formatting the log: User ID Message 28 | msg = "**{0.author.id} <{0.author}>** {0.content}".format(message) 29 | 30 | # Plaintext formatting for writing the log to the file. 31 | # Also adding timestamp for this one. 32 | timestamp = strftime("%Y-%m-%d %H:%M:%S %Z", localtime()) 33 | log = "{0.author.id} {1} <{0.author}> {0.content}".format(message, timestamp) 34 | if message.attachments: 35 | # If someone posted a picture, we're going to get the url for it 36 | # and append it to our log string. 37 | img = message.attachments[0]['url'] 38 | msg += " {}".format(img) 39 | log += " {}".format(img) 40 | 41 | return msg, log 42 | 43 | async def relay_message(msg, channel_id): 44 | await c.send_message(c.get_channel(channel_id), msg) 45 | 46 | def write(log, _file): 47 | print(log, file=open(_file, "a", encoding="utf-8")) 48 | 49 | async def log_discord(message, relay_id, _file): 50 | msg, log = await format_message(message) 51 | await relay_message(msg, relay_id) 52 | write(log, _file) 53 | 54 | @c.event 55 | async def on_message(message): 56 | # Replace '412905214533838722' with the Discord channel ID you want to log. 57 | if message.channel.id == "412905214533838722": 58 | await log_discord(message, "replace with relay channel id", "name_of_file.txt") 59 | 60 | # Create more 'if' statements like this for each channel you want to 61 | # log. I using different relay channels and log files for each discord 62 | # channel 63 | if message.channel.id == "discord channel id": 64 | await log_discord(message, "replace with other relay channel id", "other_file.txt") 65 | 66 | c.run(token, bot=False) 67 | -------------------------------------------------------------------------------- /log_discord/log_discord.service: -------------------------------------------------------------------------------- 1 | # log_discord Systemd Service 2 | # Based on this https://medium.com/@benmorel/creating-a-linux-service-with-systemd-611b5c8b91d6 3 | 4 | [Unit] 5 | Description=Log Discord Chats 6 | After=network.target 7 | StartLimitIntervalSec=0 8 | 9 | [Service] 10 | Type=simple 11 | Restart=always 12 | RestartSec=1 13 | User=[user] 14 | ExecStart=/usr/bin/python3 [path to log_discord.py] 15 | 16 | [Install] 17 | WantedBy=multi-user.target 18 | -------------------------------------------------------------------------------- /nuke/nuke.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # Usage: python3 nuke 3 | # Silently delete all your messages without anyone knowing. 4 | # Greetz to mj 4 the idea. 5 | import asyncio 6 | import discord 7 | import sys 8 | 9 | c = discord.Client() 10 | token = "token" 11 | 12 | blue = '\x1b[1;36m' 13 | green = '\x1b[1;32m' 14 | clear = '\x1b[0m' 15 | 16 | @c.event 17 | async def on_ready(): 18 | welcome = "Logged in as {0.name} - {0.id}".format(c.user) 19 | print(welcome) 20 | 21 | print("[{}+{}] Starting wipe on servers.".format(green, clear)) 22 | for server in c.servers: 23 | await wipechannels(server) 24 | 25 | print("[{}+{}] Starting wipe on DMs".format(green, clear)) 26 | for dm in c.private_channels: 27 | await wipe(dm) 28 | 29 | sys.exit(0) 30 | 31 | async def wipechannels(server): 32 | # Servers you don't want your messages deleted in go in the blacklist. 33 | blacklist = [] 34 | if not any(server.id in b for b in blacklist): 35 | for channel in server.channels: 36 | if str(channel.type) == "text": 37 | try: 38 | await wipe(channel) 39 | except: 40 | pass 41 | 42 | async def wipe(channel): 43 | print("[{}*{}] Starting nuke on {}".format(blue, clear, channel)) 44 | async for m in c.logs_from(channel, limit=9999): 45 | try: 46 | if m.author == c.user: 47 | await c.delete_message(m) 48 | except: 49 | pass 50 | 51 | c.run(token, bot=False) 52 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | discord.py 2 | websockets 3 | aiohttp 4 | --------------------------------------------------------------------------------