SHARE
TWEET

Untitled

a guest Oct 21st, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require("discord.js");
  2. const prefix = "-"
  3.  
  4.  
  5. module.exports.run = async (bot, message, args) => {
  6.  
  7.     if (isCommand(message, "new")) {
  8.         const reason = message.content.split(" ").slice(1).join(" ");
  9.         if (!message.guild.roles.exists("name", "Ticket")) return message.channel.send(`This server doesn't have a \`Ticket\` role made, so the ticket won't be opened.\nIf you are an administrator, make one with that name exactly and give it to users that should be able to see tickets.`);
  10.         if (message.guild.channels.exists("name", "ticket-" + message.author.username)) return message.channel.send(`You already have a ticket open.`);
  11.         message.guild.createChannel(`ticket-${message.author.username}`, "ticket").then(c => {
  12.             let role = message.guild.roles.find("name", "Support Team");
  13.             let role2 = message.guild.roles.find("name", "@everyone");
  14.             c.overwritePermissions(role, {
  15.                 SEND_MESSAGES: true,
  16.                 READ_MESSAGES: true
  17.             });
  18.             c.overwritePermissions(role2, {
  19.                 SEND_MESSAGES: false,
  20.                 READ_MESSAGES: false
  21.             });
  22.             c.overwritePermissions(message.author, {
  23.                 SEND_MESSAGES: true,
  24.                 READ_MESSAGES: true
  25.             });
  26.             let newembed = new Discord.RichEmbed()
  27.                 .setColor("RANDOM")
  28.                 .setDescription(`Hello ${message.author}, I have created a ticket for you! <#${c.id}>`)
  29.                 .setFooter();
  30.             message.channel.send(newembed)
  31.             let embed = new Discord.RichEmbed()
  32.                 .setColor("RANDOM")
  33.                 .setDescription(`Hey ${message.author}!\nPlease try to explain why you opened this ticket.\nOur @Support Team will be here to help soon.`)
  34.                 .setFooter()
  35.                 .setTimestamp();
  36.             c.send({
  37.                 embed: embed
  38.             });
  39.         }).catch(console.error);
  40.     }
  41.     message.delete().catch(O_o=>{});
  42. }
  43. function isCommand(message) {
  44.     return message.content.toLowerCase().startsWith(prefix);
  45. }
  46.  
  47. function isCommand(message, cmd) {
  48.     return message.content.toLowerCase().startsWith(prefix + cmd);
  49. }
  50.  
  51. module.exports.help = {
  52.     name: "new"
  53. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top