Advertisement
IxRawan_

Untitled

Jun 29th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1.  
  2. client.on("message", (message) => {
  3. if (message.content.startsWith("$ticket")) {
  4. if(message.author.id == bannedMembers) return message.channel.send('**Sorry, but You have been banned, so you can\'t use this commmand**').then(msg => {msg.delete(5000)});
  5. if(message.author.bot) return;
  6. if(message.channel.type == "dm") return;
  7. if (!message.guild.roles.exists("name", "Support Team")) return message.channel.send(`I can't find **Support Team** Role`);
  8. let reason = message.content.split(" ").slice(1).join(" ");
  9. if(reason !== null){
  10. y = `${reason}`;
  11. }else{
  12. y = "No Reason";
  13. }
  14. if (message.guild.channels.exists("name", `ticket-${message.author.username}`)) return message.channel.send(`You have already created a ticket`);
  15. message.guild.createChannel(`ticket-${message.author.username}`, "text").then(c => {
  16. let role = message.guild.roles.find("name", "Support Team");
  17. let role2 = message.guild.roles.find("name", "@everyone");
  18. c.overwritePermissions(role, {
  19. SEND_MESSAGES: true,
  20. READ_MESSAGES: true
  21. });
  22. c.overwritePermissions(role2, {
  23. SEND_MESSAGES: false,
  24. READ_MESSAGES: false
  25. });
  26. c.overwritePermissions(message.author, {
  27. SEND_MESSAGES: true,
  28. READ_MESSAGES: true
  29. });
  30. message.channel.send(`${message.author.username}, Done Your Ticket has been Created <#${c.id}>`);
  31. const embed = new Discord.RichEmbed()
  32. .setColor(0xCF40FA)
  33. .addField('User: ',`[ ${message.author.username} ]`,true)
  34. .addField('\nUserID: ', `[ ${message.author.id} ]`, true)
  35. .addField('\nCMD writed in Channel', `#${message.channel.name}`, true)
  36. .addField('\nReason: ', `[ ${reason} ]`)
  37. .setFooter(message.guild.name,message.guild.avatarURL)
  38. .setTimestamp();
  39. c.send({
  40. embed: embed
  41. });
  42. }).catch(console.error);
  43. }
  44.  
  45. if (message.content.startsWith("$close")) {
  46. if (!message.channel.name.startsWith(`ticket-`)) return message.channel.send(`You can't use the close command outside of a ticket channel.`);
  47.  
  48. message.channel.send(`Are you sure? You have 10 seconds to delete the channel type **$confirm** to confirm.`)
  49. .then((m) => {
  50. message.channel.awaitMessages(response => response.content == '$confirm', {
  51. max: 1,
  52. time: 10000,
  53. errors: ['time'],
  54. })
  55. .then((collected) => {
  56. message.channel.delete();
  57. })
  58. .catch(() => {
  59. m.edit('Ticket close timed out, the ticket was not closed.').then(m2 => {
  60. m2.delete();
  61. }, 3000);
  62. });
  63. });
  64. }
  65.  
  66. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement