Files
ephemere/python/cohort/list_all_guild_roles.py
T
naomi 4fdb5d06f1 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
2026-02-23 15:23:10 -08:00

62 lines
1.9 KiB
Python

#!/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())