Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
logicguy1
GitHub Repository: logicguy1/Discord-Nitro-Generator-and-Checker
Path: blob/main/main.py
525 views
1
import ctypes
2
import string
3
import os
4
import time
5
LICNECE = """
6
Copyright (c) 2021 Drillenissen#4268 [email protected]
7
8
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
10
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
12
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
"""
14
15
USE_WEBHOOK = True
16
17
print(LICNECE)
18
19
time.sleep(3)
20
os.system('cls' if os.name == 'nt' else 'clear')
21
22
23
try: # Check if the requrements have been installed
24
from discord_webhook import DiscordWebhook # Try to import discord_webhook
25
except ImportError: # If it chould not be installed
26
# Tell the user it has not been installed and how to install it
27
input(
28
f"Module discord_webhook not installed, to install run '{'py -3' if os.name == 'nt' else 'python3.8'} -m pip install discord_webhook'\nYou can ignore this error if you aren't going to use a webhook.\nPress enter to continue.")
29
USE_WEBHOOK = False
30
try: # Setup try statement to catch the error
31
import requests # Try to import requests
32
except ImportError: # If it has not been installed
33
# Tell the user it has not been installed and how to install it
34
input(
35
f"Module requests not installed, to install run '{'py -3' if os.name == 'nt' else 'python3.8'} -m pip install requests'\nPress enter to exit")
36
exit() # Exit the program
37
try: # Setup try statement to catch the error
38
import numpy # Try to import requests
39
except ImportError: # If it has not been installed
40
# Tell the user it has not been installed and how to install it
41
input(
42
f"Module numpy not installed, to install run '{'py -3' if os.name == 'nt' else 'python3.8'} -m pip install numpy'\nPress enter to exit")
43
exit() # Exit the program
44
45
# check if user is connected to internet
46
url = "https://github.com"
47
try:
48
response = requests.get(url) # Get the responce from the url
49
print("Internet check")
50
time.sleep(.4)
51
except requests.exceptions.ConnectionError:
52
# Tell the user
53
input("You are not connected to internet, check your connection and try again.\nPress enter to exit")
54
exit() # Exit program
55
56
57
class NitroGen: # Initialise the class
58
def __init__(self): # The initaliseaiton function
59
self.fileName = "Nitro Codes.txt" # Set the file name the codes are stored in
60
61
def main(self): # The main function contains the most important code
62
os.system('cls' if os.name == 'nt' else 'clear') # Clear the screen
63
if os.name == "nt": # If the system is windows
64
print("")
65
ctypes.windll.kernel32.SetConsoleTitleW(
66
"Nitro Generator and Checker - Made by Drillenissen#4268") # Change the
67
else: # Or if it is unix
68
print(f'\33]0;Nitro Generator and Checker - Made by Drillenissen#4268\a',
69
end='', flush=True) # Update title of command prompt
70
71
print(""" █████╗ ███╗ ██╗ ██████╗ ███╗ ██╗██╗██╗ ██╗
72
██╔══██╗████╗ ██║██╔═══██╗████╗ ██║██║╚██╗██╔╝
73
███████║██╔██╗ ██║██║ ██║██╔██╗ ██║██║ ╚███╔╝
74
██╔══██║██║╚██╗██║██║ ██║██║╚██╗██║██║ ██╔██╗
75
██║ ██║██║ ╚████║╚██████╔╝██║ ╚████║██║██╔╝ ██╗
76
╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝╚═╝ ╚═╝
77
""") # Print the title card
78
time.sleep(2) # Wait a few seconds
79
# Print who developed the code
80
self.slowType("Made by: Drillenissen#4268 && Benz#7274", .02)
81
time.sleep(1) # Wait a little more
82
# Print the first question
83
self.slowType(
84
"\nInput How Many Codes to Generate and Check: ", .02, newLine=False)
85
86
try:
87
num = int(input('')) # Ask the user for the amount of codes
88
except ValueError:
89
input("Specified input wasn't a number.\nPress enter to exit")
90
exit() # Exit program
91
92
if USE_WEBHOOK:
93
# Get the webhook url, if the user does not wish to use a webhook the message will be an empty string
94
self.slowType(
95
"If you want to use a Discord webhook, type it here or press enter to ignore: ", .02, newLine=False)
96
url = input('') # Get the awnser
97
# If the url is empty make it be None insted
98
webhook = url if url != "" else None
99
100
if webhook is not None:
101
DiscordWebhook( # Let the user know it has started logging the ids
102
url=url,
103
content=f"```Started checking urls\nI will send any valid codes here```"
104
).execute()
105
106
# print() # Print a newline for looks
107
108
valid = [] # Keep track of valid codes
109
invalid = 0 # Keep track of how many invalid codes was detected
110
chars = []
111
chars[:0] = string.ascii_letters + string.digits
112
113
# generate codes faster than using random.choice
114
c = numpy.random.choice(chars, size=[num, 16])
115
for s in c: # Loop over the amount of codes to check
116
try:
117
code = ''.join(x for x in s)
118
url = f"https://discord.gift/{code}" # Generate the url
119
120
result = self.quickChecker(url, webhook) # Check the codes
121
122
if result: # If the code was valid
123
# Add that code to the list of found codes
124
valid.append(url)
125
else: # If the code was not valid
126
invalid += 1 # Increase the invalid counter by one
127
except KeyboardInterrupt:
128
# If the user interrupted the program
129
print("\nInterrupted by user")
130
break # Break the loop
131
132
except Exception as e: # If the request fails
133
print(f" Error | {url} ") # Tell the user an error occurred
134
135
if os.name == "nt": # If the system is windows
136
ctypes.windll.kernel32.SetConsoleTitleW(
137
f"Nitro Generator and Checker - {len(valid)} Valid | {invalid} Invalid - Made by Drillenissen#4268") # Change the title
138
print("")
139
else: # If it is a unix system
140
# Change the title
141
print(
142
f'\33]0;Nitro Generator and Checker - {len(valid)} Valid | {invalid} Invalid - Made by Drillenissen#4268\a', end='', flush=True)
143
144
print(f"""
145
Results:
146
Valid: {len(valid)}
147
Invalid: {invalid}
148
Valid Codes: {', '.join(valid)}""") # Give a report of the results of the check
149
150
# Tell the user the program finished
151
input("\nThe end! Press Enter 5 times to close the program.")
152
[input(i) for i in range(4, 0, -1)] # Wait for 4 enter presses
153
154
# Function used to print text a little more fancier
155
def slowType(self, text: str, speed: float, newLine=True):
156
for i in text: # Loop over the message
157
# Print the one charecter, flush is used to force python to print the char
158
print(i, end="", flush=True)
159
time.sleep(speed) # Sleep a little before the next one
160
if newLine: # Check if the newLine argument is set to True
161
print() # Print a final newline to make it act more like a normal print statement
162
163
def quickChecker(self, nitro:str, notify=None): # Used to check a single code at a time
164
# Generate the request url
165
url = f"https://discordapp.com/api/v9/entitlements/gift-codes/{nitro}?with_application=false&with_subscription_plan=true"
166
response = requests.get(url) # Get the response from discord
167
168
if response.status_code == 200: # If the responce went through
169
# Notify the user the code was valid
170
print(f" Valid | {nitro} ", flush=True,
171
end="" if os.name == 'nt' else "\n")
172
with open("Nitro Codes.txt", "w") as file: # Open file to write
173
# Write the nitro code to the file it will automatically add a newline
174
file.write(nitro)
175
176
if notify is not None: # If a webhook has been added
177
DiscordWebhook( # Send the message to discord letting the user know there has been a valid nitro code
178
url=url,
179
content=f"Valid Nito Code detected! @everyone \n{nitro}"
180
).execute()
181
182
return True # Tell the main function the code was found
183
184
# If the responce got ignored or is invalid ( such as a 404 or 405 )
185
else:
186
# Tell the user it tested a code and it was invalid
187
print(f" Invalid | {nitro} ", flush=True,
188
end="" if os.name == 'nt' else "\n")
189
return False # Tell the main function there was not a code found
190
191
192
if __name__ == '__main__':
193
Gen = NitroGen() # Create the nitro generator object
194
Gen.main() # Run the main code
195
196