Advertisement
rama0dev

bot

Dec 5th, 2020
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const fs = require("fs");
  2. FFMPEG = require('ffmpeg');
  3. const ms = require("ms");
  4. const weather = require('weather-js')
  5. const Discord = require("discord.js");
  6. const client = new Discord.Client();
  7. const active = new Map();
  8. const ytdl = require('ytdl-core');
  9. const search = require('yt-search');
  10. const configs = require("./configs.json");
  11. const timestamp = require("console-timestamp");
  12. var botConfigs = {
  13.     token: "думал токен дам? неа",
  14.     prefix: "/",
  15.     gameStatus: "vtrand.ru | /vt",
  16.     statusType: "LISTENING",
  17.     commands: [
  18.     {
  19.         "id": 1,
  20.         "command": "inv",
  21.         "message": "http://vtrand-bot.ga/",
  22.         "embed": false
  23.     },
  24.     {
  25.         "id": 2,
  26.         "command": "vt",
  27.         "message": "",
  28.         "embed": true,
  29.         "embedFields": [
  30.             {
  31.                 "title": "ВТренде",
  32.                 "text": "Команды:"
  33.             }
  34.         ]
  35.     },
  36.     {
  37.         "id": 3,
  38.         "command": "vt",
  39.         "message": "",
  40.         "embed": true,
  41.         "embedFields": [
  42.             {
  43.                 "title": "Музыка:",
  44.                 "text": "(Поддерживается только YouTube)"
  45.             }
  46.         ]
  47.     },
  48.     {
  49.         "id": 4,
  50.         "command": "vt",
  51.         "message": "",
  52.         "embed": true,
  53.         "embedFields": [
  54.             {
  55.                 "title": "/play",
  56.                 "text": "Воспроизвести трек."
  57.             },
  58.             {
  59.                 "title": "/leave",
  60.                 "text": "Покинуть канал."
  61.             }
  62.         ]
  63.     },
  64.     {
  65.         "id": 5,
  66.         "command": "vt",
  67.         "message": "",
  68.         "embed": true,
  69.         "embedFields": [
  70.             {
  71.                 "title": "/pause",
  72.                 "text": "Поставить на паузу."
  73.             },
  74.             {
  75.                 "title": "/resume",
  76.                 "text": "Продолжить воспроизведение."
  77.             },
  78.             {
  79.                 "title": "/queue",
  80.                 "text": "Очередь."
  81.             },
  82.             {
  83.                 "title": "/skip",
  84.                 "text": "Пропустить песню."
  85.             }
  86.         ]
  87.     },
  88.     {
  89.         "id": 6,
  90.         "command": "vt",
  91.         "message": "",
  92.         "embed": true,
  93.         "embedFields": [
  94.             {
  95.                 "title": "Погода:",
  96.                 "text": "(Вы можете смотерть какая погода у вас в городе,и у ваших друзей)"
  97.             }
  98.         ]
  99.     },
  100.     {
  101.         "id": 7,
  102.         "command": "vt",
  103.         "message": "",
  104.         "embed": true,
  105.         "embedFields": [
  106.             {
  107.                 "title": "/weather Город",
  108.                 "text": "Погода в городе в данный момент"
  109.             }
  110.         ]
  111.     },
  112. ],
  113.     plugins: [
  114.     {
  115.         "id": 0,
  116.         "name": "Purge messages",
  117.         "activated": false,
  118.         "config": "",
  119.         "info": {
  120.             "example": "!purge 20",
  121.             "note": "",
  122.             "requirements": "Create a logs channel"
  123.         }
  124.     },
  125.     {
  126.         "id": 1,
  127.         "name": "Welcome message",
  128.         "activated": false,
  129.         "config": "welcomemessage",
  130.         "info": {
  131.             "example": "",
  132.             "note": "",
  133.             "requirements": "Create a channel"
  134.         }
  135.     },
  136.     {
  137.         "id": 2,
  138.         "name": "Kick user",
  139.         "activated": false,
  140.         "config": "",
  141.         "info": {
  142.             "example": "!kick @user spam",
  143.             "note": "",
  144.             "requirements": "Create a logs channel"
  145.         }
  146.     },
  147.     {
  148.         "id": 3,
  149.         "name": "Ban user",
  150.         "activated": false,
  151.         "config": "",
  152.         "info": {
  153.             "example": "!ban @user spam",
  154.             "note": "",
  155.             "requirements": "Create a logs channel"
  156.         }
  157.     },
  158.     {
  159.         "id": 4,
  160.         "name": "Report user",
  161.         "activated": false,
  162.         "config": "",
  163.         "info": {
  164.             "example": "!report @user spam",
  165.             "note": "",
  166.             "requirements": "Create a logs channel"
  167.         }
  168.     },
  169.     {
  170.         "id": 5,
  171.         "name": "Temp mute user",
  172.         "activated": false,
  173.         "config": "",
  174.         "info": {
  175.             "example": "!tempmute @user 10s",
  176.             "note": "s = seconds, m = minutes, h = hours",
  177.             "requirements": "Create a logs channel"
  178.         }
  179.     },
  180.     {
  181.         "id": 6,
  182.         "name": "Server info",
  183.         "activated": true,
  184.         "config": "",
  185.         "info": {
  186.             "example": "!serverinfo",
  187.             "note": "",
  188.             "requirements": ""
  189.         }
  190.     },
  191.     {
  192.         "id": 7,
  193.         "name": "Weather info",
  194.         "activated": true,
  195.         "config": "weather",
  196.         "info": {
  197.             "example": "!weather Copenhagen",
  198.             "note": "",
  199.             "requirements": ""
  200.         }
  201.     },
  202.     {
  203.         "id": 8,
  204.         "name": "Music - Export only",
  205.         "activated": true,
  206.         "config": "",
  207.         "info": {
  208.             "example": "!play {YouTube URL}, !leave, !pause, !resume, !queue, !skip",
  209.             "note": "Export only",
  210.             "requirements": ""
  211.         }
  212.     },
  213.     {
  214.         "id": 9,
  215.         "name": "Channel lockdown",
  216.         "activated": false,
  217.         "config": "",
  218.         "info": {
  219.             "example": "!lockdown 10s",
  220.             "note": "s = seconds, m = minutes, h = hours",
  221.             "requirements": ""
  222.         }
  223.     },
  224.     {
  225.         "id": 10,
  226.         "name": "Shutdown command",
  227.         "activated": false,
  228.         "config": "",
  229.         "info": {
  230.             "example": "!shutdown",
  231.             "note": "",
  232.             "requirements": ""
  233.         }
  234.     },
  235.     {
  236.         "id": 11,
  237.         "name": "Banned words",
  238.         "activated": false,
  239.         "config": "bannedwords",
  240.         "info": {
  241.             "example": "",
  242.             "note": "Auto delete messages contained banned words",
  243.             "requirements": ""
  244.         }
  245.     },
  246.     {
  247.         "id": 12,
  248.         "name": "Ticket system",
  249.         "activated": false,
  250.         "config": "ticketSystem",
  251.         "info": {
  252.             "example": "!ticket I cant find Bob",
  253.             "note": "",
  254.             "requirements": "You need a channel to create tickets called: create-ticket, support or something like that."
  255.         }
  256.     },
  257.     {
  258.         "id": 13,
  259.         "name": "DM message",
  260.         "activated": false,
  261.         "config": "",
  262.         "info": {
  263.             "example": "!dm <@user or ID> Message",
  264.             "note": "!dm @zit_x_us#9951 Hello!",
  265.             "requirements": ""
  266.         }
  267.     },
  268.     {
  269.         "id": 14,
  270.         "name": "Dice",
  271.         "activated": false,
  272.         "config": "",
  273.         "info": {
  274.             "example": "!dice",
  275.             "note": "Will return a random number between 1 and 6",
  276.             "requirements": ""
  277.         }
  278.     },
  279.     {
  280.         "id": 15,
  281.         "name": "Warn",
  282.         "activated": false,
  283.         "config": "",
  284.         "info": {
  285.             "example": "!Warn @zit_x_us#9951",
  286.             "note": "Warns a user",
  287.             "requirements": "Create a logs channel"
  288.         }
  289.     },
  290.     {
  291.         "id": 16,
  292.         "name": "Advanced Help",
  293.         "activated": false,
  294.         "config": "",
  295.         "info": {
  296.             "example": "!help",
  297.             "note": "",
  298.             "requirements": ""
  299.         }
  300.     },
  301.     {
  302.         "id": 17,
  303.         "name": "Coin Flip",
  304.         "activated": false,
  305.         "config": "",
  306.         "info": {
  307.             "example": "!flip",
  308.             "note": "",
  309.             "requirements": ""
  310.         }
  311.     },
  312.     {
  313.         "id": 18,
  314.         "name": "Announcement",
  315.         "activated": true,
  316.         "config": "",
  317.         "info": {
  318.             "example": "!announce {#channel} {COLOR} {TITLE} {MESSAGE CAN BE LIKE THIS}",
  319.             "note": "",
  320.             "requirements": ""
  321.         }
  322.     },
  323.     {
  324.         "id": 19,
  325.         "name": "Auto role",
  326.         "activated": false,
  327.         "config": "autorole",
  328.         "info": {
  329.             "example": "",
  330.             "note": "Gives the joining user a role",
  331.             "requirements": ""
  332.         }
  333.     }
  334. ],
  335.     welcomemessage: {
  336.     "channelid": "",
  337.     "text": ""
  338. },
  339.     weather: {
  340.     "degree": "C"
  341. },
  342.     autorole: {
  343.     "guildID": "",
  344.     "autoroleID": ""
  345. },
  346.     ticketsystem: {
  347.     "ticketCategoryID": "",
  348.     "createTicketChannelID": ""
  349. },
  350.     gif: "BOT_GIF"
  351. };
  352.  
  353. console.log("|  Loading Scripts ");
  354.  
  355. var ops = {
  356.     active: active
  357. }
  358.  
  359. client.on("ready", async function() {
  360.     if (botConfigs.statusType === "PLAYING" || botConfigs.statusType === "WATCHING" || botConfigs.statusType === "LISTENING") {
  361.         client.user.setActivity(botConfigs.gameStatus, { type: botConfigs.statusType });
  362.     } else {
  363.         client.user.setActivity(botConfigs.gameStatus, { type: "PLAYING" });
  364.     }
  365. });
  366.  
  367. client.on("guildCreate", async function() {
  368.     if (botConfigs.statusType === "PLAYING" || botConfigs.statusType === "WATCHING" || botConfigs.statusType === "LISTENING") {
  369.         client.user.setActivity(botConfigs.gameStatus, { type: botConfigs.statusType });
  370.     } else {
  371.         client.user.setActivity(botConfigs.gameStatus, { type: "PLAYING" });
  372.     }
  373. });
  374.  
  375. client.on("guildDelete", async function(guild) {
  376.     if (botConfigs.statusType === "PLAYING" || botConfigs.statusType === "WATCHING" || botConfigs.statusType === "LISTENING") {
  377.         client.user.setActivity(botConfigs.gameStatus, { type: botConfigs.statusType });
  378.     } else {
  379.         client.user.setActivity(botConfigs.gameStatus, { type: "PLAYING" });
  380.     }
  381. });
  382.  
  383. client.on("guildMemberAdd", async function(member) {
  384.     if (botConfigs.plugins[1].activated == true) {
  385.         member.guild.channels
  386.             .get(botConfigs.welcomemessage.channelid)
  387.             .send(`${member}, ${botConfigs.welcomemessage.text}`);
  388.     }
  389. });
  390.  
  391.  
  392. client.on('guildMemberAdd', async function (member) {
  393.     if (botConfigs.plugins[19].activated == true) {
  394.        
  395.        if (member.guild.id == botConfigs.autorole.guildID) {
  396.        member.addRole(botConfigs.autorole.autoroleID);
  397.        }
  398.     }
  399. });
  400.  
  401.  
  402. client.on("message", async function (message) {
  403.     if (botConfigs.plugins[11].activated == true) {
  404.         //if (botConfigs.bannedwords.channelid.length > 0) {
  405.             configs.bannedWords.forEach(async function (element) {
  406.                 let msg = message.content.toLowerCase();
  407.                 if (msg.includes(element)) {
  408.                     message.delete().catch(O_o => { });
  409.                     let projectData = await botConfigs;
  410.                     let Dmchannel = client.users.get(message.author.id);
  411.                         if (!Dmchannel) {
  412.                             return;
  413.                         }
  414.                    
  415.                     Dmchannel.send(projectData.bannedwords.responseMessage);
  416.                     let pjc = projectData.bannedwords.channelid;
  417.  
  418.                     if (pjc == "" || pjc == null || pjc == undefined) {
  419.                         return;
  420.                     }
  421.                     if (botConfigs.bannedwords.channelid.length > 10) {
  422.                    let CH = client.channels.get(pjc).catch(O => {})
  423.                         let embed = new Discord.RichEmbed()
  424.                         .setDescription("~Banned word~")
  425.                         .setColor("#e56b00")
  426.                         .addField("Message: ", `${msg}`)
  427.                         .addField("Send By", `<@${message.author.id}> with ID ${message.author.id}`)
  428.                         .addField("Sent In", message.channel)
  429.                         .addField("Time", message.createdAt);
  430.                          CH.send(embed);
  431.                 }
  432.             }
  433.         })
  434.     }
  435.  
  436.     let prefix = botConfigs.prefix;
  437.  
  438.     if (message.author.bot) return;
  439.  
  440.     if (message.content.indexOf(prefix) !== 0) return;
  441.  
  442.     const args = message.content
  443.         .slice(prefix.length)
  444.         .trim()
  445.         .split(/ +/g);
  446.     const command = args.shift().toLowerCase();
  447.  
  448.     if (command === "purge" && botConfigs.plugins[0].activated == true) {
  449.         if (!message.member.hasPermission("MANAGE_MESSAGES")) return message.channel.send("You don't have permission!");
  450.         const deleteCount = parseInt(args[0], 10);
  451.  
  452.         let embed = new Discord.RichEmbed()
  453.             .setDescription("~Purge~")
  454.             .setColor("#e56b00")
  455.             .addField("Messages: ", `${deleteCount}`)
  456.             .addField("Purged By", `<@${message.author.id}> with ID ${message.author.id}`)
  457.             .addField("Purged In", message.channel)
  458.             .addField("Time", message.createdAt);
  459.  
  460.         //let channel = message.guild.channels.find(`name`, "logs");
  461.         let channel = message.guild.channels.find(ch => ch.name === 'logs');
  462.         if (!channel) {
  463.             message.channel.send("Can't find a 'logs' channel.");
  464.             return;
  465.         }
  466.  
  467.         if (!deleteCount || deleteCount < 2 || deleteCount > 100) {
  468.             message.channel.send("Example: " + prefix + "purge 10");
  469.             message.channel.send("Please enter a number between 2 and 100");
  470.             return;
  471.         }
  472.  
  473.         const fetched = await message.channel.fetchMessages({ limit: deleteCount });
  474.         channel.send(embed);
  475.         message.channel
  476.             .bulkDelete(fetched)
  477.             .catch(error => message.reply("Error. Contact an administrator."));
  478.     }
  479.  
  480.     if (command === "kick" && botConfigs.plugins[2].activated == true) {
  481.         let bUser = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
  482.         if (!bUser) return message.channel.send("Can't find user!");
  483.         let bReason = args.join(" ").slice(22);
  484.         if (!message.member.hasPermission("KICK_MEMBERS")) return message.channel.send("You don't have permission!");
  485.         if (bUser.hasPermission("ADMINISTRATOR")) return message.channel.send("That person can't be kicked")
  486.  
  487.  
  488.         let banEmbed = new Discord.RichEmbed()
  489.             .setDescription("~Kick~")
  490.             .setColor("#bc0000")
  491.             .addField("Kicked User", `${bUser} with ID ${bUser.id}`)
  492.             .addField("Kicked By", `<@${message.author.id}> with ID ${message.author.id}`)
  493.             .addField("Kicked In", message.channel)
  494.             .addField("Time", message.createdAt)
  495.             .addField("Reason", bReason);
  496.  
  497.         //let incidentchannel = message.guild.channels.find(`name`, "logs");
  498.         let channel = message.guild.channels.find(ch => ch.name === 'logs');
  499.         if (!channel) {
  500.             message.channel.send("Can't find a 'logs' channel.");
  501.             return;
  502.         }
  503.  
  504.         message.guild.member(bUser).kick(bReason);
  505.         channel.send(banEmbed);
  506.     }
  507.    
  508.     if(command === 'temprole' && botConfigs.plugins[21].activated == true) {
  509.    
  510.     if(!message.member.hasPermission('MANAGE_ROLES')) return message.reply('You do not have required permission');
  511.    
  512.     if(!message.guild.members.get(client.user.id).hasPermission('MANAGE_ROLES')) return message.reply("I don't have `MANAGE ROLES` Permission")
  513.    
  514.     if(!args[0]) return message.reply('You should spcefic [User] [Role] [Time]');
  515.    
  516.     let user = message.mentions.members.first() || message.guild.members.get(args[0]);
  517.    
  518.     if(!user) return  message.reply('You Should Mention User or User ID');
  519.    
  520.     let role = message.mentions.roles.first() || message.guild.roles.get(args[1]);
  521.    
  522.     if(!role) return message.reply('You Should Mention Role or Role ID');
  523.    
  524.     if(user.roles.has(role.id)) return message.reply(`This User ${user.user.tag} Already Have \`${role.name}\` Role`)
  525.    
  526.     let time = ms(args[2]);
  527.    
  528.     if(!time) return message.reply('Spcefic Time');
  529.    
  530.     let channel = message.guild.channels.find(ch => ch.name === 'logs');
  531.    
  532.     if(!channel) return message.reply("Can't find a **`logs`** channel.");
  533.    
  534.     try {
  535.       await user.addRole(role.id);
  536.       channel.send(
  537.         new Discord.RichEmbed()
  538.           .setTitle("~ Temporary Role Added ~")
  539.           .setColor(0x00e676)
  540.           .addField('Added By?', message.author.tag + `(${message.member})`)
  541.           .addField('Role', role)
  542.           .addField('Added To?', user.user.tag + (`${user.user}`))
  543.           .addField('Duration', ms(time))
  544.           .setThumbnail(user.user.displayAvatarURL)
  545.       ).then(() => {
  546.         message.reply(`Role **\`${role.name}\`** Added To ${user.user.tag}(${user.user}) For ${ms(time)}`).then(m => {
  547.           m.delete(5000)
  548.         })
  549.       });
  550.     } catch(e) {
  551.       message.reply(`Unexpected Error: ${e.message}`);
  552.     }
  553.    
  554.     setTimeout(async () => {
  555.       if(!user.roles.has(role.id)) return;
  556.         await user.removeRole(role.id);
  557.         channel.send(
  558.           new Discord.RichEmbed()
  559.           .setTitle("~ Role Removed ~")
  560.           .setColor(0xff5252)
  561.           .addField('Removed By?', client.user + ' (Bot)')
  562.           .addField('Role', role)
  563.           .addField('Removed From?', user.user.tag + (`${user.user}`))
  564.           .addField('Reason', "Time's up")
  565.           .setThumbnail(user.user.displayAvatarURL)
  566.         )
  567.     }, time)
  568.    
  569.   }
  570.    
  571.     if (command === "ban" && botConfigs.plugins[3].activated == true) {
  572.         let bUser = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
  573.         if (!bUser) return message.channel.send("Can't find user!");
  574.         let bReason = args.join(" ").slice(22);
  575.         if (!message.member.hasPermission("BAN_MEMBERS")) return message.channel.send("You don't have permission!");
  576.         if (bUser.hasPermission("ADMINISTRATOR")) return message.channel.send("That person can't be banned")
  577.  
  578.  
  579.         let banEmbed = new Discord.RichEmbed()
  580.             .setDescription("~Ban~")
  581.             .setColor("#bc0000")
  582.             .addField("Banned User", `${bUser} with ID ${bUser.id}`)
  583.             .addField("Banned By", `<@${message.author.id}> with ID ${message.author.id}`)
  584.             .addField("Banned In", message.channel)
  585.             .addField("Time", message.createdAt)
  586.             .addField("Reason", bReason);
  587.  
  588.         //let incidentchannel = message.guild.channels.find(`name`, "logs");
  589.         let channel = message.guild.channels.find(ch => ch.name === 'logs');
  590.         if (!channel) {
  591.             message.channel.send("Can't find a 'logs' channel.");
  592.             return;
  593.         }
  594.  
  595.         message.guild.member(bUser).ban(bReason);
  596.         channel.send(banEmbed);
  597.     }
  598.  
  599.     if (command === "report" && botConfigs.plugins[4].activated == true) {
  600.         let rUser = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
  601.         if (!rUser) return message.channel.send("Couldn't find user.");
  602.         let reason = args.join(" ").slice(22);
  603.  
  604.         let reportEmbed = new Discord.RichEmbed()
  605.             .setDescription("Reports")
  606.             .setColor("#15f153")
  607.             .addField("Reported User", `${rUser} with ID: ${rUser.id}`)
  608.             .addField("Reported By", `${message.author} with ID: ${message.author.id}`)
  609.             .addField("Channel", message.channel)
  610.             .addField("Time", message.createdAt)
  611.             .addField("Reason", reason);
  612.  
  613.         let channel = message.guild.channels.find(ch => ch.name === 'logs');
  614.         if (!channel) {
  615.             message.channel.send("Can't find a 'logs' channel.");
  616.             return;
  617.         }
  618.  
  619.         message.delete().catch(O_o => {});
  620.         channel.send(reportEmbed);
  621.     }
  622.  
  623.     if (command === "tempmute" && botConfigs.plugins[5].activated == true) {
  624.         let tomute = message.mentions.members.first() || message.guild.members.get(args[0]);
  625.         if (!tomute) return message.reply("Could't find user.");
  626.         if (tomute.hasPermission("ADMINISTRATOR")) return message.reply("He's an administrator. You can't do that!");
  627.         if (!message.member.hasPermission("MUTE_MEMBERS")) return message.channel.send("You don't have permission");
  628.  
  629.         let muterole = message.guild.roles.find(`name`, "muted");
  630.         let muteEmbed = new Discord.RichEmbed()
  631.             .setDescription("~MUTED~")
  632.             .setColor("#e56b00")
  633.             .addField("Muted User", `${tomute} with ID ${tomute.id}`)
  634.             .addField("Muted By", `<@${message.author.id}> with ID ${message.author.id}`)
  635.             .addField("Muted In", message.channel)
  636.             .addField("Time", message.createdAt)
  637.  
  638.         let channel = message.guild.channels.find(ch => ch.name === 'logs');
  639.         if (!channel) {
  640.             message.channel.send("Can't find a 'logs' channel.");
  641.             return;
  642.         }
  643.         channel.send(muteEmbed);
  644.         if (!muterole) {
  645.             try {
  646.                 muterole = await message.guild.createRole({
  647.                     name: "muted",
  648.                     color: "#000000"
  649.                 })
  650.                 message.guild.channels.forEach(async(channel, id) => {
  651.                     await channel.overwritePermissions(muterole, {
  652.                         SEND_MESSAGES: false,
  653.                         ADD_REACTIONS: false,
  654.                         SPEAK: false
  655.                     })
  656.                 })
  657.             } catch (e) {
  658.                 console.log(e.stack);
  659.             }
  660.         }
  661.  
  662.         let mutetime = args[1];
  663.         if (!mutetime) return message.reply("You didn't specify a time!");
  664.  
  665.         await (tomute.addRole(muterole.id));
  666.         message.reply(`<@${tomute.id}> has been muted for ${ms(mutetime)}`)
  667.  
  668.         setTimeout(function() {
  669.             tomute.removeRole(muterole.id);
  670.             message.channel.send(`<@${tomute.id}> has been unmuted!`)
  671.  
  672.         }, ms(mutetime));
  673.  
  674.     }
  675.  
  676.     if (command === "serverinfo" && botConfigs.plugins[6].activated == true) {
  677.         let sicon = message.guild.iconURL;
  678.         let sererembed = new Discord.RichEmbed()
  679.             .setDescription("Информация о сервере:")
  680.             .setColor("#15f153")
  681.             .setThumbnail(sicon)
  682.             .addField("Название сервера:", message.guild.name)
  683.             .addField("Создан:", message.guild.createdAt)
  684.             .addField("Вы присоединились:", message.member.joinedAt)
  685.             .addField("Всего участников:", message.guild.memberCount);
  686.  
  687.         return message.channel.send(sererembed);
  688.     }
  689.  
  690.     if (command === "weather" && botConfigs.plugins[7].activated == true) {
  691.         weather.find({ search: args.join(" "), degreeType: botConfigs.weather.degree }, function(err, result) {
  692.             if (err) message.channel.send(err);
  693.  
  694.             if (result.length === 0) {
  695.                 message.channel.send('**Please enter a valid location.**')
  696.                 return;
  697.             }
  698.  
  699.             var current = result[0].current;
  700.             var location = result[0].location;
  701.  
  702.             const embed = new Discord.RichEmbed()
  703.                 .setDescription(`**${current.skytext}**`)
  704.                 .setAuthor(`Weather for ${current.observationpoint}`)
  705.                 .setThumbnail(current.imageUrl)
  706.                 .setColor(0x00AE86)
  707.                 .addField('Timezone', `UTC${location.timezone}`, true)
  708.                 .addField('Degree Type', location.degreetype, true)
  709.                 .addField('Temperature', `${current.temperature} Degrees`, true)
  710.                 .addField('Feels Like', `${current.feelslike} Degrees`, true)
  711.                 .addField('Winds', current.winddisplay, true)
  712.                 .addField('Humidity', `${current.humidity}%`, true)
  713.  
  714.             message.channel.send({ embed });
  715.         });
  716.     }
  717.  
  718.     if (command === "lockdown" && botConfigs.plugins[9].activated == true) {
  719.         let time = args[0];
  720.  
  721.         if (!client.lockit) { client.lockit = []; }
  722.         let validUnlocks = ["release", "unlock", "u"];
  723.         if (!time) { return message.reply("I need a set time to lock the channel down for!"); }
  724.  
  725.         const Lockembed = new Discord.RichEmbed()
  726.             .setColor(0xDD2E44)
  727.             .setTimestamp()
  728.             .setTitle("🔒 LOCKDOWN NOTICE 🔒")
  729.             .setDescription(`This channel has been lockdown by ${message.author.tag} for ${time}`);
  730.  
  731.         const Unlockembed = new Discord.RichEmbed()
  732.             .setColor(0xDD2E44)
  733.             .setTimestamp()
  734.             .setTitle("🔓 LOCKDOWN NOTICE 🔓")
  735.             .setDescription("This channel is now unlocked.");
  736.  
  737.         if (message.channel.permissionsFor(message.author.id).has("MUTE_MEMBERS") === false) {
  738.             const embed = new Discord.RichEmbed()
  739.                 .setColor(0xDD2E44)
  740.                 .setTimestamp()
  741.                 .setTitle("❌ ERROR: MISSING PERMISSIONS! ❌")
  742.                 .setDescription("You do not have the correct permissions for this command!");
  743.             return message.channel.send({ embed });
  744.         }
  745.  
  746.         if (validUnlocks.includes(time)) {
  747.             message.channel.overwritePermissions(message.guild.id, { SEND_MESSAGES: null }).then(() => {
  748.                 message.channel.send({ embed: Unlockembed });
  749.                 clearTimeout(client.lockit[message.channel.id]);
  750.                 delete client.lockit[message.channel.id];
  751.             }).catch(error => { console.log(error); });
  752.         } else {
  753.             message.channel.overwritePermissions(message.guild.id, { SEND_MESSAGES: false }).then(() => {
  754.                 message.channel.send({ embed: Lockembed }).then(() => {
  755.                     client.lockit[message.channel.id] = setTimeout(() => {
  756.                         message.channel.overwritePermissions(message.guild.id, {
  757.                             SEND_MESSAGES: null
  758.                         }).then(message.channel.send({ embed: Unlockembed })).catch(console.error);
  759.                         delete client.lockit[message.channel.id];
  760.                     }, ms(time));
  761.                 }).catch(error => { console.log(error); });
  762.             });
  763.         }
  764.     }
  765.  
  766.     if (command === "ping") {
  767.         const msg = await message.channel.send("Pinging...");
  768.         await msg.edit(`Pong! (PING: ${msg.createdTimestamp - message.createdTimestamp}ms.)`);
  769.     }
  770.  
  771.     if (command === "shutdown" && botConfigs.plugins[10].activated == true) {
  772.         if (!message.member.hasPermission("ADMINISTRATOR")) return message.channel.send("You don't have permission!");
  773.         await message.channel.send(`Good night, ${message.author.tag}!`);
  774.         await message.delete().catch();
  775.         await process.exit().catch((e) => { console.error(e); });
  776.     }
  777.  
  778.     if (command === "ticket" && botConfigs.plugins[12].activated == true) {
  779.         if (botConfigs.ticketsystem.createTicketChannelID == "" || botConfigs.ticketsystem.createTicketChannelID == null || botConfigs.ticketsystem.createTicketChannelID == undefined || botConfigs.ticketsystem.ticketCategoryID == "" || botConfigs.ticketsystem.ticketCategoryID == null || botConfigs.ticketsystem.ticketCategoryID == undefined) return message.channel.send("The ticket system is not working - Please run the config").catch(console.error);
  780.         if (message.channel.id === botConfigs.ticketsystem.createTicketChannelID) {
  781.             if (message.guild.channels.some(ch => ch.name === message.author.id)) {
  782.                 message.author.send("You already have a open ticket.\n\nIf you wanna close the ticket: \nGo to the ticket channel, and type: " + prefix + "close ticket \n\nBest regards\n" + message.guild.name);
  783.                 message.delete().catch(O_o => {});
  784.                 return;
  785.             }
  786.  
  787.             if (!args[0]) return message.channel.send("Please enter a subject - Example: " + prefix + "ticket I need support").catch(console.error);
  788.  
  789.             let subject = message.content.split(' ').splice(1).join(' ');
  790.             if (subject.length > 20) return message.channel.send("Subject max length: 20 characters").catch(console.error);
  791.             message.guild.createChannel(message.author.id, 'text').then(async m => {
  792.                 await m.setParent(botConfigs.ticketsystem.ticketCategoryID);
  793.                 await m.overwritePermissions(message.guild.id, {
  794.                     VIEW_CHANNEL: false
  795.                 });
  796.  
  797.                 m.overwritePermissions(message.author.id, {
  798.                     VIEW_CHANNEL: true
  799.                 });
  800.                 m.send("Subject: " + subject);
  801.             });
  802.             message.author.send("Ticket created! We appreciate you contacting us. One of our staff members will get back to you shortly. \n\nBest regards\n" + message.guild.name);
  803.             message.delete().catch(O_o => {});
  804.         } else {
  805.             let channel = await client.channels.find(ch => ch.id === botConfigs.ticketsystem.createTicketChannelID);
  806.             return message.channel.send("Please go to: <#" + channel.id + ">").catch(console.error);
  807.         }
  808.     }
  809.    
  810.             //plugin 13: Dm plugin
  811.         if (command === "dm" && botConfigs.plugins[13].activated == true) {
  812.             let rUser = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
  813.             if (!rUser) return message.channel.send("Provide a valid Ping or user id");
  814.             let reason = args.join(" ").slice(22);
  815.             if (!reason) return message.channel.send("Provide a message!")
  816.             let dmEmbed = new Discord.RichEmbed()
  817.                 .setDescription("DM Message")
  818.                 .setColor("#15f153")
  819.                 .setDescription(reason)
  820.                 .setFooter("This message was sent to you by: " + `${message.author.username}  ` + " • " + `${timestamp('hh:mm:ss')}`, `${message.author.displayAvatarURL}`)
  821.             let channel = client.users.get(rUser.id)
  822.             if (!channel) {
  823.                 message.channel.send("Can't find a user.")
  824.                 return;
  825.             } else {
  826.             await channel.send(dmEmbed).catch(O_o => console.log({O_o}));
  827.            }
  828.         }
  829.  
  830.       if (command === "dice" && botConfigs.plugins[14].activated == true) {
  831.           message.delete()
  832.           message.channel.send(`<@${message.author.id}> The dice landed on ${Math.floor(Math.random() * 6) + 1}`).then(msg => {msg.delete(8000)})
  833.         }
  834.         //plugin 15: Warn warn plugin
  835.         if (command === "warn" && botConfigs.plugins[15].activated == true) {
  836.             if (!message.member.hasPermission("MANAGE_MESSAGES")) return message.channel.send("You don't have permission!");
  837.             let rUser = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
  838.             if (!rUser) return message.channel.send("Provide a valid Ping or user id");
  839.             let repCH = message;
  840.             let reason = args.join(" ").slice(22);
  841.            
  842.    
  843.             let reportEmbed = new Discord.RichEmbed()
  844.                 .setTitle("Warnings")
  845.                 .setColor("#15f153")
  846.                 .addField("Warned User", `${rUser} with ID: ${rUser.id}`)
  847.                 .addField("Warned By", `${message.author} with ID: ${message.author.id}`)
  848.                 .addField("In channel", repCH.channel)
  849.                 .addField("Time", repCH.createdAt)
  850.                 .addField("Reason", reason)
  851.    
  852.             let channel = message.guild.channels.find(ch => ch.name === 'logs');
  853.  
  854.             if (!channel) {
  855.                 message.channel.send("Can't find a 'logs' channel.");
  856.                 return;
  857.             }
  858.    
  859.             message.delete().catch(O_o => { });
  860.             channel.send(reportEmbed);
  861.         }
  862.  
  863.         if (command === "help" && botConfigs.plugins[16].activated == true) {
  864.             let helpACT = [];
  865.             let helpNACT = [];            
  866.             let Nplugin = "";
  867.             let plugin = "";
  868.  
  869.             botConfigs.plugins.forEach(element => {
  870.                 if (element.activated == true) {
  871.                     helpACT.push("✔" + element.name)
  872.                     plugin = helpACT.join('\n').toString();
  873.                 } else if (element.activated == false) {
  874.                     helpNACT.push("✖" + element.name)
  875.                     Nplugin = helpNACT.join('\n').toString();
  876.               }
  877.             });
  878.              notActive(Nplugin);
  879.             function notActive(Nplugin) {
  880.                 let NhelpEmbed = new Discord.RichEmbed()
  881.                 .setTitle("Help")
  882.                 .setColor("GRAY")
  883.                 .setDescription(Nplugin)
  884.                 if (!Nplugin) return;
  885.                 message.channel.send(NhelpEmbed)
  886.             }
  887.                 Active(plugin)
  888.                 function Active(plugin) {
  889.                     let helpEmbed = new Discord.RichEmbed()
  890.                     .setTitle("Help")
  891.                     .setColor("GRAY")
  892.                     .setDescription(plugin)
  893.                     message.channel.send(helpEmbed)
  894.           }
  895.     }
  896.  
  897.     if (command === "flip" && botConfigs.plugins[17].activated == true) {
  898.         let x = Math.floor(Math.random() * 3) + 1
  899.        if (x == 1) {
  900.            message.channel.send(`<@${message.author.id}>, tails`)
  901.        } else if (x == 2) {
  902.         message.channel.send(`<@${message.author.id}>, heads`)
  903.        } else {
  904.         message.channel.send(`<@${message.author.id}>, No way! it landed on the side`)
  905.        }
  906.     }
  907.  
  908.     if (command === "announce" && botConfigs.plugins[18].activated === true) {
  909.         const messageArray = message.content.split(/ +/g)
  910.         let id = args[0].slice(2, -1)
  911.         var embed_channel = message.guild.channels.find(ch => ch.id == id)
  912.    
  913.         let embed_color = args[1]
  914.         let embed_title = args[2]
  915.         let embed_desc = messageArray.slice(4).join(` `)
  916.    
  917.         const AnnounceEmbed = new Discord.RichEmbed()
  918.             .setTitle(embed_title)
  919.             .setColor(embed_color)
  920.             .setDescription(embed_desc)
  921.         if (!embed_channel) return message.channel.send(`Sorry, either that's an invalid channel or it isn't a channel at all. Please redo your command!`)
  922.  
  923.             message.channel.send(`Are you sure you would like to send an announcement with the following information?`).then((msgx) => {
  924.                 message.channel.send({embed: {
  925.                     color: 0000000,
  926.                     description: `Title: **${args[2]}**\n` +
  927.                                  `Color: **${args[1]}**\n` +
  928.                                  `Description: **${embed_desc}**\n` +
  929.                                  `Channel: ${embed_channel}`
  930.                 }}).then(awaitResponse => {
  931.                     message.channel.awaitMessages(response => response.author.id === message.author.id, {
  932.                         /* Above line matches original message author ID with the new message author ID. */
  933.                         max: 1,
  934.                         time: 15000,
  935.                         error: ['time'],
  936.                     }).then((collectedResponse) => {
  937.                         /* If the user wants to send the announcement, they say yes */
  938.                         if (collectedResponse.first().content === `yes` || collectedResponse.first().content === `Yes`) {
  939.                             //embed_channel.send(`@everyone`)
  940.                             embed_channel.send(AnnounceEmbed);
  941.            
  942.                             message.delete()
  943.                             msgx.delete()
  944.                             collectedResponse.first().delete()
  945.                             awaitResponse.delete()
  946.    
  947.                             message.channel.send(`Successfully sent announcement!`).then(announceconfirm => {
  948.                                 announceconfirm.delete(3000)
  949.                             })
  950.                         }
  951.                         /* If the user wants to send the announcement, they say yes */
  952.  
  953.                         /* If the user does not want to send the announcement, they say no */
  954.                         if (collectedResponse.first().content === `no` || collectedResponse.first().content === `No`) {
  955.                             message.channel.send(`Cancelled action.`).then(cancelaction => {
  956.    
  957.                                 cancelaction.delete()
  958.                                 message.delete()
  959.                                 msgx.delete()
  960.                                 collectedResponse.first().delete()
  961.                                 awaitResponse.delete()
  962.  
  963.                                 message.channel.send(`Announcement cancelled.`).then(announceconfirm => {
  964.                                     announceconfirm.delete(3000)
  965.                                 })
  966.                             })            
  967.                         }
  968.                         /* If the user does not want to send the announcement, they say no */
  969.                     })
  970.                 })
  971.             })
  972.     }
  973.     //close command for Ticket plugin
  974.     if (command === "close") {
  975.         if (!args[0]) return message.channel.send("Please specify what you wanna close - Example: !close ticket").catch(console.error);
  976.         if (args[0] === "ticket") {
  977.             if (message.channel.parent.id === botConfigs.ticketsystem.ticketCategoryID) {
  978.                 message.channel.delete();
  979.                 if (message.channel.name === message.author.id) {
  980.                     message.author.send("The ticket has been closed and deleted. \n\nBest regards\n" + message.guild.name);
  981.                 } else {
  982.                     message.author.send("The ticket has been closed and deleted. \n\nBest regards\n" + message.guild.name);
  983.                     client.fetchUser(message.channel.name)
  984.                         .then(user => {
  985.                             user.send("The ticket has been closed and deleted by an administrator. \n\nBest regards\n" + message.guild.name)
  986.                         })
  987.                 }
  988.             } else {
  989.                 message.channel.send("Please go to a ticket, and try again.");
  990.             }
  991.         }
  992.     }
  993.  
  994.     botConfigs.commands.forEach(element => {
  995.         element.command = element.command.toLowerCase();
  996.         if (command === element.command) {
  997.             if (element.embed) {
  998.                 if (element.embedFields.length == 1) {
  999.                     let embed = new Discord.RichEmbed()
  1000.                         .setColor("RANDOM")
  1001.                         .addField(element.embedFields[0].title, element.embedFields[0].text);
  1002.  
  1003.                     message.channel.send({ embed });
  1004.                 } else if (element.embedFields.length == 2) {
  1005.                     let embed = new Discord.RichEmbed()
  1006.                         .setColor("RANDOM")
  1007.                         .addField(element.embedFields[0].title, element.embedFields[0].text)
  1008.                         .addField(element.embedFields[1].title, element.embedFields[1].text);
  1009.  
  1010.                     message.channel.send({ embed });
  1011.                 } else if (element.embedFields.length == 3) {
  1012.                     let embed = new Discord.RichEmbed()
  1013.                         .setColor("RANDOM")
  1014.                         .addField(element.embedFields[0].title, element.embedFields[0].text)
  1015.                         .addField(element.embedFields[1].title, element.embedFields[1].text)
  1016.                         .addField(element.embedFields[2].title, element.embedFields[2].text);
  1017.  
  1018.                     message.channel.send({ embed });
  1019.                 } else if (element.embedFields.length == 4) {
  1020.                     let embed = new Discord.RichEmbed()
  1021.                         .setColor("RANDOM")
  1022.                         .addField(element.embedFields[0].title, element.embedFields[0].text)
  1023.                         .addField(element.embedFields[1].title, element.embedFields[1].text)
  1024.                         .addField(element.embedFields[2].title, element.embedFields[2].text)
  1025.                         .addField(element.embedFields[3].title, element.embedFields[3].text);
  1026.  
  1027.                     message.channel.send({ embed });
  1028.                 } else if (element.embedFields.length == 5) {
  1029.                     let embed = new Discord.RichEmbed()
  1030.                         .setColor("RANDOM")
  1031.                         .addField(element.embedFields[0].title, element.embedFields[0].text)
  1032.                         .addField(element.embedFields[1].title, element.embedFields[1].text)
  1033.                         .addField(element.embedFields[2].title, element.embedFields[2].text)
  1034.                         .addField(element.embedFields[3].title, element.embedFields[3].text)
  1035.                         .addField(element.embedFields[4].title, element.embedFields[4].text);
  1036.  
  1037.                     message.channel.send({ embed });
  1038.                 } else {
  1039.                     message.channel.send("Ошибка, обратитесь к администратору.");
  1040.                 }
  1041.             } else {
  1042.                 message.channel.send(element.message);
  1043.             }
  1044.         }
  1045.     });
  1046.  
  1047.     if (command === "commands") {
  1048.         let allCommands = "";
  1049.         botConfigs.commands.forEach(element => {
  1050.             if (allCommands.length < 1 || allCommands == "") {
  1051.                 allCommands = prefix + element.command;
  1052.             } else {
  1053.                 allCommands = allCommands + ", " + prefix + element.command;
  1054.             }
  1055.         });
  1056.         message.channel.send("Commands: " + allCommands);
  1057.     }
  1058.  
  1059.     if (command === "leave" && botConfigs.plugins[8].activated == true || command === "stop" && botConfigs.plugins[8].activated == true) {
  1060.         if (!message.member.voiceChannel) return message.channel.send('Пожалуйста, подключитесь к голосовому каналу.');
  1061.         if (!message.guild.me.voiceChannel) return message.channel.send('К сожалению, бот не связан с гильдией');
  1062.         if (message.guild.me.voiceChannelID !== message.member.voiceChannelID) return message.channel.send('Извините, но вы не подключены к одному и тому же каналу');
  1063.         message.guild.me.voiceChannel.leave();
  1064.         message.channel.send('Покидаю Канал....');
  1065.     }
  1066.  
  1067.     if (command === "pause" && botConfigs.plugins[8].activated == true) {
  1068.         let fetched = ops.active.get(message.guild.id);
  1069.  
  1070.         if (!fetched) return message.channel.send('В настоящее время в этой гильдии не играет никакой музыки!');
  1071.  
  1072.         if (message.member.voiceChannel !== message.guild.me.voiceChannel) return message.channel.send('Извините, но вы не находитесь на том же канале, что и музыкальный бот!');
  1073.  
  1074.         if (fetched.dispatcher.paused) return message.channel.send('Эта музыка уже приостановлена.');
  1075.  
  1076.         fetched.dispatcher.pause();
  1077.  
  1078.         message.channel.send(`Successfully paused ${fetched.queue[0].songTitle}`);
  1079.     }
  1080.  
  1081.     if (command === "play" && botConfigs.plugins[8].activated == true) {
  1082.         if (!message.member.voiceChannel) return message.channel.send('Пожалуйста, подключитесь к голосовому каналу.');
  1083.         if (!args[0]) return message.channel.send('Извините, пожалуйста, введите url-адрес после команды');
  1084.  
  1085.         let validate = await ytdl.validateURL(args[0]);
  1086.  
  1087.         if (!validate) {
  1088.             let ops = {
  1089.                 active: active
  1090.             }
  1091.             return searchYT(client, message, args, ops);
  1092.         }
  1093.  
  1094.         let info = await ytdl.getInfo(args[0]);
  1095.         let data = ops.active.get(message.guild.id) || {};
  1096.  
  1097.         if (!data.connection) data.connection = await message.member.voiceChannel.join();
  1098.         if (!data.queue) data.queue = [];
  1099.  
  1100.         data.guildID = message.guild.id;
  1101.         data.queue.push({
  1102.             songTitle: info.title,
  1103.             requester: message.author.tag,
  1104.             url: args[0],
  1105.             announceChannel: message.channel.id
  1106.         });
  1107.  
  1108.         if (!data.dispatcher) play(client, ops, data);
  1109.         else {
  1110.             message.channel.send(`Добавлено В Очередь: ${info.title} | Заказал: ${message.author.tag}`);
  1111.         }
  1112.  
  1113.         ops.active.set(message.guild.id, data);
  1114.     }
  1115.  
  1116.     if (command === "queue" && botConfigs.plugins[8].activated == true) {
  1117.         let fetched = ops.active.get(message.guild.id);
  1118.  
  1119.         if (!fetched) return message.channel.send('В настоящее время в этой гильдии не играет никакой музыки!');
  1120.  
  1121.         let queue = fetched.queue;
  1122.         let nowPlaying = queue[0];
  1123.         let resp = `__**Сейчас играет**__\n**${nowPlaying.songTitle}** -- **Заказал:** *${nowPlaying.requester}*\n\n__**Очередь**__\n`;
  1124.  
  1125.         for (var i = 1; i < queue.length; i++) {
  1126.             resp += `${i}. **${queue[i].songTitle}** -- **Заказал:** *${queue[i].requester}*\n`;
  1127.         }
  1128.         message.channel.send(resp);
  1129.     }
  1130.  
  1131.     if (command === "resume" && botConfigs.plugins[8].activated == true) {
  1132.         let fetched = ops.active.get(message.guild.id);
  1133.  
  1134.         if (!fetched) return message.channel.send('В настоящее время в этой гильдии не играет никакой музыки!');
  1135.         if (message.member.voiceChannel !== message.guild.me.voiceChannel) return message.channel.send('Извините, но вы не находитесь на том же канале, что и музыкальный бот!');
  1136.         if (!fetched.dispatcher.paused) return message.channel.send('Эта музыка не останавливается.');
  1137.  
  1138.         fetched.dispatcher.resume();
  1139.         message.channel.send(`Successfully resumed ${fetched.queue[0].songTitle}`);
  1140.     }
  1141.  
  1142.     if (command === "fskip" && botConfigs.plugins[8].activated == true) {
  1143.  
  1144.         let fetched = ops.active.get(message.guild.id);
  1145.  
  1146.         if (!fetched) return message.channel.send("В настоящее время в этой гильдии нет ни одной песни!");
  1147.  
  1148.         if (message.member.voiceChannel !== message.guild.me.voiceChannel) return message.channel.send("Извините, но сейчас вы находитесь не на том же канале, что и бот!");
  1149.  
  1150.         if (!message.member.hasPermission("ADMINISTRATOR")) return message.channel.send("Вы не являетесь администратором этой гильдии!");
  1151.  
  1152.         fetched.dispatcher.end();
  1153.     }
  1154.  
  1155.     if (command === "skip" && botConfigs.plugins[8].activated == true) {
  1156.         let fetched = ops.active.get(message.guild.id)
  1157.  
  1158.         if (!fetched) return message.channel.send('В настоящее время в гильдии не играет никакой музыки!');
  1159.         if (message.member.voiceChannel !== message.guild.me.voiceChannel) return message.channel.send('Извините, но в настоящее время вы не находитесь на том же канале, что и бот!');
  1160.  
  1161.         let userCount = message.member.voiceChannel.members.size;
  1162.         let required = Math.ceil(userCount / 2);
  1163.  
  1164.         if (!fetched.queue[0].voteSkips) fetched.queue[0].voteSkips = [];
  1165.         if (fetched.queue[0].voteSkips.includes(message.member.id)) return message.channel.send(`Извините, но вы уже проголосовали за пропуск! ${fetched.queue[0].voteSkips.length}/${required} required.`);
  1166.  
  1167.         fetched.queue[0].voteSkips.push(message.member.id);
  1168.         ops.active.set(message.guild.id, fetched);
  1169.  
  1170.         if (fetched.queue[0].voteSkips.length >= required) {
  1171.             message.channel.send('Пропуск песни!');
  1172.             return fetched.dispatcher.end();
  1173.         }
  1174.         message.channel.send(`Успешно проголосовал за пропуск ${fetched.queue[0].voteSkips.length}/${required} required`);
  1175.     }
  1176. });
  1177.  
  1178. console.log("|  Loggin in...   ");
  1179. client.login(botConfigs.token);
  1180. console.log("|  Bot was logged in.   ");
  1181. console.log("|------------------");
  1182. console.log("|  Bot Info:    ");
  1183. console.log("|  ");
  1184. console.log("|  Bot Prefix: " + botConfigs.prefix + " ");
  1185.  
  1186.  
  1187. var ListPlugins = " | " + ListPlugins
  1188. botConfigs.plugins.forEach(element => {
  1189.     if (element.activated == true) {
  1190.         ListPlugins = ListPlugins + element.name + "\n"
  1191.  
  1192.     }
  1193. });
  1194. console.log(" ");
  1195. console.log(" ");
  1196. console.log("Activated Plugins: ");
  1197. console.log("------------------");
  1198. console.log(ListPlugins.replace(" | undefined", ""));
  1199.  
  1200.  
  1201. async function play(client, ops, data) {
  1202.  
  1203.     client.channels.get(data.queue[0].announceChannel).send(`Сейчас играет: ${data.queue[0].songTitle} | Заказал: ${data.queue[0].requester}`);
  1204.  
  1205.     data.dispatcher = await data.connection.playStream(ytdl(data.queue[0].url, { filter: 'audioonly' }));
  1206.     data.dispatcher.guildID = data.guildID;
  1207.  
  1208.     data.dispatcher.once('end', function() {
  1209.         finish(client, ops, this);
  1210.     })
  1211.  
  1212.  
  1213. }
  1214.  
  1215. function finish(client, ops, dispatcher) {
  1216.     let fetched = ops.active.get(dispatcher.guildID);
  1217.  
  1218.     fetched.queue.shift();
  1219.  
  1220.     if (fetched.queue.length > 0) {
  1221.  
  1222.         ops.active.set(dispatcher.guildID, fetched);
  1223.  
  1224.         play(client, ops, fetched);
  1225.  
  1226.     } else {
  1227.         ops.active.delete(dispatcher.guildID);
  1228.  
  1229.         let vc = client.guilds.get(dispatcher.guildID).me.voiceChannel;
  1230.         if (vc) vc.leave();
  1231.  
  1232.     }
  1233. }
  1234.  
  1235. async function searchYT(client, message, args, ops) {
  1236.     search(args.join(' '), function(err, res) {
  1237.         if (err) return message.channel.send('Извини, что-то пошло не так.');
  1238.  
  1239.         let videos = res.videos.slice(0, 10);
  1240.  
  1241.         let resp = '';
  1242.         for (var i in videos) {
  1243.             resp += `\n**[${parseInt(i) + 1}]:** \`${videos[i].title}\`\n`;
  1244.         }
  1245.  
  1246.         resp += `\n Choose a number between \`1-${videos.length}\``;
  1247.  
  1248.         message.channel.send(resp);
  1249.  
  1250.         const filter = m => !isNaN(m.content) && m.content < videos.length + 1 && m.content > 0;
  1251.  
  1252.         const collector = message.channel.createMessageCollector(filter);
  1253.  
  1254.         collector.videos = videos;
  1255.  
  1256.         collector.once('collect', function(m) {
  1257.             playYT(client, message, [this.videos[parseInt(m.content) - 1].url], ops);
  1258.         })
  1259.  
  1260.     })
  1261. }
  1262.  
  1263. async function playYT(client, message, args, ops) {
  1264.     if (!message.member.voiceChannel) return message.channel.send('Пожалуйста, подключитесь к голосовому каналу.');
  1265.  
  1266.     // if (message.guild.me.voiceChannel) return message.channel.send('Sorry, the bot is already connected to the guild.');
  1267.  
  1268.     if (!args[0]) return message.channel.send('Извините, пожалуйста, введите url-адрес после команды');
  1269.  
  1270.     let validate = await ytdl.validateURL(args[0]);
  1271.  
  1272.     if (!validate) {
  1273.         let ops = {
  1274.             active: active
  1275.         }
  1276.  
  1277.         //let commandFile = require(`./search.js`);
  1278.         return searchYT(client, message, args, ops);
  1279.  
  1280.     }
  1281.  
  1282.     let info = await ytdl.getInfo(args[0]);
  1283.  
  1284.     let data = ops.active.get(message.guild.id) || {};
  1285.  
  1286.     if (!data.connection) data.connection = await message.member.voiceChannel.join();
  1287.     if (!data.queue) data.queue = [];
  1288.     data.guildID = message.guild.id;
  1289.  
  1290.     data.queue.push({
  1291.         songTitle: info.title,
  1292.         requester: message.author.tag,
  1293.         url: args[0],
  1294.         announceChannel: message.channel.id
  1295.     });
  1296.  
  1297.     if (!data.dispatcher) play(client, ops, data);
  1298.     else {
  1299.  
  1300.         message.channel.send(`Добавлено в очередь: ${info.title} | Заказал: ${message.author.tag}`);
  1301.     }
  1302.  
  1303.     ops.active.set(message.guild.id, data);
  1304. }
  1305.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement