Advertisement
Guest User

Untitled

a guest
Mar 24th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. var Discord = require('discord.io');
  2. var fs = require("fs");
  3. var request = require("request");
  4. var path = require("path");
  5.  
  6. var roomId = "427109857984774144";
  7. var voideId = "368053162445242382";
  8. var invCode = "dy7FPJ";
  9. var msg = "!skip ";
  10.  
  11. let bot;
  12.  
  13. request({
  14. method: "POST",
  15. url: "https://discordapp.com/api/v6/invite/",
  16. headers: {
  17. Authorization: process.argv[2]
  18. }
  19. }, (error, response, body) => {
  20. bot = new Discord.Client({
  21. token: process.argv[2],
  22. autorun: true
  23. });
  24.  
  25. bot.on('ready', function() {
  26. console.log('Logged in as %s - %s\n', bot.username, bot.id);
  27.  
  28.  
  29. setInterval(function() {
  30. bot.sendMessage({
  31. to: roomId,
  32. message: msg
  33. });
  34. }, 1000);
  35.  
  36.  
  37. bot.joinVoiceChannel(voideId, function(error, events) {
  38. if (error) {
  39. return console.error(error);
  40. }
  41.  
  42. setTimeout(function(){
  43. bot.getAudioContext(voideId, function(error, stream) {
  44. if (error) {
  45. return console.error(error);
  46. }
  47.  
  48. playSound(stream);
  49. });
  50. }, 1000);
  51. });
  52.  
  53. });
  54. });
  55.  
  56.  
  57. function playSound(s) {
  58. console.log("Ide");
  59. let rs = fs.createReadStream(path.join(__dirname, "b.mp3")).pipe(s, {end: false});
  60. s.on('done', function() {
  61. console.log("Ide2");
  62. playSound(s);
  63. });
  64. }
  65.  
  66. process.on('SIGINT', function() {
  67. bot.disconnect();
  68. process.exit();
  69. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement