poru 4.2.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitpod.yml +8 -8
- package/LICENSE +21 -21
- package/README.md +164 -157
- package/dist/src/Connection.d.ts +17 -17
- package/dist/src/Connection.js +50 -50
- package/dist/src/Error.d.ts +3 -3
- package/dist/src/Error.js +7 -7
- package/dist/src/Filters.d.ts +77 -77
- package/dist/src/Filters.js +94 -94
- package/dist/src/Node/Node.js +5 -5
- package/dist/src/Node/Node.js.map +1 -1
- package/dist/src/Node/Rest.d.ts +1 -1
- package/dist/src/Node/Rest.js +3 -3
- package/dist/src/Node/Rest.js.map +1 -1
- package/dist/src/Node.d.ts +59 -59
- package/dist/src/Node.js +179 -179
- package/dist/src/Player/Player.d.ts +3 -3
- package/dist/src/Player/Player.js +7 -8
- package/dist/src/Player/Player.js.map +1 -1
- package/dist/src/Player.d.ts +57 -57
- package/dist/src/Player.js +270 -270
- package/dist/src/Poru.d.ts +1 -1
- package/dist/src/Poru.js +6 -6
- package/dist/src/Rest.d.ts +40 -40
- package/dist/src/Rest.js +88 -88
- package/dist/src/config.d.ts +1 -1
- package/dist/src/config.js +1 -1
- package/dist/src/config.js.map +1 -1
- package/dist/src/guild/Response.d.ts +3 -2
- package/dist/src/guild/Response.js +12 -4
- package/dist/src/guild/Response.js.map +1 -1
- package/dist/src/guild/Track.d.ts +7 -1
- package/dist/src/guild/Track.js +7 -2
- package/dist/src/guild/Track.js.map +1 -1
- package/docs/404.html +16 -16
- package/docs/assets/js/main.5068e5c4.js +1 -1
- package/docs/assets/js/main.5068e5c4.js.LICENSE.txt +63 -63
- package/docs/blog/archive/index.html +16 -16
- package/docs/blog/atom.xml +69 -69
- package/docs/blog/first-blog-post/index.html +16 -16
- package/docs/blog/index.html +16 -16
- package/docs/blog/long-blog-post/index.html +16 -16
- package/docs/blog/mdx-blog-post/index.html +16 -16
- package/docs/blog/rss.xml +51 -51
- package/docs/blog/tags/docusaurus/index.html +16 -16
- package/docs/blog/tags/facebook/index.html +16 -16
- package/docs/blog/tags/hello/index.html +16 -16
- package/docs/blog/tags/hola/index.html +16 -16
- package/docs/blog/tags/index.html +16 -16
- package/docs/blog/welcome/index.html +16 -16
- package/docs/docs/classes/Connection/index.html +16 -16
- package/docs/docs/classes/Filters/index.html +16 -16
- package/docs/docs/classes/Node/index.html +16 -16
- package/docs/docs/classes/Player/index.html +16 -16
- package/docs/docs/classes/Plugin/index.html +16 -16
- package/docs/docs/classes/Poru/index.html +16 -16
- package/docs/docs/classes/Response/index.html +16 -16
- package/docs/docs/classes/Rest/index.html +16 -16
- package/docs/docs/classes/Track/index.html +16 -16
- package/docs/docs/classes/customFilter/index.html +16 -16
- package/docs/docs/enums/RequestMethod/index.html +16 -16
- package/docs/docs/interfaces/ConnectionOptions/index.html +16 -16
- package/docs/docs/interfaces/IVoiceServer/index.html +16 -16
- package/docs/docs/interfaces/LavalinkResponse/index.html +16 -16
- package/docs/docs/interfaces/NodeGroup/index.html +16 -16
- package/docs/docs/interfaces/NodeStats/index.html +16 -16
- package/docs/docs/interfaces/PoruEvents/index.html +16 -16
- package/docs/docs/interfaces/PoruOptions/index.html +16 -16
- package/docs/docs/interfaces/ResolveOptions/index.html +16 -16
- package/docs/docs/interfaces/channelMixOptions/index.html +16 -16
- package/docs/docs/interfaces/playOptions/index.html +16 -16
- package/docs/docs/interfaces/trackData/index.html +16 -16
- package/docs/docs/interfaces/trackInfo/index.html +16 -16
- package/docs/docs/introduction/index.html +22 -22
- package/docs/docs/modules/index.html +16 -16
- package/docs/img/undraw_docusaurus_mountain.svg +171 -171
- package/docs/img/undraw_docusaurus_react.svg +170 -170
- package/docs/img/undraw_docusaurus_tree.svg +40 -40
- package/docs/index.html +16 -16
- package/docs/markdown-page/index.html +16 -16
- package/guide.md +25 -25
- package/index.ts +9 -9
- package/package.json +57 -57
- package/src/Node/Node.ts +236 -236
- package/src/Node/Rest.ts +124 -123
- package/src/Player/Connection.ts +82 -82
- package/src/Player/CustomFilters.ts +100 -100
- package/src/Player/Filters.ts +339 -339
- package/src/Player/Player.ts +499 -500
- package/src/Plugin.ts +13 -13
- package/src/Poru.ts +523 -523
- package/src/config.ts +3 -3
- package/src/guild/Queue.ts +36 -36
- package/src/guild/Response.ts +44 -28
- package/src/guild/Track.ts +93 -83
- package/tsconfig.json +16 -16
package/.gitpod.yml
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# This configuration file was automatically generated by Gitpod.
|
|
2
|
-
# Please adjust to your needs (see https://www.gitpod.io/docs/config-gitpod-file)
|
|
3
|
-
# and commit this file to your remote git repository to share the goodness with others.
|
|
4
|
-
|
|
5
|
-
tasks:
|
|
6
|
-
- init: npm install
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
# This configuration file was automatically generated by Gitpod.
|
|
2
|
+
# Please adjust to your needs (see https://www.gitpod.io/docs/config-gitpod-file)
|
|
3
|
+
# and commit this file to your remote git repository to share the goodness with others.
|
|
4
|
+
|
|
5
|
+
tasks:
|
|
6
|
+
- init: npm install
|
|
7
|
+
|
|
8
|
+
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 parasop
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 parasop
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,157 +1,164 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<img src="https://cdn.discordapp.com/attachments/732987654165233744/987656504373026816/20220618_000923_0000.png" />
|
|
3
|
-
</p>
|
|
4
|
-
<p align="center">
|
|
5
|
-
|
|
6
|
-
[](https://discord.gg/Zmmc47Nrh8)
|
|
7
|
-
[](https://www.npmjs.com/package/poru)
|
|
8
|
-

|
|
9
|
-

|
|
10
|
-

|
|
11
|
-

|
|
12
|
-
|
|
13
|
-
</p>
|
|
14
|
-
|
|
15
|
-
<p align="center">
|
|
16
|
-
|
|
17
|
-
</p>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
client.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
interaction.reply(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://cdn.discordapp.com/attachments/732987654165233744/987656504373026816/20220618_000923_0000.png" />
|
|
3
|
+
</p>
|
|
4
|
+
<p align="center">
|
|
5
|
+
|
|
6
|
+
[](https://discord.gg/Zmmc47Nrh8)
|
|
7
|
+
[](https://www.npmjs.com/package/poru)
|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
note: this version support only lavalink v4 or above
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
<p align="center">
|
|
22
|
+
<a href="https://nodei.co/npm/poru/"><img src="https://nodei.co/npm/poru.png?downloads=true&downloadRank=true&stars=true"></a>
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
## Table of contents
|
|
26
|
+
|
|
27
|
+
- [Documentation](https://poru.js.org)
|
|
28
|
+
- [Installation](#installation)
|
|
29
|
+
- [About](#about)
|
|
30
|
+
- [Example](https://github.com/parasop/poru-example)
|
|
31
|
+
|
|
32
|
+
# Installation
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
// Using npm
|
|
36
|
+
npm install poru
|
|
37
|
+
|
|
38
|
+
// Using yarn
|
|
39
|
+
yarn add poru
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
# About
|
|
43
|
+
|
|
44
|
+
To use you need a configured [Lavalink](https://github.com/freyacodes/Lavalink) instance.
|
|
45
|
+
|
|
46
|
+
- Stable client
|
|
47
|
+
- support typescript
|
|
48
|
+
- 100% Compatible with Lavalink
|
|
49
|
+
- Object-oriented
|
|
50
|
+
- 100% Customizable
|
|
51
|
+
- Easy to setup
|
|
52
|
+
- Inbuilt Queue System
|
|
53
|
+
- Inbuilt support for spotify,apple music and deezer
|
|
54
|
+
## Implementation
|
|
55
|
+
|
|
56
|
+
[Poru Music](https://github.com/parasop/poru-example) **Example bot as guide for beginning.**
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
## Implementation Repo:
|
|
60
|
+
Note : Send pr to add your repo here
|
|
61
|
+
|
|
62
|
+
URL | Features | Additional Information
|
|
63
|
+
-------|----------|-----------------
|
|
64
|
+
[Poru Music](https://github.com/parasop/poru-example) | Basic example | works with latest djs version |
|
|
65
|
+
[The world machine](https://github.com/Reishimanfr/TWM-bot) | See github repo for full list | - |
|
|
66
|
+
[Lunox](https://github.com/adh319/Lunox) | Look over the repo for the full list of features. | Simply powerfull Discord Music Bot |
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
## Example usage basic bot
|
|
77
|
+
|
|
78
|
+
```javascript
|
|
79
|
+
const { Client, GatewayIntentBits } = require("discord.js");
|
|
80
|
+
const { Poru } = require("poru");
|
|
81
|
+
const nodes = [
|
|
82
|
+
{
|
|
83
|
+
name: "local-node",
|
|
84
|
+
host: "localhost",
|
|
85
|
+
port: 2333,
|
|
86
|
+
password: "youshallnotpass",
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
const PoruOptions = {
|
|
90
|
+
library:"discord.js",
|
|
91
|
+
defaultPlatform: "scsearch",
|
|
92
|
+
};
|
|
93
|
+
const client = new Client({
|
|
94
|
+
intents: [
|
|
95
|
+
GatewayIntentBits.Guilds,
|
|
96
|
+
GatewayIntentBits.GuildMessages,
|
|
97
|
+
GatewayIntentBits.GuildVoiceStates,
|
|
98
|
+
GatewayIntentBits.MessageContent,
|
|
99
|
+
],
|
|
100
|
+
});
|
|
101
|
+
client.poru = new Poru(client, nodes, PoruOptions);
|
|
102
|
+
|
|
103
|
+
client.poru.on("trackStart", (player, track) => {
|
|
104
|
+
const channel = client.channels.cache.get(player.textChannel);
|
|
105
|
+
return channel.send(`Now playing \`${track.info.title}\``);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
client.on("ready", () => {
|
|
109
|
+
console.log("Ready!");
|
|
110
|
+
client.poru.init(client);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
client.on("interactionCreate", async (interaction) => {
|
|
114
|
+
if (!interaction.isChatInputCommand()) return;
|
|
115
|
+
if (!interaction.member.voice.channel)
|
|
116
|
+
return interaction.reply({
|
|
117
|
+
content: `Please connect with voice channel `,
|
|
118
|
+
ephemeral: true,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const track = interaction.options.getString("track");
|
|
122
|
+
|
|
123
|
+
const res = await client.poru.resolve({query:track,source:"scsearch",requester:interaction.member});
|
|
124
|
+
|
|
125
|
+
if (res.loadType === "error") {
|
|
126
|
+
return interaction.reply("Failed to load track.");
|
|
127
|
+
} else if (res.loadType === "empty") {
|
|
128
|
+
return interaction.reply("No source found!");
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
//create connection with discord voice channnel
|
|
132
|
+
const player = client.poru.createConnection({
|
|
133
|
+
guildId: interaction.guild.id,
|
|
134
|
+
voiceChannel: interaction.member.voice.channelId,
|
|
135
|
+
textChannel: interaction.channel.id,
|
|
136
|
+
deaf: true,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
if (res.loadType === "playlist") {
|
|
140
|
+
for (const track of res.tracks) {
|
|
141
|
+
track.info.requester = interaction.user;
|
|
142
|
+
player.queue.add(track);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
interaction.reply(
|
|
146
|
+
`${res.playlistInfo.name} has been loaded with ${res.tracks.length}`
|
|
147
|
+
);
|
|
148
|
+
} else {
|
|
149
|
+
const track = res.tracks[0];
|
|
150
|
+
track.info.requester = interaction.user;
|
|
151
|
+
player.queue.add(track);
|
|
152
|
+
interaction.reply(`Queued Track \n \`${track.info.title}\``)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (!player.isPlaying && player.isConnected) player.play();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
client.login("TOKEN");
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Need Help?
|
|
162
|
+
|
|
163
|
+
Feel free to join our [discord server](https://discord.gg/Zmmc47Nrh8), Give us suggestions and advice about errors and new features.
|
|
164
|
+
with ❤️ by [Paras](https://github.com/parasop) .
|
package/dist/src/Connection.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Player } from "./Player";
|
|
2
|
-
export interface IVoiceServer {
|
|
3
|
-
token: string;
|
|
4
|
-
sessionId: string;
|
|
5
|
-
endpoint: string;
|
|
6
|
-
}
|
|
7
|
-
export declare class Connection {
|
|
8
|
-
player: Player;
|
|
9
|
-
sessionId: string | null;
|
|
10
|
-
region: string | null;
|
|
11
|
-
voice: IVoiceServer | null;
|
|
12
|
-
self_mute: boolean;
|
|
13
|
-
self_deaf: boolean;
|
|
14
|
-
constructor(player: Player);
|
|
15
|
-
setServersUpdate(data: any): void;
|
|
16
|
-
setStateUpdate(data: any): void;
|
|
17
|
-
}
|
|
1
|
+
import { Player } from "./Player";
|
|
2
|
+
export interface IVoiceServer {
|
|
3
|
+
token: string;
|
|
4
|
+
sessionId: string;
|
|
5
|
+
endpoint: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class Connection {
|
|
8
|
+
player: Player;
|
|
9
|
+
sessionId: string | null;
|
|
10
|
+
region: string | null;
|
|
11
|
+
voice: IVoiceServer | null;
|
|
12
|
+
self_mute: boolean;
|
|
13
|
+
self_deaf: boolean;
|
|
14
|
+
constructor(player: Player);
|
|
15
|
+
setServersUpdate(data: any): void;
|
|
16
|
+
setStateUpdate(data: any): void;
|
|
17
|
+
}
|
package/dist/src/Connection.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Connection = void 0;
|
|
4
|
-
const Error_1 = require("./Error");
|
|
5
|
-
class Connection {
|
|
6
|
-
player;
|
|
7
|
-
sessionId;
|
|
8
|
-
region;
|
|
9
|
-
voice;
|
|
10
|
-
self_mute;
|
|
11
|
-
self_deaf;
|
|
12
|
-
constructor(player) {
|
|
13
|
-
this.player = player;
|
|
14
|
-
this.sessionId = null;
|
|
15
|
-
this.region = null;
|
|
16
|
-
this.voice = {
|
|
17
|
-
sessionId: null,
|
|
18
|
-
token: null,
|
|
19
|
-
endpoint: null,
|
|
20
|
-
};
|
|
21
|
-
this.self_mute = false;
|
|
22
|
-
this.self_deaf = false;
|
|
23
|
-
}
|
|
24
|
-
setServersUpdate(data) {
|
|
25
|
-
if (!data.endpoint)
|
|
26
|
-
throw new Error(Error_1.Errors.sessionNotFound);
|
|
27
|
-
this.voice.endpoint = data.endpoint;
|
|
28
|
-
this.voice.token = data.token;
|
|
29
|
-
this.region =
|
|
30
|
-
data.endpoint.split(".").shift()?.replace(/[0-9]/g, "") || null;
|
|
31
|
-
this.player.node.rest.updatePlayer({
|
|
32
|
-
guildId: this.player.guildId,
|
|
33
|
-
data: { voice: this.voice },
|
|
34
|
-
});
|
|
35
|
-
this.player.poru.emit("debug", this.player.node.name, `[Voice] <- [Discord] : Voice Server Update | Server: ${this.region} Guild: ${this.player.guildId}`);
|
|
36
|
-
}
|
|
37
|
-
setStateUpdate(data) {
|
|
38
|
-
const { session_id, channel_id, self_deaf, self_mute } = data;
|
|
39
|
-
if (this.player.voiceChannel &&
|
|
40
|
-
channel_id &&
|
|
41
|
-
this.player.voiceChannel !== channel_id) {
|
|
42
|
-
this.player.voiceChannel = channel_id;
|
|
43
|
-
}
|
|
44
|
-
this.self_deaf = self_deaf;
|
|
45
|
-
this.self_mute = self_mute;
|
|
46
|
-
this.voice.sessionId = session_id || null;
|
|
47
|
-
// this.player.poru.emit('debug', this.player.node.name, `[Voice] <- [Discord] : State Update Received | Channel: ${this.player.voiceChannel} Session ID: ${session_id} Guild: ${this.player.guildId}`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.Connection = Connection;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Connection = void 0;
|
|
4
|
+
const Error_1 = require("./Error");
|
|
5
|
+
class Connection {
|
|
6
|
+
player;
|
|
7
|
+
sessionId;
|
|
8
|
+
region;
|
|
9
|
+
voice;
|
|
10
|
+
self_mute;
|
|
11
|
+
self_deaf;
|
|
12
|
+
constructor(player) {
|
|
13
|
+
this.player = player;
|
|
14
|
+
this.sessionId = null;
|
|
15
|
+
this.region = null;
|
|
16
|
+
this.voice = {
|
|
17
|
+
sessionId: null,
|
|
18
|
+
token: null,
|
|
19
|
+
endpoint: null,
|
|
20
|
+
};
|
|
21
|
+
this.self_mute = false;
|
|
22
|
+
this.self_deaf = false;
|
|
23
|
+
}
|
|
24
|
+
setServersUpdate(data) {
|
|
25
|
+
if (!data.endpoint)
|
|
26
|
+
throw new Error(Error_1.Errors.sessionNotFound);
|
|
27
|
+
this.voice.endpoint = data.endpoint;
|
|
28
|
+
this.voice.token = data.token;
|
|
29
|
+
this.region =
|
|
30
|
+
data.endpoint.split(".").shift()?.replace(/[0-9]/g, "") || null;
|
|
31
|
+
this.player.node.rest.updatePlayer({
|
|
32
|
+
guildId: this.player.guildId,
|
|
33
|
+
data: { voice: this.voice },
|
|
34
|
+
});
|
|
35
|
+
this.player.poru.emit("debug", this.player.node.name, `[Voice] <- [Discord] : Voice Server Update | Server: ${this.region} Guild: ${this.player.guildId}`);
|
|
36
|
+
}
|
|
37
|
+
setStateUpdate(data) {
|
|
38
|
+
const { session_id, channel_id, self_deaf, self_mute } = data;
|
|
39
|
+
if (this.player.voiceChannel &&
|
|
40
|
+
channel_id &&
|
|
41
|
+
this.player.voiceChannel !== channel_id) {
|
|
42
|
+
this.player.voiceChannel = channel_id;
|
|
43
|
+
}
|
|
44
|
+
this.self_deaf = self_deaf;
|
|
45
|
+
this.self_mute = self_mute;
|
|
46
|
+
this.voice.sessionId = session_id || null;
|
|
47
|
+
// this.player.poru.emit('debug', this.player.node.name, `[Voice] <- [Discord] : State Update Received | Channel: ${this.player.voiceChannel} Session ID: ${session_id} Guild: ${this.player.guildId}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.Connection = Connection;
|
|
51
51
|
//# sourceMappingURL=Connection.js.map
|
package/dist/src/Error.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare enum Errors {
|
|
2
|
-
sessionNotFound = ""
|
|
3
|
-
}
|
|
1
|
+
export declare enum Errors {
|
|
2
|
+
sessionNotFound = ""
|
|
3
|
+
}
|
package/dist/src/Error.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Errors = void 0;
|
|
4
|
-
var Errors;
|
|
5
|
-
(function (Errors) {
|
|
6
|
-
Errors["sessionNotFound"] = "";
|
|
7
|
-
})(Errors = exports.Errors || (exports.Errors = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Errors = void 0;
|
|
4
|
+
var Errors;
|
|
5
|
+
(function (Errors) {
|
|
6
|
+
Errors["sessionNotFound"] = "";
|
|
7
|
+
})(Errors = exports.Errors || (exports.Errors = {}));
|
|
8
8
|
//# sourceMappingURL=Error.js.map
|