Version 0.4.0 - Ajout du Loop, Volume et de la déconnexion
This commit is contained in:
		@@ -194,8 +194,8 @@ function startErelaManager(dlog, config) {
 | 
			
		||||
 | 
			
		||||
    const list = new List() 
 | 
			
		||||
    
 | 
			
		||||
    client.manager.on("playerCreate", (player) => {
 | 
			
		||||
        client.channels.fetch(player.options.voiceChannel).then(channel => {
 | 
			
		||||
    client.manager.on("playerCreate", async (player) => {
 | 
			
		||||
        await client.channels.fetch(player.options.voiceChannel).then(channel => {
 | 
			
		||||
            plog.log("Nouveau Player instancié dans : " + channel.name)
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
@@ -204,10 +204,10 @@ function startErelaManager(dlog, config) {
 | 
			
		||||
   
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    client.manager.on("playerDestroy", (player) => {
 | 
			
		||||
    client.manager.on("playerDestroy",async (player) => {
 | 
			
		||||
 | 
			
		||||
        list.destroy()
 | 
			
		||||
        client.channels.fetch(player.options.voiceChannel).then(channel => {
 | 
			
		||||
        await list.destroy()
 | 
			
		||||
        await client.channels.fetch(player.options.voiceChannel).then(channel => {
 | 
			
		||||
            plog.log("Player supprimé dans : " + channel.name)
 | 
			
		||||
        })
 | 
			
		||||
 
 | 
			
		||||
@@ -215,21 +215,21 @@ function startErelaManager(dlog, config) {
 | 
			
		||||
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    client.manager.on("trackStart", (song) => {
 | 
			
		||||
        plog.log("Lecture de '" + song.queue.current.title + "' de '" + song.queue.current.author + "'")
 | 
			
		||||
        list.setCurrent(song)
 | 
			
		||||
 | 
			
		||||
    client.manager.on("trackStart",async (player) => {
 | 
			
		||||
        plog.log("Lecture de '" + player.queue.current.title + "' de '" + player.queue.current.author + "'")
 | 
			
		||||
        await  list.setCurrent(player)
 | 
			
		||||
        await player.seek(0)
 | 
			
		||||
        process.emit("MUSIC_UPDATE_STATE")
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    client.manager.on("queueEnd", () => {
 | 
			
		||||
    client.manager.on("queueEnd", async () => {
 | 
			
		||||
        let player = client.manager.players.get("137291455336022018")
 | 
			
		||||
        if(player) { 
 | 
			
		||||
 | 
			
		||||
            list.passCurrent()
 | 
			
		||||
            await list.passCurrent()
 | 
			
		||||
            if(list.haveSongs()) {
 | 
			
		||||
                player.play(list.next())
 | 
			
		||||
                await player.play(list.next())
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
         
 | 
			
		||||
 
 | 
			
		||||
@@ -174,6 +174,39 @@ module.exports.getState = function(client, interaction) {
 | 
			
		||||
 | 
			
		||||
   
 | 
			
		||||
        
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports.SPECIAL_MJ = async function (client) {
 | 
			
		||||
 | 
			
		||||
    if(!client) {
 | 
			
		||||
 | 
			
		||||
        client = discord.getClient()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let player = client.manager.players.get("137291455336022018")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    if(!player) { 
 | 
			
		||||
            
 | 
			
		||||
        player = client.manager.create({
 | 
			
		||||
            guild: "137291455336022018",
 | 
			
		||||
            voiceChannel: "664355734288465920",
 | 
			
		||||
            textChannel: "664355637685256203",
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        player.connect();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    const songs = await client.manager.search("Earth MJ")
 | 
			
		||||
    const songs2 = await client.manager.search("They don't care About Us")
 | 
			
		||||
 | 
			
		||||
    player.play(songs.tracks[0])
 | 
			
		||||
 | 
			
		||||
    list.add(songs2.tracks[0])
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports.skip = function (client, interaction) {
 | 
			
		||||
@@ -243,7 +276,12 @@ module.exports.seek = function (data) {
 | 
			
		||||
 | 
			
		||||
    let player = client.manager.players.get("137291455336022018")
 | 
			
		||||
 | 
			
		||||
    player.seek(data)
 | 
			
		||||
    if(player) {
 | 
			
		||||
 | 
			
		||||
        player.seek(data)
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    process.emit("MUSIC_UPDATE_STATE")
 | 
			
		||||
 | 
			
		||||
@@ -251,6 +289,55 @@ module.exports.seek = function (data) {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports.setVol = function (data) {
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
    client = discord.getClient()
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    let player = client.manager.players.get("137291455336022018")
 | 
			
		||||
 | 
			
		||||
    if(player) {
 | 
			
		||||
 | 
			
		||||
        player.setVolume(data)
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    process.emit("MUSIC_UPDATE_STATE")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports.loop = function (client) {
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    if(!client) {
 | 
			
		||||
 | 
			
		||||
        client = discord.getClient()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let player = client.manager.players.get("137291455336022018")
 | 
			
		||||
 | 
			
		||||
    if(player) {
 | 
			
		||||
 | 
			
		||||
        if(player.queueRepeat == true) {
 | 
			
		||||
            player.setQueueRepeat(false)
 | 
			
		||||
        } else {
 | 
			
		||||
 | 
			
		||||
            player.setQueueRepeat(true)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    process.emit("MUSIC_UPDATE_STATE")
 | 
			
		||||
 | 
			
		||||
} 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
module.exports.previous = function (client, interaction) {
 | 
			
		||||
 | 
			
		||||
@@ -388,6 +475,11 @@ module.exports.leave = function (client, interaction) {
 | 
			
		||||
    if(interaction) {
 | 
			
		||||
 | 
			
		||||
        player = client.manager.players.get(interaction.guild.id)
 | 
			
		||||
    } else {
 | 
			
		||||
 | 
			
		||||
        client = discord.getClient()
 | 
			
		||||
        player = client.manager.players.get("137291455336022018")
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
        
 | 
			
		||||
    if(player) {
 | 
			
		||||
 
 | 
			
		||||
@@ -217,6 +217,27 @@ function IOConnection(io) {
 | 
			
		||||
            io.emit("ANSWER/GET/FORWARD", "OK")
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
        GetRequest(socket, "LOOP", () => {
 | 
			
		||||
 | 
			
		||||
            subplayer.loop()
 | 
			
		||||
            io.emit("ANSWER/GET/LOOP", "OK")
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
        GetRequest(socket, "DISCONNECT", () => {
 | 
			
		||||
 | 
			
		||||
            subplayer.leave()
 | 
			
		||||
            io.emit("ANSWER/GET/DISCONNECT", "OK")
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        GetRequest(socket, "SPECIAL/MJ", () => {
 | 
			
		||||
 | 
			
		||||
            subplayer.SPECIAL_MJ()
 | 
			
		||||
            io.emit("ANSWER/GET/SPECIAL/MJ", "OK")
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        // SEND REQUEST
 | 
			
		||||
 | 
			
		||||
        socket.on("SEND/SEEK", (data) => {
 | 
			
		||||
@@ -244,12 +265,35 @@ function IOConnection(io) {
 | 
			
		||||
         
 | 
			
		||||
           
 | 
			
		||||
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
        socket.on("SEND/VOLUME", (data) => {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            var cookies = socket.handshake.headers.cookie
 | 
			
		||||
 | 
			
		||||
            if(cookies) {
 | 
			
		||||
 | 
			
		||||
                cookies = cook.parse(cookies)
 | 
			
		||||
                var token = cookies.token
 | 
			
		||||
                 
 | 
			
		||||
                if(auth.checkUser(token)) {
 | 
			
		||||
 | 
			
		||||
                    subplayer.setVol(data)
 | 
			
		||||
                
 | 
			
		||||
                } else {
 | 
			
		||||
 | 
			
		||||
                    io.emit("ANSWER/SEND/VOLUME", {"error":"USER_DONT_EXIST"})
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                io.emit("ANSWER/SEND/VOLUME", {"error":"TOKEN_NOT_FINDED"})
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
         
 | 
			
		||||
           
 | 
			
		||||
 | 
			
		||||
        })
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
       
 | 
			
		||||
        
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
@@ -258,9 +302,6 @@ function IOConnection(io) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
function GetRequest (socket, name, func) {
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user