Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js');
- const Util = require('discord.js');
- const getYoutubeID = require('get-youtube-id');
- const fetchVideoInfo = require('youtube-info');
- const YouTube = require('simple-youtube-api');
- const youtube = new YouTube("AIzaSyDLDoUv5Oca_Hd1QbTFL0jN6M6wWqn7njA");
- const queue = new Map();
- const ytdl = require('ytdl-core');
- const fs = require('fs');
- const gif = require("gif-search");
- const client = new Discord.Client({disableEveryone: true});
- const prefix = "1";
- /////////////////////////
- ////////////////////////
- client.on('ready', () => {
- console.log(`Logged in as ${client.user.tag} !`);
- client.user.setGame(`1help `, `www.twitch.tv/v5bz`);
- });
- const devs1 = ['510831122238668833','480407581085532180'];
- client.on('message', message => {
- let argresult = message.content.split(` `).slice(1).join(' ');
- if (message.content.startsWith(prefix + 'setStreaming')) {
- if (!devs1.includes(message.author.id)) return message.channel.send("<@480407581085532180> only this guy can do restart the bot so don't try again :wink:.");
- message.delete();
- client.user.setGame(argresult, 'https://twitch.tv/DynastyShop');
- } else if(message.content.startsWith(prefix + 'setWatching')) {
- client.user.setActivity(argresult,{type: 'WATCHING'});
- } else if(message.content.startsWith(prefix + 'setListening')) {
- client.user.setActivity(argresult,{type: 'LISTENING'});
- } else if(message.content.startsWith(prefix + 'setPlaying')) {
- client.user.setActivity(argresult,{type: 'PLAYING'});
- } else if(message.content.startsWith(prefix + 'setName')) {
- client.user.setUsername(argresult);
- } else if(message.content.startsWith(prefix + 'setAvatar')) {
- client.user.setAvatar(argresult);
- } else if(message.content.startsWith(prefix + 'setStatus')) {
- if(!argresult) return message.channel.send('`online`, `DND(Do not Distrub),` `idle`, `invisible(Offline)` :notes: أختر أحد الحالات');
- client.user.setStatus(argresult);
- }
- });
- client.on('message', async msg =>{
- if (msg.author.bot) return undefined;
- if (!msg.content.startsWith(prefix)) return undefined;
- let args = msg.content.split(' ');
- let command = msg.content.toLowerCase().split(" ")[0];
- command = command.slice(prefix.length)
- if(command === `ping`) {
- let embed = new Discord.RichEmbed()
- .setColor(3447003)
- .setTitle("Pong!!")
- .setDescription(`${client.ping} ms,`)
- .setFooter(`Requested by | ${msg.author.tag}`);
- msg.delete().catch(O_o=>{})
- msg.channel.send(embed);
- }
- });
- /////////////////////////
- ////////////////////////
- //////////////////////
- client.on('message', async msg =>{
- if (msg.author.bot) return undefined;
- if (!msg.content.startsWith(prefix)) return undefined;
- let args = msg.content.split(' ');
- let command = msg.content.toLowerCase().split(" ")[0];
- command = command.slice(prefix.length)
- if(command === `avatar`){
- if(msg.channel.type === 'dm') return msg.channel.send("Nope Nope!! u can't use avatar command in DMs (:")
- let mentions = msg.mentions.members.first()
- if(!mentions) {
- let sicon = msg.author.avatarURL
- let embed = new Discord.RichEmbed()
- .setImage(msg.author.avatarURL)
- .setColor("#5074b3")
- msg.channel.send({embed})
- } else {
- let sicon = mentions.user.avatarURL
- let embed = new Discord.RichEmbed()
- .setColor("#5074b3")
- .setImage(sicon)
- msg.channel.send({embed})
- }
- };
- });
- /////////////////////////
- ////////////////////////
- //////////////////////
- /////////////////////////
- ////////////////////////
- //////////////////////
- /////////////////////////
- ////////////////////////
- //////////////////////
- /////////////////////////
- ////////////////////////
- //////////////////////
- client.on('message', async msg => {
- if (msg.author.bot) return undefined;
- if (!msg.content.startsWith(prefix)) return undefined;
- const args = msg.content.split(' ');
- const searchString = args.slice(1).join(' ');
- const url = args[1] ? args[1].replace(/<(.+)>/g, '$1') : '';
- const serverQueue = queue.get(msg.guild.id);
- let command = msg.content.toLowerCase().split(" ")[0];
- command = command.slice(prefix.length)
- if (command === `play`) {
- const voiceChannel = msg.member.voiceChannel;
- if (!voiceChannel) return msg.channel.send("I can't find you in any voice channel!");
- const permissions = voiceChannel.permissionsFor(msg.client.user);
- if (!permissions.has('CONNECT')) {
- return msg.channel.send("I don't have enough permissions to join your voice channel!");
- }
- if (!permissions.has('SPEAK')) {
- return msg.channel.send("I don't have enough permissions to speak in your voice channel!");
- }
- if (!permissions.has('EMBED_LINKS')) {
- return msg.channel.sendMessage("I don't have enough permissions to insert a URLs!")
- }
- if (url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)) {
- const playlist = await youtube.getPlaylist(url);
- const videos = await playlist.getVideos();
- for (const video of Object.values(videos)) {
- const video2 = await youtube.getVideoByID(video.id);
- await handleVideo(video2, msg, voiceChannel, true);
- }
- return msg.channel.send(`**${playlist.title}**, Just added to the queue!`);
- } else {
- try {
- var video = await youtube.getVideo(url);
- } catch (error) {
- try {
- var videos = await youtube.searchVideos(searchString, 5);
- let index = 0;
- const embed1 = new Discord.RichEmbed()
- .setTitle(":mag_right: YouTube Search Results :")
- .setDescription(`
- ${videos.map(video2 => `${++index}. **${video2.title}**`).join('\n')}`)
- .setColor("#f7abab")
- msg.channel.sendEmbed(embed1).then(message =>{message.delete(20000)})
- /////////////////
- try {
- var response = await msg.channel.awaitMessages(msg2 => msg2.content > 0 && msg2.content < 11, {
- maxMatches: 1,
- time: 15000,
- errors: ['time']
- });
- } catch (err) {
- console.error(err);
- return msg.channel.send('No one respone a number!!');
- }
- const videoIndex = parseInt(response.first().content);
- var video = await youtube.getVideoByID(videos[videoIndex - 1].id);
- } catch (err) {
- console.error(err);
- return msg.channel.send("I didn't find any results!");
- }
- }
- return handleVideo(video, msg, voiceChannel);
- }
- } else if (command === `skip`) {
- if (!msg.member.voiceChannel) return msg.channel.send("You Must be in a Voice channel to Run the Music commands!");
- if (!serverQueue) return msg.channel.send("There is no Queue to skip!!");
- serverQueue.connection.dispatcher.end('Ok, skipped!');
- return undefined;
- } else if (command === `stop`) {
- if (!msg.member.voiceChannel) return msg.channel.send("You Must be in a Voice channel to Run the Music commands!");
- if (!serverQueue) return msg.channel.send("There is no Queue to stop!!");
- serverQueue.songs = [];
- serverQueue.connection.dispatcher.end('Ok, stopped & disconnected from your Voice channel');
- return undefined;
- } else if (command === `vol`) {
- if (!msg.member.voiceChannel) return msg.channel.send("You Must be in a Voice channel to Run the Music commands!");
- if (!serverQueue) return msg.channel.send('You only can use this command while music is playing!');
- if (!args[1]) return msg.channel.send(`The bot volume is **${serverQueue.volume}**`);
- serverQueue.volume = args[1];
- serverQueue.connection.dispatcher.setVolumeLogarithmic(args[1] / 50);
- return msg.channel.send(`Volume Now is **${args[1]}**`);
- } else if (command === `np`) {
- if (!serverQueue) return msg.channel.send('There is no Queue!');
- const embedNP = new Discord.RichEmbed()
- .setDescription(`Now playing **${serverQueue.songs[0].title}**`)
- return msg.channel.sendEmbed(embedNP);
- } else if (command === `queue`) {
- if (!serverQueue) return msg.channel.send('There is no Queue!!');
- let index = 0;
- // // //
- const embedqu = new Discord.RichEmbed()
- .setTitle("The Queue Songs :")
- .setDescription(`
- ${serverQueue.songs.map(song => `${++index}. **${song.title}**`).join('\n')}
- **Now playing :** **${serverQueue.songs[0].title}**`)
- .setColor("#f7abab")
- return msg.channel.sendEmbed(embedqu);
- } else if (command === `pause`) {
- if (serverQueue && serverQueue.playing) {
- serverQueue.playing = false;
- serverQueue.connection.dispatcher.pause();
- return msg.channel.send('Ok, paused');
- }
- return msg.channel.send('There is no Queue to Pause!');
- } else if (command === "resume") {
- if (serverQueue && !serverQueue.playing) {
- serverQueue.playing = true;
- serverQueue.connection.dispatcher.resume();
- return msg.channel.send('Ok, resumed!');
- }
- return msg.channel.send('Queue is empty!');
- }
- return undefined;
- });
- async function handleVideo(video, msg, voiceChannel, playlist = false) {
- const serverQueue = queue.get(msg.guild.id);
- console.log(video);
- const song = {
- id: video.id,
- title: Util.escapeMarkdown(video.title),
- url: `https://www.youtube.com/watch?v=${video.id}`
- };
- if (!serverQueue) {
- const queueConstruct = {
- textChannel: msg.channel,
- voiceChannel: voiceChannel,
- connection: null,
- songs: [],
- volume: 5,
- playing: true
- };
- queue.set(msg.guild.id, queueConstruct);
- queueConstruct.songs.push(song);
- try {
- var connection = await voiceChannel.join();
- queueConstruct.connection = connection;
- play(msg.guild, queueConstruct.songs[0]);
- } catch (error) {
- console.error(`I could not join the voice channel: ${error}!`);
- queue.delete(msg.guild.id);
- return msg.channel.send(`Can't join this channel: ${error}!`);
- }
- } else {
- serverQueue.songs.push(song);
- console.log(serverQueue.songs);
- if (playlist) return undefined;
- else return msg.channel.send(`**${song.title}**, just added to the queue! `);
- }
- return undefined;
- }
- function play(guild, song) {
- const serverQueue = queue.get(guild.id);
- if (!song) {
- serverQueue.voiceChannel.leave();
- queue.delete(guild.id);
- return;
- }
- console.log(serverQueue.songs);
- const dispatcher = serverQueue.connection.playStream(ytdl(song.url))
- .on('end', reason => {
- if (reason === 'Stream is not generating quickly enough.') console.log('Song ended.');
- else console.log(reason);
- serverQueue.songs.shift();
- play(guild, serverQueue.songs[0]);
- })
- .on('error', error => console.error(error));
- dispatcher.setVolumeLogarithmic(serverQueue.volume / 5);
- serverQueue.textChannel.send(`**${song.title}**, is now playing!`);
- }
- client.on('message', message => {
- if (message.author.bot) return;
- if (message.content === prefix + "help") {
- message.channel.send('**The Message Was Sent On Private**');
- message.author.sendMessage(`
- **
- By: JakeY#2019
- ╔[❖════════════❖]╗
- Prefix = ' 1 '
- ╚[❖════════════❖]╝
- ╔[❖════════════❖]╗
- Music Commands كومندات الميوزك
- ╚[❖════════════❖]╝
- ❖ 1play ➾ play a song تشغل اغنية برابط او اسم
- ❖ 1stop ➾ stop the song توقف البوت نهائيا
- ❖ 1np ➾ view the current song تشوف الاغنية اللي مشغلة حاليا
- ❖ 1queue ➾ the current playlist تشوف قائمة التشغيل الحالية
- ❖ 1skip ➾ skips a song تتجاوز اغنية
- ❖ 1resume ➾ resums a song تشغل الاغنية بعد التوقيف المؤقت
- ❖ 1pause ➾ pauses a song تووقف اغنية مؤقتا
- تخلي البوت يخرج من رومك الصوتي
- ╔[❖════════════❖]╗
- General Commands كومندات عامة
- ╚[❖════════════❖]╝
- ❖ 1ping ➾ view my ping ! تشوف سرعة اتصال البوت
- ==================================================================
- ==================================================================
- `);
- }
- });
- client.on('message', message => {
- if (message.content === '1general_commands') {
- let helpEmbed = new Discord.RichEmbed()
- .setTitle('**أوامر عامة...**')
- .addField('avatar', "افاتار الشخص المطلوب")
- .addField('gif', 'البحث عن جيف انت تطلبه')
- .addField('ping', 'معرفة ping البوت')
- .setFooter('المزيد قريبا ان شاء الله!')
- message.channel.send(helpEmbed);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement