Updated to include volume

This commit is contained in:
Benjamin Sherriff
2023-10-08 08:58:38 -04:00
parent 1035d3bc21
commit 6d30eb468b
3 changed files with 63 additions and 12 deletions

View File

@@ -20,14 +20,14 @@ export async function playTrack(guildId: number, channelId: number, track: strin
await postRequest(`guilds/${guildId}/voice/${channelId}/play`, { track_url: track });
}
export async function stopTrack(guildId: number, channelId: number): Promise<void> {
await postRequest(`guilds/${guildId}/voice/${channelId}/stop`, {});
export async function stopTrack(guildId: number): Promise<void> {
await postRequest(`guilds/${guildId}/voice/stop`, {});
}
export async function pauseTrack(guildId: number, channelId: number): Promise<void> {
await postRequest(`guilds/${guildId}/voice/${channelId}/pause`, {});
export async function pauseTrack(guildId: number): Promise<void> {
await postRequest(`guilds/${guildId}/voice/pause`, {});
}
export async function resumeTrack(guildId: number, channelId: number): Promise<void> {
await postRequest(`guilds/${guildId}/voice/${channelId}/resume`, {});
export async function resumeTrack(guildId: number): Promise<void> {
await postRequest(`guilds/${guildId}/voice/resume`, {});
}

View File

@@ -82,7 +82,7 @@ export default function Page() {
<Tabs.Panel key={channel.id} value={channel.name}>
{channel.name}
<form
style={{ display: 'flex' }}
style={{ margin: '1em' }}
onSubmit={playForm.onSubmit((values) => {
playTrack(activeGuild!.id, channel.id, values.trackUrl);
})}
@@ -90,11 +90,22 @@ export default function Page() {
<TextInput placeholder='Youtube URL...' {...playForm.getInputProps('trackUrl')} />
<Button type='submit'>Play Track</Button>
</form>
<Button onClick={() => stopTrack(activeGuild!.id, channel.id)}>Stop</Button>
<Button onClick={() => pauseTrack(activeGuild!.id, channel.id)}>Pause</Button>
<Button onClick={() => resumeTrack(activeGuild!.id, channel.id)}>Resume</Button>
<div>
<div style={{ margin: '1em' }}>
<Button style={{ marginRight: '1em' }} onClick={() => stopTrack(activeGuild!.id)}>
Stop
</Button>
<Button style={{ marginRight: '1em' }} onClick={() => pauseTrack(activeGuild!.id)}>
Pause
</Button>
<Button style={{ marginRight: '1em' }} onClick={() => resumeTrack(activeGuild!.id)}>
Resume
</Button>
</div>
<div style={{ margin: '1em' }}>
<Slider label='Volume' style={{ width: '20%' }} defaultValue={50} onChange={(v) => {}} />
<Button style={{ marginRight: '1em' }} onClick={() => {}}>
Set Volume
</Button>
</div>
</Tabs.Panel>
))}