├── LICENSE ├── README.md ├── config.json ├── main.py ├── requirements.txt ├── scraped └── there-will-be-messages.txt └── start.bat /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 LnX 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 Scraper 📝

2 |

Scrapes messages in chanel

3 |

⭐ Don't forget to leave a star! ⭐

4 | 5 |
🔩 V2 Coming soon! 🔩
6 | 7 | 8 | ## Usage: 9 | 1. Config settings and token in `config.json` 10 | 2. Open install.bat 11 | 3. Open start.bat 12 | 4. In channel write `!scrape ` 13 | 5. Scraped messages will be saved in `scraped/name-of-channel` 14 | 15 | ## Settings: 16 | ![Settings Showcase](https://camo.githubusercontent.com/91fb91dbef076670a6791ffdea7bcf3591e36643/68747470733a2f2f7768657265732d6d792d74612e636f2f74504a58576c2e706e67) 17 | 18 | ## Showcase: 19 | ![Showcase](https://i.imgur.com/jQEmM9K.png) 20 | 21 | `WARN: Using a selfbot is against TOS, It's not my fault if you get a ban when someone reports you` 22 | -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "token": "token-here" 3 | } 4 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | from colorama import Fore 2 | import json 3 | import os 4 | import discord 5 | 6 | 7 | from discord.ext import ( 8 | commands, 9 | tasks 10 | ) 11 | 12 | 13 | 14 | client = discord.Client() 15 | client = commands.Bot( 16 | command_prefix="!", 17 | self_bot=True 18 | ) 19 | client.remove_command('help') 20 | 21 | with open('config.json') as f: 22 | config = json.load(f) 23 | 24 | token = config.get("token") 25 | os.system('cls') 26 | 27 | print(f"{Fore.WHITE}[ {Fore.CYAN}§ {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Discord Chat Scraper made by {Fore.WHITE}LnX{Fore.LIGHTBLACK_EX} | Licensed under {Fore.WHITE}MIT {Fore.LIGHTBLACK_EX}License") 28 | print(f"{Fore.WHITE}[ {Fore.CYAN}§ {Fore.WHITE}] {Fore.LIGHTBLACK_EX}You can follow me on Github: {Fore.WHITE}https://github.com/lnxcz") 29 | 30 | print(f"\n{Fore.WHITE}[ {Fore.GREEN}+ {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Bot is ready!") 31 | print(f"{Fore.WHITE}[ {Fore.YELLOW}? {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Write {Fore.WHITE}!scrape {Fore.LIGHTBLACK_EX} to log messages\n") 32 | 33 | def Init(): 34 | if config.get('token') == "token-here": 35 | os.system('cls') 36 | print(f"\n\n{Fore.WHITE}[ {Fore.RED}E {Fore.WHITE}] {Fore.LIGHTBLACK_EX}You didnt put your token in the config.json file\n\n"+Fore.RESET) 37 | exit() 38 | else: 39 | token = config.get('token') 40 | try: 41 | client.run(token, bot=False, reconnect=True) 42 | os.system(f'Discord message scraper') 43 | except discord.errors.LoginFailure: 44 | print(f"\n\n{Fore.WHITE}[ {Fore.RED}E {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Token is invalid\n\n"+Fore.RESET) 45 | exit() 46 | 47 | 48 | @client.command() 49 | async def scrape(ctx, amount: int): 50 | f = open(f"scraped/{ctx.message.channel}.txt","w+", encoding="UTF-8") 51 | total = amount 52 | print(f"{Fore.WHITE}[ {Fore.YELLOW}? {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Scraping {Fore.WHITE}{amount}{Fore.LIGHTBLACK_EX} messages to {Fore.WHITE}scraped/{ctx.message.channel}.txt{Fore.LIGHTBLACK_EX}!") 53 | async for message in ctx.message.channel.history(limit=amount): 54 | attachments = [attachment.url for attachment in message.attachments if message.attachments] 55 | try: 56 | if attachments: 57 | realatt = attachments[0] 58 | f.write(f"({message.created_at}) {message.author}: {message.content} ({realatt})\n") 59 | print(f"{Fore.WHITE}[ {Fore.GREEN}+ {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Scraped message") 60 | else: 61 | f.write(f"({message.created_at}) {message.author}: {message.content}\n") 62 | print(f"{Fore.WHITE}[ {Fore.GREEN}+ {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Scraped message") 63 | except Exception as e: 64 | print(f"{Fore.WHITE}[ {Fore.RED}- {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Cannot scrape message from {Fore.WHITE}{message.author}") 65 | print(f"{Fore.WHITE}[ {Fore.RED}E {Fore.WHITE}] {Fore.LIGHTBLACK_EX} {Fore.WHITE}{e}") 66 | total = total - 1 67 | print(f"{Fore.WHITE}[ {Fore.YELLOW}? {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Succesfully scraped {Fore.WHITE}{total} {Fore.LIGHTBLACK_EX}messages!\n\n{Fore.WHITE}") 68 | 69 | 70 | @client.event 71 | async def on_command_error(ctx, error): 72 | error_str = str(error) 73 | error = getattr(error, 'original', error) 74 | if isinstance(error, commands.CommandNotFound): 75 | return 76 | elif isinstance(error, discord.errors.Forbidden): 77 | print(f"{Fore.WHITE}[ {Fore.RED}E {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Discord error: {error}"+Fore.RESET) 78 | else: 79 | print(f"{Fore.WHITE}[ {Fore.RED}E {Fore.WHITE}] {Fore.LIGHTBLACK_EX}{error_str}"+Fore.RESET) 80 | 81 | Init() 82 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | discord 2 | colorama 3 | -------------------------------------------------------------------------------- /scraped/there-will-be-messages.txt: -------------------------------------------------------------------------------- 1 | . -------------------------------------------------------------------------------- /start.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | cls 3 | title Discord Scrape Bot 4 | py -3.8 main.py 5 | pause --------------------------------------------------------------------------------