Guest User

TokyoDiscordBot

a guest
Aug 21st, 2019
89
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const http = require('http');
  2. const express = require('express');
  3. const app = express();
  4. app.get("/", (request, response) => {
  5. response.sendStatus(200);
  6. });
  7. app.listen(process.env.PORT);
  8. setInterval(() => {
  9. http.get(`http://music-bottsp.glitch.me/`);
  10. }, 280000);
  11.  
  12. // كل البكجات الي ممكن تحتجها في اي بوت
  13. const { Client, RichEmbed } = require("discord.js");
  14. var { Util } = require('discord.js');
  15. const {TOKEN, YT_API_KEY, prefix, devs} = require('./config')
  16. const client = new Client({ disableEveryone: true})
  17. const ytdl = require("ytdl-core");
  18. const canvas = require("canvas");
  19. const Canvas = require("canvas");
  20. const convert = require("hh-mm-ss")
  21. const fetchVideoInfo = require("youtube-info");
  22. const botversion = require('./package.json').version;
  23. const simpleytapi = require('simple-youtube-api')
  24. const moment = require("moment");
  25. const fs = require('fs');
  26. const util = require("util")
  27. const gif = require("gif-search");
  28. const opus = require("node-opus");
  29. const ms = require("ms");
  30. const jimp = require("jimp");
  31. const { get } = require('snekfetch');
  32. const guild = require('guild');
  33. const dateFormat = require('dateformat');//npm i dateformat
  34. const YouTube = require('simple-youtube-api');
  35. const youtube = new YouTube('AIzaSyAdORXg7UZUo7sePv97JyoDqtQVi3Ll0b8');
  36. const hastebins = require('hastebin-gen');
  37. const getYoutubeID = require('get-youtube-id');
  38. const yt_api_key = "AIzaSyDeoIH0u1e72AtfpwSKKOSy3IPp2UHzqi4";
  39. const pretty = require("pretty-ms");
  40. client.login(TOKEN);
  41. const queue = new Map();
  42. var table = require('table').table
  43. const Discord = require('discord.js');
  44. client.on('ready', () => {
  45. console.log(`Logged in as ${client.user.tag}!`);
  46. });
  47.  
  48.  
  49. //كود للتجربة
  50.  
  51. client.on('message', message =>{
  52. if(message.content === 'Rping'){
  53. let start = Date.now(); message.channel.send('pong').then(message => {
  54. message.edit(`\`\`\`js
  55. Time taken: ${Date.now() - start} ms
  56. Discord API: ${client.ping.toFixed(0)} ms\`\`\``);
  57. });
  58. }
  59. });
  60.  
  61. console.log("==================================")
  62. console.log("1")
  63. console.log("2")
  64. console.log("3")
  65. console.log("=========> Bot Online <=========")
  66. console.log("========> TestBot <========")
  67. console.log("=======> Token Bot **** <=======")
  68. console.log("3")
  69. console.log("2")
  70. console.log("1")
  71. console.log("====================================")
  72. console.log("Bot Online 24/7");
  73.  
  74. client.on('message', async msg => {
  75. if (msg.author.bot) return undefined;
  76. if (!msg.content.startsWith(prefix)) return undefined;
  77. const args = msg.content.split(' ');
  78. const searchString = args.slice(1).join(' ');
  79. const url = args[1] ? args[1] .replace(/<(.+)>/g, '$1') : '';
  80. const serverQueue = queue.get(msg.guild.id);
  81. let command = msg.content.toLowerCase().split(" ")[0];
  82. command = command.slice(prefix.length)
  83. if (command === `p`) {
  84. const voiceChannel = msg.member.voiceChannel;
  85. if (!voiceChannel) return msg.channel.send('يجب توآجد حضرتك بروم صوتي .');
  86. const permissions = voiceChannel.permissionsFor(msg.client.user);
  87. if (!permissions.has('CONNECT')) {
  88. return msg.channel.send('لا يتوآجد لدي صلاحية للتكلم بهذآ الروم');
  89. }
  90. if (!permissions.has('SPEAK')) {
  91. return msg.channel.send('لا يتوآجد لدي صلاحية للتكلم بهذآ الروم');
  92. }
  93.  
  94. if (!permissions.has('EMBED_LINKS')) {
  95. return msg.channel.sendMessage("**يجب توآفر برمشن `EMBED LINKS`لدي **rl")
  96. }
  97.  
  98. if (url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)) {
  99. const playlist = await youtube.getPlaylist(url);
  100. const videos = await playlist.getVideos();
  101. for (const video of Object.values(videos)) {
  102. const video2 = await youtube.getVideoByID(video.id);
  103. await handleVideo(video2, msg, voiceChannel, true);
  104. }
  105. return msg.channel.send(` **${playlist.title}** تم الإضآفة إلى قأئمة التشغيل`);
  106. } else {
  107. try {
  108.  
  109. var video = await youtube.getVideo(url);
  110.  
  111. } catch (error) {
  112. try {
  113. var fast = {};
  114. var videos = await youtube.searchVideos(searchString, 10);
  115. let index = 0;
  116. const embed1 = new Discord.RichEmbed()
  117. .setDescription(`**الرجآء من حضرتك إختيآر رقم المقطع** :
  118. ${videos.map(video2 => `[**${++index}**] **${video2.title}**`).join('\n')}`)
  119. .setFooter(`${msg.guild.name}`)
  120. msg.channel.sendEmbed(embed1).then(message =>{
  121.  
  122. message.delete(15000)
  123.  
  124. });
  125. try {
  126. var response = await msg.channel.awaitMessages(msg2 => msg2.content > 0 && msg2.content < 11, {
  127. maxMatches: 1,
  128. time: 20000,
  129. errors: ['time']
  130. })
  131.  
  132. }catch(err) {
  133. console.error(err);
  134. return msg.channel.send('لم يتم إختيآر مقطع صوتي');
  135. }
  136. const videoIndex = parseInt(response.first().content);
  137. var video = await youtube.getVideoByID(videos[videoIndex - 1].id);
  138. } catch (err) {
  139. console.error(err);
  140. return msg.channel.send(':x: لا يتوفر نتآئج بحث ');
  141. }
  142. }
  143.  
  144. return handleVideo(video, msg, voiceChannel);
  145. }
  146. } else if (command === `sk`) {
  147. if (!msg.member.voiceChannel) return msg.channel.send('أنت لست بروم صوتي .');
  148. if (!serverQueue) return msg.channel.send('لا يتوفر مقطع لتجآوزه');
  149. serverQueue.connection.dispatcher.end('تم تجآوز هذآ المقطع');
  150. return undefined;
  151. } else if (command === `s`) {
  152. if (!msg.member.voiceChannel) return msg.channel.send('أنت لست بروم صوتي .');
  153. if (!serverQueue) return msg.channel.send('لا يتوفر مقطع لإيقآفه');
  154. serverQueue.songs = [];
  155. serverQueue.connection.dispatcher.end('تم إيقآف هذآ المقطع');
  156. return undefined;
  157. } else if (command === `vol`) {
  158. if (!msg.member.voiceChannel) return msg.channel.send('أنت لست بروم صوتي .');
  159. if (!serverQueue) return msg.channel.send('لا يوجد شيء شغآل.');
  160. if (!args[1]) return msg.channel.send(`:loud_sound: مستوى الصوت **${serverQueue.volume}**`);
  161. serverQueue.volume = args[1];
  162. serverQueue.connection.dispatcher.setVolumeLogarithmic(args[1] / 50);
  163. return msg.channel.send(`:speaker: تم تغير الصوت الي **${args[1]}**`);
  164. } else if (command === `np`) {
  165. if (!serverQueue) return msg.channel.send('لا يوجد شيء حالي ف العمل.');
  166. const embedNP = new Discord.RichEmbed()
  167. .setDescription(`:notes: الان يتم تشغيل : **${serverQueue.songs[0].title}**`)
  168. return msg.channel.sendEmbed(embedNP);
  169. } else if (command === `re`) {
  170. if (!serverQueue) return msg.channel.send('لا يوجد شيء حالي ف العمل.');
  171. const embedNP = new Discord.RichEmbed()
  172. .setDescription(`سيتم اعاده تشغيل الفديو :**${serverQueue.songs[0].title}**`)
  173. msg.channel.send({embed: embedNP})
  174. return handleVideo(video, msg, msg.member.voiceChannel);
  175.  
  176. } else if (command === `q`) {
  177. if (!serverQueue) return msg.channel.send('لا يوجد شيء حالي ف العمل.');
  178. let index = 0;
  179. const embedqu = new Discord.RichEmbed()
  180. .setDescription(`**Songs Queue**
  181. ${serverQueue.songs.map(song => `**${++index} -** ${song.title}`).join('\n')}
  182. **الان يتم تشغيل** ${serverQueue.songs[0].title}`)
  183. return msg.channel.sendEmbed(embedqu);
  184. } else if (command === `pa`) {
  185. if (serverQueue && serverQueue.playing) {
  186. serverQueue.playing = false;
  187. serverQueue.connection.dispatcher.pause();
  188. return msg.channel.send('تم إيقاف الموسيقى مؤقتا!');
  189. }
  190. return msg.channel.send('لا يوجد شيء حالي ف العمل.');
  191. } else if (command === "res") {
  192. if (serverQueue && !serverQueue.playing) {
  193. serverQueue.playing = true;
  194. serverQueue.connection.dispatcher.resume();
  195. return msg.channel.send('استأنفت الموسيقى بالنسبة لك !');
  196. }
  197. return msg.channel.send('لا يوجد شيء حالي في العمل.');
  198. }
  199.  
  200. return undefined;
  201. async function handleVideo(video, msg, voiceChannel, playlist = false) {
  202. const serverQueue = queue.get(msg.guild.id);
  203. const song = {
  204. id: video.id,
  205. title: Util.escapeMarkdown(video.title),
  206. url: `https://www.youtube.com/watch?v=${video.id}`,
  207. time:`${video.duration.hours}:${video.duration.minutes}:${video.duration.seconds}`,
  208. eyad:`${video.thumbnails.high.url}`,
  209. best:`${video.channel.title}`,
  210. bees:`${video.raw.snippet.publishedAt}`,
  211. shahd:`${video.raw.kind}`,
  212. zg:`${video.raw.snippet.channelId}`,
  213. views:`${video.raw.views}`,
  214. like:`${video.raw.likeCount}`,
  215. dislike:`${video.raw.dislikeCount}`,
  216. hi:`${video.raw.id}`
  217. };
  218. if (!serverQueue) {
  219. const queueConstruct = {
  220. textChannel: msg.channel,
  221. voiceChannel: voiceChannel,
  222. connection: null,
  223. songs: [],
  224. volume: 5,
  225. playing: true
  226. };
  227. queue.set(msg.guild.id, queueConstruct);
  228. queueConstruct.songs.push(song);
  229. try {
  230. var connection = await voiceChannel.join();
  231. queueConstruct.connection = connection;
  232. play(msg.guild, queueConstruct.songs[0]);
  233. } catch (error) {
  234. console.error(`I could not join the voice channel: ${error}`);
  235. queue.delete(msg.guild.id);
  236. return msg.channel.send(`لا أستطيع دخول هذآ الروم ${error}`);
  237. }
  238. } else {
  239. serverQueue.songs.push(song);
  240. console.log(serverQueue.songs);
  241. if (playlist) return undefined;
  242. else return msg.channel.send(` **${song.title}** تم اضافه الاغنية الي القائمة!`);
  243. }
  244. return undefined;
  245. }
  246.  
  247. function play(guild, song) {
  248. const serverQueue = queue.get(guild.id);
  249.  
  250. if (!song) {
  251. serverQueue.voiceChannel.leave();
  252. queue.delete(guild.id);
  253. return;
  254. }
  255. console.log(serverQueue.songs);
  256. const dispatcher = serverQueue.connection.playStream(ytdl(song.url))
  257. .on('end', reason => {
  258. if (reason === 'تيار لا يولد بسرعة كافية.') console.log('Song ended.');
  259. else console.log(reason);
  260. serverQueue.songs.shift();
  261. play(guild, serverQueue.songs[0]);
  262. })
  263. .on('error', error => console.error(error));
  264. dispatcher.setVolumeLogarithmic(serverQueue.volume / 5);
  265. fetchVideoInfo(`${song.hi}`, function (err, idk) {
  266. if (err) throw new Error(err);
  267. console.log( idk);
  268. const yyyy = {}
  269. if(!yyyy[msg.guild.id]) yyyy[msg.guild.id] = {
  270. like: `${ idk.likeCount}`,
  271. dislike: `${ idk.dislikeCount}`
  272. }
  273. serverQueue.textChannel.send({embed : new Discord.RichEmbed()
  274. .setTitle(`**${ idk.title}**`)
  275. .setURL( idk.url)
  276. .addField('Time The Video :' , `${song.time}`, true)
  277. .addField('Channel Name :' , `${song.best}`, true)
  278. .addField('Channel ID :' , `${song.zg}`, true)
  279. .addField('Video Created at :' , `${ idk.datePublished}`, true)
  280. .addField('Views :' , `${ idk.views}`, true)
  281. .addField('Like?? :' , `${ idk.likeCount}`, true)
  282. .addField('dislike?? :' , `${ idk.dislikeCount}`, true)
  283. .addField('comments :' , `${ idk.commentCount}`, true)
  284. .setImage(`${song.eyad}`)
  285. .setThumbnail('http://cdn.akhbaar24.com/430e061a-f89a-43c7-86d9-82fae5f7c495.jpg')
  286. .setColor('#ff0000')
  287. .setTimestamp()
  288. }).then(love => {
  289. love.react('??').then(r=>{
  290. love.react('??').then(r =>{
  291. love.react('??').then(r=> {
  292. let likee = (reaction, user) => reaction.emoji.name === '??' && user.id === msg.author.id;
  293. let dislikee = (reaction, user) => reaction.emoji.name === '??' && user.id === msg.author.id;
  294. let cnn = (reaction, user) => reaction.emoji.name === '??' && user.id === msg.author.id;
  295.  
  296. let ll = love.createReactionCollector(likee , {max:5});
  297. let dd = love.createReactionCollector(dislikee , {max:5});
  298. let cn = love.createReactionCollector(cnn , {max:5});
  299.  
  300. ll.on("collect", r => {
  301. yyyy[msg.guild.id].like++;
  302. love.edit({embed : new Discord.RichEmbed()
  303. .setTitle(`**${ idk.title}**`)
  304. .setURL( idk.url)
  305. .addField('Time The Video :' , `${song.time}`, true)
  306. .addField('Channel Name :' , `${song.best}`, true)
  307. .addField('Channel ID :' , `${song.zg}`, true)
  308. .addField('Video Created at :' , `${ idk.datePublished}`, true)
  309. .addField('Views :' , `${ idk.views}`, true)
  310. .addField('Like?? :' , `${yyyy[msg.guild.id].like}`, true)
  311. .addField('dislike?? :' , `${ idk.dislikeCount}`, true)
  312. .addField('comments :' , `${ idk.commentCount}`, true)
  313. .setImage(`${song.eyad}`)
  314. .setThumbnail('http://cdn.akhbaar24.com/430e061a-f89a-43c7-86d9-82fae5f7c495.jpg')
  315. .setColor('#ff0000')
  316. .setTimestamp()
  317. });
  318. })
  319.  
  320. dd.on("collect", r => {
  321. yyyy[msg.guild.id].dislike++;
  322. love.edit({embed : new Discord.RichEmbed()
  323. .setTitle(`**${ idk.title}**`)
  324. .setURL( idk.url)
  325. .addField('Time The Video :' , `${song.time}`, true)
  326. .addField('Channel Name :' , `${song.best}`, true)
  327. .addField('Channel ID :' , `${song.zg}`, true)
  328. .addField('Video Created at :' , `${ idk.datePublished}`, true)
  329. .addField('Views :' , `${ idk.views}`, true)
  330. .addField('Like?? :' , `${ idk.likeCount}`, true)
  331. .addField('dislike?? :' , `${yyyy[msg.guild.id].dislike}`, true)
  332. .addField('comments :' , `${ idk.commentCount}`, true)
  333. .setImage(`${song.eyad}`)
  334. .setThumbnail('http://cdn.akhbaar24.com/430e061a-f89a-43c7-86d9-82fae5f7c495.jpg')
  335. .setColor('#ff0000')
  336. .setTimestamp()
  337. });
  338. })
  339. cn.on("collect", r => {
  340. love.edit({embed : new Discord.RichEmbed()
  341. .setTitle(`**${ idk.title}**`)
  342. .setURL( idk.url)
  343. .addField('Time The Video :' , `${song.time}`, true)
  344. .addField('Channel Name :' , `${song.best}`, true)
  345. .addField('Channel ID :' , `${song.zg}`, true)
  346. .addField('Video Created at :' , `${ idk.datePublished}`, true)
  347. .addField('Views :' , `${ idk.views}`, true)
  348. .addField('Like?? :' , `${ idk.likeCount}`, true)
  349. .addField('dislike?? :' , `${ idk.dislikeCount}`, true)
  350. .addField('comments :' , `${ idk.commentCount}`, true)
  351. .setImage(`${song.eyad}`)
  352. .setThumbnail('http://cdn.akhbaar24.com/430e061a-f89a-43c7-86d9-82fae5f7c495.jpg')
  353. .setColor('#ff0000')
  354. .setTimestamp()
  355. });
  356. })
  357. })
  358. })
  359. })
  360. })
  361. })
  362. }
  363. });
  364.  
  365. client.on('ready', function(){
  366. var ms = 5000 ;
  367. var setGame = [`غنوجة | نورة | طوكيو`];
  368. var i = -1;
  369. var j = 0;
  370. setInterval(function (){
  371. if( i == -1 ){
  372. j = 1;
  373. }
  374. if( i == (setGame.length)-1 ){
  375. j = -1;
  376. }
  377. i = i+j;
  378. client.user.setGame(setGame[i],`http://www.twitch.tv/imd3s_x`);
  379. }, ms);30000
  380.  
  381. });
  382.  
  383. client.on("message", message => {
  384. if (message.content === (prefix + "help")) {
  385. const embed = new Discord.RichEmbed()
  386. .setColor("#580e6b")
  387. .setThumbnail(message.author.avatarURL)
  388. .setDescription(`***
  389.  
  390. اوامر تشغيل الميوزك
  391.  
  392. ${prefix}5p ==== > لتشغيل الاغنية
  393. ${prefix}s ==== > لايقاف جميع الاغاني
  394. ${prefix}sk ==== > لتخطي الاغنية
  395. ${prefix}vol ==== > لرفع او خفض الصوت
  396. ${prefix}np ==== > لعرض الاغنية التي يتم تشغيلها
  397. ${prefix}re ==== > لاعادة تشغيل الاغنية
  398. ${prefix}q ==== > لعرض قائمة التشغيل
  399. ${prefix}pa ==== > لايقاف الاغنية المشتغلة
  400. ***`)
  401.  
  402. message.author.sendEmbed(embed)
  403.  
  404. }
  405. });
RAW Paste Data