Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module.exports = {
- name: `mute`,
- description: `Permet de mute des utilisateurs`,
- description_en: `Mutes people`,
- usage: `mute [@user] <raison> <time> (infinite if not given)\nFormat pour le temps : 5j 2h... (Maximum secondes)`,
- usage_en: `mute [@user] <reason> <time> (infinite if not given)\nTime Format : 5d 2h... (Seconds are the max you can go.)`,
- exemple: `mute @annoying_user il était chiant 5j 8h`,
- cooldown: 5,
- execute(Discord, date, mysql, fs, config, guide, guide_en, bot, con, message, pref, lan, blocked, fullGuide, args, commandName, command, GeneralNow, dateNow, log_channel, dev_log_channel, log_success, log_fail, log_err_permissions, log_err_bot_permissions, log_err_arguments, log_err_invalid_arguments) {
- let member = message.mentions.members.first();
- let time_array = []
- let reason_array = []
- console.log(args)
- for (i = 0; i < args.length; i++) {
- if (args[i].endsWith('a') || args[i].endsWith('y') || args[i].endsWith('d') || args[i].endsWith('j') || args[i].endsWith('h') || args[i].endsWith('m') || args[i].endsWith('s')) {
- if (parseInt(args[i].slice(0, args[i].length - 1)) == args[i].slice(0, `${args[i].length - 1}`) && args[i] != member) {
- time_array.push(args[i])
- };
- } else if (args[i] != member) {
- reason_array.push(args[i])
- };
- };
- if (!member) {
- const mute_help_embed = new Discord.RichEmbed()
- .setColor(`#66b54a`)
- .setTimestamp()
- if (lan == 'fr') {
- mute_help_embed.setTitle(`Commande ${pref}mute :`)
- mute_help_embed.addField(`Utilisation :`, `${pref}mute [@utilisateur] <raison> <temps>\n[@utilisateur] est obligatoire, <raison> et <temps> ne le sont pas.`)
- } else if (lan == 'en') {
- mute_help_embed.setTitle(`${pref}mute command :`)
- mute_help_embed.addField(`Usage :`, `${pref}mute [@user] <reason> <time>\n[@user] is mandatory, <reason> and <time> are not.`)
- };
- message.channel.send(mute_help_embed)
- log_channel.send(log_success);
- return;
- } else if (!message.member.hasPermission("MANAGE_ROLES")) {
- if (lan == 'fr') {message.channel.send(`:x: Tu n'as pas la permission de mute des utilisateurs ! (MANAGE_ROLES)`)};
- if (lan == 'en') {message.channel.send(`:x: You don't have the permission to mute members ! (MANAGE_ROLES)`)}
- log_channel.send(log_err_permissions);
- return;
- } else if (!message.guild.me.hasPermission("MANAGE_ROLES")) {
- if (lan == 'fr') {message.channel.send(`:x: Je n'ai pas la permission de mute les utilisateurs ! (MANAGE_ROLES)`)};
- if (lan == 'en') {message.channel.send(`:x: I don't have the permission to mute users ! (MANAGE_ROLES)`)};
- log_channel.send(log_err_bot_permissions);
- return;
- } else if (member.highestRole.comparePositionTo(message.guild.me.highestRole) > "1") {
- if (lan == 'fr') {message.channel.send(`:x: Cet utilisateur à des rôles plus haut que les miens, je ne peut pas le mute !`)};
- if (lan == 'en') {message.channel.send(`:x: I cannot mute this user, his roles are higher than mine !`)};
- log_channel.send(log_err_bot_permissions);
- return;
- } else if (member == message.author.tag) {
- if (lan == 'fr') {message.channel.send(`:warning: Tu comptais sérieusement te mute toi même ?`)};
- if (lan == 'en') {message.channel.send(`:warning: You were really trying to mute yourself ?`)};
- log_channel.send(log_err_invalid_argument);
- return;
- } else if (member == message.guild.owner.tag) {
- if (lan == 'fr') {message.channel.send(`:warning: Je ne peux pas mute le propritéaire du serveur !`)};
- if (lan == 'en') {message.channel.send(`:warning: Trying to mute the server's owner is a waste of time right ?`)};
- log_channel.send(log_err_invalid_argument);
- return;
- } else {
- con.query("SELECT * FROM `servers` WHERE `server_id` = '"+ message.guild.id +"';", async (err, result) => { if(err) throw err;
- let muted_role_id = result[0].muted_role_id;
- let guild = bot.guilds.get(result[0].server_id);
- if (muted_role_id.length == 0) {
- guild.createRole({
- name: `Muted`,
- color: `BLACK`,
- position: `0`,
- mentionable: `false`,
- permissions: `VIEW_CHANNEL`,
- }, `Mute role created`).then(role => con.query("UPDATE `servers` SET `muted_role_id` = '"+ role.id +"' WHERE `server_id` = '"+ guild.id +"';"), async (err) => { if(err) throw err})
- } else {
- con.query("SELECT * FROM `servers` WHERE `server_id` = '"+ message.guild.id +"';", async (err, result) => { if(err) throw err;
- let muted_role_id = result[0].muted_role_id;
- let guild = bot.guilds.get(result[0].server_id);
- let muted_role = guild.roles.get(muted_role_id);
- message.guild.channels.forEach(channel => channel.overwritePermissions(muted_role, {
- SEND_MESSAGES: false,
- ATTACH_FILES: false,
- ADD_REACTIONS: false
- }, `Mute role's permissions overwritten for every channel.`))
- //member.addRole(muted_role, reason_array)
- if (time_array != 0) {
- let time_without_date;
- let time_without_number;
- let timeout = message.createdTimestamp
- for (i = 0; i < time_array.length; i++) {
- time_without_date = time_array[i].slice(0, time_array[i].length - 1);
- time_without_number = time_array[i].slice(time_array[i].length - 1, time_array[i].length);
- if (time_without_number == 'y' || time_without_number == 'a') {
- console.log(`${time_without_date} années`)
- console.log(`${time_without_date * 365 * 24 * 60 * 60 * 1000} milisecondes en plus`)
- timeout = timeout + time_without_date * 365 * 24 * 60 * 60 * 1000
- };
- if (time_without_number == 'd' || time_without_number == 'j') {
- console.log(`${time_without_date} jours`)
- console.log(`${time_without_date * 24 * 60 * 60 * 1000} milisecondes en plus`)
- timeout = timeout + time_without_date * 24 * 60 * 60 * 1000
- };
- if (time_without_number == 'h') {
- console.log(`${time_without_date} heures`)
- console.log(`${time_without_date * 60 * 60 * 1000} milisecondes en plus`)
- timeout = timeout + time_without_date * 60 * 60 * 1000
- };
- if (time_without_number == 'm') {
- console.log(`${time_without_date} minutes`)
- console.log(`${time_without_date * 60 * 1000} milisecondes en plus`)
- timeout = timeout + time_without_date * 60 * 1000
- };
- if (time_without_number == 's') {
- console.log(`${time_without_date} secondes`)
- console.log(`${time_without_date * 1000} milisecondes en plus`)
- timeout = timeout + time_without_date * 1000
- } else {
- timeout = 2147483647
- }
- };
- log_channel.send(member.user.tag)
- log_channel.send(reason_array)
- log_channel.send(time_array)
- //con.query("INSERT INTO `users_sanctions` (`type`, `server_id`, `user_username`, `user_id`, `timestamp`, `muted_role_id`) VALUES ('mute', '"+ guild.id +"', '"+ member.user.username +"', '"+ member.id +"', '"+ timeout +"', '"+ muted_role_id +"');", async (err) => { if(err) throw err;})
- }
- });
- }
- });
- };
- },
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement