Advertisement
penguibird

Untitled

Dec 13th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { Client } = require ('discord.js');
  2. const bot = new Client();
  3. const TOKEN = "";
  4. var dispatcher;
  5.  
  6.  
  7. bot.login(TOKEN);
  8.  
  9. bot.on('ready', () => {
  10.     console.info(`Logged in as ${bot.user.tag}!`);
  11. });
  12.  
  13. bot.on('message', msg => {
  14.     if (msg.content === 'ping') {
  15.         msg.reply('pong');
  16.         msg.channel.send('pong');
  17.  
  18.     } else if (msg.content.startsWith('play')) {
  19.         if(msg.member.voiceChannel) {
  20.             msg.member.voiceChannel.join()
  21.             .then(connection => {
  22.                 msg.reply("I'm here");
  23.                 if (msg.content.endsWith("song")) {
  24.                     let music = "C:/scripts/JandaBot/discord-bot-sitepoint/song.mp3"
  25.                     dispatcher = connection.playFile(music);
  26.                     dispatcher.resume();
  27.                 }
  28.             })
  29.         }
  30.     } else if (msg.content.startsWith('stop')) {
  31.         dispatcher.end()
  32.     }
  33. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement