This program is designed to automatically generate and verify Discord gift codes. It uses Discord's APIs to check the validity of the generated codes and sends the results to a Discord webhook.
The program generates a series of gift codes using a combination of lowercase characters and digits. Below is an example of a function that generates a gift code:
def generate_random_string(length):
characters = string.ascii_lowercase + string.digits
return ''.join(random.choice(characters) for _ in range(length))
The generated codes are verified through HTTP requests to Discord's APIs. Below is an example of a function that verifies a gift code using asyncio:
async def check_gift_code(code, client):
url = f"https://discordapp.com/api/v9/entitlements/gift-codes/{code}?with_application=false&with_subscription_plan=true"
response = await client.get(url)
if response.status_code == 200:
return True
return False
If a code is valid, the program sends a message containing the code and a direct link to the gift code on Discord. Below is an example of a function that sends a message to a Discord webhook:
async def send_to_discord_webhook(message):
async with httpx.AsyncClient() as client:
payload = {
"content": message
}
await client.post(discord_webhook_url, json=payload)
The program utilizes various techniques to generate a large number of gift codes efficiently.
Gift codes are randomly generated by selecting characters from the allowed character set. Below is an example of random generation of a gift code:
codes = [''.join(random.choices(character_set, k=18)) for _ in range(1000)]
To speed up the generation process, the program employs concurrency. Below is an example of concurrent generation of gift codes using asyncio:
async with httpx.AsyncClient() as client:
tasks = [check_gift_code(code, client) for code in codes]
results = await asyncio.gather(*tasks)
After generating and verifying the gift codes, the program starts a user interface to display the results. Below is an example of starting the graphical user interface using Tkinter:
root = tk.Tk()
app = DiscordCodeCheckerGUI(root)
root.mainloop()