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

1 messages · Page 1 of 1 (latest)

exotic trout
#

Not sure what's causing this error
Here is my code and file tree

└───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();
        }
    }
}
stable bison
#

Tsconfig?

exotic trout
#
{
  "compilerOptions": {
    "target": "ES2020",
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,   
    "module": "commonjs",
    "rootDir": "./src",
    "outDir": "./dist",
    "moduleResolution": "node",
    "resolveJsonModule": true,     
    "skipLibCheck": true
  }
}
stable bison
#

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 #1047062662082732093 so I assume you use Sapphire.

exotic trout
#

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

stable bison
#

Then don't put it in the commands folder

exotic trout
#

it isn't, it's in the utils folder

stable bison
#

Oh your file tree seemed to suggest otherwise...

exotic trout
#
│
└───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!

lean helmBOT