Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Discord = require("discord.js");
- var client = new Discord.Client();
- var request = require("discord.js-music");
- client.on("message", m => {
- if (m.content === "&init") {
- for (var channel of m.channel.server.channels) {
- if (channel instanceof Discord.VoiceChannel) {
- client.reply(m, channel.name + " - " + channel.id);
- client.joinVoiceChannel(channel).catch(error);
- break;
- }
- }
- }
- if (m.content.startsWith("$$$ stop")) {
- if (client.internal.voiceConnection) {
- client.internal.voiceConnection.stopPlaying();
- }
- return;
- }
- if (m.content.startsWith("$$$ leave")) {
- client.internal.leaveVoiceChannel();
- return;
- }
- if (m.content.startsWith("$$$")) {
- var rest = m.content.split(" ");
- rest.splice(0, 1);
- rest = rest.join(" ");
- if (client.internal.voiceConnection) {
- client.reply(m, "ok, I'll play that for you");
- var connection = client.internal.voiceConnection;
- var filePath = LOADDIR + rest
- connection.playFile(filePath);
- }
- }
- if (m.content.startsWith("pipeit")) {
- var rest = m.content.split(" ");
- rest.splice(0, 1);
- rest = rest.join(" ");
- if (client.internal.voiceConnection) {
- var connection = client.internal.voiceConnection;
- var request = require("request");
- var stream = request(rest);
- connection.playRawStream(stream).then(intent => {
- client.reply(m, "playing!").then((msg) => {
- intent.on("end", () => {
- client.updateMessage(msg, "that song has finished now.");
- });
- });
- });
- }
- }
- });
- function error(e) {
- console.log(e.stack);
- process.exit(0);
- }
- client.on('ready', () => {
- console.log('I am ready!');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement