<?php
header('Content-Type: application/json');
require_once __DIR__ . '/db/config.php';

try {
    $db = db();
    $vc_id = $db->query("SELECT setting_value FROM bot_settings WHERE setting_key = 'voice_channel_id'")->fetchColumn();
    $source = $db->query("SELECT setting_value FROM bot_settings WHERE setting_key = 'sahur_source'")->fetchColumn();

    $message = "Test Sahur triggered. Joining VC ID: $vc_id and playing from source: $source";
    
    $stmt = $db->prepare("INSERT INTO bot_logs (log_level, message) VALUES ('info', ?)");
    $stmt->execute([$message]);

    echo json_encode(['success' => true]);
} catch (Exception $e) {
    echo json_encode(['success' => false, 'error' => $e->getMessage()]);
}
