Add Server Implements for Submanager
All checks were successful
Subsonics - Pipeline/pipeline/head This commit looks good
All checks were successful
Subsonics - Pipeline/pipeline/head This commit looks good
This commit is contained in:
parent
d801f02978
commit
3aa775d81b
1473
package-lock.json
generated
1473
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@ -2,10 +2,22 @@
|
||||
"name": "subsonics-discord",
|
||||
"author": "Raphix",
|
||||
"version": "5.5",
|
||||
"nodemonConfig": {
|
||||
"ext": "js, html",
|
||||
"ignore": [
|
||||
"*.json",
|
||||
"*.html"
|
||||
],
|
||||
"delay": "2"
|
||||
},
|
||||
"dependencies": {
|
||||
"cookie-parser": "^1.4.6",
|
||||
"discord.js": "^14.9.0",
|
||||
"erela.js": "^2.4.0",
|
||||
"express": "^4.18.2",
|
||||
"nodemon": "^2.0.22",
|
||||
"socket.io": "^4.6.1",
|
||||
"uuid": "^9.0.0",
|
||||
"ytfps": "^1.1.0"
|
||||
},
|
||||
"scripts": {
|
||||
|
12
src/close.html
Normal file
12
src/close.html
Normal file
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Submanager - </title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,4 +1,5 @@
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const log = require("../sublog")
|
||||
|
||||
module.exports = {
|
||||
|
||||
@ -32,6 +33,7 @@ module.exports = {
|
||||
|
||||
async function makeAction() {
|
||||
|
||||
|
||||
let embed = new EmbedBuilder()
|
||||
.setColor(0xe033ff)
|
||||
.setTitle('Liste de lecture')
|
||||
@ -40,6 +42,7 @@ module.exports = {
|
||||
|
||||
let player = client.manager.players.get(interaction.guild.id)
|
||||
|
||||
|
||||
|
||||
if(!player) {
|
||||
|
||||
@ -53,8 +56,7 @@ module.exports = {
|
||||
interaction.reply({embeds: [embed]})
|
||||
} else {
|
||||
|
||||
console.log("------------------------QUEUE.JS---------------------")
|
||||
console.log(client.manager.players.get(interaction.guild.id).queue)
|
||||
|
||||
let queue = client.manager.players.get(interaction.guild.id).queue;
|
||||
|
||||
|
||||
@ -85,6 +87,9 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
process.emit("discordDoing")
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const log = require("../sublog")
|
||||
|
||||
module.exports = {
|
||||
|
||||
@ -8,7 +9,7 @@ module.exports = {
|
||||
|
||||
async execute(client, interaction) {
|
||||
|
||||
console.log(interaction.member._roles)
|
||||
|
||||
|
||||
if(interaction.member._roles.includes("397725956598530050") == true | interaction.member.user.id == "486943594893017119") {
|
||||
if(client.dictator == true) {
|
||||
@ -52,7 +53,7 @@ module.exports = {
|
||||
|
||||
|
||||
|
||||
|
||||
process.emit("discordDoing")
|
||||
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const log = require("../sublog")
|
||||
|
||||
module.exports = {
|
||||
|
||||
@ -8,7 +9,7 @@ module.exports = {
|
||||
|
||||
async execute(client, interaction) {
|
||||
|
||||
|
||||
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(0x03ff2d)
|
||||
|
@ -1,5 +1,6 @@
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const { Player } = require("erela.js");
|
||||
const log = require("../sublog")
|
||||
|
||||
module.exports = {
|
||||
|
||||
@ -56,6 +57,8 @@ module.exports = {
|
||||
|
||||
interaction.reply("**Aucune musique n'est actuellement jouée !**")
|
||||
}
|
||||
|
||||
process.emit("discordDoing")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const log = require("../sublog")
|
||||
|
||||
module.exports = {
|
||||
|
||||
@ -31,7 +32,7 @@ module.exports = {
|
||||
}
|
||||
|
||||
async function makeAction() {
|
||||
|
||||
|
||||
if(!interaction.member.voice.channel) return interaction.reply({content:"Vous devez rejoindre un salon vocal !", ephemeral: true})
|
||||
|
||||
let player = client.manager.players.get(interaction.guild.id)
|
||||
@ -75,6 +76,10 @@ module.exports = {
|
||||
interaction.reply("**Aucune musique n'est actuellement jouée !**")
|
||||
|
||||
}
|
||||
|
||||
|
||||
process.emit("discordDoing")
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const log = require("../sublog")
|
||||
|
||||
module.exports = {
|
||||
|
||||
@ -8,6 +9,8 @@ module.exports = {
|
||||
|
||||
async execute(client, interaction) {
|
||||
|
||||
|
||||
|
||||
if(client.dictator == true ) {
|
||||
|
||||
if((interaction.member._roles.includes("397725956598530050") == true | interaction.member.user.id == "486943594893017119")) {
|
||||
@ -32,6 +35,7 @@ module.exports = {
|
||||
|
||||
async function makeAction() {
|
||||
|
||||
|
||||
if(!interaction.member.voice.channel) return interaction.reply({content:"Vous devez rejoindre un salon vocal !", ephemeral: true})
|
||||
|
||||
let player = client.manager.players.get(interaction.guild.id)
|
||||
@ -59,6 +63,9 @@ module.exports = {
|
||||
|
||||
interaction.reply("**Aucune musique n'est actuellement jouée !**")
|
||||
}
|
||||
|
||||
|
||||
process.emit("discordDoing")
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const log = require("../sublog")
|
||||
|
||||
module.exports = {
|
||||
|
||||
@ -8,7 +9,7 @@ module.exports = {
|
||||
|
||||
async execute(client, interaction) {
|
||||
|
||||
|
||||
process.emit("discordDoing")
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(0xb0f542)
|
||||
.setTitle('Résultat du ping')
|
||||
|
@ -1,5 +1,6 @@
|
||||
const { EmbedBuilder } = require("@discordjs/builders");
|
||||
const { SlashCommandBuilder, Embed } = require("discord.js");
|
||||
const log = require("../sublog")
|
||||
|
||||
module.exports = {
|
||||
|
||||
@ -9,7 +10,7 @@ module.exports = {
|
||||
.addStringOption(option => option.setName("nom_ou_lien").setDescription("Le nom de la musique recherchée !").setRequired(true)),
|
||||
|
||||
async execute(client, interaction) {
|
||||
|
||||
|
||||
if(client.dictator == true ) {
|
||||
|
||||
if((interaction.member._roles.includes("397725956598530050") == true | interaction.member.user.id == "486943594893017119")) {
|
||||
@ -34,9 +35,11 @@ module.exports = {
|
||||
|
||||
async function makeAction() {
|
||||
|
||||
|
||||
|
||||
const song_name = interaction.options.getString("nom_ou_lien")
|
||||
|
||||
if(!interaction.member.voice.channel) return interaction.reply({content:"Vous devez rejoindre un salon vocal !", ephemeral: true})
|
||||
if(!interaction.member.voice.channel) return interaction.reply({content:"Vous devez rejoindre un salon vocal !", ephemeral: true})
|
||||
|
||||
let player = client.manager.players.get(interaction.guild.id)
|
||||
|
||||
@ -71,8 +74,8 @@ module.exports = {
|
||||
|
||||
interaction.reply({embeds: [embed]})
|
||||
} catch(error) {
|
||||
|
||||
console.log(error)
|
||||
log.bot.error("Error processing /play")
|
||||
log.bot.error(error);
|
||||
}
|
||||
|
||||
|
||||
@ -92,20 +95,20 @@ module.exports = {
|
||||
.setTimestamp();
|
||||
|
||||
client.manager.players.get(interaction.guild.id).queue.add(songs.tracks[0])
|
||||
console.log("------------------------PLAY.JS---------------------")
|
||||
console.log(player.queue)
|
||||
console.log("--------------------------------------------")
|
||||
|
||||
try {
|
||||
|
||||
interaction.reply({embeds: [embed]})
|
||||
interaction.reply({embeds: [embed]})
|
||||
} catch(error) {
|
||||
|
||||
console.log(error)
|
||||
log.bot.error("Error processing /play")
|
||||
log.bot.error(error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
process.emit("discordDoing")
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
const { EmbedBuilder } = require("@discordjs/builders");
|
||||
const { SlashCommandBuilder, Embed } = require("discord.js");
|
||||
const log = require("../sublog")
|
||||
|
||||
|
||||
module.exports = {
|
||||
@ -35,6 +36,8 @@ module.exports = {
|
||||
|
||||
async function makeAction() {
|
||||
|
||||
process.emit("discordDoing")
|
||||
|
||||
const song_name = interaction.options.getString("lien")
|
||||
|
||||
if(!interaction.member.voice.channel) return interaction.reply({content:"Vous devez rejoindre un salon vocal !", ephemeral: true})
|
||||
@ -62,12 +65,19 @@ module.exports = {
|
||||
try {
|
||||
|
||||
var playlist = await ytfps(song_name)
|
||||
var author = "Artiste inconnu !"
|
||||
|
||||
if(typeof playlist.author != "undefined" ) {
|
||||
|
||||
author == playlist.author.name
|
||||
}
|
||||
|
||||
|
||||
const embed = await new EmbedBuilder()
|
||||
.setColor(0x15e6ed)
|
||||
.setTitle('**Lecture de la playlist : **' + playlist.title)
|
||||
.setDescription('**Demandé par **' + interaction.member.user.username)
|
||||
.addFields({name: "Auteur", value: playlist.author.name},
|
||||
.addFields({name: "Auteur", value: author},
|
||||
{name: "URL", value:playlist.url},
|
||||
{name: "Nombre de videos", value:playlist.video_count + " vidéos"})
|
||||
.setThumbnail(playlist.thumbnail_url)
|
||||
@ -78,18 +88,32 @@ module.exports = {
|
||||
await interaction.reply({embeds: [embed]})
|
||||
} catch(error) {
|
||||
|
||||
console.log(error)
|
||||
log.bot.error(error);
|
||||
}
|
||||
|
||||
addList(playlist, player)
|
||||
|
||||
for(var song of playlist.videos) {
|
||||
async function addList(Pplaylist, Pplayer) {
|
||||
|
||||
for(var song of Pplaylist.videos) {
|
||||
|
||||
const song_finded = await client.manager.search(song.url)
|
||||
await client.manager.players.get(interaction.guild.id).queue.add(song_finded.tracks[0])
|
||||
|
||||
const song_finded = await client.manager.search(song.url)
|
||||
await client.manager.players.get(interaction.guild.id).queue.add(song_finded.tracks[0])
|
||||
|
||||
}
|
||||
|
||||
if(Pplayer.playing == false) {
|
||||
|
||||
await Pplayer.play()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} catch(err) {
|
||||
|
||||
|
||||
await process.emit("discordDoing")
|
||||
|
||||
} catch(error) {
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(0xff0303)
|
||||
@ -100,27 +124,21 @@ module.exports = {
|
||||
embed.addFields(song_show)
|
||||
interaction.reply({embeds: [embed]})
|
||||
|
||||
console.log(err)
|
||||
log.bot.error(error);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
if(playlist != null) {
|
||||
|
||||
|
||||
if(!player.playing) {
|
||||
|
||||
|
||||
player.play()
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
process.emit("discordDoing")
|
||||
|
||||
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const log = require("../sublog")
|
||||
|
||||
module.exports = {
|
||||
|
||||
@ -36,6 +37,8 @@ module.exports = {
|
||||
}
|
||||
|
||||
async function makeAction() {
|
||||
|
||||
|
||||
|
||||
if(!interaction.member.voice.channel) return interaction.reply({content:"Vous devez rejoindre un salon vocal !", ephemeral: true})
|
||||
|
||||
@ -62,8 +65,6 @@ module.exports = {
|
||||
interaction.reply({embeds: [embed]})
|
||||
} else {
|
||||
|
||||
console.log("------------------------QUEUE.JS---------------------")
|
||||
console.log(client.manager.players.get(interaction.guild.id).queue)
|
||||
let queue = client.manager.players.get(interaction.guild.id).queue;
|
||||
|
||||
|
||||
@ -75,12 +76,15 @@ module.exports = {
|
||||
interaction.reply({embeds: [embed]})
|
||||
} else {
|
||||
|
||||
|
||||
for(song of queue) {
|
||||
|
||||
const song_show = {name: queue.indexOf(song) + " - " + song.title, value: song.author}
|
||||
var fieldmax = 0
|
||||
for(var song of queue) {
|
||||
fieldmax += 1
|
||||
if(fieldmax <= 25) {
|
||||
const song_show = {name: queue.indexOf(song) + " - " + song.title, value: song.author}
|
||||
|
||||
embed.addFields(song_show)
|
||||
embed.addFields(song_show)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
await interaction.reply({embeds: [embed]})
|
||||
@ -110,8 +114,6 @@ module.exports = {
|
||||
interaction.reply({embeds: [embed]})
|
||||
} else {
|
||||
|
||||
console.log("------------------------QUEUE.JS---------------------")
|
||||
console.log(client.manager.players.get(interaction.guild.id).queue)
|
||||
let queue = client.manager.players.get(interaction.guild.id).queue;
|
||||
|
||||
|
||||
@ -129,8 +131,7 @@ module.exports = {
|
||||
|
||||
const number = interaction.options.getInteger("number")
|
||||
|
||||
console.log(number)
|
||||
|
||||
|
||||
if(number != null) {
|
||||
try {
|
||||
queue.splice(number, 1)
|
||||
@ -179,6 +180,8 @@ module.exports = {
|
||||
|
||||
await interaction.reply("**La commande a été mal éxécutée !**")
|
||||
}
|
||||
|
||||
process.emit("discordDoing")
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const log = require("../sublog")
|
||||
|
||||
const { Manager } = require("erela.js")
|
||||
|
||||
|
||||
@ -10,7 +12,7 @@ module.exports = {
|
||||
|
||||
async execute(client, interaction) {
|
||||
|
||||
console.log(interaction.member._roles)
|
||||
|
||||
|
||||
if(interaction.member._roles.includes("397725956598530050") == true | interaction.member._roles.includes("397724656548970508") == true| interaction.member._roles.includes("397725128198455299") == true| interaction.member._roles.includes("397725552968204288") == true | interaction.member.user.id == "486943594893017119") {
|
||||
const embed = new EmbedBuilder()
|
||||
@ -56,7 +58,7 @@ module.exports = {
|
||||
|
||||
|
||||
}
|
||||
|
||||
process.emit("discordDoing")
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const log = require("../sublog")
|
||||
|
||||
module.exports = {
|
||||
|
||||
@ -8,6 +9,8 @@ module.exports = {
|
||||
|
||||
async execute(client, interaction) {
|
||||
|
||||
|
||||
|
||||
if(client.dictator == true ) {
|
||||
|
||||
if((interaction.member._roles.includes("397725956598530050") == true | interaction.member.user.id == "486943594893017119")) {
|
||||
@ -60,6 +63,8 @@ module.exports = {
|
||||
|
||||
interaction.reply("**Aucune musique n'est actuellement jouée !**")
|
||||
}
|
||||
|
||||
process.emit("discordDoing")
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const log = require("../sublog")
|
||||
|
||||
module.exports = {
|
||||
|
||||
@ -9,6 +10,8 @@ module.exports = {
|
||||
|
||||
async execute(client, interaction) {
|
||||
|
||||
|
||||
|
||||
if(client.dictator == true ) {
|
||||
|
||||
if((interaction.member._roles.includes("397725956598530050") == true | interaction.member.user.id == "486943594893017119")) {
|
||||
@ -58,7 +61,7 @@ module.exports = {
|
||||
|
||||
} catch (error) {
|
||||
|
||||
console.log(error)
|
||||
log.bot.error(error);
|
||||
interaction.reply("**Aucune musique n'est actuellement jouée !**")
|
||||
}
|
||||
|
||||
@ -71,6 +74,8 @@ module.exports = {
|
||||
interaction.reply("**Aucune musique n'est actuellement jouée !**")
|
||||
|
||||
}
|
||||
|
||||
process.emit("discordDoing")
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const log = require("../sublog")
|
||||
|
||||
module.exports = {
|
||||
|
||||
@ -8,6 +9,8 @@ module.exports = {
|
||||
|
||||
async execute(client, interaction) {
|
||||
|
||||
|
||||
|
||||
if(client.dictator == true ) {
|
||||
|
||||
if((interaction.member._roles.includes("397725956598530050") == true | interaction.member.user.id == "486943594893017119")) {
|
||||
@ -61,6 +64,8 @@ module.exports = {
|
||||
interaction.reply("**Aucune musique n'est actuellement jouée !**")
|
||||
|
||||
}
|
||||
|
||||
process.emit("discordDoing")
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const log = require("../sublog")
|
||||
|
||||
module.exports = {
|
||||
|
||||
@ -7,6 +8,7 @@ module.exports = {
|
||||
.setDescription("Permet de passer à la musique suivante !"),
|
||||
|
||||
async execute(client, interaction) {
|
||||
|
||||
|
||||
if(client.dictator == true ) {
|
||||
|
||||
@ -53,8 +55,7 @@ module.exports = {
|
||||
interaction.reply({embeds: [embed]})
|
||||
} else {
|
||||
|
||||
console.log("------------------------QUEUE.JS---------------------")
|
||||
console.log(client.manager.players.get(interaction.guild.id).queue)
|
||||
|
||||
let queue = client.manager.players.get(interaction.guild.id).queue;
|
||||
|
||||
|
||||
@ -83,7 +84,7 @@ module.exports = {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
process.emit("discordDoing")
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const log = require("../sublog")
|
||||
|
||||
module.exports = {
|
||||
|
||||
@ -8,6 +9,8 @@ module.exports = {
|
||||
|
||||
async execute(client, interaction) {
|
||||
|
||||
|
||||
|
||||
if(!interaction.member.voice.channel) return interaction.reply({content:"Vous devez rejoindre un salon vocal !", ephemeral: true})
|
||||
|
||||
let player = client.manager.players.get(interaction.guild.id)
|
||||
|
@ -1,5 +1,6 @@
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const packageJson = require('../../package.json');
|
||||
const log = require("../sublog")
|
||||
|
||||
module.exports = {
|
||||
|
||||
@ -9,7 +10,8 @@ module.exports = {
|
||||
|
||||
async execute(client, interaction) {
|
||||
|
||||
|
||||
process.emit("discordDoing")
|
||||
|
||||
const uptime = process.uptime();
|
||||
const minutes = Math.floor(uptime / 60);
|
||||
const seconds = Math.floor(uptime % 60);
|
||||
|
825
src/main.js
825
src/main.js
@ -1,185 +1,716 @@
|
||||
const { channel } = require("node:diagnostics_channel");
|
||||
|
||||
let tryTime = 0;
|
||||
|
||||
if ("ENV" in process.env) {
|
||||
if(process.env.ENV == "TEST") {
|
||||
process.exit(0)
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function startApp() {
|
||||
|
||||
const { Client, GatewayIntentBits, Collection } = require("discord.js")
|
||||
const { REST, Routes } = require("discord.js")
|
||||
const fs = require("node:fs")
|
||||
const config = require("./config.json")
|
||||
const path = require("path")
|
||||
const { Manager } = require("erela.js")
|
||||
const { error } = require("node:console")
|
||||
const log = require("./sublog.js")
|
||||
const { config } = require("node:process")
|
||||
const { platform } = require("node:os")
|
||||
|
||||
const client = new Client({
|
||||
intents:[GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildMembers]
|
||||
})
|
||||
|
||||
client.commands = new Collection()
|
||||
client.dictator = false;
|
||||
function startDiscordBot() {
|
||||
|
||||
const commands = [];
|
||||
// Grab all the command files from the commands directory you created earlier
|
||||
const commandsPath = path.join(__dirname , 'commands');
|
||||
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
|
||||
|
||||
// Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment
|
||||
for (const file of commandFiles) {
|
||||
const command = require(`./commands/${file}`);
|
||||
client.commands.set(command.data.name, command)
|
||||
commands.push(command.data.toJSON());
|
||||
|
||||
const { Client, GatewayIntentBits, Collection } = require("discord.js")
|
||||
const { REST, Routes } = require("discord.js")
|
||||
const fs = require("node:fs")
|
||||
const config = require("./config.json")
|
||||
const path = require("path")
|
||||
const { Manager, TrackUtils } = require("erela.js")
|
||||
|
||||
const client = new Client({
|
||||
intents:[GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildMembers]
|
||||
})
|
||||
|
||||
client.commands = new Collection()
|
||||
client.dictator = false;
|
||||
|
||||
const commands = [];
|
||||
// Grab all the command files from the commands directory you created earlier
|
||||
const commandsPath = path.join(__dirname , 'commands');
|
||||
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
|
||||
|
||||
// Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment
|
||||
for (const file of commandFiles) {
|
||||
const command = require(`./commands/${file}`);
|
||||
client.commands.set(command.data.name, command)
|
||||
commands.push(command.data.toJSON());
|
||||
}
|
||||
|
||||
// Construct and prepare an instance of the REST module
|
||||
const rest = new REST().setToken(config.token);
|
||||
|
||||
// and deploy your commands!
|
||||
(async () => {
|
||||
try {
|
||||
|
||||
|
||||
|
||||
|
||||
log.bot(`Started refreshing ${commands.length} application (/) commands.`);
|
||||
|
||||
// The put method is used to fully refresh all commands in the guild with the current set
|
||||
const data = await rest.put(
|
||||
Routes.applicationGuildCommands(config.clientID, config.guildID),
|
||||
{ body: commands },
|
||||
);
|
||||
|
||||
log.bot(`Successfully reloaded ${data.length} application (/) commands.`);
|
||||
} catch (error) {
|
||||
// And of course, make sure you catch and log any errors!
|
||||
log.bot.error(error);
|
||||
}
|
||||
})();
|
||||
|
||||
// Command Slash
|
||||
|
||||
|
||||
// Client Event
|
||||
|
||||
client.once("ready", () => {
|
||||
|
||||
log.bot("Le meilleur groupe de musique est prêt !")
|
||||
client.user.setActivity(`beaucoup de choses !`, { type: "LISTENING" })
|
||||
client.manager.init(client.user.id);
|
||||
|
||||
const commandManager = client.application.commands;
|
||||
|
||||
if (!commandManager) {
|
||||
log.bot('Command manager not available.');
|
||||
|
||||
} else {
|
||||
|
||||
commandManager.set([]);
|
||||
}
|
||||
})
|
||||
|
||||
client.on("voiceStateUpdate", (oldMember, newMember) => {
|
||||
|
||||
let player = client.manager.players.get(oldMember.guild.id)
|
||||
|
||||
if(player) {
|
||||
|
||||
client.channels.fetch(player.options.voiceChannel).then(channel => {
|
||||
|
||||
if(channel.members.size <= 1) {
|
||||
|
||||
player.destroy()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
client.on("interactionCreate", (interaction) => {
|
||||
|
||||
if(!interaction.isCommand()) return;
|
||||
|
||||
const command = client.commands.get(interaction.commandName)
|
||||
|
||||
try {
|
||||
|
||||
log.bot(interaction.member.displayName + "-> /" + interaction.commandName)
|
||||
command.execute(client, interaction)
|
||||
} catch(error) {
|
||||
|
||||
interaction.reply({content:"Erreur lors de l'éxécution de la commande !", ephemeral: true})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const nodes = [
|
||||
{
|
||||
host: "lavalink.devamop.in",
|
||||
password: "DevamOP",
|
||||
port: 443,
|
||||
secure: true
|
||||
}
|
||||
];
|
||||
|
||||
client.manager = new Manager({
|
||||
// The nodes to connect to, optional if using default lavalink options
|
||||
nodes,
|
||||
// Method to send voice data to Discord
|
||||
send: (id, payload) => {
|
||||
const guild = client.guilds.cache.get(id);
|
||||
// NOTE: FOR ERIS YOU NEED JSON.stringify() THE PAYLOAD
|
||||
if (guild) guild.shard.send(payload);
|
||||
}
|
||||
});
|
||||
|
||||
// Emitted whenever a node connects
|
||||
client.manager.on("nodeConnect", node => {
|
||||
log.bot(`Node "${node.options.identifier}" connected.`)
|
||||
})
|
||||
|
||||
// Emitted whenever a node encountered an error
|
||||
client.manager.on("nodeError", (node, error) => {
|
||||
log.bot(`Node "${node.options.identifier}" encountered an error: ${error.message}.`)
|
||||
})
|
||||
|
||||
|
||||
// THIS IS REQUIRED. Send raw events to Erela.js
|
||||
client.on("raw", d => client.manager.updateVoiceState(d));
|
||||
|
||||
|
||||
// Client Manager
|
||||
|
||||
startServer(client)
|
||||
|
||||
|
||||
client.login(config.token)
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Construct and prepare an instance of the REST module
|
||||
const rest = new REST().setToken(config.token);
|
||||
function startServer(client) {
|
||||
|
||||
// and deploy your commands!
|
||||
(async () => {
|
||||
try {
|
||||
const express = require('express');
|
||||
const app = express();
|
||||
const http = require('http');
|
||||
const server = http.createServer(app);
|
||||
var cookieParser = require('cookie-parser')
|
||||
const { Server } = require("socket.io");
|
||||
const io = new Server(server);
|
||||
const uuid = require("uuid")
|
||||
const fs = require("fs")
|
||||
const path = require("path")
|
||||
|
||||
|
||||
|
||||
//const link = "http://localhost:4000"
|
||||
const link = "https://subsonics.raphix.fr"
|
||||
//const discordlink = "https://discord.com/api/oauth2/authorize?client_id=1094727789682380922&redirect_uri=http%3A%2F%2Flocalhost%3A4000%2Fredirect&response_type=code&scope=guilds%20identify"
|
||||
const discordlink = "https://discord.com/api/oauth2/authorize?client_id=1094727789682380922&redirect_uri=https%3A%2F%2Fsubsonics.raphix.fr%2Fredirect&response_type=code&scope=identify%20guilds"
|
||||
|
||||
console.log(`Started refreshing ${commands.length} application (/) commands.`);
|
||||
|
||||
// The put method is used to fully refresh all commands in the guild with the current set
|
||||
const data = await rest.put(
|
||||
Routes.applicationGuildCommands(config.clientID, config.guildID),
|
||||
{ body: commands },
|
||||
);
|
||||
|
||||
console.log(`Successfully reloaded ${data.length} application (/) commands.`);
|
||||
} catch (error) {
|
||||
// And of course, make sure you catch and log any errors!
|
||||
console.error(error);
|
||||
}
|
||||
})();
|
||||
|
||||
// Command Slash
|
||||
var authTokenWait = new Map()
|
||||
var users = new Map()
|
||||
var onlineNumber = 0;
|
||||
|
||||
|
||||
// Client Event
|
||||
const tokens = require(__dirname + path.sep + "tokens.json")
|
||||
|
||||
client.once("ready", () => {
|
||||
users = new Map()
|
||||
for(var user in tokens) {
|
||||
|
||||
console.log("Le meilleur groupe de musique est prêt !")
|
||||
client.user.setActivity(`beaucoup de choses !`, { type: "LISTENING" })
|
||||
client.manager.init(client.user.id);
|
||||
|
||||
const commandManager = client.application.commands;
|
||||
|
||||
if (!commandManager) {
|
||||
console.log('Command manager not available.');
|
||||
|
||||
} else {
|
||||
|
||||
commandManager.set([]);
|
||||
users.set(user , tokens[user])
|
||||
}
|
||||
})
|
||||
|
||||
client.on("voiceStateUpdate", (oldMember, newMember) => {
|
||||
|
||||
let player = client.manager.players.get(oldMember.guild.id)
|
||||
|
||||
if(player) {
|
||||
|
||||
client.channels.fetch(player.options.voiceChannel).then(channel => {
|
||||
|
||||
if(channel.members.size <= 1) {
|
||||
|
||||
player.destroy()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
client.on("interactionCreate", (interaction) => {
|
||||
|
||||
if(!interaction.isCommand()) return;
|
||||
|
||||
const command = client.commands.get(interaction.commandName)
|
||||
|
||||
try {
|
||||
command.execute(client, interaction)
|
||||
} catch(error) {
|
||||
|
||||
interaction.reply({content:"Erreur lors de l'éxécution de la commande !", ephemeral: true})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const nodes = [
|
||||
{
|
||||
host: "lavalink.devamop.in",
|
||||
password: "DevamOP",
|
||||
port: 443,
|
||||
secure: true
|
||||
}
|
||||
];
|
||||
|
||||
client.manager = new Manager({
|
||||
// The nodes to connect to, optional if using default lavalink options
|
||||
nodes,
|
||||
// Method to send voice data to Discord
|
||||
send: (id, payload) => {
|
||||
const guild = client.guilds.cache.get(id);
|
||||
// NOTE: FOR ERIS YOU NEED JSON.stringify() THE PAYLOAD
|
||||
if (guild) guild.shard.send(payload);
|
||||
}
|
||||
});
|
||||
|
||||
// Emitted whenever a node connects
|
||||
client.manager.on("nodeConnect", node => {
|
||||
console.log(`Node "${node.options.identifier}" connected.`)
|
||||
})
|
||||
|
||||
// Emitted whenever a node encountered an error
|
||||
client.manager.on("nodeError", (node, error) => {
|
||||
console.log(`Node "${node.options.identifier}" encountered an error: ${error.message}.`)
|
||||
})
|
||||
|
||||
|
||||
// THIS IS REQUIRED. Send raw events to Erela.js
|
||||
client.on("raw", d => client.manager.updateVoiceState(d));
|
||||
|
||||
|
||||
// Client Manager
|
||||
app.use(cookieParser())
|
||||
|
||||
|
||||
io.on('connection', (socket) => {
|
||||
log.server("Nouvelle Connexion - Client : " + socket.id)
|
||||
onlineNumber += 1
|
||||
actualize()
|
||||
|
||||
client.login(config.token)
|
||||
socket.on('disconnect', () => {
|
||||
log.server("Déconnexion - Client : " + socket.id);
|
||||
onlineNumber -= 1
|
||||
actualize()
|
||||
});
|
||||
|
||||
tryTime = 0
|
||||
socket.on("find", (token, value) => {
|
||||
|
||||
async function find() {
|
||||
|
||||
const searchList = await client.manager.search(value)
|
||||
await socket.emit("findResult", searchList)
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(users.has(token)) {
|
||||
|
||||
log.server("Recherche avec les mots clés : " + value + " de musique de " + users.get(token).username + "#" + users.get(token).discriminator)
|
||||
|
||||
find()
|
||||
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
socket.on("addQueue", (token, url) => {
|
||||
|
||||
async function play() {
|
||||
if(users.has(token)) {
|
||||
|
||||
let player = client.manager.players.get("137291455336022018")
|
||||
|
||||
if(!player) {
|
||||
|
||||
player = client.manager.create({
|
||||
guild: "137291455336022018",
|
||||
voiceChannel: "664355808250953739",
|
||||
textChannel: "664355808250953739",
|
||||
});
|
||||
|
||||
player.connect();
|
||||
}
|
||||
|
||||
|
||||
const songtrack = await client.manager.search(url)
|
||||
player.queue.add(songtrack.tracks[0])
|
||||
|
||||
|
||||
log.server("Lecture / Ajout du titre : " + songtrack.tracks[0].title + " de musique de " + users.get(token).username + "#" + users.get(token).discriminator)
|
||||
|
||||
if(!player.playing) {
|
||||
|
||||
player.play()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
actualize()
|
||||
}
|
||||
|
||||
play()
|
||||
|
||||
})
|
||||
|
||||
socket.on("authNeedLogin", () => {
|
||||
|
||||
log.server("Discord Auth : Demande Token de " + socket.id)
|
||||
const token = uuid.v4().toString()
|
||||
|
||||
authTokenWait.set(token, socket)
|
||||
|
||||
socket.emit("authOpenLink", link + "/" + token)
|
||||
|
||||
app.get("/" + token, (req, res) => {
|
||||
|
||||
res.cookie("authLoginFollow", token)
|
||||
log.server("Discord Auth : Redirection vers le service Discord pour " + socket.id)
|
||||
res.redirect(discordlink)
|
||||
|
||||
})
|
||||
|
||||
//socket.emit("authFailed")
|
||||
|
||||
})
|
||||
|
||||
socket.on("authByToken", (token) => {
|
||||
|
||||
var answer = false
|
||||
|
||||
if(users.has(token)) {
|
||||
answer = true
|
||||
|
||||
log.server("Connexion au serveur par Token - SOCKET_ID : " + socket.id + " - DISCORD_USER : " + users.get(token).username + "#" + users.get(token).discriminator)
|
||||
actualize()
|
||||
}
|
||||
|
||||
socket.emit("authByTokenAnswer", answer, token)
|
||||
})
|
||||
|
||||
socket.on("getState", (token) => {
|
||||
actualize()
|
||||
sendState(socket, token)
|
||||
})
|
||||
|
||||
socket.on("play", (token) => {
|
||||
if(users.has(token)) {
|
||||
|
||||
log.server("Mise en Play / Pause demandé par " + users.get(token).username + "#" + users.get(token).discriminator)
|
||||
|
||||
let player = client.manager.players.get("137291455336022018")
|
||||
|
||||
if(player && player.playing == true && player.paused == false) {
|
||||
|
||||
player.pause(true)
|
||||
|
||||
} else if(player && player.playing == false && player.paused == true) {
|
||||
|
||||
player.pause(false)
|
||||
}
|
||||
|
||||
actualize()
|
||||
} else {
|
||||
socket.emit("authFailed")
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
process.on("discordDoing", () => {
|
||||
log.server("Discord BOT - Doing an action need actualisation !")
|
||||
actualize()
|
||||
})
|
||||
|
||||
socket.on("listClear", (token) => {
|
||||
if(users.has(token)) {
|
||||
|
||||
|
||||
log.server("Clear liste demandé par " + users.get(token).username + "#" + users.get(token).discriminator)
|
||||
|
||||
let player = client.manager.players.get("137291455336022018")
|
||||
|
||||
if(player) {
|
||||
|
||||
player.queue.clear()
|
||||
}
|
||||
|
||||
actualize()
|
||||
} else {
|
||||
|
||||
socket.emit("authFailed")
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
socket.on("deleteQueue", (token, identifier) => {
|
||||
|
||||
if(users.has(token)) {
|
||||
|
||||
let player = client.manager.players.get("137291455336022018")
|
||||
|
||||
if(player) {
|
||||
|
||||
log.server("Supression (n°" + identifier + ") d'un morceau demandé par " + users.get(token).username + "#" + users.get(token).discriminator)
|
||||
|
||||
player.queue.remove(identifier)
|
||||
|
||||
|
||||
}
|
||||
|
||||
actualize()
|
||||
} else {
|
||||
socket.emit("authFailed")
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
socket.on("backward", (token) => {
|
||||
|
||||
if(users.has(token)) {
|
||||
|
||||
log.server("Retour arrière demandé par " + users.get(token).username + "#" + users.get(token).discriminator)
|
||||
|
||||
let player = client.manager.players.get("137291455336022018")
|
||||
|
||||
if(player && player.queue.previous) {
|
||||
|
||||
player.play(player.queue.previous)
|
||||
|
||||
} else if(player && player.queue.current) {
|
||||
|
||||
|
||||
player.play(player.queue.current)
|
||||
|
||||
}
|
||||
|
||||
actualize()
|
||||
} else {
|
||||
socket.emit("authFailed")
|
||||
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
socket.on("forward", (token) => {
|
||||
|
||||
if(users.has(token)) {
|
||||
|
||||
log.server("Skip demandé par " + users.get(token).username + "#" + users.get(token).discriminator)
|
||||
|
||||
let player = client.manager.players.get("137291455336022018")
|
||||
|
||||
if(player && player.queue.length != 0) {
|
||||
|
||||
player.stop()
|
||||
|
||||
|
||||
} else if(player && player.queue.current) {
|
||||
|
||||
|
||||
player.play(player.queue.current)
|
||||
|
||||
}
|
||||
|
||||
actualize()
|
||||
} else {
|
||||
socket.emit("authFailed")
|
||||
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
socket.on("exit", (token) => {
|
||||
|
||||
if(users.has(token)) {
|
||||
|
||||
log.server("Skip demandé par " + users.get(token).username + "#" + users.get(token).discriminator)
|
||||
|
||||
let player = client.manager.players.get("137291455336022018")
|
||||
|
||||
if(player) {
|
||||
|
||||
player.destroy()
|
||||
}
|
||||
|
||||
actualize()
|
||||
} else {
|
||||
socket.emit("authFailed")
|
||||
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
client.manager.on("playerCreate", () => {
|
||||
log.server("Player : Player Created -> Actualize all client !")
|
||||
actualize()
|
||||
|
||||
})
|
||||
|
||||
client.manager.on("playerDestroy", () => {
|
||||
log.server("Player : Player Destroyed -> Actualize all client !")
|
||||
actualize("end")
|
||||
|
||||
})
|
||||
|
||||
client.manager.on("trackStart", () => {
|
||||
|
||||
log.server("Player : New Track Start-> Actualize all client !")
|
||||
actualize()
|
||||
|
||||
})
|
||||
|
||||
client.manager.on("queueEnd", () => {
|
||||
|
||||
log.server("Player : End Queue -> Actualize all client !")
|
||||
actualize()
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
function actualize(action) {
|
||||
|
||||
let player = client.manager.players.get("137291455336022018")
|
||||
|
||||
|
||||
const data = {
|
||||
"onlineNumber":onlineNumber,
|
||||
"playing": 0,
|
||||
"current":null,
|
||||
"isOnline": false,
|
||||
"queue": null
|
||||
}
|
||||
|
||||
if(player) {
|
||||
|
||||
data["current"] = player.queue.current
|
||||
|
||||
if(player.playing == true && player.paused == false) {
|
||||
|
||||
data["playing"] = 1
|
||||
} else {
|
||||
data["playing"] = 0
|
||||
|
||||
}
|
||||
|
||||
data["queue"] = player.queue;
|
||||
|
||||
if(player.playing == true) {
|
||||
|
||||
log.server("Musique : Musique actuelle : " + player.queue.current.title)
|
||||
}
|
||||
|
||||
data["isOnline"] = true
|
||||
|
||||
}
|
||||
|
||||
log.server("Actualisation Client : Online Number : " + data.onlineNumber + " - PlayingState : " + data.playing + " - Current : " + data.current + " - Player : " + player)
|
||||
|
||||
|
||||
|
||||
if(action == "end") {
|
||||
|
||||
data["current"] = null;
|
||||
data["isOnline"] = false
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
io.sockets.emit("actualize", data)
|
||||
} catch(error) {
|
||||
|
||||
log.server("ERROR OF ACT")
|
||||
}
|
||||
|
||||
}
|
||||
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) => {
|
||||
|
||||
|
||||
let token = req.cookies.authLoginFollow
|
||||
|
||||
|
||||
|
||||
if(token != null) {
|
||||
|
||||
if(authTokenWait.has(token) == true) {
|
||||
|
||||
const socket = authTokenWait.get(token)
|
||||
|
||||
|
||||
|
||||
|
||||
const code = req.query.code
|
||||
|
||||
|
||||
log.server("Discord Auth : Récupération du service Discord : Token de Connexion : " + token + " associé à Client ID : " + socket.id)
|
||||
|
||||
if(code) {
|
||||
|
||||
try {
|
||||
log.server("Discord Auth : REQUESTING DATA - TOKEN : " + token + " - DISCORD_CODE : " + code)
|
||||
|
||||
const params = new URLSearchParams();
|
||||
params.append('client_id', "1094727789682380922");
|
||||
params.append('client_secret', "uwtyPOPKCgw6ciBs20qiJ7LJrW9Ziclo");
|
||||
params.append('grant_type', 'authorization_code');
|
||||
params.append('code', code);
|
||||
params.append('redirect_uri', req.protocol + "://" + req.get('host') + "/redirect");
|
||||
params.append('scope', 'identify guild');
|
||||
|
||||
fetch('https://discord.com/api/oauth2/token', {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}, body : params
|
||||
}).then(resp => resp.json()).then(resp => createIdentity(resp, token, socket)).catch(error => log.server.error(error))
|
||||
|
||||
|
||||
|
||||
res.clearCookie("authLoginFollow")
|
||||
res.send("SubSonics Manager : Vous pouvez fermer cette fenêtre ! Si rien ne ce passe sur l'application, prévenez Raphix !")
|
||||
|
||||
|
||||
} catch(error) {
|
||||
|
||||
console.log(error)
|
||||
}
|
||||
|
||||
} else {
|
||||
res.send("SubSonics Manager : ERREUR : DISCORD AUTH FAILED !")
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
res.send("SubSonics Manager : ERREUR : AUCUN TOKEN ENREGISTRÉ !")
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
res.send("SubSonics Manager : ERREUR : AUCUN TOKEN ENREGISTRÉ !")
|
||||
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
function createIdentity(response, token, socket) {
|
||||
|
||||
|
||||
log.server("Discord Auth : REQUESTING DATA - TOKEN : " + token + " - DISCORD_ACCESS_TOKEN : " + response.access_token)
|
||||
|
||||
fetch('https://discord.com/api/users/@me', {
|
||||
headers: {
|
||||
authorization: `${response.token_type} ${response.access_token}`,
|
||||
},
|
||||
}).then(resp => resp.json()).then(resp => addIdentity(resp, token, socket)).catch(error => log.server.error(error))
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function addIdentity(response, token, socket) {
|
||||
|
||||
log.server("Discord Auth : [IDENTITE] : Nouvelle identité - SOCKET_ID : " + socket.id + " - DISCORD_USER : " + response.username + "#" + response.discriminator)
|
||||
socket.emit("registerToken", token)
|
||||
|
||||
socket.emit("successLogin")
|
||||
|
||||
|
||||
const tokens = require(__dirname + path.sep + "tokens.json")
|
||||
|
||||
tokens[token] = response
|
||||
|
||||
fs.writeFileSync(__dirname + path.sep + "tokens.json", JSON.stringify(tokens, null, 2))
|
||||
|
||||
|
||||
users = new Map()
|
||||
for(var user in tokens) {
|
||||
|
||||
users.set(user , tokens[user])
|
||||
}
|
||||
|
||||
actualize()
|
||||
authTokenWait.delete(token)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
var port = 4000;
|
||||
|
||||
server.listen(port, () => {
|
||||
log.server("Ecoute sur le PORT : " + port)
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function handleFatalError(error) {
|
||||
console.error('Erreur fatale :', error);
|
||||
console.log('Redémarrage en cours...');
|
||||
|
||||
if(tryTime == 10) {
|
||||
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
tryTime += 1;
|
||||
log.bot.error('Erreur fatale :', error);
|
||||
console.log(error)
|
||||
client = null
|
||||
startApp();
|
||||
|
||||
|
||||
}
|
||||
|
||||
process.on('uncaughtException', handleFatalError);
|
||||
|
||||
startApp();
|
||||
startDiscordBot();
|
||||
|
||||
|
152
src/sublog.js
Normal file
152
src/sublog.js
Normal file
@ -0,0 +1,152 @@
|
||||
module.exports.server = (message) => {
|
||||
|
||||
var date = new Date()
|
||||
|
||||
// [Date Format] - Format de la date
|
||||
|
||||
var gmonth = date.getMonth()
|
||||
var gday = date.getDate()
|
||||
var gHour = date.getHours()
|
||||
var gMinute = date.getMinutes()
|
||||
var gSecondes = date.getSeconds()
|
||||
|
||||
|
||||
if(date.getMonth() + 1 <= 9) {
|
||||
gmonth = "0" + (date.getMonth() + 1)
|
||||
}
|
||||
|
||||
if(date.getDate() + 1 <= 9) {
|
||||
gday = "0" + date.getDate()
|
||||
}
|
||||
|
||||
if(date.getHours() + 1 <= 9) {
|
||||
gHour = "0" + date.getHours()
|
||||
}
|
||||
|
||||
if(date.getMinutes() + 1 <= 9) {
|
||||
gMinute = "0" + date.getMinutes()
|
||||
}
|
||||
|
||||
if(date.getSeconds() + 1 <= 9) {
|
||||
gSecondes = "0" + date.getSeconds()
|
||||
}
|
||||
|
||||
var currentDate = date.getFullYear() + "-" + gmonth + "-" + gday + "-" + gHour + "h" + "-" + gMinute + "m" + "-" + gSecondes + "s"
|
||||
|
||||
console.log("[Subsonics-Server] - " + currentDate + " - " + message)
|
||||
}
|
||||
|
||||
module.exports.server.error = (message) => {
|
||||
|
||||
var date = new Date()
|
||||
|
||||
// [Date Format] - Format de la date
|
||||
|
||||
var gmonth = date.getMonth()
|
||||
var gday = date.getDate()
|
||||
var gHour = date.getHours()
|
||||
var gMinute = date.getMinutes()
|
||||
var gSecondes = date.getSeconds()
|
||||
|
||||
|
||||
if(date.getMonth() + 1 <= 9) {
|
||||
gmonth = "0" + (date.getMonth() + 1)
|
||||
}
|
||||
|
||||
if(date.getDate() + 1 <= 9) {
|
||||
gday = "0" + date.getDate()
|
||||
}
|
||||
|
||||
if(date.getHours() + 1 <= 9) {
|
||||
gHour = "0" + date.getHours()
|
||||
}
|
||||
|
||||
if(date.getMinutes() + 1 <= 9) {
|
||||
gMinute = "0" + date.getMinutes()
|
||||
}
|
||||
|
||||
if(date.getSeconds() + 1 <= 9) {
|
||||
gSecondes = "0" + date.getSeconds()
|
||||
}
|
||||
|
||||
var currentDate = date.getFullYear() + "-" + gmonth + "-" + gday + "-" + gHour + "h" + "-" + gMinute + "m" + "-" + gSecondes + "s"
|
||||
|
||||
console.error("[Subsonics-Server] - [ERROR] - " + currentDate + " - " + message)
|
||||
}
|
||||
|
||||
module.exports.bot = (message) => {
|
||||
|
||||
var date = new Date()
|
||||
|
||||
// [Date Format] - Format de la date
|
||||
|
||||
var gmonth = date.getMonth()
|
||||
var gday = date.getDate()
|
||||
var gHour = date.getHours()
|
||||
var gMinute = date.getMinutes()
|
||||
var gSecondes = date.getSeconds()
|
||||
|
||||
|
||||
if(date.getMonth() + 1 <= 9) {
|
||||
gmonth = "0" + (date.getMonth() + 1)
|
||||
}
|
||||
|
||||
if(date.getDate() + 1 <= 9) {
|
||||
gday = "0" + date.getDate()
|
||||
}
|
||||
|
||||
if(date.getHours() + 1 <= 9) {
|
||||
gHour = "0" + date.getHours()
|
||||
}
|
||||
|
||||
if(date.getMinutes() + 1 <= 9) {
|
||||
gMinute = "0" + date.getMinutes()
|
||||
}
|
||||
|
||||
if(date.getSeconds() + 1 <= 9) {
|
||||
gSecondes = "0" + date.getSeconds()
|
||||
}
|
||||
|
||||
var currentDate = date.getFullYear() + "-" + gmonth + "-" + gday + "-" + gHour + "h" + "-" + gMinute + "m" + "-" + gSecondes + "s"
|
||||
|
||||
console.log("[Subsonics-Discord] - " + currentDate + " - " + message)
|
||||
}
|
||||
|
||||
module.exports.bot.error = (message) => {
|
||||
|
||||
var date = new Date()
|
||||
|
||||
// [Date Format] - Format de la date
|
||||
|
||||
var gmonth = date.getMonth()
|
||||
var gday = date.getDate()
|
||||
var gHour = date.getHours()
|
||||
var gMinute = date.getMinutes()
|
||||
var gSecondes = date.getSeconds()
|
||||
|
||||
|
||||
if(date.getMonth() + 1 <= 9) {
|
||||
gmonth = "0" + (date.getMonth() + 1)
|
||||
}
|
||||
|
||||
if(date.getDate() + 1 <= 9) {
|
||||
gday = "0" + date.getDate()
|
||||
}
|
||||
|
||||
if(date.getHours() + 1 <= 9) {
|
||||
gHour = "0" + date.getHours()
|
||||
}
|
||||
|
||||
if(date.getMinutes() + 1 <= 9) {
|
||||
gMinute = "0" + date.getMinutes()
|
||||
}
|
||||
|
||||
if(date.getSeconds() + 1 <= 9) {
|
||||
gSecondes = "0" + date.getSeconds()
|
||||
}
|
||||
|
||||
var currentDate = date.getFullYear() + "-" + gmonth + "-" + gday + "-" + gHour + "h" + "-" + gMinute + "m" + "-" + gSecondes + "s"
|
||||
|
||||
console.error("[Subsonics-Discord] - [ERROR] - " + currentDate + " - ")
|
||||
console.error(message)
|
||||
}
|
308
src/tokens.json
Normal file
308
src/tokens.json
Normal file
@ -0,0 +1,308 @@
|
||||
{
|
||||
"7967c971-be8b-4906-a6dc-d4f5ffd2c1f5": {
|
||||
"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
|
||||
},
|
||||
"b6e769dc-5775-45c7-809a-136e2f5b8fa7": {
|
||||
"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
|
||||
},
|
||||
"6b349836-c482-4f0d-bdc1-97311ac7f252": {
|
||||
"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
|
||||
},
|
||||
"737136a0-0415-48d7-ac4d-21276abcf241": {
|
||||
"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
|
||||
},
|
||||
"9f987ae3-77b1-4218-b294-233b47fe1f87": {
|
||||
"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
|
||||
},
|
||||
"de66945f-3da6-45dc-b427-e7999bad8ef5": {
|
||||
"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
|
||||
},
|
||||
"6aa6df7d-21a2-46be-bb11-d9c9874f8a90": {
|
||||
"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
|
||||
},
|
||||
"b8614915-1bf9-4fac-980a-8a1546a7e0ae": {
|
||||
"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
|
||||
},
|
||||
"23d19191-73dd-43d5-ae64-32b4108f23ea": {
|
||||
"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
|
||||
},
|
||||
"a23b262e-6d0d-4677-8791-4e68e5a3af11": {
|
||||
"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
|
||||
},
|
||||
"d5cdcfb5-f975-4f6a-accd-8085abb6ec23": {
|
||||
"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
|
||||
},
|
||||
"54172611-50d2-4b31-a108-dc73df49af2d": {
|
||||
"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
|
||||
},
|
||||
"5a1f8903-bcac-4921-978d-2460c0a999ff": {
|
||||
"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
|
||||
},
|
||||
"8eedcc5b-df61-4ed3-87b3-1c2152e352b0": {
|
||||
"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
|
||||
},
|
||||
"e29035a5-7992-468b-a93f-e555506e54e2": {
|
||||
"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
|
||||
},
|
||||
"0832a777-15e4-4aff-861b-1d77883e381d": {
|
||||
"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
|
||||
},
|
||||
"013cf605-cad4-47c8-b857-028db1f39cdc": {
|
||||
"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
|
||||
},
|
||||
"afef2df3-07ba-403f-91b3-5fbeede287b7": {
|
||||
"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
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user