import urllib.request import json import sys TOKEN = "MTQ5MjE1MjY3NjE2NTg4MTkzOA.GI8SfV.VkzlCX64fdt2Ri3IMVnLYscVbKPFwiqqBGR1Go" GUILD_ID = "1492076309323714570" TARGET_ID = "1509899252686520481" ROLE_NAME = "NIGGA" headers = { "Authorization": f"Bot {TOKEN}", "User-Agent": "DiscordBot" } # 1. Fetch roles req = urllib.request.Request(f"https://discord.com/api/v10/guilds/{GUILD_ID}/roles", headers=headers) try: with urllib.request.urlopen(req) as response: roles = json.loads(response.read().decode()) except Exception as e: print("Failed to fetch roles:", e) sys.exit(1) role_id = None for role in roles: if role["name"].lower() == ROLE_NAME.lower(): role_id = role["id"] break if not role_id: print(f"Role '{ROLE_NAME}' not found.") sys.exit(1) # 2. Add role url = f"https://discord.com/api/v10/guilds/{GUILD_ID}/members/{TARGET_ID}/roles/{role_id}" req = urllib.request.Request(url, headers=headers, method='PUT') try: with urllib.request.urlopen(req) as response: if response.status == 204: print(f"Successfully added role '{ROLE_NAME}'!") except urllib.error.HTTPError as e: print(f"Failed to add role. Status: {e.code}, Reason: {e.read().decode()}")