V6
All checks were successful
Subsonics - Pipeline/pipeline/head This commit looks good

This commit is contained in:
CICD - Pipeline 2023-04-28 17:06:31 +02:00
parent 9c5ade930c
commit 28ec915144
2 changed files with 261 additions and 36 deletions

View File

@ -6,12 +6,16 @@ if ("ENV" in process.env) {
} }
const { error } = require("node:console")
const log = require("./sublog.js") const log = require("./sublog.js")
const { config } = require("node:process")
const { platform } = require("node:os")
const nodes = [
{
host: "lavalink.devamop.in",
password: "DevamOP",
port: 443,
secure: true
}
];
function startDiscordBot() { function startDiscordBot() {
@ -22,7 +26,7 @@ function startDiscordBot() {
const fs = require("node:fs") const fs = require("node:fs")
const config = require("./config.json") const config = require("./config.json")
const path = require("path") const path = require("path")
const { Manager, TrackUtils } = require("erela.js") const { Manager } = require("erela.js")
const client = new Client({ const client = new Client({
intents:[GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildMembers] intents:[GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildMembers]
@ -127,14 +131,7 @@ function startDiscordBot() {
const nodes = [
{
host: "lavalink.devamop.in",
password: "DevamOP",
port: 443,
secure: true
}
];
client.manager = new Manager({ client.manager = new Manager({
// The nodes to connect to, optional if using default lavalink options // The nodes to connect to, optional if using default lavalink options
@ -186,7 +183,7 @@ function startServer(client) {
const fs = require("fs") const fs = require("fs")
const path = require("path") const path = require("path")
var changeMusic = 0
var link = null var link = null
var discordlink = null var discordlink = null
@ -207,6 +204,10 @@ function startServer(client) {
var onlineNumber = 0; var onlineNumber = 0;
function reimportUser() {
const tokens = require(__dirname + path.sep + "tokens.json") const tokens = require(__dirname + path.sep + "tokens.json")
users = new Map() users = new Map()
@ -215,6 +216,10 @@ function startServer(client) {
users.set(user , tokens[user]) users.set(user , tokens[user])
} }
return users
}
app.use(cookieParser()) app.use(cookieParser())
@ -327,8 +332,16 @@ function startServer(client) {
}) })
socket.on("getState", (token) => { socket.on("getState", (token) => {
reimportUser()
actualize() actualize()
sendState(socket, token) console.log(token)
console.log(users)
const data = {
"username":users.get(token).username + "#" + users.get(token).discriminator,
"avatar": users.get(token).avatar,
"id": users.get(token).id,
}
socket.emit("updateState", data)
}) })
socket.on("play", (token) => { socket.on("play", (token) => {
@ -360,6 +373,48 @@ function startServer(client) {
actualize() actualize()
}) })
socket.on("seek", (token, pos) => {
if(users.has(token)) {
log.server("Avancement demandé par " + users.get(token).username + "#" + users.get(token).discriminator)
let player = client.manager.players.get("137291455336022018")
if(player) {
player.seek(pos)
}
actualize()
} else {
socket.emit("authFailed")
}
})
socket.on("volume", (token, pos) => {
if(users.has(token)) {
log.server("Changement de volume demandé par " + users.get(token).username + "#" + users.get(token).discriminator)
let player = client.manager.players.get("137291455336022018")
if(player) {
player.setVolume(pos * 10)
}
actualize()
} else {
socket.emit("authFailed")
}
})
socket.on("listClear", (token) => { socket.on("listClear", (token) => {
if(users.has(token)) { if(users.has(token)) {
@ -513,6 +568,32 @@ function startServer(client) {
}) })
socket.on("restart", (token) => {
if(users.has(token)) {
log.server("Restart demandé par " + users.get(token).username + "#" + users.get(token).discriminator)
let player = client.manager.players.get("137291455336022018")
if(player) {
player.destroy()
}
client.manager.createNode(nodes)
actualize()
} else {
socket.emit("authFailed")
}
})
}); });
@ -533,6 +614,7 @@ function startServer(client) {
client.manager.on("trackStart", () => { client.manager.on("trackStart", () => {
log.server("Player : New Track Start-> Actualize all client !") log.server("Player : New Track Start-> Actualize all client !")
changeMusic += 1
actualize() actualize()
}) })
@ -562,7 +644,9 @@ function startServer(client) {
"queue": null, "queue": null,
"loop": false, "loop": false,
"durationNow": null, "durationNow": null,
"durationAll": null "durationAll": null,
"changeMusic": changeMusic,
"volume": null
} }
if(player) { if(player) {
@ -574,6 +658,7 @@ function startServer(client) {
data["loop"] = true data["loop"] = true
} }
data["volume"] = player.volume
if(player.queue.current) { if(player.queue.current) {
@ -619,25 +704,13 @@ function startServer(client) {
} }
} }
function sendState(socket, token) {
const data = {
"username":users.get(token).username + "#" + users.get(token).discriminator,
"avatar": users.get(token).avatar,
"id": users.get(token).id,
}
socket.emit("updateState", data)
}
app.get("/redirect", (req, res) => { app.get("/redirect", (req, res) => {
let token = req.cookies.authLoginFollow let token = req.cookies.authLoginFollow
if(token != null) { if(token != null) {
if(authTokenWait.has(token) == true) { if(authTokenWait.has(token) == true) {

View File

@ -1,3 +1,155 @@
{ {
"68e45a4a-0f46-4a0c-b4aa-efac9439b0cc": {
"id": "486943594893017119",
"username": "Raphix",
"global_name": null,
"display_name": null,
"avatar": "883ec1a7136b0aa3c22e4bdc33e278e5",
"discriminator": "8434",
"public_flags": 4194368,
"flags": 4194368,
"banner": null,
"banner_color": "#ff4d4d",
"accent_color": 16731469,
"locale": "fr",
"mfa_enabled": true,
"premium_type": 0,
"avatar_decoration": null
},
"d13687de-adcd-454b-8f82-d5a67f1aefda": {
"id": "486943594893017119",
"username": "Raphix",
"global_name": null,
"display_name": null,
"avatar": "883ec1a7136b0aa3c22e4bdc33e278e5",
"discriminator": "8434",
"public_flags": 4194368,
"flags": 4194368,
"banner": null,
"banner_color": "#ff4d4d",
"accent_color": 16731469,
"locale": "fr",
"mfa_enabled": true,
"premium_type": 0,
"avatar_decoration": null
},
"3410460a-ff5c-4075-901c-13660ffd496d": {
"id": "486943594893017119",
"username": "Raphix",
"global_name": null,
"display_name": null,
"avatar": "883ec1a7136b0aa3c22e4bdc33e278e5",
"discriminator": "8434",
"public_flags": 4194368,
"flags": 4194368,
"banner": null,
"banner_color": "#ff4d4d",
"accent_color": 16731469,
"locale": "fr",
"mfa_enabled": true,
"premium_type": 0,
"avatar_decoration": null
},
"af09802f-fa3a-4ebe-8b34-51a6375408d1": {
"id": "486943594893017119",
"username": "Raphix",
"global_name": null,
"display_name": null,
"avatar": "883ec1a7136b0aa3c22e4bdc33e278e5",
"discriminator": "8434",
"public_flags": 4194368,
"flags": 4194368,
"banner": null,
"banner_color": "#ff4d4d",
"accent_color": 16731469,
"locale": "fr",
"mfa_enabled": true,
"premium_type": 0,
"avatar_decoration": null
},
"5be82e44-2ecf-4f1c-8850-37886e15937b": {
"id": "486943594893017119",
"username": "Raphix",
"global_name": null,
"display_name": null,
"avatar": "883ec1a7136b0aa3c22e4bdc33e278e5",
"discriminator": "8434",
"public_flags": 4194368,
"flags": 4194368,
"banner": null,
"banner_color": "#ff4d4d",
"accent_color": 16731469,
"locale": "fr",
"mfa_enabled": true,
"premium_type": 0,
"avatar_decoration": null
},
"1c62461d-7cc9-44e2-a42a-6fae79baabb6": {
"id": "486943594893017119",
"username": "Raphix",
"global_name": null,
"display_name": null,
"avatar": "883ec1a7136b0aa3c22e4bdc33e278e5",
"discriminator": "8434",
"public_flags": 4194368,
"flags": 4194368,
"banner": null,
"banner_color": "#ff4d4d",
"accent_color": 16731469,
"locale": "fr",
"mfa_enabled": true,
"premium_type": 0,
"avatar_decoration": null
},
"cdba02f4-3473-4c76-8567-ef8965e0c211": {
"id": "486943594893017119",
"username": "Raphix",
"global_name": null,
"display_name": null,
"avatar": "883ec1a7136b0aa3c22e4bdc33e278e5",
"discriminator": "8434",
"public_flags": 4194368,
"flags": 4194368,
"banner": null,
"banner_color": "#ff4d4d",
"accent_color": 16731469,
"locale": "fr",
"mfa_enabled": true,
"premium_type": 0,
"avatar_decoration": null
},
"73f031a3-6280-4836-89d1-09080d1a74c2": {
"id": "486943594893017119",
"username": "Raphix",
"global_name": null,
"display_name": null,
"avatar": "883ec1a7136b0aa3c22e4bdc33e278e5",
"discriminator": "8434",
"public_flags": 4194368,
"flags": 4194368,
"banner": null,
"banner_color": "#ff4d4d",
"accent_color": 16731469,
"locale": "fr",
"mfa_enabled": true,
"premium_type": 0,
"avatar_decoration": null
},
"c3b40227-5112-421d-8f2b-46a30a87cbca": {
"id": "486943594893017119",
"username": "Raphix",
"global_name": null,
"display_name": null,
"avatar": "883ec1a7136b0aa3c22e4bdc33e278e5",
"discriminator": "8434",
"public_flags": 4194368,
"flags": 4194368,
"banner": null,
"banner_color": "#ff4d4d",
"accent_color": 16731469,
"locale": "fr",
"mfa_enabled": true,
"premium_type": 0,
"avatar_decoration": null
}
} }