Advertisement
2wild4u

ticketcreate.js

Mar 27th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require('discord.js');
  2. const config = require('../../config.json');
  3. const randomString = require('random-string');
  4.  
  5. module.exports.run = async (bot, message, args) => {
  6.     // ID van de categorie van de tickets.
  7.     const categoryId = "691192396276432946";
  8.  
  9.         const client = message.client;
  10.         // command starts here
  11.         message.delete();
  12.         let topic = args.join(" ");
  13.  
  14.         let nums = randomString({
  15.             length: 3,
  16.             numeric: true,
  17.             letters: false,
  18.             special: false,
  19.         });
  20.         let num = randomString({
  21.             length: 3,
  22.             numeric: true,
  23.             letters: false,
  24.             special: false,
  25.         });
  26.         let id = nums.toString().substr(0, 3) + num;
  27.         let chan = `ticket♯${id}`;
  28.         if (message.guild.channels.cache.find(x => x.name === chan)) {
  29.             if (config.useEmbeds) {
  30.                 const err1 = new Discord.MessageEmbed()
  31.                     .setColor("#E74C3C")
  32.                     .setDescription(`:x: You already have an open ticket.`)
  33.                 return message.channel.send(err1)
  34.             } else {
  35.                 message.channel.send(`:x: You already have an open ticket.`)
  36.             }
  37.  
  38.         };
  39.  
  40.         message.guild.channels.create(`ticket♯${id}`, {
  41.             type: 'text'
  42.         }).then(async c => {
  43.             c.setParent(categoryId);
  44.  
  45.  
  46.             c.overwritePermissions(message.guild.defaultRole, {
  47.                 VIEW_CHANNEL: false,
  48.                 SEND_MESSAGES: false
  49.             })
  50.             c.overwritePermissions(message.member, {
  51.                 VIEW_CHANNEL: true,
  52.                 SEND_MESSAGES: true
  53.             })
  54.             c.setTopic(`${message.author} | ${topic}`);
  55.             if (config.tagHereOnly) {
  56.                 await c.send(`${message.author}, a user has created a new ticket.\n`);
  57.             };
  58.  
  59.             if (config.ticketImage) {
  60.                 var embedCreateTicket = new Discord.MessageEmbed()
  61.                 .setAuthor('Master [Code-Docs] Support Server', 'https://thumbs.gfycat.com/DeliciousJoyfulAustralianshelduck-max-1mb.gif')
  62.                 //.setAuthor(`Ticket♯${id}` , 'https://thumbs.gfycat.com/DeliciousJoyfulAustralianshelduck-max-1mb.gif')
  63.                 .setColor("#1f264d")
  64.                 .setTitle(`Ticket♯${id}`)
  65.                 .setDescription(`yout ticket has been created with [Ticket♯${id}]`, topic)
  66.                 .setFooter("Your ticket has been created Succesfully!!!!")
  67.                 .setTimestamp()
  68.          
  69.                 c.send(embedCreateTicket)({
  70.                     files: [`../image.png`]
  71.                 })
  72.             } else {
  73.                 var embedCreateTicket = new Discord.MessageEmbed()
  74.                 .setAuthor('Master [Code-Docs] Support Server', 'https://thumbs.gfycat.com/DeliciousJoyfulAustralianshelduck-max-1mb.gif')
  75.                 //.setAuthor(`Ticket♯${id}` , 'https://thumbs.gfycat.com/DeliciousJoyfulAustralianshelduck-max-1mb.gif')
  76.                 .setColor("#1f264d")
  77.                 .setTitle(`Ticket♯${id}`)
  78.                 .addField(`yout ticket has been created with [Ticket♯${id}]`, topic)
  79.                 .setFooter("Your ticket has been created Succesfully!!!!")
  80.                 .setTimestamp()
  81.          
  82.                 c.send(embedCreateTicket)
  83.             }
  84.  
  85.             const created = new Discord.MessageEmbed()
  86.                 .setColor("#1f264d")
  87.                 .setDescription(`Your ticket **Ticket♯${id}** has been created.\nPlease read the information sent and follow any instructions given.`)
  88.                 .setTimestamp();
  89.                 message.channel.send(created).then(message => message.delete(2000));
  90.  
  91.                 message.delete()
  92.  
  93.             // const welcome = new Discord.MessageEmbed()
  94.             //     .setColor("#1f264d")
  95.             //  .setDescription(`**Ticket topic:** \`${topic}\`\n\n${config.ticketText}`)
  96.             //     message.channel.send(welcome);
  97.  
  98.             // if (config.useEmbeds) {
  99.             //  message.channel.send(created)
  100.             //     let w = await channel.send(welcome);
  101.             // } else {
  102.             //  message.channel.send(`Your ticket (Ticket♯${id}) has been created.\nPlease read the information sent and follow any instructions given.`)
  103.             //  let c = await channel.send(`**Ticket topic:** \`${topic}\`\n\n${config.ticketText}`);
  104.  
  105.             // }
  106.         })
  107. }
  108.  
  109. module.exports.config = {
  110.     name: "ticket-create-2",
  111.     description: 'Create a new ticket',
  112.     usage: '<brief description>',
  113.     aliases: ["new"],
  114.     example: 'new I found an error',
  115.     accessableby: "Members",
  116.     args: true,
  117.     guildOnly: true,
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement