summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--commands/play.js95
-rw-r--r--music.js92
-rw-r--r--package-lock.json75
-rw-r--r--package.json4
4 files changed, 1 insertions, 265 deletions
diff --git a/commands/play.js b/commands/play.js
deleted file mode 100644
index ce7072c..0000000
--- a/commands/play.js
+++ /dev/null
@@ -1,95 +0,0 @@
-/********************************
- *
- * Play: Command for AleeBot
- *
- * Copyright (c) 2018 AleeCorp & jtsshieh
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- ********************************/
-module.exports.run = async (client, message, args) => {
- if (!args[0]) return await message.channel.send('A name of the song of a link is needed.');
- if (!message.member.voiceChannelID) return await message.channel.send('You are not in a voice channel');
- const YouTube = require('simple-youtube-api');
- const moment = require('moment');
- const youtube = new YouTube(client.apikey);
- const url = args.join(' ').replace(/<(.+)>/g, '$1');
- if (!url) return;
- await youtube.getVideo(url)
- .then(results => {
- YTVideo(results);
- })
- .catch(() => {
- youtube.searchVideos(args.join(' '), 1)
- .then(results => {
- youtube.getVideo(results[0].url)
- .then(vid => {
- YTVideo(vid);
- });
- });
- });
-
- const music = require('../music.js');
- async function YTVideo(video) {
- if (video.durationSeconds === 0) {
- return message.channel.send('Live streams are not available');
- }
- const d = moment.duration({
- s: video.durationSeconds
- });
-
- const server = music.MusicVariables(client, message.member.guild.id);
- const time = moment().startOf('day').add(d).format('HH:mm:ss');
- server.queue.push({
- url: video.url,
- title: video.title,
- thumbnail: video.thumbnails.high.url,
- duration: video.durationSeconds,
- requested: message.author.mention,
- playing: false
- });
- const { RichEmbed } = require('discord.js');
-
- const embed = new RichEmbed()
- .setTitle('A song has been queued')
- .setAuthor(video.title, video.thumbnails.high.url)
- .setColor(0x00afff)
- .setTimestamp()
- .addField('Title', video.title)
- .addField('Link', video.url)
- .addField('Duration', time)
- .setThumbnail(video.thumbnails.high.url)
- .setFooter('AleeBot Music Player');
- await message.channel.send({embed});
- if (!client.voiceConnections.get(message.member.guild.id))
- message.member.voiceChannel.join().then(function(connection) {
- music.playYT(client, connection, message);
- });
- return null;
- }};
-
-exports.conf = {
- aliases: [],
- guildOnly: false,
-};
-exports.help = {
- name: 'play',
- description: 'Plays music',
- usage: 'play [args]',
- category: '- Music Commands',
-};
diff --git a/music.js b/music.js
deleted file mode 100644
index a4e0b90..0000000
--- a/music.js
+++ /dev/null
@@ -1,92 +0,0 @@
-/********************************
- *
- * Music: Plugin for AleeBot
- *
- * Copyright (c) 2018 AleeCorp & jtsshieh
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- ********************************/
-// Created by jtsshieh#6434 in the BonGon project: https://github.com/jtsshieh/BonGon
-
-const YTDL = require('ytdl-core');
-module.exports.playYT = async (bot, connection, msg) => {
- const EventEmitter = require('events');
- class MyEmitter extends EventEmitter {}
- bot.musicEmit = new MyEmitter();
-
- const musicvariables = require('./music.js').MusicVariables;
- const server = musicvariables(bot, msg.member.guild.id);
-
- server.dispatcher = connection;
-
- connection.playStream(YTDL(server.queue[0].url, {
- filter: 'audioonly'
- }));
-
- server.nowPlaying = server.queue[0];
- server.beforeNowPlaying = server.nowPlaying;
-
-
- server.queue.shift();
-
- server.nowPlaying.playing = true;
-
- let time = 0;
- let counter = setInterval(
- function() {
- time = time + 1;
- server.dispatcher.time = time;
- }, 1000);
-
- bot.musicEmit.on('paused', () => {
- clearInterval(counter);
- });
-
- bot.musicEmit.on('resumed',() =>{
- counter = setInterval(
- function() {
- time = time + 1;
- server.dispatcher.time = time;
- }, 1000);
- });
-
- connection.once('end', function() {
- clearInterval(counter);
-
- if (server.queue[0] || server.beforeNowPlaying) {
- if (server.repeat) {
- server.queue.push(server.beforeNowPlaying);
- }
-
- server.nowPlaying = null;
- bot.playYT(connection, msg);
- }
-
- else {
- bot.leaveVoiceChannel(connection.channelID);
- bot.servers[msg.member.guild.id] = null;
- }
- });
-};
-module.exports.MusicVariables = (bot, guildID) => {
- if (!bot.servers[guildID]) {
- bot.servers[guildID] = {'queue' : [], 'dispatcher': null, 'repeat': false};
- }
- return bot.servers[guildID];
-};
diff --git a/package-lock.json b/package-lock.json
index 02cc339..1c89a88 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -47,57 +47,16 @@
"ws": "4.1.0"
}
},
- "encoding": {
- "version": "0.1.12",
- "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz",
- "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=",
- "requires": {
- "iconv-lite": "0.4.19"
- }
- },
"fs": {
"version": "0.0.1-security",
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
"integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ="
},
- "html-entities": {
- "version": "1.2.1",
- "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-1.2.1.tgz",
- "integrity": "sha1-DfKTUfByEWNRXfueVUPl9u7VFi8="
- },
- "iconv-lite": {
- "version": "0.4.19",
- "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz",
- "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ=="
- },
- "is-stream": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz",
- "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ="
- },
- "iso8601-duration": {
- "version": "1.1.1",
- "resolved": "https://registry.npmjs.org/iso8601-duration/-/iso8601-duration-1.1.1.tgz",
- "integrity": "sha512-dE/f+GO/ptSFgsM7ccVOYb/82PdCrSAHdmFZgAKwdoUWq8NHg5ygohklQBqVoqcN+CHPwE+f+pWuu2HZPnBU/Q=="
- },
"long": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz",
"integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA=="
},
- "m3u8stream": {
- "version": "0.2.2",
- "resolved": "https://registry.npmjs.org/m3u8stream/-/m3u8stream-0.2.2.tgz",
- "integrity": "sha512-R/xWLXBtVr0m9sPruRL4p9uO01JyHxhcQ4nhqQhVgyT802OZyVW+dn+fWHvTnbfE6YMLc65TksZZut+Mh2OVMQ==",
- "requires": {
- "miniget": "1.2.0"
- }
- },
- "miniget": {
- "version": "1.2.0",
- "resolved": "https://registry.npmjs.org/miniget/-/miniget-1.2.0.tgz",
- "integrity": "sha1-ADY3Oia71S2+aUX85sjAOR6eEkE="
- },
"moment": {
"version": "2.21.0",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.21.0.tgz",
@@ -113,15 +72,6 @@
"resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz",
"integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA=="
},
- "node-fetch": {
- "version": "1.7.3",
- "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz",
- "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==",
- "requires": {
- "encoding": "0.1.12",
- "is-stream": "1.1.0"
- }
- },
"node-opus": {
"version": "0.2.7",
"resolved": "https://registry.npmjs.org/node-opus/-/node-opus-0.2.7.tgz",
@@ -178,20 +128,6 @@
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
},
- "sax": {
- "version": "1.2.4",
- "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
- "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
- },
- "simple-youtube-api": {
- "version": "5.0.1",
- "resolved": "https://registry.npmjs.org/simple-youtube-api/-/simple-youtube-api-5.0.1.tgz",
- "integrity": "sha512-INma8k+8z0xbsEobNyeyPdh6uEAj7PvZLbK621sjYIM609zRBYH36dQ5QofNbaNFCkGLeO2xXwLz4VDhkA3uFw==",
- "requires": {
- "iso8601-duration": "1.1.1",
- "node-fetch": "1.7.3"
- }
- },
"snekfetch": {
"version": "3.6.4",
"resolved": "https://registry.npmjs.org/snekfetch/-/snekfetch-3.6.4.tgz",
@@ -927,17 +863,6 @@
"async-limiter": "1.0.0",
"safe-buffer": "5.1.1"
}
- },
- "ytdl-core": {
- "version": "0.20.2",
- "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-0.20.2.tgz",
- "integrity": "sha512-7AAIdhVRJgS3HulFCdT4C4G8FpeKouFinMCa8YA2cvKmEjXoIiNcMJmtnOI1VJil+l57K1Ly4MzEKlvR6H7C0g==",
- "requires": {
- "html-entities": "1.2.1",
- "m3u8stream": "0.2.2",
- "miniget": "1.2.0",
- "sax": "1.2.4"
- }
}
}
}
diff --git a/package.json b/package.json
index 96b6e71..9649e0c 100644
--- a/package.json
+++ b/package.json
@@ -22,9 +22,7 @@
"fs": "0.0.1-security",
"moment": "^2.21.0",
"node-opus": "^0.2.7",
- "os": "^0.1.1",
- "simple-youtube-api": "^5.0.1",
- "ytdl-core": "^0.20.2"
+ "os": "^0.1.1"
},
"devDependencies": {}
}