Compare commits
22 Commits
59ea576181
...
main
Author | SHA1 | Date | |
---|---|---|---|
96cd60912b
|
|||
b2aadc7c3c
|
|||
dcc056455e
|
|||
f777fb821a
|
|||
ecbda838d3
|
|||
5ac195fd46
|
|||
914edbbf13
|
|||
c376e3259c
|
|||
f3b237b74f
|
|||
83e11f3341
|
|||
b132041d16
|
|||
33da8e8527
|
|||
c613d67c60
|
|||
48e5bfad60
|
|||
54fd731ab9
|
|||
5b8f591216
|
|||
2fe5d35efe
|
|||
b0f5ccbe5a
|
|||
98e5c41fa5
|
|||
f41eddf1dc
|
|||
f12bbe8ad2
|
|||
0c50874644
|
@@ -20,21 +20,35 @@ jobs:
|
|||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
||||||
chmod 600 ~/.ssh/id_rsa
|
chmod 600 ~/.ssh/id_rsa
|
||||||
ssh-keyscan raphix.fr >> ~/.ssh/known_hosts
|
eval "$(ssh-agent -s)"
|
||||||
|
ssh-add ~/.ssh/id_rsa
|
||||||
|
ssh-keyscan git.raphix.fr >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
- name: Deploy Subsonics
|
- name: Deploy Subsonics as gitlab-ci
|
||||||
run: |
|
run: |
|
||||||
ssh -o StrictHostKeyChecking=no raphix@raphix.fr << 'EOF'
|
ssh -A -o StrictHostKeyChecking=no raphix@alpha.raphix.fr << 'EOF'
|
||||||
sudo su - gitlab-ci << 'INNER_EOF'
|
sudo su - gitlab-ci -c '
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# Variables PM2 et npm
|
||||||
|
export PM2_HOME=/home/gitlab-ci/.pm2
|
||||||
|
export NPM_CONFIG_CACHE=/home/gitlab-ci/.npm
|
||||||
|
|
||||||
|
mkdir -p $PM2_HOME $NPM_CONFIG_CACHE
|
||||||
|
chown -R gitlab-ci:gitlab-ci $PM2_HOME $NPM_CONFIG_CACHE
|
||||||
|
|
||||||
echo "[Subsonics-Deploy] - Stage - Déploiement - START"
|
echo "[Subsonics-Deploy] - Stage - Déploiement - START"
|
||||||
|
|
||||||
echo "[Subsonics-Deploy] - Arrêt de Subsonics : Processing"
|
echo "[Subsonics-Deploy] - Arrêt de Subsonics : Processing"
|
||||||
cd /home/gitlab-ci
|
cd /home/gitlab-ci
|
||||||
whoami
|
pm2 stop "Subsonics - Backend" || true
|
||||||
pm2 stop "Subsonics" || true
|
pm2 delete "Subsonics - Backend" || true
|
||||||
pm2 delete "Subsonics" || true
|
|
||||||
echo "[Subsonics-Deploy] - Arrêt de Subsonics : Success"
|
echo "[Subsonics-Deploy] - Arrêt de Subsonics : Success"
|
||||||
|
|
||||||
|
# Préparer tempdata
|
||||||
|
if [ ! -d "/home/gitlab-ci/backend/data" ]; then
|
||||||
|
mkdir -p /home/gitlab-ci/backend/data
|
||||||
|
fi
|
||||||
mv /home/gitlab-ci/backend/data/ /home/gitlab-ci/tempdata || true
|
mv /home/gitlab-ci/backend/data/ /home/gitlab-ci/tempdata || true
|
||||||
|
|
||||||
echo "[Subsonics-Deploy] - Suppression de Subsonics : Processing"
|
echo "[Subsonics-Deploy] - Suppression de Subsonics : Processing"
|
||||||
@@ -42,13 +56,23 @@ jobs:
|
|||||||
echo "[Subsonics-Deploy] - Suppression de Subsonics : Success"
|
echo "[Subsonics-Deploy] - Suppression de Subsonics : Success"
|
||||||
|
|
||||||
echo "[Subsonics-Deploy] - Installation de Subsonics : Processing"
|
echo "[Subsonics-Deploy] - Installation de Subsonics : Processing"
|
||||||
git clone https://git.raphix.fr/subsonics/chopin.git
|
git clone https://git.raphix.fr/subsonics/chopin backend
|
||||||
echo "[Subsonics-Deploy] - Installation de Subsonics : Success"
|
echo "[Subsonics-Deploy] - Installation de Subsonics : Success"
|
||||||
|
|
||||||
echo "[Subsonics-Deploy] - Installation des dépendances : Processing"
|
echo "[Subsonics-Deploy] - Installation des dépendances : Processing"
|
||||||
cd /home/gitlab-ci/backend
|
cd /home/gitlab-ci/backend
|
||||||
rm -r /home/gitlab-ci/backend/data || true
|
|
||||||
mv /home/gitlab-ci/tempdata/ /home/gitlab-ci/backend/data || true
|
# Nettoyage node_modules et tempdata
|
||||||
|
rm -rf node_modules
|
||||||
|
if [ -d "/home/gitlab-ci/tempdata" ]; then
|
||||||
|
mv /home/gitlab-ci/tempdata/ ./data
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Assurer la propriété gitlab-ci
|
||||||
|
chown -R gitlab-ci:gitlab-ci /home/gitlab-ci/backend
|
||||||
|
mkdir -p $NPM_CONFIG_CACHE
|
||||||
|
chown -R gitlab-ci:gitlab-ci $NPM_CONFIG_CACHE
|
||||||
|
|
||||||
npm install --omit=dev
|
npm install --omit=dev
|
||||||
echo "[Subsonics-Deploy] - Installation des dépendances : Success"
|
echo "[Subsonics-Deploy] - Installation des dépendances : Success"
|
||||||
|
|
||||||
@@ -56,6 +80,7 @@ jobs:
|
|||||||
cd /home/gitlab-ci
|
cd /home/gitlab-ci
|
||||||
pm2 start subsonic.config.js
|
pm2 start subsonic.config.js
|
||||||
echo "[Subsonics-Deploy] - Démarrage de Subsonics : Success"
|
echo "[Subsonics-Deploy] - Démarrage de Subsonics : Success"
|
||||||
|
|
||||||
echo "[Subsonics-Deploy] - Stage - Déploiement - END"
|
echo "[Subsonics-Deploy] - Stage - Déploiement - END"
|
||||||
INNER_EOF
|
'
|
||||||
EOF
|
EOF
|
||||||
|
@@ -1,13 +1,29 @@
|
|||||||
<div class="changelog-version changelog-actual">
|
<div class="changelog-version changelog-actual">
|
||||||
<h2>Chopin - Version /*1.0.0*/</h2>
|
<h2>Chopin - Version /*1.2.0*/</h2>
|
||||||
<p class="changelog-date">*_Date de sortie_*: *-XX/XX/XXXX-*</p>
|
<p class="changelog-date">*_Date de sortie_*: *-07/09/2025-*</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>[FRONTEND] Sortie de la version 1.0.0 de Chopin, le bot Discord pour SubSonics.</li>
|
<li>/#[AJOUT][FRONTEND]#/ Suggestion de recherche, depuis Youtube</li>
|
||||||
<li>[BACKEND] Ajout de la fonctionnalité de gestion des utilisateurs avec un fichier JSON.</li>
|
<li>/#[FIX][FRONTEND]#/ Optimisation des bouttons, avec une modification du composant</li>
|
||||||
<li>[DISCORD] Ajout de la fonctionnalité de gestion des utilisateurs avec un fichier JSON.</li>
|
<li>/#[AJOUT][DISCORD]#/ Ajout de la sécurité, permettant de restreindre l'utilisation du Bot au Rôle paramétré</li>
|
||||||
<li>[PLAYER] Ajout de la fonctionnalité de gestion des utilisateurs avec un fichier JSON.</li>
|
</ul>
|
||||||
<li>[AUTRE] Ajout de la fonctionnalité de gestion des utilisateurs avec un fichier JSON.</li>
|
</div>
|
||||||
<li>[FIX] Ajout de la fonctionnalité de gestion des utilisateurs avec un fichier JSON.</li>
|
<div class="changelog-version">
|
||||||
<li>[AJOUT] Ajout de la fonctionnalité de gestion des utilisateurs avec un fichier JSON.</li>
|
<h2>Chopin - Version /*1.1.0*/</h2>
|
||||||
|
<p class="changelog-date">*_Date de sortie_*: *-06/09/2025-*</p>
|
||||||
|
<ul>
|
||||||
|
<li>/#[AJOUT][FRONTEND]#/ Désormais, lorsque l'utilisateur n'est pas connecté, les bouttons de lecture sont désactivés au lieu d'être masqués</li>
|
||||||
|
<li>/#[AJOUT][FRONTEND] #/ Ajout de la prise en charge de plusieurs fichiers en même temps (Impossibilité sur Discord à cause de restriction) !</li>
|
||||||
|
<li>/#[FIX][BACKEND]#/ La source Youtube est désormais fonctionnelle</li>
|
||||||
|
<li>/#[FIX][BACKEND]#/ Le changement de channel est désormais fonctionnel.</li>
|
||||||
|
<li>/#[FIX][FRONTEND]#/ Résolution d'un problème d'affichage du changelog et de la liste de lecture</li>
|
||||||
|
<li>/#[FIX][FRONTEND]#/ Le "En ligne" est désormais resynchronisé sur le Bot</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="changelog-version">
|
||||||
|
<h2>Chopin - Version /*1.0.0*/</h2>
|
||||||
|
<p class="changelog-date">*_Date de sortie_*: *-29/08/2025-*</p>
|
||||||
|
<ul>
|
||||||
|
<li>/#[FRONTEND]#/ Sortie de la version 1.0.0 de Chopin, le bot Discord pour SubSonics. Refonte graphique et passage sur Vue JS</li>
|
||||||
|
<li>/#[BACKEND]#/ Refonte de toute la gestion de la musique et ajout de nouvelles fonctionnalités</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "chopin-backend",
|
"name": "chopin-backend",
|
||||||
"version": "1.1.1",
|
"version": "1.1.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "chopin-backend",
|
"name": "chopin-backend",
|
||||||
"version": "1.1.1",
|
"version": "1.1.2",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/voice": "^0.18.0",
|
"@discordjs/voice": "^0.18.0",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "chopin-backend",
|
"name": "chopin-backend",
|
||||||
"version": "1.1.1",
|
"version": "1.2.0",
|
||||||
"description": "Discord Bot for music - Fetching everywhere !",
|
"description": "Discord Bot for music - Fetching everywhere !",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"nodemonConfig": {
|
"nodemonConfig": {
|
||||||
|
@@ -7,6 +7,8 @@ const config = require("../utils/Database/Configuration")
|
|||||||
const metric = require("webmetrik")
|
const metric = require("webmetrik")
|
||||||
const { Player } = require("../player/Player")
|
const { Player } = require("../player/Player")
|
||||||
const {refreshAllUserInformation} = require("../server/auth/User")
|
const {refreshAllUserInformation} = require("../server/auth/User")
|
||||||
|
const serverSettings = require("./ServerSettings")
|
||||||
|
const { Embed, EmbedError } = require("./Embed")
|
||||||
|
|
||||||
const dlog = new LogType("Discord")
|
const dlog = new LogType("Discord")
|
||||||
const glog = new LogType("GuildUpdater")
|
const glog = new LogType("GuildUpdater")
|
||||||
@@ -49,6 +51,29 @@ function getGuildMembers(guildId) {
|
|||||||
return guild.members.cache.map(member => member.user.id)
|
return guild.members.cache.map(member => member.user.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getGuildMember(guildId, memberId) {
|
||||||
|
const guild = client.guilds.cache.get(guildId)
|
||||||
|
if(!guild) {
|
||||||
|
dlog.error("Guild not found: " + guildId)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return guild.members.cache.get(memberId) || null
|
||||||
|
}
|
||||||
|
|
||||||
|
function getGuildRoles(guildId) {
|
||||||
|
const guild = client.guilds.cache.get(guildId)
|
||||||
|
if(!guild) {
|
||||||
|
dlog.error("Guild not found: " + guildId)
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
return guild.roles.cache.map(role => ({
|
||||||
|
id: role.id,
|
||||||
|
name: role.name,
|
||||||
|
color: role.color,
|
||||||
|
position: role.position
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
function getChannel(guildId, channelId) {
|
function getChannel(guildId, channelId) {
|
||||||
return client.guilds.cache.get(guildId).channels.cache.get(channelId)
|
return client.guilds.cache.get(guildId).channels.cache.get(channelId)
|
||||||
}
|
}
|
||||||
@@ -77,7 +102,7 @@ function init() {
|
|||||||
operational = true
|
operational = true
|
||||||
})
|
})
|
||||||
|
|
||||||
client.on("interactionCreate", (interaction) => {
|
client.on("interactionCreate", async (interaction) => {
|
||||||
|
|
||||||
if(!interaction.isCommand()) return;
|
if(!interaction.isCommand()) return;
|
||||||
|
|
||||||
@@ -87,13 +112,27 @@ function init() {
|
|||||||
numberOfCommandsServer.setValue(numberOfCommandsServer.getValue() + 1)
|
numberOfCommandsServer.setValue(numberOfCommandsServer.getValue() + 1)
|
||||||
|
|
||||||
const command = client.commands.get(interaction.commandName)
|
const command = client.commands.get(interaction.commandName)
|
||||||
|
const roleProtected = await serverSettings.getSecureRole(interaction.guild.id) || false
|
||||||
|
var havePermission = true;
|
||||||
|
if(roleProtected) {
|
||||||
|
await interaction.member.fetch()
|
||||||
|
if(!interaction.member.roles.cache.has(roleProtected.id)) {
|
||||||
|
havePermission = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Create a metric to count the number of commands executed by each user
|
// Create a metric to count the number of commands executed by each user
|
||||||
const userCommand = new metric.Metric("userCommand_" + interaction.member.user.username, "Nombre de commandes éxécutées par l'utilisateur : " + interaction.member.user.username)
|
const userCommand = new metric.Metric("userCommand_" + interaction.member.user.username, "Nombre de commandes éxécutées par l'utilisateur : " + interaction.member.user.username)
|
||||||
userCommand.setValue(userCommand.getValue() + 1)
|
userCommand.setValue(userCommand.getValue() + 1)
|
||||||
dlog.log(interaction.member.user.username + "-> /" + interaction.commandName)
|
dlog.log(interaction.member.user.username + "-> /" + interaction.commandName)
|
||||||
|
if(havePermission) {
|
||||||
command.execute(client, interaction)
|
command.execute(client, interaction)
|
||||||
|
} else {
|
||||||
|
const embed = new EmbedError(`L'utilisation du Bot est réservée aux membres ayant le rôle "${roleProtected.name}"`, interaction, true)
|
||||||
|
embed.setTitle("Accès refusé")
|
||||||
|
embed.send()
|
||||||
|
}
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
|
|
||||||
dlog.error(interaction.member.user.username + "-> /" + interaction.commandName + " : ERREUR RENCONTRE")
|
dlog.error(interaction.member.user.username + "-> /" + interaction.commandName + " : ERREUR RENCONTRE")
|
||||||
@@ -210,23 +249,15 @@ async function refreshGuilds() {
|
|||||||
|
|
||||||
function checkRequiredPermission(guildMember) {
|
function checkRequiredPermission(guildMember) {
|
||||||
const requiredPermissions = [
|
const requiredPermissions = [
|
||||||
'CreateInstantInvite', 'AddReactions',
|
'ViewChannel', // Voir les salons
|
||||||
'Stream', 'ViewChannel',
|
'SendMessages', // Envoyer des messages texte
|
||||||
'SendMessages', 'SendTTSMessages',
|
'ReadMessageHistory', // Lire l’historique des messages
|
||||||
'EmbedLinks', 'AttachFiles',
|
'Connect', // Se connecter aux salons vocaux
|
||||||
'ReadMessageHistory', 'UseExternalEmojis',
|
'Speak' // Parler dans les salons vocaux
|
||||||
'Connect', 'Speak',
|
|
||||||
'UseVAD', 'ChangeNickname',
|
|
||||||
'UseApplicationCommands', 'RequestToSpeak',
|
|
||||||
'CreatePublicThreads', 'CreatePrivateThreads',
|
|
||||||
'UseExternalStickers', 'SendMessagesInThreads',
|
|
||||||
'UseEmbeddedActivities', 'UseSoundboard',
|
|
||||||
'UseExternalSounds', 'SendVoiceMessages',
|
|
||||||
'SendPolls', 'UseExternalApps'
|
|
||||||
]
|
]
|
||||||
return requiredPermissions.filter(permission => !guildMember.permissions.has(permission));
|
return requiredPermissions.filter(permission => !guildMember.permissions.has(permission));
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {init, getClient, getGuilds, getMembersVoices, getChannel, getGuildMembers, isReady}
|
module.exports = {init, getClient, getGuilds, getMembersVoices, getChannel, getGuildMembers, getGuildMember, isReady, getGuildRoles}
|
||||||
|
|
||||||
|
|
||||||
|
38
src/discord/ServerSettings.js
Normal file
38
src/discord/ServerSettings.js
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
const { LogType } = require('loguix');
|
||||||
|
const clog = new LogType('ServerSettings');
|
||||||
|
const { __glob } = require('../utils/GlobalVars');
|
||||||
|
const { Database } = require('../utils/Database/Database');
|
||||||
|
const ServerDB = new Database("server_settings", __glob.SERVER_DB, {});
|
||||||
|
|
||||||
|
function getSecureRole(guildId) {
|
||||||
|
checkKey(guildId);
|
||||||
|
var role = ServerDB.getData()[guildId].secureRole || null;
|
||||||
|
if(role) {
|
||||||
|
if(role.name === "@everyone") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return role;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setSecureRole(guildId, roleId) {
|
||||||
|
checkKey(guildId);
|
||||||
|
ServerDB.getData()[guildId].secureRole = roleId;
|
||||||
|
ServerDB.save();
|
||||||
|
process.emit("USERS_UPDATE")
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkKey(guildId) {
|
||||||
|
const data = ServerDB.getData();
|
||||||
|
if (!data[guildId]) {
|
||||||
|
data[guildId] = { secureRole: null };
|
||||||
|
ServerDB.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
getSecureRole,
|
||||||
|
setSecureRole
|
||||||
|
};
|
@@ -2,19 +2,35 @@ const {createAudioResource, VoiceConnectionStatus, createAudioPlayer, StreamType
|
|||||||
const {LogType} = require('loguix')
|
const {LogType} = require('loguix')
|
||||||
const clog = new LogType("Youtube-Stream")
|
const clog = new LogType("Youtube-Stream")
|
||||||
const ytdl = require('@distube/ytdl-core')
|
const ytdl = require('@distube/ytdl-core')
|
||||||
const ffmpeg = require('fluent-ffmpeg')
|
const { __glob } = require('../../utils/GlobalVars');
|
||||||
const { getRandomIPv6 } = require("@distube/ytdl-core/lib/utils");
|
const fs = require('fs');
|
||||||
|
|
||||||
async function getStream(song) {
|
async function getStream(song) {
|
||||||
|
|
||||||
|
// FIXME: Change youtube provider
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
const headers = {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) ' +
|
||||||
|
'AppleWebKit/537.36 (KHTML, like Gecko) ' +
|
||||||
|
'Chrome/116.0.5845.97 Safari/537.36',
|
||||||
|
'Accept-Language': 'en-US,en;q=0.9'
|
||||||
|
};
|
||||||
|
|
||||||
|
var cookies = await JSON.parse(await fs.readFileSync(__glob.COOKIES, 'utf-8'));
|
||||||
|
const proxy = await JSON.parse(await fs.readFileSync(__glob.PROXY, 'utf-8'));
|
||||||
|
const agent = ytdl.createProxyAgent(proxy, cookies)
|
||||||
let stream = ytdl(song.url, {
|
let stream = ytdl(song.url, {
|
||||||
quality: 'highestaudio',
|
quality: 'highestaudio',
|
||||||
highWaterMark: 1 << 30,
|
highWaterMark: 1 << 30,
|
||||||
liveBuffer: 20000,
|
liveBuffer: 20000,
|
||||||
dlChunkSize: 0,
|
dlChunkSize: 0,
|
||||||
bitrate: 128,
|
bitrate: 128,
|
||||||
|
requestOptions: {
|
||||||
|
headers: headers,
|
||||||
|
},
|
||||||
|
agent: agent,
|
||||||
});
|
});
|
||||||
|
|
||||||
return stream
|
return stream
|
||||||
|
@@ -127,7 +127,7 @@ class Player {
|
|||||||
|
|
||||||
checkConnection() {
|
checkConnection() {
|
||||||
if(this.connection === null) {
|
if(this.connection === null) {
|
||||||
clog.error(`GUILD : ${this.guildId} - La connection n'est pas définie`)
|
// clog.error(`GUILD : ${this.guildId} - La connection n'est pas définie`)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if(this.player === null) {
|
if(this.player === null) {
|
||||||
|
@@ -19,6 +19,7 @@ const {__glob} = require("../utils/GlobalVars")
|
|||||||
const playlists = require("../playlists/PlaylistManager")
|
const playlists = require("../playlists/PlaylistManager")
|
||||||
const history = require("../playlists/History")
|
const history = require("../playlists/History")
|
||||||
const lyrics = require("../lyrics/Lyrics")
|
const lyrics = require("../lyrics/Lyrics")
|
||||||
|
const serverSettings = require("../discord/ServerSettings")
|
||||||
const mediaBase = require("../discord/MediaBase")
|
const mediaBase = require("../discord/MediaBase")
|
||||||
const googleApis = require("../playlists/Google/OAuth2")
|
const googleApis = require("../playlists/Google/OAuth2")
|
||||||
const youtubeApi = require("../playlists/Google/YoutubeList")
|
const youtubeApi = require("../playlists/Google/YoutubeList")
|
||||||
@@ -34,8 +35,6 @@ const allConnectedUsers = new Array()
|
|||||||
const guildConnectedUsers = new Map()
|
const guildConnectedUsers = new Map()
|
||||||
const UsersBySocket = new Map()
|
const UsersBySocket = new Map()
|
||||||
|
|
||||||
//TODO: Separate all request in separate files
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
wlog.step.init("server_init", "Initialisation du serveur Socket.IO")
|
wlog.step.init("server_init", "Initialisation du serveur Socket.IO")
|
||||||
@@ -419,7 +418,7 @@ function init() {
|
|||||||
// CHECKED : 03/05/2025
|
// CHECKED : 03/05/2025
|
||||||
IORequest("/PLAYER/CHANNEL/CHANGE", () => {
|
IORequest("/PLAYER/CHANNEL/CHANGE", () => {
|
||||||
handlePlayerAction(actualGuildId, (player) => {
|
handlePlayerAction(actualGuildId, (player) => {
|
||||||
const channel = getUserChannel()
|
const channel = getUserChannel(false, true)
|
||||||
if(!channel) {
|
if(!channel) {
|
||||||
IOAnswer("/PLAYER/CHANNEL/CHANGE", false)
|
IOAnswer("/PLAYER/CHANNEL/CHANGE", false)
|
||||||
return
|
return
|
||||||
@@ -793,6 +792,35 @@ function init() {
|
|||||||
IOAnswer("/OWNER/USERS/SWITCH_MOD", true)
|
IOAnswer("/OWNER/USERS/SWITCH_MOD", true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
IORequest("/OWNER/ROLES/GET", async () => {
|
||||||
|
if(!actualGuildId) return IOAnswer("/OWNER/ROLES/GET", false)
|
||||||
|
const guild = discordBot.getGuilds().get(actualGuildId)
|
||||||
|
if(!socketUser.identity.id === guild.owner) return IOAnswer("/OWNER/ROLES/GET", false)
|
||||||
|
const rolesSecure = discordBot.getGuildRoles(actualGuildId)
|
||||||
|
const actualRole = await serverSettings.getSecureRole(actualGuildId)
|
||||||
|
// Move the actual role at the start of the array
|
||||||
|
if(actualRole) {
|
||||||
|
const index = rolesSecure.findIndex(r => r.id === actualRole.id)
|
||||||
|
if(index > -1) {
|
||||||
|
rolesSecure.unshift(rolesSecure.splice(index, 1)[0])
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Find the @everyone role and put it at the start of the array
|
||||||
|
const index = rolesSecure.findIndex(r => r.name === "@everyone")
|
||||||
|
if(index > -1) {
|
||||||
|
rolesSecure.unshift(rolesSecure.splice(index, 1)[0])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IOAnswer("/OWNER/ROLES/GET", await rolesSecure)
|
||||||
|
})
|
||||||
|
|
||||||
|
IORequest("/OWNER/ROLES/SET", async (data) => {
|
||||||
|
if(!actualGuildId) return IOAnswer("/OWNER/ROLES/SET", false)
|
||||||
|
const guild = discordBot.getGuilds().get(actualGuildId)
|
||||||
|
if(!socketUser.identity.id === guild.owner) return IOAnswer("/OWNER/ROLES/SET", false)
|
||||||
|
await serverSettings.setSecureRole(actualGuildId, data)
|
||||||
|
IOAnswer("/OWNER/ROLES/SET", true)
|
||||||
|
})
|
||||||
|
|
||||||
// CHECKED : 24/04/2025
|
// CHECKED : 24/04/2025
|
||||||
IORequest("/MOD/USERS/BAN", async (userId) => {
|
IORequest("/MOD/USERS/BAN", async (userId) => {
|
||||||
@@ -873,9 +901,9 @@ function init() {
|
|||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
|
|
||||||
function getUserChannel(usual) {
|
function getUserChannel(usual, force) {
|
||||||
const botChannel = getBotChannel()
|
const botChannel = getBotChannel()
|
||||||
if(botChannel) {
|
if(botChannel && !force) {
|
||||||
return botChannel
|
return botChannel
|
||||||
}
|
}
|
||||||
const membersVoices = discordBot.getMembersVoices()
|
const membersVoices = discordBot.getMembersVoices()
|
||||||
@@ -907,6 +935,18 @@ function init() {
|
|||||||
const guildData = guild[1]
|
const guildData = guild[1]
|
||||||
guildData['members'] = new Array()
|
guildData['members'] = new Array()
|
||||||
guildData.serverMember = guild[1].allMembers.length
|
guildData.serverMember = guild[1].allMembers.length
|
||||||
|
guildData.restricted = false
|
||||||
|
const secureRole = serverSettings.getSecureRole(guild[0])
|
||||||
|
if(secureRole && socketUser.identity.id !== discordBot.getGuilds().get(guild[0]).owner) {
|
||||||
|
const member = discordBot.getGuildMember(guild[0], socketUser.identity.id)
|
||||||
|
if(!member.roles.cache.has(secureRole.id) && socketUser.identity.id !== guild[1].owner && !socketUser.isAdmin()) {
|
||||||
|
guildData.restricted = true
|
||||||
|
} else {
|
||||||
|
guildData.restricted = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
guildData.allowed = true
|
||||||
for(var user of guildConnectedUsers.get(guild[0]) || []) {
|
for(var user of guildConnectedUsers.get(guild[0]) || []) {
|
||||||
const userData = users.getUserById(user.id)
|
const userData = users.getUserById(user.id)
|
||||||
if(userData && userData.identity.id != socketUser.identity.id) {
|
if(userData && userData.identity.id != socketUser.identity.id) {
|
||||||
@@ -986,6 +1026,15 @@ function init() {
|
|||||||
wlog.warn("Aucun guildId n'est actif pour l'utilisateur : " + socketUser.identity.username)
|
wlog.warn("Aucun guildId n'est actif pour l'utilisateur : " + socketUser.identity.username)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
// Check role if secure role is set
|
||||||
|
const secureRole = serverSettings.getSecureRole(guildId)
|
||||||
|
if(secureRole && socketUser.identity.id !== discordBot.getGuilds().get(guildId).owner) {
|
||||||
|
const member = discordBot.getGuildMember(guildId, socketUser.identity.id)
|
||||||
|
if(member.roles.cache.has(secureRole.id) == false) {
|
||||||
|
wlog.warn("L'utilisateur '" + socketUser.identity.username + "' n'a pas le rôle requis pour accéder à la guilde : " + guildId)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
// Check if the guildId is referenced in the bot guilds
|
// Check if the guildId is referenced in the bot guilds
|
||||||
if(!discordBot.getGuilds().has(guildId)) {
|
if(!discordBot.getGuilds().has(guildId)) {
|
||||||
wlog.warn("La guilde : " + guildId + " n'est pas référencée dans le bot")
|
wlog.warn("La guilde : " + guildId + " n'est pas référencée dans le bot")
|
||||||
|
@@ -8,15 +8,18 @@ const __glob = {
|
|||||||
SRC: root + path.sep + "src",
|
SRC: root + path.sep + "src",
|
||||||
LOGS: root + path.sep + "logs",
|
LOGS: root + path.sep + "logs",
|
||||||
DATA: root + path.sep + "data",
|
DATA: root + path.sep + "data",
|
||||||
COMMANDS: root + path.sep + "src" + path.sep + "discord" + path.sep + "commands",
|
COMMANDS: root + path.sep + "src" + path.sep + "discord" + path.sep + "Commands",
|
||||||
METRIC_FILE: root + path.sep + "data" + path.sep + "metrics.json",
|
METRIC_FILE: root + path.sep + "data" + path.sep + "metrics.json",
|
||||||
PREVIOUSFILE: root + path.sep + "data" + path.sep + "previous.json",
|
PREVIOUSFILE: root + path.sep + "data" + path.sep + "previous.json",
|
||||||
USERFILE: root + path.sep + "data" + path.sep + "users.json",
|
USERFILE: root + path.sep + "data" + path.sep + "users.json",
|
||||||
PLAYLISTFILE: root + path.sep + "data" + path.sep + "playlists.json",
|
PLAYLISTFILE: root + path.sep + "data" + path.sep + "playlists.json",
|
||||||
HISTORY_DB: root + path.sep + "data" + path.sep + "history.json",
|
HISTORY_DB: root + path.sep + "data" + path.sep + "history.json",
|
||||||
MEDIA_DB: root + path.sep + "data" + path.sep + "media.json",
|
MEDIA_DB: root + path.sep + "data" + path.sep + "media.json",
|
||||||
|
SERVER_DB: root + path.sep + "data" + path.sep + "servers.json",
|
||||||
VERSION: version,
|
VERSION: version,
|
||||||
CHANGELOG_PATH: root + path.sep + "CHANGELOG.html",
|
CHANGELOG_PATH: root + path.sep + "CHANGELOG.html",
|
||||||
|
COOKIES: root + path.sep + "data" + path.sep + "cookies.json",
|
||||||
|
PROXY: root + path.sep + "data" + path.sep + "proxy.json"
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {__glob}
|
module.exports = {__glob}
|
Reference in New Issue
Block a user