Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. var Enmap = require("enmap") // npm i enmap + swy mlf times.json w 7t fyh {}
  4. db = new Enmap({name: "fireking"}),
  5. times = require("./times.json"),
  6. owners = ["387107653148475393"]
  7. client["on"]("message", async message => {
  8. if(message["author"]["bot"] || message["channel"]["type"] === "dm") return undefined;
  9. let args = message["content"]["split"](' ');
  10. db["ensure"](`vip${client["user"]["id"]}`,{
  11. vipownership: [],
  12. vipotherownership: [],
  13. vippremiumnumber: 1,
  14. vipguild: "",
  15. vipprefix: "-"
  16. })
  17. if(!owners["includes"](message["author"]["id"])) return undefined
  18. if(args[0]["toLowerCase"]() == prefix + `vipmove`) { // هنا علشان تنقل البوت لشخص مع تحديد الاونر الاساسي  و تحديد رقم البريميوم و تحديد السيرفر و تحديد البرفكس
  19. let ownership = message["mentions"]["users"]["first"]()
  20. let premiumnumber = message["content"]["split"](" ")[2]
  21. let guild = message["content"]["split"](" ")[3]
  22. let prefix = message["content"]["split"](" ")[4]
  23. if(ownership === message["author"]["bot"]) return message["channel"]["send"](`**| Error**`)
  24. if(!guild || !ownership || !premiumnumber || !prefix) return message["channel"]["send"](`**| Using: \`-vipmove [MentionUser] [PremiumNumber] [GuildID] [Prefix]\`**`)
  25. db["pushIn"](`vip${client["user"]["id"]}`, "vipownership" , ownership);
  26. db["set"](`vip${client["user"]["id"]}`, "vippremiumnumber", premiumnumber)
  27. db["set"](`vip${client["user"]["id"]}`, "vipguild", guild)
  28. db["set"](`vip${client["user"]["id"]}`, "vipprefix", prefix)
  29. ownership["send"](`**Link: ${await client["generateInvite"]("ADMINISTRATOR")}
  30. سيتم خذف الرساله بعد 2 دقائق**`)["then"](e => e["delete"](2*60*1000))
  31. message["channel"]["send"](`**| Done**`)
  32. }
  33. })
  34.  
  35. client["on"]("message", async message => {
  36. if(message["author"]["bot"] || message["channel"]["type"] === "dm") return undefined;
  37. let args = message["content"]["split"](' ');
  38. if(db["get"](`vip${client["user"]["id"]}`, 'vipownership') !== message["author"]["id"]) return undefined;
  39. if(args[0]["toLowerCase"]() == `${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}viptransfer`) { // هنا لنقل ملكية البوت
  40. let ownerships = message["mentions"]["users"]["first"]()
  41. if(ownerships === message["author"]["bot"]) return message["channel"]["send"](`**| Error**`)
  42. if(ownerships === message["author"]) return message["channel"]["send"](`**| Error**`)
  43. if(!ownerships) return message["channel"]["send"](`**| Using: \`${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}viptransfer [MentionUser]\`**`)
  44. db["remove"](`vip${client["user"]["id"]}`, db["get"](`vip${client["user"]["id"]}`, 'vipownership'), "vipownership");
  45. db["pushIn"](`vip${client["user"]["id"]}`, "vipownership", ownerships);
  46. ownerships["send"](`**Link: ${await client["generateInvite"]("ADMINISTRATOR")}
  47. سيتم خذف الرساله بعد 2 دقائق**`)["then"](e => e["delete"](2*60*1000))
  48. message["channel"]["send"](`**| Done**`)
  49. }
  50. })
  51.  
  52. client["on"]("message", async message => {
  53. if(message["author"]["bot"] || message["channel"]["type"] === "dm") return undefined;
  54. let args = message["content"]["split"](' ');
  55. if(db["get"](`vip${client["user"]["id"]}`, 'vipownership') !== message["author"]["id"]) return undefined;
  56. if(args[0]["toLowerCase"]() == `${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}add-otherownership`) { // هنا لأضافة اونرات اخري
  57. let otherownerships = message["mentions"]["users"]["first"]()
  58. if(otherownerships === message["author"]["bot"]) return message["channel"]["send"](`**| Error**`)
  59. if(otherownerships === message["author"]) return message["channel"]["send"](`**| Error**`)
  60. if(!otherownerships) return message["channel"]["send"](`**| Using: \`${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}add-otherownership [MentionUser]\`**`)
  61. db["pushIn"](`vip${client["user"]["id"]}`, "vipotherownership", otherownerships);
  62. message["channel"]["send"](`**| Done**`)
  63. }
  64. })
  65.  
  66. client["on"]("message", async message => {
  67. if(message["author"]["bot"] || message["channel"]["type"] === "dm") return undefined;
  68. let args = message["content"]["split"](' ');
  69. if(db["get"](`vip${client["user"]["id"]}`, 'vipownership') !== message["author"]["id"]) return undefined;
  70. if(args[0]["toLowerCase"]() == `${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}remove-otherownership`) { // هنا لأزالة اونر
  71. let otherownerships = message["mentions"]["users"]["first"]()
  72. if(otherownerships === message["author"]["bot"]) return message["channel"]["send"](`**| Error**`)
  73. if(otherownerships === message["author"]) return message["channel"]["send"](`**| Error**`)
  74. if(!otherownerships) return message["channel"]["send"](`**| Using: \`${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}remove-otherownership [MentionUser]\`**`)
  75. db["remove"](`vip${client["user"]["id"]}`, otherownerships, "vipotherownership");
  76. message["channel"]["send"](`**| Done**`)
  77. }
  78. })
  79.  
  80. async function save() {
  81. require("fs")["writeFileSync"]("./times.json", JSON.stringify(times), function (error) {
  82. if(error) throw error;
  83. })
  84. };
  85. client["on"]("ready", async function () {
  86. if(!times[client ["user"]["id"]]) times [client["user"]["id"]] = {
  87. time: require("ms")("30d")
  88. };
  89. save();
  90. setInterval(() => {
  91. times[client["user"]["id"]].time -= require("ms")("1s");
  92. save();
  93. }, 1000);
  94. });
  95. client["on"]('message', async message => {
  96. if(message["author"]["bot"]) return undefined;
  97. let args = message["content"]["split"](' ');
  98. if(args[0]["toLowerCase"]() == `${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}vip`) { // هنا يعرض لك معلومات البريموم
  99. if(!times [client["user"]["id"]]) {
  100. times [client["user"]["id"]] = {
  101. time: require("ms")("30d")
  102. };
  103. save();
  104. process["exit"](1)["then"](() => {
  105. message["channel"]["send"]("**restarting the bot to save the premium time please wait..**");
  106. });
  107. } else {
  108. message["channel"]["send"](`**> Premiumnumber: \`\`${db["get"](`vip${client["user"]["id"]}`, 'vippremiumnumber')}\`\` | Prefix: \`\`${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}\`\`
  109. > Ownership: ${db["get"](`vip${client["user"]["id"]}`, 'vipownership')["join"](" | ")}
  110. > OtherOwnership(s): ${db["get"](`vip${client["user"]["id"]}`, 'vipotherownership')["join"](" | ") || "No othership"}
  111. > End At: \`${require("countdown")(Date.now() + times [client["user"]["id"]]["time"])["toString"]()}\`** `)
  112. }
  113. }
  114. })
  115.  
  116.  
  117. client["on"]("message", async message => {
  118. if(message["author"]["bot"]) return undefined;
  119. let args = message["content"]["split"](' ');
  120. var argresult = message["content"]["split"](` `)["slice"](1)["join"](' ');
  121. if(db["get"](`vip${client["user"]["id"]}`, 'vipownership') !== message["author"]["id"]) return undefined;
  122. if(db["get"](`vip${client["user"]["id"]}`, 'vipotherownership') !== message["author"]["id"]) return undefined;
  123. if(args[0]["toLowerCase"]() == `${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}setplaying`) {
  124. if(!argresult) return message["channel"]["send"](`**| Using: \`${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}setplaying [Game]\`**`);
  125. client["user"]["setGame"](argresult);
  126. message["channel"]["send"](`**✅ Changed the Bot Playing to » \`${argresult}\`**`)
  127. } else                      
  128. if(args[0]["toLowerCase"]() == `${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}setwatch`) {
  129. if(!argresult) return message["channel"]["send"](`**| Using: \`${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}setwatch [Game]\`**`);
  130. client["user"]["setActivity"](argresult, {type:'WATCHING'});
  131. message["channel"]["send"](`**✅ Changed the Bot Watching to » \`${argresult}\`**`)
  132. } else
  133. if(args[0]["toLowerCase"]() == `${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}setlisten`) {
  134. if(!argresult) return message["channel"]["send"](`**| Using: \`${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}setlisten [Game]\`**`);
  135. client["user"]["setActivity"](argresult , {type:'LISTENING'});
  136. message["channel"]["send"](`**✅ Changed the Bot Listening to » \`${argresult}\`**`)
  137. } else
  138. if(args[0]["toLowerCase"]() == `${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}setstream`) {
  139. if(!argresult) return message["channel"]["send"](`**| Using: \`${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}setstream [Game]\`**`);
  140. client["user"]["setGame"](argresult, "https://www.twitch.tv/P");
  141. message["channel"]["send"](`**✅ Changed the Bot Streaming to » \`${argresult}\`**`)
  142. }
  143. if(args[0]["toLowerCase"]() == `${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}setname`) {
  144. if(!argresult) return message["channel"]["send"](`**| Using: \`${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}setname [Name]\`**`);
  145. client["user"]["setUsername"](argresult)["then"]
  146. message["channel"]["send"](`**✅ Changed the Bot Name to » \`${argresult}\`**`)
  147. } else
  148. if(args[0]["toLowerCase"]() == `${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}setavatar`) {
  149. if(!argresult) return message["channel"]["send"](`**| Using: \`${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}setavatar [URL]\`**`);
  150. client["user"]["setAvatar"](argresult);
  151. message["channel"]["send"](`**✅ Changed the Bot Avatar to » \`${argresult}\`**`);
  152. } else                      
  153. if(args[0]["toLowerCase"]() == `${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}setprefix`) {
  154. if(!argresult) return message["channel"]["send"](`**| Using: \`${db["get"](`vip${client["user"]["id"]}`, 'vipprefix')}setprefix [Prefix]\`**`);
  155. db["set"](`vip${client["user"]["id"]}`, "vipprefix", argresult)
  156. message["channel"]["send"](`**✅ Changed the Bot Prefix to » \`${argresult}\`**`)
  157. }
  158. })
  159.  
  160. client["on"]("guildCreate", async function(guild) {
  161. if(guild["id"] !== db["get"](`vip${client["user"]["id"]}`, 'vipguild'))
  162. guild["leave"]();
  163. })
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174. const ownerID = ["387107653148475393"]; // ايدي ادارة البوت او صاحب البوت ..
  175.  
  176.  
  177. client.commands = new Discord.Collection();
  178. client.aliases = new Discord.Collection();
  179.  
  180.  
  181. let cmds = {
  182.   play: { cmd: 'play', a: ['p'] },
  183.   skip: { cmd: 'skip', a: ['s'] },
  184.   stop: { cmd: 'stop' },
  185.   pause: { cmd: 'pause' },
  186.   resume: { cmd: 'resume', a: ['r'] },
  187.   volume: { cmd: 'volume', a: ['vol'] },
  188.   queue: { cmd: 'queue', a: ['q'] },
  189.   repeat: { cmd: 'repeat', a: ['re'] },
  190.   forceskip: { cmd: 'forceskip', a: ['fs', 'fskip'] },
  191.   skipto: { cmd: 'skipto', a: ['st'] },
  192.   nowplaying: { cmd: 'Nowplaying', a: ['np'] }
  193. };
  194.  
  195.  
  196.  
  197. Object.keys(cmds).forEach(key => {
  198. var value = cmds[key];
  199.   var command = value.cmd;
  200.   client.commands.set(command, command);
  201.  
  202.   if(value.a) {
  203.     value.a.forEach(alias => {
  204.     client.aliases.set(alias, command)
  205.   })
  206.   }
  207. })
  208.  
  209.  
  210.  
  211. let active = new Map();
  212.  
  213. client.on('warn', console.warn);
  214.  
  215. client.on('error', console.error);
  216.  
  217. client.on('ready', () => {
  218.     console.log(`Created By: Kahrbaa`);
  219.     console.log(`Guilds: ${client.guilds.size}`);
  220.     console.log(`Users: ${client.users.size}`);
  221.     client.user.setActivity(`Type ${prefix}help`,{type: 'Playing'});
  222. });
  223.  
  224. client.on('message', async msg => {
  225.     if(msg.author.bot) return undefined;
  226.   if(!msg.content.startsWith(prefix)) return undefined;
  227.  
  228.   const args = msg.content.slice(prefix.length).trim().split(/ +/g);
  229. const command = args.shift().toLowerCase();
  230.  
  231.     const url = args[1] ? args[1].replace(/<(.+)>/g, '$1') : '';
  232.  
  233.     let cmd = client.commands.get(command) || client.commands.get(client.aliases.get(command))
  234.  
  235.     let s;
  236.  
  237.     if(cmd === 'play') {
  238.         const voiceChannel = msg.member.voiceChannel;
  239.         if(!voiceChannel) return msg.channel.send(`:no_entry_sign: You must be listening in a voice channel to use that!`);
  240.         const permissions = voiceChannel.permissionsFor(msg.client.user);
  241.         if(!permissions.has('CONNECT')) {
  242.             return msg.channel.send(`:no_entry_sign: I can't join Your voiceChannel because i don't have ` + '`' + '`CONNECT`' + '`' + ` permission!`);
  243.         }
  244.  
  245.         if(!permissions.has('SPEAK')) {
  246.             return msg.channel.send(`:no_entry_sign: I can't SPEAK in your voiceChannel because i don't have ` + '`' + '`SPEAK`' + '`' + ` permission!`);
  247.         }
  248.  
  249.         if (url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)) {
  250.             const playlist = await youtube.getPlaylist(url);
  251.             const videos = await playlist.getVideos();
  252.  
  253.             for (const video of Object.values(videos)) {
  254.                 const video2 = await youtube.getVideoByID(video.id); // eslint-disable-line no-await-in-loop
  255.                 await handleVideo(video2, msg, voiceChannel, true); // eslint-disable-line no-await-in-loop
  256.             }
  257.             return msg.channel.send(`Added to queue: ${playlist.title}`);
  258.         } else {
  259.             try {
  260.  
  261.                 var video = await youtube.getVideo(url);
  262.             } catch (error) {
  263.                 try {
  264.                     var videos = await youtube.searchVideos(args, 1);
  265.  
  266.                     // eslint-disable-next-line max-depth
  267.                     var video = await youtube.getVideoByID(videos[0].id);
  268.                 } catch (err) {
  269.                     console.error(err);
  270.                     return msg.channel.send('I can\'t find any thing');
  271.                 }
  272.             }
  273.  
  274.             return handleVideo(video, msg, voiceChannel);
  275.         }
  276.  
  277.         async function handleVideo(video, msg, voiceChannel, playlist = false) {
  278.     const serverQueue = active.get(msg.guild.id);
  279.  
  280.  
  281. //  console.log('yao: ' + Util.escapeMarkdown(video.thumbnailUrl));
  282.  
  283. let hrs = video.duration.hours > 0 ? (video.duration.hours > 9 ? `${video.duration.hours}:` : `0${video.duration.hours}:`) : '';
  284. let min = video.duration.minutes > 9 ? `${video.duration.minutes}:` : `0${video.duration.minutes}:`;
  285. let sec = video.duration.seconds > 9 ? `${video.duration.seconds}` : `0${video.duration.seconds}`;
  286. let dur = `${hrs}${min}${sec}`
  287.  
  288.   let ms = video.durationSeconds * 1000;
  289.  
  290.     const song = {
  291.         id: video.id,
  292.         title: video.title,
  293.     duration: dur,
  294.     msDur: ms,
  295.         url: `https://www.youtube.com/watch?v=${video.id}`
  296.     };
  297.     if (!serverQueue) {
  298.         const queueConstruct = {
  299.             textChannel: msg.channel,
  300.             voiceChannel: voiceChannel,
  301.             connection: null,
  302.             songs: [],
  303.             volume: 50,
  304.       requester: msg.author,
  305.             playing: true,
  306.       repeating: false
  307.         };
  308.         active.set(msg.guild.id, queueConstruct);
  309.  
  310.         queueConstruct.songs.push(song);
  311.  
  312.         try {
  313.             var connection = await voiceChannel.join();
  314.             queueConstruct.connection = connection;
  315.             play(msg.guild, queueConstruct.songs[0]);
  316.         } catch (error) {
  317.             console.error(`I could not join the voice channel: ${error}`);
  318.             active.delete(msg.guild.id);
  319.             return msg.channel.send(`I cant join this voice channel`);
  320.         }
  321.     } else {
  322.         serverQueue.songs.push(song);
  323.  
  324.         if (playlist) return undefined;
  325.         if(!args) return msg.channel.send('no results.');
  326.         else return msg.channel.send(':watch: Loading... [`' + args + '`]').then(m => {
  327.       setTimeout(() => {//:watch: Loading... [let]
  328.         m.edit(`:notes: Added **${song.title}**` + '(` ' + song.duration + ')`' + ` to the queue at position ` + `${serverQueue.songs.length}`);
  329.       }, 500)
  330.     })
  331.     }
  332.     return undefined;
  333. }
  334.  
  335. function play(guild, song) {
  336.     const serverQueue = active.get(guild.id);
  337.  
  338.     if (!song) {
  339.         serverQueue.voiceChannel.leave();
  340.         active.delete(guild.id);
  341.         return;
  342.     }
  343.     //console.log(serverQueue.songs);
  344.   if(serverQueue.repeating) {
  345.     console.log('Repeating');
  346.   } else {
  347.     serverQueue.textChannel.send(':notes: Added **' + song.title + '** (`' + song.duration + '`) to begin playing.');
  348. }
  349.     const dispatcher = serverQueue.connection.playStream(ytdl(song.url))
  350.         .on('end', reason => {
  351.             //if (reason === 'Stream is not generating quickly enough.') console.log('Song ended.');
  352.             //else console.log(reason);
  353.       if(serverQueue.repeating) return play(guild, serverQueue.songs[0])
  354.             serverQueue.songs.shift();
  355.             play(guild, serverQueue.songs[0]);
  356.         })
  357.         .on('error', error => console.error(error));
  358.     dispatcher.setVolumeLogarithmic(serverQueue.volume / 100);
  359.  
  360.  
  361. }
  362. } else if(cmd === 'stop') {
  363.         if(msg.guild.me.voiceChannel !== msg.member.voiceChannel) return msg.channel.send(`You must be in ${msg.guild.me.voiceChannel.name}`)
  364.         if(!msg.member.hasPermission('ADMINISTRATOR')) {
  365.           msg.react('❌')
  366.           return msg.channel.send('You don\'t have permission `ADMINSTRATOR`');
  367.         }
  368.         let queue = active.get(msg.guild.id);
  369.         if(queue.repeating) return msg.channel.send('Repeating Mode is on, you can\'t stop the music, run `' + `${prefix}repeat` + '` to turn off it.')
  370.         queue.songs = [];
  371.         queue.connection.dispatcher.end();
  372.         return msg.channel.send(':notes: The player has stopped and the queue has been cleared.');
  373.  
  374.     } else if(cmd === 'skip') {
  375.  
  376.       let vCh = msg.member.voiceChannel;
  377.  
  378.       let queue = active.get(msg.guild.id);
  379.  
  380.         if(!vCh) return msg.channel.send('Sorry, but you can\'t because you are not in voice channel');
  381.  
  382.         if(!queue) return msg.channel.send('No music playing to skip it');
  383.  
  384.         if(queue.repeating) return msg.channel.send('You can\'t skip it, because repeating mode is on, run ' + `\`${prefix}forceskip\``);
  385.  
  386.         let req = vCh.members.size - 1;
  387.  
  388.         if(req == 1) {
  389.             msg.channel.send('**:notes: Skipped **' + args);
  390.             return queue.connection.dispatcher.end('Skipping ..')
  391.         }
  392.  
  393.         if(!queue.votes) queue.votes = [];
  394.  
  395.         if(queue.votes.includes(msg.member.id)) return msg.say(`You already voted for skip! ${queue.votes.length}/${req}`);
  396.  
  397.         queue.votes.push(msg.member.id);
  398.  
  399.         if(queue.votes.length >= req) {
  400.             msg.channel.send('**:notes: Skipped **' + args);
  401.  
  402.             delete queue.votes;
  403.  
  404.             return queue.connection.dispatcher.end('Skipping ..')
  405.         }
  406.  
  407.         msg.channel.send(`**You have successfully voted for skip! ${queue.votes.length}/${req}**`)
  408.  
  409.     } else if(cmd === 'pause') {
  410.  
  411.       let queue = active.get(msg.guild.id);
  412.  
  413.         let vCh = msg.member.voiceChannel;
  414.  
  415.         if(!vCh || vCh !== msg.guild.me.voiceChannel) return msg.channel.send(`You are not in my voice channel.`);
  416.  
  417.         if(!queue) {
  418.             return msg.channel.send('No music playing to pause.')
  419.         }
  420.  
  421.         if(!queue.playing) return msg.channel.send(':no_entry_sign: There must be music playing to use that!')
  422.  
  423.         let disp = queue.connection.dispatcher;
  424.  
  425.         disp.pause('Pausing..')
  426.  
  427.         queue.playing = false;
  428.  
  429.         msg.channel.send(':notes: Paused ' + args + '. **Type** `' + prefix + 'resume` to unpause!')
  430.  
  431.     } else if (cmd === 'resume') {
  432.  
  433.       let queue = active.get(msg.guild.id);
  434.  
  435.         let vCh = msg.member.voiceChannel;
  436.  
  437.         if(!vCh || vCh !== msg.guild.me.voiceChannel) return msg.channel.send(`You are not in my voice channel.`);
  438.  
  439.         if(!queue) return msg.channel.send(':notes: No music paused to resume.')
  440.  
  441.         if(queue.playing) return msg.channel.send(':notes: No music paused to resume.')
  442.  
  443.         let disp = queue.connection.dispatcher;
  444.  
  445.         disp.resume('Resuming..')
  446.  
  447.         queue.playing = true;
  448.  
  449.         msg.channel.send(':notes: Resumed.')
  450.  
  451.     } else if(cmd === 'volume') {
  452.  
  453.       let queue = active.get(msg.guild.id);
  454.  
  455.       if(!queue || !queue.songs) return msg.channel.send(':notes: There is no music playing to set volume.');
  456.  
  457.       let vCh = msg.member.voiceChannel;
  458.  
  459.       if(!vCh || vCh !== msg.guild.me.voiceChannel) return msg.channel.send(':notes: You are not in my voice channel');
  460.  
  461.       let disp = queue.connection.dispatcher;
  462.  
  463.       if(isNaN(args[0])) return msg.channel.send(':notes: Numbers only!');
  464.  
  465.       if(parseInt(args[0]) > 100) return msg.channel.send('You can\'t set the volume more than 100.')
  466. //:speaker: Volume changed from 20 to 20 ! The volume has been changed from ${queue.volume} to ${args[0]}
  467.       msg.channel.send(':speaker: Volume has been **changed** from (`' + queue.volume + '`) to (`' + args[0] + '`)');
  468.  
  469.       queue.volume = args[0];
  470.  
  471.       disp.setVolumeLogarithmic(queue.volume / 100);
  472.  
  473.     } else if (cmd === 'queue') {
  474.  
  475.       let queue = active.get(msg.guild.id);
  476.  
  477.       if(!queue) return msg.channel.send(':no_entry_sign: There must be music playing to use that!');
  478.  
  479.       let embed = new Discord.RichEmbed()
  480.       .setAuthor(`${client.user.username}`, client.user.displayAvatarURL)
  481.       let text = '';
  482.  
  483.       for (var i = 0; i < queue.songs.length; i++) {
  484.         let num;
  485.         if((i) > 8) {
  486.           let st = `${i+1}`
  487.           let n1 = converter.toWords(st[0])
  488.           let n2 = converter.toWords(st[1])
  489.           num = `:${n1}::${n2}:`
  490.         } else {
  491.         let n = converter.toWords(i+1)
  492.         num = `:${n}:`
  493.       }
  494.         text += `${num} ${queue.songs[i].title} [${queue.songs[i].duration}]\n`
  495.       }
  496.       embed.setDescription(`Songs Queue | ${msg.guild.name}\n\n ${text}`)
  497.       msg.channel.send(embed)
  498.  
  499.     } else if(cmd === 'repeat') {
  500.  
  501.       let vCh = msg.member.voiceChannel;
  502.  
  503.       if(!vCh || vCh !== msg.guild.me.voiceChannel) return msg.channel.send('You are not in my voice channel');
  504.  
  505.       let queue = active.get(msg.guild.id);
  506.  
  507.       if(!queue || !queue.songs) return msg.channel.send('There is no music playing to repeat it.');
  508.  
  509.       if(queue.repeating) {
  510.         queue.repeating = false;
  511.         return msg.channel.send(':arrows_counterclockwise: **Repeating Mode** (`False`)');
  512.       } else {
  513.         queue.repeating = true;
  514.         return msg.channel.send(':arrows_counterclockwise: **Repeating Mode** (`True`)');
  515.       }
  516.  
  517.     } else if(cmd === 'forceskip') {
  518.  
  519.       let vCh = msg.member.voiceChannel;
  520.  
  521.       if(!vCh || vCh !== msg.guild.me.voiceChannel) return msg.channel.send('You are not in my voice channel');
  522.  
  523.       let queue = active.get(msg.guild.id);
  524.  
  525.       if(queue.repeating) {
  526.  
  527.         queue.repeating = false;
  528.  
  529.         msg.channel.send('ForceSkipped, Repeating mode is on.')
  530.  
  531.         queue.connection.dispatcher.end('ForceSkipping..')
  532.  
  533.         queue.repeating = true;
  534.  
  535.       } else {
  536.  
  537.         queue.connection.dispatcher.end('ForceSkipping..')
  538.  
  539.         msg.channel.send('ForceSkipped.')
  540.  
  541.       }
  542.  
  543.      } else if(cmd === 'skipto') {
  544.  
  545.       let vCh = msg.member.voiceChannel;
  546.  
  547.       if(!vCh || vCh !== msg.guild.me.voiceChannel) return msg.channel.send('You are not in my voice channel');
  548.  
  549.       let queue = active.get(msg.guild.id);
  550.  
  551.       if(!queue.songs || queue.songs < 2) return msg.channel.send('There is no music to skip to.');
  552.  
  553.     if(queue.repeating) return msg.channel.send('You can\'t skip, because repeating mode is on, run ' + `\`${prefix}repeat\` to turn off.`);
  554.  
  555.       if(!args[0] || isNaN(args[0])) return msg.channel.send('Please input song number to skip to it, run ' + prefix + `queue` + ' to see songs numbers.');
  556.  
  557.       let sN = parseInt(args[0]) - 1;
  558.  
  559.       if(!queue.songs[sN]) return msg.channel.send('There is no song with this number.');
  560.  
  561.       let i = 1;
  562.  
  563.       msg.channel.send(`Skipped to: **${queue.songs[sN].title}[${queue.songs[sN].duration}]**`)
  564.  
  565.       while (i < sN) {
  566.         i++;
  567.         queue.songs.shift();
  568.       }
  569.  
  570.       queue.connection.dispatcher.end('SkippingTo..')
  571.  
  572.     } else if(cmd === 'Nowplaying') {
  573.  
  574.       let q = active.get(msg.guild.id);
  575.  
  576.       let now = npMsg(q)
  577.  
  578.       msg.channel.send(now.mes, now.embed)
  579.       .then(me => {
  580.         setInterval(() => {
  581.           let noww = npMsg(q)
  582.           me.edit(noww.mes, noww.embed)
  583.         }, 5000)
  584.       })
  585.  
  586.       function npMsg(queue) {
  587.  
  588.         let m = !queue || !queue.songs[0] ? 'No music playing.' : "Now Playing..."
  589.  
  590.       const eb = new Discord.RichEmbed();
  591.  
  592.       eb.setColor(msg.guild.me.displayHexColor)
  593.  
  594.       if(!queue || !queue.songs[0]){
  595.  
  596.         eb.setTitle("No music playing");
  597.             eb.setDescription("\u23F9 "+bar(-1)+" "+volumeIcon(!queue?100:queue.volume));
  598.       } else if(queue.songs) {
  599.  
  600.         if(queue.requester) {
  601.  
  602.           let u = msg.guild.members.get(queue.requester.id);
  603.  
  604.           if(!u)
  605.             eb.setAuthor('Unkown (ID:' + queue.requester.id + ')')
  606.           else
  607.             eb.setAuthor(u.user.tag, u.user.displayAvatarURL)
  608.         }
  609.  
  610.         if(queue.songs[0]) {
  611.         try {
  612.             eb.setTitle(queue.songs[0].title);
  613.             eb.setURL(queue.songs[0].url);
  614.         } catch (e) {
  615.           eb.setTitle(queue.songs[0].title);
  616.         }
  617. }
  618.         eb.setDescription(embedFormat(queue))
  619.  
  620.       }
  621.  
  622.       return {
  623.         mes: m,
  624.         embed: eb
  625.       }
  626.  
  627.     }
  628.  
  629.       function embedFormat(queue) {
  630.  
  631.         if(!queue || !queue.songs) {
  632.           return "No music playing\n\u23F9 "+bar(-1)+" "+volumeIcon(100);
  633.         } else if(!queue.playing) {
  634.           return "No music playing\n\u23F9 "+bar(-1)+" "+volumeIcon(queue.volume);
  635.         } else {
  636.  
  637.           let progress = (queue.connection.dispatcher.time / queue.songs[0].msDur);
  638.           let prog = bar(progress);
  639.           let volIcon = volumeIcon(queue.volume);
  640.           let playIcon = (queue.connection.dispatcher.paused ? "\u23F8" : "\u25B6")
  641.           let dura = queue.songs[0].duration;
  642.  
  643.           return playIcon + ' ' + prog + ' `[' + formatTime(queue.connection.dispatcher.time) + '/' + dura + ']`' + volIcon;
  644.  
  645.  
  646.         }
  647.  
  648.       }
  649.  
  650.       function formatTime(duration) {
  651.   var milliseconds = parseInt((duration % 1000) / 100),
  652.     seconds = parseInt((duration / 1000) % 60),
  653.     minutes = parseInt((duration / (1000 * 60)) % 60),
  654.     hours = parseInt((duration / (1000 * 60 * 60)) % 24);
  655.  
  656.   hours = (hours < 10) ? "0" + hours : hours;
  657.   minutes = (minutes < 10) ? "0" + minutes : minutes;
  658.   seconds = (seconds < 10) ? "0" + seconds : seconds;
  659.  
  660.   return (hours > 0 ? hours + ":" : "") + minutes + ":" + seconds;
  661. }
  662.  
  663.       function bar(precent) {
  664.  
  665.         var str = '';
  666.  
  667.         for (var i = 0; i < 12; i++) {
  668.  
  669.           let pre = precent
  670.           let res = pre * 12;
  671.  
  672.           res = parseInt(res)
  673.  
  674.           if(i == res){
  675.             str+="\uD83D\uDD18";
  676.           }
  677.           else {
  678.             str+="▬";
  679.           }
  680.         }
  681.  
  682.         return str;
  683.  
  684.       }
  685.  
  686.       function volumeIcon(volume) {
  687.  
  688.         if(volume == 0)
  689.            return "\uD83D\uDD07";
  690.        if(volume < 30)
  691.            return "\uD83D\uDD08";
  692.        if(volume < 70)
  693.            return "\uD83D\uDD09";
  694.        return "\uD83D\uDD0A";
  695.  
  696.       }
  697.  
  698.     }
  699.  
  700. });
  701.  
  702.  
  703. client.on('message', message => {
  704.   if (!message.guild) return;
  705.   if (message.content === prefix + 'join') {
  706.     if (message.member.voiceChannel) {
  707.       message.member.voiceChannel.join()
  708.         .then(connection => {
  709.           message.reply('**ابشر انا معاك ف الروم الان ..**!');
  710.         })
  711.         .catch(console.log);
  712.     } else {
  713.       message.reply('**- لازم تخش روم صوتي!**');
  714.     }
  715.   }
  716. });
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724. client.on('message', message => {
  725.   var helplist = `**:notes:  قائمة الاوامر:  
  726.  
  727. > Play : تشغيل الاغنية او اضافتها للقائمة او اكمال الاغنية [p]
  728. > Pause : ايقاف مؤقت الاغنية  
  729. > Resume : اكمال الاغنية
  730. > stop : لأيقاف الأغنية وخروج البوت من الروم
  731. > forceskip : لتخطي الأغنية بشكل مباشر
  732. > Queue : عرض القائمة
  733. > skipto : لتخطي الأغنية الى الأغنية القادمة في طابور الموسيقى القادمة
  734. > Skip : تخطي للاغنية التالية
  735. > Volume : تغيير الصوت [vol]
  736. > Nowplaying : عرض مايتم تشغيله الان [np]
  737. > Ping : سرعة استجابة البوت
  738. > repeat : تكرار الاغنية
  739. > Leave : الخروج من الروم الصوتي  
  740.  
  741. `
  742.   if(message.content === prefix + 'help') {
  743.             message.delete(1000)
  744.     let e = '** جاري الارســال .. :envelope_with_arrow: **'
  745.       message.reply(e).then(m => m.delete(1000))
  746.       message.author.send(helplist).catch(error => message.reply('** لم اتمكن من الارسال الاوامر لك , يرجي فتح خاصك :negative_squared_cross_mark:**'))
  747. }
  748. });
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760. var userid = "387107653148475393",
  761.     category = "660529483052220427",
  762.     rolename = "Vip",
  763.     price = 1000;//السعر
  764. client.on ("message",async message => {
  765.  
  766.     if (message.author.bot) return;
  767.     if (!message.guild) return;
  768.     if (!message.content.startsWith(prefix)) return;
  769.  
  770.  
  771.     const args = message.content.slice(prefix.length).trim().split(/ +/g);
  772.     const cmd = args.shift().toLowerCase();
  773.  
  774.  
  775.     if(cmd === "private") {
  776.    
  777.     let room = args.join(" ");
  778.  
  779.     let embed = new Discord.RichEmbed()
  780.     .setTitle(`**${message.author.username} - Welcome**`)
  781.     .setDescription(`**Please Transfer ${price} Probot
  782. To : <@${userid}>**`)
  783.     message.channel.send(embed)
  784.       let P2 = Math.floor (price - (price * (5 / 100))) // xD
  785.   let filter = response => response.author.id == "282859044593598464" && response.mentions._content.includes(`:moneybag: | ${message.author.username}, has transferred \`$${P2}\` to <@${userid}>`)
  786.   message.channel.awaitMessages(filter, { maxMatches: 1, time: 240000, errors: ['time'] })
  787.   .then( collected =>{
  788.      
  789.         let filter2 = m => m.author.id === message.author.id;
  790.    
  791.       let thisMessage;
  792.  
  793.     let thisFalse;
  794.  
  795.         message.channel.send('📝 **| من فضلك اكتب اسم الروم الان... ✏ **').then(msg => {
  796.  
  797.      message.channel.awaitMessages(filter2, {
  798.  
  799.       max: 1,
  800.  
  801.       time: 180000,
  802.  
  803.       errors: ['time']
  804.  
  805.     })
  806.            
  807.              .then(collected => {
  808.  
  809.       collected.first().delete();
  810.  
  811.       thisMessage = collected.first().content;
  812.  
  813.       let boi;
  814.  
  815.   message.channel.send(`done !`)
  816.    var role = message.guild.roles.find(role => role.name === rolename);
  817. message.member.addRole(role);
  818.        let room = collected.first().content
  819.      message.guild.createChannel(room, "text").then(c => {
  820.             let role2 = message.guild.roles.find("name", "@everyone");
  821.  
  822.             c.overwritePermissions(role2, {
  823.                 SEND_MESSAGES: false,
  824.                 READ_MESSAGES: true
  825.             });
  826.             c.overwritePermissions(message.author, {
  827.                 SEND_MESSAGES: true,
  828.                 READ_MESSAGES: true,
  829.               MENTION_EVERYONE:true
  830.             });
  831.  
  832.             let embed2 = new RichEmbed()
  833.             .setTitle(`**${message.author.username}**`)
  834.             .setDescription(`Done, Your Private room was created in <#${c.id}>`)
  835.             .setTimestamp()
  836.             message.channel.send(embed2);
  837.            
  838.             const embed = new Discord.RichEmbed()
  839.                 .setColor(0xCF40FA)
  840.                 .setTitle(`Room For ${message.author.username}`)
  841.                 .setDescription(`Enjoy !`)
  842.                 .setTimestamp()
  843.                 c.send({
  844.                     embed: embed
  845.                 });
  846.               c.setParent(category)
  847.  
  848.         }).catch(console.error);
  849.        
  850.        message.reply("Done !").then(msg => {
  851.  
  852.  
  853.  
  854.           message.channel.awaitMessages(filter, {
  855.  
  856.             max: 1,
  857.  
  858.             time: 90000,
  859.  
  860.             errors: ['time']
  861.  
  862.           })
  863.          })
  864.  })
  865.           })
  866.    
  867.    
  868.          
  869.        
  870.  
  871.   });
  872.    
  873.  }
  874.  
  875.  
  876.    
  877.  
  878.  
  879.  
  880.   });
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896. /*
  897.  
  898. let vipKeys = JSON.parse(fs.readFileSync("./vipKeys.json", "utf8"));
  899. client.on("message", msg=>{
  900. let id = "387107653148475393"; // ايديك
  901. let role = "Vip"; // اسم رتبة الفيب
  902. let Price = 10; // السعر
  903. let Price2 = Math.floor(Price-(Price*(5/100)));
  904. if(!Price || Price < 1) return;
  905. let cmd = msg.content.split(' ')[0];
  906. if(cmd === `${prefix}buy`){
  907. if(msg.author.bot) return;
  908. if(!msg.channel.guild) return;
  909. let embedvip = new Discord.RichEmbed()
  910. .setColor("#42f4f4")
  911. .setAuthor(msg.author.username, msg.author.displayAvatarURL)
  912. .setThumbnail(msg.author.avatarURL)
  913. .setTitle("**اختر الطريقة المناسبة لك**")
  914. .addField("ل شراء الفي اي بي لنفسك","🔱",true )
  915. .addField("ل شراء الفي اي بي ك هدية","🎁",true)
  916. .setTimestamp()
  917. .setFooter(client.user.username,client.user.displayAvatarURL);
  918. msg.channel.send(embedvip).then(msgs2 =>{
  919. msgs2.react("🔱").then(()=>{
  920.   msgs2.react("🎁").then(()=>{
  921.     const me = (reaction, user) => reaction.emoji.name === '🔱' && user.id === msg.author.id;
  922.     const gift = (reaction, user) => reaction.emoji.name === '🎁' && user.id === msg.author.id;
  923.     const mec = msgs2.createReactionCollector(me, {time: 120000});
  924.     const giftc = msgs2.createReactionCollector(gift, {time: 120000});
  925. mec.on("collect", r=>{  
  926. msgs2.delete()
  927. if(msg.member.roles.find(r=>r.name == role)) return msg.reply("انت تمتلك الرتبة مسبقًا");
  928. let roleW = msg.guild.roles.find(r=>r.name == role);
  929. if(!roleW) return msg.reply(`البوت مقفل لعدم وجود رتبة ب أسم \`${role}\``)
  930. msg.channel.send(`كردت بروبوت\`${Price}\` لديك 4 دقائق لتحويل
  931. إلى ${msg.guild.members.get(id)}
  932. `).then( msgs =>{
  933. const filter = response => response.author.id == "282859044593598464" && response.mentions._content.includes(`:moneybag: | ${msg.author.username}, has transferred \`$${Price2}\` to ${msg.guild.members.get(id)}`);
  934. msg.channel.awaitMessages(filter, { maxMatches: 1, time: 240000, errors: ['time'] })
  935. .then( collected =>{
  936. msgs.delete()
  937. msg.reply(`تم اعطائك رتبة \`${role}\``);
  938. msg.member.addRole(roleW);
  939. }).catch(e => {});
  940. })})
  941. giftc.on("collect", r=>{
  942.   msgs2.delete()
  943.   let roleW = msg.guild.roles.find(r=>r.name == role);
  944.   if(!roleW) return msg.reply(`البوت مقفل لعدم وجود رتبة ب أسم \`${role}\``)
  945. msg.channel.send(`كردت بروبوت\`${Price}\` لديك 4 دقائق لتحويل
  946. إلى ${msg.guild.members.get(id)}
  947. `).then( msgs =>{
  948.   const filter = response => response.author.id == "282859044593598464" && response.mentions._content.includes(`:moneybag: | ${msg.author.username}, has transferred \`$${Price2}\` to ${msg.guild.members.get(id)}`);
  949.   msg.channel.awaitMessages(filter, { maxMatches: 1, time: 240000, errors: ['time'] })
  950.   .then( collected =>{
  951.   msgs.delete()
  952.   genKey(msg,roleW);
  953.   }).catch(e => {});
  954.   })
  955. })
  956. })})})
  957. ///
  958. }
  959. if(cmd === `${prefix}used`){
  960.   let args = msg.content.split(" ").slice(1)[0];
  961.   if(!args) {  
  962.     let embed = new Discord.RichEmbed()
  963.     .setColor("#42f4f4")
  964.     .setTitle(`:x: - **الرجاء ادخال كود الهدية** \`${prefix}used <Key>\``)
  965.     msg.reply(embed).then( z => z.delete(3000));
  966.     return
  967. }
  968.   let embed = new Discord.RichEmbed()
  969. .setTitle(`**جاري التحقق من الكود**`)
  970. .setColor("#42f4f4")
  971.   msg.reply(embed).then( msgs =>{
  972.   if(vipKeys[args]){
  973.     let hav = msg.member.roles.find(`name`, vipKeys[args].name);
  974.     if(hav){
  975.     let embed = new Discord.RichEmbed()
  976.     .setTitle(`:x: - **انت تمتلك هذه الرتبة مسبقًا**  \`${vipKeys[args].name}\``)
  977.     .setColor("#42f4f4")
  978.     msgs.edit(embed)
  979.     return
  980.     }
  981.     let embed = new Discord.RichEmbed()
  982.     .setTitle(`:tada: - **مبروك تم اعطائك رتبة** \`${vipKeys[args].name}\``)
  983.     .setColor("#42f4f4")
  984.     msgs.edit(embed)
  985.     msg.member.addRole(vipKeys[args]);
  986.     delete vipKeys[args]
  987.     save()
  988.   }else{
  989.     let embed = new Discord.RichEmbed()
  990.     .setTitle(`:x: - **الكود غير صيحيح أو انه مستعمل من قبل**`)
  991.     .setColor("#42f4f4")
  992.     msgs.edit(embed)
  993.   }});
  994. }
  995. });
  996.  
  997. function genKey(msg,role){
  998.   var randomkeys = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  999.   var gift = "";
  1000.   for (var y = 0; y < 16; y++) {   ///16
  1001.     gift +=  `${randomkeys.charAt(Math.floor(Math.random() * randomkeys.length))}`;
  1002.   }
  1003.   vipKeys[gift] = role;
  1004.   let embed = new Discord.RichEmbed()
  1005.   .setColor("#42f4f4")
  1006.   .setTitle(`:ok_hand: - **تم ارسآل الكود على الخاص**`);
  1007.   msg.reply(embed);
  1008.   let embed2= new Discord.RichEmbed()
  1009.   .setAuthor(msg.author.username, msg.author.displayAvatarURL)
  1010.   .setThumbnail(msg.author.avatarURL)
  1011.   .addField("**Key Of Gift**", gift,true)
  1012.   .addField("Role",vipKeys[gift].name,true)
  1013.   .addField("This Key Made by", msg.author, true)
  1014.   .addField("The Room", msg.channel , true)
  1015.   .setTimestamp()
  1016.   .setFooter(client.user.username,client.user.displayAvatarURL)  
  1017.   msg.author.send(embed2);
  1018.   save()
  1019. }
  1020.  
  1021. function save(){
  1022.   fs.writeFile("./vipKeys.json", JSON.stringify(vipKeys), (err) => {
  1023.     if (err) console.log(err)
  1024.   });
  1025.  
  1026. }
  1027.  
  1028. */
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035. client.on ("message", async (Message) => {
  1036.     if (!Message.guild
  1037.         || Message.author.bot)
  1038.         return false;
  1039.     if (Message.content.startsWith (prefix + "role")) {
  1040.         if (!Message.member.hasPermission ("MANAGE_ROLES")) return Message.reply("** You dont have Permissions.**");
  1041.         var user = Message.mentions.members.first ();
  1042.         if (!user) return Message.reply ("**I can't find this member.**");
  1043.         var men = Message.mentions.roles.first() || Message.guild.roles.find(r => r.name.startsWith ( Message.content.split(" ").slice(2).join(" ")));
  1044.         if (!men) return Message.reply ("**I can't find this role.**");
  1045.      
  1046.       if (user.roles.get (men.id)) {
  1047.         user.removeRole(men).then(() => {
  1048.                   return Message.reply("**Successfully removed " + men + " role from  "+user+ " **");
  1049.  
  1050.         }).catch(err => err.code == 50013 ? Message.channel.send("**This role is above my role.**") : Message.channel.send(err.message))
  1051.       } else {
  1052.         user.addRole(men).then(() =>{
  1053.         Message.reply("**Successfully added " + men + " role to  "+user+ " **")
  1054.         }).catch(err => err.code == 50013 ? Message.channel.send("**This role is above my role.**") : Message.channel.send(err.message))
  1055.       }
  1056.      
  1057.     }
  1058. })
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072. var categoryID = '660529483052220427';
  1073. var voiceID = '661210220994887690';
  1074.  
  1075. client.on('ready',()=>console.log(`${client.user.tag} is ready`));
  1076. client.on('voiceStateUpdate',(Old,New)=>
  1077. {
  1078.     if(New.user.bot) return;
  1079.     if(Old.user.bot) return;
  1080.  
  1081.     if(New.voiceChannelID == voiceID)
  1082.     {
  1083.         New.guild.createChannel(New.user.username,'voice').then(set=>
  1084.         {
  1085.             New.setVoiceChannel(New.guild.channels.get(set.id)).then(()=>
  1086.             {
  1087.                 set.setParent(New.guild.channels.get(categoryID));
  1088.             });
  1089.             set.overwritePermissions(New.user,
  1090.                 {
  1091.                     'CONNECT':true,'SPEAK':true,
  1092.                     'MOVE_MEMBERS':true,'VIEW_CHANNEL':true,
  1093.                     'MANAGE_CHANNELS':true,'MANAGE_ROLES_OR_PERMISSIONS':true,
  1094.                     'USE_VAD':true,'PRIORITY_SPEAKER':true
  1095.                 });
  1096.         });
  1097.     }
  1098.  
  1099.     if(Old.voiceChannel)
  1100.     {
  1101.         Old.guild.channels.forEach(channels=>
  1102.             {
  1103.                 if(channels.parentID == categoryID)
  1104.                 {
  1105.                     if(channels.id == voiceID) return;
  1106.                     if(Old.voiceChannelID == channels.id)
  1107.                     {
  1108.                         if(Old.voiceChannel.members.size == 0)
  1109.                         {
  1110.                             channels.delete();
  1111.                         }
  1112.                     }
  1113.                 }
  1114.             });
  1115.     }
  1116.  
  1117. });
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135. var top = require("./top.json");
  1136. function save() {
  1137.     fs.writeFileSync("./top.json", JSON.stringify(top, null, 4));
  1138. }
  1139. client.on("voiceStateUpdate", async function(oldMember, newMember) {
  1140.     if (newMember.user.bot) return;
  1141.     if (!top[newMember.guild.id]) top[newMember.guild.id] = {};
  1142.     if (!top[newMember.guild.id][newMember.user.id]) top[newMember.guild.id][newMember.user.id] = {
  1143.         "text": 0,
  1144.         "voice": parseInt(Math.random()*10),
  1145.         "msgs": 0,
  1146.         "id": newMember.user.id
  1147.     }
  1148.     save();
  1149.     if (!oldMember.voiceChannel && newMember.voiceChannel) {
  1150.         var addXP = setInterval(async function () {
  1151.             top[newMember.guild.id][newMember.user.id].voice+=parseInt(Math.random()*4);
  1152.             save();
  1153.             if (!newMember.voiceChannel) {
  1154.                 clearInterval(addXP);
  1155.             }
  1156.         }, 60000);
  1157.     }
  1158. });
  1159. client.on("message", async function (message) {
  1160.     if (message.author.bot) return;
  1161.     if (!message.guild) return;
  1162.     if (!top[message.guild.id]) top[message.guild.id] = {};
  1163.     if (!top[message.guild.id][message.author.id]) top[message.guild.id][message.author.id] = {
  1164.         "text": parseInt(Math.random()*10),
  1165.         "voice": 0,
  1166.         "msgs": 0,
  1167.         "id": message.author.id
  1168.     }
  1169.     if (top[message.guild.id][message.author.id].msgs > 10) {
  1170.         top[message.guild.id][message.author.id].text += parseInt(Math.random()*4);
  1171.         top[message.guild.id][message.author.id].msgs = 0;
  1172.     }
  1173.     save();
  1174.     var args = message.content.split(" ");
  1175.     var cmd = args[0].slice(prefix.length).toLowerCase();
  1176.     if (!message.content.startsWith(prefix)) return;
  1177.     switch (cmd) {
  1178.         case "top":
  1179.             var topArray = Object.values(top[message.guild.id]);
  1180.             var num = 0;
  1181.             var textStr = `${topArray.sort((a, b) => b.text - a.text).slice(0, 10).filter(user => user.text > 0 && message.guild.members.get(user.id)).map(function (user) {
  1182.                 if (user.text > 0) {
  1183.                     return `**#${++num} | <@${user.id}> XP: \`${user.text}\` **`
  1184.                 }
  1185.             }).join("\n")}`;
  1186.             num = 0;
  1187.             var voiceStr = `${topArray.sort((a, b) => b.voice - a.voice).slice(0, 10).filter(user => user.voice > 0 && message.guild.members.get(user.id)).map(function (user) {
  1188.                 if (user.voice > 0) {
  1189.                     return `**#${++num} | <@${user.id}> XP: \`${user.voice}\` **`
  1190.                 }
  1191.             }).join("\n")}`;
  1192.             var embed = new Discord.RichEmbed()
  1193.             .setAuthor(message.author.tag, message.author.displayAvatarURL)
  1194.             .addField(`**TOP 10 TEXT 💬**`, textStr.length > 1 ? textStr : "» NO TOP TEXT", true)
  1195.             .addField(`**TOP 10 VOICE 🎙️**`, voiceStr.length > 1 ? voiceStr : "» NO TOP VOICE", true)
  1196.             .setFooter(client.user.tag, client.user.displayAvatarURL)
  1197.             .setColor("RANDOM");
  1198.             message.channel.send({
  1199.                 embed: embed
  1200.             });
  1201.         break;
  1202.         case "topvoice":
  1203.             var topArray = Object.values(top[message.guild.id]);
  1204.             var num = 0;
  1205.             var voiceStr = `${topArray.sort((a, b) => b.voice - a.voice).slice(0, 5).filter(user => user.voice > 0 && message.guild.members.get(user.id)).map(function (user) {
  1206.                 if (user.voice > 0) {
  1207.                     return `**#${++num} | <@${user.id}> XP: \`${user.voice}\` **`
  1208.                 }
  1209.             }).join("\n")}`;
  1210.             var embed = new Discord.RichEmbed()
  1211.             .setTitle("**TOP 5 VOICE 🎙️**")
  1212.             .setAuthor(message.author.tag, message.author.displayAvatarURL)
  1213.             .setDescription(voiceStr.length > 1 ? voiceStr : "» NO TOP VOICE")
  1214.             .setFooter(client.user.tag, client.user.displayAvatarURL)
  1215.             .setColor("RANDOM");
  1216.             message.channel.send({
  1217.                 embed: embed
  1218.             });
  1219.         break;
  1220.         case "toptext":
  1221.             var topArray = Object.values(top[message.guild.id]);
  1222.             var num = 0;
  1223.             var textStr = `${topArray.sort((a, b) => b.text - a.text).slice(0, 5).filter(user => user.text > 0 && message.guild.members.get(user.id)).map(function (user) {
  1224.                 if (user.text > 0) {
  1225.                     return `**#${++num} | <@${user.id}> XP: \`${user.text}\` **`
  1226.                 }
  1227.             }).join("\n")}`;
  1228.             var embed = new Discord.RichEmbed()
  1229.             .setTitle("**TOP 5 TEXT 💬**")
  1230.             .setAuthor(message.author.tag, message.author.displayAvatarURL)
  1231.             .setDescription(textStr.length > 1 ? textStr : "» NO TOP TEXT")
  1232.             .setFooter(client.user.tag, client.user.displayAvatarURL)
  1233.             .setColor("RANDOM");
  1234.             message.channel.send({
  1235.                 embed: embed
  1236.             });
  1237.         break;
  1238.     }
  1239. });
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254. function forEachObject(obj, func) {
  1255.   Object.keys(obj).forEach(function(key) {
  1256.     func(key, obj[key]);
  1257. var dat = JSON.parse("{}");
  1258.   });
  1259. }
  1260. const xp = JSON.parse(fs.readFileSync("./xp.json", "utf8"));
  1261. const profile = JSON.parse(fs.readFileSync("profile.json", "utf8"));
  1262.  
  1263. const credits = JSON.parse(fs.readFileSync('./credits.json'));
  1264. const creditsPath = './credits.json';
  1265. var time = require("./time.json");
  1266.  
  1267. client.on('message',async message => {
  1268.   var Canvas = require('canvas')
  1269. if(message.author.bot || message.channel.type === 'dm') return;
  1270. let args = message.content.split(' ');
  1271. let author = message.author.id;
  1272. if(!credits[author]) credits[author] = {
  1273. credits: 0
  1274. }
  1275. if(!credits[author]) credits[author] = {
  1276. blacklist: false
  1277. }
  1278. fs.writeFileSync(creditsPath, JSON.stringify(credits, null, 4));
  1279. if(credits[message.author.id].blacklist === true) return undefined;
  1280. if(args[0].toLowerCase() == `${prfs}credit` || args[0].toLowerCase() === `${prfs}credits`) {
  1281. const mention = message.mentions.users.first() || client.users.get(args[1]) || message.author;
  1282. const mentionn = message.mentions.users.first() || client.users.get(args[1]);
  1283. if(!args[2]) {
  1284. message.channel.send(`**:money_with_wings: | ${mention.username}, Have Credits \`$${credits[mention.id].credits}\`**`)
  1285. } else if(mentionn && args[2]) {
  1286. if(isNaN(args[2])) return message.channel.send(`**:x: | Error**`);
  1287. if(args[2] < 1) return message.channel.send(`**:x: | Error**`);
  1288. if(mention.bot) return message.channel.send(`**:x: | Error**`);      
  1289. if(mentionn.id === message.author.id) return message.channel.send(`**:x: | Error**`);
  1290. if(args[2] > credits[author].credits) return message.channel.send(`**:x: | Error , You Don't Have Enough Credit**`);
  1291. if(args[2].includes("-")) return message.channel.send(`**:x: | Error**`);
  1292. if(args[2].includes(".")) return message.channel.send(`**:x: | Error**`);
  1293. let first = Math.floor(Math.random() * 9);
  1294. let second = Math.floor(Math.random() * 9);
  1295. let third = Math.floor(Math.random() * 9);
  1296. let fourth = Math.floor(Math.random() * 9);
  1297. let num = `${first}${second}${third}${fourth}`;
  1298. let canvas = Canvas.createCanvas(150 , 50)
  1299. let ctx = canvas.getContext('2d');
  1300. const background = await Canvas.loadImage("https://cdn.discordapp.com/attachments/653622087201849375/656070567073415178/PicsArt_12-16-12.49.43.png");
  1301. ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
  1302. let url = message.author.displayAvatarURL.endsWith(".webp") ? message.author.displayAvatarURL.slice(5, -20) + ".gif" : message.author.displayAvatarURL;
  1303. jimp.read(url, (err, ava) => {
  1304. if(err) return console.log(err);
  1305. ava.getBuffer(jimp.MIME_PNG, (err, buf) => {
  1306. if(err) return console.log(err);
  1307. ctx.font = "sans-serif";
  1308. ctx.fontSize = '180px';
  1309. ctx.fillStyle = "#ffffff";
  1310. message.channel.send(`**${message.author.username}, You Will Trans \`$${args[2]}\` To ${mentionn}
  1311. If You Want To Complete Trans Type The Number Above in this image **`).then(essss => {
  1312. ctx.fillText(num, canvas.width / 2.4, canvas.height / 1.7);
  1313. message.channel.sendFile(canvas.toBuffer()).then(m => {
  1314. message.channel.awaitMessages(r => r.author.id === message.author.id, { max: 1, time: 20000, errors:['time'] }).then(collected => {
  1315. if(collected.first().content === num) {
  1316. client.channels.get("668195069513433098").send(`**
  1317. المرسل : ${message.author.username} | (ID: \`${message.author.id}\`)
  1318. المستقبل : ${mentionn.username} | (ID: \`${mentionn.id}\`)
  1319. الكريدتس : \`$${args[2]}\`
  1320. **`);
  1321. message.channel.send(`**:moneybag: | ${message.author.username}, Done Trans \`$${args[2]}\` To ${mentionn}**`);
  1322. mention.send(`**:money_with_wings: | Transfer Receipt** \`\`\`You Have Received \`$${args[2]}\` From User ${message.author.username}; (ID (${message.author.id})\`\`\``);
  1323. m.delete();
  1324. credits[author].credits += Math.floor((-args[2]));
  1325. credits[mentionn.id].credits += Math.floor((+args[2]));
  1326. fs.writeFileSync(creditsPath, JSON.stringify(credits, null, 4));
  1327. } else {
  1328. m.delete();
  1329. essss.delete();
  1330. }
  1331. })
  1332. })
  1333. })
  1334. })
  1335. })
  1336. }else {
  1337. message.channel.send(`**:x: | Error , Please Command True Ex: \`${prfs}redit [MentionUser] [Balance]\`**`);
  1338. }
  1339. }
  1340. if(args[0].toLowerCase() === `${prfs}daily`) {
  1341. let cooldown = 8.64e+7
  1342. let Daily = time[message.author.id]
  1343. if (Daily !== null && cooldown - (Date.now() - Daily) > 0) {
  1344. let times = (cooldown - (Date.now() - Daily));
  1345. message.channel.send(`**:stopwatch: | ${message.author.username}, Please Wait ${pretty(times, {verbose:true})} To Take Your Daily Again.**`);
  1346. fs.writeFile("./time.json", JSON.stringify(time), function(e) {
  1347. if(e)throw e;
  1348. })
  1349. }else{
  1350. let ammount = (300, 500, 100, 200, 120, 150, 350, 320, 220, 250);
  1351. credits[author].credits += ammount;
  1352. time[message.author.id] = Date.now();
  1353. message.channel.send(`**:money_with_wings:| ${message.author.username}, Done You Have Take Your Daily \`$${ammount}\`**`);
  1354. fs.writeFile("./credits.json", JSON.stringify(credits), function(e) {
  1355. if(e)throw e;
  1356. })
  1357. }
  1358. }
  1359. });
  1360. var guildT = '387107653148475393';
  1361. var channelT = '668195069513433098';
  1362. client.on("message", msg => {
  1363. if(msg.author.bot) return undefined
  1364. if(msg.content.startsWith(prfs + "rcredit")) {
  1365. if(!msg.guild.roles.exists("name", "Mange RemoveCredit")) return undefined;
  1366. if(!guildT.includes(msg.guild.id)) return;
  1367. if(!channelT.includes(msg.channel.id)) return;
  1368. let user = client.users.get(msg.content.split(" ")[1])
  1369. let reason = msg.content.split(" ").slice(2).join(" ");
  1370. if(!reason || !user) return msg.channel.send(`**:x: | Error , Please Type Command True Ex : \`${prfs}rcredit [ID] [Reason]\`**`)
  1371. let channell = client.channels.get("653624195149725711")
  1372. channell.send(`**:white_check_mark: | Done I Have Remove \`${credits[user.id].credits}\` Credit From <@${user.id}>, Reason: \`${reason}\` By: <@${msg.author.id}>**`)
  1373. msg.channel.send("**:white_check_mark: | Done.**")
  1374. credits[user.id].credits = 0
  1375. fs.writeFile("./credits.json", JSON.stringify(credits), function(e) {
  1376. if(e)throw e;
  1377. })
  1378. }
  1379. })
  1380.  
  1381. client.on('message',async message => {
  1382. let Fire = message.content.split(" ")[0].substring(prfs.length);
  1383. let mention = message.mentions.users.first() || message.author
  1384. if(Fire === "cg") {
  1385. let args = message.content.split(" ");
  1386. if(!devs.includes(message.author.id)) return;
  1387. if(!args[1] || isNaN(args[1])) return message.reply("**Type Credit**")
  1388. if(!credits[mention.id]) return;
  1389. credits[mention.id].credits += (+args[1]);
  1390. fs.writeFileSync("./credits.json", JSON.stringify(credits));
  1391. console.log(credits[mention.id])
  1392. message.reply(`**Give : \`${args[1]}\`**`);
  1393. } else if(Fire === "cr") {
  1394. let args = message.content.split(" ");
  1395. if(!devs.includes(message.author.id)) return;
  1396. if(!args[1] || isNaN(args[1])) return message.reply("**Type Credit**")
  1397. if(!credits[mention.id]) return;
  1398. credits[mention.id].credits += (-args[1]);
  1399. fs.writeFileSync("./credits.json", JSON.stringify(credits));
  1400. console.log(credits[mention.id])
  1401. message.reply(`**Removed : \`${args[1]}\`**`);
  1402. }
  1403. });
  1404. let level = JSON.parse(fs.readFileSync("./level.json", "utf8"));
  1405. client.on("message", message => {
  1406.  if (message.author.bot) return undefined;
  1407.  if (!level[message.author.id])
  1408.    level[message.author.id] = {
  1409.      xp: 0,
  1410.      level: 0
  1411.    };
  1412.  let username = message.author;
  1413.  level[message.author.id].xp++;
  1414.  let userlevel = level[message.author.id];
  1415.  if (userlevel.xp > Math.floor(Math.random() * 250) + 50) {
  1416.    userlevel.level++;
  1417.    userlevel.xp = 0;
  1418.  }
  1419.  fs.writeFileSync("./level.json", JSON.stringify(level), function(s) {
  1420.    if (s) throw s;
  1421.  });
  1422. });
  1423.  
  1424.  
  1425.  
  1426.      client.on('message', message => {
  1427.          if(!profile[message.author.id]) profile[message.author.id] ={
  1428.              points: 0,
  1429.              level: 1,
  1430.              rep: 0,
  1431.              tite: "No Title"
  1432.          };
  1433.          if(message.author.bot) return;
  1434.          profile[message.author.id].points = Math.floor(profile[message.author.id].points+1);
  1435.          if(profile[message.author.id].points > 250) {
  1436.              profile[message.author.id].points = 0
  1437.              profile[message.author.id].level = Math.floor(profile[message.author.id].level+1);
  1438.              message.channel.send(`**${message.author.username}, You leveld up to __${profile[message.author.id].level}__**`)
  1439.          }
  1440.          fs.writeFile('profile.json', JSON.stringify(profile), (err) => {
  1441. if (err) console.error(err);
  1442. })
  1443.      })
  1444.  
  1445.    client.on('message', message => {
  1446.        let tit = message.content.split(" ").slice(1).join(" ");
  1447.        if(message.content.startsWith(prefix + "title")) {
  1448.        if(!profile[message.author.id].tite) profile[message.author.id].tite = "Hey im using Super"
  1449.        if(!tit) {
  1450.            message.channel.send("**Usage: <title <something>**");
  1451.        } else {
  1452.            profile[message.author.id].tite = tit
  1453.            message.channel.send(`:ok:`)
  1454.        }
  1455.        }
  1456.        fs.writeFile('profile.json', JSON.stringify(profile), (err) => {
  1457. if (err) console.error(err);
  1458. })
  1459.    })
  1460.  
  1461. client.on('message', message => {
  1462.  
  1463.    if(message.content.startsWith(prefix + 'rep')) {
  1464.      if(!message.channel.guild) return;
  1465.                    moment.locale('en');
  1466.                  var getvalueof = message.mentions.users.first()
  1467.                    if(!getvalueof) return message.channel.send(`**:mag: |  ${message.author.username}, the user could not be found.    **`);
  1468.                       if(getvalueof.id == message.author.id) return message.channel.send(`**${message.author.username}, you cant give yourself a reputation !**`)
  1469.    if(profile[message.author.id].reps != moment().format('L')) {
  1470.            profile[message.author.id].reps = moment().format('L');
  1471.            profile[getvalueof.id].rep = Math.floor(profile[getvalueof.id].rep+1);
  1472.         message.channel.send(`** :up:  |  ${message.author.username} has given ${getvalueof} a reputation point!**`)
  1473.        } else {
  1474.         message.channel.send(`**:stopwatch: |  ${message.author.username}, you can raward more reputation  ${moment().endOf('day').fromNow()} **`)
  1475.        }
  1476.       }
  1477.       fs.writeFile('profile.json', JSON.stringify(profile), (err) => {
  1478. if (err) console.error(err);
  1479. })
  1480. });
  1481.  
  1482.    client.on("message", message => {
  1483.  if (message.author.bot) return;
  1484.    if(!message.channel.guild) return;
  1485. if (message.content.startsWith(prefix + "profile")) {
  1486.                               let user = message.mentions.users.first();
  1487.         var men = message.mentions.users.first();
  1488.            var heg;
  1489.            if(men) {
  1490.                heg = men
  1491.            } else {
  1492.                heg = message.author
  1493.            }
  1494.          var mentionned = message.mentions.members.first();
  1495.             var h;
  1496.            if(mentionned) {
  1497.                h = mentionned
  1498.            } else {
  1499.                h = message.member
  1500.            }
  1501.            var ment = message.mentions.users.first();
  1502.            var getvalueof;
  1503.            if(ment) {
  1504.              getvalueof = ment;
  1505.            } else {
  1506.              getvalueof = message.author;
  1507.            }
  1508.   var mentionned = message.mentions.users.first();
  1509.  let mention = message.mentions.users.first() || message.author;
  1510.  
  1511.    var client;
  1512.      if(mentionned){
  1513.          var client = mentionned;
  1514.      } else {
  1515.          var client = message.author;
  1516.  
  1517.      }
  1518. if (!profile[getvalueof.id]) profile[getvalueof.id] = {points: 0,reps: "No Reps", credits: 1, level: 1,tite: "Earth Bot User", rep: 0, lastDaily: "NOT COLLECTED"};
  1519.            let Image = Canvas.Image,
  1520.            canvas = new Canvas.createCanvas(300, 300),
  1521.            ctx = canvas.getContext('2d');
  1522.            fs.readFile("Pic.jpg", function (err, Background) { //امتداد الصورة
  1523.            if (err) return console.log(err);
  1524.            let BG = Canvas.Image;
  1525.            let ground = new Image;
  1526.            ground.src = Background;
  1527.            ctx.drawImage(ground, 0, 0, 300, 300); // حجم الصورة
  1528.  
  1529. })
  1530.  
  1531.  
  1532.  
  1533.  
  1534.                let url = getvalueof.displayAvatarURL.endsWith(".webp") ? getvalueof.displayAvatarURL.slice(5, -20) + ".png" : getvalueof.displayAvatarURL;
  1535.                jimp.read(url, (err, ava) => {
  1536.                    if (err) return console.log(err);
  1537.                    ava.getBuffer(jimp.MIME_PNG, (err, buf) => {
  1538.                        if (err) return console.log(err);
  1539.  
  1540.                        //ur name
  1541.                        ctx.font = 'bold 16px kathen'; // حجم الخط و نوعه
  1542.                        ctx.fontSize = '40px'; // عرض الخط
  1543.                        ctx.fillStyle = "#000000"; // لون الخط
  1544.                        ctx.textAlign = "center"; // محاذا ة النص
  1545.                        ctx.fillText(`${getvalueof.username}`, 153, 104) // احداثيات اسمك
  1546.  
  1547.                        //ur name
  1548.                        ctx.font = 'bold 16px kathen'; // حجم الخط و نوعه
  1549.                        ctx.fontSize = '40px'; // عرض الخط
  1550.                        ctx.fillStyle = "#f1f1f1"; // لون الخط
  1551.                        ctx.textAlign = "center"; // محاذا ة النص
  1552.                        ctx.fillText(`${getvalueof.username}`, 151, 102) // احداثيات اسمك
  1553.  
  1554.                        //credit
  1555.                        ctx.font = "bold 10px kathen" // نوع الخط وحجمه
  1556.                        ctx.fontSize = '10px'; // عرض الخط
  1557.                        ctx.fillStyle = "#f1f1f1" // لون الخط
  1558.                        ctx.textAlign = "center"; // محاذا ة النص
  1559.                        ctx.fillText(`$${credits[mention.id].credits}`, 230, 182) // احداثيات المصاري
  1560.  
  1561.  
  1562.                        ctx.font = "bold 14px kathen" // نوع الخط وحجمه
  1563.                        ctx.fontSize = '12px'; // عرض الخط
  1564.                        ctx.fillStyle = "#f1f1f1" // لون الخط
  1565.                        ctx.textAlign = "center"; // محاذا ة النص
  1566.                        ctx.fillText(`${profile[mention.id].tite}`, 150, 130) // احداثيات المصاري
  1567.  
  1568.                        //Level
  1569.                        ctx.font = "bold 24px kathen" // نوع الخط و حجمه
  1570.                        ctx.fontSize = '10px'; // عرض الخط
  1571.                        ctx.fillStyle = "#f1f1f1" // لون الخط
  1572.                        ctx.textAlign = "center"; // محاذا ة النص
  1573.                        ctx.fillText(`${profile[getvalueof.id].level}`, 70, 78) // احداثيات اللفل
  1574.  
  1575.                         //info
  1576.                        ctx.font = "bold 12px kathen" // ن
  1577.                        ctx.fontSize = '15px'; // عرض الخطوع الخط وحجمه
  1578.                        ctx.fillStyle = "#000000" // لون الخط
  1579.                        ctx.textAlign = "center"; // محاذا ة النص
  1580.                        ctx.fillText(`${profile[getvalueof.id].points}/250`, 150, 232) // احداثيات النقاط
  1581.  
  1582.                        //info
  1583.                        ctx.font = "bold 12px kathen" // ن
  1584.                        ctx.fontSize = '15px'; // عرض الخطوع الخط وحجمه
  1585.                        ctx.fillStyle = "#f1f1f1" // لون الخط
  1586.                        ctx.textAlign = "center"; // محاذا ة النص
  1587.                        ctx.fillText(`${profile[getvalueof.id].points}/250`, 150, 232) // احداثيات النقاط
  1588.  
  1589.                        // REP
  1590.                        ctx.font = "bold 20px  kathen";
  1591.                        ctx.fontSize = "50px";
  1592.                        ctx.fillStyle = "#f1f1f1";
  1593.                        ctx.textAlign = "center";
  1594.                        ctx.fillText(`+${profile[mention.id].rep}`, 225, 76)
  1595.  
  1596.                        let Avatar = Canvas.Image;
  1597.                        let ava = new Avatar;
  1598.  
  1599. ava.src = buf;
  1600.                        ctx.beginPath();
  1601.                        ctx.arc(75, 100, 780, 0, Math.PI*2, true);
  1602.                        ctx.closePath();
  1603.                        ctx.clip();
  1604.                        ctx.drawImage(ava, 110, 29, 82, 60);
  1605.  
  1606. message.channel.startTyping()
  1607. message.channel.sendFile(canvas.toBuffer())
  1608. message.channel.stopTyping()
  1609. })
  1610. })
  1611. }
  1612. });
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627. client.on('message', message => {
  1628. if (message.content === prefix + "هلا") {
  1629.  message.channel.send(`**
  1630. هلا بيك
  1631. **`)
  1632.  
  1633.   }
  1634. });
  1635.  
  1636.  
  1637.  
  1638.  
  1639. /*
  1640. client.on('message', async msg => { // eslint-disable-line
  1641.    if (msg.author.bot) return undefined;
  1642.    if (!msg.content.startsWith(PREFIX)) return undefined;
  1643.    const args = msg.content.split(' ');
  1644.    const searchString = args.slice(1).join(' ');
  1645.    const url = args[1];
  1646.    const serverQueue = queue.get(msg.guild.id);
  1647.  
  1648.    if(msg.content.startsWith(`${PREFIX}play`)){
  1649.        const voiceChannel = msg.member.voiceChannel;
  1650.        if(!voiceChannel){
  1651.            var embedplay1 = new Discord.RichEmbed()
  1652.                .setTitle(`Please Connect To A Voice Channel To Play Something!`)
  1653.                .setColor(['#f9fcfc'])
  1654.            return msg.channel.sendEmbed(embedplay1);
  1655.        }
  1656.        const permissions = voiceChannel.permissionsFor(msg.client.user);
  1657.        if(!permissions.has('CONNECT')){
  1658.            var embedplay2 = new Discord.RichEmbed()
  1659.                .setTitle(`I lack the right CONNECT to connect in these Voice Channel!`)
  1660.                .setColor(['#f9fcfc'])
  1661.            return msg.channel.sendEmbed(embedplay2);
  1662.        }
  1663.        if (!permissions.has('SPEAK')){
  1664.            var embedplay3 = new Discord.RichEmbed()
  1665.                .setTitle(`I do not have the right to SPEAK to connect in these Voice Channel!`)
  1666.                .setColor(['#f9fcfc'])
  1667.            return msg.channel.sendEmbed(embedplay3);
  1668.        }
  1669.      
  1670.  
  1671.                    
  1672.        if(url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)){
  1673.            const playlist = await youtube.getPlaylist(url);
  1674.            const videos = await playlist.getVideos();
  1675.            for(const video of Object.values(videos)){
  1676.                const video2 = await youtube.getVideoByID(video.id);
  1677.                await handleVideo(video2, msg, voiceChannel, true);
  1678.            }
  1679.            var embedplay4 = new Discord.RichEmbed()
  1680.                .setTitle(`Playlist: ${playlist.title} queued!`)
  1681.                .setColor(['#f9fcfc'])
  1682.            return msg.channel.sendEmbed(embedplay4);
  1683.        }else{
  1684.            try{
  1685.                var video = await youtube.getVideo(url);
  1686.            }catch(error){
  1687.                try{
  1688.                    var videos = await youtube.searchVideos(searchString, 10);
  1689.                    let index = 0;
  1690.                    var embedqueue5 = new Discord.RichEmbed()
  1691.                        .setTitle(`Song Play list`)
  1692.                        .setDescription(`
  1693. ${videos.map(video2 => `${++index}- ${video2.title}`).join('\n')}
  1694.  
  1695. Please enter a number between 1-10 on,a Song select!`)
  1696.                .setColor(['#f9fcfc'])
  1697.                    msg.channel.sendEmbed(embedqueue5);
  1698.                  
  1699.                    try{
  1700.                       var response = await msg.channel.awaitMessages(msg2 => msg2.content > 0 && msg2.content < 11, {
  1701.                           maxMatches: 1,
  1702.                           time: 100000,
  1703.                           errors: ['time']
  1704.                       });
  1705.                    }catch(err){
  1706.                        console.error(err);
  1707.                        var embedplay6 = new Discord.RichEmbed()
  1708.                            .setTitle(`no or invalid number was entered. Demolition of the song selection!`)
  1709.                            .setColor(['#f9fcfc'])
  1710.                        return msg.channel.sendEmbed(embedplay6);
  1711.                    }
  1712.                    const videoIndex = parseInt(response.first().content);
  1713.                    var video = await youtube.getVideoByID(videos[videoIndex - 1].id);
  1714.                }catch(err){
  1715.                    console.error(err);
  1716.                    var embedplay7 = new Discord.RichEmbed()
  1717.                        .setTitle(`I could find no video!`)
  1718.                        .setColor(['#f9fcfc'])
  1719.                    return msg.channel.sendEmbed(embedplay7);
  1720.                }
  1721.            }
  1722.            return handleVideo(video, msg, voiceChannel);
  1723.        }
  1724.  
  1725.    } else if(msg.content.startsWith(`${PREFIX}skip`)) {
  1726.        if(!msg.member.voiceChannel){
  1727.           var embedskip1 = new Discord.RichEmbed()
  1728.                .setTitle(`You are in not in the Voice Channel!`)
  1729.                .setColor(['#f9fcfc'])
  1730.            return msg.channel.sendEmbed(embedskip1);
  1731.        }
  1732.        if(!serverQueue){
  1733.            var embedskip2 = new Discord.RichEmbed()
  1734.                .setTitle(`There is nothing to Skip!`)
  1735.                .setColor(['#f9fcfc'])
  1736.            return msg.channel.sendEmbed(embedskip2);
  1737.        }
  1738.        serverQueue.connection.dispatcher.end('Skip command has been used!');
  1739.        var embedskip3 = new Discord.RichEmbed()
  1740.            .setTitle(`⏩Skipped👍`)
  1741.            .setColor(['#f9fcfc'])
  1742.        return msg.channel.sendEmbed(embedskip3);
  1743.    }  
  1744.      
  1745.     else if (msg.content.startsWith(`${PREFIX}stop`)){
  1746.        if(!msg.member.voiceChannel){
  1747.           var embedstop1 = new Discord.RichEmbed()
  1748.                .setTitle(`you're not in the voice channel!`)
  1749.                .setColor(['#f9fcfc'])
  1750.            return msg.channel.sendEmbed(embedstop1);
  1751.        }
  1752.        if(!serverQueue){
  1753.            var embedstop2 = new Discord.RichEmbed()
  1754.                .setTitle(`There is nothing to stop!`)
  1755.                .setColor(['#f9fcfc'])
  1756.            return msg.channel.sendEmbed(embedstop2);
  1757.        }
  1758.        serverQueue.songs = [];
  1759.        serverQueue.connection.dispatcher.end('Stop command has been used!');
  1760.        var embedstop3 = new Discord.RichEmbed()
  1761.            .setTitle(`⏩Skipped👍`)
  1762.            .setColor(['#f9fcfc'])
  1763.        return msg.channel.sendEmbed(embedstop3);
  1764.    }
  1765.    else if(msg.content.startsWith(`${PREFIX}song`)){
  1766.        if(!serverQueue){
  1767.            var embedsong1 = new Discord.RichEmbed()
  1768.                .setTitle(`It does nothing at the moment!`)
  1769.                .setColor(['#f9fcfc'])
  1770.            return msg.channel.sendEmbed(embedsong1);
  1771.                 }
  1772.            var embedsong2 = new Discord.RichEmbed()
  1773.                .setTitle(`${serverQueue.songs[0].title}`)
  1774.                .setThumbnail(serverQueue.songs[0].thumbnail)
  1775.                .setDescription(`
  1776. Von: ${serverQueue.songs[0].channel}
  1777. Dauer: ${serverQueue.songs[0].duration}
  1778. Link: ${serverQueue.songs[0].url}
  1779. `)
  1780.                .setColor(['#f9fcfc'])
  1781.            return msg.channel.sendEmbed(embedsong2);
  1782.    }
  1783.    else if(msg.content.startsWith(`${PREFIX}volume`)){
  1784.        if(!serverQueue){
  1785.            var embedvolume1 = new Discord.RichEmbed()
  1786.                .setTitle(`It does nothing at the moment!`)
  1787.                .setColor(['#f9fcfc'])
  1788.            return msg.channel.sendEmbed(embedvolume1);}
  1789.        if(!args[1]){
  1790.             var embedvolume2 = new Discord.RichEmbed()
  1791.                .setTitle(`The current volume is: ${serverQueue.volume}`)
  1792.                .setColor(['#f9fcfc'])
  1793.            return msg.channel.sendEmbed(embedvolume2);
  1794.        }
  1795.        
  1796.        if(args[1]>0){
  1797.        serverQueue.volume = args[1];
  1798.        serverQueue.connection.dispatcher.setVolume(args[1] / 2000);
  1799.        serverQueue.mute = false;
  1800.        var embedvolume3 = new Discord.RichEmbed()
  1801.                .setTitle(`The volume is on ${args[1]} set`)
  1802.                .setColor(['#f9fcfc'])
  1803.        return msg.channel.sendEmbed(embedvolume3);
  1804.        } else{
  1805.            var embedvolume4 = new Discord.RichEmbed()
  1806.                .setTitle(`Please enter a number >0 on!`)
  1807.                .setColor(['#f9fcfc'])
  1808.            return msg.channel.sendEmbed(embedvolume4);
  1809.        }
  1810.    }
  1811.    else if(msg.content.startsWith(`${PREFIX}queue`)){
  1812.        if(!serverQueue){
  1813.            var embedqueue1 = new Discord.RichEmbed()
  1814.                .setTitle(`It does nothing at the moment!`)
  1815.                .setColor(['#f9fcfc'])
  1816.        return msg.channel.sendEmbed(embedqueue1);
  1817.        }
  1818.        var embedqueue2 = new Discord.RichEmbed()
  1819.                .setTitle(`Song Queue`)
  1820.                .setDescription(`
  1821. ${serverQueue.songs.map(song => `- ${song.title}`).join('\n')}
  1822.  
  1823. Playing: ${serverQueue.songs[0].title}`)
  1824.                .setColor(['#f9fcfc'])
  1825.        return msg.channel.sendEmbed(embedqueue2);
  1826.    }
  1827.    else if(msg.content.startsWith(`${PREFIX}pause`)){
  1828.        if(serverQueue && serverQueue.playing) {
  1829.        serverQueue.playing = false;
  1830.        serverQueue.connection.dispatcher.pause();
  1831.        var embedpause1 = new Discord.RichEmbed()
  1832.                .setTitle(`The song is stopped!`)
  1833.                .setColor(['#f9fcfc'])
  1834.        return msg.channel.sendEmbed(embedpause1);
  1835.        }
  1836.        var embedpause2 = new Discord.RichEmbed()
  1837.            .setTitle(`It does nothing at the moment!`)
  1838.            .setColor(['#f9fcfc'])
  1839.        return msg.channel.sendEmbed(embedpause2);
  1840.    }
  1841.    else if(msg.content.startsWith(`${PREFIX}resume`)){
  1842.        if(serverQueue && !serverQueue.playing){
  1843.        serverQueue.playing = true;
  1844.        serverQueue.connection.dispatcher.resume();
  1845.        var embedresume1 = new Discord.RichEmbed()
  1846.                .setTitle(`The song keeps playing on!`)
  1847.                .setColor(['#f9fcfc'])
  1848.        return msg.channel.sendEmbed(embedresume1);          
  1849.        }
  1850.        var embedresume2 = new Discord.RichEmbed()
  1851.            .setTitle(`It does nothing at the moment!`)
  1852.            .setColor(['#f9fcfc'])
  1853.        return msg.channel.sendEmbed(embedresume2);
  1854.    }  
  1855.    else if(msg.content.startsWith(`${PREFIX}mutebot`)){
  1856.        if(!serverQueue){
  1857.        var embedmute1 = new Discord.RichEmbed()
  1858.                .setTitle(`It does nothing at the moment!`)
  1859.                .setColor(['#f9fcfc'])
  1860.        return msg.channel.sendEmbed(embedmute1);    
  1861.        }
  1862.        if(serverQueue.mute){
  1863.        var embedmute2 = new Discord.RichEmbed()
  1864.                .setTitle(`The music Bot is already muted!`)
  1865.                .setColor(['#f9fcfc'])
  1866.        return msg.channel.sendEmbed(embedmute2);    
  1867.        }
  1868.        else{
  1869.            serverQueue.mute = true;
  1870.            serverQueue.connection.dispatcher.setVolume(0 / 2000);
  1871.            var embedmute3 = new Discord.RichEmbed()
  1872.                .setTitle(`The music Bot was muted!`)
  1873.                .setColor(['#f9fcfc'])
  1874.        return msg.channel.sendEmbed(embedmute3);
  1875.        }
  1876.    }
  1877.    else if(msg.content.startsWith(`${PREFIX}unmutebot`)){
  1878.        if(!serverQueue){
  1879.            var embedunmute1 = new Discord.RichEmbed()
  1880.                .setTitle(`It does nothing at the moment!`)
  1881.                .setColor(['#f9fcfc'])
  1882.            return msg.channel.sendEmbed(embedunmute1);    
  1883.        }
  1884.        if(!serverQueue.mute){
  1885.            var embedunmute2 = new Discord.RichEmbed()
  1886.                .setTitle(`The Music Bot is already unmuted!`)
  1887.                .setColor(['#f9fcfc'])
  1888.            return msg.channel.sendEmbed(embedunmute2);    
  1889.        }  
  1890.        else{
  1891.            serverQueue.mute = false;
  1892.            serverQueue.connection.dispatcher.setVolume(serverQueue.volume / 2000);
  1893.            var embedunmute3 = new Discord.RichEmbed()
  1894.                .setTitle(`The Music Bot has been unmuted!`)
  1895.                .setColor(['#f9fcfc'])
  1896.        return msg.channel.sendEmbed(embedunmute3);
  1897.        }
  1898.    }
  1899.    else if(msg.content.startsWith(`${PREFIX}help`)){
  1900.        var embedhelp = new Discord.RichEmbed()
  1901.            .setTitle(`marcos-MusicBot Commands`)
  1902.            .addField("play", "Usage: `play`<song name> Description: To play Music.", false)
  1903.            .addField("skip", "Usage: `skip` Description: To skip music.", false)
  1904.            .addField("stop", "Usage: `stop` Description: To Bot disconnected.", false)
  1905.            .addField("song", "Usage: `song` Description: To Check The Current playing song.", false)
  1906.            .addField("queue", "Usage: `queue` Description: To Check The Queue List.", false)
  1907.            .addField("volume", "Usage: `volume` Description: To See Volume.", false)
  1908.            .addField("pause", "Usage: `pause` Description: To pause The Current Playing Song.", false)
  1909.            .addField("resume", "Usage: `resume` Description: To Resume The Paused Song.", false)
  1910.            .addField("mutebot", "Usage: `mutebot` Description: To mute Bot.", false)
  1911.            .addField("unmutebot", "Usage: `unmutebot` Description: To unmute Bot.", false)
  1912.            .setColor(['#f9fcfc'])
  1913.            .setThumbnail(client.user.avatarURL)
  1914.            return msg.channel.sendEmbed(embedhelp);
  1915.    }
  1916.    return undefined;
  1917. });
  1918.  
  1919.  
  1920. async function handleVideo(video, msg, voiceChannel, playlist=false){
  1921.    const serverQueue = queue.get(msg.guild.id);
  1922.    
  1923.    const song = {
  1924.        id: video.id,
  1925.        title: Util.escapeMarkdown(video.title),
  1926.        url: `https://www.youtube.com/watch?v=${video.id}`,
  1927.        thumbnail: video.thumbnails.default.url,
  1928.        channel: video.channel.title,
  1929.        duration: `${video.duration.hours}hrs : ${video.duration.minutes}min : ${video.duration.seconds}sec`
  1930.    };
  1931.    if(!serverQueue){
  1932.        const queueConstruct = {
  1933.            textChannel: msg.channel,
  1934.            voiceChannel: voiceChannel,
  1935.            connection: null,
  1936.            songs: [],
  1937.            volume: 2100,
  1938.            mute: false,
  1939.            playing: true
  1940.        };
  1941.        queue.set(msg.guild.id, queueConstruct);
  1942.  
  1943.        queueConstruct.songs.push(song);
  1944.  
  1945.        try{
  1946.            var connection = await voiceChannel.join();
  1947.            queueConstruct.connection = connection;
  1948.            play(msg.guild, queueConstruct.songs[0]);
  1949.        }catch(error){
  1950.            console.log(error);
  1951.            queue.delete(msg.guild.id);
  1952.            var embedfunc1 = new Discord.RichEmbed()
  1953.                .setTitle(`Bot could not VoiceChannel the join!`)
  1954.                .setColor(['#f9fcfc'])
  1955.            return msg.channel.sendEmbed(embedfunc1);
  1956.        }
  1957.    } else {
  1958.        serverQueue.songs.push(song);
  1959.        console.log(serverQueue.songs);
  1960.        if(playlist) return undefined;
  1961.        else{
  1962.            var embedfunc2 = new Discord.RichEmbed()
  1963.                .setTitle(`${song.title} queued!`)
  1964.                .setColor(['#f9fcfc'])
  1965.            return msg.channel.sendEmbed(embedfunc2);
  1966.        }
  1967.    }    
  1968.    return undefined;
  1969. }
  1970.  
  1971. function play(guild, song){
  1972.    const serverQueue = queue.get(guild.id);
  1973.    
  1974.    if(!song){
  1975.        serverQueue.voiceChannel.leave();
  1976.        queue.delete(guild.id);
  1977.        return;
  1978.    }
  1979.    console.log(serverQueue.songs);
  1980.    
  1981.    const dispatcher = serverQueue.connection.playStream(ytdl(song.url))
  1982.            .on('end', reason => {
  1983.                if(reason === 'Stream is not generating quickly enough.') console.log('Song ended');
  1984.                else console.log(reason);
  1985.                serverQueue.songs.shift();
  1986.                setTimeout(() => {
  1987.                play(guild, serverQueue.songs[0]);
  1988.                }, 250);
  1989.            })
  1990.            .on('error', error => console.log(error));
  1991.            
  1992.    dispatcher.setVolume(serverQueue.volume / 2000);
  1993.    
  1994.    var messagefunction1 = new Discord.RichEmbed()
  1995.                .setTitle(`Playing 🎶 ${song.title} -now`)
  1996.                .setColor(['#f9fcfc'])
  1997.            return serverQueue.textChannel.sendEmbed(messagefunction1);
  1998. }
  1999.  
  2000.  
  2001.  */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement