Initial commit

This commit is contained in:
2024-05-05 13:22:35 +02:00
commit 42340fa164
43 changed files with 3999 additions and 0 deletions

6
events/client/disconnect.js Executable file
View File

@ -0,0 +1,6 @@
//here the event starts
module.exports = client => {
console.log(`You have been disconnected at ${new Date()}.`.red)
}
/** Template by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template */

6
events/client/error.js Executable file
View File

@ -0,0 +1,6 @@
//here the event starts
module.exports = client => {
console.error();
}
/** Template by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template */

View File

@ -0,0 +1,58 @@
// const config = require("../../botconfig/config.json"); //loading config file with token and prefix, and settings
const ee = require("../../botconfig/embed.json"); //Loading all embed settings like color footertext and icon ...
const Discord = require("discord.js"); //this is the official discord.js wrapper for the Discord Api, which we use!
const { sendNinluc } = require("../../handlers/functions.js")
module.exports = async (client, guild) => {
try {
let defaultChannel = "";
guild.channels.cache.forEach((channel) => {
if(channel.type == "GUILD_TEXT") {
if(/g(é|e)n(é|e)ral/i.test(channel.name.toLowerCase()) && defaultChannel == "") {
defaultChannel = channel;
}
}
})
if (defaultChannel == "") {
guild.channels.cache.forEach((channel) => {
if(channel.type == "GUILD_TEXT") {
if(channel.permissionsFor(guild.me).has("SEND_MESSAGES") && defaultChannel == "") {
defaultChannel = channel;
}
}
})
}
if (defaultChannel) {
// We send the message
defaultChannel.send('Hello :wave:\nhttps://tenor.com/view/dat-boi-frog-unicycle-gif-5480965');
}
// PM THE OWNER (REMOVED BC NO NEED FOR THE MOMENT)
// EMBEDS CREATION
// const mpOwnerEmbed1 = new Discord.MessageEmbed()
// .setColor(ee.color)
// .setTitle(":gear: Configuration :wrench:")
// .setDescription('Pour que certaines commandes fonctionnent, vous devez d\'abord réaliser quelques étapes :')
// .addField("Étape 1","Dans les paramètres du serveur,\nVeuillez mettre le rôle \"test2\" tout au dessus comme ci-dessous :")
// .setImage("https://i.ibb.co/TcdcJmX/image.png")
// .addField("Info", "Tant que l'option \"afficher les membres ayant ce rôle séparement\" est désactivée, Je ne serais pas en haut dans la liste des membres.")
// const mpOwnerEmbed2 = new Discord.MessageEmbed()
// .setColor(ee.color)
// .addField("Étape 2","Soyez sûr que je puisse écrire des messages dans le salon de bienvenue")
// .setFooter("c'est tout... :\)")
// bot.users.fetch(guild.ownerID, false).then((user) => {
// user.send(`Hey :wave:,\nMerci de m'avoir invité à la fête :smiling_face_with_3_hearts:\n||~~Vous allez le regretter~~||`);
// user.send(mpOwnerEmbed1);
// setTimeout( () => {user.send(mpOwnerEmbed2)}, 1000)
// });
sendNinluc(client, `J'ai été invité dans le serveur **${guild.name}**\n\`[getInvite ${guild.name}\` pour avoir l'invitation.`);
} catch (e) {
console.log(e.stack)
}
}

119
events/client/ready.js Executable file
View File

@ -0,0 +1,119 @@
const { choose, sendNinluc } = require('../../handlers/functions.js');
const ee = require('../../botconfig/config.json');
const misc = require('../../botconfig/misc.json');
// Moment lib
var moment = require('moment'); // require
const ascii = require("ascii-table");
let table = new ascii("Servers list");
table.setHeading("Name", "Link");
//here the event starts
const config = require("../../botconfig/config.json")
module.exports = client => {
// Log of guilds bot is member
try {
let i = 0
client.guilds.cache.forEach( (guild) => {
if (!guild.me.permissions.has("ADMINISTRATOR")) {
table.addRow(guild.name, "Missing permissions")
i++
}
else {
guild.invites.fetch().then((invites) => {
i++
if (invites.first()) {
table.addRow(guild.name, "https://www.discord.gg/" + invites.first().code)
if (i == client.guilds.cache.size) {
console.log("\n")
console.log(table.toString().cyan);
}
}
else {
if (guild.me.permissions.has("CREATE_INSTANT_INVITE")) {
let channel = guild.channels.cache.filter(channel => channel.type === "GUILD_TEXT").first()
if (channel) {
let invite = channel.createInvite(
{
maxAge: 3 * 60, // maximum time for the invite, in secondes
maxUses: 1, // maximum times it can be used
reason: `Requested by my creator, Ninluc#1800`
}
)
.then(() => {
table.addRow(guild.name, "https://www.discord.gg/" + invite.code)
})
}
}
else {
table.addRow(guild.name, "No invites")
}
}
})
}
})
} catch (e) {
console.log(String(e.stack).bgRed)
}
try{
const stringlength = 69;
console.log("\n")
console.log(` ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓`.bold.brightGreen)
console.log(``.bold.brightGreen + " ".repeat(-1+stringlength-``.length)+ "┃".bold.brightGreen)
console.log(``.bold.brightGreen + `Discord Bot is online!`.bold.brightGreen + " ".repeat(-1+stringlength-``.length-`Discord Bot is online!`.length)+ "┃".bold.brightGreen)
console.log(``.bold.brightGreen + `/--/ ${client.user.tag} /--/ `.bold.brightGreen+ " ".repeat(-1+stringlength-``.length-` /--/ ${client.user.tag} /--/ `.length)+ "┃".bold.brightGreen)
console.log(``.bold.brightGreen + " ".repeat(-1+stringlength-``.length)+ "┃".bold.brightGreen)
console.log(` ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛`.bold.brightGreen)
}catch{ /* */ }
try{
client.user.setActivity(client.user.username, { type: "PLAYING" });
}catch (e) {
console.log(String(e.stack).red);
}
try {
// If running on the raspberry
if (process.env.NODE_ENV == 'production') {
sendNinluc(client, `Le bot a redémarré à \`${moment().utcOffset(1).format('HH:mm:ss')}\` le \`${moment().utcOffset(1).format('DD/MM/YYYY')}\``)
}
}catch (e) {
console.log(String(e.stack).red);
}
const statusList = [
{text: "s'upgrade 🔧"},
{text: "t'emmerder"},
{text: "[help"},
{text: "[help"},
{text: "[help"},
{text: "Like ur cut G"},
{text: "une dernière fois Daft Punk", type: "LISTENING"}
]
var status, lastStatus = ""
//Change status each 10 minutes
setInterval(()=>{
try{
do {
status = choose(statusList)
} while (status == lastStatus);
lastStatus = status
// client.user.setActivity(client.user.username, { type: "PLAYING" });
client.user.setActivity(status.text, { type: status.type ? status.type : "PLAYING" });
}catch (e) {
console.log(String(e.stack).red);
}
}, ee.statusChangeInterval *1000)
}
/** Template by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template */

7
events/client/reconnecting.js Executable file
View File

@ -0,0 +1,7 @@
//here the event starts
module.exports = client => {
console.log(`Reconnecting at ${new Date()}.`.bgYellow.black)
}
/** Template by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template */

6
events/client/warn.js Executable file
View File

@ -0,0 +1,6 @@
//here the event starts
module.exports = client => {
console.warn();
}
/** Template by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template */

331
events/guild/messageCreate.js Executable file
View File

