Version 0.6.0 - Ajout des fonctionnalités externes de la version
This commit is contained in:
		@@ -1,6 +1,7 @@
 | 
			
		||||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
 | 
			
		||||
const { __glob } = require("../modules/global-variables");
 | 
			
		||||
const { LogType } = require('./sub-log');
 | 
			
		||||
const discord = require("./discord-bot")
 | 
			
		||||
 | 
			
		||||
const dlog = new LogType("Queue-List")
 | 
			
		||||
 | 
			
		||||
@@ -223,12 +224,39 @@ module.exports.List = class {
 | 
			
		||||
 | 
			
		||||
        } else {
 | 
			
		||||
 | 
			
		||||
            // [A FINIR POUR WEB]
 | 
			
		||||
        }
 | 
			
		||||
            if(!client) {
 | 
			
		||||
 | 
			
		||||
                client = discord.getClient()
 | 
			
		||||
            }
 | 
			
		||||
        
 | 
			
		||||
            let player = client.manager.players.get("137291455336022018")
 | 
			
		||||
        
 | 
			
		||||
            if(!player) { 
 | 
			
		||||
            
 | 
			
		||||
                player = client.manager.create({
 | 
			
		||||
                    guild: "137291455336022018",
 | 
			
		||||
                    voiceChannel: discord.getMemberVoices().get(userId),
 | 
			
		||||
                    textChannel: "664355637685256203",
 | 
			
		||||
                });
 | 
			
		||||
        
 | 
			
		||||
        
 | 
			
		||||
                player.connect();
 | 
			
		||||
            }
 | 
			
		||||
        
 | 
			
		||||
            for(var song of playlist) {
 | 
			
		||||
        
 | 
			
		||||
                const song_finded = await client.manager.search(song.url)
 | 
			
		||||
                next.push(song_finded.tracks[0])
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if(!player.playing) {
 | 
			
		||||
 | 
			
		||||
               player.play(next[0])
 | 
			
		||||
               this.remove(next[0])
 | 
			
		||||
            
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    } 
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -175,6 +175,16 @@ module.exports.getState = function(client, interaction) {
 | 
			
		||||
 | 
			
		||||
   
 | 
			
		||||
        
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports.playPlaylist = function (data, client) {
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    list.playlistAdd(data, null)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports.SPECIAL_MJ = async function (client, userId) {
 | 
			
		||||
 
 | 
			
		||||
@@ -89,6 +89,20 @@ module.exports.removeSong = function (id, name, song ) {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports.playPlaylist = function (id, name) {
 | 
			
		||||
    check()
 | 
			
		||||
    if(playlists[id][name]) {
 | 
			
		||||
        plog.log("Ajout de la playlist à l'utilisateur \"" + id  + "\" dans la liste de lecture !")
 | 
			
		||||
        
 | 
			
		||||
        subplayer.playPlaylist(playlists[id][name])
 | 
			
		||||
    } else {
 | 
			
		||||
 | 
			
		||||
        plog.log("L'utilisateur \"" + id  + "\" n'a pas une playlist avec le nom "+ name + " dans la base de donnée Playlist !")
 | 
			
		||||
    
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
function check() {
 | 
			
		||||
 
 | 
			
		||||
@@ -599,6 +599,42 @@ function IOConnection(io) {
 | 
			
		||||
         
 | 
			
		||||
           
 | 
			
		||||
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
        socket.on("SEND/PLAY_PLAYLIST", async (data) => {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            var cookies = socket.handshake.headers.cookie
 | 
			
		||||
 | 
			
		||||
            if(cookies) {
 | 
			
		||||
 | 
			
		||||
                cookies = cook.parse(cookies)
 | 
			
		||||
                var token = cookies.token
 | 
			
		||||
                 
 | 
			
		||||
                if(auth.checkUser(token)) {
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
                    var user = auth.getUser(token)
 | 
			
		||||
                    var userId = user.user.id
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    subplaylist.playPlaylist(userId, data)
 | 
			
		||||
                    
 | 
			
		||||
                    io.emit("DO_UPDATE_PLAYLIST")
 | 
			
		||||
                    io.emit("ANSWER/SEND/PLAY_PLAYLIST/OK")
 | 
			
		||||
                
 | 
			
		||||
                } else {
 | 
			
		||||
 | 
			
		||||
                    io.emit("ANSWER/SEND/PLAY_PLAYLIST", {"error":"USER_DONT_EXIST"})
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                io.emit("ANSWER/SEND/PLAY_PLAYLIST", {"error":"TOKEN_NOT_FINDED"})
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
         
 | 
			
		||||
           
 | 
			
		||||
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -88,6 +88,16 @@ function delPlayList(key) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
function playPlayList(key) {
 | 
			
		||||
 | 
			
		||||
    send("PLAY_PLAYLIST", key)
 | 
			
		||||
 
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
socket.on("DO_UPDATE_PLAYLIST", () => {
 | 
			
		||||
@@ -184,7 +194,7 @@ socket.on("ANSWER/GET/PLAYLIST", (data) => {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        playlistToPush.push('<div class="apPres"><div class="apTitle"><img class="apTile" src="/images/playlist-tile.svg"><p class="apName">' + key + '</p></div><div class="apButtons"><button id="'+ key +'_playlistplay" class="primary"><i class="fas fa-play"></i></button><button onclick="delPlayList(\''+ key +'\')" "id="'+ key +'_playlistdelete" class="list_delete"><i class="fas fa-trash"></i></button></div></div><hr>' + playlist_songs.join(""))
 | 
			
		||||
        playlistToPush.push('<div class="apPres"><div class="apTitle"><img class="apTile" src="/images/playlist-tile.svg"><p class="apName">' + key + '</p></div><div class="apButtons"><button onclick="playPlayList(\''+ key +'\')" id="'+ key +'_playlistplay" class="primary"><i class="fas fa-play"></i></button><button onclick="delPlayList(\''+ key +'\')" "id="'+ key +'_playlistdelete" class="list_delete"><i class="fas fa-trash"></i></button></div></div><hr>' + playlist_songs.join(""))
 | 
			
		||||
        
 | 
			
		||||
        if(playlistToPush.join("") == "") {
 | 
			
		||||
    
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user