Advertisement
akimc

Untitled

Jul 17th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. const config = require('./botconfig.json');
  2. const fs = require('fs')
  3.  
  4. const Discord = require('discord.js')
  5. const client = new Discord.Client()
  6.  
  7. client.on('ready', () => {
  8. console.log(`Logged in as ${client.user.tag}!`)
  9. })
  10.  
  11. client.on('message', async function(message) {
  12. let messageArray = message.content.split(/\s/);
  13. let cmd = messageArray[0];
  14.  
  15. if (cmd.toLowerCase() == `${config.prefix}admin`){
  16. var channel;
  17. var Member;
  18. channel = await message.guild.createChannel(`${message.author.username}`, "text").catch(ex => console.error(ex));
  19. var newMessage = await channel.send(`We recognize your request for help and one of our admins will be on it right away, please don't spam any of our admins or at them, they will be with you just as soon as they can. /complete to close the support channel.`);
  20. var Roles = await message.member.roles.array();
  21. var AuthorRole = await message.guild.createRole({
  22. name: message.author.username
  23. }).catch(ex => console.error(ex));
  24. Roles.forEach(async(role) => {
  25. await channel.overwritePermissions(role, {
  26. READ_MESSAGE: false,
  27. VIEW_CHANNEL: false
  28. });
  29. });
  30. channel.overwritePermissions(AuthorRole, {
  31. READ_MESSAGE: true,
  32. VIEW_CHANNEL: true
  33. });
  34. await message.member.addRole(AuthorRole);
  35. message.channel.send("Created the support channel!");
  36. }
  37.  
  38. if(cmd.toLowerCase() == `${config.prefix}complete` && message.channel.name == message.author.username){
  39. var boolean = (message.channel.name.toLowerCase() == message.author.username.toLowerCase());//Boolean Expression; will return true or false.
  40. if (boolean){
  41. message.member.send("Your support ticket is now closed!");
  42. message.channel.delete();
  43. }
  44. else {
  45. return;
  46. }
  47.  
  48. }})
  49.  
  50. client.login(config.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement