Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. bot.on('message', message => {
  2. if (isCommand(message, "new")) {
  3. const reason = message.content.split(" ").slice(1).join(" ");
  4. if (!message.guild.roles.exists("name", "Staff")) return message.channel.send(`This server doesn't have a \`Support Staff\` 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.id)) return message.channel.send(`You already have a ticket open.`);
  6. message.guild.createChannel(`ticket-${message.author.username}`, { type: 'text' }).then(c => {
  7. let role = message.guild.roles.find(c => c.name === "Staff")
  8. let role2 = message.guild.roles.find(c => c.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. message.channel.send(`:white_check_mark: Your ticket has been created, #${c.name}.`);
  22. const embed = new Discord.RichEmbed()
  23. .setColor(0xCF40FA)
  24. .addField(`Hey ${message.author.username}!`, `Please try explain why you opened this ticket with as much detail as possible. Our **Staff** will be here soon to help.`)
  25. .setTimestamp();
  26. c.send({
  27. embed: embed
  28. });
  29. }).catch(console.error); // Send errors to console
  30. }
  31. function isCommand(message)
  32. {
  33. return message.content.toLowerCase().startsWith(PREFIX);
  34. }
  35. function clean(text)
  36. {
  37. if (typeof(text) === "string")
  38. return text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203));
  39. else
  40. return text;
  41. }
  42. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement