Version 0.4.0-alpha1

This commit is contained in:
2025-03-02 21:37:04 +01:00
parent 407d9d6b9a
commit 12c4e2740a
5 changed files with 24 additions and 4 deletions

View File

@@ -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"

View File

@@ -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}`)

View File

@@ -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}`)

View File

@@ -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);

View File

@@ -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"