├── README.md
├── bot.py
├── data.json
├── example1.png
├── example2.png
└── main.py
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | # Discord-DM-All-Bot
9 |
10 |
11 |
12 |
13 | ## Installation
14 | Here is the list of requements:
15 | * colored
16 | * discord.py
17 |
18 | ## How to use
19 | 1. Run the file `main.py` it will first ask you for a discord bot token here it is very important in the discord dev portal to check on member indents or the bot will not work properbly
20 | 2. Second it will ask you for a message to send in discord this can be left blank
21 | 3. Third it will ask you if you want to use embeds if so you can create and visuelise one [here](https://leovoel.github.io/embed-visualizer/) just copy the json data from that into the json file the bot creates
22 | 4. Fourfth will be a cooldown in seconds, i recommend 5 seconds to avoid getting your bot banned by discord, you can set this to 0 for guilds under 50 ive found
23 | 5. Invite the bot into a server of your choice, it does not need to have any permissions once the bot joins it will do its thing
24 | ---
25 |
26 | *This code was developed in collaboration with [this discord server](https://www.anonix.xyz/discord) make sure to check them out*
27 |
--------------------------------------------------------------------------------
/bot.py:
--------------------------------------------------------------------------------
1 | from discord.ext import tasks, commands
2 | import discord
3 |
4 | from colored import fg, bg, attr
5 | from datetime import datetime
6 | import asyncio
7 | import time
8 | import json
9 | import sys
10 | import os
11 |
12 | message = "" # Initialise a few variables to use later
13 | embed = None
14 | cooldown = 0
15 |
16 | r = fg(241) # Setup the diffrent color variables
17 | r2 = fg(247)
18 | b = fg(31)
19 | w = fg(15)
20 |
21 | intents = discord.Intents.default() # Setup permissions for the bot to be able to see all the members in a server
22 | intents.members = True
23 |
24 | bot = commands.Bot( # Setup the bot object
25 | command_prefix = '>> ',
26 | intents=intents
27 | )
28 |
29 | def progressbar(it, prefix="", size=60, file=sys.stdout): # Setup the progress bar to be used later
30 | count = len(it) # Get the lenght of the loop
31 | def show(i, user): # Define a function to show the current progress bar
32 | x = int(size * i / count) # Get the lenght of the bar
33 |
34 | file.write(f"{r} [{w}?{r}] {b}|{r2}{'#' * x}{'.' * ( size - x )}{b}| {i}{r}/{b}{count} {r}|{b} {str(user):<30} {r}\r")
35 | file.flush() # Print out the bar
36 |
37 | show(0, "None") # Show the bar empty
38 | for i, item in enumerate(it): # Loop over the iterator
39 | yield item # Yield the item allowing us to loop over the function later
40 | show(i+1, item) # Show the progress bar at its current state
41 |
42 | show(len(it), "Done") # Show the progress bar is done
43 |
44 | file.write("\n") # Flush the newline
45 | file.flush()
46 |
47 | @bot.event
48 | async def on_ready(): # Tell the user when the bot comes online
49 | global cooldown # Globalise variables we need to use later
50 | global message # This is needed since if we change them here they will be private variables
51 | global embed
52 |
53 | with open("data.json", "r") as file: # Open the data.json file
54 | data = json.load(file) # Load the data using a json parser
55 |
56 | message = data["message"] # Get the message to send
57 | cooldown = data["cooldown"] # And the cooldown
58 |
59 | if data["embed"] is not None: # Check if the embed has a value
60 | dictEmbed = data["embed"]["embed"] # Get the embed
61 | try: # We want to catch any errors that might come up
62 | dictEmbed.pop("timestamp") # Remove the timestamp since that wont work properbly
63 | except: # If we get an error and the provided data does not have a timestamp key
64 | pass # Do nothing
65 | embed = discord.Embed.from_dict(dictEmbed) # Create the embed variable from the data
66 |
67 | print(f"{r} [{w}!{r}] Logged in as: {b}{bot.user}{r}") # Say who its logged in as
68 | print(f" [{w}+{r}] Message: {b}{message}{r}") # Tell the user the message
69 | print(f" [{w}+{r}] Embed: {b}{'True' if embed is not None else 'False'}{r}") # If it has a embed or not
70 | print(f" [{w}+{r}] Cooldown: {b}{cooldown}s\n{r}") # Tell the cooldown
71 |
72 | @bot.event
73 | async def on_guild_join(guild): # If the bot joins a guild
74 | print(f"{r} [{w}!{r}] Joined server {b}{guild.name}{r}. Starting Attack.{r}") # Warn the user its about to start an attack
75 | time.sleep(2) # Wait a bit
76 |
77 | start = time.time() # Start a timer
78 | successes = 0 # Setup a counter for the successfull attempts
79 | fails = 0 # And one for the unsuccessfull attempts
80 |
81 | members = guild.members # Get all the members of the guild
82 | for i in progressbar(guild.members, "", 40): # Loop over the members in the guild
83 | try: # Try to send the message
84 | if embed is None: # Check if there is an embed
85 | await i.send(message) # Send the message without an embed
86 | else: # Or if there is an embed
87 | await i.send(message, embed = embed) # Send the message with an embed
88 | successes += 1 # Increase the successes with one
89 | time.sleep(cooldown) # Wait for the cooldown
90 | except Exception as e: # If there happens an error
91 | # print(e)
92 | fails += 1 # Increase fails by one
93 |
94 | print(f"{r} [{w}?{r}] {b}{successes}{r} Successes && {b}{fails}{r} Fails && Total time: {b}{( time.time() - start ) / 60}{r} minutes") # Give a report of the results
95 | time.sleep(2) # Wait 2 seconds
96 | print(f"{r} [{w}!{r}] Finished attack, leaving server.\n") # Warn the user its about to leave a guild
97 | await guild.leave() # Leave the guild
98 |
99 | if __name__ == '__main__': # If the file is getting ran directly
100 | bot.run("") # Run the bot
101 |
--------------------------------------------------------------------------------
/data.json:
--------------------------------------------------------------------------------
1 | {"message": "", "embed": null, "cooldown": 0}
2 |
--------------------------------------------------------------------------------
/example1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logicguy1/Discord-DM-All-Bot/3c0ffac71a343c691cac5b06f608b54c06496c34/example1.png
--------------------------------------------------------------------------------
/example2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logicguy1/Discord-DM-All-Bot/3c0ffac71a343c691cac5b06f608b54c06496c34/example2.png
--------------------------------------------------------------------------------
/main.py:
--------------------------------------------------------------------------------
1 | import json
2 | import time
3 | import bot
4 | import os
5 |
6 | from colored import fg, bg, attr
7 |
8 | r = fg(241) # Setup color variables
9 | r2 = fg(255)
10 | b = fg(31)
11 | w = fg(15)
12 |
13 | class DMAllBot: # Initialise the class
14 | def main(self): # Main function, holds the main code
15 | os.system('cls' if os.name == 'nt' else 'clear') # Clear the screen
16 | print(f""" {r2} █████{b}╗{r2} ███{b}╗{r2} ██{b}╗{r2} ██████{b}╗{r2} ███{b}╗{r2} ██{b}╗{r2}██{b}╗{r2}██{b}╗{r2} ██{b}╗{r2}
17 | ██{b}╔══{r2}██{b}╗{r2}████{b}╗ {r2}██{b}║{r2}██{b}╔═══{r2}██{b}╗{r2}████{b}╗ {r2}██{b}║{r2}██{b}║╚{r2}██{b}╗{r2}██{b}╔╝{r2}
18 | ███████{b}║{r2}██{b}╔{r2}██{b}╗ {r2}██{b}║{r2}██{b}║ {r2}██{b}║{r2}██{b}╔{r2}██{b}╗ {r2}██{b}║{r2}██{b}║ ╚{r2}███{b}╔╝{r2}
19 | ██{b}╔══{r2}██{b}║{r2}██{b}║╚{r2}██{b}╗{r2}██{b}║{r2}██{b}║ {r2}██{b}║{r2}██{b}║╚{r2}██{b}╗{r2}██{b}║{r2}██{b}║ {r2}██{b}╔{r2}██{b}╗{r2}
20 | ██{b}║ {r2}██{b}║{r2}██{b}║ ╚{r2}████{b}║╚{r2}██████{b}╔╝{r2}██{b}║ ╚{r2}████{b}║{r2}██{b}║{r2}██{b}╔╝ {r2}██{b}╗{r2}
21 | {b}╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝╚═╝ ╚═╝
22 | """) # Print the title card
23 |
24 | time.sleep(2) # Wait a few seconds
25 | self.slow_type(f"{r} [{w}+{r}] DMAllBot made by: {b}Drillenissen#4268{r} && {b}Benz#1001", .02) # Print who developed the code
26 | time.sleep(1) # Wait a little more
27 | self.slow_type(f"{r} [{w}?{r}] Input the Discord bot token: {b}", .02, newLine = False)
28 | token = input("").strip() # Get the discord token
29 |
30 | self.slow_type(f"{r} [{w}?{r}] Input the message to post: {b}", .02, newLine = False) # Ask for a message to dm
31 | message = input("") # Wait for an awnser
32 | self.slow_type(f"{r} [{w}?{r}] Do you wish yo use embeds? (Y/n): {b}", .02, newLine = False) # Ask for a message to dm
33 | emb = input("") # Wait for an awnser
34 |
35 | if "y" in emb.lower(): # Check if "y" is in the responce
36 | data = self.emb_setup() # Run the embed setup function
37 | else: # Otherwise
38 | data = None # Set the embed as None
39 |
40 | self.slow_type(f"{r} [{w}?{r}] Set a cooldown ( Seconds ): {b}", .02, newLine = False) # Ask for a message to dm
41 | cooldown = float(input("")) # Wait for an awnser
42 |
43 |
44 | with open("data.json", "w") as josnFile: # Open the file used to pass data into the bot
45 | json.dump( # Dump the requed data
46 | {
47 | "message" : f"{message}",
48 | "embed" : data,
49 | "cooldown" : cooldown
50 | },
51 | josnFile
52 | )
53 |
54 | print(r) # Reset the color
55 | self.start(token) # Start the bot using the start code
56 |
57 | def slow_type(self, text, speed, newLine = True): # Function used to print text a little more fancier
58 | for i in text: # Loop over the message
59 | print(i, end = "", flush = True) # Print the one charecter, flush is used to force python to print the char
60 | if i not in f"{r}{r2}{b}{w}":
61 | time.sleep(speed) # Sleep a little before the next one
62 | if newLine: # Check if the newLine argument is set to True
63 | print() # Print a final newline to make it act more like a normal print statement
64 |
65 | def emb_setup(self): # The function to setup embeds
66 | with open("EMBED.json", "w") as file: # Create the file embed.json
67 | file.write("") # Write an empty line in it
68 |
69 | self.slow_type(f"{r} [{w}!{r}] Place your embed data in the new file {b}\"EMBED.json\"{r} Press enter when done {b}", .02, newLine = False) # Tell the user to put the embed data in the file
70 | message = input("") # Wait for an awnser
71 |
72 | with open("EMBED.json", "r") as file: # Open the file agein in read mode
73 | data = json.load(file) # Read the file using a json parser
74 |
75 | os.remove("EMBED.json") # Remove the file
76 |
77 | return data # Return the data as a dict
78 |
79 |
80 | def start(self, token): # Function used to start the main bot
81 | Bot = bot.bot # Initialise the bot object ( This is a discord bot )
82 |
83 | Bot.run( # Run the bot with the token etc
84 | token
85 | )
86 |
87 | if __name__ == '__main__': # If the file is getting ran directly
88 | DMClient = DMAllBot() # Create the sniper class
89 | DMClient.main() # Run the main function
90 |
--------------------------------------------------------------------------------