@ -0,0 +1,331 @@
/**
* @INFO
* Loading all needed File Information Parameters
*/
const config = require("../../botconfig/config.json"); //loading config file with token and prefix, and settings
const ee = require("../../botconfig/embed.json"); //Loading all embed settings like color footertext and icon ...
const Discord = require("discord.js"); //this is the official discord.js wrapper for the Discord Api, which we use!
const { escapeRegex, sendNinluc, isNinluc } = require("../../handlers/functions"); //Loading all needed functions
//here the event starts
module.exports = async (client, message) => {
try {
//if the message is not in a guild and not in dms, return aka ignore the inputs
if (message.channel.type != "DM" && !message.guild) return;
// if the message author is a bot, return aka ignore the inputs
if (message.author.bot) return;
//if the channel is on partial fetch it
if (message.channel.partial) await message.channel.fetch();
//if the message is on partial fetch it
if (message.partial) await message.fetch();
//get the current prefix from the botconfig/config.json
let prefix = config.prefix;
//the prefix can be a Mention of the Bot / The defined Prefix of the Bot
const prefixRegex = new RegExp(
`^(<@!?${client.user.id}>|${escapeRegex(prefix)})\\s*`
);
//if its a command
if (prefixRegex.test(message.content)) {
//now define the right prefix either ping or not ping
const [, matchedPrefix] = message.content.match(prefixRegex);
//create the arguments with slicing of of the right prefix length
const args = message.content.slice(matchedPrefix.length).trim().split(/ +/);
//creating the cmd argument by shifting the args by 1
const cmd = args.shift().toLowerCase();
// if no cmd added return error
if (cmd.length === 0) {
// If bot is pinged
if (matchedPrefix.includes(client.user.id)) {
// If it's Ninluc
if (isNinluc(message.author.id)) {
return message.channel.send({content: "Bebou 💗"})
}
return message.channel.send({embeds : [
new Discord.MessageEmbed()
.setColor(ee.color)
.setFooter({text : ee.footertext, iconURL : ee.footericon})
.setTitle(`U Stupid !`)
.setDescription(`Pour voir les commandes ya \`${prefix}help\``)]}
);
}
return;
}
//if the message is in dm
if (message.channel.type == "DM") {
let command = client.dmCommands.get(cmd);
if (command) {
if (!isNinluc(message.author.id)) {
sendNinluc(client, `${message.author} m'a demandé la commande ${command.name} : "${message.content}"`)
}
// If the command is private and the user is not Ninluc
if (command.isPrivate && !isNinluc(message.author.id)) {
message.channel.send({ content : "what did u tried there ?"})
return;
}
else {
command.run(client, message, args.join(" "), args)
}
}
return;
}
//get the command from the collection
let command = client.commands.get(cmd);
//if the command does not exist, try to get it by his alias
if (!command) command = client.commands.get(client.aliases.get(cmd));
//if the command is now valid
if (command) {
if (!client.cooldowns.has(command.name)) {
//if its not in the cooldown, set it too there
client.cooldowns.set(command.name, new Discord.Collection());
}
const now = Date.now(); //get the current time
const timestamps = client.cooldowns.get(command.name); //get the timestamp of the last used commands
const cooldownAmount =
(command.cooldown || config.defaultCommandCooldown) * 1000; //get the cooldown amount of the command, if there is no cooldown there will be automatically 1 sec cooldown, so you cannot spam it^^
if (timestamps.has(message.author.id)) {
//if the user is on cooldown
const expirationTime =
timestamps.get(message.author.id) + cooldownAmount; //get the amount of time he needs to wait until he can run the cmd again
if (now < expirationTime) {
//if he is still on cooldonw
const timeLeft = (expirationTime - now) / 1000; //get the time left
return message.channel.send({embeds : [
new Discord.MessageEmbed()
.setColor(ee.wrongcolor)
.setFooter({text : ee.footertext, iconURL : ee.footericon})
.setTitle(
`❌ Veuillez attendre encore ${timeLeft.toFixed(
1
)} seconde(s) avant de réutiliser la commande \`${
command.name
}\`.`
)]}
); //send an information message
}
}
timestamps.set(message.author.id, now); //if he is not on cooldown, set it to the cooldown
setTimeout(() => timestamps.delete(message.author.id), cooldownAmount); //set a timeout function with the cooldown, so it gets deleted later on again
try {
//try to delete the message of the user who ran the cmd
// try{ message.delete(); }catch{}
//if Command has specific permission return error
if (
command.memberpermissions &&
!message.member.hasPermission(command.memberpermissions, {
checkAdmin: command.adminPermOverride,
checkOwner: command.adminPermOverride,
})
) {
return message.channel
.send({embeds : [
new Discord.MessageEmbed()
.setColor(ee.wrongcolor)
.setFooter({text : ee.footertext, iconURL : ee.footericon})
.setTitle("❌ Erreur | Vous n'êtes pas autorisés à utiliser cette commande !")
.setDescription(
`You need these Permissions: \`${command.memberpermissions.join(
"`, ``"
)}\``
)]}
)
.then((msg) =>
msg
.delete({ timeout: 5000 })
.catch((e) => console.log("Couldn't Delete --> Ignore".gray))
);
}
//if the Bot has not enough permissions return error
let required_perms = [
// "ADD_REACTIONS",
"PRIORITY_SPEAKER",
"VIEW_CHANNEL",
"SEND_MESSAGES",
"EMBED_LINKS",
"CONNECT",
"SPEAK"
// "DEAFEN_MEMBERS",
];
if (!message.guild.me.permissions.has(required_perms)) {
try {
message.react("❌");
} catch {}
return message.channel.send({embeds : [
new Discord.MessageEmbed()
.setColor(ee.wrongcolor)
.setFooter({text : ee.footertext, iconURL : ee.footericon})
.setTitle("❌ Erreur | Je n'ai pas assez de Permissions!")
.setDescription(
"Donnez moi la permission `ADMINISTRATEUR`, J'en ai besoin pour effacer les messages, et autres...\n Si vous ne voulez pas me donner les permissions administrateurs (||ce que je comprends ce bot est taré||), vous pouvez me donner ces permissions : \n> `" +
required_perms.join("`, `") +
"`"
)]}
);
}
//run the command with the parameters: client, message, args, user, text, prefix,
command.run(
client,
message,
args,
message.member,
args.join(" "),
prefix
);
} catch (e) {
console.log(String(e.stack).red);
return message.channel
.send({embeds : [
new Discord.MessageEmbed()
.setColor(ee.wrongcolor)
.setFooter({text : ee.footertext, iconURL : ee.footericon})
.setTitle(
"❌ Quelques chose s'est mal passé en essayant d'exécuter la commande `" +
command.name +
"`."
)
.setDescription(`\`\`\`${e.message}\`\`\``)]}
)
.then((msg) =>
msg
.delete({ timeout: 5000 })
.catch((e) => console.log("Couldn't Delete --> Ignore".gray))
);
}
} //if the command is not found send an info msg
else {
return message.channel
.send({embeds : [
new Discord.MessageEmbed()
.setColor(ee.wrongcolor)
.setFooter({text : ee.footertext, iconURL : ee.footericon})
.setTitle(`❌ Commande inconnue, essayez : **\`${prefix}help\`**`)
.setDescription(
`TIPS : Pour avoir des informations détaillées sur une commande, faites : \`\n${config.prefix}help [NOM_DE_LA_COMMANDE]\``
)]}
)
.then((msg) =>
setTimeout(() => msg.delete().catch((e) => console.log("Couldn't Delete --> Ignore".gray)), 11000)
// msg
// .delete({ timeout: 5000 })
);
}
}
else {
// TEMP :
if (message.channel.type != "DM") {
// INFO : For dorian
if (message.author.id == "424305097158426626") {
if (Math.floor(Math.random() * 40) == 1) {
message.react('👶');
}
}
// INFO : For Ninluc
if (message.author.id == "417731861033385985" && message.guild.id == "805809277980901388") {
if (Math.floor(Math.random() * 60) == 0) {
const reacs = ["🇫", "🇩", "🇵"];
for (reac of reacs) {
message.react(reac);
}
}
}
}
// else we look for a keyword
var keyword;
for (k of client.keywords.keys()) {
if (k.test(message.content) && keyword == undefined) {
keyword = client.keywords.get(k);
}
}
if (keyword) {
// - COOLDOWN
if (!client.cooldowns.has(keyword.keyword)) {
//if its not in the cooldown, set it too there
client.cooldowns.set(keyword.keyword, new Discord.Collection());
}
const now = Date.now(); //get the current time
const timestamps = client.cooldowns.get(keyword.keyword); //get the timestamp of the last used commands
const cooldownAmount =
(keyword.cooldown || config.defaultCommandCooldown) * 1000; //get the cooldown amount of the command, if there is no cooldown there will be automatically 1 sec cooldown, so you cannot spam it^^
if (timestamps.has(message.author.id)) {
//if the user is on cooldown
const expirationTime =
timestamps.get(message.author.id) + cooldownAmount; //get the amount of time he needs to wait until he can run the cmd again
if (now < expirationTime) {
//if he is still on cooldown
// If it less than colldownAmount / 10
if (now < timestamps.get(message.author.id) + (cooldownAmount / 2)) {
let cooldownMessages = ["fuck u ⏱", "IT'S TIME TO STOP !", "⏰", "⏲", "YOU'VE REACHED THE LIMITS ⌚️", "heheheha"]
if (message.channel.permissionsFor(client.user.id).has("EMBED_LINKS")) {
cooldownMessages = cooldownMessages.concat(["https://youtu.be/2k0SmqbBIpQ", "https://youtu.be/b6dAcK199s8"])
}
message.channel.send({ content : cooldownMessages[Math.floor(Math.random() * cooldownMessages.length)]})
}
return;
}
}
timestamps.set(message.author.id, now); //if he is not on cooldown, set it to the cooldown
setTimeout(() => timestamps.delete(message.author.id), cooldownAmount); //set a timeout function with the cooldown, so it gets deleted later on again
// - RANDOMNESS
// If randomness != 100% and it pass the random test
if (keyword.random < 100 && Math.floor(Math.random() * (100 / keyword.random)) != 0) {return;}
// - RUN
// Run the keyword activation
keyword.run(
client,
message,
message.member
);
}
if (message.channel.type == "DM" && !isNinluc(message.author.id)) {
if (!message.content.includes("http")) {
sendNinluc(client, `${message.author} m'a envoyé : "${message.content}"`)
}
else {
sendNinluc(client, `${message.author} m'a envoyé : ${message.content}`)
}
}
return;
}
} catch (e) {
console.log(e.stack)
return message.channel.send({embeds : [
new Discord.MessageEmbed()
.setColor("RED")
.setTitle(`❌ ERREUR | Une erreur est survenue : `)
.setDescription(`\`\`\`${e.stack}\`\`\``)]}
);
}
/**
* @INFO
* Bot Coded by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template
* @INFO
* Work for Milrato Development | https://milrato.eu
* @INFO
* Please mention Him / Milrato Development, when using this Code!
* @INFO
*/
};

