Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
111
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 fs = require("fs");
  4. const ticket = require("../data/tickets.json");
  5.  
  6. module.exports.run = async (bot, message, args) => {
  7.   if(!ticket[message.author.id]) {
  8.       ticket[message.author.id] = {
  9.         tickets: 0
  10.       };
  11.     }
  12.    
  13.   let guild = message.guild;
  14.   let curtick = ticket[message.author.id].tickets;
  15.  
  16.   if(!message.author.bot) return;
  17.   if(curtick === 1) return message.channel.send("You already have a ticket.");
  18.  
  19.   guild.createChannel(`ticket-${message.author.id}`, {
  20.     type: 'text',
  21.     permissionOverwrites: [
  22.       {
  23.         allow: 'VIEW_CHANNEL',
  24.         id: message.author.id
  25.       },
  26.       {
  27.         deny: 'VIEW_CHANNEL',
  28.         id: guild.id
  29.       },
  30.       {
  31.         allow: 'VIEW_CHANNEL',
  32.         id: '669429112557010944'
  33.       }
  34.     ]
  35.   }).then(ch => {
  36.     message.channel.send(`Your ticket was created in ${ch}`);
  37.     let tickAdd = 0 + 1;
  38.    
  39.     ticket[message.author.id].tickets = curtick + tickAdd;
  40.    
  41.     fs.writeFile("../data/tickets.json", JSON.stringify(ticket), (err) => {
  42.       if(err) console.log(err);
  43.     });
  44.   });
  45. };
  46.  
  47. module.exports.help = {
  48.   name: "new",
  49.   aliases: ["ticket"]
  50. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement