{"id":25740178,"url":"https://github.com/lavalibs/lavaqueue","last_synced_at":"2025-05-08T21:14:49.476Z","repository":{"id":30494881,"uuid":"124468363","full_name":"lavalibs/lavaqueue","owner":"lavalibs","description":"A queue system for Lavalink, backed by Redis.","archived":false,"fork":false,"pushed_at":"2025-03-29T14:52:46.000Z","size":315,"stargazers_count":27,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-08T21:14:43.872Z","etag":null,"topics":["discord","lavalink","playlist","redis-queue","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lavalibs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-03-09T01:12:36.000Z","updated_at":"2025-03-29T14:52:43.000Z","dependencies_parsed_at":"2025-04-13T06:45:06.139Z","dependency_job_id":null,"html_url":"https://github.com/lavalibs/lavaqueue","commit_stats":{"total_commits":104,"total_committers":7,"mean_commits":"14.857142857142858","dds":0.4903846153846154,"last_synced_commit":"870b9e50f411febb6e919a76d257e0e99079ecf5"},"previous_names":["appellation/lavaqueue"],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lavalibs%2Flavaqueue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lavalibs%2Flavaqueue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lavalibs%2Flavaqueue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lavalibs%2Flavaqueue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lavalibs","download_url":"https://codeload.github.com/lavalibs/lavaqueue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253149618,"owners_count":21861740,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["discord","lavalink","playlist","redis-queue","typescript"],"created_at":"2025-02-26T08:37:28.566Z","updated_at":"2025-05-08T21:14:49.455Z","avatar_url":"https://github.com/lavalibs.png","language":"TypeScript","readme":"# Lavaqueue\n\n[![lavalibs support server](https://discordapp.com/api/guilds/494948120103485440/embed.png)](https://discord.gg/jXSKeW5)\n\nA simple queue system for Lavalink, backed by Redis. Built as extension of [my generic Lavalink wrapper](https://github.com/appellation/lavalink.js).\n\n## How to use\n\n```js\nconst { Client: Lavaqueue } = require('lavaqueue');\nconst voice = new Lavaqueue({\n  userID: '', // the user that will be sending audio\n  password: '', // your lavalink password\n  hosts: {\n    rest: '', // your lavalink rest endpoint (include port and protocol)\n    ws: '', // your lavalink ws endpoint (include port and protocol)\n    redis: '', // your redis instance\n  },\n  send(guildID, packet) {\n    // send the packet to the appropriate gateway connection\n  },\n  advanceBy(queue, { previous, remaining }) { // optional\n    // called at the end of a track when the queue is otherwise unaware of how many tracks to\n    // advance by; returns a number: 0 to repeat, negative to advance in reverse, positive to\n    // advance forward\n  },\n});\n\nasync function connect() {\n  const res = await voice.load('some identifier');\n  const queue = voice.queues.get('some guild ID');\n\n  await queue.player.join('channel id'); // join the voice channel\n  await queue.add(...res.tracks.map(t =\u003e t.track)); // add songs to the queue\n  await queue.start(); // start the queue\n}\n\nasync function skip() {\n  await voice.queues.get('some guild ID').next();\n}\n\nasync function stop() {\n  await voice.queues.get('some guild ID').stop();\n}\n```\n\nQueues are resilient to crashes, meaning it's safe to blindly restart a queue: it will attempt to recover the previous song at the point the crash occurred. You can restart all currently playing queues by calling `voice.queues.start()`, although it is recommended to do so as infrequently as possible.\n\n## Reference\n\n### `Queue`\n- `store: QueueStore`\n- `guildID: string`\n- *readonly* `player` - the [lavalink](https://github.com/lavalibs/lavalink.js) player\n- `start(): Promise\u003cboolean\u003e` - start the queue\n- `add(...tracks: string[]): Promise\u003cnumber\u003e` - add tracks to the queue\n- `unshift(...tracks: string[]): Promise\u003cnumber\u003e` - add tracks to the front of the queue\n- `remove(track: string): PromiseLike\u003cnumber\u003e` - remove a track from the queue\n- `next(count: number = 1): Promise\u003cboolean\u003e` - skip to the next song; pass negatives to advance in reverse, or 0 to repeat\n- `sort(predicate?: (a: string, b: string) =\u003e number): Promise\u003cnumber\u003e` - sort the upcoming tracks; resolves with the length of the queue\n- `move(from: number, to: number): Promise\u003cstring[]\u003e` - move a track by index; resolves with the new list\n- `shuffle(): Promise\u003cstring[]\u003e` - shuffle the list; resolves with the new list\n- `splice(start: number, deleteCount?: number, ...tracks: string[]): Promise\u003cstring[]\u003e` - splice the list at the given position; works like [Array#splice](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice)\n- `trim(start: number, end: number): PromiseLike\u003cstring\u003e` - trim the queue to between the specified positions\n- `stop(): Promise\u003cvoid\u003e` - stop playback\n- `clear(): PromiseLike\u003cnumber\u003e` - clear the queue\n- `current(): Promise\u003cNP | null\u003e` - retrieve the current song: returns an object with properties `track` and `position`\n- `tracks(start: number = 0, end: number = -1): Promise\u003cstring[]\u003e` - retrieves queued tracks\n\n```ts\ninterface NP {\n  position: number;\n  track: string;\n}\n```\n\n### `QueueStore extends Map\u003cstring, Queue\u003e`\n- `client: Client`\n- `redis: Redis` - the ioredis instance this queue store is using\n- `start(filter?: (guildID: string) =\u003e boolean)` - start all currently playing queues, with an optional filter callback\n- `get(key: string): Queue` - gets the specified queue, or creates one if none is found\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flavalibs%2Flavaqueue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flavalibs%2Flavaqueue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flavalibs%2Flavaqueue/lists"}