Ajout du Bot
0
.gitignore
vendored
Normal file
271
Includes/play.js
Normal file
|
@ -0,0 +1,271 @@
|
||||||
|
const ytdl = require("ytdl-core-discord");
|
||||||
|
const { canModifyQueue, STAY_TIME } = require("../util/LanBot");
|
||||||
|
const { MessageEmbed, MessageAttachment } = require("discord.js");
|
||||||
|
const musicGif = new MessageAttachment('./assets/img/Music.gif');
|
||||||
|
const dancingGif = new MessageAttachment('./assets/img/dancing.gif');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
async play(song, message) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
let config;
|
||||||
|
|
||||||
|
try {
|
||||||
|
config = require("../config");
|
||||||
|
} catch (error) {
|
||||||
|
config = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const PRUNING = config ? config.PRUNING : process.env.PRUNING;
|
||||||
|
|
||||||
|
const queue = message.client.queue.get(message.guild.id);
|
||||||
|
|
||||||
|
if (!song) {
|
||||||
|
setTimeout(function () {
|
||||||
|
if (queue.connection.dispatcher && message.guild.me.voice.channel) return;
|
||||||
|
queue.channel.leave();
|
||||||
|
queue.textChannel.send("Fin de la liste de lecture ! Je vous abandonne !");
|
||||||
|
}, STAY_TIME * 1000);
|
||||||
|
queue.textChannel.send("❌ La file d'attente est terminée.").catch(console.error);
|
||||||
|
return message.client.queue.delete(message.guild.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
let stream = null;
|
||||||
|
let streamType = song.url.includes("youtube.com") ? "opus" : "ogg/opus";
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (song.url.includes("youtube.com")) {stream = await ytdl(song.url, {
|
||||||
|
filter: format => ['251'],
|
||||||
|
highWaterMark: 1 << 25
|
||||||
|
}), {
|
||||||
|
type: 'opus'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
if (queue) {
|
||||||
|
queue.songs.shift();
|
||||||
|
module.exports.play(queue.songs[0], message);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.error(error);
|
||||||
|
return message.channel.send(
|
||||||
|
"Erreur: {error}", { error: error.message ? error.message : error }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
queue.connection.on("disconnect", () => message.client.queue.delete(message.guild.id));
|
||||||
|
|
||||||
|
const dispatcher = queue.connection
|
||||||
|
.play(stream, { type: streamType })
|
||||||
|
.on("finish", () => {
|
||||||
|
if (collector && !collector.ended) collector.stop();
|
||||||
|
|
||||||
|
if (queue.loop) {
|
||||||
|
// if loop is on, push the song back at the end of the queue
|
||||||
|
// so it can repeat endlessly
|
||||||
|
let lastSong = queue.songs.shift();
|
||||||
|
queue.songs.push(lastSong);
|
||||||
|
module.exports.play(queue.songs[0], message);
|
||||||
|
} else {
|
||||||
|
// Recursively play the next song
|
||||||
|
queue.songs.shift();
|
||||||
|
module.exports.play(queue.songs[0], message);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on("error", (err) => {
|
||||||
|
console.error(err);
|
||||||
|
queue.songs.shift();
|
||||||
|
module.exports.play(queue.songs[0], message);
|
||||||
|
});
|
||||||
|
dispatcher.setVolumeLogarithmic(queue.volume / 100);
|
||||||
|
|
||||||
|
var date = new Date(0);
|
||||||
|
date.setSeconds(song.duration); // specify value for SECONDS here
|
||||||
|
var timeString = date.toISOString().substr(11, 8);
|
||||||
|
|
||||||
|
try {
|
||||||
|
//let DJYT = require ("discordjs-ytdl");
|
||||||
|
let noiceEmbed = new MessageEmbed()
|
||||||
|
.setTitle('Début de la lecture')
|
||||||
|
.attachFiles(dancingGif)
|
||||||
|
.setThumbnail('attachment://dancing.gif')
|
||||||
|
.addField('Nom', song.title, true)
|
||||||
|
.addField('Demandé par', message.author, true)
|
||||||
|
.addField('Nombre de vues', song.views, true)
|
||||||
|
.addField('Durée', timeString, true)
|
||||||
|
.setImage(song.thumbnail)
|
||||||
|
//.setImage("https://media.discordapp.net/attachments/789196713540976670/812047848047771658/lanziumbanniere.gif");
|
||||||
|
var playingMessage = await queue.textChannel.send(noiceEmbed);
|
||||||
|
|
||||||
|
//console.log(DJYT.thumbnail);
|
||||||
|
//`🎶 A commencé à jouer: **${song.title}** ${song.url}`
|
||||||
|
|
||||||
|
await playingMessage.react("⏭");
|
||||||
|
await playingMessage.react("⏯");
|
||||||
|
await playingMessage.react("🔇");
|
||||||
|
await playingMessage.react("🔉");
|
||||||
|
await playingMessage.react("🔊");
|
||||||
|
await playingMessage.react("🔁");
|
||||||
|
await playingMessage.react("🔀");
|
||||||
|
await playingMessage.react("⏹");
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
const filter = (reaction, user) => user.id !== message.client.user.id;
|
||||||
|
var collector = playingMessage.createReactionCollector(filter, {
|
||||||
|
time: song.duration > 0 ? song.duration * 1000 : 600000
|
||||||
|
});
|
||||||
|
|
||||||
|
collector.on("collect", (reaction, user) => {
|
||||||
|
if (!queue) return;
|
||||||
|
const member = message.guild.member(user);
|
||||||
|
|
||||||
|
switch (reaction.emoji.name) {
|
||||||
|
case "⏭":
|
||||||
|
queue.playing = true;
|
||||||
|
reaction.users.remove(user).catch(console.error);
|
||||||
|
if (!canModifyQueue(member)) return message.channel.send("Vous devez d'abord rejoindre un salon vocal !");
|
||||||
|
queue.connection.dispatcher.end();
|
||||||
|
queue.textChannel.send(`${user} ⏩ a skip la musique.`).catch(console.error).then(msg => {
|
||||||
|
msg.delete({ timeout: 5000 /*time unitl delete in milliseconds*/});
|
||||||
|
});
|
||||||
|
collector.stop();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "⏯":
|
||||||
|
reaction.users.remove(user).catch(console.error);
|
||||||
|
if (!canModifyQueue(member)) return message.channel.send("Vous devez d'abord rejoindre un salon vocal !");
|
||||||
|
if (queue.playing) {
|
||||||
|
queue.playing = !queue.playing;
|
||||||
|
queue.connection.dispatcher.pause(true);
|
||||||
|
queue.textChannel.send(`${user} ⏸ a mis en pause la musique.`).catch(console.error).then(msg => {
|
||||||
|
msg.delete({ timeout: 5000 /*time unitl delete in milliseconds*/});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
queue.playing = !queue.playing;
|
||||||
|
queue.connection.dispatcher.resume();
|
||||||
|
queue.textChannel.send(`${user} ▶ a relancé la musique!`).catch(console.error).then(msg => {
|
||||||
|
msg.delete({ timeout: 5000 /*time unitl delete in milliseconds*/});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "🔇":
|
||||||
|
reaction.users.remove(user).catch(console.error);
|
||||||
|
if (!canModifyQueue(member)) return message.channel.send("Vous devez d'abord rejoindre un salon vocal !");
|
||||||
|
if (queue.volume <= 0) {
|
||||||
|
queue.volume = 100;
|
||||||
|
queue.connection.dispatcher.setVolumeLogarithmic(100 / 100);
|
||||||
|
queue.textChannel.send(`${user} 🔊 a unmute la musique!`).catch(console.error).then(msg => {
|
||||||
|
msg.delete({ timeout: 5000 /*time unitl delete in milliseconds*/});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
queue.volume = 0;
|
||||||
|
queue.connection.dispatcher.setVolumeLogarithmic(0);
|
||||||
|
queue.textChannel.send(`${user} 🔇 a mute la musique!`).catch(console.error).then(msg => {
|
||||||
|
msg.delete({ timeout: 5000 /*time unitl delete in milliseconds*/});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "🔉":
|
||||||
|
reaction.users.remove(user).catch(console.error);
|
||||||
|
if (queue.volume == 0) return;
|
||||||
|
if (!canModifyQueue(member)) return message.channel.send("Vous devez d'abord rejoindre un salon vocal !");
|
||||||
|
if (queue.volume - 10 <= 0) queue.volume = 0;
|
||||||
|
else queue.volume = queue.volume - 10;
|
||||||
|
queue.connection.dispatcher.setVolumeLogarithmic(queue.volume / 100);
|
||||||
|
queue.textChannel
|
||||||
|
.send(`${user} 🔉 a diminué le volume, le volume est maintenant à ${queue.volume}%`)
|
||||||
|
.catch(console.error)
|
||||||
|
.then(msg => {
|
||||||
|
msg.delete({ timeout: 5000 /*time unitl delete in milliseconds*/});
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "🔊":
|
||||||
|
reaction.users.remove(user).catch(console.error);
|
||||||
|
if (queue.volume == 100) return;
|
||||||
|
if (!canModifyQueue(member)) return message.channel.send("Vous devez d'abord rejoindre un salon vocal !");
|
||||||
|
if (queue.volume + 10 >= 100) queue.volume = 100;
|
||||||
|
else queue.volume = queue.volume + 10;
|
||||||
|
queue.connection.dispatcher.setVolumeLogarithmic(queue.volume / 100);
|
||||||
|
queue.textChannel
|
||||||
|
.send(`${user} 🔉 a augmenté le volume, le volume est maintenant à ${queue.volume}%`)
|
||||||
|
.catch(console.error)
|
||||||
|
.then(msg => {
|
||||||
|
msg.delete({ timeout: 5000 /*time unitl delete in milliseconds*/});
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "🔁":
|
||||||
|
reaction.users.remove(user).catch(console.error);
|
||||||
|
if (!canModifyQueue(member)) return message.channel.send("Vous devez d'abord rejoindre un salon vocal !");
|
||||||
|
queue.loop = !queue.loop;
|
||||||
|
queue.textChannel
|
||||||
|
.send(
|
||||||
|
(`Le loop est maintenant ${queue.loop ? `**Actif**` : `**Inactif**`}`)
|
||||||
|
)
|
||||||
|
.catch(console.error)
|
||||||
|
.then(msg => {
|
||||||
|
msg.delete({ timeout: 5000 /*time unitl delete in milliseconds*/});
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "🔀":
|
||||||
|
reaction.users.remove(user).catch(console.error);
|
||||||
|
if (!canModifyQueue(member)) return message.channel.send("Vous devez d'abord rejoindre un salon vocal !");
|
||||||
|
let songs = queue.songs;
|
||||||
|
for (let i = songs.length - 1; i > 1; i--) {
|
||||||
|
let j = 1 + Math.floor(Math.random() * i);
|
||||||
|
[songs[i], songs[j]] = [songs[j], songs[i]];
|
||||||
|
}
|
||||||
|
|
||||||
|
queue.songs = songs;
|
||||||
|
queue.textChannel
|
||||||
|
.send(
|
||||||
|
(`Lecture aléatoire de la liste de lecture 🔀`)
|
||||||
|
)
|
||||||
|
.catch(console.error)
|
||||||
|
.then(msg => {
|
||||||
|
msg.delete({ timeout: 5000 /*time unitl delete in milliseconds*/});
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "⏹":
|
||||||
|
reaction.users.remove(user).catch(console.error);
|
||||||
|
if (!canModifyQueue(member)) return message.channel.send("Vous devez d'abord rejoindre un salon vocal !");
|
||||||
|
queue.songs = [];
|
||||||
|
queue.textChannel.send(`${user} ⏹ a arrêté la musique!`)
|
||||||
|
.catch(console.error)
|
||||||
|
.then(msg => {
|
||||||
|
msg.delete({ timeout: 5000 /*time unitl delete in milliseconds*/});
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
queue.connection.dispatcher.end();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
queue.connection.disconnect();
|
||||||
|
}
|
||||||
|
collector.stop();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
reaction.users.remove(user).catch(console.error);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
collector.on("end", () => {
|
||||||
|
playingMessage.reactions.removeAll().catch(console.error);
|
||||||
|
if (PRUNING && playingMessage && !playingMessage.deleted) {
|
||||||
|
playingMessage.delete({ timeout: 3000 }).catch(console.error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
BIN
assets/img/8ball.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
assets/img/Music.gif
Normal file
After Width: | Height: | Size: 88 KiB |
BIN
assets/img/canardcouteau.PNG
Normal file
After Width: | Height: | Size: 52 KiB |
BIN
assets/img/cat.gif
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
assets/img/choose.gif
Normal file
After Width: | Height: | Size: 882 KiB |
BIN
assets/img/dancing.gif
Normal file
After Width: | Height: | Size: 891 KiB |
BIN
assets/img/divider.png
Normal file
After Width: | Height: | Size: 439 B |
36
commands/Admin/chargement.js
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
const { MessageEmbed, MessageAttachment } = require("discord.js");
|
||||||
|
|
||||||
|
module.exports.run = async (client, message, args) => {
|
||||||
|
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setAuthor(`${client.user.username} Info`, client.user.avatarURL())
|
||||||
|
.setColor("cb4e41")
|
||||||
|
.addFields(
|
||||||
|
{ name:'Configurer le prefix', value:'Faire la commande \`?config prefix (le nouveau préfix)\`', inline: true},
|
||||||
|
{ name:'\u200b', value:'\u200b', inline: true},
|
||||||
|
{ name:'\u200b', value:'\u200b', inline: true},
|
||||||
|
)
|
||||||
|
.setTimestamp()
|
||||||
|
.setImage("https://media.discordapp.net/attachments/789196713540976670/812047848047771658/lanziumbanniere.gif");
|
||||||
|
|
||||||
|
|
||||||
|
const embed2 = new MessageEmbed()
|
||||||
|
.setColor("dc143c")
|
||||||
|
.setTitle("LanBot ")
|
||||||
|
.setDescription("LanBot a été invité !")
|
||||||
|
.setThumbnail(client.user.displayAvatarURL())
|
||||||
|
.addFields(
|
||||||
|
{ name: "Serveur ", value: `Le bot a été invité sur le serveur ${message.member.guild.name}`, inline: true},
|
||||||
|
{ name: 'Créateur du serveur', value: `L'Owner du serveur est ${message.member.guild.owner}`, inline: true},
|
||||||
|
{ name: "Invitation", value: await message.channel.createInvite({maxAge: 0, reason: "Permet au développeur de venir si besoin"}), inline: true},
|
||||||
|
)
|
||||||
|
.setImage(client.user.displayAvatarURL())
|
||||||
|
.setTimestamp()
|
||||||
|
|
||||||
|
//client.channels.cache.get('818435612678946826').send(embed2);
|
||||||
|
message.channel.send(embed)
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.ADMIN.CHARGEMENT;
|
20
commands/Admin/config.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
|
||||||
|
module.exports.run = async (client, message, args, settings) => {
|
||||||
|
const getSetting = args[0];
|
||||||
|
const newSetting = args.slice(1).join(" ");
|
||||||
|
//const newLogSetting = args.slice(2, -1);
|
||||||
|
|
||||||
|
switch(getSetting) {
|
||||||
|
case "prefix": {
|
||||||
|
if (newSetting) {
|
||||||
|
await client.updateGuild(message.guild, { prefix: newSetting });
|
||||||
|
return message.channel.send(`Prefix mis à jour: \`${settings.prefix}\`-> \`${newSetting}\``);
|
||||||
|
}
|
||||||
|
message.channel.send(`Prefix actuel: \`${settings.prefix}\``);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.ADMIN.CONFIG;
|
17
commands/Developpeur/eval.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
|
||||||
|
module.exports.run = async (client, message, args) => {
|
||||||
|
function clean(text) {
|
||||||
|
if (typeof text === "string")
|
||||||
|
return text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203));
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.author.id !== "327193195085824001") return message.channel.send("Cette commande est réservé au développeur de LanBot");
|
||||||
|
const code = args.join(" ");
|
||||||
|
const evaled = eval(code);
|
||||||
|
const cleanCode = await clean(evaled);
|
||||||
|
message.channel.send(cleanCode, { code: "js" });
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.DEVELOPPEUR.EVAL;
|
10
commands/Developpeur/reload.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
|
||||||
|
module.exports.run = async (client, message, args) => {
|
||||||
|
if (message.author.id !== "327193195085824001") return message.channel.send("Cette commande est réservé au développeur de LanBot");
|
||||||
|
client.channels.cache.get('844290195787743262').send("Je redémarre !");
|
||||||
|
await message.delete();
|
||||||
|
|
||||||
|
process.exit();
|
||||||
|
};
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.DEVELOPPEUR.RELOAD;
|
22
commands/Informations/botinfo.js
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
const { MessageEmbed } = require ("discord.js");
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args) => {
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setColor("#0c2461")
|
||||||
|
.setAuthor(`${client.user.username} Info`, client.user.avatarURL())
|
||||||
|
.addFields(
|
||||||
|
{ name: 'Mémoire', value: `${(process.memoryUsage().heapUsed / 1024 /1024).toFixed(2)}MB`, inline: true},
|
||||||
|
{ name: 'Uptime', value: `${Math.floor(client.uptime / 1000 / 60).toString()} minutes`, inline: true},
|
||||||
|
{ name: '\u200b', value: `\u200b`, inline: true},
|
||||||
|
{ name: 'Serveurs', value: `${client.guilds.cache.size.toString()}`, inline: true},
|
||||||
|
{ name: 'Salons', value: `${client.channels.cache.size.toString()}`, inline: true},
|
||||||
|
{ name: 'Utilisateurs', value: `${client.guilds.cache.map(g => g.memberCount).reduce((a,b) => a + b)}`, inline: true},
|
||||||
|
{ name: 'Version', value: `Version 2.2.1`, inline: true},
|
||||||
|
{ name: 'Source', value: `[SiteWeb](https://lan7ium.fr)`, inline: true},
|
||||||
|
{ name: 'Support', value: `[Serveur Invite](https://discord.gg/K6tGTtNVTE)`, inline: true},
|
||||||
|
);
|
||||||
|
message.channel.send(embed);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.INFORMATIONS.BOTINFO;
|
49
commands/Informations/embed.txt
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
const { MessageEmbed } = require("discord.js");
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args) => {
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setColor("dc143c")
|
||||||
|
.setTitle("Titre de l'embed")
|
||||||
|
.setURL("https://google.com")
|
||||||
|
.setDescription("Description de l'embed")
|
||||||
|
.setThumbnail(client.user.displayAvatarURL())
|
||||||
|
.addField("Je suis un champ", "et je suis sa valeur")
|
||||||
|
.addFields(
|
||||||
|
{ name: 'Je suis le champ 1', value: 'et je suis sa valeur', inline: true},
|
||||||
|
{ name: 'Je suis le champ 2', value: 'et en plus on est aligné', inline: true},
|
||||||
|
)
|
||||||
|
.setImage(client.user.displayAvatarURL())
|
||||||
|
.setTimestamp()
|
||||||
|
.setFooter("Je suis sur le pied du footer");
|
||||||
|
|
||||||
|
message.channel.send(embed);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.INFORMATIONS.EMBED;
|
||||||
|
|
||||||
|
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setColor("#0c2461")
|
||||||
|
.setDescription(`Plus d'informations à propos du serveur: **${guild.name}**`)
|
||||||
|
.setThumbnail(guild.iconURL())
|
||||||
|
.addField(
|
||||||
|
`• ID: ${guild.id}
|
||||||
|
• Owner: ${guild.owner.user.tag} (${guild.ownerID})
|
||||||
|
• Roles: ${guild.roles.cache.size}
|
||||||
|
• Créé le: ${moment(guild.createdAt).format('DD/MM/YYYY')}
|
||||||
|
`)
|
||||||
|
.setTimestamp();
|
||||||
|
|
||||||
|
|
||||||
|
const embed2 = new MessageEmbed()
|
||||||
|
.setColor("#0c2461")
|
||||||
|
.setDescription("Statistique du serveur : ")
|
||||||
|
.addFields(
|
||||||
|
{ name: `Nombre de membres total : `, value: `${guild.memberCount -1 }`},
|
||||||
|
{ name: `Nombre de salons textuels : `, value: `${guild.channels.cache.filter(ch => ch.type === "text").size}`},
|
||||||
|
{ name: `Nombre de salons vocaux : `, value: `${guild.channels.cache.filter(ch => ch.type === "voice").size}`},
|
||||||
|
)
|
||||||
|
|
||||||
|
message.channel.send(embed);
|
||||||
|
message.channel.send(embed2);
|
39
commands/Informations/serverinfo.js
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
const { MessageEmbed } = require ("discord.js");
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
const moment = require("moment");
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args) => {
|
||||||
|
const guild = message.guild;
|
||||||
|
|
||||||
|
message.guild.members.fetch().then(fetchAll => {
|
||||||
|
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setColor("#0c2461")
|
||||||
|
.setThumbnail(guild.iconURL())
|
||||||
|
.addField(`Plus d'informations à propos du serveur : **${guild.name}**`,
|
||||||
|
`• ID: ${guild.id}
|
||||||
|
• Owner: ${guild.owner.user.tag} (${guild.ownerID})
|
||||||
|
• Roles: ${guild.roles.cache.size}
|
||||||
|
• Créé le: ${moment(guild.createdAt).format('DD/MM/YYYY')}
|
||||||
|
`
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
const embed2 = new MessageEmbed()
|
||||||
|
.setColor("#0c2461")
|
||||||
|
.setDescription("Statistique du serveur : ")
|
||||||
|
.addFields(
|
||||||
|
{ name: `Nombre de membres total : `, value: `${guild.memberCount -1 }`},
|
||||||
|
{ name: `Nombre de salons textuels : `, value: `${guild.channels.cache.filter(ch => ch.type === "text").size}`},
|
||||||
|
{ name: `Nombre de salons vocaux : `, value: `${guild.channels.cache.filter(ch => ch.type === "voice").size}`},
|
||||||
|
{ name: 'Membres Totaux', value: `${fetchAll.size}`, inline: true},
|
||||||
|
)
|
||||||
|
.setTimestamp();
|
||||||
|
|
||||||
|
message.channel.send(embed);
|
||||||
|
message.channel.send(embed2);
|
||||||
|
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.INFORMATIONS.SERVERINFO;
|
30
commands/Informations/stats.js
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
const { MessageEmbed } = require ("discord.js");
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args) => {
|
||||||
|
const nameGuild = message.guild.name;
|
||||||
|
message.guild.members.fetch().then(fetchAll => {
|
||||||
|
const offline = fetchAll.filter(m => m.presence.status === 'offline');
|
||||||
|
const dnd = fetchAll.filter(m => m.presence.status === 'dnd');
|
||||||
|
const online = fetchAll.filter(m => m.presence.status === 'online');
|
||||||
|
const bot = message.guild.members.cache.filter(member => member.user.bot).size;
|
||||||
|
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setTitle("Informations sur les membres du serveur !")
|
||||||
|
.setColor("#0c2461")
|
||||||
|
.addFields(
|
||||||
|
{ name: 'Nom du serveur', value: `${nameGuild}`, inline: true},
|
||||||
|
{ name: 'Membres Totaux', value: `${fetchAll.size}`, inline: true},
|
||||||
|
{ name: 'Nombre de Bots', value: `${bot}`, inline: true},
|
||||||
|
{ name: 'Membres Connectés', value: `${online.size}`, inline: true},
|
||||||
|
{ name: 'Membres Hors-ligne', value: `${offline.size}`, inline: true},
|
||||||
|
{ name: 'Membres Occupés', value: `${dnd.size}`, inline: true},
|
||||||
|
)
|
||||||
|
.setTimestamp();
|
||||||
|
|
||||||
|
message.channel.send(embed);
|
||||||
|
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.INFORMATIONS.STATS;
|
31
commands/Informations/userinfo.js
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
const { MessageEmbed } = require ("discord.js");
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
const moment = require("moment");
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args) => {
|
||||||
|
let member = message.member;
|
||||||
|
if (args[0]) member = message.guild.member(message.mentions.users.first());
|
||||||
|
let user = member.user;
|
||||||
|
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setColor("#0c2461")
|
||||||
|
.setThumbnail(user.displayAvatarURL())
|
||||||
|
.addField(`Plus d'informations à propos de **${user.username}**`,
|
||||||
|
`• Nom: ${user.tag}
|
||||||
|
• Bot: ${user.bot ? 'true' : 'false'}
|
||||||
|
• Crée le: ${moment(user.createdAt).format('DD/MM/YYYY | hh:mm')}
|
||||||
|
• Statut: ${user.presence.status.toUpperCase()}`
|
||||||
|
);
|
||||||
|
|
||||||
|
const embed2 = new MessageEmbed()
|
||||||
|
.setColor("#0c2461")
|
||||||
|
.addField(`L'utilisateur **${user.username}** ${member.username === undefined ? '' : `aka **${member.username}**`}`,
|
||||||
|
`• A rejoint le serveur le: ${moment(member.joinedAt).format('DD/MM/YYYY | hh:mm')}
|
||||||
|
• Ce membre possède les rôles suivants : ${member.roles.cache.map(roles => `\`${roles.name}\``).join(', ')}`
|
||||||
|
);
|
||||||
|
|
||||||
|
message.channel.send(embed);
|
||||||
|
message.channel.send(embed2);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.INFORMATIONS.USERINFO;
|
18
commands/Musique/join.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
|
||||||
|
module.exports.run = async (client, message, args, settings) => {
|
||||||
|
const { channel } = message.member.voice;
|
||||||
|
|
||||||
|
const queueConstruct = {
|
||||||
|
textChannel: message.channel,
|
||||||
|
channel,
|
||||||
|
connection: null,
|
||||||
|
songs: [],
|
||||||
|
loop: false,
|
||||||
|
playing: true
|
||||||
|
};
|
||||||
|
|
||||||
|
queueConstruct.connection = await channel.join();
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.JOIN;
|
8
commands/Musique/leave.js
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args, settings) => {
|
||||||
|
const queue = message.client.queue.get(message.guild.id);
|
||||||
|
queue.connection.disconnect()
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.LEAVE;
|
26
commands/Musique/loop.js
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
const { canModifyQueue } = require("../../util/LanBot");
|
||||||
|
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args, settings) => {
|
||||||
|
|
||||||
|
if (!canModifyQueue(message.member)) return message.channel.send('Vous devez être dans un salon vocal pour utiliser cette commande !');
|
||||||
|
const queue = message.client.queue.get(message.guild.id)
|
||||||
|
if(!queue){ return message.channel.send({
|
||||||
|
embed: {
|
||||||
|
description: `Liste d'attente vide ! merci d'utiliser la commande \`${settings.prefix}play + URL / Nom de la musique\` !`,
|
||||||
|
color: 'BLACK'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// toggle from false to true and reverse
|
||||||
|
queue.loop = !queue.loop;
|
||||||
|
//queue.connection.dispatcher.loop()
|
||||||
|
return message.channel.send(`Le loop est maintenant ${queue.loop ? `**Actif**` : `**Inactif**`}`)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.LOOP;
|
30
commands/Musique/lyrics.js
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
const { MessageEmbed } = require("discord.js");
|
||||||
|
const lyricsFinder = require("lyrics-finder");
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
|
||||||
|
module.exports.run = async (client, message, args, settings) => {
|
||||||
|
const queue = message.client.queue.get(message.guild.id);
|
||||||
|
if (!queue) return message.channel.send("Aucune musique lancé !").catch(console.error);
|
||||||
|
|
||||||
|
let lyrics = null;
|
||||||
|
const title = queue.songs[0].title;
|
||||||
|
|
||||||
|
try {
|
||||||
|
lyrics = await lyricsFinder(queue.songs[0].title, "");
|
||||||
|
if (!lyrics) lyrics = `Pas de paroles trouvé pour ${queue.songs[0].title} ! `;
|
||||||
|
} catch (error) {
|
||||||
|
lyrics = `Pas de paroles trouvé pour ${queue.songs[0].title} ! `;
|
||||||
|
}
|
||||||
|
|
||||||
|
let lyricsEmbed = new MessageEmbed()
|
||||||
|
.setTitle(`Paroles pour ${queue.songs[0].title}`)
|
||||||
|
.setDescription(lyrics)
|
||||||
|
.setColor("GREEN")
|
||||||
|
.setTimestamp();
|
||||||
|
|
||||||
|
if (lyricsEmbed.description.length >= 2048)
|
||||||
|
lyricsEmbed.description = `${lyricsEmbed.description.substr(0, 2045)}...`;
|
||||||
|
return message.channel.send(lyricsEmbed).catch(console.error);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.LYRICS;
|
22
commands/Musique/move.js
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
const move = require("array-move");
|
||||||
|
const { canModifyQueue } = require("../../util/LanBot");
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args, settings) => {
|
||||||
|
const queue = message.client.queue.get(message.guild.id);
|
||||||
|
if (!queue) return message.channel.send("Il n'y a pas de musique dans la file d'attente.").catch(console.error);
|
||||||
|
if (!canModifyQueue(message.member)) return;
|
||||||
|
|
||||||
|
let song = queue.songs[args[0] - 1];
|
||||||
|
|
||||||
|
queue.songs = move(queue.songs, args[0] - 1, args[1] == 1 ? 1 : args[1] - 1);
|
||||||
|
queue.textChannel.send(
|
||||||
|
("Déplacement effectué !", {
|
||||||
|
author: message.author,
|
||||||
|
title: song.title,
|
||||||
|
index: args[1] == 1 ? 1 : args[1]
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.MOVE;
|
52
commands/Musique/nowplaying.js
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
const { MessageEmbed, MessageAttachment } = require("discord.js");
|
||||||
|
const musicGif = new MessageAttachment('./assets/img/Music.gif');
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
const createBar = require("string-progressbar");
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args, settings) => {
|
||||||
|
const channel = message.member.voice.channel;
|
||||||
|
if (!channel) return message.channel.send('Tu dois te trouver dans un salon vocal pour utiliser cette commande');
|
||||||
|
let queue = message.client.queue.get(message.guild.id)
|
||||||
|
if(!queue) return message.channel.send({
|
||||||
|
embed:{
|
||||||
|
title: `Aucune musique n'est lancé actuellement donc merci d'utiliser la commande \`${settings.prefix}play + URL\`! `
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const song = queue.songs[0];
|
||||||
|
const seek = (queue.connection.dispatcher.streamTime - queue.connection.dispatcher.pausedTime) / 1000;
|
||||||
|
const left = song.duration - seek;
|
||||||
|
|
||||||
|
let nowPlaying = new MessageEmbed()
|
||||||
|
.setTitle("En lecture")
|
||||||
|
.setDescription(`${song.title}\n${song.url}`)
|
||||||
|
.setColor("#F8AA2A")
|
||||||
|
.setAuthor(message.client.user.username)
|
||||||
|
//.attachFiles(musicGif)
|
||||||
|
//.setThumbnail('attachment://Music.gif')
|
||||||
|
.setThumbnail('https://tenor.com/8P2l.gif');
|
||||||
|
|
||||||
|
|
||||||
|
var time = new Date(left * 1000).toISOString().substr(11, 8);
|
||||||
|
|
||||||
|
if (song.duration > 0) {
|
||||||
|
nowPlaying.addField(
|
||||||
|
"\u200b",
|
||||||
|
new Date(seek * 1000).toISOString().substr(11, 8) +
|
||||||
|
"[" +
|
||||||
|
createBar(song.duration == 0 ? seek : song.duration, seek, 20)[0] +
|
||||||
|
"]" +
|
||||||
|
(song.duration == 0 ? " ◉ LIVE" : new Date(song.duration * 1000).toISOString().substr(11, 8)),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
nowPlaying.setFooter(
|
||||||
|
(`Temps restant : ${time}`)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return message.channel.send(nowPlaying);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.NOWPLAYING;
|
||||||
|
|
19
commands/Musique/pause.js
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
const { canModifyQueue } = require("../../util/LanBot");
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args, settings) => {
|
||||||
|
|
||||||
|
if (!canModifyQueue(message.member))return message.channel.send('Vous devez être dans un salon vocal pour utiliser cette commande !');
|
||||||
|
let queue = message.client.queue.get(message.guild.id)
|
||||||
|
if(!queue) return message.channel.send({
|
||||||
|
embed: {
|
||||||
|
description: "Impossible de mettre en pause, car aucune musique n'est lancé !"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if(queue.playing !== false)
|
||||||
|
queue.connection.dispatcher.pause()
|
||||||
|
message.react('⏸')
|
||||||
|
message.channel.send('Musique mis en pause !')
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.PAUSE;
|
116
commands/Musique/play.js
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
const { play } = require("../../Includes/play");
|
||||||
|
const ytdl = require("ytdl-core");
|
||||||
|
const YouTubeAPI = require("simple-youtube-api");
|
||||||
|
const { YOUTUBE_API_KEY, DEFAULT_VOLUME } = require("../../util/LanBot");
|
||||||
|
const youtube = new YouTubeAPI(YOUTUBE_API_KEY);
|
||||||
|
const { MessageEmbed } = require("discord.js");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
|
||||||
|
module.exports.run = async (client, message, args, settings) => {
|
||||||
|
const { channel } = message.member.voice;
|
||||||
|
|
||||||
|
const serverQueue = message.client.queue.get(message.guild.id);
|
||||||
|
if (!channel) return message.reply("Vous devez d'abord rejoindre un canal vocal!").catch(console.error);
|
||||||
|
if (serverQueue && channel !== message.guild.me.voice.channel)
|
||||||
|
return message
|
||||||
|
.reply("Vous devez être dans le même canal que {user}", { user: message.client.user })
|
||||||
|
.catch(console.error);
|
||||||
|
|
||||||
|
if (!channel.permissionsFor(message.client.user).has("CONNECT")) return message.channel.send("Je n'ai pas la permission de rejoindre un salon vocal !")
|
||||||
|
if (!channel.permissionsFor(message.client.user).has("SPEAK"))return message.channel.send("Je n'ai pas la permission Parler dans le salon vocal !")
|
||||||
|
|
||||||
|
const search = args.join(" ");
|
||||||
|
const videoPattern = /^(https?:\/\/)?(www\.)?(m\.)?(youtube\.com|youtu\.?be)\/.+$/gi;
|
||||||
|
const playlistPattern = /^.*(list=)([^#\&\?]*).*/gi;
|
||||||
|
const url = args[0];
|
||||||
|
const urlValid = videoPattern.test(args[0]);
|
||||||
|
|
||||||
|
// Start the playlist if playlist url was provided
|
||||||
|
if (!videoPattern.test(args[0]) && playlistPattern.test(args[0])) {
|
||||||
|
return message.client.commands.get("playlist").execute(message, args);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const queueConstruct = {
|
||||||
|
textChannel: message.channel,
|
||||||
|
channel,
|
||||||
|
connection: null,
|
||||||
|
songs: [],
|
||||||
|
loop: false,
|
||||||
|
volume: DEFAULT_VOLUME || 100,
|
||||||
|
playing: true
|
||||||
|
};
|
||||||
|
|
||||||
|
let songInfo = null;
|
||||||
|
let song = null;
|
||||||
|
|
||||||
|
if (urlValid) {
|
||||||
|
try {
|
||||||
|
songInfo = await ytdl.getInfo(url);
|
||||||
|
song = {
|
||||||
|
title: songInfo.videoDetails.title,
|
||||||
|
url: songInfo.videoDetails.video_url,
|
||||||
|
duration: songInfo.videoDetails.lengthSeconds,
|
||||||
|
views: songInfo.videoDetails.viewCount,
|
||||||
|
thumbnail: songInfo.videoDetails.thumbnails[2]["url"]
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return message.reply(error.message).catch(console.error);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
const results = await youtube.searchVideos(search, 1, { part: "snippet" });
|
||||||
|
songInfo = await ytdl.getInfo(results[0].url);
|
||||||
|
song = {
|
||||||
|
title: songInfo.videoDetails.title,
|
||||||
|
url: songInfo.videoDetails.video_url,
|
||||||
|
duration: songInfo.videoDetails.lengthSeconds,
|
||||||
|
views: songInfo.videoDetails.viewCount,
|
||||||
|
thumbnail: songInfo.videoDetails.thumbnails[2]["url"]
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return message.reply(error.message).catch(console.error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var date = new Date(0);
|
||||||
|
date.setSeconds(song.duration); // specify value for SECONDS here
|
||||||
|
var timeString = date.toISOString().substr(11, 8);
|
||||||
|
|
||||||
|
|
||||||
|
if (serverQueue) {
|
||||||
|
serverQueue.songs.push(song);
|
||||||
|
let embed = new MessageEmbed()
|
||||||
|
.setTitle('Ajouté à la liste de lecture!')
|
||||||
|
.setColor('#00fff1')
|
||||||
|
.addField('Nom', song.title, true)
|
||||||
|
.setThumbnail(song.thumbnail)
|
||||||
|
.addField('Nombre de vues', song.views, true)
|
||||||
|
.addField('Demandé par', message.author, true)
|
||||||
|
.addField('Durée', timeString, true)
|
||||||
|
return serverQueue.textChannel
|
||||||
|
.send(embed)
|
||||||
|
.catch(console.error);
|
||||||
|
}
|
||||||
|
|
||||||
|
queueConstruct.songs.push(song);
|
||||||
|
message.client.queue.set(message.guild.id, queueConstruct);
|
||||||
|
|
||||||
|
try {
|
||||||
|
queueConstruct.connection = await channel.join();
|
||||||
|
await queueConstruct.connection.voice.setSelfDeaf(true);
|
||||||
|
play(queueConstruct.songs[0], message);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
message.client.queue.delete(message.guild.id);
|
||||||
|
await channel.leave();
|
||||||
|
return message.channel.send(`Impossible de rejoindre le channel: ${error}`).catch(console.error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.PLAY;
|
||||||
|
|
114
commands/Musique/playlist.js
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
const { MessageEmbed } = require("discord.js");
|
||||||
|
const { play } = require("../../Includes/play");
|
||||||
|
const YouTubeAPI = require("simple-youtube-api");
|
||||||
|
|
||||||
|
const {
|
||||||
|
YOUTUBE_API_KEY,
|
||||||
|
MAX_PLAYLIST_SIZE,
|
||||||
|
DEFAULT_VOLUME,
|
||||||
|
} = require("../../util/LanBot");
|
||||||
|
const youtube = new YouTubeAPI(YOUTUBE_API_KEY);
|
||||||
|
|
||||||
|
|
||||||
|
module.exports.run = async (client, message, args, settings) => {
|
||||||
|
const { channel } = message.member.voice;
|
||||||
|
const serverQueue = message.client.queue.get(message.guild.id);
|
||||||
|
|
||||||
|
if (!channel.permissionsFor(message.client.user).has("CONNECT")) return message.channel.send("Je n'ai pas la permission de rejoindre un salon vocal !")
|
||||||
|
if (!channel.permissionsFor(message.client.user).has("SPEAK"))return message.channel.send("Je n'ai pas la permission Parler dans le salon vocal !")
|
||||||
|
|
||||||
|
if (serverQueue && channel !== message.guild.me.voice.channel)
|
||||||
|
return message
|
||||||
|
.reply(`Vous devez être dans le même canal que ${message.client.user}`)
|
||||||
|
.catch(console.error);
|
||||||
|
|
||||||
|
const search = args.join(" ");
|
||||||
|
const pattern = /^.*(youtu.be\/|list=)([^#\&\?]*).*/gi;
|
||||||
|
const url = args[0];
|
||||||
|
const urlValid = pattern.test(args[0]);
|
||||||
|
|
||||||
|
const queueConstruct = {
|
||||||
|
textChannel: message.channel,
|
||||||
|
channel,
|
||||||
|
connection: null,
|
||||||
|
songs: [],
|
||||||
|
loop: false,
|
||||||
|
volume: DEFAULT_VOLUME || 100,
|
||||||
|
playing: true
|
||||||
|
};
|
||||||
|
|
||||||
|
let playlist = null;
|
||||||
|
let videos = [];
|
||||||
|
|
||||||
|
if (urlValid) {
|
||||||
|
try {
|
||||||
|
playlist = await youtube.getPlaylist(url, { part: "snippet" });
|
||||||
|
videos = await playlist.getVideos(MAX_PLAYLIST_SIZE || 10, { part: "snippet" });
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return message.reply("Playlist introuvable ! 🥺 ").catch(console.error);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
const results = await youtube.searchPlaylists(search, 1, { part: "snippet" });
|
||||||
|
playlist = results[0];
|
||||||
|
videos = await playlist.getVideos(MAX_PLAYLIST_SIZE || 10, { part: "snippet" });
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return message.reply(error.message).catch(console.error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const newSongs = videos
|
||||||
|
.filter((video) => video.title != "Private video" && video.title != "Deleted video")
|
||||||
|
.map((video) => {
|
||||||
|
return (song = {
|
||||||
|
title: video.title,
|
||||||
|
url: video.url,
|
||||||
|
duration: video.durationSeconds
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
serverQueue ? serverQueue.songs.push(...newSongs) : queueConstruct.songs.push(...newSongs);
|
||||||
|
|
||||||
|
let playlistEmbed = new MessageEmbed()
|
||||||
|
.setTitle(`${playlist.title}`)
|
||||||
|
.setDescription(newSongs.map((song, index) => `${index + 1}. ${song.title}`))
|
||||||
|
.setURL(playlist.url)
|
||||||
|
.setColor("#F8AA2A")
|
||||||
|
.setTimestamp();
|
||||||
|
|
||||||
|
if (playlistEmbed.description.length >= 2048)
|
||||||
|
playlistEmbed.description =
|
||||||
|
playlistEmbed.description.substr(0, 2007) + ("\nListe de lecture supérieure à la limite de caractères...");
|
||||||
|
|
||||||
|
message.channel.send((`${message.author} a commencé une playlist`), playlistEmbed);
|
||||||
|
|
||||||
|
if (!serverQueue) {
|
||||||
|
message.client.queue.set(message.guild.id, queueConstruct);
|
||||||
|
|
||||||
|
try {
|
||||||
|
queueConstruct.connection = await channel.join();
|
||||||
|
await queueConstruct.connection.voice.setSelfDeaf(true);
|
||||||
|
play(queueConstruct.songs[0], message);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
message.client.queue.delete(message.guild.id);
|
||||||
|
await channel.leave();
|
||||||
|
return message.channel.send(`Impossible de rejoindre le channel: ${error}`).catch(console.error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.PLAYLIST;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Play Pause ⏯️
|
||||||
|
Stop ⏹️
|
||||||
|
Shuffle 🔀
|
||||||
|
Loop All 🔁
|
||||||
|
Loop One 🔂
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
28
commands/Musique/pruning.js
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
const fs = require("fs");
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
|
||||||
|
let config;
|
||||||
|
|
||||||
|
try {
|
||||||
|
config = require("../../config");
|
||||||
|
} catch (error) {
|
||||||
|
config = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args, settings) => {
|
||||||
|
if (!config) return;
|
||||||
|
config.PRUNING = !config.PRUNING;
|
||||||
|
|
||||||
|
fs.writeFile("../../config", JSON.stringify(config, null, 2), (err) => {
|
||||||
|
if (err) {
|
||||||
|
console.log(err);
|
||||||
|
return message.channel.send("Une erreur s'est produite lors de l'écriture dans le fichier.").catch(console.error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return message.channel
|
||||||
|
.send(`Pruning est ${config.PRUNING ? "**ON**" : "**OFF**"}`)
|
||||||
|
.catch(console.error);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.PRUNING;
|
88
commands/Musique/queue.js
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
const { MessageEmbed } = require('discord.js')
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
|
||||||
|
module.exports.run = async (client, message, args, settings) => {
|
||||||
|
const permissions = message.channel.permissionsFor(message.client.user);
|
||||||
|
if (!permissions.has(["MANAGE_MESSAGES", "ADD_REACTIONS"]))
|
||||||
|
return message.reply("Il me manque l'autorisation de gérer les messages ou d'ajouter des réactions");
|
||||||
|
|
||||||
|
const queue = message.client.queue.get(message.guild.id);
|
||||||
|
if (!queue) return message.channel.send("❌ **Rien ne joue sur ce serveur**");
|
||||||
|
|
||||||
|
let currentPage = 0;
|
||||||
|
const embeds = generateQueueEmbed(message, queue.songs);
|
||||||
|
|
||||||
|
const queueEmbed = await message.channel.send(
|
||||||
|
`**${("Page actuelle - ")} ${currentPage + 1}/${embeds.length}**`,
|
||||||
|
embeds[currentPage]
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await queueEmbed.react("⬅️");
|
||||||
|
await queueEmbed.react("⏹");
|
||||||
|
await queueEmbed.react("➡️");
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
message.channel.send(error.message).catch(console.error);
|
||||||
|
}
|
||||||
|
|
||||||
|
const filter = (reaction, user) =>
|
||||||
|
["⬅️", "⏹", "➡️"].includes(reaction.emoji.name) && message.author.id === user.id;
|
||||||
|
const collector = queueEmbed.createReactionCollector(filter, { time: 60000 });
|
||||||
|
|
||||||
|
collector.on("collect", async (reaction, user) => {
|
||||||
|
try {
|
||||||
|
if (reaction.emoji.name === "➡️") {
|
||||||
|
if (currentPage < embeds.length - 1) {
|
||||||
|
currentPage++;
|
||||||
|
queueEmbed.edit(
|
||||||
|
("Page actuelle - ", { page: currentPage + 1, length: embeds.length }),
|
||||||
|
embeds[currentPage]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if (reaction.emoji.name === "⬅️") {
|
||||||
|
if (currentPage !== 0) {
|
||||||
|
--currentPage;
|
||||||
|
queueEmbed.edit(
|
||||||
|
("Page actuelle - ", { page: currentPage + 1, length: embeds.length }),
|
||||||
|
embeds[currentPage]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
collector.stop();
|
||||||
|
reaction.message.reactions.removeAll();
|
||||||
|
}
|
||||||
|
await reaction.users.remove(message.author.id);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return message.channel.send(error.message).catch(console.error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateQueueEmbed(message, queue) {
|
||||||
|
let embeds = [];
|
||||||
|
let k = 10;
|
||||||
|
|
||||||
|
for (let i = 0; i < queue.length; i += 10) {
|
||||||
|
const current = queue.slice(i, k);
|
||||||
|
let j = i;
|
||||||
|
k += 10;
|
||||||
|
|
||||||
|
const info = current.map((track) => `${++j} - [${track.title}](${track.url})`).join("\n");
|
||||||
|
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setTitle("Song Queue\n")
|
||||||
|
.setThumbnail(message.guild.iconURL())
|
||||||
|
.setColor("#F8AA2A")
|
||||||
|
.setDescription(
|
||||||
|
(`**Morceau en cours - [${queue[0].title}](${queue[0].url})**\n\n${info}`)
|
||||||
|
)
|
||||||
|
.setTimestamp();
|
||||||
|
embeds.push(embed);
|
||||||
|
}
|
||||||
|
|
||||||
|
return embeds;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.QUEUE;
|
104
commands/Musique/radiozebre.js
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
const { MessageEmbed } = require("discord.js");
|
||||||
|
const { play } = require("../../Includes/play");
|
||||||
|
const YouTubeAPI = require("simple-youtube-api");
|
||||||
|
|
||||||
|
const {
|
||||||
|
YOUTUBE_API_KEY,
|
||||||
|
MAX_PLAYLIST_SIZE,
|
||||||
|
DEFAULT_VOLUME,
|
||||||
|
} = require("../../util/LanBot");
|
||||||
|
const youtube = new YouTubeAPI(YOUTUBE_API_KEY);
|
||||||
|
|
||||||
|
|
||||||
|
module.exports.run = async (client, message, args, settings) => {
|
||||||
|
const { channel } = message.member.voice;
|
||||||
|
const serverQueue = message.client.queue.get(message.guild.id);
|
||||||
|
|
||||||
|
if (!channel.permissionsFor(message.client.user).has("CONNECT")) return message.channel.send("Je n'ai pas la permission de rejoindre un salon vocal !")
|
||||||
|
if (!channel.permissionsFor(message.client.user).has("SPEAK"))return message.channel.send("Je n'ai pas la permission Parler dans le salon vocal !")
|
||||||
|
|
||||||
|
if (serverQueue && channel !== message.guild.me.voice.channel)
|
||||||
|
return message
|
||||||
|
.reply(`Vous devez être dans le même canal que ${message.client.user}`)
|
||||||
|
.catch(console.error);
|
||||||
|
|
||||||
|
const search = ("https://youtube.com/playlist?list=PLEQIc8j7Pa4SX6ixC2D6wplqzXI9Jv6el");
|
||||||
|
const pattern = /^.*(youtu.be\/|list=)([^#\&\?]*).*/gi;
|
||||||
|
const url = ("https://youtube.com/playlist?list=PLEQIc8j7Pa4SX6ixC2D6wplqzXI9Jv6el");
|
||||||
|
const urlValid = pattern.test("https://youtube.com/playlist?list=PLEQIc8j7Pa4SX6ixC2D6wplqzXI9Jv6el");
|
||||||
|
|
||||||
|
const queueConstruct = {
|
||||||
|
textChannel: message.channel,
|
||||||
|
channel,
|
||||||
|
connection: null,
|
||||||
|
songs: [],
|
||||||
|
loop: false,
|
||||||
|
volume: DEFAULT_VOLUME || 100,
|
||||||
|
playing: true
|
||||||
|
};
|
||||||
|
|
||||||
|
let playlist = null;
|
||||||
|
let videos = [];
|
||||||
|
|
||||||
|
if (urlValid) {
|
||||||
|
try {
|
||||||
|
playlist = await youtube.getPlaylist(url, { part: "snippet" });
|
||||||
|
videos = await playlist.getVideos(MAX_PLAYLIST_SIZE || 10, { part: "snippet" });
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return message.reply("Playlist introuvable ! 🥺 ").catch(console.error);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
const results = await youtube.searchPlaylists(search, 1, { part: "snippet" });
|
||||||
|
playlist = results[0];
|
||||||
|
videos = await playlist.getVideos(MAX_PLAYLIST_SIZE || 10, { part: "snippet" });
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return message.reply(error.message).catch(console.error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const newSongs = videos
|
||||||
|
.filter((video) => video.title != "Private video" && video.title != "Deleted video")
|
||||||
|
.map((video) => {
|
||||||
|
return (song = {
|
||||||
|
title: video.title,
|
||||||
|
url: video.url,
|
||||||
|
duration: video.durationSeconds
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
serverQueue ? serverQueue.songs.push(...newSongs) : queueConstruct.songs.push(...newSongs);
|
||||||
|
|
||||||
|
let playlistEmbed = new MessageEmbed()
|
||||||
|
.setTitle(`${playlist.title}`)
|
||||||
|
.setDescription(newSongs.map((song, index) => `${index + 1}. ${song.title}`))
|
||||||
|
.setURL(playlist.url)
|
||||||
|
.setColor("#F8AA2A")
|
||||||
|
.setTimestamp();
|
||||||
|
|
||||||
|
if (playlistEmbed.description.length >= 2048)
|
||||||
|
playlistEmbed.description =
|
||||||
|
playlistEmbed.description.substr(0, 2007) + ("\nListe de lecture supérieure à la limite de caractères...");
|
||||||
|
|
||||||
|
message.channel.send((`${message.author} a commencé une playlist`), playlistEmbed);
|
||||||
|
|
||||||
|
if (!serverQueue) {
|
||||||
|
message.client.queue.set(message.guild.id, queueConstruct);
|
||||||
|
|
||||||
|
try {
|
||||||
|
queueConstruct.connection = await channel.join();
|
||||||
|
await queueConstruct.connection.voice.setSelfDeaf(true);
|
||||||
|
play(queueConstruct.songs[0], message);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
message.client.queue.delete(message.guild.id);
|
||||||
|
await channel.leave();
|
||||||
|
return message.channel.send(`Impossible de rejoindre le channel: ${error}`).catch(console.error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.RADIOZEBRE;
|
33
commands/Musique/remove.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
const pattern = /^[0-9]{1,2}(\s*,\s*[0-9]{1,2})*$/;
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
const { canModifyQueue } = require("../../util/LanBot");
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args, settings) => {
|
||||||
|
const queue = message.client.queue.get(message.guild.id);
|
||||||
|
|
||||||
|
if (!queue) return message.channel.send("Il n'y a pas de file d'attente.").catch(console.error);
|
||||||
|
if (!canModifyQueue(message.member))return message.channel.send('Vous devez être dans un salon vocal pour utiliser cette commande !');
|
||||||
|
|
||||||
|
|
||||||
|
const arguments = args.join("");
|
||||||
|
const songs = arguments.split(",").map((arg) => parseInt(arg));
|
||||||
|
let removed = [];
|
||||||
|
|
||||||
|
if (pattern.test(arguments)) {
|
||||||
|
queue.songs = queue.songs.filter((item, index) => {
|
||||||
|
if (songs.find((songIndex) => songIndex - 1 === index)) removed.push(item);
|
||||||
|
else return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
queue.textChannel.send(
|
||||||
|
`${message.author} ❌ suppression de **${removed.map((song) => song.title).join("\n")}** de la file d'attente.`
|
||||||
|
);
|
||||||
|
} else if (!isNaN(args[0]) && args[0] >= 1 && args[0] <= queue.songs.length) {
|
||||||
|
console.log("On a eu de la chance !");
|
||||||
|
return queue.textChannel.send(
|
||||||
|
`${message.author} ❌ suppression de **${queue.songs.splice(args[0] - 1, 1)[0].title}** de la file d'attente.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.REMOVE;
|
18
commands/Musique/resume.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
const { canModifyQueue } = require("../../util/LanBot");
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args, settings) => {
|
||||||
|
if (!canModifyQueue(message.member))return message.channel.send('Vous devez être dans un salon vocal pour utiliser cette commande !');
|
||||||
|
let queue = message.client.queue.get(message.guild.id)
|
||||||
|
if(!queue) return message.channel.send({
|
||||||
|
embed: {
|
||||||
|
description: "Aucune musique actuellement en pause !"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if(queue.playing !== false)
|
||||||
|
queue.connection.dispatcher.resume()
|
||||||
|
message.react('▶')
|
||||||
|
message.channel.send('Musique relancée !')
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.RESUME;
|
60
commands/Musique/search.js
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
const { MessageEmbed } = require("discord.js");
|
||||||
|
const YouTubeAPI = require("simple-youtube-api");
|
||||||
|
const { YOUTUBE_API_KEY } = require("../../util/LanBot");
|
||||||
|
const youtube = new YouTubeAPI(YOUTUBE_API_KEY);
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
|
||||||
|
|
||||||
|
module.exports.run = async (client, message, args, settings) => {
|
||||||
|
|
||||||
|
|
||||||
|
if (message.channel.activeCollector) return message.reply("Un collecteur de messages est déjà actif dans ce canal.");
|
||||||
|
if (!message.member.voice.channel)
|
||||||
|
return message.reply("Vous devez d'abord rejoindre un canal vocal!").catch(console.error);
|
||||||
|
|
||||||
|
const search = args.join(" ");
|
||||||
|
|
||||||
|
let resultsEmbed = new MessageEmbed()
|
||||||
|
.setTitle("**Répondez avec le numéro de la chanson que vous souhaitez écouter**")
|
||||||
|
.setDescription(`Résultat pour: ${search}`)
|
||||||
|
.setColor("#F8AA2A");
|
||||||
|
|
||||||
|
try {
|
||||||
|
const results = await youtube.searchVideos(search, 10);
|
||||||
|
results.map((video, index) => resultsEmbed.addField(video.shortURL, `${index + 1}. ${video.title}`));
|
||||||
|
|
||||||
|
let resultsMessage = await message.channel.send(resultsEmbed);
|
||||||
|
|
||||||
|
function filter(msg) {
|
||||||
|
const pattern = /^[0-9]{1,2}(\s*,\s*[0-9]{1,2})*$/;
|
||||||
|
return pattern.test(msg.content);
|
||||||
|
}
|
||||||
|
|
||||||
|
message.channel.activeCollector = true;
|
||||||
|
const response = await message.channel.awaitMessages(filter, { max: 1, time: 30000, errors: ["time"] });
|
||||||
|
const reply = response.first().content;
|
||||||
|
|
||||||
|
if (reply.includes(",")) {
|
||||||
|
let songs = reply.split(",").map((str) => str.trim());
|
||||||
|
|
||||||
|
for (let song of songs) {
|
||||||
|
await message.client.commands
|
||||||
|
.get("play")
|
||||||
|
.execute(message, [resultsEmbed.fields[parseInt(song) - 1].name]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const choice = resultsEmbed.fields[parseInt(response.first()) - 1].name;
|
||||||
|
message.client.commands.get("play").execute(message, [choice]);
|
||||||
|
}
|
||||||
|
|
||||||
|
message.channel.activeCollector = false;
|
||||||
|
resultsMessage.delete().catch(console.error);
|
||||||
|
response.first().delete().catch(console.error);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
message.channel.activeCollector = false;
|
||||||
|
message.reply("lantium a encore chié sur le code ! ").catch(console.error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.SEARCH;
|
23
commands/Musique/shuffle.js
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
const { canModifyQueue } = require("../../util/LanBot");
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args, settings) => {
|
||||||
|
|
||||||
|
if (!canModifyQueue(message.member))return message.channel.send('Vous devez être dans un salon vocal pour utiliser cette commande !');
|
||||||
|
|
||||||
|
const queue = message.client.queue.get(message.guild.id)
|
||||||
|
if(!queue) return message.channel.send("Aucune musique dans la liste d'attente !")
|
||||||
|
|
||||||
|
let songs = queue.songs;
|
||||||
|
for (let i = songs.length - 1; i > 1; i--) {
|
||||||
|
let j = 1 + Math.floor(Math.random() * i);
|
||||||
|
[songs[i], songs[j]] = [songs[j], songs[i]];
|
||||||
|
}
|
||||||
|
|
||||||
|
queue.songs = songs;
|
||||||
|
|
||||||
|
message.client.queue.set(message.guild.id, queue);
|
||||||
|
message.channel.send(`Lecture aléatoire de la liste de lecture 🔀`).catch(console.error);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.SHUFFLE;
|
23
commands/Musique/skip.js
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
const { canModifyQueue } = require("../../util/LanBot");
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args, settings) => {
|
||||||
|
|
||||||
|
if (!canModifyQueue(message.member))return message.channel.send('Vous devez être dans un salon vocal pour utiliser cette commande !');
|
||||||
|
|
||||||
|
let queue = message.client.queue.get(message.guild.id)
|
||||||
|
if(!queue){ return message.channel.send({
|
||||||
|
embed: {
|
||||||
|
description: `Liste d'attente vide ! merci d'utiliser la commande \`${settings.prefix}play + URL / Nom de la musique\` !`,
|
||||||
|
color: 'BLACK'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if(queue.songs.length !== 0) {
|
||||||
|
message.react('✅')
|
||||||
|
queue.connection.dispatcher.end('Dacodac Je passe à la suivante')
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.SKIP;
|
33
commands/Musique/skipto.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
const { canModifyQueue } = require("../../util/LanBot");
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args, settings) => {
|
||||||
|
|
||||||
|
|
||||||
|
const queue = message.client.queue.get(message.guild.id);
|
||||||
|
if (!queue) return message.channel.send("Il n'y a pas de file d'attente.").catch(console.error);
|
||||||
|
if (!canModifyQueue(message.member))return message.channel.send('Vous devez être dans un salon vocal pour utiliser cette commande !');
|
||||||
|
|
||||||
|
if (args[0] > queue.songs.length)
|
||||||
|
return message
|
||||||
|
.reply(`La file d'attente contient seulement ${queue.songs.length} chansons!`)
|
||||||
|
.catch(console.error);
|
||||||
|
|
||||||
|
queue.playing = true;
|
||||||
|
|
||||||
|
if (queue.loop) {
|
||||||
|
for (let i = 0; i < args[0] - 2; i++) {
|
||||||
|
queue.songs.push(queue.songs.shift());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
queue.songs = queue.songs.slice(args[0] - 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
queue.connection.dispatcher.end();
|
||||||
|
queue.textChannel
|
||||||
|
.send(`${message.author} ⏭ skip ${args[0] - 1} musiques`)
|
||||||
|
.catch(console.error);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.SKIPTO;
|
19
commands/Musique/stop.js
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
const { canModifyQueue } = require("../../util/LanBot");
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args, settings) => {
|
||||||
|
if (!canModifyQueue(message.member))return message.channel.send('Vous devez être dans un salon vocal pour utiliser cette commande !');
|
||||||
|
|
||||||
|
let queue = message.client.queue.get(message.guild.id)
|
||||||
|
if(!queue) return message.channel.send({
|
||||||
|
embed: {
|
||||||
|
description: "Aucune musique de jouer, donc impossible d'utiliser la commande !",
|
||||||
|
color: 'BLACK'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
message.react('✅')
|
||||||
|
queue.songs = []
|
||||||
|
queue.connection.dispatcher.end('Fin!')
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.STOP;
|
22
commands/Musique/volume.js
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
const { canModifyQueue } = require("../../util/LanBot");
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args, settings) => {
|
||||||
|
const queue = message.client.queue.get(message.guild.id);
|
||||||
|
|
||||||
|
if (!queue) return message.reply(i18n.__("volume.errorNotQueue")).catch(console.error);
|
||||||
|
if (!canModifyQueue(message.member))return message.channel.send('Vous devez être dans un salon vocal pour utiliser cette commande !');
|
||||||
|
|
||||||
|
|
||||||
|
if (!args[0]) return message.reply(`🔊 Le volume actuelle est de: **${queue.volume}%**`).catch(console.error);
|
||||||
|
if (isNaN(args[0])) return message.reply("Veuillez utiliser un nombre pour régler le volume.").catch(console.error);
|
||||||
|
if (Number(args[0]) > 100 || Number(args[0]) < 0)
|
||||||
|
return message.reply("Veuillez utiliser un nombre compris entre 0 et 100.").catch(console.error);
|
||||||
|
|
||||||
|
queue.volume = args[0];
|
||||||
|
queue.connection.dispatcher.setVolumeLogarithmic(args[0] / 100);
|
||||||
|
return queue.textChannel.send(`Volume réglé sur: **${args[0]}%**`).catch(console.error);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.VOLUME;
|
68
commands/Utilitaire/help.js
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
const { MessageEmbed } = require("discord.js");
|
||||||
|
const { readdirSync } = require("fs");
|
||||||
|
const categoryList = readdirSync('./commands');
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args, settings) => {
|
||||||
|
|
||||||
|
//let user = message.guild.member(message.mentions.users.first());
|
||||||
|
message.delete();
|
||||||
|
|
||||||
|
if(!args.length) {
|
||||||
|
const embedIntro = new MessageEmbed()
|
||||||
|
.setAuthor('Liste des categories', message.guild.iconURL())
|
||||||
|
.setColor('#0c76e7')
|
||||||
|
.setDescription(`Voici la liste des catégories.\nPour plus d'information, merci de faire la commande \`${settings.prefix}help <Commande>\` ou \`${settings.prefix}help <Catégorie>\``)
|
||||||
|
.setTimestamp(new Date())
|
||||||
|
message.channel.send(embedIntro)
|
||||||
|
// message.member.send("**Les commandes sont à taper dans le serveur et pas en MP désolé** :innocent: ")
|
||||||
|
// message.channel.send(embedIntro);
|
||||||
|
// message.channel.send("Regarde tes MP :wink:").then(msg => {
|
||||||
|
// msg.delete({ timeout: 5000 /*time unitl delete in milliseconds*/});
|
||||||
|
// })
|
||||||
|
|
||||||
|
const embedCat = new MessageEmbed()
|
||||||
|
.setColor('#0c76e7')
|
||||||
|
.setAuthor('Help', client.user.displayAvatarURL())
|
||||||
|
.setFooter('Help', client.user.displayAvatarURL())
|
||||||
|
.setTimestamp(new Date())
|
||||||
|
.addField('Voici les différentes catégories de LanBot', `**${categoryList.join('\n')}**`)
|
||||||
|
message.channel.send(embedCat);
|
||||||
|
} else if(categoryList.includes(args[0])) {
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setColor('#0c76e7')
|
||||||
|
.setDescription(`Voici la liste des commandes de cette catégorie.\nPour plus d'informations, \`${settings.prefix}help <Commande>\``)
|
||||||
|
.setAuthor(args[0], client.user.displayAvatarURL())
|
||||||
|
.setFooter(args[0], client.user.displayAvatarURL())
|
||||||
|
.setTimestamp(new Date())
|
||||||
|
.addField(`Pas assez de commande ? Envie d'en avoir plus ?`, `Fait la commande \`${settings.prefix}sugg\` pour faire ta suggestion au développeur :blush:`)
|
||||||
|
|
||||||
|
const cmds = client.commands.filter(cmd => cmd.help.category=== args[0].toLowerCase()).array();
|
||||||
|
cmds.forEach(cmd => {
|
||||||
|
|
||||||
|
const aliases = (!cmd.help.aliases)? 'aucun':cmd.help.aliases.join(', ');
|
||||||
|
embed.addField(`${settings.prefix}${cmd.help.name}`, `Description: ${cmd.help.description}\nAliase(s): ${aliases}\nUtilisation(s): ${settings.prefix}${cmd.help.usage.join('\n')}`);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
message.channel.send(embed);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
const command = client.commands.find(cmd => cmd.help.name === args[0]);
|
||||||
|
if(!command) return message.channel.send('Commande ou Catégorie invalide !')
|
||||||
|
const aliases = (!command.help.aliases)? 'aucun':command.help.aliases.join('\n');
|
||||||
|
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setColor('#0c76e7')
|
||||||
|
.setAuthor(args[0], client.user.displayAvatarURL())
|
||||||
|
.setFooter(args[0], client.user.displayAvatarURL())
|
||||||
|
.setTimestamp(new Date())
|
||||||
|
.addField(`${settings.prefix}${command.help.name}`, `Description: ${command.help.description}\nAliase(s): ${aliases}\nUtilisation(s): ${settings.prefix}${command.help.usage.join('\n')}`);
|
||||||
|
|
||||||
|
message.channel.send(embed);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.UTILITAIRE.HELP;
|
12
commands/Utilitaire/ping.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
|
||||||
|
module.exports.run = async (client, message, args) => {
|
||||||
|
const msg = await message.channel.send("Pong ! ");
|
||||||
|
msg.edit(
|
||||||
|
`Pong !
|
||||||
|
Latence du bot: ${msg.createdTimestamp - message.createdTimestamp}ms
|
||||||
|
Latence de l'API: ${Math.round(client.ws.ping)}ms`
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.UTILITAIRE.PING;
|
15
commands/Utilitaire/yt.js
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
const { DiscordTogether } = require('discord-together');
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args, settings) => {
|
||||||
|
|
||||||
|
client.discordTogether = new DiscordTogether(client);
|
||||||
|
|
||||||
|
if(message.member.voice.channel) {
|
||||||
|
client.discordTogether.createTogetherCode(message.member.voice.channel.id, 'youtube').then(async invite => {
|
||||||
|
return message.channel.send(`${invite.code} \nRemarque : vous devez cliquer sur le LIEN BLEU, et non sur le bouton 'Play', afin de démarrer l'activité !`);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.UTILITAIRE.YT;
|
12
config.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
module.exports = {
|
||||||
|
TOKEN: "",
|
||||||
|
DBCONNECTION: '',
|
||||||
|
YOUTUBE_API_KEY: "",
|
||||||
|
MAX_PLAYLIST_SIZE: 200,
|
||||||
|
PRUNING: true,
|
||||||
|
STAY_TIME: 30,
|
||||||
|
DEFAULT_VOLUME: 80,
|
||||||
|
DEFAULTSETTINGS: {
|
||||||
|
prefix: "?",
|
||||||
|
}
|
||||||
|
}
|
14
events/client/ready.js
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = client => {
|
||||||
|
|
||||||
|
console.log(`${client.user.tag} oberve les ${client.guilds.cache.map(g => g.memberCount).reduce((a,b) => a + b)} utilisateur du serveur !`)
|
||||||
|
//client.channels.cache.get('818435944968618006').send("Le bot est prêt !");
|
||||||
|
|
||||||
|
let activites = ['Créer par Lantium !',`Ecoute prefix + help` ], i = 0;
|
||||||
|
|
||||||
|
// let activites = ['Jour spécial pour Lantium ! 🎂'], i = 0;
|
||||||
|
|
||||||
|
setInterval(() => client.user.setPresence({ activity: { name: `${activites [i++ % activites.length]}`, type: 'PLAYING' }, status: 'online' }), 5000);
|
||||||
|
|
||||||
|
}
|
26
events/guild/guildCreate.js
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
const { MessageEmbed } = require("discord.js");
|
||||||
|
|
||||||
|
module.exports = async (client, guild, message) => {
|
||||||
|
const newGuild = {
|
||||||
|
guildID: guild.id,
|
||||||
|
guildName: guild.name
|
||||||
|
};
|
||||||
|
|
||||||
|
await client.createGuild(newGuild);
|
||||||
|
|
||||||
|
const flag = guild.systemChannel;
|
||||||
|
|
||||||
|
//const msg = ("Bonjour, je m'appelle LanBot\nJe suis content que vous m'ayez choisi pour vous assister dans votre serveur et je me ferai une joie de mettre mes commandes et ma puissance de calcul à votre contribution.\n\nJe vous laisse le plaisir de faire la commande \`?init\` pour m'initialiser et suivre mes indications !\n\nSi vous avez le moindre soucis vous pouvez contactez mon développeur via la commande \`?sugg\` qui se fera un plaisir de venir vous voir et vous aidez !");
|
||||||
|
|
||||||
|
//flag.send(msg);
|
||||||
|
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setColor("RANDOM")
|
||||||
|
.setTitle("Bonjour, je m'appelle LanBot")
|
||||||
|
.setDescription("Je suis content que vous m'ayez choisi pour vous assister dans votre serveur et je me ferai une joie de mettre mes commandes et ma puissance de calcul à votre contribution.\n\nJe vous laisse le plaisir de faire la commande \`?init\` pour m'initialiser et suivre mes indications !\n\nSi vous avez le moindre soucis vous pouvez contactez mon développeur via la commande \`?sugg\` qui se fera un plaisir de venir vous voir et vous aidez !")
|
||||||
|
.setTimestamp()
|
||||||
|
.setFooter("Développé et Créé par lantium#9402");
|
||||||
|
|
||||||
|
flag.send(embed);
|
||||||
|
};
|
||||||
|
|
3
events/guild/guildDelete.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = async (client, guild, member) => {
|
||||||
|
await client.deleteGuild(guild);
|
||||||
|
};
|
17
events/message/directMessage.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
const { MessageEmbed } = require("discord.js");
|
||||||
|
|
||||||
|
module.exports = (client, message) => {
|
||||||
|
const user = message.author;
|
||||||
|
if (user.bot) return;
|
||||||
|
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setAuthor(`${user.username} (${user.id})`)
|
||||||
|
.setColor("#ffa500")
|
||||||
|
.setDescription(`**Action**: ouverture ticket\n**Raison**: ${message.content}\nUtilisateur ${user}`)
|
||||||
|
.setThumbnail(user.avatarURL())
|
||||||
|
.setTimestamp()
|
||||||
|
.setFooter(message.author.username, message.author.avatarURL());
|
||||||
|
|
||||||
|
user.send("Nous avons reçu votre ticket, on vous répondra d'est que possible !");
|
||||||
|
client.channels.cache.get('815483099034943488').send(embed);
|
||||||
|
}
|
92
events/message/message.js
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
const { Collection } = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = async (client, message) => {
|
||||||
|
const settings = await client.getGuild(message.guild);
|
||||||
|
//const dbUser = await client.getUser(message.member);
|
||||||
|
|
||||||
|
|
||||||
|
if (message.channel.type === "dm") return client.emit("directMessage", message);
|
||||||
|
if (message.author.bot) return;
|
||||||
|
|
||||||
|
|
||||||
|
// reaction à tous les messages des membres via leur ID sur une guilde
|
||||||
|
//if (message.guild.id == "720405633228079185") {
|
||||||
|
//if (message.member.id == "475730695889879071") return message.channel.send(`${message.author.username} Au nom de <@721861508723638383> et de mon plaisir je te botte le cul https://tenor.com/view/funny-cut-throat-black-and-white-im-gonna-kill-you-kill-you-gif-7390009 !`);
|
||||||
|
//if (message.member.id == "327193195085824001") return message.channel.send(` Chef oui Chef ! <@327193195085824001>`);
|
||||||
|
//if (message.member.id == "721861508723638383") return message.channel.send(`${message.author.tag} Nous te vengerons https://tenor.com/view/running-hug-embrace-i-miss-you-good-to-see-you-again-gif-15965620 `);
|
||||||
|
|
||||||
|
|
||||||
|
// reaction à tous les messages des membres via leur ID
|
||||||
|
//if (message.member.id == "319931881741352980") return message.channel.send(` Nous t'avons lu haut GRANDE <@319931881741352980> :green_heart:`);
|
||||||
|
|
||||||
|
/*if (!dbUser) await client.createUser({
|
||||||
|
guildID: message.member.guild.id,
|
||||||
|
guildName: message.member.guild.name,
|
||||||
|
userID: message.member.id,
|
||||||
|
username: message.member.user.tag,
|
||||||
|
});*/
|
||||||
|
|
||||||
|
if (!message.content.startsWith(settings.prefix)) return;
|
||||||
|
|
||||||
|
const lantium = message.member.id == "327193195085824001";
|
||||||
|
|
||||||
|
if (message.channel.send === true );
|
||||||
|
|
||||||
|
const args = message.content.slice(settings.prefix.length).split(/ +/);
|
||||||
|
const commandName = args.shift().toLowerCase();
|
||||||
|
const user = message.mentions.users.first();
|
||||||
|
|
||||||
|
//si la commande n'existe pas, le bot ne réagit pas sauf si il y a les aliases
|
||||||
|
const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.help.aliases && cmd.help.aliases.includes(commandName));
|
||||||
|
if (!command) return;
|
||||||
|
|
||||||
|
|
||||||
|
// vérification des permissions avant exécution des commandes qui contiennent permissions dans comma,d.help.permissions
|
||||||
|
if (command.help.permissions && !message.member.hasPermission('BAN_MEMBERS') && message.author.id !== "327193195085824001" && message.author.id !== "761547180724060181") return message.reply("Tu n'as pas les permissions pour taper cette commande ! https://tenor.com/view/tiananmen-square-prostest-tank-block-gif-4724995");
|
||||||
|
|
||||||
|
// pour utiliser le args dans le help des commandes + explication de comment utiliser la commande
|
||||||
|
if (command.help.args && !args.length) {
|
||||||
|
let noArgsReply = `il me faut des arguments pour cette commande, ${message.author}!`;
|
||||||
|
|
||||||
|
if (command.help.usage) noArgsReply += `\nVoici comment utiliser la commande: \`${settings.prefix}${command.help.name} ${command.help.usage}\``
|
||||||
|
|
||||||
|
return message.channel.send(noArgsReply);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (command.help.isUserAdmin && !user) return message.reply("Il faut mentionner un utilisateur");
|
||||||
|
|
||||||
|
|
||||||
|
// vérification des permissions avant exécution des commandes qui contiennent permissions dans comma,d.help.permissions
|
||||||
|
if (command.help.isUserAdmin && message.guild.member(user).hasPermission('BAN_MEMBERS')) return message.reply(`Tu ne peux pas utiliser la commande ${command.help.name} sur cet utilisateur !`);
|
||||||
|
|
||||||
|
|
||||||
|
// pour le cooldowns + utilisation de cooldown dans le help des commandes
|
||||||
|
if (!client.cooldowns.has(command.help.name)) {
|
||||||
|
client.cooldowns.set(command.help.name, new Collection());
|
||||||
|
}
|
||||||
|
|
||||||
|
const timeNow = Date.now();
|
||||||
|
const tStamps = client.cooldowns.get(command.help.name);
|
||||||
|
//permet de définir par défault 5 secondes entre toutes les commandes, sauf si cooldown est modifié dans une commande
|
||||||
|
const cdAmount = (command.help.cooldown || 5) * 1000;
|
||||||
|
|
||||||
|
//vérifie si l'utilisateur est dans la collection
|
||||||
|
if (tStamps.has(message.author.id)) {
|
||||||
|
const cdExpirationTime = tStamps.get(message.author.id) + cdAmount;
|
||||||
|
|
||||||
|
if (timeNow < cdExpirationTime) {
|
||||||
|
timeLeft = (cdExpirationTime - timeNow) / 1000;
|
||||||
|
return message.reply(`Merci d'attendre ${timeLeft.toFixed(0)} seconde(s) avant de ré-utiliser la commande \`${command.help.name}\`.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//permet de supprimer le membre de la collection si le cooldowns est fini
|
||||||
|
tStamps.set(message.author.id, timeNow);
|
||||||
|
setTimeout(() => tStamps.delete(message.author.id), cdAmount);
|
||||||
|
|
||||||
|
|
||||||
|
command.run(client, message, args, settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//, dbUser
|
27
main.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
const { Client, Collection } = require('discord.js');
|
||||||
|
const { loadCommands, loadEvents } = require("./util/loader");
|
||||||
|
|
||||||
|
const client = new Client({ partials: ['MESSAGE', 'CHANNEL', 'REACTION'] });
|
||||||
|
require("./util/functions")(client);
|
||||||
|
client.config = require("./config");
|
||||||
|
client.mongoose = require("./util/mongoose");
|
||||||
|
client.queue = new Map();
|
||||||
|
|
||||||
|
//correspond à client.commands, client.cooldowns
|
||||||
|
["commands", "cooldowns", "category", "name"].forEach(x => client[x] = new Collection());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* TODO ligne exécution commande DEBUG !!!!
|
||||||
|
|
||||||
|
const message = ("say")
|
||||||
|
const settings = client.getGuild(message.guild);
|
||||||
|
module.exports.run(client, message, "hello", settings); */
|
||||||
|
|
||||||
|
|
||||||
|
loadCommands(client);
|
||||||
|
loadEvents(client);
|
||||||
|
client.mongoose.init();
|
||||||
|
|
||||||
|
//lien vers le token du bot
|
||||||
|
client.login(client.config.TOKEN);
|
15
models/guild.js
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
const mongoose = require("mongoose");
|
||||||
|
const { DEFAULTSETTINGS: defaults } = require("../config");
|
||||||
|
|
||||||
|
const guildSchema = mongoose.Schema({
|
||||||
|
_id: mongoose.Schema.Types.ObjectId,
|
||||||
|
guildID: String,
|
||||||
|
guildName: String,
|
||||||
|
prefix: {
|
||||||
|
"type": String,
|
||||||
|
"default": defaults.prefix
|
||||||
|
},
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = mongoose.model("Guild", guildSchema);
|
6
models/index.js
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
module.exports = {
|
||||||
|
Guild: require("./guild"),
|
||||||
|
User: require("./user"),
|
||||||
|
Role: require("./role"),
|
||||||
|
//Ticket: require("./ticket")
|
||||||
|
};
|
15
models/role.js
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
const mongoose = require("mongoose");
|
||||||
|
const { DEFAULTSETTINGS: defaults } = require("../config");
|
||||||
|
|
||||||
|
const roleSchema = mongoose.Schema({
|
||||||
|
_id: mongoose.Schema.Types.ObjectId,
|
||||||
|
guildID: String,
|
||||||
|
guildName: String,
|
||||||
|
roleID: {
|
||||||
|
"type": String,
|
||||||
|
"default": defaults.role
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = mongoose.model("Role", roleSchema);
|
19
models/user.js
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
const mongoose = require("mongoose");
|
||||||
|
|
||||||
|
const userSchema = mongoose.Schema({
|
||||||
|
_id: mongoose.Schema.Types.ObjectId,
|
||||||
|
guildID: String,
|
||||||
|
guildName: String,
|
||||||
|
userID: String,
|
||||||
|
username: String,
|
||||||
|
experience: {
|
||||||
|
"type": Number,
|
||||||
|
"default": 0
|
||||||
|
},
|
||||||
|
level: {
|
||||||
|
"type": Number,
|
||||||
|
"default": 0
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = mongoose.model("User", userSchema);
|
1489
package-lock.json
generated
Normal file
37
package.json
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
"dependencies": {
|
||||||
|
"@discordjs/opus": "^0.4.0",
|
||||||
|
"array-move": "^3.0.1",
|
||||||
|
"dateformat": "^4.5.1",
|
||||||
|
"discord-together": "^1.2.0",
|
||||||
|
"discord.js": "^12.5.1",
|
||||||
|
"discordjs-ytdl": "^2.2.0",
|
||||||
|
"dotenv": "^8.2.0",
|
||||||
|
"ffmpeg": "^0.0.4",
|
||||||
|
"ffmpeg-static": "^4.2.7",
|
||||||
|
"fs": "^0.0.1-security",
|
||||||
|
"generate-password": "^1.6.0",
|
||||||
|
"lyrics-finder": "^21.7.0",
|
||||||
|
"moment": "^2.29.1",
|
||||||
|
"mongodb": "^3.6.4",
|
||||||
|
"mongoose": "^5.11.18",
|
||||||
|
"ms": "^2.1.3",
|
||||||
|
"node-fetch": "^2.6.1",
|
||||||
|
"node-superfetch": "^0.2.3",
|
||||||
|
"nodejs": "0.0.0",
|
||||||
|
"scrape-yt": "^1.4.8",
|
||||||
|
"simple-youtube-api": "^5.1.1",
|
||||||
|
"string-progressbar": "^1.0.3",
|
||||||
|
"ytdl-core": "^4.9.1",
|
||||||
|
"ytdl-core-discord": "^1.2.5"
|
||||||
|
},
|
||||||
|
"name": "lanbot",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "main.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "MIT",
|
||||||
|
"description": ""
|
||||||
|
}
|
0
sounds/putmusichere.mp3
Normal file
29
template commande.txt
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
const { canModifyQueue } = require("../../util/LanBot");
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args, settings) => {
|
||||||
|
message.channel.send("Pong ! ");
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const { MESSAGES } = require("../../util/constants");
|
||||||
|
|
||||||
|
module.exports.run = (client, message, args, settings) => {
|
||||||
|
const channel = message.member.voice.channel;
|
||||||
|
if (!channel) return message.channel.send('Vous devez être dans un salon vocal pour utiliser cette commande !'');
|
||||||
|
let queue = message.client.queue.get(message.guild.id)
|
||||||
|
if(!queue) return message.channel.send({
|
||||||
|
embed: {
|
||||||
|
description: "Aucune musique de jouer, donc impossible d'utiliser la commande !",
|
||||||
|
color: 'BLACK'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
message.react('✅')
|
||||||
|
queue.songs = []
|
||||||
|
queue.connection.dispatcher.end('Fin!')
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.STOP;
|
27
util/LanBot.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
exports.canModifyQueue = (member) => {
|
||||||
|
const { channelID } = member.voice;
|
||||||
|
const botChannel = member.guild.voice.channelID;
|
||||||
|
|
||||||
|
if (channelID !== botChannel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
let config;
|
||||||
|
|
||||||
|
try {
|
||||||
|
config = require("../config");
|
||||||
|
} catch (error) {
|
||||||
|
config = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.TOKEN = config.TOKEN;
|
||||||
|
exports.YOUTUBE_API_KEY = config.YOUTUBE_API_KEY;
|
||||||
|
//exports.SOUNDCLOUD_CLIENT_ID = config.SOUNDCLOUD_CLIENT_ID;
|
||||||
|
exports.MAX_PLAYLIST_SIZE = config.MAX_PLAYLIST_SIZE;
|
||||||
|
exports.PRUNING = config.PRUNING;
|
||||||
|
exports.STAY_TIME = config.STAY_TIME;
|
||||||
|
exports.DEFAULT_VOLUME = config.DEFAULT_VOLUME;
|
||||||
|
//exports.LOCALE = config.LOCALE;
|
357
util/constants.js
Normal file
|
@ -0,0 +1,357 @@
|
||||||
|
const MESSAGES = {
|
||||||
|
COMMANDS: {
|
||||||
|
ADMIN: {
|
||||||
|
CONFIG: {
|
||||||
|
name: "config",
|
||||||
|
aliases: ['config'],
|
||||||
|
category: 'admin',
|
||||||
|
description: "Modifier la base de données !\n<key> disponible : **prefix** / **logChannel** / **welcomeMessage**\nAttention pour le **logChannel** merci de mettre l'ID du salon !",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: ['<key> <value> '],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: true,
|
||||||
|
args: true,
|
||||||
|
},
|
||||||
|
CHARGEMENT: {
|
||||||
|
name: "chargement",
|
||||||
|
aliases: ['chargement', 'init'],
|
||||||
|
category: 'admin',
|
||||||
|
description: "Config à faire pour le premier lancement du bot !",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: [''],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: true,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
DEVELOPPEUR: {
|
||||||
|
EVAL: {
|
||||||
|
name: "eval",
|
||||||
|
aliases: ['eval'],
|
||||||
|
category: 'developpeur',
|
||||||
|
description: "Renvoie un code javascript testé !",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: ['<code_to_test>'],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: true,
|
||||||
|
},
|
||||||
|
RELOAD: {
|
||||||
|
name: "reload",
|
||||||
|
aliases: ['reload'],
|
||||||
|
category: 'developpeur',
|
||||||
|
description: "Reboot le bot !",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: [''],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
INFORMATIONS: {
|
||||||
|
BOTINFO: {
|
||||||
|
name: "botinfo",
|
||||||
|
aliases: ['botinfo', 'bi'],
|
||||||
|
category: 'informations',
|
||||||
|
description: "Renvoie des informations concernant le bot !",
|
||||||
|
cooldown: 4,
|
||||||
|
usage: [''],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
SERVERINFO: {
|
||||||
|
name: "serverinfo",
|
||||||
|
aliases: ['serverinfo', 'si'],
|
||||||
|
category: 'informations',
|
||||||
|
description: "Renvoie des informations concernant le serveur !",
|
||||||
|
cooldown: 4,
|
||||||
|
usage: [''],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
STATS: {
|
||||||
|
name: "stats",
|
||||||
|
aliases: ['stats'],
|
||||||
|
category: 'informations',
|
||||||
|
description: "Renvoie des Statistiques !",
|
||||||
|
cooldown: 4,
|
||||||
|
usage: [''],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
USERINFO: {
|
||||||
|
name: "userinfo",
|
||||||
|
aliases: ['userinfo', 'ui'],
|
||||||
|
category: 'informations',
|
||||||
|
description: "Permet d'avoir les informations de la personne mentionnée",
|
||||||
|
cooldown: 10,
|
||||||
|
usage: ['[<@user>]'],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
MUSIQUE: {
|
||||||
|
JOIN: {
|
||||||
|
name: "join",
|
||||||
|
aliases: ['join'],
|
||||||
|
category: 'musique',
|
||||||
|
description: "Connecte le bot au canal vocal !",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: [''],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
LEAVE: {
|
||||||
|
name: "leave",
|
||||||
|
aliases: ['leave'],
|
||||||
|
category: 'musique',
|
||||||
|
description: "Déconnecte le bot du canal vocal !",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: [''],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
LOOP: {
|
||||||
|
name: "loop",
|
||||||
|
aliases: ['loop'],
|
||||||
|
category: 'musique',
|
||||||
|
description: "Rejoue la musique lancé !",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: [''],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
LYRICS: {
|
||||||
|
name: "lyrics",
|
||||||
|
aliases: ['lyrics'],
|
||||||
|
category: 'musique',
|
||||||
|
description: "Envoie les paroles de la musique joué",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: [''],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
MOVE: {
|
||||||
|
name: "Move",
|
||||||
|
aliases: ['move'],
|
||||||
|
category: 'musique',
|
||||||
|
description: "Déplacez les chansons de la file d'attente",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: ['<numéro de la musique> <nouvel emplacement'],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: true,
|
||||||
|
},
|
||||||
|
NOWPLAYING: {
|
||||||
|
name: "NowPlaying",
|
||||||
|
aliases: ['nowplaying', 'np'],
|
||||||
|
category: 'musique',
|
||||||
|
description: "Afficher la chanson en cours de lecture",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: [''],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
PAUSE: {
|
||||||
|
name: "pause",
|
||||||
|
aliases: ['pause'],
|
||||||
|
category: 'musique',
|
||||||
|
description: "Met en pause la musique actuelle !",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: [''],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
PLAY: {
|
||||||
|
name: "play",
|
||||||
|
aliases: ['play'],
|
||||||
|
category: 'musique',
|
||||||
|
description: "Lance une musique",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: ['URL'],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: true,
|
||||||
|
},
|
||||||
|
PLAYLIST: {
|
||||||
|
name: "playlist",
|
||||||
|
aliases: ['playlist'],
|
||||||
|
category: 'musique',
|
||||||
|
description: "Lance une playlist",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: ['URL'],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
PRUNING: {
|
||||||
|
name: "pruning",
|
||||||
|
aliases: ['pruning'],
|
||||||
|
category: 'musique',
|
||||||
|
description: "Possibilité de supprimer les messages du bot",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: [''],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
QUEUE: {
|
||||||
|
name: "queue",
|
||||||
|
aliases: ['q'],
|
||||||
|
category: 'musique',
|
||||||
|
description: "Affiche la liste de lecture actuelle",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: [''],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
RADIOZEBRE: {
|
||||||
|
name: "radiozebre",
|
||||||
|
aliases: ['rz', 'radiozebre'],
|
||||||
|
category: 'musique',
|
||||||
|
description: "Lance la playlist radiozebre",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: [''],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
REMOVE: {
|
||||||
|
name: "remove",
|
||||||
|
aliases: ['rm'],
|
||||||
|
category: 'musique',
|
||||||
|
description: "Supprimer la chanson de la file d'attente",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: ['numéro de la musique'],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: true,
|
||||||
|
},
|
||||||
|
RESUME: {
|
||||||
|
name: "resume",
|
||||||
|
aliases: ['r'],
|
||||||
|
category: 'musique',
|
||||||
|
description: "Relance la musique mis en pause",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: [''],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
SEARCH: {
|
||||||
|
name: "search",
|
||||||
|
aliases: ['search'],
|
||||||
|
category: 'musique',
|
||||||
|
description: "Recherchez et sélectionnez des vidéos à écouter",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: ['<URL> <nom de la vidéo / musique>'],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: true,
|
||||||
|
},
|
||||||
|
SHUFFLE: {
|
||||||
|
name: "shuffle",
|
||||||
|
aliases: ['shuffle'],
|
||||||
|
category: 'musique',
|
||||||
|
description: "Lance la liste de lecture en aléatoire",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: [''],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
SKIP: {
|
||||||
|
name: "skip",
|
||||||
|
aliases: ['skip'],
|
||||||
|
category: 'musique',
|
||||||
|
description: "Lance la prochaine musique de la liste d'attente",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: [''],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
SKIPTO: {
|
||||||
|
name: "skipto",
|
||||||
|
aliases: ['skipto'],
|
||||||
|
category: 'musique',
|
||||||
|
description: "Passer au numéro de file d'attente sélectionné",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: ['numéro de la musique'],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: true,
|
||||||
|
},
|
||||||
|
STOP: {
|
||||||
|
name: "stop",
|
||||||
|
aliases: ['stop'],
|
||||||
|
category: 'musique',
|
||||||
|
description: "Arrête la musique et fait quitter le bot du salon vocal",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: [''],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
VOLUME: {
|
||||||
|
name: "VOLUME",
|
||||||
|
aliases: ['volume', 'vol'],
|
||||||
|
category: 'musique',
|
||||||
|
description: "Règle le volume du bot !",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: [''],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
UTILITAIRE: {
|
||||||
|
HELP: {
|
||||||
|
name: "help",
|
||||||
|
aliases: ['help'],
|
||||||
|
category: 'utilitaire',
|
||||||
|
description: "Renvoie une liste de commandes ou les informations sur une seule !",
|
||||||
|
cooldown: 3,
|
||||||
|
usage: ['<command_name>'],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
PING: {
|
||||||
|
name: "ping",
|
||||||
|
aliases: ['ping'],
|
||||||
|
category: 'utilitaire',
|
||||||
|
description: "Renvoie pong ! + la latence",
|
||||||
|
cooldown: 10,
|
||||||
|
usage: [''],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
YT: {
|
||||||
|
name: "yt",
|
||||||
|
aliases: ['yt'],
|
||||||
|
category: 'utilitaire',
|
||||||
|
description: "Youtube Together",
|
||||||
|
cooldown: 10,
|
||||||
|
usage: [''],
|
||||||
|
isUserAdmin: false,
|
||||||
|
permissions: false,
|
||||||
|
args: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.MESSAGES = MESSAGES;
|
33
util/functions.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
const mongoose = require("mongoose");
|
||||||
|
const { Guild, User, Ticket } = require("../models/index");
|
||||||
|
|
||||||
|
module.exports = client => {
|
||||||
|
client.createGuild = async guild => {
|
||||||
|
const merged = Object.assign({ _id: mongoose.Types.ObjectId() }, guild);
|
||||||
|
const createGuild = await new Guild(merged);
|
||||||
|
createGuild.save()
|
||||||
|
.then(g => console.log(`Nouveau serveur -> ${g.guildName}`));
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
client.getGuild = async guild => {
|
||||||
|
const data = await Guild.findOne({ guildID: guild.id });
|
||||||
|
if (data) return data;
|
||||||
|
return client.config.DEFAULTSETTINGS;
|
||||||
|
};
|
||||||
|
|
||||||
|
client.updateGuild = async (guild, settings) => {
|
||||||
|
let data = await client.getGuild(guild);
|
||||||
|
if (typeof data !== "object") data = {};
|
||||||
|
for (const key in settings) {
|
||||||
|
if (data[key] !== settings[key]) data[key] = settings[key];
|
||||||
|
}
|
||||||
|
return data.updateOne(settings);
|
||||||
|
};
|
||||||
|
|
||||||
|
client.deleteGuild = async guild => {
|
||||||
|
const guilde = await client.getGuild(guild)
|
||||||
|
await guilde.delete()
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
33
util/loader.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
const fs = require("fs");
|
||||||
|
|
||||||
|
//Fonction pour récupérer les fichiers dans les sous-dossier
|
||||||
|
const loadCommands = (client, dir = "./commands/") => {
|
||||||
|
fs.readdirSync(dir).forEach(dirs => {
|
||||||
|
const commands = fs.readdirSync(`${dir}/${dirs}/`).filter(files => files.endsWith(".js"));
|
||||||
|
|
||||||
|
for(const file of commands) {
|
||||||
|
const getFileName = require(`../${dir}/${dirs}/${file}`);
|
||||||
|
client.commands.set(getFileName.help.name, getFileName);
|
||||||
|
console.log(`Commande chargée: ${getFileName.help.name}`);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
//Fonction pour les Events
|
||||||
|
const loadEvents = (client, dir = "./events/") => {
|
||||||
|
fs.readdirSync(dir).forEach(dirs => {
|
||||||
|
const events = fs.readdirSync(`${dir}/${dirs}/`).filter(files => files.endsWith(".js"));
|
||||||
|
|
||||||
|
for(const event of events) {
|
||||||
|
const evt = require(`../${dir}/${dirs}/${event}`);
|
||||||
|
const evtName = event.split(".")[0];
|
||||||
|
client.on(evtName, evt.bind(null, client));
|
||||||
|
console.log(`Evenement chargé: ${evtName}`);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
loadCommands,
|
||||||
|
loadEvents,
|
||||||
|
}
|
22
util/mongoose.js
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
const mongoose = require("mongoose");
|
||||||
|
const { DBCONNECTION } = require("../config");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
init: () => {
|
||||||
|
const mongOptions = {
|
||||||
|
useNewUrlParser: true,
|
||||||
|
useUnifiedTopology: true,
|
||||||
|
useCreateIndex: true,
|
||||||
|
useFindAndModify: false,
|
||||||
|
autoIndex: false, // Don't build indexes
|
||||||
|
poolSize: 10, // Maintain up to 10 socket connections
|
||||||
|
serverSelectionTimeoutMS: 5000, // Keep trying to send operations for 5 seconds
|
||||||
|
socketTimeoutMS: 45000, // Close sockets after 45 seconds of inactivity
|
||||||
|
family: 4 // Use IPv4, skip trying IPv6
|
||||||
|
}
|
||||||
|
|
||||||
|
mongoose.connect(DBCONNECTION, mongOptions);
|
||||||
|
mongoose.Promise = global.Promise;
|
||||||
|
mongoose.connection.on("connected", () => console.log("Mongoose est connecté !"));
|
||||||
|
}
|
||||||
|
}
|