Advertisement
zSpl1nterUS_

Untitled

Apr 5th, 2020
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { Command, Emojis, ClientEmbed } = require("../..");
  2.  
  3. class Sst extends Command {
  4.   constructor(client) {
  5.     super(client, {
  6.       name: "Sst",
  7.       description: "Sistema de bloquear invites de outros discords no seu servidor!",
  8.       usage: { args: true, argsNeed: true, argsTxt: "<antinvite>", need: "{antinvite} {cmd} {args}" },
  9.       category: "sv",
  10.       cooldown: 3000,
  11.       aliases: ["sv"],
  12.       Permissions: [],
  13.       UserPermissions: ["MANAGE_GUILD"],
  14.       needGuild: true
  15.     });
  16.   }
  17.  
  18.   async run({ channel, message, guild, author, args, prefix }, t) {
  19.  
  20.     if (args[0] === 'remover') {
  21.  
  22.       const guild = await this.client.database.guilds.findOne({ _id: message.guild.id }),
  23.         total = message.guild.channels.get(guild.statuscanais.total),
  24.         users = message.guild.channels.get(guild.statuscanais.users),
  25.         bots = message.guild.channels.get(guild.statuscanais.bots)
  26.  
  27.         console.log(total);
  28.        
  29.       if (Number(guild.statuscanais.total) !== 0)
  30.         return total.delete();
  31.       else if (Number(guild.statuscanais.users) !== 0)
  32.         return users.delete();
  33.       else if (Number(guild.statuscanais.bots) !== 0)
  34.         return bots.delete();
  35.  
  36.       await this.client.database.guilds.update(message.guild.id, { $set: { statuscanais: { total: '0', users: '0', bots: '0' } } })
  37.       return;
  38.     }
  39.  
  40.     let doc = await this.client.database.guilds.findOne(message.guild.id);
  41.  
  42.     if (Number(doc.statuscanais.total) !== 0)
  43.       return message.channel.send(`Total users já está ativado`);
  44.  
  45.     if (Number(doc.statuscanais.users) !== 0)
  46.       return message.channel.send(`Users já está ativado`);
  47.  
  48.     if (Number(doc.statuscanais.bots) !== 0)
  49.       return message.channel.send(`Bots já está ativado`);
  50.  
  51.  
  52.     const categ = message.guild.channels.find("name", "📓 Status Servidor 📓");
  53.     if (!categ) {
  54.  
  55.       message.guild.createChannel(`📓 Status Servidor 📓`, {
  56.         type: 'category',
  57.         position: '1',
  58.         permissionOverwrites: [{
  59.           id: guild.id,
  60.           deny: ['CONNECT'],
  61.           allow: ['VIEW_CHANNEL']
  62.         }]
  63.       })
  64.  
  65.     }
  66.  
  67.     if (categ || !categ) {
  68.       channel.send(`Criando os canais...`).then(msg =>
  69.         setTimeout(() => {
  70.           const category = message.guild.channels.find("name", "📓 Status Servidor 📓")
  71.  
  72.           message.guild.createChannel(`Total de Usuários: ${message.guild.members.size}`, "voice").then((createdChan) => {
  73.  
  74.             createdChan.setParent(category).then((settedParent) => {
  75.  
  76.               settedParent.overwritePermissions(message.guild.roles.find('name', "@everyone"), { "CONNECT": false, "VIEW_CHANNEL:": true });
  77.  
  78.             }).catch(err => {
  79.               message.channel.send("Algo deu errado!");
  80.             });
  81.             console.log(createdChan.id)
  82.             return this.client.database.guilds.update({ _id: message.guild.id }, { 'statuscanais.total': `${createdChan.id}` })
  83.  
  84.           }).catch(err => {
  85.             message.channel.send("Algo deu errado!");
  86.           });
  87.  
  88.           message.guild.createChannel(`Membros: ${message.guild.members.filter(a => !a.user.bot).size}`, "voice").then((createdChan2) => {
  89.             createdChan2.setParent(category).then((settedParent) => {
  90.  
  91.               settedParent.overwritePermissions(message.guild.roles.find('name', "@everyone"), { "CONNECT": false, "VIEW_CHANNEL:": true });
  92.  
  93.             }).catch(err => {
  94.               message.channel.send("Algo deu errado!");
  95.             });
  96.             return this.client.database.guilds.update({ _id: message.guild.id }, { 'statuscanais.users': `${createdChan2.id}` })
  97.  
  98.           }).catch(err => {
  99.             message.channel.send("Algo deu errado!");
  100.           });
  101.  
  102.           message.guild.createChannel(`Bots: ${message.guild.members.filter(a => a.user.bot).size}`, "voice").then((createdChan3) => {
  103.             createdChan3.setParent(category).then((settedParent) => {
  104.  
  105.               settedParent.overwritePermissions(message.guild.roles.find('name', "@everyone"), { "CONNECT": false, "VIEW_CHANNEL:": true });
  106.  
  107.             }).catch(err => {
  108.               message.channel.send("Algo deu errado!");
  109.             });
  110.             return this.client.database.guilds.update({ _id: message.guild.id }, { 'statuscanais.bots': `${createdChan3.id}` })
  111.  
  112.           }).catch(err => {
  113.             message.channel.send("Algo deu errado!");
  114.           });
  115.  
  116.         }, 3 * 1000)).then(msg =>
  117.           setTimeout(() => {
  118.  
  119.             channel.send(`${Emojis.Certo} - ${message.author}, canais criados com sucesso!`)
  120.  
  121.           }, 3 * 2000))
  122.     }
  123.   }
  124. }
  125.  
  126. module.exports = Sst;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement