Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. const Discord = require('discord.js')
  2. const bot = new Discord.Client();
  3. const fs = require('fs');
  4. const db = JSON.parse(fs.readFileSync("./db.json", "utf8"));
  5. const prefix = "-";
  6.  
  7. module.exports.run = async (bot, message, args) => {
  8. const config = await yml("./config.yml");
  9.  
  10. bot.on("message", async msg => {
  11. if(msg.author.bot || !msg.channel.guild) return;
  12. let args = msg.content.slice(prefix.length).split(" ");
  13. let cmd = args.shift().toLowerCase();
  14.  
  15. if(cmd == 'apply') {
  16. if(!db[msg.guild.id]){
  17. db[msg.guild.id] = {
  18. counter: 0
  19. };
  20. }
  21. let job = args.join(' ');
  22. if(!job) {
  23. let embed = new Discord.RichEmbed()
  24. .setColor("RED")
  25. .setDescription(`:x: Please supply job name - Ex: ${prefix}apply Graphics Designer`);
  26. return msg.channel.send(embed)
  27. }
  28. db[msg.guild.id] = {
  29. counter: db[msg.guild.id].counter + 1
  30. };
  31. await fs.writeFile("./db.json", JSON.stringify(db), (err) => {
  32. if (err) console.error(err)
  33. });
  34. let count = db[msg.guild.id].counter;
  35. const channel = await msg.guild.createChannel(`application-${count}`, 'text');
  36. await channel.overwritePermissions(msg.guild.id, {
  37. READ_MESSAGES: false,
  38. SEND_MESSAGES: false
  39. });
  40. await channel.overwritePermissions(msg.author.id, {
  41. READ_MESSAGES: true,
  42. SEND_MESSAGES: true
  43. });
  44. let embed = new Discord.RichEmbed()
  45. .setTitle('Odyssey Services')
  46. .setTimestamp()
  47. .setDescription(`<@${msg.author.id}>, Thank you for creating an application ticket. Our management team will respond as soon as possible. \nPlease inform our management team about what is you job to speed up our reponse time.\n\n**Job: ${job}**`)
  48. .setColor('#55afe4');
  49. channel.send(embed);
  50. let em = new Discord.RichEmbed()
  51. .setColor(`#55afe4`)
  52. .setDescription(`:white_check_mark: **Created your application ticket in ${channel}**`);
  53. return msg.channel.send(em);
  54. }
  55. });
  56.  
  57. module.exports.help = {
  58. name: "apply"
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement