const Discord = require('discord.js')
const fs = require("fs");
const ms = require("ms");
const moment = require("moment");
const database = JSON.parse(fs.readFileSync("./database.json", `utf8`));
const mysql = require("mysql");

    module.exports.run = async (client, message, args) => {
        var con = mysql.createConnection({
          host: database.host,
          user: database.user,
          password: database.password,
          database: database.database,
          charset : 'utf8mb4'
      });
      con.connect(err => {
          if (err) throw err;
      });



      if(!message.member.hasPermission("KICK_MEMBERS")) return message.channel.send(`:)`);
    var name = args[0];
    var price = args[1];
    var ddosprot = args[2];
    var kvk = args[3];
    var disk = args[4];
    var cpu = args[5];
    var hardware = args[6];
    var panel = args[7];
    var locatie = args[8];
    var support = args[9];
    var package = args[10];
    var siteurl = args[11];
    var imgurl = args[12];
    var score = args[13];
    var trustpilot = args[14];

    var filter = m => m.author.id === message.author.id

    message.channel.send("💻 **Naam** | Wat is de naam van het bedrijf\nVoorbeeld: RoyaleHosting B.V.")
        message.channel.awaitMessages(filter, {
        max: 1,}).then(collected => {
        name = collected.first().content;
    
    message.channel.send("💰 **Prijs** | Wat is de prijs per gigabyte\nVoorbeeld: 5").then((message) => {
        message.channel.awaitMessages(filter, {
        max: 1,}).then(collected => {
        price =  collected.first().content + "/GB p.m."

    message.channel.send("🛡️ **DDoS Protectie** | Wat is de DDoS protectie\nVoorbeeld: 100Gbps").then((message) => {
        message.channel.awaitMessages(filter, {
        max: 1,}).then(collected => {
        ddosprot = "Ja -" + collected.first().content

    message.channel.send("💼 **KvK Nummer** | Wat is het KvK nummer\nVoorbeeld: 19581181").then((message) => {
        message.channel.awaitMessages(filter, {
        max: 1,}).then(collected => {
        kvk = collected.first().content

    message.channel.send("💾 **Disk** | Wat voor opslag is er in gebruik\nVoorbeeld: SATA/NVMe SSD").then((message) => {
        message.channel.awaitMessages(filter, {
        max: 1,}).then(collected => {
        disk = collected.first().content

    message.channel.send("☄️ **CPU** | Welke CPU zit er in de server\nVoorbeeld: Intel Core i9-9900k").then((message) => {
        message.channel.awaitMessages(filter, {
        max: 1,}).then(collected => {
        cpu = collected.first().content

    message.channel.send("🖥️ **Hardware** | Is er eigen hardware in gebruik\nVoorbeeld: Ja").then((message) => {
        message.channel.awaitMessages(filter, {
        max: 1,}).then(collected => {
        hardware = collected.first().content
        
        
    message.channel.send("🖼️ **Paneel** | Welk paneel is er in gebruik\nVoorbeeld: Pterodactyl").then((message) => {
        message.channel.awaitMessages(filter, {
        max: 1,}).then(collected => {
        panel = collected.first().content

    message.channel.send("🌐 **Locatie** | Op welke locatie staan de servers\nVoorbeeld: Duitsland").then((message) => {
        message.channel.awaitMessages(filter, {
        max: 1,}).then(collected => {
        locatie = collected.first().content

    message.channel.send("📱 **Support** | Op welke manier wordt er support aangeboden\nVoorbeeld: Mail | Ticket | Livechat | Discord").then((message) => {
        message.channel.awaitMessages(filter, {
        max: 1,}).then(collected => {
        support = collected.first().content

    message.channel.send("🗳️ **Pakket** | Op welk pakket is de prijs gebaseerd\nVoorbeeld: 1GB Coal").then((message) => {
        message.channel.awaitMessages(filter, {
        max: 1,}).then(collected => {
        package = collected.first().content

    message.channel.send("🔗 **URL** | Wat is de website URL\nVoorbeeld: <https://royalehosting.nl>").then((message) => {
        message.channel.awaitMessages(filter, {
        max: 1,}).then(collected => {
        siteurl = collected.first().content


    message.channel.send("🖼️ **Logo URL** | Plaats hier de **URL** voor het logo\nVoorbeeld: <https://i.imgur.com/jJ1yK34.png>").then((message) => {
        message.channel.awaitMessages(filter, {
        max: 1,}).then(collected => {
        imgurl = collected.first().content

        message.channel.send("🖼️ **Score** | Plaats hier de score van het bedrijf\nVoorbeeld: 5**.**9").then((message) => {
            message.channel.awaitMessages(filter, {
            max: 1,}).then(collected => {
            score = collected.first().content

            message.channel.send("🔗 **Trustpilot** | Wat is de trustpilot URL\nVoorbeeld: <https://nl.trustpilot.com/review/royalehosting.be>").then((message) => {
                message.channel.awaitMessages(filter, {
                max: 1,}).then(collected => {
                trustpilot = collected.first().content

    con.query(`SELECT * FROM data`, (err, rows) => {

        if (err) throw err;
  
        if (rows.length < 1) {
            con.query(`INSERT INTO data (name, price, ddosprot, kvk, disk, cpu, hardware, panel, location, support, package, url, img, score, trustpilot) VALUES ("${name}", "${price}", "${ddosprot}", "${kvk}", "${disk}", "${cpu}", "${hardware}", "${panel}", "${locatie}", "${support}", "${package}", "${siteurl}", "${imgurl}", "${score}", "${trustpilot}")`);
             setTimeout(function(){ 
              message.channel.send(`${name} Is toegevoegd aan de website! 🥳`)
                         }, 10);
  
            } else {
                con.query(`INSERT INTO data (name, price, ddosprot, kvk, disk, cpu, hardware, panel, location, support, package, url, img, score, trustpilot) VALUES ("${name}", "${price}", "${ddosprot}", "${kvk}", "${disk}", "${cpu}", "${hardware}", "${panel}", "${locatie}", "${support}", "${package}", "${siteurl}", "${imgurl}", "${score}", "${trustpilot}")`);
                                 setTimeout(function(){ 
                    message.channel.send(`${name} Is toegevoegd aan de website! 🥳`)
             }, 10);
  
        }
  
    })

});
});
});
});
});
});
});
});
});
});
});
});
});
});
});
});
});
});
});
});
});
});
});
});
});
});
});
});
    })


}

module.exports.help = {
  name: "create"
}