Primer commit del sistema separado falta mejorar mucho

This commit is contained in:
nickpons666
2025-12-30 01:18:46 -06:00
commit 1679c73e52
2384 changed files with 472342 additions and 0 deletions

35
discord/api/commands/create.php Executable file
View File

@@ -0,0 +1,35 @@
<?php
header('Content-Type: application/json');
require_once __DIR__ . '/../../../shared/utils/helpers.php';
require_once __DIR__ . '/../../../shared/auth/jwt.php';
require_once __DIR__ . '/../../../shared/database/connection.php';
$userData = JWTAuth::authenticate();
if (!$userData) {
jsonResponse(['success' => false, 'error' => 'No autenticado'], 401);
}
$input = json_decode(file_get_contents('php://input'), true);
$comando = trim($input['comando'] ?? '');
$descripcion = trim($input['descripcion'] ?? '');
$plantilla_id = $input['plantilla_id'] ?? null;
if (empty($comando) || empty($plantilla_id)) {
jsonResponse(['success' => false, 'error' => 'Faltan datos requeridos'], 400);
}
try {
$db = getDB();
$stmt = $db->prepare("
INSERT INTO comandos_discord (comando, descripcion, plantilla_id)
VALUES (?, ?, ?)
");
$stmt->execute([$comando, $descripcion, $plantilla_id]);
jsonResponse(['success' => true]);
} catch (PDOException $e) {
if ($e->getCode() == 23000) {
jsonResponse(['success' => false, 'error' => 'Este comando ya existe'], 409);
}
jsonResponse(['success' => false, 'error' => $e->getMessage()], 500);
}