4.0
This commit is contained in:
parent
2a62ebc2f6
commit
31ba11951b
63
package-lock.json
generated
63
package-lock.json
generated
@ -1,16 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "subsonics-discord",
|
"name": "subsonics-discord",
|
||||||
"version": "1.0.0",
|
"version": "4.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "subsonics-discord",
|
"name": "subsonics-discord",
|
||||||
"version": "1.0.0",
|
"version": "4.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord.js": "^14.9.0",
|
"discord.js": "^14.9.0",
|
||||||
"erela.js": "^2.4.0",
|
"erela.js": "^2.4.0",
|
||||||
"nodemon": "^2.0.22"
|
"nodemon": "^2.0.22",
|
||||||
|
"ytfps": "^1.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@discordjs/builders": {
|
"node_modules/@discordjs/builders": {
|
||||||
@ -141,6 +142,14 @@
|
|||||||
"node": ">= 8"
|
"node": ">= 8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/axios": {
|
||||||
|
"version": "0.21.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
|
||||||
|
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
|
||||||
|
"dependencies": {
|
||||||
|
"follow-redirects": "^1.14.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/balanced-match": {
|
"node_modules/balanced-match": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||||
@ -298,6 +307,25 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/follow-redirects": {
|
||||||
|
"version": "1.15.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
|
||||||
|
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "individual",
|
||||||
|
"url": "https://github.com/sponsors/RubenVerborgh"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"debug": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/fsevents": {
|
"node_modules/fsevents": {
|
||||||
"version": "2.3.2",
|
"version": "2.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||||
@ -716,6 +744,14 @@
|
|||||||
"optional": true
|
"optional": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"node_modules/ytfps": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ytfps/-/ytfps-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-uev6HLs/cGsjPFiF4wfW93g03Da0SUhIG+n+Wfv25VOEWaXuwP/H5hNv1pa0JP8cAnfr8NG+rOM3JPswzq+Q3Q==",
|
||||||
|
"dependencies": {
|
||||||
|
"axios": "^0.21.1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -817,6 +853,14 @@
|
|||||||
"picomatch": "^2.0.4"
|
"picomatch": "^2.0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"axios": {
|
||||||
|
"version": "0.21.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
|
||||||
|
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
|
||||||
|
"requires": {
|
||||||
|
"follow-redirects": "^1.14.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"balanced-match": {
|
"balanced-match": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||||
@ -939,6 +983,11 @@
|
|||||||
"to-regex-range": "^5.0.1"
|
"to-regex-range": "^5.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"follow-redirects": {
|
||||||
|
"version": "1.15.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
|
||||||
|
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA=="
|
||||||
|
},
|
||||||
"fsevents": {
|
"fsevents": {
|
||||||
"version": "2.3.2",
|
"version": "2.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||||
@ -1206,6 +1255,14 @@
|
|||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz",
|
||||||
"integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==",
|
"integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==",
|
||||||
"requires": {}
|
"requires": {}
|
||||||
|
},
|
||||||
|
"ytfps": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ytfps/-/ytfps-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-uev6HLs/cGsjPFiF4wfW93g03Da0SUhIG+n+Wfv25VOEWaXuwP/H5hNv1pa0JP8cAnfr8NG+rOM3JPswzq+Q3Q==",
|
||||||
|
"requires": {
|
||||||
|
"axios": "^0.21.1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "subsonics-discord",
|
"name": "subsonics-discord",
|
||||||
"author": "Raphix",
|
"author": "Raphix",
|
||||||
"version": "3.0",
|
"version": "4.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord.js": "^14.9.0",
|
"discord.js": "^14.9.0",
|
||||||
"erela.js": "^2.4.0",
|
"erela.js": "^2.4.0",
|
||||||
"nodemon": "^2.0.22"
|
"nodemon": "^2.0.22",
|
||||||
|
"ytfps": "^1.1.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "nodemon src/main.js"
|
"start": "nodemon src/main.js"
|
||||||
|
@ -21,7 +21,8 @@ module.exports = {
|
|||||||
{name: "/queue <afficher/supprimer>", value: "Permet d'afficher ou de supprimer les titres de la liste de lecture."},
|
{name: "/queue <afficher/supprimer>", value: "Permet d'afficher ou de supprimer les titres de la liste de lecture."},
|
||||||
{name: "/state", value: "Donne l'état de la musique"},
|
{name: "/state", value: "Donne l'état de la musique"},
|
||||||
{name: "/skip", value: "Passer à la chanson suivante."},
|
{name: "/skip", value: "Passer à la chanson suivante."},
|
||||||
{name: "/back", value: "Revenir à la chanson précédente."})
|
{name: "/back", value: "Revenir à la chanson précédente."},
|
||||||
|
{name: "/playlist", value: "Permet d'ajouter à la liste de lecture toute une playlist."})
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setThumbnail("https://static.wikia.nocookie.net/codelyoko/images/9/95/Subdigitals.jpg/revision/latest/scale-to-width-down/180?cb=20120105180510&path-prefix=fr");
|
.setThumbnail("https://static.wikia.nocookie.net/codelyoko/images/9/95/Subdigitals.jpg/revision/latest/scale-to-width-down/180?cb=20120105180510&path-prefix=fr");
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ module.exports = {
|
|||||||
|
|
||||||
const embed = await new EmbedBuilder()
|
const embed = await new EmbedBuilder()
|
||||||
.setColor(0x15e6ed)
|
.setColor(0x15e6ed)
|
||||||
.setTitle('**Lecture de **' + songs.tracks[0].title)
|
.setTitle('**Lecture de : **' + songs.tracks[0].title)
|
||||||
.setDescription('**Demandé par **' + interaction.member.user.username)
|
.setDescription('**Demandé par **' + interaction.member.user.username)
|
||||||
.addFields({name: "Auteur", value: songs.tracks[0].author},
|
.addFields({name: "Auteur", value: songs.tracks[0].author},
|
||||||
{name: "URL", value:songs.tracks[0].uri})
|
{name: "URL", value:songs.tracks[0].uri})
|
||||||
@ -72,7 +72,7 @@ module.exports = {
|
|||||||
interaction.reply({embeds: [embed]})
|
interaction.reply({embeds: [embed]})
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
|
|
||||||
interaction.reply({embeds: [embed]})
|
console.log(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ module.exports = {
|
|||||||
|
|
||||||
const embed = await new EmbedBuilder()
|
const embed = await new EmbedBuilder()
|
||||||
.setColor(0x15e6ed)
|
.setColor(0x15e6ed)
|
||||||
.setTitle('**Ajout dans la liste de lecture **' + songs.tracks[0].title)
|
.setTitle('**Ajout dans la liste de lecture **: ' + songs.tracks[0].title)
|
||||||
.setDescription('**Demandé par **' + interaction.member.user.username)
|
.setDescription('**Demandé par **' + interaction.member.user.username)
|
||||||
.addFields({name: "Auteur", value: songs.tracks[0].author},
|
.addFields({name: "Auteur", value: songs.tracks[0].author},
|
||||||
{name: "URL", value:songs.tracks[0].uri})
|
{name: "URL", value:songs.tracks[0].uri})
|
||||||
@ -100,7 +100,7 @@ module.exports = {
|
|||||||
interaction.reply({embeds: [embed]})
|
interaction.reply({embeds: [embed]})
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
|
|
||||||
interaction.reply({embeds: [embed]})
|
console.log(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
129
src/commands/playlist.js
Normal file
129
src/commands/playlist.js
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
const { EmbedBuilder } = require("@discordjs/builders");
|
||||||
|
const { SlashCommandBuilder, Embed } = require("discord.js");
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
data:new SlashCommandBuilder()
|
||||||
|
.setName("playlist")
|
||||||
|
.setDescription("Permet de lire une playlist de Youtube !")
|
||||||
|
.addStringOption(option => option.setName("lien").setDescription("Le lien de la playlist !").setRequired(true)),
|
||||||
|
|
||||||
|
async execute(client, interaction) {
|
||||||
|
|
||||||
|
if(client.dictator == true ) {
|
||||||
|
|
||||||
|
if((interaction.member._roles.includes("397725956598530050") == true | interaction.member.user.id == "486943594893017119")) {
|
||||||
|
|
||||||
|
makeAction()
|
||||||
|
} else {
|
||||||
|
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setColor(0xff0303)
|
||||||
|
.setTitle('Mode Dictateur')
|
||||||
|
.setTimestamp();
|
||||||
|
const song_show = {name: "Le mode dictateur est actif !", value: "Demande au grand roi !"}
|
||||||
|
|
||||||
|
embed.addFields(song_show)
|
||||||
|
interaction.reply({embeds: [embed]})
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
makeAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function makeAction() {
|
||||||
|
|
||||||
|
const song_name = interaction.options.getString("lien")
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
if(!player) {
|
||||||
|
|
||||||
|
player = client.manager.create({
|
||||||
|
guild: interaction.guild.id,
|
||||||
|
voiceChannel: interaction.member.voice.channel.id,
|
||||||
|
textChannel: interaction.channel.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
player.connect();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var ytfps = require("ytfps")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
var playlist = await ytfps(song_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},
|
||||||
|
{name: "URL", value:playlist.url},
|
||||||
|
{name: "Nombre de videos", value:playlist.video_count + " vidéos"})
|
||||||
|
.setThumbnail(playlist.thumbnail_url)
|
||||||
|
.setTimestamp();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
await interaction.reply({embeds: [embed]})
|
||||||
|
} catch(error) {
|
||||||
|
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for(var song of playlist.videos) {
|
||||||
|
|
||||||
|
const song_finded = await client.manager.search(song.url)
|
||||||
|
await client.manager.players.get(interaction.guild.id).queue.add(song_finded.tracks[0])
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch(err) {
|
||||||
|
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setColor(0xff0303)
|
||||||
|
.setTitle('Erreur : Playlist !')
|
||||||
|
.setTimestamp();
|
||||||
|
const song_show = {name: "Une erreur s'est produite ou la playlist n'existe pas !", value: "Est-tu sur du lien ?"}
|
||||||
|
|
||||||
|
embed.addFields(song_show)
|
||||||
|
interaction.reply({embeds: [embed]})
|
||||||
|
|
||||||
|
console.log(err)
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
if(playlist != null) {
|
||||||
|
|
||||||
|
if(!player.playing) {
|
||||||
|
|
||||||
|
|
||||||
|
player.play()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
src/main.js
11
src/main.js
@ -2,7 +2,7 @@ let tryTime = 0;
|
|||||||
|
|
||||||
function startApp() {
|
function startApp() {
|
||||||
|
|
||||||
const { Client, GatewayIntentBits, Collection } = require("discord.js")
|
const { Client, GatewayIntentBits, Collection } = require("discord.js")
|
||||||
const { REST, Routes } = require("discord.js")
|
const { REST, Routes } = require("discord.js")
|
||||||
const fs = require("node:fs")
|
const fs = require("node:fs")
|
||||||
const config = require("./config.json")
|
const config = require("./config.json")
|
||||||
@ -136,7 +136,7 @@ tryTime = 0
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleFatalError(error) {
|
function handleFatalError(error) {
|
||||||
console.error('Erreur fatale :', error);
|
console.error('Erreur fatale :', error);
|
||||||
console.log('Redémarrage en cours...');
|
console.log('Redémarrage en cours...');
|
||||||
|
|
||||||
@ -146,9 +146,10 @@ tryTime = 0
|
|||||||
}
|
}
|
||||||
|
|
||||||
tryTime += 1;
|
tryTime += 1;
|
||||||
|
client = null
|
||||||
startApp();
|
startApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
process.on('uncaughtException', handleFatalError);
|
process.on('uncaughtException', handleFatalError);
|
||||||
|
|
||||||
startApp();
|
startApp();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user