Advertisement
dfhfjjfgjfsfeedgf

Untitled

May 23rd, 2019
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. const Discord = require('discord.js');
  2. const bot = new Discord.Client();
  3.  
  4. const token = 'NTgxMjYzMzU4NTMxOTkzNjE3.XOc53A.AjJ6FyT6_mJwB3MAvijd-xId1Zo';
  5. const ytdl = require ("ytdl-core")
  6.  
  7. const servers ={};
  8.  
  9. const PREFIX = '?';
  10.  
  11.  
  12. bot.on('ready',() =>{
  13. console.log('This bot is online!')
  14. });
  15.  
  16. bot.on('message', message=>{
  17.  
  18. let args = message.content.substring(PREFIX.length).split(" ");
  19.  
  20. switch(args[0]){
  21. case 'ping':
  22. message.reply('pong!');
  23. break;
  24. case 'info':
  25. message.reply('This bot was created by ItszKev to use it on your server click https://discordapp.com/oauth2/authorize?client_id=581263358531993617&scope=bot&permissions=0');
  26. break;
  27. case 'clear':
  28. if(!args[1]) return message.reply('how much should I clear?')
  29. message.channel.bulkDelete(args[1]);
  30. break;
  31.  
  32. }
  33. if(message.content.startsWith('?play')) {
  34. if (!message.member.voiceChannel) return message.channel.send(`Please connect to a voice channel ${message.author}`);
  35.  
  36. //checks if the bot is already connected to a voice channel
  37. if (message.guild.me.voiceChannel) return message.channel.send("Sorry, the bot is already connected to a voice channel");
  38.  
  39. //checks if the person put a url
  40. if (!args[0]) return message.channel.send(" Uh oh, something turned into a oof try again!");
  41.  
  42. //validate info
  43. let validate = await ytdl.validateURL(args[0]);
  44.  
  45. //checks validation
  46. if (!validate) return message.channel.send("Uhhhh wa happend? Try again please");
  47.  
  48. //fetches video information
  49. let info = await ytdl.getInfo(args[0]);
  50.  
  51. //stores authors guild channels
  52. let connection = await message.member.voiceChannel.join();
  53.  
  54. //plays the song with url
  55. let dispatcher = await connection.playStream(ytdl(args[0], { filter: `audioonly`}));
  56.  
  57. //song now playing
  58. message.channel.send(`Now playing: ${info.title}`);
  59.  
  60. }
  61.  
  62. });
  63.  
  64.  
  65. bot.login(token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement