Advertisement
n3k4a

Untitled

May 11th, 2019
894
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.10 KB | None | 0 0
  1. const Discord = require('discord.js'); //Toxic Codes//Toxic Codes//Toxic Codes//Toxic Codes//Toxic Codes//Toxic Codes
  2. const client = new Discord.Client();
  3. const db = require("quick.db");
  4.  
  5. const serverStats = {
  6. guildID: 'SERVER ID HERE',
  7. ticketCategoryID: 'TICKET CATEGORY ID HERE'
  8.  
  9. }
  10.  
  11.  
  12. //It's not a command, just send a DM for bot and...
  13.  
  14. client.on('message', async message => {
  15. if (message.author.bot) return;
  16. if (message.channel.type !== 'text') {
  17. let active = await db.fetch(`support_${message.author.id}`);
  18. let guild = client.guilds.get(serverStats.guildID);
  19. let channel, found = true;
  20. try {
  21. if (active) client.channels.get(active.channelID)
  22. .guild;
  23. } catch (e) {
  24. found = false;
  25. }
  26. if (!active || !found) {
  27. active = {};
  28. channel = await guild.createChannel(`${message.author.username}-${message.author.discriminator}`)
  29. channel.setParent(serverStats.ticketCategoryID)
  30. channel.setTopic(`/complete to close the ticket | Support for ${message.author.tag} | ID: ${message.author.id}`)
  31.  
  32. channel.overwritePermissions("465147579517370368", { //Role id (when someone join my server get this role with id <<, i dont know how to change it for @everyone. This will prevent users to see the channel, only admins will see!
  33. VIEW_CHANNEL: false,
  34. SEND_MESSAGES: false,
  35. ADD_REACTIONS: false
  36. });//Toxic Codes
  37.  
  38.  
  39.  
  40. let author = message.author;
  41. const newChannel = new Discord.RichEmbed()//Toxic Codes
  42. .setColor('RANDOM')
  43. .setAuthor(author.tag, author.avatarURL)
  44. .setFooter('Support Ticket Created!')
  45. .addField('User', author)
  46. .addField('ID', author.id)
  47. await channel.send(newChannel);
  48. const newTicket = new Discord.RichEmbed()
  49. .setColor('RANDOM')
  50. .setAuthor(`Hello, ${author.username}`, author.avatarURL)
  51. .setFooter('Support Ticket Created!')
  52. await author.send(newTicket);
  53. active.channelID = channel.id;
  54. active.targetID = author.id;
  55. }
  56. channel = client.channels.get(active.channelID);//Toxic Codes
  57. const dm = new Discord.RichEmbed()
  58. .setColor('RANDOM')
  59. .setAuthor(`Thank you, ${message.author.username}`, message.author.avatarURL)
  60. .setFooter(`Your message has been sent - A staff member will be in contact soon.`)//Toxic Codes
  61. await message.author.send(dm);
  62. if (message.content.startsWith(prefix + 'complete')) return;
  63. const embed5 = new Discord.RichEmbed()
  64. .setColor('RANDOM')
  65. .setAuthor(message.author.tag, message.author.avatarURL)
  66. .setDescription(message.content)
  67. .setFooter(`Message Received - ${message.author.tag}`)
  68. await channel.send(embed5);
  69. db.set(`support_${message.author.id}`, active);
  70. db.set(`supportChannel_${channel.id}`, message.author.id); //Toxic Codes
  71. return;
  72. }
  73. let support = await db.fetch(`supportChannel_${message.channel.id}`); //Toxic Codes
  74. if (support) {
  75. support = await db.fetch(`support_${support}`);
  76. let supportUser = client.users.get(support.targetID);
  77. if (!supportUser) return message.channel.delete();
  78. if (message.content.toLowerCase() === '/complete') { //Toxic Codes
  79. const complete = new Discord.RichEmbed()
  80. .setColor('RANDOM')
  81. .setAuthor(`Hey, ${supportUser.tag}`, supportUser.avatarURL)
  82. .setFooter('Ticket Closed -- Toxic Codes')
  83. .setDescription('*Your ticket has been marked as complete. If you wish to reopen it, or create a new one, please send a message to the bot.*')
  84. supportUser.send(complete);
  85. message.channel.delete();
  86. db.delete(`support_${support.targetID}`);
  87. let inEmbed = new Discord.RichEmbed()
  88. .setTitle('Ticket Closed!')
  89. .addField('Support User', `${supportUser.tag}`)
  90. .addField('Closer', message.author.tag)
  91. .setColor('RANDOM')
  92. const staffChannel = client.channels.get('489156917092941826'); //Create a log channel and put id here
  93. staffChannel.send(inEmbed); //Toxic Codes
  94. }
  95. const embed4 = new Discord.RichEmbed() //Toxic Codes
  96. .setColor('RANDOM')
  97. .setAuthor(message.author.tag, message.author.avatarURL)
  98. .setFooter(`Message Received - Toxic Codes`)
  99. .setDescription(message.content)
  100. client.users.get(support.targetID)
  101. .send(embed4);
  102. message.delete({
  103. timeout: 10000
  104. }); //Toxic Codes
  105. embed4.setFooter(`Message Sent -- ${supportUser.tag}`) //Toxic Codes
  106. .setDescription(message.content); //Toxic Codes
  107. return message.channel.send(embed4); //Toxic Codes
  108. }
  109. }); //Toxic Codes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement