Advertisement
dfhfjjfgjfsfeedgf

Untitled

Dec 15th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.53 KB | None | 0 0
  1. const db = require("enmap");
  2. if (message.author.bot) return;
  3. if (message.channel.type !== `text`) {
  4. let active = await bot.db.get(`support_${message.author.id}`);
  5. let guild = client.guilds.get(`guildID`);
  6. let channel, found = true;
  7. try{
  8. if (active) client.channels.get(active.channelID).guild;
  9. } catch (e) {
  10. found = false;
  11. }
  12. if (!active || !found) {
  13.  
  14. active = {};
  15.  
  16. channel = await guild.channels.create(`${message.author.username}-${message.author.discriminator}`, {
  17. parent: `522562841123880977`,
  18. topic: `When this support ticket is complete do *complete* to close the ticket | Support ticket for ${message.author.tag} | ID: ${message.author.id}`
  19. });
  20.  
  21. let author = message.author;
  22.  
  23. //embed
  24. const newChannel = new Discord.MessageEmbed()
  25. .setColor(0x36393e)
  26. .setAuthor(author.tag, author.displayAvatarURL())
  27. .setFooter("Support Ticket Created")
  28. .addField(`User`, author)
  29. .addField("User's ID", author.id)
  30.  
  31. await channel.send(newChannel);
  32.  
  33. //sends user the confirmation
  34. const newTicket = new Discord.MessageEmbed()
  35. .setColor(0x36393e)
  36. .setAuthor(`Hello, ${author.tag}`, author.displayAvatarURL())
  37. .setFooter("Support Ticket Created")
  38.  
  39. //sends pm embed
  40. await author.send(newTicket);
  41.  
  42. //updates data
  43. active.channelID = channel.id;
  44. active.targetID = author.id
  45.  
  46. }
  47.  
  48. //sends the message author said into support channels
  49. channel = client.channels.get(active.channelID);
  50.  
  51. //create dm embed
  52. const dm = new Discord.MessageEmbed()
  53. .setColor(0x36393e)
  54. .setAuthor(`Thank you, ${message.author.tag}`, message.author.displayAvatarURL())
  55. .setFooter(`Your message has been sent! A staff member will be in contact with you soon!`)
  56.  
  57. //sends embed
  58. await message.author.send(dm);
  59.  
  60. const embed = new Discord.MessageEmbed()
  61. .setColor(0x36393e)
  62. .setAuthor(message.author.tag, message.author.displayAvatarURL())
  63. .setDescription(message.content)
  64. .setFooter(`Message Recieved -- ${message.author.tag}`)
  65.  
  66. //sends embed
  67. await channel.send(embed);
  68.  
  69. //updates database
  70. db.set(`support_${message.author.id}`, active);
  71. db.set(`supportChannel_${channel.id}`, message.author.id);
  72. return;
  73. }
  74.  
  75. let support = await bot.db.get(`supportChannel_${message.channel.id}`);
  76.  
  77. if (support) {
  78.  
  79. support = await bot.db.get(`support_${support}`);
  80.  
  81. let supportUser = client.users.get(support.targetID);
  82. if (!supportUser) return message.channel.delete();
  83.  
  84. if (message.content.toLowerCase() === `*complete`) {
  85.  
  86. const complete = new Discord.MessageEmbed()
  87. .setColor(0x36393e)
  88. .setAuthor(`Hey, ${supportUser.tag}`, supportUser.displayAvatarURL())
  89. .setFooter(`Ticket Closed -- Justice County Roleplay`)
  90. .setDescription(`*Your ticket has been marked as **complete**. If you whish to re-open this or create a new one, please PM/DM the discord bot (JCRP Bot) *`)
  91.  
  92. //sends the message
  93. supportUser.send(complete);
  94.  
  95. //deletes the support channel
  96. message.channel.delete();
  97.  
  98. db.delete(`support_${support.targetID}`);
  99.  
  100. }
  101.  
  102. //embed
  103. const embed = new Discord.MessageEmbed()
  104. .setColor(0x36393e)
  105. .setAuthor(message.author.tag, message.author.displayAvatarURL())
  106. .setFooter(`Message Recieved -- Justice County Roleplay`)
  107. .setDescription(message.content)
  108.  
  109. // sends the embed in dm
  110. client.users.get(support.targetID).send(embed)
  111.  
  112. message.delete({timeout: 1000});
  113.  
  114. //modifys the embed
  115. embed.setFooter(`Message Sent -- ${supportUser.tag}`).setDescription(message.content);
  116.  
  117. //sends and returns
  118. return message.channel.send(embed)
  119.  
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement