Skip to content

Commit d436729

Browse files
committed
chore: release 6.7.1
1 parent 2725277 commit d436729

File tree

8 files changed

+64
-44
lines changed

8 files changed

+64
-44
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ $ npm install --save ffmpeg-binaries
8585
8686
#### Streaming Library
8787

88-
YouTube streaming is not supported without installing one of the following package. If you want to add support for YouTube playback, you need to install a streaming library. This step is not needed if you do not plan on using youtube source.
88+
**The following method is deprecated and will be removed in the future. Please switch to [discord-player-youtubei](https://npmjs.com/discord-player-youtubei).**
89+
90+
**Not recommended**:
8991

90-
* The default Youtube streaming appears to be unstable due to recent changes. It is recommend to install [`discord-player-youtubei`](https://npm.im/discord-player-youtubei)*
92+
YouTube streaming is not supported without installing one of the following package. If you want to add support for YouTube playback, you need to install a streaming library. This step is not needed if you do not plan on using youtube source.
9193

9294
```bash
9395
$ npm install --save youtube-ext
@@ -101,8 +103,6 @@ $ npm install --save yt-stream
101103
$ npm install --save ytdl-core
102104
```
103105

104-
We recommend using `youtube-ext` for better performance.
105-
106106
Once you have completed these installations, let's proceed with writing a simple music bot.
107107

108108
### Setup

packages/discord-player/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ $ npm install --save ffmpeg-binaries
8585
8686
#### Streaming Library
8787

88+
**The following method is deprecated and will be removed in the future. Please switch to [discord-player-youtubei](https://npmjs.com/discord-player-youtubei).**
89+
90+
**Not recommended**:
91+
8892
YouTube streaming is not supported without installing one of the following package. If you want to add support for YouTube playback, you need to install a streaming library. This step is not needed if you do not plan on using youtube source.
8993

9094
```bash
@@ -99,8 +103,6 @@ $ npm install --save yt-stream
99103
$ npm install --save ytdl-core
100104
```
101105

102-
We recommend using `youtube-ext` for better performance.
103-
104106
Once you have completed these installations, let's proceed with writing a simple music bot.
105107

106108
### Setup

packages/discord-player/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "discord-player",
3-
"version": "6.7.0",
3+
"version": "6.7.1",
44
"description": "Complete framework to facilitate music commands using discord.js",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -55,7 +55,6 @@
5555
"@discord-player/utils": "workspace:^",
5656
"@web-scrobbler/metadata-filter": "^3.1.0",
5757
"discord-voip": "^0.1.3",
58-
"ip": "^2.0.1",
5958
"libsodium-wrappers": "^0.7.13"
6059
},
6160
"peerDependencies": {
@@ -78,4 +77,4 @@
7877
"readmeFile": "./README.md",
7978
"tsconfig": "./tsconfig.json"
8079
}
81-
}
80+
}

packages/discord-player/src/errors/index.ts

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,133 +3,140 @@ const DiscordPlayerErrors = {
33
name: 'ERR_OUT_OF_SPACE',
44
type: RangeError,
55
createError(target: string, capacity: number, total: number) {
6-
return `[${this.name}] Max capacity reached for ${target} (Capacity ${capacity}/Total ${total})`;
6+
return `[${this.constructor.name}] Max capacity reached for ${target} (Capacity ${capacity}/Total ${total})`;
77
}
88
},
99
ERR_INVALID_ARG_TYPE: {
1010
name: 'ERR_INVALID_ARG_TYPE',
1111
type: TypeError,
1212
createError(target: string, expectation: string, found: string) {
13-
return `[${this.name}] Expected ${target} to be "${expectation}", received "${found}"`;
13+
return `[${this.constructor.name}] Expected ${target} to be "${expectation}", received "${found}"`;
1414
}
1515
},
1616
ERR_NO_RESULT: {
1717
name: 'ERR_NO_RESULT',
1818
type: Error,
1919
createError(message: string) {
20-
return `[${this.name}] ${message}`;
20+
return `[${this.constructor.name}] ${message}`;
2121
}
2222
},
2323
ERR_NOT_IMPLEMENTED: {
2424
name: 'ERR_NOT_IMPLEMENTED',
2525
type: Error,
2626
createError(target: string) {
27-
return `[${this.name}] ${target} is not yet implemented`;
27+
return `[${this.constructor.name}] ${target} is not yet implemented`;
2828
}
2929
},
3030
ERR_NOT_EXISTING: {
3131
name: 'ERR_NOT_EXISTING',
3232
type: Error,
3333
createError(target: string) {
34-
return `[${this.name}] ${target} does not exist`;
34+
return `[${this.constructor.name}] ${target} does not exist`;
3535
}
3636
},
3737
ERR_OUT_OF_RANGE: {
3838
name: 'ERR_OUT_OF_RANGE',
3939
type: RangeError,
4040
createError(target: string, value: string, minimum: string, maximum: string) {
41-
return `[${this.name}] ${target} is out of range (Expected minimum ${maximum} and maximum ${maximum}, got ${value})`;
41+
return `[${this.constructor.name}] ${target} is out of range (Expected minimum ${maximum} and maximum ${maximum}, got ${value})`;
4242
}
4343
},
4444
ERR_NO_VOICE_CONNECTION: {
4545
name: 'ERR_NO_VOICE_CONNECTION',
4646
type: Error,
4747
createError(message?: string) {
48-
return `[${this.name}] ` + (message || 'No voice connection available, maybe connect to a voice channel first?');
48+
return `[${this.constructor.name}] ` + (message || 'No voice connection available, maybe connect to a voice channel first?');
4949
}
5050
},
5151
ERR_VOICE_CONNECTION_DESTROYED: {
5252
name: 'ERR_VOICE_CONNECTION_DESTROYED',
5353
type: Error,
5454
createError() {
55-
return `[${this.name}] ` + 'Cannot use destroyed voice connection';
55+
return `[${this.constructor.name}] ` + 'Cannot use destroyed voice connection';
5656
}
5757
},
5858
ERR_NO_VOICE_CHANNEL: {
5959
name: 'ERR_NO_VOICE_CHANNEL',
6060
type: Error,
6161
createError() {
62-
return `[${this.name}] ` + 'Could not get the voice channel';
62+
return `[${this.constructor.name}] ` + 'Could not get the voice channel';
6363
}
6464
},
6565
ERR_INVALID_VOICE_CHANNEL: {
6666
name: 'ERR_INVALID_VOICE_CHANNEL',
6767
type: Error,
6868
createError() {
69-
return `[${this.name}] ` + 'Expected a voice channel';
69+
return `[${this.constructor.name}] ` + 'Expected a voice channel';
7070
}
7171
},
7272
ERR_NO_RECEIVER: {
7373
name: 'ERR_NO_RECEIVER',
7474
type: Error,
7575
createError(message?: string) {
76-
return `[${this.name}] ` + (message || 'No voice receiver is available, maybe connect to a voice channel first?');
76+
return `[${this.constructor.name}] ` + (message || 'No voice receiver is available, maybe connect to a voice channel first?');
7777
}
7878
},
7979
ERR_FFMPEG_LOCATOR: {
8080
name: 'ERR_FFMPEG_LOCATOR',
8181
type: Error,
8282
createError(message: string) {
83-
return `[${this.name}] ` + message;
83+
return `[${this.constructor.name}] ` + message;
8484
}
8585
},
8686
ERR_NO_AUDIO_RESOURCE: {
8787
name: 'ERR_NO_AUDIO_RESOURCE',
8888
type: Error,
8989
createError(message?: string) {
90-
return `[${this.name}] ` + (message || 'Expected an audio resource');
90+
return `[${this.constructor.name}] ` + (message || 'Expected an audio resource');
9191
}
9292
},
9393
ERR_NO_GUILD_QUEUE: {
9494
name: 'ERR_NO_GUILD_QUEUE',
9595
type: Error,
9696
createError(message?: string) {
97-
return `[${this.name}] ` + (message || 'Expected a guild queue');
97+
return `[${this.constructor.name}] ` + (message || 'Expected a guild queue');
9898
}
9999
},
100100
ERR_NO_GUILD: {
101101
name: 'ERR_NO_GUILD',
102102
type: Error,
103103
createError(message?: string) {
104-
return `[${this.name}] ` + (message || 'Expected a guild');
104+
return `[${this.constructor.name}] ` + (message || 'Expected a guild');
105105
}
106106
},
107107
ERR_INFO_REQUIRED: {
108108
name: 'ERR_INFO_REQUIRED',
109109
type: Error,
110110
createError(target: string, actual: string) {
111-
return `[${this.name}] Expected ${target}, found "${actual}"`;
111+
return `[${this.constructor.name}] Expected ${target}, found "${actual}"`;
112112
}
113113
},
114114
ERR_SERIALIZATION_FAILED: {
115115
name: 'ERR_SERIALIZATION_FAILED',
116116
type: Error,
117117
createError() {
118-
return `[${this.name}]` + "Don't know how to serialize this data";
118+
return `[${this.constructor.name}]` + "Don't know how to serialize this data";
119119
}
120120
},
121121
ERR_DESERIALIZATION_FAILED: {
122122
name: 'ERR_DESERIALIZATION_FAILED',
123123
type: Error,
124124
createError() {
125-
return `[${this.name}]` + "Don't know how to deserialize this data";
125+
return `[${this.constructor.name}]` + "Don't know how to deserialize this data";
126126
}
127127
},
128128
ERR_ILLEGAL_HOOK_INVOCATION: {
129129
name: 'ERR_ILLEGAL_HOOK_INVOCATION',
130130
type: Error,
131131
createError(target: string, message?: string) {
132-
return `[${this.name}] ` + `Illegal invocation of ${target} hook.${message ? ` ${message}` : ''}`;
132+
return `[${this.constructor.name}]` + `Illegal invocation of ${target} hook.${message ? ` ${message}` : ''}`;
133+
}
134+
},
135+
ERR_NOT_EXISTING_MODULE: {
136+
name: 'ERR_NOT_EXISTING_MODULE',
137+
type: Error,
138+
createError(target: string, description = '') {
139+
return `[${this.constructor.name}]` + `${target} module does not exist. Install it with \`npm install ${target}\`.${description ? ' ' + description : ''}`;
133140
}
134141
}
135142
} as const;

packages/discord-player/src/queue/GuildQueuePlayerNode.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,9 @@ export class GuildQueuePlayerNode<Meta = unknown> {
603603
const opusStream = $fmt === StreamType.Opus ?
604604
stream :
605605
$fmt === StreamType.OggOpus ?
606+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
606607
stream.pipe(new prism.opus.OggDemuxer() as any) :
608+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
607609
stream.pipe(new prism.opus.WebmDemuxer() as any);
608610

609611
if (shouldPCM) {

packages/discord-player/src/utils/IPRotator.ts

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,37 @@
1-
import ip from 'ip';
1+
import { Util } from './Util';
2+
import { Exceptions } from '../errors';
3+
4+
// @ts-ignore
5+
let ip: typeof import('ip');
6+
7+
function ensureIp() {
8+
if (ip) return ip;
9+
10+
const { error, module } = Util.require('ip');
11+
12+
if (error) {
13+
throw Exceptions.ERR_NOT_EXISTING_MODULE('ip', 'ip package is required to use IPRotator.');
14+
}
15+
16+
ip = module;
17+
18+
return ip;
19+
}
220

321
export class IPBlock {
422
public usage = 0;
523
public readonly cidr: string;
624
public readonly cidrSize: number;
725

826
public constructor(public block: string) {
9-
if (ip.isV4Format(block.split('/')[0]) && !block.includes('/')) {
27+
if (ensureIp().isV4Format(block.split('/')[0]) && !block.includes('/')) {
1028
block += '/32';
11-
} else if (ip.isV6Format(block.split('/')[0]) && !block.includes('/')) {
29+
} else if (ensureIp().isV6Format(block.split('/')[0]) && !block.includes('/')) {
1230
block += '/128';
1331
}
1432

15-
this.cidr = ip.cidr(this.block);
16-
this.cidrSize = ip.cidrSubnet(this.block).subnetMaskLength;
33+
this.cidr = ensureIp().cidr(this.block);
34+
this.cidrSize = ensureIp().cidrSubnet(this.block).subnetMaskLength;
1735
}
1836

1937
public consume() {
@@ -67,7 +85,7 @@ export class IPRotator {
6785

6886
this.#retries = 0;
6987
block.consume();
70-
return { ip: random, family: ip.isV4Format(random) ? 4 : 6 };
88+
return { ip: random, family: ensureIp().isV4Format(random) ? 4 : 6 };
7189
}
7290

7391
public isFailedOrExcluded(ip: string) {
@@ -84,7 +102,7 @@ export class IPRotator {
84102
// Author: Jesse Tane <jesse.tane@gmail.com>
85103
// NPMJS: https://npmjs.org/random-ip
86104

87-
const bytes = ip.toBuffer(address);
105+
const bytes = ensureIp().toBuffer(address);
88106
const ipv6 = bytes.length === 16;
89107
const bytesize = 8;
90108

packages/extractor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@
6262
"readmeFile": "./README.md",
6363
"tsconfig": "./tsconfig.json"
6464
}
65-
}
65+
}

yarn.lock

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6047,7 +6047,6 @@ __metadata:
60476047
discord-api-types: "npm:^0.37.0"
60486048
discord-voip: "npm:^0.1.3"
60496049
discord.js: "npm:^14.15.3"
6050-
ip: "npm:^2.0.1"
60516050
libsodium-wrappers: "npm:^0.7.13"
60526051
opusscript: "npm:^0.0.8"
60536052
tsup: "npm:^7.2.0"
@@ -8743,13 +8742,6 @@ __metadata:
87438742
languageName: node
87448743
linkType: hard
87458744

8746-
"ip@npm:^2.0.1":
8747-
version: 2.0.1
8748-
resolution: "ip@npm:2.0.1"
8749-
checksum: 10/d6dd154e1bc5e8725adfdd6fb92218635b9cbe6d873d051bd63b178f009777f751a5eea4c67021723a7056325fc3052f8b6599af0a2d56f042c93e684b4a0349
8750-
languageName: node
8751-
linkType: hard
8752-
87538745
"ipaddr.js@npm:1.9.1":
87548746
version: 1.9.1
87558747
resolution: "ipaddr.js@npm:1.9.1"

0 commit comments

Comments
 (0)