Version 1.1.1 - Premier Deploy

This commit is contained in:
2025-08-28 23:15:27 +02:00
parent e313d4228c
commit 8b2728622c
18 changed files with 1849 additions and 1282 deletions

View File

@@ -60,6 +60,7 @@ class List {
}
this.setCurrent(song)
process.emit("PLAYERS_UPDATE")
//TODO: Check History and continuity
return song
}

View File

@@ -5,6 +5,7 @@ const songCheck = require('./SongCheck')
const ffmpeg = require('fluent-ffmpeg')
const fs = require('fs')
const { PassThrough } = require('stream');
const { Metric } = require('webmetrik')
const plog = new LogType("Player")
const clog = new LogType("Signal")
@@ -21,6 +22,7 @@ class Player {
player;
guildId;
channelId;
channelName;
queue;
currentResource;
loop = false;
@@ -29,7 +31,9 @@ class Player {
clog.error("Impossible de créer un Player, car guildId est null")
return
}
if(AllPlayers.has(guildId)) {
return AllPlayers.get(guildId)
}
this.connection = null
@@ -37,6 +41,7 @@ class Player {
this.guildId = guildId
this.queue = new List(guildId)
AllPlayers.set(guildId, this)
}
async join(channel) {
@@ -59,6 +64,7 @@ class Player {
joinChannel(channel) {
this.channelId = channel.id
this.channelName = channel.name
this.connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
@@ -77,6 +83,8 @@ class Player {
}
});
this.connected = true
AllPlayers.set(this.guildId, this)
process.emit("PLAYERS_UPDATE")
}
@@ -134,7 +142,7 @@ class Player {
const state = {
current: this.queue.current,
next: this.queue.next,
previous: this.queue.previous,
previous: this.queue.getPrevious(),
loop: this.loop,
shuffle: this.queue.shuffle,
paused: playerStatus === AudioPlayerStatus.Paused,
@@ -143,6 +151,7 @@ class Player {
playerState: playerStatus,
connectionState: connectionStatus,
channelId: this.channelId,
channelName: this.channelName,
guildId: this.guildId,
}
return state
@@ -171,12 +180,19 @@ class Player {
}
async play(song) {
if(!songCheck.checkSong(song)) return
if(this.checkConnection()) return
if(this.queue.current != null) {
this.player.stop()
}
var numberOfMusicPlayedPerServer = new Metric("numberOfMusicPlayed_" + this.guildId, "Nombre de musiques jouées sur le serveur : " + this.guildId)
numberOfMusicPlayedPerServer.setValue(numberOfMusicPlayedPerServer.getValue() + 1)
var numberOfSecondsPlayedPerServer = new Metric("numberOfSecondsPlayed_" + this.guildId, "Temps jouée sur le serveur : " + this.guildId)
numberOfSecondsPlayedPerServer.setValue(numberOfSecondsPlayedPerServer.getValue() + song.duration)
this.queue.setCurrent(song)
this.stream = await this.getStream(song)
@@ -240,8 +256,7 @@ class Player {
process.emit("PLAYERS_UPDATE")
return true
}
const { LogType } = require('loguix')
}
@@ -257,6 +272,7 @@ class Player {
this.player = null
this.connection = null
this.channelId = null
this.channelName = null
this.connected = false
Activity.idleActivity()
this.queue.destroy()
@@ -291,6 +307,7 @@ class Player {
}
const passThroughStream = new PassThrough();
duration = Math.floor(duration.time);
ffmpeg(this.stream)
.setStartTime(duration) // Démarrer à la position demandée (en secondes)
.outputOptions('-f', 'mp3') // Specify output format if needed
@@ -398,6 +415,7 @@ function getAllPlayers() {
AllPlayers.forEach((player) => {
players.push(player)
})
return players
}
function isPlayer(guildId) {

View File

@@ -51,31 +51,17 @@ class Song {
}
async processYoutubeVideo(video, playlist) {
if(playlist) {
async processYoutubeVideo(video) {
this.title = video.title
this.author = video.author.name
this.authorId = video.author.channel_url
this.thumbnail = video.thumbnail_url
this.url = video.url
this.authorId = video.author.url
this.thumbnail = video.thumbnail
this.url = "https://www.youtube.com/watch?v=" + video.videoId
this.type = "youtube"
this.id = video.id
this.id = video.videoId
this.duration = video.milis_length / 1000
this.duration = video.duration.seconds
this.readduration = getReadableDuration(this.duration)
} else {
this.title = video.name
this.author = video.author.name
this.authorId = video.author.url
this.thumbnail = video.thumbnail
this.url = video.url
this.type = "youtube"
this.id = video.id
this.duration = getSecondsDuration(video.duration)
this.readduration = getReadableDuration(this.duration)
}
return this
}

View File

@@ -26,11 +26,11 @@ function checkSong(song) {
slog.error("La musique n'a pas d'auteur")
return false
}
if(!song.duration) {
if(song.duration == null) {
slog.error("La musique n'a pas de durée")
return false
}
if(!song.readduration) {
if(song.readduration == null) {
slog.error("La musique n'a pas de durée lisible")
return false
}