Guest User

Untitled

a guest
May 11th, 2025
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.18 KB | Source Code | 0 0
  1. import requests
  2. import time
  3. from colorama import Fore, Style, init
  4.  
  5. # Initialize Colorama
  6. init()
  7.  
  8. # Webhook URL (Your Discord webhook URL)
  9. WEBHOOK_URL = "" # Replace this with your webhook URL
  10.  
  11. # Your Discord User ID (for pinging)
  12. USER_ID = "" # Your actual Discord User ID
  13.  
  14. # Check username availability
  15. def check_username(username):
  16. url = f"https://api.mojang.com/users/profiles/minecraft/{username}"
  17. try:
  18. response = requests.get(url)
  19. if response.status_code == 204: # Username is available
  20. return True
  21. return False
  22. except requests.exceptions.RequestException as e:
  23. print(f"{Fore.RED}Error while checking username '{username}': {e}{Style.RESET_ALL}")
  24. return False
  25.  
  26. # Function to send to Discord with a ping
  27. def send_to_discord(message):
  28. data = {
  29. "content": message
  30. }
  31.  
  32. try:
  33. response = requests.post(WEBHOOK_URL, json=data)
  34.  
  35. # Check the response status
  36. if response.status_code == 204:
  37. print(f"{Fore.GREEN}Message sent successfully to Discord!{Style.RESET_ALL}")
  38. else:
  39. print(f"{Fore.RED}Failed to send message. Status code: {response.status_code} Response: {response.text}{Style.RESET_ALL}")
  40. except Exception as e:
  41. print(f"{Fore.RED}Error while sending message to Discord: {e}{Style.RESET_ALL}")
  42.  
  43. # Function to check all usernames in the text file and send available/unavailable ones to Discord
  44. def check_and_send_usernames(filename):
  45. available_usernames = []
  46. unavailable_usernames = []
  47.  
  48. with open(filename, 'r') as file:
  49. usernames = file.readlines()
  50.  
  51. for i, username in enumerate(usernames):
  52. username = username.strip() # Remove any leading/trailing whitespace
  53. print(f"{Fore.YELLOW}Checking username: {username}...{Style.RESET_ALL}")
  54.  
  55. # Check if the username is available
  56. if check_username(username):
  57. print(f"{Fore.GREEN}Username '{username}' is available!{Style.RESET_ALL}")
  58. available_usernames.append(username)
  59.  
  60. # Ping the user on Discord when an available username is found
  61. message = f"<@{USER_ID}> Username '{username}' is available!"
  62. send_to_discord(message)
  63. else:
  64. print(f"{Fore.RED}Username '{username}' is not available.{Style.RESET_ALL}")
  65. unavailable_usernames.append(username)
  66.  
  67. # Sleep to avoid hitting rate limits or appearing like a bot
  68. time.sleep(1)
  69.  
  70. # Send available usernames to Discord
  71. if available_usernames:
  72. message = f"Available Minecraft usernames:\n" + "\n".join(available_usernames)
  73. send_to_discord(message)
  74. else:
  75. send_to_discord("No available usernames found.")
  76.  
  77. # Send unavailable usernames to Discord
  78. if unavailable_usernames:
  79. message = f"Unavailable Minecraft usernames:\n" + "\n".join(unavailable_usernames)
  80. send_to_discord(message)
  81.  
  82. # Run the script with the text file of usernames
  83. if __name__ == "__main__":
  84. # Specify your text file containing usernames
  85. check_and_send_usernames("usernames.txt") # Replace with your actual file path
Advertisement
Add Comment
Please, Sign In to add comment