© 2026 Hedgehog Software, LLC
└───src ├───apis ├───commands │ └───quran-player ├───data ├───private └───utils
import { AudioPlayer, AudioPlayerStatus, NoSubscriberBehavior, createAudioResource } from "@discordjs/voice"; export class QuranTrack { public readonly name : string; public readonly url : string; constructor(name : string, url : string) { this.name = name; this.url = url; } } export class QuranAudioPlayer extends AudioPlayer { private _queue : QuranTrack[]; private _currentTrack : QuranTrack; constructor() { super({ behaviors: { noSubscriber: NoSubscriberBehavior.Pause, maxMissedFrames: 0 }}); this.on(AudioPlayerStatus.Idle, this.next); } get currentTrackName() : QuranTrack { return this._currentTrack; } get queue() : QuranTrack[] { return this._queue; } public async playQuran(track : QuranTrack) : Promise<boolean> { const resource = createAudioResource(track.url); try { this.play(resource); this._currentTrack = track; return true; }catch (error) { return false; } } public async next() { if (this._queue.length > 0) { const track = this._queue.shift(); this.playQuran(track); } } public async enqueue(track : QuranTrack) { this._queue.push(track); if (this.state.status == AudioPlayerStatus.Idle) { this.next(); } } }
Join the Discord to ask follow-up questions and connect with the community
Sapphire is a next-gen object-oriented Discord.js bot framework.
2,286 Members