SHARE
TWEET

ticketbot

a guest Jul 16th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const botconfig = require("./botconfig.json");
  2. const Discord = require("discord.js");
  3. const bot = new Discord.Client({disableEveryone: true});
  4.  
  5. bot.on("ready", async () => {
  6.     console.log(`${bot.user.username} was started, with ${bot.users.size} users, in ${bot.channels.size} channels of ${bot.guilds.size} guilds!`);
  7.     bot.user.setActivity("ACTIVITY", {type: "PLAYING"});
  8.     bot.user.setActivity(`PREFIX | BOTUSERNAME`, {type: "PLAYING"});
  9. });
  10.    
  11. bot.on("guildCreate", guild => {
  12.     console.log(`New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`);
  13.     bot.user.setActivity(`Serving ${client.guilds.size} servers`);
  14. });
  15.    
  16. bot.on("guildDelete", guild => {
  17.     console.log(`I have been removed from: ${guild.name} (id: ${guild.id})`);
  18. });
  19.  
  20. if(command === "ping") {
  21.   message.channel.send(`:ping_pong: ${Math.round(client.ping)}ms`);
  22. };
  23.  
  24. if(cmd === `${prefix}close`) {
  25.   let cName = message.channel.name;
  26.   if (!cName.startsWith("ticket-") && !cName.startsWith("bestelling-") && !cName.startsWith("partnership-")) return message.channel.send("Je mag dit alleen in ticket kanalen doen.");
  27. var user = message.author;
  28. var botIcon = bot.user.displayAvatarURL;
  29. var embed = new Discord.RichEmbed()
  30. .setTimestamp()
  31. .setFooter("Servernaam hier", botIcon)
  32. .setColor("#46a7f2")
  33. .setThumbnail(botIcon)
  34. .setDescription("**__Servernaam hier | Close__**\n Bedankt voor het contacteren met ons, als u later nog vragen hebt kunt u gerust weer een ticket maken\n\nDoe **confirm** om het ticket volledig te sluiten, dit kan niet ongedaan worden.");
  35. message.channel.send(embed)
  36.     .then((message) => {
  37.     message.channel.awaitMessages(close => close.content === 'confirm', {
  38.         max: 1,
  39.         time: 20000,
  40.         errors: ['time'],
  41.     }).then(async (collected) => {
  42.         message.channel.delete();
  43.  
  44.             ///let tickets = await db.get("tickets");
  45.         //if (!tickets) tickets = 0;
  46.         //tickets++;
  47.         //await db.set("tickets", tickets);
  48.        
  49.         let closechannel = message.guild.channels.find(`name`, `modlogs`);
  50.         if(!closechannel) return message.channel.send("Kan dit kanaal niet vinden");
  51.         var botIcon = bot.user.displayAvatarURL;
  52.         var closeEmbed = new Discord.RichEmbed()
  53.         .setTimestamp()
  54.         .setFooter("Servernaam hier ", botIcon)
  55.         .setColor("#59a0d7")
  56.         .setThumbnail(botIcon)
  57.         .setTitle("***Ticket***")
  58.         .addField("Ticket gesloten door", user)
  59.         .addField("Ticket gesloten kanaal", message.channel.name);
  60.         closechannel.send(closeEmbed);                    
  61.     })
  62.         .catch(() => {
  63.         message.channel.send('Je wachtte te lang, je ticket is niet gesloten').then(message2 => {
  64.         }, 5000);
  65.         });
  66.     });        
  67. }
  68.  
  69. if (cmd === `${prefix}new` || cmd === `${prefix}ticket`) {;
  70.   const persoon = message.author.username;  
  71.   var user = message.author;
  72.    
  73.  
  74.         var bool = false;
  75.  
  76.     message.guild.channels.forEach((channel) => {
  77.  
  78.         if (channel.name == "ticket-" + persoon.toLowerCase()) {
  79.  
  80.             message.channel.send("Je hebt al een ticket aangemaakt");
  81.  
  82.             bool = true;
  83.  
  84.         }
  85.  
  86.     });
  87.  
  88.     if (bool == true) return;
  89.     const supportcategory1 = message.guild.channels.get(supportcategory);
  90.     const userChannel = message.guild.channels.find('name', `ticket-${persoon}`);
  91.     const Onderwerp = args.slice(0).join(" ");
  92.     if (!Onderwerp) return message.channel.send("Je moet een onderwerp aangeven");
  93.     message.delete().catch(O_o=>{});  
  94.     const supportrole = message.guild.roles.find('name', 'Support Team');
  95.     if (!supportcategory1) return message.channel.send(`Geen category gevonden`);
  96.     message.channel.send({ embed: { color: 0x46a7f2, description:`ticket aanmaken.....`}}).then(m => {
  97.     message.guild.createChannel(`ticket-${persoon}`, 'text').then((cc) => {
  98.        
  99.      cc.setTopic("Wilt u dit ticket sluiten? Gebruik dan -close. Ons team komt uw zo snel mogelijk helpen.")
  100.         .then(c => {
  101.           c.overwritePermissions(message.guild.id, {
  102.             READ_MESSAGES: false
  103.           });
  104.           c.overwritePermissions(message.author.id, {
  105.             READ_MESSAGES: true
  106.           });
  107.             c.overwritePermissions(supportrole.id, {
  108.               READ_MESSAGES: true
  109.             });
  110.      
  111.           cc.setParent(supportcategory1);
  112.  
  113.           //await db.set(c.id, {
  114.             //user: {
  115.               //id: message.author.id,
  116.               //username: message.author.username
  117.             //},
  118.             //onderwerp: Onderwerp,
  119.             //created: Date.now()
  120.           //});
  121.          
  122.           var botIcon = bot.user.displayAvatarURL;
  123.          
  124.           var tEmbed = new Discord.RichEmbed()
  125.           .setColor("#46a7f2")
  126.           .setThumbnail(botIcon)
  127.           .setTimestamp()
  128.           .addField("**Welkom**", `Welkom ${persoon}, Ons support team komt u zo snel mogelijk helpen. Om het geordend te houden kunt u met het volgende reageren\n\n:regional_indicator_b: = Voor een bestelling.\n:regional_indicator_p: = Voor partnership.\n:regional_indicator_t: = Voor support. `)
  129.           .addField("\nOnderwerp", Onderwerp)
  130.           .setFooter("Servernaam hier | Tickets", botIcon);
  131.          
  132.           var botIcon = bot.user.displayAvatarURL;
  133.           var ticketdone1Embed = new Discord.RichEmbed()
  134.           .setColor("#46a7f2")
  135.           .setTimestamp()
  136.           .setTitle("Servernaam hier - Tickets")
  137.           .setDescription(`:white_check_mark: *Je ticket is aangemaakt* ${c.name}`)
  138.           .setFooter("Servernaam hier | Tickets", botIcon);
  139.           c.send(tEmbed).then(imsg => {
  140.          imsg.react("🇧");
  141.          imsg.react("🇵");
  142.          imsg.react("🇹")
  143.         });
  144.        
  145.           m.edit(ticketdone1Embed);
  146. let ticketchannel = message.guild.channels.find(`name`, "modlogs");
  147. if(!ticketchannel) return message.channel.send("Kan dit kanaal niet vinden");
  148. var botIcon = bot.user.displayAvatarURL;
  149. var ticketEmbed = new Discord.RichEmbed()
  150. .setTimestamp()
  151. .setFooter("Servernaam hier", botIcon)
  152. .setColor("#46a7f2")
  153. .setThumbnail(botIcon)
  154. .addField("Ticket aangemaakt", user)
  155. .addField("Ticket naam", c.name)
  156. .addField("Onderwerp", Onderwerp)
  157. ticketchannel.send(ticketEmbed);  
  158.         });
  159.       });
  160.     })
  161. bot.on('messageReactionAdd', (reaction, user) => {
  162.   if (user.bot) return;
  163.           if (reaction.emoji.name == "🇧") {
  164.       reaction.message.channel.setParent("559836222017503237");
  165.       reaction.message.channel.setName("bestelling" + '-' + message.author.username)
  166.    
  167.        
  168.     }
  169. });      
  170. bot.on('messageReactionAdd', (reaction, user) => {
  171.   if (user.bot) return;
  172.           if (reaction.emoji.name == "🇵") {
  173.       reaction.message.channel.setParent("566735574904602638");
  174.       reaction.message.channel.setName("partnership" + '-' + message.author.username)
  175.    
  176.        
  177.     }      
  178. });
  179. bot.on('messageReactionAdd', (reaction, user) => {
  180.   if (user.bot) return;
  181.           if (reaction.emoji.name == "🇹") {
  182.       reaction.message.channel.setParent("559529218677932078");
  183.       reaction.message.channel.setName("ticket" + '-' + message.author.username)
  184.    
  185.        
  186.     }      
  187. });      
  188.   }
  189.  
  190.       if (cmd === `${prefix}add`)  {
  191.           message.delete().catch(O_o=>{});
  192.           let cName = message.channel.name;
  193.         if (!cName.startsWith("ticket-") && !cName.startsWith("bestelling-") && !cName.startsWith("partnership-")) return message.channel.send("Je mag dit alleen in ticket kanalen doen.");
  194.     let connectMember = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0])
  195.     if (!args[0]) return message.channel.send("Je moet een user opgeven");
  196.     message.channel.overwritePermissions(connectMember, {
  197.   CONNECT: true,
  198.   VIEW_CHANNEL: true,
  199.   SEND_MESSAGES: true
  200.  });
  201.     var botIcon = bot.user.displayAvatarURL;
  202.     var embed = new Discord.RichEmbed()
  203.     .setColor("#46a7f2")
  204.     .setTimestamp()
  205.     .setDescription(`User toegevoegt: ${connectMember}`)
  206.     .setFooter("Servernaam hier | Tickets", botIcon);
  207.    
  208.     message.channel.send(embed).then(msg => msg.delete(10000));
  209. let addchannel = message.guild.channels.find(`name`, "modlogs");
  210. if(!addchannel) return message.channel.send("Kan dit kanaal niet vinden");
  211. var botIcon = bot.user.displayAvatarURL;
  212. var addEmbed = new Discord.RichEmbed()
  213. .setTimestamp()
  214. .setFooter("Servernaam hier | Tickets", botIcon)
  215. .setColor("#46a7f2")
  216. .setThumbnail(botIcon)
  217. .setTitle("Servernaam hier | Tickets")
  218. .addField("Member toegevoegt door", message.author)  
  219. .addField("Member toegevoegt", connectMember)
  220. .addField("Toegevoegt aan ticket kanaal", message.channel.name);
  221. addchannel.send(addEmbed);        
  222. }
  223.  
  224. if (cmd === `${prefix}remove`)  {
  225.     message.delete().catch(O_o=>{});
  226.           let cName = message.channel.name;
  227.         if (!cName.startsWith("ticket-") && !cName.startsWith("bestelling-") && !cName.startsWith("partnership-")) return message.channel.send("Je mag dit alleen in ticket kanalen doen.");
  228.     let removeMember = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0])
  229.     if (!args[0]) return message.channel.send("Je moet een user opgeven");
  230.     message.channel.overwritePermissions(removeMember, {
  231.   CONNECT: false,
  232.   VIEW_CHANNEL: false,
  233.   SEND_MESSAGES: false
  234.  });
  235.     var botIcon = bot.user.displayAvatarURL;
  236.     var embed = new Discord.RichEmbed()
  237.     .setColor("#46a7f2")
  238.     .setTimestamp()
  239.     .setDescription(`User verwijderd: ${removeMember}`)
  240.     .setFooter("Servernaam hier | Tickets", botIcon);
  241.    
  242.     message.channel.send(embed).then(msg => msg.delete(10000));
  243. let removechannel = message.guild.channels.find(`name`, "modlogs");
  244. if(!removechannel) return message.channel.send("Kan dit kanaal niet vinden");
  245. var botIcon = bot.user.displayAvatarURL;
  246. var removeEmbed = new Discord.RichEmbed()
  247. .setTimestamp()
  248. .setFooter("Servernaam hier | Tickets", botIcon)
  249. .setColor("#46a7f2")
  250. .setThumbnail(botIcon)
  251. .setTitle("Servernaam hier | Tickets")
  252. .addField("Member verwijderd door", message.author)  
  253. .addField("Member verwijderd", removeMember)
  254. .addField("Verwijderd uit ticket kanaal", message.channel.name);
  255. removechannel.send(removeEmbed);        
  256. }
  257.  
  258. bot.login(botconfig.token);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top