Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. });
  2. bot.on("message", async message => {
  3.  
  4.  
  5.  
  6. if(message.author.bot) return;
  7. if(message.channel.type === "dm") return;
  8.  
  9. let prefix = botconfig.prefix;
  10. let messageArray = message.content.split(" ");
  11. let cmd = messageArray[0];
  12. let args = messageArray.slice(1);
  13.  
  14.  
  15. if(cmd === `${prefix}ticket`){
  16.  
  17. const reason = message.content.split(" ").slice(1).join(" ");
  18.  
  19.  
  20. await message.react('👍')
  21.  
  22.  
  23.  
  24. if (!message.guild.roles.exists("name", "Public Relations")) return message.channel.send(`This server doesn't have a \`Relations Employee\` 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.`);
  25. if (message.guild.channels.exists("name", "ticket-" + message.author.id)) return message.channel.send(`You already have a ticket open.`);
  26. message.guild.createChannel(`ticket-${message.author.id}`, "text").then(c => {
  27. let role = message.guild.roles.find("name", "Public Relations");
  28. let role2 = message.guild.roles.find("name", "@everyone");
  29. c.overwritePermissions(role, {
  30. SEND_MESSAGES: true,
  31. READ_MESSAGES: true
  32. });
  33. c.overwritePermissions(role2, {
  34. SEND_MESSAGES: false,
  35. READ_MESSAGES: false
  36. });
  37. c.overwritePermissions(message.author, {
  38. SEND_MESSAGES: true,
  39. READ_MESSAGES: true
  40. });
  41. message.channel.send(`:white_check_mark: Your ticket has been created, #${c.name}.`);
  42. const embed = new Discord.RichEmbed()
  43. .setColor(0xCF40FA)
  44. .addField(`Greetings! ${message.author.username}!`, `Please explain any inquiries, questions, and concerns on why you've opened this ticket with as much details as possible. Our **Public Relations Officers** will respond when they're available. Thank you! If no one responds within 4 hours, feel free to tag them.`)
  45. .setTimestamp();
  46. c.send({
  47. embed: embed
  48. });
  49. }).catch(console.error); // Send errors to console
  50. }
  51.  
  52. // Close ticket command
  53. if(cmd === `${prefix}close`){
  54. if (!message.channel.name.startsWith(`ticket-`)) return message.channel.send(`You can't use the close command outside of a ticket channel.`);
  55. // Confirm delete - with timeout (Not command)
  56. message.channel.send(`Are you sure? Once confirmed, you cannot reverse this action!\nTo confirm, type \`/confirm\`. This will time out in 10 seconds and be cancelled.`)
  57. .then((m) => {
  58. message.channel.awaitMessages(response => response.content === '/confirm', {
  59. max: 1,
  60. time: 10000,
  61. errors: ['time'],
  62. })
  63. .then((collected) => {
  64. message.channel.delete();
  65. })
  66. .catch(() => {
  67. m.edit('Ticket close timed out, the ticket was not closed.').then(m2 => {
  68. m2.delete();
  69. }, 3000);
  70. });
  71. });
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement