gaber-elsayed

Clan System

Apr 13th, 2020
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.31 KB | None | 0 0
  1.  
  2. const Discord = require('discord.js');
  3. const hero = new Discord.Client();
  4. const prefix = '-'
  5.  
  6. hero.on('ready',async () => {
  7. console.log(`Otaku: , iAmHeRo¹⁵ ☤`);
  8. console.log(`User: ${hero.user.username}`);
  9. console.log(`Servers: ${hero.guilds.size}`);
  10. hero.generateInvite(['ADMINISTRATOR']).then(link => console.log(link));
  11. });
  12.  
  13.  
  14. const fs = require('fs');
  15. const clans = JSON.parse(fs.readFileSync("./ClanSystem/ClanSystem.json", 'UTF8'));
  16. const system = JSON.parse(fs.readFileSync("./ClanSystem/ClanStats.json", 'UTF8'));
  17. const level = JSON.parse(fs.readFileSync("./ClanSystem/ClanLevels.json", 'UTF8'));
  18.  
  19. hero.on('message',async message => {
  20. if(message.author.bot) return;
  21. if(message.channel.type === 'dm') return;
  22.  
  23. let args = message.content.split(' ');
  24. let random = Math.floor(Math.random() * 5) + 2;
  25. let author = message.author;
  26.  
  27. let xpLeft;
  28. let nameClan;
  29. let membersClan = [];
  30. let levelClan = 0;
  31. if(!system[author.id]) system[author.id] = {clan: 'None',joinedAt: new Date().toLocaleString() ,clanLevel: 0};
  32. fs.writeFile('./ClanSystem/ClanSystem.json', JSON.stringify(clans, null, 4), function(err) {if(err) console.log(err)});
  33. if(!level[author.id]) level[author.id] = {level: 1, xp: 1};
  34. fs.writeFile('./ClanSystem/ClanLevels.json', JSON.stringify(level, null, 4), function(err) {if(err) console.log(err)});
  35.  
  36. level[author.id].xp += (+random);
  37. if(level[author.id].xp >= 300) {
  38. if(level[author.id].xp > 300) xpLeft = level[author.id].xp - 300;
  39. level[author.id] = {
  40. level: level[author.id].level + 1,
  41. xp: xpLeft
  42. };
  43. fs.writeFile('./ClanSystem/ClanLevels.json', JSON.stringify(level, null, 4), function(err) {if(err) console.log(err)});
  44. }
  45. if(message.content.startsWith(prefix + "clan")) {
  46. if(message.content.split(' ')[0] !== `${prefix}clan`) return;
  47.  
  48. if(!args[1] || args[1] && args[1] === 'info') {
  49. let embed = new Discord.RichEmbed()
  50. .setAuthor('الكلانات', message.author.avatarURL)
  51. .setDescription(`- \`${prefix}clan\`: نظام الكلانات هو نظام شبه مسلي ينمي التفاعل ويمكنك التحكم بالكلان تبعك بشكل كامل
  52. - \`${prefix}clan info\`: لأظهار رسالة الأوامر ( هذه الرسالة ) ء
  53. - \`${prefix}clan create\`: لأنشاء كلان بالأسم الذي تريده
  54. - \`${prefix}clan invite\`: لدعوة شخص ما للكلان تبعك
  55. - \`${prefix}clan join\`: للتقديم على دخول الكلان الذي تريده
  56. - \`${prefix}clan promote\`: لأعطاء شخص بالكلان صلاحيات الادمن ( يتطلب صلاحية الادمن ) ء
  57. - \`${prefix}clan demote\`: لأزالة صلاحية الادمن من عضو بالكلان ( صاحب الكلان فقط ) ء
  58. - \`${prefix}clan ownership\`: لنقل ملكيةالكلان
  59. - \`${prefix}clan leave\`: للخروج من الكلان الذي انت به
  60. - \`${prefix}clan kick\`: لطرد عضو من الكلان ( يتطلب صلاحية الادمن ) ء
  61. - \`${prefix}clan disband\`: لمسح الكلان من السستم ( صاحب الكلان فقط ) ء
  62. - \`${prefix}clan stats\`: لعرض معلومات الكلان تبعك
  63. - \`${prefix}clan list\`: يظهر لك اعضاء الكلان برسالة
  64. - \`${prefix}clan accept\`: لقبول شخص وجعل الشخص يدخل الكلان ( يتطلب صلاحية الادمن ) ء
  65. - \`${prefix}clan decline\`: لرفض شخص وعم جعل الشخص يدخل الكلان ( يطلب صلاحية الادمن ) ء
  66. - \`${prefix}clan rename\`: تغير الاسم الكلان ( صاحب الكلان فقط ) ء`)
  67. .setFooter(message.author.username, message.author.avatarURL);
  68. message.channel.send(embed);
  69. }
  70.  
  71. if(args[1] && args[1] === 'create') {
  72. //if(level[author.id].level < 10) return message.channel.send('**# يجب أن يكون لديك 10 مستويات لعمل كلان , لتجميع مستويات تفاعل بالشات وسيتم حساب النقاط**');
  73. if(system[author.id].clan !== 'None') return message.channel.send('**# يجب عليك ان تخرج من الكلان الذي أنت به حاليا**');
  74.  
  75. let m = await message.channel.send('**# أكتب أسم الكلان الان**');
  76. let awaited = await message.channel.awaitMessages(r => r.author.id === message.author.id, { max: 1, time: 20000, errors: ['time']}).then(collected => {
  77. if(collected.first().content.length > 25) return message.channel.send("**# لا يمكنك وضع اسم للكلان يفوق الـ25 حرفا , أعد كابة الأمر**");
  78. if(collected.first().content.includes("None")) return message.channel.send("**# `None`, لا يمكنك وضع هذه الكلمة كأسم للكلان**");
  79. collected.first().delete().catch();
  80. nameClan = collected.first().content;
  81. });
  82.  
  83. m = await m.edit('**# جارى عمل الكلان**');
  84. awaited = await setTimeout(async() => {
  85. let membersArray = {
  86. nameClan: {
  87. array: []
  88. }
  89. };
  90. let members = membersArray.nameClan.array;
  91. members.push(message.author.id);
  92. clans[nameClan] = {
  93. name: nameClan,
  94. createdAt: new Date().toLocaleString(),
  95. level: levelClan,
  96. creator: message.author.id,
  97. members: members,
  98. applylist: [],
  99. admins: []
  100. };
  101. fs.writeFile('./ClanSystem/ClanSystem.json', JSON.stringify(clans, null, 4), function(err) {if(err) console.log(err)});
  102. system[author.id] = {
  103. clan: nameClan,
  104. joinedAt: new Date().toLocaleString(),
  105. clanLevel: 0,
  106. creator: message.author.id
  107. };
  108. fs.writeFile('./ClanSystem/ClanStats.json', JSON.stringify(system, null, 4), function(err) {if(err) console.log(err)});
  109. m = await m.edit('**# تم عمل الكلان بنجاح**');
  110. }, 2300);
  111.  
  112. }
  113. if(args[1] && args[1] === 'invite') {
  114. if(!system[author.id]) return message.channel.send("**# أنت لست بكلان**");
  115. let clan = system[author.id].clan;
  116. if(system[author.id].clan === 'None') return message.channel.send('**# أنت لست بكلان**');
  117. if(!clans[clan].admins.includes(message.author.id) && clans[system[author.id].clan].creator !== message.author.id) return message.channel.send('**# يجب عليك ان تكون اداري بالكلان**');
  118. let mention = message.mentions.users.first();
  119. if(!mention) return message.channel.send('**# منشن شخص لدعوته للكلان**');
  120. if(clans[clan].members.includes(mention.id)) return message.channel.send("**# هذا العضو بالكلان بالفعل**");
  121. if(clans[clan].members.length === 10) return message.channel.send("**# هذا الكلان وصل للحد الاقصى من الاعضاء يمكنك**");
  122.  
  123. let m = await message.channel.send(`**${mention} # \`${clan}\`, تم دعوتك لدخول الكلان**\n\n - لقبول الدعوة \`نعم\`\n - لرفض الدعوة \`لا\``);
  124. let awaiting = await message.channel.awaitMessages(r => r.author.id === mention.id, {max: 1, time: 20000, errors:['time']}).then(collected => {
  125. collected.first().delete().catch();
  126. if(collected.first().content === 'نعم') {
  127. clans[clan].members.push(mention.id);
  128. fs.writeFile('./ClanSystem/ClanSystem.json', JSON.stringify(clans, null, 4), function(err) {if(err) console.log(err)});
  129. system[author.id].members += 1;
  130. fs.writeFile('./ClanSystem/ClanStats.json', JSON.stringify(system, null, 4), function(err) {if(err) console.log(err)});
  131.  
  132. system[mention.id] = {
  133. clan: clan,
  134. joinedAt: new Date().toLocaleString(),
  135. clanLevel: 0,
  136. creator: clans[clan].creator
  137. };
  138. fs.writeFile('./ClanSystem/ClanStats.json', JSON.stringify(system, null, 4), function(err) {if(err) console.log(err)});
  139. message.channel.send(`**${message.author} # تم قبول الدعوة**`);
  140. }
  141. if(collected.first().content === 'لا') {
  142. message.channel.send(`**${message.author} # تم رفض الدعوة**`);
  143. } else if(collected.first().content !== 'نعم' && collected.first().content !== 'لا'){
  144. return message.channel.send('**# يجب عليك كتابة `نعم` أو `لا`**');
  145. }
  146. });
  147. }
  148. if(args[1] && args[1] === 'stats') {
  149. if(system[author.id].clan === 'None') return message.channel.send('**# يجب ان تكون بكلان لأستخدام هذا الأمر**');
  150. let clan = system[author.id].clan;
  151. let embed = new Discord.RichEmbed()
  152. .setAuthor(`${message.author.username} || الكلانات`, message.author.avatarURL)
  153. .setDescription(`الكلان || \`${clan.toString()}\``)
  154. embed.addField('» اسم الكلان', clan, true)
  155. embed.addField('» تاريخ عمل الكلان', clans[clan].createdAt, true);
  156. embed.addField('» تاريخ دخول الكلان', system[author.id].joinedAt, true)
  157. embed.addField('» صاحب الكلان', `<@${clans[clan].creator}>`, true);
  158. embed.addField('» لفل الكلان', clans[clan].level, true);
  159. embed.addField('» عدد اعضاء الكلان', clans[clan].members.length, true);
  160. embed.addField('» عدد التقديمات للكلان', clans[clan].applylist.length, true);
  161. embed.addField('» عدد الادمنية بالكلان', clans[clan].admins.length, true);
  162. embed.addField('» اعضاء الكلان', `${prefix}clan list || يظهرلك رسالة بها اعضاء الكلان`);
  163. message.channel.send(embed);
  164.  
  165. }
  166. if(args[1] && args[1] === 'join') {
  167. let clanName = message.content.split(' ').slice(2).join(" ");
  168. if(system[author.id].clan !== 'None') return message.channel.send("**# يجب أن لا تكون بكلان**");
  169. if(!args[2]) return message.channel.send("**# يجب عليك كتابة اسم الكلان**");
  170. if(!clans[clanName]) return message.channel.send("**# هذا الكلان غير موجود**");
  171. if(clans[clanName].applylist.includes(message.author.id)) return message.channel.send("**# لقد قدمت على دخول هذا الكلان مسبقا");
  172.  
  173. clans[clanName].applylist.push(message.author.id);
  174. message.channel.send("**# لقد تم التقديم على دخول الكلان , سيتم الرد عليك من قبل احد ادارة الكلان**");
  175.  
  176. }
  177. if(args[1] && args[1] === 'accept') {
  178. let mention = message.mentions.users.first();
  179. if(system[author.id].clan === 'None') return message.channel.send("**# يجب عليك ان تكون بكلان لأستخدام هذا الأمر**");
  180. if(!clans[system[author.id].clan].admins.includes(message.author.id) && clans[system[author.id].clan].creator !== message.author.id) return message.channel.send("**# يجب عليك ان تكون اداري بالكلان لأستخدام هذا الأمر**");
  181. if(!mention) return message.channel.send("**# يجب عليك منشنة شخص لأستخدام هذا الأمر**");
  182. if(!system[mention.id]) system[mention.id] = {clan: 'None',joinedAt: new Date().toLocaleString() ,clanLevel: 0};
  183. fs.writeFile('./ClanSystem/ClanSystem.json', JSON.stringify(clans, null, 4), function(err) {if(err) console.log(err)});
  184. if(!clans[system[author.id].clan].applylist.includes(mention.id)) return message.channel.send("**# هذا الشخص لم يقم بالتقديم على دخول الكلان**");
  185.  
  186. clans[system[author.id].clan].applylist.shift(mention.id);
  187. clans[system[author.id].clan].members.push(mention.id);
  188. let clan = system[author.id].clan;
  189. fs.writeFile('./ClanSystem/ClanSystem.json', JSON.stringify(clans, null, 4), function(err) {if(err) console.log(err)});
  190.  
  191. system[mention.id] = {
  192. clan: clan,
  193. joinedAt: new Date().toLocaleString(),
  194. clanLevel: 0,
  195. creator: clans[clan].creator
  196. };
  197. fs.writeFile('./ClanSystem/ClanStats.json', JSON.stringify(system, null, 4), function(err) {if(err) console.log(err)});
  198.  
  199. mention.send(`**# \`${system[author.id].clan}\`, لقد تم قبولك بالكلان**`).catch();
  200. message.channel.send(`**# \`${mention.username}\`, لقد تم قبول الشخص ودخوله للكلان**`);
  201. }
  202. if(args[1] && args[1] === 'decline') {
  203. let mention = message.mentions.users.first();
  204. if(system[author.id].clan === 'None') return message.channel.send("**# يجب عليك ان تكون بكلان لأستخدام هذا الأمر**");
  205. if(!clans[system[author.id].clan].admins.includes(message.author.id) && clans[system[author.id].clan].creator !== message.author.id) return message.channel.send("**# يجب عليك ان تكون اداري بالكلان لأستخدام هذا الأمر**");
  206. if(!mention) return message.channel.send("**# يجب عليك منشنة شخص لأستخدام هذا الأمر**");
  207. if(!system[mention.id]) system[mention.id] = {clan: 'None',joinedAt: new Date().toLocaleString() ,clanLevel: 0};
  208. fs.writeFile('./ClanSystem/ClanSystem.json', JSON.stringify(clans, null, 4), function(err) {if(err) console.log(err)});
  209. if(!clans[system[author.id].clan].applylist.includes(mention.id)) return message.channel.send("**# هذا الشخص لم يقم بالتقديم على دخول الكلان**");
  210.  
  211. clans[system[author.id].clan].applylist.shift(mention.id);
  212. fs.writeFile('./ClanSystem/ClanSystem.json', JSON.stringify(clans, null, 4), function(err) {if(err) console.log(err)});
  213. system[mention.id] = {
  214. clan: clans[system[author.id].clan],
  215. joinedAt: new Date().toLocaleString(),
  216. clanLevel: 0
  217. };
  218. fs.writeFile('./ClanSystem/ClanStats.json', JSON.stringify(system, null, 4), function(err) {if(err) console.log(err)});
  219.  
  220. mention.send(`**# \`${system[author.id].clan}\`, لقد تم رفض دخولك للكلان**`).catch();
  221. message.channel.send(`**# \`${mention.username}\`, لقد تم رفض دخول الشخص للكلان**`);
  222.  
  223. }
  224. if(args[1] && args[1] === 'promote') {
  225. let mention = message.mentions.users.first();
  226. if(system[author.id].clan === 'None') return message.channel.send("**# يجب ان تكون بكلان لأستخدام هذا الأمر**");
  227. if(!clans[system[author.id].clan].admins.includes(message.author.id) && clans[system[author.id].clan].creator !== message.author.id) return message.channel.send("**# يجب عليك ان تكون اونر او ادمن بالكلان لترقية عضو بالكلان**");
  228. if(!mention) return message.channel.send("**# يجب عليك منشنة عضو بالكلان لأعطائه الترقية**");
  229. if(!system[mention.id]) system[mention.id] = {clan: 'None',joinedAt: new Date().toLocaleString() ,clanLevel: 0};
  230. fs.writeFile('./ClanSystem/ClanSystem.json', JSON.stringify(clans, null, 4), function(err) {if(err) console.log(err)});
  231. if(system[mention.id].clan === 'None') return message.channel.send("**# هذا الشخص ليس بكلان**");
  232. if(!clans[system[author.id].clan].members.includes(mention.id)) return message.channel.send("**# هذا الشخص ليس بالكلان**");
  233. if(clans[system[author.id].clan].admins.includes(mention.id)) return message.channel.send("**# هذا العضو لديه ادمن بالفعل**");
  234. if(mention.id === message.author.id) return message.channel.send("**# لا يمكنك اعطاء نفسك ترقية**");
  235.  
  236. clans[system[author.id].clan].admins.push(mention.id);
  237. fs.writeFile('./ClanSystem/ClanSystem.json', JSON.stringify(clans, null, 4), function(err) {if(err) console.log(err)});
  238.  
  239. mention.send(`**# \`${system[author.id].clan}\`, لقد تم ترقيتك الى ادمن**`).catch();
  240. message.channel.send(`**# \`${mention.username}\`, لقد تم ترقية العضو الى رتبة ادمن**`);
  241. }
  242. if(args[1] && args[1] === 'demote') {
  243. let mention = message.mentions.users.first();
  244. if(system[author.id].clan === 'None') return message.channel.send("**# يجب ان تكون بكلان لأستخدام هذا الأمر**");
  245. if(clans[system[author.id].clan].creator !== message.author.id) return message.channel.send("**# هذا الأمر لضاحب الكلان فقط**");
  246. if(!mention) return message.channel.send("**# يجب عليك منشنة عضو بالكلان لأعطائه الترقية**");
  247. if(!system[mention.id]) system[mention.id] = {clan: 'None',joinedAt: new Date().toLocaleString() ,clanLevel: 0};
  248. fs.writeFile('./ClanSystem/ClanSystem.json', JSON.stringify(clans, null, 4), function(err) {if(err) console.log(err)});
  249. if(system[mention.id].clan === 'None') return message.channel.send("**# هذا الشخص ليس بكلان**");
  250. if(!clans[system[author.id].clan].members.includes(mention.id)) return message.channel.send("**# هذا الشخص ليس بالكلان**");
  251. if(!clans[system[author.id].clan].admins.includes(mention.id)) return message.channel.send("**# هذا الشخص ليس ادمن بالكلان**");
  252. if(mention.id === message.author.id) return message.channel.send("**# لا يمكنك اعطاء نفسك ترقية**");
  253.  
  254. clans[system[author.id].clan].admins.shift(mention.id);
  255. fs.writeFile('./ClanSystem/ClanSystem.json', JSON.stringify(clans, null, 4), function(err) {if(err) console.log(err)});
  256. mention.send(`**# \`${system[author.id].clan}\`, لقد تم ازالتك من منصب الادمن**`).catch();
  257. message.channel.send(`**# \`${mention.username}\`, لقد تم ازالة الادمنية من العضو**`);
  258. }
  259. if(args[1] && args[1] === 'rename') {
  260. if(system[author.id].clan === 'None') return message.channel.send("**# يجب ان تكون بكلان لأستخدام هذا الأمر**");
  261. let newName;
  262. let oldName = clans[system[author.id].clan];
  263. if(clans[system[author.id].clan].creator !== message.author.id) return message.channel.send("**# هذا الأمر مخصص لصاحب الكلان فقط**");
  264. if(!args[2]) return message.channel.send("**# يجب عليك تحديد اسم الكلان**");
  265.  
  266. let c = message.content.split(' ').slice(2).join(" ");
  267. newName = c;
  268. let clanInfo = clans[system[author.id].clan];
  269. let m = await message.channel.send(`**# \`${c}\`, هل أنت متأكد من تغيير اسم الكلان \n\n - للتأكيد \`نعم\`\n - للرفض \`لا\`**`);
  270. let awaiting = await message.channel.awaitMessages(r => r.author.id === message.author.id, {max: 1, time: 20000, errors: ['time']}).then(c => {
  271. let collected = c.first();
  272. collected.delete().catch();
  273. m.delete().catch();
  274. if(collected.content === 'نعم') {
  275. clans[newName] = {
  276. name: newName,
  277. createdAt: clanInfo.createdAt,
  278. level: clanInfo.level,
  279. creator: clanInfo.creator,
  280. members: clanInfo.members,
  281. applylist: clanInfo.applylist,
  282. admins: clanInfo.admins
  283. };
  284. clans[system[author.id].clan] = undefined;
  285. fs.writeFile('./ClanSystem/ClanSystem.json', JSON.stringify(clans, null, 4), function(err) {if(err) console.log(err)});
  286. system[author.id].clan = newName;
  287. fs.writeFile('./ClanSystem/ClanStats.json', JSON.stringify(system, null, 4), function(err) {if(err) console.log(err)});
  288.  
  289. message.channel.send("**# جارى تغيير الاسم**");
  290. message.channel.send("**# تم تغيير اسم الكلان بنجاح**");
  291.  
  292. } else if(collected.content === 'لا') {
  293. message.channel.send(`**# \`${newName}\`, تم الغاء تغيير اسم الكلان**`);
  294.  
  295. } else if(collected.first().content !== 'نعم' && collected.first().content !== 'لا'){
  296. return message.channel.send('**# يجب عليك كتابة `نعم` أو `لا`**')
  297. }
  298. });
  299. }
  300. if(args[1] && args[1] === 'list') {
  301. if(system[author.id].clan === 'None') return message.channel.send("**# يجب عليك ان تكون بكلان لأستخدام هذا الأمر**");
  302. let clan = clans[system[author.id].clan];
  303. let members = Array.from(clan.members);
  304. let admins = Array.from(clan.admins);
  305. let applylist = Array.from(clan.applylist);
  306. let i = 1;
  307. let o = 1;
  308.  
  309. let embed = new Discord.RichEmbed();
  310. embed.setAuthor(`${message.author.username} || ${clan.name}`, message.author.avatarURL);
  311. embed.addField("# Members", members.map(r => `\`${i++}.\` **|| <@${r}>**`).join('\n') || `\`1.\` **|| None**`, true);
  312. embed.addField('# Admins', admins.map(r => `\`${o++}.\` **|| <@${r}>**`).join('\n') || `\`1.\` **|| None**`, true);
  313. embed.addField('# Apply', applylist.map(r => `\`${o++}.\` **|| <@${r}>**`).join('\n') || `\`1.\` **|| None**`, true);
  314. embed.addField('# Owner', `\`1.\` **|| <@${clan.creator}>**`, true);
  315. message.channel.send(embed);
  316. }
  317. if(args[1] && args[1] === 'leave') {
  318. if(system[author.id].clan === 'None') return message.channel.send("**# يجب ان تكون بكلان لأستخدام هذا الأمر**");
  319. let m = await message.channel.send("**# هل انت متأكد انك تريد الخروج من الكلان \n\n - للتأكيد \`نعم\`\n - للألغاء \`لا\`**");
  320. let awaited = await message.channel.awaitMessages(r => r.author.id === message.author.id, {max: 1, time: 20000, errors:['time']}).then(c => {
  321. let collected = c.first();
  322. if(collected.content === 'نعم') {
  323. clans[system[author.id].clan].members.shift(author.id);
  324. fs.writeFile('./ClanSystem/ClanSystem.json', JSON.stringify(clans, null, 4), function(err) {if(err) console.log(err)});
  325. system[author.id] = {clan: 'None',joinedAt: new Date().toLocaleString() ,clanLevel: 0};
  326. fs.writeFile('./ClanSystem/ClanStats.json', JSON.stringify(system, null, 4), function(err) {if(err) console.log(err)});
  327.  
  328. message.channel.send("**# لقد غادرت الكلان**");
  329. } else if(collected.content === 'لا') {
  330. message.channel.send("**# تم الغاء الخروج من الكلان**");
  331. } else if(collected.content !== 'نعم' && collected.content === 'لا') {
  332. message.channel.send('**# يجب عليك كتابة `نعم` أو `لا`**');
  333. }
  334. });
  335. }
  336. if(args[1] && args[1] === 'kick') {
  337. let mention = message.mentions.users.first();
  338. if(system[author.id].clan === 'None') return message.channel.send("**# يجب ان تكون بكلان لأستخدام هذا الأمر**");
  339. if(!clans[system[author.id].clan].admins.includes(message.author.id) && clans[system[author.id].clan].creator !== message.author.id) return message.channel.send("**# يجب عليك ان تكون اونر او ادمن بالكلان لأستخدام هذا الامر**");
  340. if(!mention) return message.channel.send("**# يجب عليك منشنة عضو بالكلان لطرده**");
  341. if(!system[mention.id]) system[mention.id] = {clan: 'None',joinedAt: new Date().toLocaleString() ,clanLevel: 0};
  342. fs.writeFile('./ClanSystem/ClanSystem.json', JSON.stringify(clans, null, 4), function(err) {if(err) console.log(err)});
  343. if(system[mention.id].clan === 'None') return message.channel.send("**# هذا الشخص ليس بكلان**");
  344. if(!clans[system[author.id].clan].members.includes(mention.id)) return message.channel.send("**# هذا الشخص ليس بالكلان**");
  345. if(clans[system[author.id].clan].admins.includes(mention.id) && clans[system[author.id].clan].creator !== message.author.id) return message.channel.send("**# هذا العضو لديه ادمن**");
  346. if(mention.id === message.author.id) return message.channel.send("**# لا يمكنك طرد نفسك**");
  347.  
  348. let index = clans[system[author.id].clan].members.indexOf(mention.id);
  349. let index2 = clans[system[author.id].clan].admins.indexOf(mention.id) || "";
  350. clans[system[author.id].clan].members.splice(index, 1);
  351. if(clans[system[author.id].clan].admins.includes(mention.id)) clans[system[author.id].clan].admins.splice(index2, 1);
  352. fs.writeFile('./ClanSystem/ClanSystem.json', JSON.stringify(clans, null, 4), function(err) {if(err) console.log(err)});
  353. system[mention.id] = {clan: 'None',joinedAt: new Date().toLocaleString() ,clanLevel: 0};
  354. fs.writeFile('./ClanSystem/ClanStats.json', JSON.stringify(system, null, 4), function(err) {if(err) console.log(err)});
  355.  
  356. message.channel.send(`**# \`${mention.username}\`, تم طرد الشخص من الكلان**`);
  357. mention.send(`**# \`${system[author.id].clan}\`, لقد تم طردك من الكلان**`).catch();
  358. }
  359. if(args[1] && args[1] === 'ownership') {
  360. let mention = message.mentions.users.first();
  361. if(system[author.id].clan === 'None') return message.channel.send("**# يجب ان تكون بكلان لأستخدام هذا الأمر**");
  362. if(!mention) return message.channel.send("**# يجب عليك منشنة شخص لتسليمه الأونر**");
  363. if(clans[system[author.id].clan].creator !== message.author.id) return message.channel.send("**# يجب أن تكون صاحب الكلان لأستخدام هذا الأمر**");
  364. if(!clans[system[author.id].clan].members.includes(mention.id)) return message.channel.send("**# هذا الشخص ليس بالكلان**");
  365. let o = Math.floor(Math.random() * 8) + 1;
  366. let t = Math.floor(Math.random() * 8) + 1;
  367. let th = Math.floor(Math.random() * 8) + 1;
  368. let f = Math.floor(Math.random() * 8) + 1;
  369. let number = `${o}${t}${th}${f}`;
  370.  
  371. message.author.send(`- \`${number}\`, أكتب هذا الرقم بالشات للأستمرار`).catch(e => {
  372. return message.channel.send(`**# يجب عليك فتح خاصك لأستخدام هذا الأمر**`);
  373. });
  374.  
  375. let m = await message.channel.send("**# تم ارسال رقم التكملة بالخاص .. يجب عليك كتابة الرقم بالشات للأستمرار**");
  376. let awaited = await message.channel.awaitMessages(r => r.author.id === message.author.id, {max: 1, time: 20000, errors:['time']}).then(c => {
  377. let collected = c.first();
  378.  
  379. if(collected.content === number) {
  380. clans[system[author.id].clan].creator = mention.id;
  381. fs.writeFile('./ClanSystem/ClanSystem.json', JSON.stringify(clans, null, 4), function(err) {if(err) console.log(err)});
  382.  
  383. m.delete();
  384. message.channel.send(`**# \`${mention.username}\`, تم تحويل اونر الكلان للشخص**`);
  385. } else
  386. if(collected.content !== number) {
  387. m.delete();
  388. }
  389. });
  390. }
  391. if(args[1] && args[1] === 'disband') {
  392. if(system[author.id].clan === 'None') return message.channel.send("**# يجب ان تكون بكلان لأستخدام هذا الأمر**");
  393. if(clans[system[author.id].clan].creator !== message.author.id) return message.channel.send("**# يجب أن تكون صاحب الكلان لأستخدام هذا الأمر**");
  394. let o = Math.floor(Math.random() * 8) + 1;
  395. let t = Math.floor(Math.random() * 8) + 1;
  396. let th = Math.floor(Math.random() * 8) + 1;
  397. let f = Math.floor(Math.random() * 8) + 1;
  398. let fi = Math.floor(Math.random() * 8) + 1;
  399. let number = `${o}${t}${th}${f}${fi}`;
  400.  
  401. message.author.send(`- \`${number}\`, أكتب هذا الرقم بالشات للأستمرار`).catch(e => {
  402. return message.channel.send(`**# يجب عليك فتح خاصك لأستخدام هذا الأمر**`);
  403. });
  404.  
  405. let m = await message.channel.send("**# تم ارسال رقم التكملة بالخاص .. يجب عليك كتابة الرقم بالشات للأستمرار**");
  406. let awaited = await message.channel.awaitMessages(r => r.author.id === message.author.id, {max: 1, time: 20000, errors:['time']}).then(c => {
  407. let collected = c.first();
  408.  
  409. if(collected.content === number) {
  410. m.delete().catch();
  411. let i = 0;
  412. let name = system[author.id].clan;
  413. let members = clans[system[author.id].clan].members.length;
  414. clans[system[author.id].clan] = undefined;
  415. fs.writeFile('./ClanSystem/ClanSystem.json', JSON.stringify(clans, null, 4), function(err) {if(err) console.log(err)});
  416. hero.users.get(Array.from(clans[system[author.id].clan].members)).forEach(g => {
  417. i++;
  418. g.send(`- \`${system[author.id].clan}\`, تم اقفال الكلان`).catch();
  419. system[g.id] = {clan: 'None',joinedAt: new Date().toLocaleString() ,clanLevel: 0};
  420. fs.writeFile('./ClanSystem/ClanStats.json', JSON.stringify(system, null, 4), function(err) {if(err) console.log(err)});
  421. });
  422. if(i === members) return message.channel.send(` - \`${name}\`, تم اغلاق الكلان`);
  423. } else
  424. if(collected.content !== number) {
  425. m.delete();
  426. }
  427. });
  428. }
  429. }
  430. });
  431.  
  432. hero.login("NTk5OTcwODk1MDQxMTM0NjAy.XmoMVA.ry7pJv6x-DKrz2X-02LYU3BhsQU");
Advertisement
Add Comment
Please, Sign In to add comment