f
This commit is contained in:
parent
0273eab753
commit
a4abbf7844
3 changed files with 9 additions and 4 deletions
|
|
@ -1214,7 +1214,8 @@ function renderSounds(sounds) {
|
||||||
async function deleteSound(soundId) {
|
async function deleteSound(soundId) {
|
||||||
if (!state.selectedGuildId) return;
|
if (!state.selectedGuildId) return;
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`/guilds/${state.selectedGuildId}/sounds/${soundId}`, {
|
const url = API_BASE_URL ? `${API_BASE_URL}/guilds/${state.selectedGuildId}/sounds/${soundId}` : `/guilds/${state.selectedGuildId}/sounds/${soundId}`;
|
||||||
|
const response = await fetch(url, {
|
||||||
method: 'DELETE'
|
method: 'DELETE'
|
||||||
});
|
});
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
|
@ -1228,11 +1229,12 @@ async function deleteSound(soundId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function playRemoteSound(url) {
|
function playRemoteSound(url) {
|
||||||
|
const fullUrl = API_BASE_URL && !url.startsWith('http') ? `${API_BASE_URL}${url}` : url;
|
||||||
if (state.voice.ws && state.voice.ws.readyState === WebSocket.OPEN) {
|
if (state.voice.ws && state.voice.ws.readyState === WebSocket.OPEN) {
|
||||||
state.voice.ws.send(JSON.stringify({ type: 'play_sound', sound_url: url }));
|
state.voice.ws.send(JSON.stringify({ type: 'play_sound', sound_url: fullUrl }));
|
||||||
}
|
}
|
||||||
// Also play locally immediately
|
// Also play locally immediately
|
||||||
const audio = new Audio(url);
|
const audio = new Audio(fullUrl);
|
||||||
audio.play().catch(console.error);
|
audio.play().catch(console.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1459,7 +1461,8 @@ async function init() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Need to use fetch directly because api() might not handle FormData correctly depending on implementation
|
// Need to use fetch directly because api() might not handle FormData correctly depending on implementation
|
||||||
const response = await fetch(`/guilds/${state.selectedGuildId}/sounds`, {
|
const url = API_BASE_URL ? `${API_BASE_URL}/guilds/${state.selectedGuildId}/sounds` : `/guilds/${state.selectedGuildId}/sounds`;
|
||||||
|
const response = await fetch(url, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData
|
body: formData
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -367,6 +367,7 @@ select {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
order: -1;
|
order: -1;
|
||||||
|
margin-right: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes fadeInOut {
|
@keyframes fadeInOut {
|
||||||
|
|
|
||||||
|
|
@ -367,6 +367,7 @@ select {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
order: -1;
|
order: -1;
|
||||||
|
margin-right: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes fadeInOut {
|
@keyframes fadeInOut {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue