1.0.3 • Published 3 years ago
@musicca/structs v1.0.3
About 📛
This package is a collection of structures for Musicca.
Installation 💾
npm install @musicca/structs
yarn add @musicca/structs
pnpm add @musicca/structs
Guide 🖋
Creating custom queue
First, you need to create a new queue class with your custom implementation
import { Queue, Media } from 'musicca';
export default class CustomQueue extends Queue {
public list: Media[] = [];
// Always put options at the 3rd parameter
constructor(manager, id, options) { ... }
// All custom methods are awaitable by default
public all() { ... }
public add<T extends Media | Media[] = Media>(media: T, position?: number) { ... }
public get(position: number) { ... }
public remove(position: number) { ... }
public clear() { ... }
public indexOf(media: Media) { ... }
}
Now, you can just plug it in to musicca
const client = new Musicca<CustomQueue>({
plugins: { ... },
structs: {
queue: CustomQueue
}
});