Version 2
This commit is contained in:
parent
23814fbb24
commit
ffeef2df90
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "subsonics-discord",
|
"name": "subsonics-discord",
|
||||||
"author": "Raphix",
|
"author": "Raphix",
|
||||||
"version": "1.0.0",
|
"version": "2.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord.js": "^14.9.0",
|
"discord.js": "^14.9.0",
|
||||||
"erela.js": "^2.4.0",
|
"erela.js": "^2.4.0",
|
||||||
|
32
src/commands/help.js
Normal file
32
src/commands/help.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
data:new SlashCommandBuilder()
|
||||||
|
.setName("help")
|
||||||
|
.setDescription("Faire partir le meilleur groupe du monde !"),
|
||||||
|
|
||||||
|
async execute(client, interaction) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setColor(0x03ff2d)
|
||||||
|
.setTitle('Comment assister au concert ?')
|
||||||
|
.setDescription("**Eh ! Tu as eu ton ticket ? Tant mieux ! Voici la liste des commandes à utiliser dans le salon <#664355637685256203>**")
|
||||||
|
.addFields({name: "/play <nom>", value: "Cette commande te permet de lire depuis Youtube, n'importe quel musique !"},
|
||||||
|
{name: "/leave", value: "Si tu ne veux plus du meilleur groupe du monde (faire partir le bot), cette commande les fera partir aussi vite qu'ils sont arrivés !"},
|
||||||
|
{name: "/pause", value: "Besoin d'un entracte ? Cette commande te permettera de mettre le morceau en cours, en pause !"},
|
||||||
|
{name: "/resume", value: "Fin de l'entracte ? Cette commande te permettera de mettre le morceau qui était en pause, en cours !"},
|
||||||
|
{name: "/queue <afficher/supprimer>", value: "Permet d'afficher ou de supprimer les titres de la liste de lecture."})
|
||||||
|
.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");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
interaction.reply({embeds: [embed]})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||||
|
const { Player } = require("erela.js");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
@ -12,9 +13,10 @@ module.exports = {
|
|||||||
|
|
||||||
let player = client.manager.players.get(interaction.guild.id)
|
let player = client.manager.players.get(interaction.guild.id)
|
||||||
|
|
||||||
|
|
||||||
if(player) {
|
if(player) {
|
||||||
|
|
||||||
player.disconnect()
|
player.destroy()
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(0xff0000)
|
.setColor(0xff0000)
|
||||||
@ -28,7 +30,7 @@ module.exports = {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
interaction.reply("**Aucune musique n'est actuellement joué !**")
|
interaction.reply("**Aucune musique n'est actuellement jouée !**")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ module.exports = {
|
|||||||
|
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName("pause")
|
.setName("pause")
|
||||||
.setDescription("Met en pause la musique joué !"),
|
.setDescription("Met en pause la musique jouée !"),
|
||||||
|
|
||||||
async execute(client, interaction) {
|
async execute(client, interaction) {
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ module.exports = {
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(0x03ff2d)
|
.setColor(0x03ff2d)
|
||||||
.setTitle('Pause !')
|
.setTitle('Pause !')
|
||||||
.setDescription("**Ok, une entracte est demandé par " + interaction.member.user.username + "**")
|
.setDescription("**Ok, une entracte est demandée par " + interaction.member.user.username + "**")
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
|
|
||||||
|
|
||||||
@ -27,13 +27,13 @@ module.exports = {
|
|||||||
|
|
||||||
player.pause(true)
|
player.pause(true)
|
||||||
} else {
|
} else {
|
||||||
interaction.reply("**Aucune musique n'est actuellement joué !**")
|
interaction.reply("**Aucune musique n'est actuellement jouée !**")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
interaction.reply("**Aucune musique n'est actuellement joué !**")
|
interaction.reply("**Aucune musique n'est actuellement jouée !**")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,42 +6,82 @@ module.exports = {
|
|||||||
data:new SlashCommandBuilder()
|
data:new SlashCommandBuilder()
|
||||||
.setName("play")
|
.setName("play")
|
||||||
.setDescription("Lire une musique depuis youtube")
|
.setDescription("Lire une musique depuis youtube")
|
||||||
.addStringOption(option => option.setName("nom").setDescription("Le nom de la musique recherché !").setRequired(true)),
|
.addStringOption(option => option.setName("nom_ou_lien").setDescription("Le nom de la musique recherchée !").setRequired(true)),
|
||||||
|
|
||||||
async execute(client, interaction) {
|
async execute(client, interaction) {
|
||||||
|
|
||||||
const song_name = interaction.options.getString("nom")
|
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)
|
let player = client.manager.players.get(interaction.guild.id)
|
||||||
|
|
||||||
if(!player) player = client.manager.create({
|
if(!player) {
|
||||||
|
|
||||||
|
player = client.manager.create({
|
||||||
guild: interaction.guild.id,
|
guild: interaction.guild.id,
|
||||||
voiceChannel: interaction.member.voice.channel.id,
|
voiceChannel: interaction.member.voice.channel.id,
|
||||||
textChannel: interaction.channel.id,
|
textChannel: interaction.channel.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
player.connect();
|
||||||
|
}
|
||||||
|
|
||||||
const songs = await client.manager.search(song_name)
|
const songs = await client.manager.search(song_name)
|
||||||
|
|
||||||
player.connect();
|
if(!player.playing) {
|
||||||
|
|
||||||
player.queue.add(songs.tracks[0])
|
client.manager.players.get(interaction.guild.id).queue.add(songs.tracks[0])
|
||||||
|
player.play()
|
||||||
|
|
||||||
if(!player.playing) player.play()
|
const embed = await new EmbedBuilder()
|
||||||
|
.setColor(0x15e6ed)
|
||||||
|
.setTitle('**Lecture de **' + songs.tracks[0].title)
|
||||||
|
.setDescription('**Demandé par **' + interaction.member.user.username)
|
||||||
|
.addFields({name: "Auteur", value: songs.tracks[0].author},
|
||||||
|
{name: "URL", value:songs.tracks[0].uri})
|
||||||
|
.setThumbnail(songs.tracks[0].thumbnail)
|
||||||
|
.setTimestamp();
|
||||||
|
|
||||||
console.log(songs.tracks[0])
|
try {
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
interaction.reply({embeds: [embed]})
|
||||||
.setColor(0x15e6ed)
|
} catch(error) {
|
||||||
.setTitle('**Lecture de **' + songs.tracks[0].title)
|
|
||||||
.setDescription('**Demandé par **' + interaction.member.user.username)
|
interaction.reply({embeds: [embed]})
|
||||||
.addFields({name: "Auteur", value: songs.tracks[0].author},
|
}
|
||||||
{name: "URL", value:songs.tracks[0].uri})
|
|
||||||
.setThumbnail(songs.tracks[0].thumbnail)
|
|
||||||
.setTimestamp();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
const embed = await new EmbedBuilder()
|
||||||
|
.setColor(0x15e6ed)
|
||||||
|
.setTitle('**Ajout dans la liste de lecture **' + songs.tracks[0].title)
|
||||||
|
.setDescription('**Demandé par **' + interaction.member.user.username)
|
||||||
|
.addFields({name: "Auteur", value: songs.tracks[0].author},
|
||||||
|
{name: "URL", value:songs.tracks[0].uri})
|
||||||
|
.setThumbnail(songs.tracks[0].thumbnail)
|
||||||
|
.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]})
|
||||||
|
} catch(error) {
|
||||||
|
|
||||||
|
interaction.reply({embeds: [embed]})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
interaction.reply({embeds: [embed]})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
160
src/commands/queue.js
Normal file
160
src/commands/queue.js
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName("queue")
|
||||||
|
.setDescription("Affiche le ping du bot !")
|
||||||
|
.addStringOption(option => option.setName("action").setDescription("Que veux tu faire avec la queue ?").setRequired(true).addChoices(
|
||||||
|
{name: "Afficher", value: "show"},
|
||||||
|
{name: "Supprimer", value: "delete"}
|
||||||
|
)).addIntegerOption(option => option.setName("number").setDescription("Numéro de la place dans la liste de lecture")),
|
||||||
|
|
||||||
|
|
||||||
|
async execute(client, interaction) {
|
||||||
|
|
||||||
|
if(!interaction.member.voice.channel) return interaction.reply({content:"Vous devez rejoindre un salon vocal !", ephemeral: true})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const choice = interaction.options.getString("action")
|
||||||
|
|
||||||
|
if(choice == "show") {
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setColor(0xe033ff)
|
||||||
|
.setTitle('Liste de lecture')
|
||||||
|
.setDescription("Les musiques vont défiler dans cet ordre !")
|
||||||
|
.setTimestamp();
|
||||||
|
|
||||||
|
let player = client.manager.players.get(interaction.guild.id)
|
||||||
|
|
||||||
|
|
||||||
|
if(!player) {
|
||||||
|
|
||||||
|
const song_show = {name: "Aucune chanson n'est dans la queue", value: "Tu peux en ajouter avec /play"}
|
||||||
|
|
||||||
|
embed.addFields(song_show)
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
if(queue.length == 0){
|
||||||
|
|
||||||
|
const song_show = {name: "Aucune chanson n'est dans la queue", value: "Tu peux en ajouter avec /play"}
|
||||||
|
|
||||||
|
embed.addFields(song_show)
|
||||||
|
interaction.reply({embeds: [embed]})
|
||||||
|
} else {
|
||||||
|
|
||||||
|
|
||||||
|
for(song of queue) {
|
||||||
|
|
||||||
|
const song_show = {name: queue.indexOf(song) + " - " + song.title, value: song.author}
|
||||||
|
|
||||||
|
embed.addFields(song_show)
|
||||||
|
}
|
||||||
|
|
||||||
|
await interaction.reply({embeds: [embed]})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else if(choice == "delete") {
|
||||||
|
|
||||||
|
let embed = new EmbedBuilder()
|
||||||
|
.setColor(0xe033ff)
|
||||||
|
.setTitle('Liste de lecture')
|
||||||
|
.setDescription("Les musiques vont défiler dans cet ordre !")
|
||||||
|
.setTimestamp();
|
||||||
|
|
||||||
|
let player = client.manager.players.get(interaction.guild.id)
|
||||||
|
|
||||||
|
if(!player) {
|
||||||
|
|
||||||
|
embed = new EmbedBuilder()
|
||||||
|
.setColor(0xff0303)
|
||||||
|
.setTitle('Erreur : Liste de lecture')
|
||||||
|
.setTimestamp();
|
||||||
|
const song_show = {name: "Aucune chanson n'est dans la queue", value: "Supression impossible"}
|
||||||
|
|
||||||
|
embed.addFields(song_show)
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
if(queue.length == 0){
|
||||||
|
|
||||||
|
embed = new EmbedBuilder()
|
||||||
|
.setColor(0xff0303)
|
||||||
|
.setTitle('Erreur : Liste de lecture')
|
||||||
|
.setTimestamp();
|
||||||
|
const song_show = {name: "Aucune chanson n'est dans la queue", value: "Supression impossible"}
|
||||||
|
|
||||||
|
embed.addFields(song_show)
|
||||||
|
interaction.reply({embeds: [embed]})
|
||||||
|
} else {
|
||||||
|
|
||||||
|
const number = interaction.options.getInteger("number")
|
||||||
|
|
||||||
|
console.log(number)
|
||||||
|
|
||||||
|
if(number != null) {
|
||||||
|
try {
|
||||||
|
queue.splice(number, 1)
|
||||||
|
|
||||||
|
embed = new EmbedBuilder()
|
||||||
|
.setColor(0xe033ff)
|
||||||
|
.setTitle('Supressipn : Liste de lecture')
|
||||||
|
.setDescription("La musique a été retiré de la liste de lecture !")
|
||||||
|
.setTimestamp();
|
||||||
|
|
||||||
|
interaction.reply({embeds: [embed]})
|
||||||
|
|
||||||
|
} catch(error) {
|
||||||
|
|
||||||
|
embed = new EmbedBuilder()
|
||||||
|
.setColor(0xff0303)
|
||||||
|
.setTitle('Erreur : Liste de lecture')
|
||||||
|
.setTimestamp();
|
||||||
|
const song_show = {name: "Le numéro correspondant n'est pas disponible", value: "Supression impossible"}
|
||||||
|
|
||||||
|
embed.addFields(song_show)
|
||||||
|
interaction.reply({embeds: [embed]})
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
embed = new EmbedBuilder()
|
||||||
|
.setColor(0xff0303)
|
||||||
|
.setTitle('Erreur : Liste de lecture')
|
||||||
|
.setTimestamp();
|
||||||
|
const song_show = {name: "Un numéro est nécéssaire", value: "Supression impossible"}
|
||||||
|
|
||||||
|
embed.addFields(song_show)
|
||||||
|
interaction.reply({embeds: [embed]})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
await interaction.reply("**La commande a été mal éxécutée !**")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@ module.exports = {
|
|||||||
|
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName("resume")
|
.setName("resume")
|
||||||
.setDescription("Met en pause la musique joué !"),
|
.setDescription("Remet la musique qui était en pause !"),
|
||||||
|
|
||||||
async execute(client, interaction) {
|
async execute(client, interaction) {
|
||||||
|
|
||||||
@ -19,21 +19,22 @@ module.exports = {
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(0x03ff2d)
|
.setColor(0x03ff2d)
|
||||||
.setTitle('C\'est reparti !')
|
.setTitle('C\'est reparti !')
|
||||||
.setDescription("**Ok, Fin de l'entracte, c'est reparti et c'est demandé par " + interaction.member.user.username + "**")
|
.setDescription("**Ok, Fin de l'entracte, c'est reparti et c'est demandée par " + interaction.member.user.username + "**")
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
|
|
||||||
|
|
||||||
interaction.reply({embeds: [embed]})
|
interaction.reply({embeds: [embed]})
|
||||||
|
|
||||||
player.pause(false)
|
player.pause(false)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
interaction.reply("**Aucune musique n'est actuellement joué !**")
|
interaction.reply("**Aucune musique n'est actuellement jouée !**")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
interaction.reply("**Aucune musique n'est actuellement joué !**")
|
interaction.reply("**Aucune musique n'est actuellement jouée !**")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
21
src/main.js
21
src/main.js
@ -1,4 +1,6 @@
|
|||||||
const { Client, GatewayIntentBits, Collection } = require("discord.js")
|
function startApp() {
|
||||||
|
|
||||||
|
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")
|
||||||
@ -10,6 +12,7 @@ const client = new Client({
|
|||||||
})
|
})
|
||||||
|
|
||||||
client.commands = new Collection()
|
client.commands = new Collection()
|
||||||
|
client.queue = []
|
||||||
|
|
||||||
const commands = [];
|
const commands = [];
|
||||||
// Grab all the command files from the commands directory you created earlier
|
// Grab all the command files from the commands directory you created earlier
|
||||||
@ -90,8 +93,8 @@ client.on("interactionCreate", (interaction) => {
|
|||||||
|
|
||||||
const nodes = [
|
const nodes = [
|
||||||
{
|
{
|
||||||
host: "lavalink.lexnet.cc",
|
host: "lavalink.devamop.in",
|
||||||
password: "lexn3tl@val!nk",
|
password: "DevamOP",
|
||||||
port: 443,
|
port: 443,
|
||||||
secure: true
|
secure: true
|
||||||
}
|
}
|
||||||
@ -126,3 +129,15 @@ client.on("raw", d => client.manager.updateVoiceState(d));
|
|||||||
// Client Manager
|
// Client Manager
|
||||||
|
|
||||||
client.login(config.token)
|
client.login(config.token)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleFatalError(error) {
|
||||||
|
console.error('Erreur fatale :', error);
|
||||||
|
console.log('Redémarrage en cours...');
|
||||||
|
startApp();
|
||||||
|
}
|
||||||
|
|
||||||
|
process.on('uncaughtException', handleFatalError);
|
||||||
|
|
||||||
|
startApp();
|
||||||
|
Loading…
Reference in New Issue
Block a user