Advertisement
Guest User

ddddddddddddddddddddd

a guest
Jul 24th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.64 KB | None | 0 0
  1. const Discord = require('discord.js');
  2. const client = new Discord.Client();
  3. const prefix = "-";
  4. const category = "category-id";
  5. const devs = ["505022273418428426"];
  6. let mtickets = true;
  7. let tchannels = [];
  8. let current = 0;
  9.  
  10.  
  11. client.on('ready',async () => console.log(` - " ${client.user.username} " , Tickety is ready to work.`));
  12. client.on('message',async message => {
  13. if(message.author.bot || message.channel.type === 'dm') return;
  14. let args = message.content.split(" ");
  15. let author = message.author.id;
  16. if(args[0].toLowerCase() === `${prefix}help`) {
  17. let embed = new Discord.RichEmbed()
  18. .setAuthor(message.author.username, message.author.avatarURL)
  19. .setThumbnail(message.author.avatarURL)
  20. .setColor("#36393e")
  21. .addField(`⇏ -new → لفتح تكت`)
  22. .addField(`⇏ -close → لغلق تكت`)
  23. .addField(`⇏ -mtickets enable/disable → لتعطيل وتفعيل تكت `)
  24. .addField(`⇏ -cleartickets → لمسح جميع تكتات`)
  25. .addField(``)
  26. await message.channel.send(`:white_check_mark: , **هذه قائمة بجميع اوامر البووت.**`);
  27. await message.channel.send(embed);
  28. } else if(args[0].toLowerCase() === `${prefix}new`) {
  29. if(mtickets === false) return message.channel.send(`:tools: , **تم ايقاف هذه الخاصية من قبل احد ادارة السيرفر**`);
  30. if(!message.guild.me.hasPermission("MANAGE_CHANNELS")) return message.channel.send(`:tools: , **البوت لا يملك صلاحيات لصنع الروم**`);
  31. console.log(current);
  32. let openReason = "";
  33. current++;
  34. message.guild.createChannel(`ticket-${current}`, 'text').then(c => {
  35. tchannels.push(c.id);
  36. c.setParent(category);
  37. message.channel.send(`**:tickets: تم عمل التكت.**`);
  38. c.overwritePermissions(message.guild.id, {
  39. READ_MESSAGES: false,
  40. SEND_MESSAGES: false
  41. });
  42. c.overwritePermissions(message.author.id, {
  43. READ_MESSAGES: true,
  44. SEND_MESSAGES: true
  45. });
  46.  
  47. if(args[1]) openReason = `\nسبب فتح التكت , " **${args.slice(1).join(" ")}** "`;
  48. let embed = new Discord.RichEmbed()
  49. .setAuthor(message.author.username, message.author.avatarURL)
  50. .setColor("#36393e")
  51. .setDescription(`**انتظر قليلا الى حين رد الادارة عليك**${openReason}`);
  52. c.send(`${message.author}`);
  53. c.send(embed);
  54. });
  55. } else if(args[0].toLowerCase() === `${prefix}mtickets`) {
  56. if(!message.member.hasPermission("MANAGE_GUILD")) return message.channel.send(`:tools: , **أنت لست من ادارة السيرفر لتنفيذ هذا الأمر.**`);
  57. if(args[1] && args[1].toLowerCase() === "enable") {
  58. mtickets = true;
  59. message.channel.send(`:white_check_mark: , **تم تفعيل التكتات , الاَن يمكن لأعضاء السيرفر استخدام امر انشاء التكت**`);
  60. } else if(args[1] && args[1].toLowerCase() === "disable") {
  61. mtickets = false;
  62. message.channel.send(`:white_check_mark: , **تم اغلاق نظام التكتات , الاَن لا يمكن لأي عضو استخدام هذا الأمر**`);
  63. } else if(!args[1]) {
  64. if(mtickets === true) {
  65. mtickets = false;
  66. message.channel.send(`:white_check_mark: , **تم اغلاق نظام التكتات , الاَن لا يمكن لأي عضو استخدام هذا الأمر**`);
  67. } else if(mtickets === false) {
  68. mtickets = true;
  69. message.channel.send(`:white_check_mark: , **تم تفعيل التكتات , الاَن يمكن لأعضاء السيرفر استخدام امر انشاء التكت**`);
  70. }
  71. }
  72. } else if(args[0].toLowerCase() === `${prefix}close`) {
  73. if(!message.member.hasPermission("MANAGE_GUILD")) return message.channel.send(`:tools:, **أنت لست من ادارة السيرفر لتنفيذ هذا الأمر.**`);
  74. if(!message.channel.name.startsWith('ticket-') && !tchannels.includes(message.channel.id)) return message.channel.send(`:tools:, **هذا الروم ليس من رومات التكت.**`);
  75.  
  76. message.channel.send(`:white_check_mark:, **سيتم اغلاق الروم في 3 ثواني من الاَن.**`);
  77. tchannels.splice( tchannels.indexOf(message.channel.id), 1 );
  78. setTimeout(() => message.channel.delete(), 3000);
  79. } else if(args[0].toLowerCase() === `${prefix}restart`) {
  80. if(!devs.includes(message.author.id)) return message.channel.send(`:tools:, **أنت لست من ادارة السيرفر لأستخدام هذا الأمر.**`);
  81. message.channel.send(`:white_check_mark:, **جارى اعادة تشغيل البوت.**`);
  82. client.destroy();
  83. } else if(args[0].toLowerCase() === `${prefix}deletetickets`) {
  84. let iq = 0;
  85. for(let q = 0; q < tchannels.length; q++) {
  86. let c = message.guild.channels.get(tchannels[q]);
  87. if(c) {
  88. c.delete();
  89. tchannels.splice( tchannels[q], 1 );
  90. iq++;
  91. }
  92. if(q === tchannels.length - 1 || q === tchannels.lengh + 1) {
  93. message.channel.send(`:white_check_mark:, **تم مسح \`${iq}\` من التكتات.**`);
  94. }
  95. }
  96. }
  97. });
  98.  
  99. client.login(process.env.BOT_TOKEN);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement