The bot API now lets the website create raids without knowing a
Discord channel: POST /api/raids accepts guild_id and resolves the
target channel via the server's /set_raidchannel default. Adds a
"+ Neuer Raid" panel on raids.php (raids.manage only) with the same
title/date/max slots/gearscore grid and requirements textarea as the
edit form, plus the group-name row editor reused without its lock
toggle (data-locks="0" on .group-editor, since creation doesn't
support locked_groups) - one shared component instead of a second
implementation. Needs raids_api.guild_id in config.php, documented in
README.md.
Also updates the editor's "Speichern" flow for the API's other
change: PATCH /api/raids/{id} now auto-reposts the Discord message
(via sync_raid_message) if it was deleted manually, returning the new
raid_id. update_raid() now returns the API response instead of
discarding it, and raid_edit_action.php surfaces a distinct message
when the id changed - the page reload right after already picks up
the new id either way, since it re-fetches the raid list fresh.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
32 lines
1.2 KiB
PHP
32 lines
1.2 KiB
PHP
<?php
|
|
require_once __DIR__ . '/includes/bootstrap.php';
|
|
require_once __DIR__ . '/includes/raids_api.php';
|
|
require_permission('raids.manage');
|
|
|
|
$input = read_json_body();
|
|
verify_csrf_token($input['csrf_token'] ?? '');
|
|
|
|
$title = trim((string) ($input['title'] ?? ''));
|
|
$dateRaw = trim((string) ($input['date_raw'] ?? ''));
|
|
$requirements = trim((string) ($input['requirements'] ?? ''));
|
|
$groupNames = trim((string) ($input['group_names'] ?? ''));
|
|
$gearscore = trim((string) ($input['gearscore'] ?? ''));
|
|
$maxSlots = isset($input['max_slots']) && is_numeric($input['max_slots']) ? (int) $input['max_slots'] : 12;
|
|
|
|
if ($title === '' || $dateRaw === '' || $requirements === '' || $groupNames === '') {
|
|
json_response(false, 'Bitte Titel, Datum, Anforderungen und mindestens eine Gruppe angeben.');
|
|
}
|
|
|
|
try {
|
|
$result = create_raid([
|
|
'title' => $title,
|
|
'date_raw' => $dateRaw,
|
|
'requirements' => $requirements,
|
|
'group_names' => $groupNames,
|
|
'gearscore' => $gearscore,
|
|
'max_slots' => $maxSlots,
|
|
]);
|
|
json_response(true, 'Raid wurde erstellt.', ['raid_id' => $result['raid_id'] ?? null]);
|
|
} catch (Throwable $e) {
|
|
json_response(false, 'Erstellen fehlgeschlagen: ' . $e->getMessage());
|
|
}
|