Advertisement
smilerryan

[JS] Custom Ticket Bot for Discord.js

Jun 10th, 2018
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Creates automatic question tickets (with close feature) and notifies via reactions.
  2. //This Discord bot requires the Eris module to run. To install: npm install Eris
  3. //Get your own bot token at: https://discordapp.com/developers/applications/me
  4. const token = "                                                           ";
  5. const Eris = require('eris');
  6. const bot = new Eris(token);
  7.  
  8. bot.on("ready", () => {
  9. process.title = "TicketBot by SmilerRyan | " + bot.user.id + " | " + bot.user.username + "#" + bot.user.discriminator;
  10. console.log("To create a ticket, ask a question.\nTo close a ticket, type close.\n\nTo ignore ticket creation in specified channels,\ndeny the bot the read messages permission in the channel.\n\nThis bot needs the following permissions:\n- Read messages (to check for questions)\n- Add reactions (to tell them about it)\n- Manage channels (to manage channels)\n\nTicket bot by SmilerRyan\nID: " + bot.user.id + "\n"+bot.user.username + "#" + bot.user.discriminator);
  11. bot.editStatus("dnd");
  12. });
  13.  
  14. bot.on("messageCreate", (msg) => {
  15.         if(msg.channel.guild != null && msg.author.id != bot.user.id) {
  16.             if(msg.content.startsWith("close") && msg.channel.name.startsWith("ticket-")) {msg.channel.delete();}
  17.             if((msg.content.endsWith("?") && msg.content.length >= 10) && !msg.channel.name.startsWith("ticket-")) {
  18.                 msg.channel.guild.createChannel("ticket-" + msg.author.username.replace(/[\W_]+/g," "), "0", "Ticket Created.").then(c => {
  19.                     c.editPermission(msg.author.id, 1024, 0, "member", "Ticket Auto-Permissions.");
  20.                     c.editPermission(bot.user.id, 1024, 0, "member", "Ticket Auto-Permissions.");
  21.                     c.editPermission("450689860710301716", 0, 1024, "role", "Ticket Auto-Permissions.");
  22.                     c.createMessage(msg.author.mention + " asks: " + msg.cleanContent);
  23.                 });
  24.                 msg.addReaction("🎟"); //Add Ticket Reaction
  25.         }}
  26. });
  27.  
  28. bot.connect();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement