Advertisement
A_GUES

discord bot

Jun 22nd, 2023 (edited)
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.54 KB | None | 0 0
  1. from time import localtime, strftime, sleep
  2. from colorama import Fore
  3. import requests
  4. import random
  5. import string
  6. import os
  7. from flask import Flask
  8. from threading import Thread
  9.  
  10. app = Flask(__name__)
  11.  
  12. @app.route('/')
  13. def index():
  14.     return "Alive"
  15.  
  16. def keep_alive():
  17.     t = Thread(target=app.run, kwargs={'host': '0.0.0.0', 'port': 8080})
  18.     t.start()
  19.  
  20. class SapphireGen:
  21.     def __init__(self, code_type: str, prox=None, codes=None):
  22.         self.type = code_type
  23.         self.codes = codes
  24.         self.proxies = prox
  25.         self.session = requests.Session()
  26.         self.prox_api = "https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/http.txt"
  27.  
  28.     def __proxies__(self):
  29.         req = self.session.get(self.prox_api).text
  30.         if req:
  31.             with open("./data/proxies.txt", "w") as f:
  32.                 f.write(req)
  33.  
  34.     def webhook(self, message):
  35.         url = "https://example.com/webhook"  # Replace with your webhook URL
  36.         data = {"content": message, "username": "N"}
  37.         result = requests.post(url, json=data)
  38.  
  39.         try:
  40.             result.raise_for_status()
  41.         except requests.exceptions.HTTPError as err:
  42.             print(err)
  43.         else:
  44.             print("Payload delivered successfully, code {}.".format(result.status_code))
  45.  
  46.     def generate(self, scrape=False):
  47.         if scrape:
  48.             self.__proxies__()
  49.         else:
  50.             pass
  51.  
  52.         os.system("clear")
  53.         for _ in range(int(self.codes)):
  54.             sleep(35)
  55.             try:
  56.                 if self.proxies:
  57.                     with open("./data/proxies.txt", "r") as f:
  58.                         prox = {
  59.                             "http": random.choice(f.read().splitlines())
  60.                         }
  61.                 else:
  62.                     prox = None
  63.  
  64.                 if self.type == "boost":
  65.                     code = "".join(
  66.                         random.choice(string.ascii_letters + string.digits)
  67.                         for i in range(24)
  68.                     )
  69.                 else:
  70.                     code = "".join(
  71.                         random.choice(string.ascii_letters + string.digits)
  72.                         for i in range(16)
  73.                     )
  74.                 req = self.session.get(
  75.                     f"https://discord.com/api/v9/entitlements/gift-codes/{code}",
  76.                     proxies=prox,
  77.                     timeout=10,
  78.                 ).status_code
  79.                 if req == 200:
  80.                     print(f"{Fore.GREEN}<{strftime('%H:%M', localtime())}> discord.gift/{code} | valid")
  81.                     self.webhook(code)
  82.  
  83.                 if req == 404:
  84.                     print(f"{Fore.RED}<{strftime('%H:%M', localtime())}> discord.gift/{code} | invalid")
  85.  
  86.                 if req == 429:
  87.                     print(f"{Fore.YELLOW}<{strftime('%H:%M', localtime())}> discord.gift/{code} | ratelimited")
  88.  
  89.             except Exception as e:
  90.                 print(f"{Fore.RED}<{strftime('%H:%M', localtime())}> {e}")
  91.  
  92.         print(f"{Fore.LIGHTMAGENTA_EX}<{strftime('%H:%M', localtime())}> Successfully checked {self.codes} codes.")
  93.         sleep(10)
  94.         os.system("clear")
  95.  
  96. if __name__ == "__main__":
  97.     code_type = 'classic'
  98.     prox = False
  99.  
  100.     if prox:
  101.         scrape_proxy = input(f"{Fore.LIGHTMAGENTA_EX}<{strftime('%H:%M', localtime())}> Scrape proxies (y/n): ").lower() == "y"
  102.     else:
  103.         scrape_proxy = False
  104.     codes = 100000
  105.     SapphireGen(code_type, prox, codes).generate(scrape=scrape_proxy)
  106.     keep_alive()
  107.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement