Add endpoint for getting all discord IDs
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user