Musik: Siel als zweiter Musikbot - Umschalter Nezekan/Siel im Player (eigener Kanal, Warteschlange und Playlist je Bot), musik_api.php leitet je nach bot= an Nezekan (/api/music) oder Siel (/website-api/music, siel_api in config.php)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
1a08aebaa6
commit
e2bdbbc846
6 changed files with 112 additions and 35 deletions
|
|
@ -10213,6 +10213,10 @@ a.hunt-review-spot-thumb { width: 64px; height: 40px; flex-shrink: 0; }
|
|||
.music-connection.is-online::before { background: #4caf50; box-shadow: 0 0 8px rgba(76, 175, 80, 0.8); }
|
||||
.music-connection.is-offline { background: rgba(217, 83, 79, 0.14); color: #f2a19e; }
|
||||
.music-connection.is-offline::before { background: #d9534f; }
|
||||
.music-bots { display: inline-flex; margin-left: auto; padding: 3px; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 999px; background: rgba(0, 0, 0, 0.25); }
|
||||
.music-bots button { padding: 0.25rem 0.9rem; border: 0; border-radius: 999px; background: none; box-shadow: none; color: var(--text-muted); font-size: 0.8rem; font-weight: 500; transition: background 0.15s, color 0.15s; }
|
||||
.music-bots button:hover { color: var(--text); box-shadow: none; }
|
||||
.music-bots button.is-on { background: var(--gold); color: #1a1408; }
|
||||
|
||||
.music-now { display: flex; align-items: center; gap: 1.5rem; }
|
||||
.music-art { position: relative; flex: none; width: 124px; height: 124px; }
|
||||
|
|
@ -10318,6 +10322,7 @@ ol.music-list li:not(.music-empty)::before { counter-increment: music; content:
|
|||
}
|
||||
@media (max-width: 560px) {
|
||||
.music-hero { padding: 1.2rem 1.1rem; }
|
||||
.music-bots { margin-left: 0; }
|
||||
.music-now { gap: 1rem; }
|
||||
.music-art { width: 80px; height: 80px; }
|
||||
.music-disc span { inset: 28px; }
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@
|
|||
var svg = function (name) {
|
||||
return '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">' + ICON_PATHS[name] + '</svg>';
|
||||
};
|
||||
// Welcher Bot gesteuert wird (nezekan | siel) - zuletzt gewaehlter bleibt im Browser gemerkt
|
||||
var bots = (root.dataset.bots || 'nezekan').split(',');
|
||||
var bot = bots[0];
|
||||
try { if (bots.indexOf(localStorage.getItem('music.bot')) !== -1) bot = localStorage.getItem('music.bot'); } catch (e) { /* kein Speicher */ }
|
||||
var state = null;
|
||||
var stateAt = 0;
|
||||
var busy = false;
|
||||
|
|
@ -41,6 +45,7 @@
|
|||
var s = seconds % 60;
|
||||
return (h ? h + ':' + String(m).padStart(2, '0') : m) + ':' + String(s).padStart(2, '0');
|
||||
};
|
||||
var botName = function () { return bots.length > 1 ? bot.charAt(0).toUpperCase() + bot.slice(1) : 'Der Bot'; };
|
||||
var sourceDot = function (source) {
|
||||
var dot = document.createElement('i');
|
||||
dot.className = 'music-src is-' + (source || 'file');
|
||||
|
|
@ -62,6 +67,7 @@
|
|||
var request = function (fields, file) {
|
||||
var body = new FormData();
|
||||
body.append('csrf_token', csrf);
|
||||
body.append('bot', bot);
|
||||
Object.keys(fields).forEach(function (key) { if (fields[key] !== null && fields[key] !== undefined) body.append(key, fields[key]); });
|
||||
if (file) body.append('file', file);
|
||||
return fetch('/musik_api.php', {
|
||||
|
|
@ -73,10 +79,11 @@
|
|||
var act = function (fields, file) {
|
||||
busy = true;
|
||||
root.classList.add('is-busy');
|
||||
var forBot = bot;
|
||||
return request(fields, file)
|
||||
.then(function (result) {
|
||||
if (!result.ok) throw new Error(result.error || 'Hat nicht geklappt.');
|
||||
if (result.music) render(result.music);
|
||||
if (result.music && forBot === bot) render(result.music);
|
||||
toast(result.message);
|
||||
return result;
|
||||
})
|
||||
|
|
@ -98,11 +105,12 @@
|
|||
|
||||
var poll = function () {
|
||||
if (document.hidden || busy) return;
|
||||
fetch('/musik_api.php?action=state', { credentials: 'same-origin', headers: { 'Accept': 'application/json' } })
|
||||
var forBot = bot;
|
||||
fetch('/musik_api.php?action=state&bot=' + encodeURIComponent(bot), { credentials: 'same-origin', headers: { 'Accept': 'application/json' } })
|
||||
.then(function (response) { return response.json(); })
|
||||
.then(function (result) {
|
||||
if (!result.ok) throw new Error(result.error || 'Bot nicht erreichbar');
|
||||
render(result.music);
|
||||
if (forBot === bot) render(result.music);
|
||||
})
|
||||
.catch(function (error) {
|
||||
var connection = $('[data-music-connection]');
|
||||
|
|
@ -234,7 +242,8 @@
|
|||
state = music;
|
||||
stateAt = Date.now();
|
||||
var connection = $('[data-music-connection]');
|
||||
connection.textContent = music.connected ? 'Im Sprachkanal ' + music.channel.name : 'Nicht im Sprachkanal';
|
||||
connection.textContent = (bots.length > 1 ? bot.charAt(0).toUpperCase() + bot.slice(1) + ' · ' : '')
|
||||
+ (music.connected ? 'Im Sprachkanal ' + music.channel.name : 'Nicht im Sprachkanal');
|
||||
connection.className = 'music-connection' + (music.connected ? ' is-online' : '');
|
||||
root.classList.toggle('is-playing', !!(music.current && !music.paused));
|
||||
root.classList.toggle('is-paused', !!music.paused);
|
||||
|
|
@ -299,8 +308,8 @@
|
|||
select.value = chosen;
|
||||
}
|
||||
$('[data-music-channel] span').textContent = music.connected
|
||||
? 'Der Bot ist in ' + music.channel.name + ' – ' + music.channel.listeners + ' Zuhörer'
|
||||
: 'Der Bot ist in keinem Sprachkanal.';
|
||||
? botName() + ' ist in ' + music.channel.name + ' – ' + music.channel.listeners + ' Zuhörer'
|
||||
: botName() + ' ist in keinem Sprachkanal.';
|
||||
$('[data-music-leave]').hidden = !music.connected;
|
||||
$('[data-music-join]').textContent = music.connected ? 'Umziehen' : 'Holen';
|
||||
|
||||
|
|
@ -310,6 +319,22 @@
|
|||
};
|
||||
|
||||
// ---- Bedienung ----
|
||||
var switchBot = function (key) {
|
||||
if (key === bot || bots.indexOf(key) === -1) return;
|
||||
bot = key;
|
||||
try { localStorage.setItem('music.bot', key); } catch (e) { /* kein Speicher */ }
|
||||
root.querySelectorAll('[data-music-bot]').forEach(function (b) { b.classList.toggle('is-on', b.dataset.musicBot === key); });
|
||||
signatures = {};
|
||||
state = null;
|
||||
$('[data-music-channels]').value = '';
|
||||
$('[data-music-connection]').textContent = 'Verbinde mit dem Bot …';
|
||||
$('[data-music-connection]').className = 'music-connection';
|
||||
poll();
|
||||
};
|
||||
root.querySelectorAll('[data-music-bot]').forEach(function (button) {
|
||||
button.addEventListener('click', function () { switchBot(button.dataset.musicBot); });
|
||||
});
|
||||
root.querySelectorAll('[data-music-bot]').forEach(function (b) { b.classList.toggle('is-on', b.dataset.musicBot === bot); });
|
||||
root.querySelectorAll('[data-music-control]').forEach(function (button) {
|
||||
button.addEventListener('click', function () {
|
||||
if (button.dataset.musicControl === 'clear' && !window.confirm('Warteschlange leeren?')) return;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,14 @@
|
|||
<?php
|
||||
/**
|
||||
* Musik im Discord-Sprachkanal (Nezekan-Bot, cogs/music.py + music_api.py auf dem Bot): Steuerung von der
|
||||
* Website aus (musik.php, musik_api.php, assets/js/music.js). Abspielen lassen sich die Playlist der Legion
|
||||
* (eigene Dateien, Upload mit music.manage), YouTube-/YouTube-Music-Links, Spotify-Links und eine freie Suche -
|
||||
* aufgeloest und abgespielt wird alles auf dem Bot, die Website schickt nur Befehle.
|
||||
* Musik im Discord-Sprachkanal: Steuerung von der Website aus (musik.php, musik_api.php, assets/js/music.js).
|
||||
* Abspielen lassen sich die Playlist des Bots (eigene Dateien, Upload mit music.manage), YouTube-/YouTube-Music-
|
||||
* Links, Spotify-Links und eine freie Suche - aufgeloest und abgespielt wird alles auf dem Bot, die Website
|
||||
* schickt nur Befehle.
|
||||
*
|
||||
* Zwei Bots, weil ein Bot pro Discord-Server nur in einem Sprachkanal sein kann (MUSIC_BOTS):
|
||||
* nezekan Nezekan (raids_api in config.php), cogs/music.py + music_api.py, Pfade /api/music/...
|
||||
* siel Siel (siel_api in config.php, nur wenn eingerichtet), gleicher Code, Pfade /website-api/music/...
|
||||
* Jeder Bot hat seine eigene Playlist (Dateien liegen beim jeweiligen Bot).
|
||||
*/
|
||||
require_once __DIR__ . '/raids_api.php';
|
||||
require_once __DIR__ . '/events_api.php';
|
||||
|
|
@ -14,28 +19,55 @@ const MUSIC_UPLOAD_MAX = 25 * 1024 * 1024;
|
|||
const MUSIC_UPLOAD_EXTENSIONS = ['mp3', 'ogg', 'm4a', 'wav', 'flac', 'opus'];
|
||||
const MUSIC_QUERY_MAX = 500;
|
||||
const MUSIC_ACTIONS = ['toggle', 'pause', 'resume', 'skip', 'stop', 'shuffle', 'loop', 'volume', 'remove', 'clear', 'move', 'jump', 'seek'];
|
||||
const MUSIC_BOTS = ['nezekan' => 'Nezekan', 'siel' => 'Siel'];
|
||||
|
||||
/** Basis der Bot-API (eine Ebene ueber /api/raids). */
|
||||
function music_api_base(): string
|
||||
/**
|
||||
* Die Musikbots, die eingerichtet sind: Schluessel => Anzeigename. Nezekan immer, Siel nur mit siel_api in config.php.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
function music_bots(): array
|
||||
{
|
||||
return (string) preg_replace('#/raids$#', '', raids_api_config()['url']);
|
||||
$bots = ['nezekan' => MUSIC_BOTS['nezekan']];
|
||||
if (siel_api_config() !== null) {
|
||||
$bots['siel'] = MUSIC_BOTS['siel'];
|
||||
}
|
||||
return $bots;
|
||||
}
|
||||
|
||||
/** Prueft einen Bot-Schluessel aus der Anfrage; unbekannt oder nicht eingerichtet = null. */
|
||||
function music_bot_key(string $bot): ?string
|
||||
{
|
||||
return array_key_exists($bot, music_bots()) ? $bot : null;
|
||||
}
|
||||
|
||||
/** Basis der Musik-API des Bots: eine Ebene ueber .../raids (Nezekan: /api, Siel: /website-api). */
|
||||
function music_api_base(string $bot): string
|
||||
{
|
||||
$config = $bot === 'siel' ? siel_api_config() : raids_api_config();
|
||||
if ($config === null) {
|
||||
throw new RuntimeException('Siel ist nicht eingerichtet (config.php: siel_api).');
|
||||
}
|
||||
return (string) preg_replace('#/raids$#', '', $config['url']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Aufruf der Musik-API des Bots.
|
||||
* Aufruf der Musik-API eines Bots.
|
||||
*
|
||||
* @param string $bot 'nezekan' oder 'siel' (music_bots())
|
||||
* @param array<string, mixed>|null $json JSON-Body
|
||||
* @param array{0: string, 1: string, 2: string}|null $file [Pfad, Dateiname, Titel] fuer den Upload (multipart)
|
||||
* @return array<string, mixed>
|
||||
* @throws RuntimeException mit verstaendlicher Meldung
|
||||
*/
|
||||
function music_api_request(string $method, string $path, ?array $json = null, ?array $file = null): array
|
||||
function music_api_request(string $bot, string $method, string $path, ?array $json = null, ?array $file = null): array
|
||||
{
|
||||
if (!function_exists('curl_init')) {
|
||||
throw new RuntimeException('Die PHP-cURL-Erweiterung ist auf diesem Server nicht aktiviert.');
|
||||
}
|
||||
$headers = ['X-API-Key: ' . raids_api_config()['key']];
|
||||
$ch = curl_init(music_api_base() . $path);
|
||||
$key = $bot === 'siel' ? (string) (siel_api_config()['key'] ?? '') : (string) raids_api_config()['key'];
|
||||
$headers = ['X-API-Key: ' . $key];
|
||||
$ch = curl_init(music_api_base($bot) . $path);
|
||||
$options = [
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_CUSTOMREQUEST => $method,
|
||||
|
|
@ -59,12 +91,12 @@ function music_api_request(string $method, string $path, ?array $json = null, ?a
|
|||
$error = curl_error($ch);
|
||||
curl_close($ch);
|
||||
if ($response === false) {
|
||||
throw new RuntimeException('Der Bot ist gerade nicht erreichbar (' . $error . ').');
|
||||
throw new RuntimeException(MUSIC_BOTS[$bot] . ' ist gerade nicht erreichbar (' . $error . ').');
|
||||
}
|
||||
$data = json_decode((string) $response, true);
|
||||
if ($status < 200 || $status >= 300) {
|
||||
$detail = is_array($data) ? ($data['detail'] ?? $data['message'] ?? '') : '';
|
||||
throw new RuntimeException(is_string($detail) && $detail !== '' ? $detail : 'Der Bot antwortet mit Status ' . $status . '.');
|
||||
throw new RuntimeException(is_string($detail) && $detail !== '' ? $detail : MUSIC_BOTS[$bot] . ' antwortet mit Status ' . $status . '.');
|
||||
}
|
||||
if (!is_array($data)) {
|
||||
throw new RuntimeException('Unerwartete Antwort vom Bot.');
|
||||
|
|
@ -72,8 +104,8 @@ function music_api_request(string $method, string $path, ?array $json = null, ?a
|
|||
return $data;
|
||||
}
|
||||
|
||||
/** Zustand der Musik auf dem Legions-Server (Kanal, Titel, Warteschlange, Playlist). */
|
||||
function music_state(): array
|
||||
/** Zustand der Musik eines Bots auf dem Legions-Server (Kanal, Titel, Warteschlange, Verlauf, Playlist). */
|
||||
function music_state(string $bot): array
|
||||
{
|
||||
return (array) (music_api_request('GET', '/music/' . events_guild_id())['music'] ?? []);
|
||||
return (array) (music_api_request($bot, 'GET', '/music/' . events_guild_id())['music'] ?? []);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ const PATCHNOTES = [
|
|||
'changes' => [
|
||||
['type' => 'neu', 'area' => 'Musik', 'text' => 'Neue Seite „Musik“: Bot in einen Sprachkanal holen oder rausschicken, YouTube-/YouTube-Music-/Spotify-Links (auch Playlists und Alben) oder einfach einen Suchbegriff abspielen, Warteschlange ansehen, Titel überspringen, pausieren, Zufall, Schleife und Lautstärke.'],
|
||||
['type' => 'neu', 'area' => 'Discord', 'text' => 'Dasselbe geht im Discord mit /musik (join, play, skip, pause, weiter, stop, leave, …). Nach 5 Minuten allein im Kanal geht der Bot von selbst.'],
|
||||
['type' => 'neu', 'area' => 'Musik', 'text' => 'Zwei Musikbots: Neben Nezekan spielt auch Siel bei uns Musik – ein Bot kann nur in einem Sprachkanal sein, mit zweien läuft Musik in zwei Kanälen gleichzeitig. Oben im Player wählst du den Bot; im Discord heißt es bei beiden /musik. Jeder Bot hat seine eigene Playlist.'],
|
||||
['type' => 'verbessert', 'area' => 'Musik', 'text' => 'Musik gibt es ab dem Rang Legionär – auf der Website über das Recht music.control der Rang-Gruppen, im Discord prüft der Bot die Rolle. Rekruten sehen die Seite nicht und bekommen bei /musik einen Hinweis.'],
|
||||
['type' => 'neu', 'area' => 'Musik', 'text' => 'Zum laufenden Titel gibt es das Vorschaubild, wer ihn gewünscht hat und was als Nächstes kommt. Ein Klick in den Fortschrittsbalken spult, Leertaste pausiert, N springt weiter. In der Warteschlange lässt sich ein Titel nach vorn holen (⤴), sofort abspielen (▶) oder entfernen. Unter „Zuletzt gespielt“ holst du einen Titel mit ↻ noch einmal. Ist der Bot in keinem Kanal, kommt er beim Abspielen gleich in den gewählten.'],
|
||||
['type' => 'neu', 'area' => 'Musik', 'audience' => 'leitung', 'text' => 'Eigene Audiodateien (mp3, ogg, m4a, wav, flac, opus – bis 25 MB) für die Playlist der Legion hochladen und löschen, auf der Seite oder mit /musik hochladen. Dafür gibt es das neue Recht „music.manage“, das die Leitung in der Rollenverwaltung vergibt.'],
|
||||
|
|
|
|||
12
musik.php
12
musik.php
|
|
@ -9,13 +9,21 @@ require_once __DIR__ . '/includes/music.php';
|
|||
require_permission('music.control');
|
||||
|
||||
$canManage = user_has_permission('music.manage');
|
||||
$bots = music_bots(); // mehrere Bots = Umschalter im Player, jeder mit eigenem Kanal, Warteschlange und Playlist
|
||||
$pageTitle = 'Musik';
|
||||
include __DIR__ . '/includes/header.php';
|
||||
?>
|
||||
<div class="music-page" data-music data-can-manage="<?= $canManage ? '1' : '0' ?>">
|
||||
<div class="music-page" data-music data-can-manage="<?= $canManage ? '1' : '0' ?>" data-bots="<?= e(implode(',', array_keys($bots))) ?>">
|
||||
<section class="panel music-hero">
|
||||
<div class="music-hero-head">
|
||||
<h1>Musik</h1>
|
||||
<?php if (count($bots) > 1): ?>
|
||||
<div class="music-bots" role="group" aria-label="Musikbot" title="Zwei Bots: jeder kann in einem anderen Sprachkanal spielen">
|
||||
<?php foreach ($bots as $key => $label): ?>
|
||||
<button type="button" data-music-bot="<?= e($key) ?>"<?= $key === 'nezekan' ? ' class="is-on"' : '' ?>><?= e($label) ?></button>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<span class="music-connection" data-music-connection>Verbinde mit dem Bot …</span>
|
||||
</div>
|
||||
<div class="music-now">
|
||||
|
|
@ -88,7 +96,7 @@ include __DIR__ . '/includes/header.php';
|
|||
|
||||
<section class="panel music-card">
|
||||
<div class="music-card-head">
|
||||
<h2>Playlist der Legion <span data-music-tracks-count></span></h2>
|
||||
<h2>Playlist <span data-music-tracks-count></span></h2>
|
||||
<button type="button" class="music-text-btn" data-music-play-all>Alle abspielen</button>
|
||||
</div>
|
||||
<input type="search" class="music-filter" placeholder="Playlist durchsuchen …" aria-label="Playlist durchsuchen" data-music-filter>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
* Musik-Steuerung der Seite musik.php (assets/js/music.js) - leitet an die Musik-API des Bots weiter
|
||||
* (includes/music.php). Antwortet immer mit JSON {ok, message|error, music}.
|
||||
*
|
||||
* Jede Anfrage traegt bot=nezekan|siel (music_bots(); fehlt es, Nezekan).
|
||||
* GET ?action=state Zustand (Kanal, Titel, Warteschlange, Sprachkanaele, Playlist)
|
||||
* POST action=join, channel_id Bot in einen Sprachkanal holen
|
||||
* POST action=leave Bot aus dem Sprachkanal schicken
|
||||
|
|
@ -39,6 +40,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||
http_response_code(405);
|
||||
$reply(false, 'Nur per POST.');
|
||||
}
|
||||
$bot = music_bot_key((string) ($_POST['bot'] ?? $_GET['bot'] ?? 'nezekan'));
|
||||
if ($bot === null) {
|
||||
http_response_code(400);
|
||||
$reply(false, 'Diesen Musikbot gibt es nicht.');
|
||||
}
|
||||
// Die Bot-API kann etwas dauern (Playlists) - andere Seiten derselben Sitzung sollen nicht warten
|
||||
session_write_close();
|
||||
|
||||
|
|
@ -46,18 +52,18 @@ $guild = '/music/' . events_guild_id();
|
|||
try {
|
||||
switch ($action) {
|
||||
case 'state':
|
||||
$reply(true, '', ['music' => music_state()]);
|
||||
$reply(true, '', ['music' => music_state($bot), 'bot' => $bot]);
|
||||
|
||||
case 'join':
|
||||
$channel = (string) ($_POST['channel_id'] ?? '');
|
||||
if (!ctype_digit($channel)) {
|
||||
$reply(false, 'Bitte einen Sprachkanal wählen.');
|
||||
}
|
||||
$data = music_api_request('POST', $guild . '/join', ['channel_id' => (int) $channel]);
|
||||
$data = music_api_request($bot, 'POST', $guild . '/join', ['channel_id' => (int) $channel]);
|
||||
$reply(true, (string) ($data['message'] ?? ''), ['music' => $data['music'] ?? null]);
|
||||
|
||||
case 'leave':
|
||||
$data = music_api_request('POST', $guild . '/leave', []);
|
||||
$data = music_api_request($bot, 'POST', $guild . '/leave', []);
|
||||
$reply(true, (string) ($data['message'] ?? ''), ['music' => $data['music'] ?? null]);
|
||||
|
||||
case 'play':
|
||||
|
|
@ -65,7 +71,7 @@ try {
|
|||
$query = mb_substr(trim((string) ($_POST['query'] ?? '')), 0, MUSIC_QUERY_MAX);
|
||||
$channel = (string) ($_POST['channel_id'] ?? '');
|
||||
$user = current_user();
|
||||
$data = music_api_request('POST', $guild . '/play', [
|
||||
$data = music_api_request($bot, 'POST', $guild . '/play', [
|
||||
'query' => $query,
|
||||
'user' => (string) ($user['display_name'] !== '' ? $user['display_name'] : $user['username']),
|
||||
'channel_id' => ctype_digit($channel) ? (int) $channel : null,
|
||||
|
|
@ -78,7 +84,7 @@ try {
|
|||
$reply(false, 'Unbekannte Aktion.');
|
||||
}
|
||||
$value = isset($_POST['value']) && is_numeric($_POST['value']) ? (int) $_POST['value'] : null;
|
||||
$data = music_api_request('POST', $guild . '/control', ['action' => $control, 'value' => $value]);
|
||||
$data = music_api_request($bot, 'POST', $guild . '/control', ['action' => $control, 'value' => $value]);
|
||||
$reply(true, (string) ($data['message'] ?? ''), ['music' => $data['music'] ?? null]);
|
||||
|
||||
case 'upload':
|
||||
|
|
@ -100,10 +106,10 @@ try {
|
|||
}
|
||||
$title = mb_substr(trim((string) ($_POST['title'] ?? '')), 0, 100);
|
||||
$name = mb_substr(basename((string) $file['name']), 0, 150);
|
||||
$data = music_api_request('POST', '/music/tracks', null, [$file['tmp_name'], $name, $title]);
|
||||
$data = music_api_request($bot, 'POST', '/music/tracks', null, [$file['tmp_name'], $name, $title]);
|
||||
$track = (array) ($data['track'] ?? []);
|
||||
admin_log('🎵 Musik: Titel hochgeladen', ['Titel' => (string) ($track['title'] ?? $name)], 'info', 'discord');
|
||||
$reply(true, '„' . ($track['title'] ?? $name) . '“ ist in der Playlist.', ['music' => music_state()]);
|
||||
admin_log('🎵 Musik: Titel hochgeladen', ['Titel' => (string) ($track['title'] ?? $name), 'Bot' => MUSIC_BOTS[$bot]], 'info', 'discord');
|
||||
$reply(true, '„' . ($track['title'] ?? $name) . '“ ist in der Playlist.', ['music' => music_state($bot)]);
|
||||
|
||||
case 'delete':
|
||||
if (!user_has_permission('music.manage')) {
|
||||
|
|
@ -114,9 +120,9 @@ try {
|
|||
if (!ctype_digit($trackId)) {
|
||||
$reply(false, 'Unbekannter Titel.');
|
||||
}
|
||||
music_api_request('DELETE', '/music/tracks/' . $trackId);
|
||||
admin_log('🎵 Musik: Titel gelöscht', ['Titel-Nr.' => $trackId], 'danger', 'discord');
|
||||
$reply(true, 'Titel gelöscht.', ['music' => music_state()]);
|
||||
music_api_request($bot, 'DELETE', '/music/tracks/' . $trackId);
|
||||
admin_log('🎵 Musik: Titel gelöscht', ['Titel-Nr.' => $trackId, 'Bot' => MUSIC_BOTS[$bot]], 'danger', 'discord');
|
||||
$reply(true, 'Titel gelöscht.', ['music' => music_state($bot)]);
|
||||
|
||||
default:
|
||||
http_response_code(400);
|
||||
|
|
|
|||
Loading…
Reference in a new issue