├── .gitattributes ├── DiscordMember-Recon.py └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /DiscordMember-Recon.py: -------------------------------------------------------------------------------- 1 | import discord 2 | from discord import Intents 3 | import pandas as pd 4 | from openpyxl import Workbook 5 | from urllib.parse import urlparse, urlunparse 6 | import importlib 7 | import subprocess 8 | import traceback 9 | import sys 10 | 11 | # Step 1: Create a Discord application and bot account, and get the bot token 12 | bot_token = 'put your discord bots token inside here' 13 | channel_name = 'put your channel name here' # Change to your desired channel name to send progress and error handling to. Make sure the bot has permission to write there! 14 | 15 | # Step 2: Check if necessary packages (discord.py, pandas, openpyxl) are installed 16 | required_modules = ['discord', 'pandas', 'openpyxl'] 17 | for module in required_modules: 18 | try: 19 | importlib.import_module(module) 20 | print(f"Module {module} is installed.") 21 | except ImportError: 22 | print(f"{module} is not installed. Installing...") 23 | subprocess.check_call([sys.executable, '-m', 'pip', 'install', module]) 24 | 25 | # Step 3: Connect to the Discord API and fetch member information 26 | intents = Intents.default() 27 | intents.members = True 28 | 29 | client = discord.Client(intents=intents) 30 | 31 | async def send_embedded_message(title, description, color=0x00ff00): 32 | channel = discord.utils.get(client.get_all_channels(), name=channel_name) 33 | if channel: 34 | embed = discord.Embed(title=title, description=description, color=color) 35 | await channel.send(embed=embed) 36 | 37 | @client.event 38 | async def on_ready(): 39 | try: 40 | print(f"Successfully logged into Discord as {client.user.name}") 41 | 42 | guild = client.guilds[0] # Select the first guild the bot is in 43 | members = guild.members 44 | 45 | # Extract member information 46 | data = {'Name': [], 'Discriminator': [], 'Nickname': [], 'Avatar_URL': [], 'ID': [], 'Roles': [], 'Top_Role': [], 'Joined_at': [], 'Created_at': [], 'Bot': [], 'Status': [], 'Activity': [], 'Desktop_Status': [], 'Mobile_Status': [], 'Web_Status': [], 'Raw_Status': []} 47 | for member in members: 48 | data['Name'].append(member.name) 49 | data['Discriminator'].append(member.discriminator) 50 | data['Nickname'].append(member.nick) 51 | if member.avatar is not None: 52 | avatar_url = member.avatar.url 53 | if not avatar_url.startswith('http'): 54 | if avatar_url.startswith('a_'): 55 | avatar_url = f'https://cdn.discordapp.com/avatars/{member.id}/{avatar_url}.gif' 56 | else: 57 | avatar_url = f'https://cdn.discordapp.com/avatars/{member.id}/{avatar_url}.png' 58 | else: 59 | avatar_url = None 60 | data['Avatar_URL'].append(avatar_url) 61 | data['ID'].append(member.id) 62 | roles = [role.name for role in member.roles] 63 | data['Roles'].append(roles) 64 | top_role = member.top_role.name if member.top_role.name != "@everyone" else " " 65 | data['Top_Role'].append(top_role) 66 | data['Joined_at'].append(str(member.joined_at)) 67 | data['Created_at'].append(str(member.created_at)) 68 | data['Bot'].append(member.bot) 69 | data['Status'].append(str(member.status)) 70 | data['Activity'].append(str(member.activity)) 71 | data['Desktop_Status'].append(str(member.desktop_status)) 72 | data['Mobile_Status'].append(str(member.mobile_status)) 73 | data['Web_Status'].append(str(member.web_status)) 74 | data['Raw_Status'].append(str(member.raw_status)) 75 | 76 | print("Information fetched successfully.") 77 | await send_embedded_message("Progress", "Information fetched successfully.") 78 | 79 | # Step 4: Organize the fetched information into a spreadsheet using the Pandas library 80 | df = pd.DataFrame(data) 81 | print("Data organized into a DataFrame.") 82 | await send_embedded_message("Progress", "Data organized into a DataFrame.") 83 | 84 | # Step 5: Export the spreadsheet to an Excel file using the openpyxl library 85 | excel_file_name = 'discord_members.xlsx' 86 | with pd.ExcelWriter(excel_file_name) as writer: 87 | df.to_excel(writer, index=False, sheet_name='members') 88 | print("Data exported to 'discord_members.xlsx'.") 89 | await send_embedded_message("Progress", "Data exported to 'discord_members.xlsx'.") 90 | 91 | # Step 6: Export an HTML file with embedded avatar images 92 | html_file_name = 'discord_members.html' 93 | def embed_image(url): 94 | if url: 95 | if url.startswith('https://cdn.discordapp.com/avatars/'): 96 | url = url.split("?")[0] # Remove query parameter from avatar URL 97 | return f'' 98 | else: 99 | return "" 100 | 101 | df["Avatar_URL"] = df["Avatar_URL"].apply(embed_image) 102 | html = df.to_html(escape=False, index=False) 103 | with open(html_file_name, 'w', encoding='utf-8') as f: 104 | f.write(html) 105 | print("HTML file 'discord_members.html' created.") 106 | await send_embedded_message("Progress", "HTML file 'discord_members.html' created.") 107 | 108 | # Step 7: Send files to the Discord channel 109 | channel = discord.utils.get(client.get_all_channels(), name=channel_name) 110 | if channel: 111 | await channel.send(file=discord.File(excel_file_name)) 112 | await channel.send(file=discord.File(html_file_name)) 113 | print("Files sent to the Discord channel.") 114 | 115 | # Step 8: Send a custom message to the Discord channel 116 | await channel.send("All done, have a great day! -RocketGod") 117 | print("Custom message sent to the Discord channel.") 118 | 119 | await client.close() 120 | 121 | except Exception as e: 122 | print(f"An error occurred: {e}") 123 | traceback.print_exc() 124 | await send_embedded_message("Error", str(e), color=0xff0000) 125 | 126 | try: 127 | client.run(bot_token) 128 | except discord.LoginFailure: 129 | print(f"Failed to log into Discord. Check if the provided bot token ({bot_token}) is correct.") 130 | except Exception as e: 131 | print(f"An error occurred: {e}") 132 | traceback.print_exc() -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Discord_Member_Rocon 2 | RocketGod's Discord bot for collecting all available member data on a Discord server and saving it to both an Excel spreadsheet and an HTML file with member Avatars included. 3 | 4 | 5 |

6 | If you take from this repo, you bear the consequences of your actions.
7 | Feel free to contribute and submit a PR
8 |
9 | All my fun videos go here:
10 | RocketGod's YouTube Channel
11 | RocketGod’s TikTok
12 |
13 | Buy cool hacker toys here and use code ROCKETGOD for 5% discount
14 | Lab401
15 |
16 | Come hang out with me at:
17 | The Pirates' Plunder (Discord) ask me for an invite
18 |
19 | If you want to chat with me, just @RocketGod there. 20 |
21 | Buy me a coffee! I appreciate anything to help pay for server costs 🥰 22 | 23 | ![RocketGod](https://github.com/RocketGod-git/Discord-Server-Member-Recon/assets/57732082/af6197e9-88ef-49dd-a0b6-1e359b8db05e) 24 | --------------------------------------------------------------------------------