Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. var Discord = require("discord.js");
  2. var client = new Discord.Client();
  3. var request = require("discord.js-music");
  4.  
  5. client.on("message", m => {
  6.  
  7. if (m.content === "&init") {
  8.  
  9. for (var channel of m.channel.server.channels) {
  10.  
  11. if (channel instanceof Discord.VoiceChannel) {
  12.  
  13. client.reply(m, channel.name + " - " + channel.id);
  14.  
  15. client.joinVoiceChannel(channel).catch(error);
  16.  
  17. break;
  18. }
  19. }
  20. }
  21.  
  22. if (m.content.startsWith("$$$ stop")) {
  23.  
  24. if (client.internal.voiceConnection) {
  25.  
  26. client.internal.voiceConnection.stopPlaying();
  27. }
  28.  
  29. return;
  30. }
  31.  
  32. if (m.content.startsWith("$$$ leave")) {
  33.  
  34. client.internal.leaveVoiceChannel();
  35.  
  36. return;
  37. }
  38.  
  39. if (m.content.startsWith("$$$")) {
  40.  
  41. var rest = m.content.split(" ");
  42.  
  43. rest.splice(0, 1);
  44.  
  45. rest = rest.join(" ");
  46.  
  47.  
  48. if (client.internal.voiceConnection) {
  49.  
  50. client.reply(m, "ok, I'll play that for you");
  51.  
  52. var connection = client.internal.voiceConnection;
  53.  
  54. var filePath = LOADDIR + rest
  55.  
  56. connection.playFile(filePath);
  57. }
  58. }
  59.  
  60. if (m.content.startsWith("pipeit")) {
  61.  
  62. var rest = m.content.split(" ");
  63. rest.splice(0, 1);
  64. rest = rest.join(" ");
  65.  
  66.  
  67. if (client.internal.voiceConnection) {
  68.  
  69. var connection = client.internal.voiceConnection;
  70.  
  71. var request = require("request");
  72.  
  73. var stream = request(rest);
  74.  
  75. connection.playRawStream(stream).then(intent => {
  76.  
  77. client.reply(m, "playing!").then((msg) => {
  78.  
  79. intent.on("end", () => {
  80.  
  81. client.updateMessage(msg, "that song has finished now.");
  82. });
  83. });
  84. });
  85. }
  86. }
  87. });
  88.  
  89.  
  90. function error(e) {
  91. console.log(e.stack);
  92. process.exit(0);
  93. }
  94.  
  95. client.on('ready', () => {
  96. console.log('I am ready!');
  97. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement