2wild4u

ticketopen.js

Mar 21st, 2020
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require("discord.js");
  2. const footer = "Master [Code-Docs]"
  3.  
  4. module.exports.run = async (bot, message, args) => {
  5.     message.delete();
  6.     // ID van de categorie van de tickets.
  7.     const categoryId = "676054997552857111";
  8.  
  9.     // Verkrijg Gebruikersnaam
  10.     var userName = message.author.username;
  11.     // Verkrijg discriminator
  12.     var userDiscriminator = message.author.discriminator;
  13.  
  14.     // Als ticket al gemaakt is
  15.     var bool = false;
  16.  
  17.     // Kijk na als ticket al gemaakt is.
  18.     message.guild.channels.cache.forEach((channel) => {
  19.        
  20.         // Als ticket is gemaakt, zend bericht.
  21.         if (channel.name == userName.toLowerCase() + "-" + userDiscriminator) {
  22.  
  23.             message.channel.send("You have already created a ticket");
  24.  
  25.             bool = true;
  26.  
  27.         }
  28.  
  29.     });
  30.  
  31.     // Als ticket return code.
  32.     if (bool == true) return;
  33.  
  34.     let Sender = message.author;
  35.     const sayMessage = args.join(" ");
  36.     if(!sayMessage) return message.channel.send(":x: " + "`| Please mention the issues in your ticket, more info we got that way we can find the best solution for you Usage: m!ticketopen <message>`").then(msg => msg.delete(5000))
  37.     message.delete();
  38.     var embedCreateTicket = new Discord.MessageEmbed()
  39.         .setAuthor('Master [Code-Docs] Support Server', 'https://thumbs.gfycat.com/DeliciousJoyfulAustralianshelduck-max-1mb.gif')
  40.         .setColor("#1f264d")
  41.         .setTitle(message.author.username)
  42.         .setFooter("Your ticket has been created Succesfully!!!!")
  43.         .setTimestamp();
  44.  
  45.     message.channel.send(embedCreateTicket);
  46.  
  47.     // Maak kanaal en zet in juiste categorie.
  48.     message.guild.channels.create(userName + "-" + userDiscriminator, "text").then((createdChan) => { // Maak kanaal
  49.  
  50.         createdChan.setParent(categoryId).then((settedParent) => { // Zet kanaal in category.
  51.  
  52.             // Zet perms voor iedereen
  53.             settedParent.overwritePermissions(message.guild.roles.cache.find('name', "@everyone"), { "READ_MESSAGES": false });
  54.             // Zet perms voor de gebruiker die ticket heeft aangemaakt.
  55.             settedParent.overwritePermissions(message.author, {
  56.  
  57.                 "READ_MESSAGES": true, "SEND_MESSAGES": true,
  58.                 "ATTACH_FILES": true, "CONNECT": true,
  59.                 "CREATE_INSTANT_INVITE": false, "ADD_REACTIONS": true
  60.  
  61.             });
  62.  
  63.             var embedParent = new Discord.MessageEmbed()
  64.                 .setColor("#1f264d")
  65.                 .setAuthor('Master [Code-Docs] Support Server Ticket Message!', 'https://thumbs.gfycat.com/DeliciousJoyfulAustralianshelduck-max-1mb.gif')
  66.                 .setTitle("Hey, " + message.author.username.toString())
  67.                 .setDescription("Ticket System")
  68.                 .addField("Ticket sent by", Sender, true)
  69.                 .addField("Ticket: ", sayMessage)
  70.                 .setFooter("Your ticket has been created Succesfully!!!!")
  71.                 .setTimestamp()
  72.  
  73.                 settedParent.send(embedParent);
  74.             }).catch(err => {
  75.                 message.channel.send("Something went wrong.");
  76.             });
  77.  
  78.         }).catch(err => {
  79.             message.channel.send("Something went wrong.");
  80.         });
  81.         message.delete();
  82. }
  83.  
  84. module.exports.config = {
  85.     name: "ticket",
  86.     aliases: ["ticketopen", "topen"],
  87.     accessableby: "Members",
  88.     description: "Create a Ticket"
  89. }
Add Comment
Please, Sign In to add comment