Version 0.4.0-alpha1
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "chopin-backend",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"description": "Discord Bot for music - Fetching everywhere !",
|
||||
"main": "src/main.js",
|
||||
"nodemonConfig": {
|
||||
@@ -34,7 +34,7 @@
|
||||
"pm2": "^5.4.3",
|
||||
"socket.io": "^4.8.1",
|
||||
"soundcloud.ts": "^0.6.3",
|
||||
"spotify-web-api-node": "^5.0.2",
|
||||
"spotify-web-api-node": "^5.0.2",
|
||||
"uuid": "^11.1.0",
|
||||
"webmetrik": "^0.1.4",
|
||||
"ytfps": "^1.2.0"
|
||||
|
@@ -13,6 +13,8 @@ async function play(instance, song) {
|
||||
inputType: StreamType.Arbitrary
|
||||
}) // Remplace par ton fichier audio
|
||||
|
||||
|
||||
instance.setCurrentResource(resource)
|
||||
player.play(resource);
|
||||
instance.connection.subscribe(player);
|
||||
clog.log(`GUILD : ${instance.guildId} - Lecture de la musique (Media): ${song.title} - id : ${song.id}`)
|
||||
|
@@ -15,7 +15,7 @@ async function play(instance, song) {
|
||||
|
||||
const stream = await soundcloud.util.streamTrack(song.url)
|
||||
var resource = await createAudioResource(stream)
|
||||
|
||||
instance.setCurrentResource(resource)
|
||||
player.play(resource);
|
||||
instance.connection.subscribe(player);
|
||||
clog.log(`GUILD : ${instance.guildId} - Lecture de la musique (Soundcloud): ${song.title} - id : ${song.id}`)
|
||||
|
@@ -22,7 +22,7 @@ async function play(instance, song) {
|
||||
// Add compressor to the audio resource
|
||||
var resource = createAudioResource(stream);
|
||||
|
||||
|
||||
instance.setCurrentResource(resource)
|
||||
|
||||
player.play(resource);
|
||||
instance.connection.subscribe(player);
|
||||
|
@@ -17,6 +17,7 @@ class Player {
|
||||
guildId;
|
||||
channelId;
|
||||
queue;
|
||||
currentResource;
|
||||
constructor(guildId) {
|
||||
if(this.guildId === null) {
|
||||
clog.error("Impossible de créer un Player, car guildId est null")
|
||||
@@ -177,6 +178,23 @@ class Player {
|
||||
|
||||
}
|
||||
|
||||
setDuration(duration) {
|
||||
if(this.checkConnection()) return
|
||||
if(this.queue.current == null) return
|
||||
if(this.currentResource == null) return
|
||||
var maxduration = this.queue.current.duration
|
||||
if(duration > maxduration) return
|
||||
this.player.stop(); // Arrête la lecture actuelle
|
||||
this.player.play(this.currentResource, {
|
||||
startTime: duration * 1000 // Convertit le timecode en millisecondes
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
setCurrentResource(value) {
|
||||
this.currentResource = value;
|
||||
}
|
||||
|
||||
async skip() {
|
||||
|
||||
if(this.checkConnection()) return "no_music"
|
||||
|
Reference in New Issue
Block a user