Error [EMPTY_MODULE]: A compatible class export was not found.

Not sure what's causing this error Here is my code and file tree
└───src
├───apis
├───commands
└───quran-player
├───data
├───private
└───utils
└───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();
}
}
}
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();
}
}
}
9 Replies
Favna
Favna10mo ago
Tsconfig?
Disuqi
Disuqi10mo ago
{
"compilerOptions": {
"target": "ES2020",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"module": "commonjs",
"rootDir": "./src",
"outDir": "./dist",
"moduleResolution": "node",
"resolveJsonModule": true,
"skipLibCheck": true
}
}
{
"compilerOptions": {
"target": "ES2020",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"module": "commonjs",
"rootDir": "./src",
"outDir": "./dist",
"moduleResolution": "node",
"resolveJsonModule": true,
"skipLibCheck": true
}
}
Favna
Favna10mo ago
Oh the problem is that you're exporting 2 classes I think. And the class doesn't extend the Sapphire Command class. You're in #sapphire-support so I assume you use Sapphire.
Disuqi
Disuqi10mo ago
yes I am using sapphire, but I don't want this class to be a command, it's just a "utility" class used by the command class
Favna
Favna10mo ago
Then don't put it in the commands folder
Disuqi
Disuqi10mo ago
it isn't, it's in the utils folder
Favna
Favna10mo ago
Oh your file tree seemed to suggest otherwise...
Disuqi
Disuqi10mo ago

└───src
│ main.ts

├───apis
│ quran-api.ts

├───commands
│ └───quran-player
│ manager.ts

├───data
│ userdata.json

├───private
│ config.json

└───utils
audio-player.ts

└───src
│ main.ts

├───apis
│ quran-api.ts

├───commands
│ └───quran-player
│ manager.ts

├───data
│ userdata.json

├───private
│ config.json

└───utils
audio-player.ts
audio-player.ts contains the class above so no idea 😓 ? oh wait i might know what's wrong one sec sroted sorted The problem was that it was in the commands folder, but in dict not src Thank you!
Favna
Favna10mo ago
Glad you figured it out. Sorry for the late response, was driving
Want results from more Discord servers?
Add your server
More Posts