From 2740abfdcb63bceea90a2480fbe9d045006444b5 Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 25 May 2025 19:59:31 -0400 Subject: [PATCH] Add endpoint for getting all discord IDs --- app/routers/bot.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/routers/bot.py b/app/routers/bot.py index 84bc3c7..4a2968d 100644 --- a/app/routers/bot.py +++ b/app/routers/bot.py @@ -13,6 +13,7 @@ async def get_online_bots_route(): return jsonify(list(current_app.active_clients.keys())) +# ------- Discord Token Functions @bot_bp.route('/request_token', methods=['POST']) async def request_token_route(): """ @@ -57,6 +58,24 @@ async def request_token_route(): abort(500, f"An internal error occurred: {e}") +@bot_bp.route('/tokens/', methods=['GET']) +async def get_all_discord_tokens(): + """ + API endpoint to return all discord IDs + """ + try: + # get the available IDs + active_d_ids = await current_app.d_id_db_h.find_discord_ids(active_only=False) + return jsonify([active_id.to_dict() for active_id in active_d_ids]) + + except Exception as e: + print(f"Error in request_token_route: {e}") + abort(500, f"An internal error occurred: {e}") + + + +# ------- Util Functions + def find_token_in_active_clients(target_token: str) -> bool: """ Checks if a target_token exists in the active_token of any ActiveClient object in a list.