generated from nhcarrigan/template
feat: port remaining cohort scripts and make reusable
- Port 19 cohort scripts from /home/naomi/docs/cohort/ - Replace all hardcoded tokens and dotenv usage with os.environ - Add pandas==3.0.1 dependency - Add E501 to ruff ignore list for Discord message string content - Make remove_resigned_members.py reusable (empty RESIGNED_IDS constant) - Make update_roster_messages.py reusable (iterates all teams from JSON) - Exclude 12 one-off/event-specific scripts as non-reusable
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env python3
|
||||
"""List all roles in the guild to find the correct team role IDs."""
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
import aiohttp
|
||||
|
||||
DISCORD_BOT_TOKEN = os.environ["DISCORD_BOT_TOKEN"]
|
||||
BASE_URL = "https://discord.com/api/v10"
|
||||
GUILD_ID = "1354624415861833870"
|
||||
|
||||
|
||||
async def list_guild_roles() -> None:
|
||||
"""List all roles in the guild, highlighting team-related ones."""
|
||||
url = f"{BASE_URL}/guilds/{GUILD_ID}/roles"
|
||||
headers = {"Authorization": f"Bot {DISCORD_BOT_TOKEN}"}
|
||||
|
||||
async with (
|
||||
aiohttp.ClientSession() as session,
|
||||
session.get(url, headers=headers) as resp,
|
||||
):
|
||||
if resp.status == 200:
|
||||
roles = await resp.json()
|
||||
print(f"Found {len(roles)} roles in the server:\n")
|
||||
|
||||
team_names = [
|
||||
"Jade Jasmine",
|
||||
"Crimson Dahlia",
|
||||
"Rose Camellia",
|
||||
"Amber Wisteria",
|
||||
"Ivory Orchid",
|
||||
"Teal Iris",
|
||||
"Peach Gardenia",
|
||||
"Violet Carnation",
|
||||
"Azure Lotus",
|
||||
"Coral Sunflower",
|
||||
"Indigo Tulip",
|
||||
"Scarlet Hydrangea",
|
||||
"Mint Narcissus",
|
||||
"Sage Marigold",
|
||||
"Cohort",
|
||||
]
|
||||
|
||||
for role in sorted(roles, key=lambda r: r["name"].lower()):
|
||||
name = role["name"]
|
||||
is_team = any(team in name for team in team_names)
|
||||
if is_team or "spring" in name.lower() or "2026" in name:
|
||||
print(f"✅ {role['id']}: {name}")
|
||||
|
||||
print("\n\nAll roles (sorted by name):")
|
||||
for role in sorted(roles, key=lambda r: r["name"].lower()):
|
||||
print(f"{role['id']}: {role['name']}")
|
||||
|
||||
else:
|
||||
error = await resp.text()
|
||||
print(f"Error: {resp.status} - {error}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(list_guild_roles())
|
||||
Reference in New Issue
Block a user