Skip to content

Commit e5077c2

Browse files
authored
wip: lib overhaul (#20)
* chore!: complete rewrite refactor(constants): move default options to a single file chore(constants): define symbols for internal communication refactor(functions/utility): improve formatDuration refactor(functions/validation): improve all predicates refactor(main/player)!: rethink options, initialization, prop names refactor(Node)!: rework reconnect logic, remove unnecessary props, adapt to REST refactor(NodeManager)!: better naming, new methods, fix and expose metrics refactor(REST)!: remove retry limit, request queue, and improve types refactor(plugins/lavalyrics): adapt to changes in Queue refactor(FilterManager)!: remove direct filter access via data prop feat(FilterManager): specific clear types, include pluginFilters in filter names refactor(Queue)!: rename few props, adapt to external changes refactor(QueueManager)!: remove unnecessary methods, adapt to external changes refactor(typings): additions/modifications and name/description changes as needed refactor(VoiceManager)!: do not auto-destroy player on guild/channel delete refactor(VoiceRegion): adapt to external changes refactor(VoiceState)!: remove unnecessary props, adapt to external changes * refactor(functions/validation): run checks only when needed * refactor(Playlist): throw for data with no track(s) * chore: setup jest * chore: write tests * ci: add workflow for codecov coverage * ci: update checkout and setup-node actions * ci: set explicit perms for coverage, remove token (test) * chore: update readme
1 parent ece206b commit e5077c2

42 files changed

Lines changed: 7081 additions & 2957 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/coverage.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Coverage
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
run:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: read
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v6
13+
14+
- name: Setup Node
15+
uses: actions/setup-node@v6
16+
with:
17+
cache: npm
18+
node-version: 22
19+
20+
- name: Install dependencies
21+
run: npm ci
22+
23+
- name: Run tests
24+
run: npm test
25+
26+
- name: Upload results to Codecov
27+
uses: codecov/codecov-action@v5

.github/workflows/documentation.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ jobs:
2626
runs-on: ubuntu-latest
2727
steps:
2828
- name: Checkout
29-
uses: actions/checkout@v5
29+
uses: actions/checkout@v6
3030

3131
- name: Setup Node
32-
uses: actions/setup-node@v5
32+
uses: actions/setup-node@v6
3333
with:
3434
cache: npm
3535
node-version: 22

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/coverage
12
/docs
23
/lib
34
node_modules/

README.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11
<div align="center">
22
<img alt="Discolink" src="assets/music-album.png" width="120" />
33

4-
[Icon designed by juicy_fish](https://www.flaticon.com/authors/juicy-fish)
4+
[Icon by juicy_fish](https://www.flaticon.com/authors/juicy-fish)
55
<br/>
6-
[Documentation](https://github.com/execaman/discolink/wiki) | [API Reference](https://execaman.github.io/discolink)
7-
6+
[API Reference](https://execaman.github.io/discolink) | [Coverage](http://app.codecov.io/gh/execaman/discolink)
7+
88
![NPM Version](https://img.shields.io/npm/v/discolink?style=flat&logo=npm)
9-
![NPM Downloads](https://img.shields.io/npm/dm/discolink)
9+
![Codecov Coverage](https://img.shields.io/codecov/c/github/execaman/discolink?logo=codecov)
10+
1011
</div>
1112

1213
## 🎯 Purpose
1314

1415
The goal of this library is to abstract away obvious steps involved in the process of acting as an intermediary between [Lavalink](https://lavalink.dev/api) and [Discord](https://discord.com/developers/docs/events/gateway) to give developers a cleaner yet intuitive interface to work with.
1516

16-
## ✨ Features
17-
18-
- Built-in queue system
19-
- Automatic player relocation
20-
- Built-in custom plugin support
21-
- Automatic relevant-node selection
22-
2317
## ⚙️ Requirements
2418

2519
- **Runtime** - one of the following:
@@ -59,7 +53,8 @@ client.on("raw", (payload) => {
5953
client.login();
6054
```
6155

62-
## 📝 Additional Notes
56+
## 📝 Implementation
6357

64-
- Handle track end reasons other than `cleanup` and `finished` manually
65-
- Always check for `reconnecting` or `changingNode` when handling voice states
58+
- Handle track end reasons other than `cleanup` and `finished`
59+
- Handle voice states with care, e.g. `reconnecting`, `changingNode`, etc.
60+
- Handle queue destruction/relocation, e.g. guild/channel delete, node close/disconnect, etc.

jest.config.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { createDefaultPreset } from "ts-jest";
2+
import type { Config } from "jest";
3+
4+
const config: Config = {
5+
clearMocks: true,
6+
collectCoverage: true,
7+
collectCoverageFrom: [
8+
"src/Functions/**/*.ts",
9+
"src/Queue/Playlist.ts",
10+
"src/Queue/Track.ts",
11+
"!src/Typings/**/*",
12+
"!src/**/index.ts",
13+
],
14+
coverageDirectory: "coverage",
15+
coverageProvider: "v8",
16+
globals: {
17+
$clientName: "name",
18+
$clientVersion: "version",
19+
$clientRepository: "repository",
20+
},
21+
preset: "ts-jest",
22+
testEnvironment: "node",
23+
...createDefaultPreset(),
24+
};
25+
26+
export default config;

0 commit comments

Comments
 (0)