Version 0.6.0 - Ajout des fonctionnalités externes de la version

This commit is contained in:
Raphix
2023-08-29 11:51:22 +02:00
parent d5651f8cef
commit d1a0130f00
7 changed files with 177 additions and 18 deletions

View File

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

View File

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

View File

@ -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() {

View File

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