Fetch the application ID from the token (same as bot user ID for bots).
(token: str)
| 68 | |
| 69 | |
| 70 | def get_application_id(token: str) -> str | None: |
| 71 | """Fetch the application ID from the token (same as bot user ID for bots).""" |
| 72 | try: |
| 73 | response = requests.get( |
| 74 | f"{DISCORD_API_BASE}/users/@me", |
| 75 | headers={"Authorization": f"Bot {token}"}, |
| 76 | timeout=10, |
| 77 | ) |
| 78 | if response.status_code == 200: |
| 79 | return response.json().get("id") |
| 80 | except Exception: |
| 81 | pass |
| 82 | return None |
| 83 | |
| 84 | |
| 85 | def build_invite_url(application_id: str, permissions: int = BOT_PERMISSIONS) -> str: |