added rzeczy

This commit is contained in:
Patryk Koreń
2025-12-26 20:45:38 +01:00
parent 375779de9c
commit b551cce62a
14 changed files with 326 additions and 91 deletions

57
src/playback.ts Normal file
View File

@@ -0,0 +1,57 @@
import { AudioPlayer, AudioPlayerStatus } from "@discordjs/voice";
import { player } from "./main";
import { CacheType, ChatInputCommandInteraction } from "discord.js";
import { getAudioFile } from "./util/downloader";
import { playSong } from "./util/helpers";
const queue: Queue = {
songList: [],
current: null
}
export async function requestSong(
interaction: ChatInputCommandInteraction<CacheType>,
url: string) {
const path = await getAudioFile(url)
queue.songList.push(path)
updatePlayer()
}
export async function forceRequestSong(
interaction: ChatInputCommandInteraction<CacheType>,
url: string) {
const path = await getAudioFile(url)
queue.songList.push(path)
playSong(player, path);
}
export async function updatePlayer() {
if (player.state.status === AudioPlayerStatus.Idle) {
const nextSong = queue.songList.shift()
if (!nextSong) {
queue.current = null
return
};
playSong(player, nextSong);
}
}
export function pause_playback(player: AudioPlayer) {
player.pause()
}
export function stop_playback(player: AudioPlayer) {
player.stop()
}
export function resume_playback(player: AudioPlayer) {
player.unpause()
}
export function getQueue(): Queue {
return queue
}