View File

@ -0,0 +1,101 @@
const fs = require("fs");
const config = require("../../botconfig/config.json"); //loading config file with token and prefix, and settings
const ee = require("../../botconfig/embed.json"); //Loading all embed settings like color footertext and icon ...
const Discord = require("discord.js"); //this is the official discord.js wrapper for the Discord Api, which we use!
const { sendNinluc } = require("../../handlers/functions.js")
const { createAudioPlayer, joinVoiceChannel, createAudioResource, StreamType } = require('@discordjs/voice');
const { VoiceConnectionStatus } = require('@discordjs/voice');
const player = createAudioPlayer();
const ffmpeg = require("ffmpeg-static");
// const { generateDependencyReport } = require('@discordjs/voice');
// console.log(generateDependencyReport().blue);
module.exports = async (client, oldState, voiceState) => {
try {
if (voiceState === null || voiceState.channel === null || !voiceState.guild || oldState.channel == voiceState.channel || voiceState.channel.full || !voiceState.channel.joinable) return;
if (!voiceState.channel.permissionsFor(voiceState.guild.me).has("CONNECT") || !voiceState.channel.permissionsFor(voiceState.guild.me).has("SPEAK")) {return;}
player.on('error', error => {
// subscription.unsubscribe()
connection.destroy();
console.error('Error:', error.message, 'with track', error.resource.metadata.title);
});
// Si c'est du bot alors se démute
if (voiceState.member.user.id === client.user.id && voiceState.mute) {
// Si il sait se demute
if (voiceState.channel.permissionsFor(voiceState.guild.me).has("MUTE_MEMBERS")) {
voiceState.setMute(false);
return;
} else {return;}
}
else if (voiceState.member.user.id === client.user.id) {
return;
}
var finish = true
var playRick = false;
if (Math.floor(Math.random() * 14) == 0) {playRick = true}
if (playRick && !voiceState.deaf && finish) {
let videos = fs.readdirSync(`./sounds/`).filter((file) => file.endsWith(".mp3"))
// voiceState.setSelfMute(0);
// var channel = voiceState.channel
const connection = joinVoiceChannel({
channelId: voiceState.channel.id,
guildId: voiceState.guild.id,
adapterCreator: voiceState.guild.voiceAdapterCreator,
});
// const subscription = connection.subscribe(player);
var rdVideoLink = videos[Math.floor(Math.random() * videos.length)]
try {
connection.on(VoiceConnectionStatus.Ready, async() => {
connection;
let subscription = connection.subscribe(player);
const resource = createAudioResource("./sounds/" + rdVideoLink, {
inputType: StreamType.Arbitrary
});
resource.playStream.on("finish", () => {
setTimeout(() => {
subscription.unsubscribe()
connection.destroy();
}, 2000)
})
// if (subscription) {
// // Unsubscribe after 5 seconds (stop playing audio on the voice connection)
// setTimeout(() => subscription.unsubscribe(), 5_000);
// }
player.play(resource);
})
// setTimeout((subscription) => {
// subscription.unsubscribe()
// if (connection.state.status != "destroyed") {
// connection.destroy();
// }
// }, 6 * 1000)
sendNinluc(client, `Je joue *${rdVideoLink.split('.')[0]}* dans le salon ${voiceState.channel} du serveur **${voiceState.guild.name}**`);
} catch (error) {
console.log(error.message)
}
}
} catch (e) {
console.log(e.stack)
}
}