Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. client.on("message", (message) => {
  2. if (message.content.startsWith("-new")) {
  3. const reason = message.content.split(" ").slice(1).join(" ");
  4. if (!message.guild.roles.exists("name", "Support Team")) return message.channel.send(`This server doesn't have a \`Support Team\` 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.`);
  5. if (message.guild.channels.exists("name", "ticket-${message.author.username}" + message.author.username)) return message.channel.send(`You already have a ticket open.`);
  6. message.guild.createChannel(`ticket-${message.author.username}`, "text").then(c => {
  7. let role = message.guild.roles.find("name", "Support Team");
  8. let role2 = message.guild.roles.find("name", "@everyone");
  9. c.overwritePermissions(role, {
  10. SEND_MESSAGES: true,
  11. READ_MESSAGES: true
  12. });
  13. c.overwritePermissions(role2, {
  14. SEND_MESSAGES: false,
  15. READ_MESSAGES: false
  16. });
  17. c.overwritePermissions(message.author, {
  18. SEND_MESSAGES: true,
  19. READ_MESSAGES: true
  20. });
  21. const ticketnew = new Discord.RichEmbed()
  22. .setColor("RANDOM")
  23. .addField(`| :white_check_mark: **Your ticket was created** ،`, `**#${c.name}.**`)
  24. .setAuthor(`${message.author.tag}`, message.author.avatarURL)
  25. .setFooter(client.user.username , client.user.avatarURL)
  26. .setTimestamp();
  27. message.channel.send(ticketnew);
  28. const embed = new Discord.RichEmbed()
  29. .setColor(0xCF40FA)
  30. .addField(`Hello ${message.author.username}!`, `Please try to explain why this ticket is opened as closely as possible. Our support team will soon be of help.`)
  31. .setTimestamp();
  32. c.send({
  33. embed: embed
  34. });
  35. }).catch(console.error);
  36. }
  37.  
  38.  
  39. if (message.content.startsWith("-close")) {
  40. if (!message.channel.name.startsWith(`ticket-`)) return message.channel.send(`You can't use the close command outside of a ticket channel.`);
  41.  
  42. message.channel.send(`are you sure? After confirmation, you can not reverse this action!\n Type ، For confirmation\`-confirm\`. This will lead to a time-out within 10 seconds and cancel`)
  43. .then((m) => {
  44. message.channel.awaitMessages(response => response.content === '-confirm', {
  45. max: 1,
  46. time: 10000,
  47. errors: ['time'],
  48. })
  49. .then((collected) => {
  50. message.channel.delete();
  51. })
  52. .catch(() => {
  53. m.edit('Ticket close timed out, the ticket was not closed.').then(m2 => {
  54. m2.delete();
  55. }, 3000);
  56. });
  57. });
  58. }
  59.  
  60. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement