discord-player 5.2.1 → 5.3.0-dev.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/LICENSE +21 -21
- package/README.md +24 -20
- package/dist/Player.js +337 -325
- package/dist/Structures/ExtractorModel.js +19 -24
- package/dist/Structures/Playlist.js +1 -2
- package/dist/Structures/Queue.js +260 -269
- package/dist/Structures/Track.js +11 -14
- package/dist/VoiceInterface/StreamDispatcher.js +32 -38
- package/dist/VoiceInterface/VoiceUtils.js +22 -25
- package/dist/{VolumeTransformer.js → VoiceInterface/VolumeTransformer.js} +35 -9
- package/dist/index.d.ts +13 -7
- package/dist/index.js +3 -1
- package/dist/smoothVolume.js +11 -3
- package/dist/utils/Util.js +34 -1
- package/package.json +29 -31
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020-present Androz
|
|
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) 2020-present Androz
|
|
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
|
@@ -47,34 +47,33 @@ First of all, you will need to register slash commands:
|
|
|
47
47
|
|
|
48
48
|
```js
|
|
49
49
|
const { REST } = require("@discordjs/rest");
|
|
50
|
-
const { Routes } = require("discord
|
|
50
|
+
const { Routes, ApplicationCommandOptionType } = require("discord.js");
|
|
51
51
|
|
|
52
|
-
const commands = [
|
|
52
|
+
const commands = [
|
|
53
|
+
{
|
|
53
54
|
name: "play",
|
|
54
55
|
description: "Plays a song!",
|
|
55
56
|
options: [
|
|
56
57
|
{
|
|
57
58
|
name: "query",
|
|
58
|
-
type:
|
|
59
|
+
type: ApplicationCommandOptionType.String,
|
|
59
60
|
description: "The song you want to play",
|
|
60
61
|
required: true
|
|
61
62
|
}
|
|
62
63
|
]
|
|
63
|
-
}
|
|
64
|
+
}
|
|
65
|
+
];
|
|
64
66
|
|
|
65
|
-
const rest = new REST({ version: "
|
|
67
|
+
const rest = new REST({ version: "10" }).setToken("BOT_TOKEN");
|
|
66
68
|
|
|
67
69
|
(async () => {
|
|
68
70
|
try {
|
|
69
71
|
console.log("Started refreshing application [/] commands.");
|
|
70
72
|
|
|
71
|
-
await rest.put(
|
|
72
|
-
Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID),
|
|
73
|
-
{ body: commands },
|
|
74
|
-
);
|
|
73
|
+
await rest.put(Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID), { body: commands });
|
|
75
74
|
|
|
76
75
|
console.log("Successfully reloaded application [/] commands.");
|
|
77
|
-
} catch
|
|
76
|
+
} catch(error) {
|
|
78
77
|
console.error(error);
|
|
79
78
|
}
|
|
80
79
|
})();
|
|
@@ -83,8 +82,13 @@ const rest = new REST({ version: "9" }).setToken(process.env.DISCORD_TOKEN);
|
|
|
83
82
|
Now you can implement your bot's logic:
|
|
84
83
|
|
|
85
84
|
```js
|
|
86
|
-
const { Client
|
|
87
|
-
const client = new Discord.Client({
|
|
85
|
+
const { Client } = require("discord.js");
|
|
86
|
+
const client = new Discord.Client({
|
|
87
|
+
intents: [
|
|
88
|
+
"Guilds",
|
|
89
|
+
"GuildVoiceStates"
|
|
90
|
+
]
|
|
91
|
+
});
|
|
88
92
|
const { Player } = require("discord-player");
|
|
89
93
|
|
|
90
94
|
// Create a new Player (you don't need any API Key)
|
|
@@ -98,14 +102,14 @@ client.once("ready", () => {
|
|
|
98
102
|
});
|
|
99
103
|
|
|
100
104
|
client.on("interactionCreate", async (interaction) => {
|
|
101
|
-
if (!interaction.
|
|
105
|
+
if (!interaction.isChatInputCommand()) return;
|
|
102
106
|
|
|
103
107
|
// /play track:Despacito
|
|
104
108
|
// will play "Despacito" in the voice channel
|
|
105
109
|
if (interaction.commandName === "play") {
|
|
106
110
|
if (!interaction.member.voice.channelId) return await interaction.reply({ content: "You are not in a voice channel!", ephemeral: true });
|
|
107
|
-
if (interaction.guild.me.voice.channelId && interaction.member.voice.channelId !== interaction.guild.me.voice.channelId) return await interaction.reply({ content: "You are not in my voice channel!", ephemeral: true });
|
|
108
|
-
const query = interaction.options.
|
|
111
|
+
if (interaction.guild.members.me.voice.channelId && interaction.member.voice.channelId !== interaction.guild.members.me.voice.channelId) return await interaction.reply({ content: "You are not in my voice channel!", ephemeral: true });
|
|
112
|
+
const query = interaction.options.getString("query");
|
|
109
113
|
const queue = player.createQueue(interaction.guild, {
|
|
110
114
|
metadata: {
|
|
111
115
|
channel: interaction.channel
|
|
@@ -132,7 +136,7 @@ client.on("interactionCreate", async (interaction) => {
|
|
|
132
136
|
}
|
|
133
137
|
});
|
|
134
138
|
|
|
135
|
-
client.login(
|
|
139
|
+
client.login("BOT_TOKEN");
|
|
136
140
|
```
|
|
137
141
|
|
|
138
142
|
## Supported websites
|
|
@@ -143,14 +147,14 @@ By default, discord-player supports **YouTube**, **Spotify** and **SoundCloud**
|
|
|
143
147
|
|
|
144
148
|
Discord Player provides an **Extractor API** that enables you to use your custom stream extractor with it. Some packages have been made by the community to add new features using this API.
|
|
145
149
|
|
|
146
|
-
#### [@discord-player/extractor](https://github.com/
|
|
150
|
+
#### [@discord-player/extractor](https://github.com/DevAndromeda/discord-player-extractors) (optional)
|
|
147
151
|
|
|
148
152
|
Optional package that adds support for `vimeo`, `reverbnation`, `facebook`, `attachment links` and `lyrics`.
|
|
149
153
|
You just need to install it using `npm i --save @discord-player/extractor` (discord-player will automatically detect and use it).
|
|
150
154
|
|
|
151
|
-
#### [@discord-player/downloader](https://github.com/
|
|
155
|
+
#### [@discord-player/downloader](https://github.com/DevAndromeda/discord-player-downloader) (optional)
|
|
152
156
|
|
|
153
|
-
`@discord-player/downloader` is an optional package that brings support for +700 websites. The documentation is available [here](https://github.com/
|
|
157
|
+
`@discord-player/downloader` is an optional package that brings support for +700 websites. The documentation is available [here](https://github.com/DevAndromeda/discord-player-downloader).
|
|
154
158
|
|
|
155
159
|
## Examples of bots made with Discord Player
|
|
156
160
|
|
|
@@ -168,7 +172,7 @@ These bots are made by the community, they can help you build your own!
|
|
|
168
172
|
|
|
169
173
|
### Smooth Volume
|
|
170
174
|
|
|
171
|
-
Discord Player will
|
|
175
|
+
Discord Player will by default try to implement this. If smooth volume does not work, you need to add this line at the top of your main file:
|
|
172
176
|
|
|
173
177
|
```js
|
|
174
178
|
// CJS
|