I made the code automatic and made it so it doesn't spam the console. It only sends a message in the console when it starts for the first time, and when a nitro code that works gets generated. Here are my changes, feel free to use, or ignore. The chances of getting a discord nitro out of this is low, but at least with how I updated the code it'll be faster.
I removed most of the print functions, that way the while loop doesn't spam the console lol, otherwise I would have kept them in.
import requests
import random
import string
while True:
num = 10
with open("Nitro Codes.txt", "w", encoding='utf-8') as file:
for i in range(num):
code = "".join(random.choices(
string.ascii_uppercase + string.digits + string.ascii_lowercase,
k = 16
))
file.write(f"https://discord.gift/{code}\n")
with open("Nitro Codes.txt") as file:
for line in file.readlines():
nitro = line.strip("\n")
url = f"https://discordapp.com/api/v9/entitlements/gift-codes/{nitro}?with_application=false&with_subscription_plan=true"
r = requests.get(url)
if r.status_code == 200:
print(f"\n\n Valid | {nitro}\n\n") #If the nitro code will be valid, it will print the code