From 3733f7575faba8a06cc65c8eaf3612f80f46a44b Mon Sep 17 00:00:00 2001 From: 8cy <50817549+8cy@users.noreply.github.com> Date: Mon, 13 Apr 2020 03:54:31 -0700 Subject: test --- commands/voice/join.cjs | 26 ++++++ commands/voice/join.js | 26 ------ commands/voice/leave.cjs | 30 +++++++ commands/voice/leave.js | 30 ------- commands/voice/loop.js | 32 -------- commands/voice/loopc.js | 32 ++++++++ commands/voice/pause.cjs | 30 +++++++ commands/voice/pause.js | 30 ------- commands/voice/play.cjs | 196 +++++++++++++++++++++++++++++++++++++++++++++ commands/voice/play.js | 196 --------------------------------------------- commands/voice/queue.js | 51 ------------ commands/voice/queuec.js | 51 ++++++++++++ commands/voice/remove.cjs | 39 +++++++++ commands/voice/remove.js | 39 --------- commands/voice/resume.cjs | 31 +++++++ commands/voice/resume.js | 31 ------- commands/voice/shuffle.cjs | 52 ++++++++++++ commands/voice/shuffle.js | 52 ------------ commands/voice/skip.cjs | 27 +++++++ commands/voice/skip.js | 27 ------- commands/voice/skipall.js | 42 ---------- commands/voice/skipallc.js | 42 ++++++++++ commands/voice/skipto.cjs | 41 ++++++++++ commands/voice/skipto.js | 41 ---------- commands/voice/volume.cjs | 44 ++++++++++ commands/voice/volume.js | 44 ---------- 26 files changed, 641 insertions(+), 641 deletions(-) create mode 100644 commands/voice/join.cjs delete mode 100644 commands/voice/join.js create mode 100644 commands/voice/leave.cjs delete mode 100644 commands/voice/leave.js delete mode 100644 commands/voice/loop.js create mode 100644 commands/voice/loopc.js create mode 100644 commands/voice/pause.cjs delete mode 100644 commands/voice/pause.js create mode 100644 commands/voice/play.cjs delete mode 100644 commands/voice/play.js delete mode 100644 commands/voice/queue.js create mode 100644 commands/voice/queuec.js create mode 100644 commands/voice/remove.cjs delete mode 100644 commands/voice/remove.js create mode 100644 commands/voice/resume.cjs delete mode 100644 commands/voice/resume.js create mode 100644 commands/voice/shuffle.cjs delete mode 100644 commands/voice/shuffle.js create mode 100644 commands/voice/skip.cjs delete mode 100644 commands/voice/skip.js delete mode 100644 commands/voice/skipall.js create mode 100644 commands/voice/skipallc.js create mode 100644 commands/voice/skipto.cjs delete mode 100644 commands/voice/skipto.js create mode 100644 commands/voice/volume.cjs delete mode 100644 commands/voice/volume.js (limited to 'commands/voice') diff --git a/commands/voice/join.cjs b/commands/voice/join.cjs new file mode 100644 index 0000000..cac5e50 --- /dev/null +++ b/commands/voice/join.cjs @@ -0,0 +1,26 @@ +const { Command } = require('discord.js-commando'); +const emoji = require('emoji-random'); + +module.exports = class JoinVoice extends Command { + constructor(client) { + super(client, { + name: 'join', + aliases: ['j'], + group: 'voice', + memberName: 'join', + description: 'Joins your current voice channel.', + guildOnly: true, + examples: ['msb!join', 'msb!j'] + }); + } + run(msg) { + if (msg.guild.musicData.isPlaying == false && msg.member.voice.channel) { + msg.member.voice.channel.join(); + msg.reply('Succesfully joined your voice channel. ' + emoji.random()); + } else if (msg.guild.musicData.isPlaying == false) { + msg.reply('I\'m already in voice channel. ' + emoji.random()); + } else if (!msg.member.voice.channel) { + msg.reply('You\'re not in a voice channel. ' + emoji.random()); + } + } +}; \ No newline at end of file diff --git a/commands/voice/join.js b/commands/voice/join.js deleted file mode 100644 index cac5e50..0000000 --- a/commands/voice/join.js +++ /dev/null @@ -1,26 +0,0 @@ -const { Command } = require('discord.js-commando'); -const emoji = require('emoji-random'); - -module.exports = class JoinVoice extends Command { - constructor(client) { - super(client, { - name: 'join', - aliases: ['j'], - group: 'voice', - memberName: 'join', - description: 'Joins your current voice channel.', - guildOnly: true, - examples: ['msb!join', 'msb!j'] - }); - } - run(msg) { - if (msg.guild.musicData.isPlaying == false && msg.member.voice.channel) { - msg.member.voice.channel.join(); - msg.reply('Succesfully joined your voice channel. ' + emoji.random()); - } else if (msg.guild.musicData.isPlaying == false) { - msg.reply('I\'m already in voice channel. ' + emoji.random()); - } else if (!msg.member.voice.channel) { - msg.reply('You\'re not in a voice channel. ' + emoji.random()); - } - } -}; \ No newline at end of file diff --git a/commands/voice/leave.cjs b/commands/voice/leave.cjs new file mode 100644 index 0000000..ba48594 --- /dev/null +++ b/commands/voice/leave.cjs @@ -0,0 +1,30 @@ +const { Command } = require('discord.js-commando'); +const emoji = require('emoji-random'); + +module.exports = class LeaveVoice extends Command { + constructor(client) { + super(client, { + name: 'leave', + aliases: ['end', 'stop', 'l'], + group: 'voice', + memberName: 'leave', + description: 'Leaves the voice channel and ends playback.', + guildOnly: true, + examples: ['msb!leave', 'msb!end', 'msb!stop', 'msb!l'] + }); + } + run(msg) { + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('Join a voice channel and try again. ' + emoji.random()); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('The soundtrack isn\'t playing right now. ' + emoji.random()); + } + msg.guild.musicData.songDispatcher.end(); + msg.guild.musicData.queue.length = 0; + return; + } +}; \ No newline at end of file diff --git a/commands/voice/leave.js b/commands/voice/leave.js deleted file mode 100644 index ba48594..0000000 --- a/commands/voice/leave.js +++ /dev/null @@ -1,30 +0,0 @@ -const { Command } = require('discord.js-commando'); -const emoji = require('emoji-random'); - -module.exports = class LeaveVoice extends Command { - constructor(client) { - super(client, { - name: 'leave', - aliases: ['end', 'stop', 'l'], - group: 'voice', - memberName: 'leave', - description: 'Leaves the voice channel and ends playback.', - guildOnly: true, - examples: ['msb!leave', 'msb!end', 'msb!stop', 'msb!l'] - }); - } - run(msg) { - var voiceChannel = msg.member.voice.channel; - if (!voiceChannel) return msg.reply('Join a voice channel and try again. ' + emoji.random()); - - if ( - typeof msg.guild.musicData.songDispatcher == 'undefined' || - msg.guild.musicData.songDispatcher == null - ) { - return msg.reply('The soundtrack isn\'t playing right now. ' + emoji.random()); - } - msg.guild.musicData.songDispatcher.end(); - msg.guild.musicData.queue.length = 0; - return; - } -}; \ No newline at end of file diff --git a/commands/voice/loop.js b/commands/voice/loop.js deleted file mode 100644 index 507b424..0000000 --- a/commands/voice/loop.js +++ /dev/null @@ -1,32 +0,0 @@ -const { Command } = require('discord.js-commando'); -const emoji = require('emoji-random'); - -module.exports = class LoopVoice extends Command { - constructor(client) { - super(client, { - name: 'loop', - aliases: ['repeat'], - group: 'voice', - memberName: 'loop', - description: 'Loops the soundtrack.', - guildOnly: true, - examples: ['msb!loop', 'msb!repeat'] - }); - } - run(msg) { - var voiceChannel = msg.member.voice.channel; - if (!voiceChannel) return msg.reply('Join a voice channel and try again. ' + emoji.random()); - - if ( - typeof msg.guild.musicData.songDispatcher == 'undefined' || - msg.guild.musicData.songDispatcher == null - ) { - return msg.reply('The soundtrack isn\'t playing right now. ' + emoji.random()); - } - msg.channel.send( - 'Looping the soundtrack ' + emoji.random() - ); - msg.guild.musicData.queue.unshift(msg.guild.musicData.nowPlaying); - return; - } -}; \ No newline at end of file diff --git a/commands/voice/loopc.js b/commands/voice/loopc.js new file mode 100644 index 0000000..507b424 --- /dev/null +++ b/commands/voice/loopc.js @@ -0,0 +1,32 @@ +const { Command } = require('discord.js-commando'); +const emoji = require('emoji-random'); + +module.exports = class LoopVoice extends Command { + constructor(client) { + super(client, { + name: 'loop', + aliases: ['repeat'], + group: 'voice', + memberName: 'loop', + description: 'Loops the soundtrack.', + guildOnly: true, + examples: ['msb!loop', 'msb!repeat'] + }); + } + run(msg) { + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('Join a voice channel and try again. ' + emoji.random()); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('The soundtrack isn\'t playing right now. ' + emoji.random()); + } + msg.channel.send( + 'Looping the soundtrack ' + emoji.random() + ); + msg.guild.musicData.queue.unshift(msg.guild.musicData.nowPlaying); + return; + } +}; \ No newline at end of file diff --git a/commands/voice/pause.cjs b/commands/voice/pause.cjs new file mode 100644 index 0000000..20d4254 --- /dev/null +++ b/commands/voice/pause.cjs @@ -0,0 +1,30 @@ +const { Command } = require('discord.js-commando'); +const emoji = require('emoji-random'); + +module.exports = class PauseVoice extends Command { + constructor(client) { + super(client, { + name: 'pause', + group: 'voice', + memberName: 'pause', + description: 'Pauses soundtrack playback if playing.', + guildOnly: true, + examples: ['msb!pause'] + }); + } + run(msg) { + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('Join a channel and try again. ' + emoji.random()); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('The soundtrack isn\'t playing right now. ' + emoji.random()); + } + + msg.say('Soundtrack paused :pause_button:'); + + msg.guild.musicData.songDispatcher.pause(); + } +}; \ No newline at end of file diff --git a/commands/voice/pause.js b/commands/voice/pause.js deleted file mode 100644 index 20d4254..0000000 --- a/commands/voice/pause.js +++ /dev/null @@ -1,30 +0,0 @@ -const { Command } = require('discord.js-commando'); -const emoji = require('emoji-random'); - -module.exports = class PauseVoice extends Command { - constructor(client) { - super(client, { - name: 'pause', - group: 'voice', - memberName: 'pause', - description: 'Pauses soundtrack playback if playing.', - guildOnly: true, - examples: ['msb!pause'] - }); - } - run(msg) { - var voiceChannel = msg.member.voice.channel; - if (!voiceChannel) return msg.reply('Join a channel and try again. ' + emoji.random()); - - if ( - typeof msg.guild.musicData.songDispatcher == 'undefined' || - msg.guild.musicData.songDispatcher == null - ) { - return msg.reply('The soundtrack isn\'t playing right now. ' + emoji.random()); - } - - msg.say('Soundtrack paused :pause_button:'); - - msg.guild.musicData.songDispatcher.pause(); - } -}; \ No newline at end of file diff --git a/commands/voice/play.cjs b/commands/voice/play.cjs new file mode 100644 index 0000000..8797593 --- /dev/null +++ b/commands/voice/play.cjs @@ -0,0 +1,196 @@ +const ytdl = require('ytdl-core'); +const { Command } = require('discord.js-commando'); +const { MessageEmbed } = require('discord.js'); +const Youtube = require('simple-youtube-api'); +const { youtubeAPI } = require('../../config.json'); +const youtube = new Youtube('AIzaSyB9xJENORzZt-GmOGx4WsNCPgKSIxhJcds'); +const emoji = require('emoji-random'); + +module.exports = class PlayVoice extends Command { + constructor(client) { + super(client, { + name: 'play', + aliases: ['p'], + group: 'voice', + memberName: 'play', + description: 'Plays the Minecraft soundtrack.', + guildOnly: true, + clientPermissions: ['SPEAK', 'CONNECT'], + examples: ['msb!play', 'msb!p'] + }); + } + async run(msg) { + const voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.say('Join a channel and try again. ' + emoji.random()); + + const playlist = await youtube.getPlaylist('https://www.youtube.com/watch?v=05UM-i4PuOY&list=PLxOTV5xn7n1i2HcKtRBthP2loWjrBGAIY').catch(function () { + return msg.say('There was a problem getting the soundtrack. ' + emoji.random()); + }); + // remove the 10 if you removed the queue limit conditions below + const videosObj = await playlist.getVideos(24).catch(function () { + return msg.say( + 'There was a problem getting the soundtrack. ' + emoji.random() + ); + }); + for (let i = 0; i < videosObj.length; i++) { + const video = await videosObj[i].fetch(); + // this can be uncommented if you choose to limit the queue + // if (msg.guild.musicData.queue.length < 10) { + // + msg.guild.musicData.queue.push( + this.constructSongObj(video, voiceChannel) + ); + // } else { + // return msg.say( + // `I can't play the full playlist because there will be more than 10 songs in queue` + // ); + // } + } + if (msg.guild.musicData.isPlaying == false) { + msg.guild.musicData.isPlaying = true; + return this.playSong(msg.guild.musicData.queue, msg); + } else if (msg.guild.musicData.isPlaying == true) { + return msg.say( + 'Now playing the Minecraft soundtrack. ' + emoji.random() + ); + } + + var that = this; + msg.channel + .awaitMessages( + function (msg) { + return (msg.content > 0 && msg.content < 6) || msg.content === 'exit'; + }, { + max: 1, + time: 60000, + errors: ['time'] + } + ) + .then(function (response) { + const videoIndex = parseInt(response.first().content); + if (response.first().content === 'exit') return songEmbed.delete(); + youtube + .getVideoByID(videos[videoIndex - 1].id) + .then(function (video) { + // // can be uncommented if you don't want the bot to play live streams + // if (video.raw.snippet.liveBroadcastContent === 'live') { + // songEmbed.delete(); + // return msg.say("I don't support live streams!"); + // } + + // // can be uncommented if you don't want the bot to play videos longer than 1 hour + // if (video.duration.hours !== 0) { + // songEmbed.delete(); + // return msg.say('I cannot play videos longer than 1 hour'); + // } + + // // can be uncommented if you don't want to limit the queue + // if (msg.guild.musicData.queue.length > 10) { + // songEmbed.delete(); + // return msg.say( + // 'There are too many songs in the queue already, skip or wait a bit' + // ); + // } + msg.guild.musicData.queue.push( + that.constructSongObj(video, voiceChannel) + ); + if (msg.guild.musicData.isPlaying == false) { + msg.guild.musicData.isPlaying = true; + if (songEmbed) { + songEmbed.delete(); + } + that.playSong(msg.guild.musicData.queue, msg); + } else if (msg.guild.musicData.isPlaying == true) { + if (songEmbed) { + songEmbed.delete(); + } + return msg.say('Now playing the Minecraft soundtrack. ' + emoji.random()); + } + }) + .catch(function () { + if (songEmbed) { + songEmbed.delete(); + } + return msg.say( + 'An error has occured when trying to get the video ID from YouTube. ' + emoji.random() + ); + }); + }); + } + playSong(queue, msg) { + const classThis = this; // use classThis instead of 'this' because of lexical scope below + queue[0].voiceChannel + .join() + .then(function (connection) { + const dispatcher = connection + .play( + ytdl(queue[0].url, { + quality: 'highestaudio', + highWaterMark: 1024 * 1024 * 10 + }) + ) + .on('start', function () { + msg.guild.musicData.songDispatcher = dispatcher; + const volume = 100 / 100; + msg.guild.musicData.volume = volume; + dispatcher.setVolume(msg.guild.musicData.volume); + const videoEmbed = new MessageEmbed() + .setThumbnail(queue[0].thumbnail) + .setColor(0xF97DAE) + .addField('Now Playing:', queue[0].title) + .addField('Duration:', queue[0].duration); + if (queue[1]) videoEmbed.addField('Next Song:', queue[1].title); + msg.say(videoEmbed); + msg.guild.musicData.nowPlaying = queue[0]; + return queue.shift(); + }) + .on('finish', function () { + if (queue.length >= 1) { + return classThis.playSong(queue, msg); + } else { + msg.guild.musicData.isPlaying = false; + msg.guild.musicData.nowPlaying = null; + msg.guild.musicData.songDispatcher = null; + return msg.guild.me.voice.channel.leave(); + } + }) + .on('error', function (e) { + msg.say('Can\'t play soundtrack. ' + emoji.random()); + console.error(e); + msg.guild.musicData.queue.length = 0; + msg.guild.musicData.isPlaying = false; + msg.guild.musicData.nowPlaying = null; + msg.guild.musicData.songDispatcher = null; + return msg.guild.me.voice.channel.leave(); + }); + }) + .catch(function (e) { + console.error(e); + return msg.guild.me.voice.channel.leave(); + }); + } + constructSongObj(video, voiceChannel) { + let duration = this.formatDuration(video.duration); + if (duration == '00:00') duration = 'Live Stream'; + return { + url: `https://www.youtube.com/watch?v=${video.raw.id}`, + title: video.title, + duration, + thumbnail: video.thumbnails.high.url, + voiceChannel + }; + } + // prettier-ignore + formatDuration(durationObj) { + const duration = `${durationObj.hours ? (durationObj.hours + ':') : ''}${ + durationObj.minutes ? durationObj.minutes : '00' + }:${ + (durationObj.seconds < 10) + ? ('0' + durationObj.seconds) + : (durationObj.seconds + ? durationObj.seconds + : '00') + }`; + return duration; + } +}; \ No newline at end of file diff --git a/commands/voice/play.js b/commands/voice/play.js deleted file mode 100644 index 8797593..0000000 --- a/commands/voice/play.js +++ /dev/null @@ -1,196 +0,0 @@ -const ytdl = require('ytdl-core'); -const { Command } = require('discord.js-commando'); -const { MessageEmbed } = require('discord.js'); -const Youtube = require('simple-youtube-api'); -const { youtubeAPI } = require('../../config.json'); -const youtube = new Youtube('AIzaSyB9xJENORzZt-GmOGx4WsNCPgKSIxhJcds'); -const emoji = require('emoji-random'); - -module.exports = class PlayVoice extends Command { - constructor(client) { - super(client, { - name: 'play', - aliases: ['p'], - group: 'voice', - memberName: 'play', - description: 'Plays the Minecraft soundtrack.', - guildOnly: true, - clientPermissions: ['SPEAK', 'CONNECT'], - examples: ['msb!play', 'msb!p'] - }); - } - async run(msg) { - const voiceChannel = msg.member.voice.channel; - if (!voiceChannel) return msg.say('Join a channel and try again. ' + emoji.random()); - - const playlist = await youtube.getPlaylist('https://www.youtube.com/watch?v=05UM-i4PuOY&list=PLxOTV5xn7n1i2HcKtRBthP2loWjrBGAIY').catch(function () { - return msg.say('There was a problem getting the soundtrack. ' + emoji.random()); - }); - // remove the 10 if you removed the queue limit conditions below - const videosObj = await playlist.getVideos(24).catch(function () { - return msg.say( - 'There was a problem getting the soundtrack. ' + emoji.random() - ); - }); - for (let i = 0; i < videosObj.length; i++) { - const video = await videosObj[i].fetch(); - // this can be uncommented if you choose to limit the queue - // if (msg.guild.musicData.queue.length < 10) { - // - msg.guild.musicData.queue.push( - this.constructSongObj(video, voiceChannel) - ); - // } else { - // return msg.say( - // `I can't play the full playlist because there will be more than 10 songs in queue` - // ); - // } - } - if (msg.guild.musicData.isPlaying == false) { - msg.guild.musicData.isPlaying = true; - return this.playSong(msg.guild.musicData.queue, msg); - } else if (msg.guild.musicData.isPlaying == true) { - return msg.say( - 'Now playing the Minecraft soundtrack. ' + emoji.random() - ); - } - - var that = this; - msg.channel - .awaitMessages( - function (msg) { - return (msg.content > 0 && msg.content < 6) || msg.content === 'exit'; - }, { - max: 1, - time: 60000, - errors: ['time'] - } - ) - .then(function (response) { - const videoIndex = parseInt(response.first().content); - if (response.first().content === 'exit') return songEmbed.delete(); - youtube - .getVideoByID(videos[videoIndex - 1].id) - .then(function (video) { - // // can be uncommented if you don't want the bot to play live streams - // if (video.raw.snippet.liveBroadcastContent === 'live') { - // songEmbed.delete(); - // return msg.say("I don't support live streams!"); - // } - - // // can be uncommented if you don't want the bot to play videos longer than 1 hour - // if (video.duration.hours !== 0) { - // songEmbed.delete(); - // return msg.say('I cannot play videos longer than 1 hour'); - // } - - // // can be uncommented if you don't want to limit the queue - // if (msg.guild.musicData.queue.length > 10) { - // songEmbed.delete(); - // return msg.say( - // 'There are too many songs in the queue already, skip or wait a bit' - // ); - // } - msg.guild.musicData.queue.push( - that.constructSongObj(video, voiceChannel) - ); - if (msg.guild.musicData.isPlaying == false) { - msg.guild.musicData.isPlaying = true; - if (songEmbed) { - songEmbed.delete(); - } - that.playSong(msg.guild.musicData.queue, msg); - } else if (msg.guild.musicData.isPlaying == true) { - if (songEmbed) { - songEmbed.delete(); - } - return msg.say('Now playing the Minecraft soundtrack. ' + emoji.random()); - } - }) - .catch(function () { - if (songEmbed) { - songEmbed.delete(); - } - return msg.say( - 'An error has occured when trying to get the video ID from YouTube. ' + emoji.random() - ); - }); - }); - } - playSong(queue, msg) { - const classThis = this; // use classThis instead of 'this' because of lexical scope below - queue[0].voiceChannel - .join() - .then(function (connection) { - const dispatcher = connection - .play( - ytdl(queue[0].url, { - quality: 'highestaudio', - highWaterMark: 1024 * 1024 * 10 - }) - ) - .on('start', function () { - msg.guild.musicData.songDispatcher = dispatcher; - const volume = 100 / 100; - msg.guild.musicData.volume = volume; - dispatcher.setVolume(msg.guild.musicData.volume); - const videoEmbed = new MessageEmbed() - .setThumbnail(queue[0].thumbnail) - .setColor(0xF97DAE) - .addField('Now Playing:', queue[0].title) - .addField('Duration:', queue[0].duration); - if (queue[1]) videoEmbed.addField('Next Song:', queue[1].title); - msg.say(videoEmbed); - msg.guild.musicData.nowPlaying = queue[0]; - return queue.shift(); - }) - .on('finish', function () { - if (queue.length >= 1) { - return classThis.playSong(queue, msg); - } else { - msg.guild.musicData.isPlaying = false; - msg.guild.musicData.nowPlaying = null; - msg.guild.musicData.songDispatcher = null; - return msg.guild.me.voice.channel.leave(); - } - }) - .on('error', function (e) { - msg.say('Can\'t play soundtrack. ' + emoji.random()); - console.error(e); - msg.guild.musicData.queue.length = 0; - msg.guild.musicData.isPlaying = false; - msg.guild.musicData.nowPlaying = null; - msg.guild.musicData.songDispatcher = null; - return msg.guild.me.voice.channel.leave(); - }); - }) - .catch(function (e) { - console.error(e); - return msg.guild.me.voice.channel.leave(); - }); - } - constructSongObj(video, voiceChannel) { - let duration = this.formatDuration(video.duration); - if (duration == '00:00') duration = 'Live Stream'; - return { - url: `https://www.youtube.com/watch?v=${video.raw.id}`, - title: video.title, - duration, - thumbnail: video.thumbnails.high.url, - voiceChannel - }; - } - // prettier-ignore - formatDuration(durationObj) { - const duration = `${durationObj.hours ? (durationObj.hours + ':') : ''}${ - durationObj.minutes ? durationObj.minutes : '00' - }:${ - (durationObj.seconds < 10) - ? ('0' + durationObj.seconds) - : (durationObj.seconds - ? durationObj.seconds - : '00') - }`; - return duration; - } -}; \ No newline at end of file diff --git a/commands/voice/queue.js b/commands/voice/queue.js deleted file mode 100644 index ac9c236..0000000 --- a/commands/voice/queue.js +++ /dev/null @@ -1,51 +0,0 @@ -const { Command } = require('discord.js-commando'); -const { MessageEmbed } = require('discord.js'); -const emoji = require('emoji-random'); - -module.exports = class QueueVoice extends Command { - constructor(client) { - super(client, { - name: 'queue', - aliases: [ - 'q', - 'song-list', - 'next-songs', - 'songlist', - 'nextsongs', - 'nextsong', - 'next-song' - ], - group: 'voice', - memberName: 'queue', - description: 'Displays the song queue.', - guildOnly: true, - examples: [ - 'msb!queue', - 'msb!q', - 'msb!songlist', - 'msb!song-list', - 'msb!nextsong', - 'msb!next-song', - 'msb!nextsongs', - 'msb!next-songs' - ] - }); - } - run(msg) { - if (msg.guild.musicData.queue.length == 0) - return msg.say('The soundtrack is not queued. ' + emoji.random()); - const titleArray = []; - msg.guild.musicData.queue.map(obj => { - titleArray.push(obj.title); - }); - let queueEmbed = new MessageEmbed() - .setColor(0xF97DAE) - .setTitle('Soundtrack Queue ' + emoji.random()); - for (let i = 0; i < titleArray.length; i++) { - queueEmbed - .addField(`‎`, `**${i + 1}**: ` + `${titleArray[i]}`) - .setFooter(`Bot developed and administrated by sin#1337.`, this.client.users.cache.get('217348698294714370').avatarURL()); - } - return msg.say(queueEmbed); - } -}; \ No newline at end of file diff --git a/commands/voice/queuec.js b/commands/voice/queuec.js new file mode 100644 index 0000000..ac9c236 --- /dev/null +++ b/commands/voice/queuec.js @@ -0,0 +1,51 @@ +const { Command } = require('discord.js-commando'); +const { MessageEmbed } = require('discord.js'); +const emoji = require('emoji-random'); + +module.exports = class QueueVoice extends Command { + constructor(client) { + super(client, { + name: 'queue', + aliases: [ + 'q', + 'song-list', + 'next-songs', + 'songlist', + 'nextsongs', + 'nextsong', + 'next-song' + ], + group: 'voice', + memberName: 'queue', + description: 'Displays the song queue.', + guildOnly: true, + examples: [ + 'msb!queue', + 'msb!q', + 'msb!songlist', + 'msb!song-list', + 'msb!nextsong', + 'msb!next-song', + 'msb!nextsongs', + 'msb!next-songs' + ] + }); + } + run(msg) { + if (msg.guild.musicData.queue.length == 0) + return msg.say('The soundtrack is not queued. ' + emoji.random()); + const titleArray = []; + msg.guild.musicData.queue.map(obj => { + titleArray.push(obj.title); + }); + let queueEmbed = new MessageEmbed() + .setColor(0xF97DAE) + .setTitle('Soundtrack Queue ' + emoji.random()); + for (let i = 0; i < titleArray.length; i++) { + queueEmbed + .addField(`‎`, `**${i + 1}**: ` + `${titleArray[i]}`) + .setFooter(`Bot developed and administrated by sin#1337.`, this.client.users.cache.get('217348698294714370').avatarURL()); + } + return msg.say(queueEmbed); + } +}; \ No newline at end of file diff --git a/commands/voice/remove.cjs b/commands/voice/remove.cjs new file mode 100644 index 0000000..edcb948 --- /dev/null +++ b/commands/voice/remove.cjs @@ -0,0 +1,39 @@ +const { Command } = require('discord.js-commando'); +const emoji = require('emoji-random'); + +module.exports = class RemoveVoice extends Command { + constructor(client) { + super(client, { + name: 'remove', + group: 'voice', + memberName: 'remove', + description: 'Remove a certain song from the soundtrack queue.', + guildOnly: true, + args: [ + { + key: 'songNumber', + prompt: 'What song would you like the remove?', + type: 'integer' + } + ], + examples: ['msb!remove 2'] + }); + } + run(msg, { songNumber }) { + if (songNumber < 1 && songNumber >= msg.guild.musicData.queue.length) { + return msg.reply('Please enter a valid song number. ' + emoji.random()); + } + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('Join a voice channel and try again. ' + emoji.random()); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('The soundtrack isn\'t playing right now. ' + emoji.random()); + } + + msg.guild.musicData.queue.splice(songNumber - 1, 1); + return msg.say(`Removed song **#${songNumber}** from soundtrack queue. ` + emoji.random()); + } +}; \ No newline at end of file diff --git a/commands/voice/remove.js b/commands/voice/remove.js deleted file mode 100644 index edcb948..0000000 --- a/commands/voice/remove.js +++ /dev/null @@ -1,39 +0,0 @@ -const { Command } = require('discord.js-commando'); -const emoji = require('emoji-random'); - -module.exports = class RemoveVoice extends Command { - constructor(client) { - super(client, { - name: 'remove', - group: 'voice', - memberName: 'remove', - description: 'Remove a certain song from the soundtrack queue.', - guildOnly: true, - args: [ - { - key: 'songNumber', - prompt: 'What song would you like the remove?', - type: 'integer' - } - ], - examples: ['msb!remove 2'] - }); - } - run(msg, { songNumber }) { - if (songNumber < 1 && songNumber >= msg.guild.musicData.queue.length) { - return msg.reply('Please enter a valid song number. ' + emoji.random()); - } - var voiceChannel = msg.member.voice.channel; - if (!voiceChannel) return msg.reply('Join a voice channel and try again. ' + emoji.random()); - - if ( - typeof msg.guild.musicData.songDispatcher == 'undefined' || - msg.guild.musicData.songDispatcher == null - ) { - return msg.reply('The soundtrack isn\'t playing right now. ' + emoji.random()); - } - - msg.guild.musicData.queue.splice(songNumber - 1, 1); - return msg.say(`Removed song **#${songNumber}** from soundtrack queue. ` + emoji.random()); - } -}; \ No newline at end of file diff --git a/commands/voice/resume.cjs b/commands/voice/resume.cjs new file mode 100644 index 0000000..a3f32ce --- /dev/null +++ b/commands/voice/resume.cjs @@ -0,0 +1,31 @@ +const { Command } = require('discord.js-commando'); +const emoji = require('emoji-random'); + +module.exports = class ResumeVoice extends Command { + constructor(client) { + super(client, { + name: 'resume', + aliases: ['unpause'], + group: 'voice', + memberName: 'resume', + description: 'Resumes the soundtrack if paused.', + guildOnly: true, + examples: ['msb!resume', 'msb!unpause'] + }); + } + run(msg) { + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('Join a channel and try again. ' + emoji.random()); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('The soundtrack isn\'t playing right now. ' + emoji.random()); + } + + msg.say('Soundtrack resumed :play_pause:'); + + msg.guild.musicData.songDispatcher.resume(); + } +}; \ No newline at end of file diff --git a/commands/voice/resume.js b/commands/voice/resume.js deleted file mode 100644 index a3f32ce..0000000 --- a/commands/voice/resume.js +++ /dev/null @@ -1,31 +0,0 @@ -const { Command } = require('discord.js-commando'); -const emoji = require('emoji-random'); - -module.exports = class ResumeVoice extends Command { - constructor(client) { - super(client, { - name: 'resume', - aliases: ['unpause'], - group: 'voice', - memberName: 'resume', - description: 'Resumes the soundtrack if paused.', - guildOnly: true, - examples: ['msb!resume', 'msb!unpause'] - }); - } - run(msg) { - var voiceChannel = msg.member.voice.channel; - if (!voiceChannel) return msg.reply('Join a channel and try again. ' + emoji.random()); - - if ( - typeof msg.guild.musicData.songDispatcher == 'undefined' || - msg.guild.musicData.songDispatcher == null - ) { - return msg.reply('The soundtrack isn\'t playing right now. ' + emoji.random()); - } - - msg.say('Soundtrack resumed :play_pause:'); - - msg.guild.musicData.songDispatcher.resume(); - } -}; \ No newline at end of file diff --git a/commands/voice/shuffle.cjs b/commands/voice/shuffle.cjs new file mode 100644 index 0000000..a6251ca --- /dev/null +++ b/commands/voice/shuffle.cjs @@ -0,0 +1,52 @@ +const { Command } = require('discord.js-commando'); +const { MessageEmbed } = require('discord.js'); +const emoji = require('emoji-random'); + +module.exports = class ShuffleVoice extends Command { + constructor(client) { + super(client, { + name: 'shuffle', + group: 'voice', + memberName: 'shuffle', + description: 'Shuffles the soundtrack queue.', + guildOnly: true, + examples: ['msb!shuffle'] + }); + } + run(msg) { + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('Join a channel and try again. ' + emoji.random()); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('The soundtrack isn\'t playing right now. ' + emoji.random()); + } + + if (msg.guild.musicData.queue.length < 1) + return msg.say('This is the only song in the soundtrack queue. ' + emoji.random()); + + shuffleQueue(msg.guild.musicData.queue); + + const titleArray = []; + msg.guild.musicData.queue.map(obj => { + titleArray.push(obj.title); + }); + var queueEmbed = new MessageEmbed() + .setColor(0xF97DAE) + .setTitle('New Soundtrack Queue ' + emoji.random()) + .setFooter(`Bot developed and administrated by sin#1337.`, this.client.users.cache.get('217348698294714370').avatarURL()); + for (let i = 0; i < titleArray.length; i++) { + queueEmbed.addField(`${i + 1}:`, `${titleArray[i]}`); + } + return msg.say(queueEmbed); + } +}; + +function shuffleQueue(queue) { + for (let i = queue.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [queue[i], queue[j]] = [queue[j], queue[i]]; + } +} \ No newline at end of file diff --git a/commands/voice/shuffle.js b/commands/voice/shuffle.js deleted file mode 100644 index a6251ca..0000000 --- a/commands/voice/shuffle.js +++ /dev/null @@ -1,52 +0,0 @@ -const { Command } = require('discord.js-commando'); -const { MessageEmbed } = require('discord.js'); -const emoji = require('emoji-random'); - -module.exports = class ShuffleVoice extends Command { - constructor(client) { - super(client, { - name: 'shuffle', - group: 'voice', - memberName: 'shuffle', - description: 'Shuffles the soundtrack queue.', - guildOnly: true, - examples: ['msb!shuffle'] - }); - } - run(msg) { - var voiceChannel = msg.member.voice.channel; - if (!voiceChannel) return msg.reply('Join a channel and try again. ' + emoji.random()); - - if ( - typeof msg.guild.musicData.songDispatcher == 'undefined' || - msg.guild.musicData.songDispatcher == null - ) { - return msg.reply('The soundtrack isn\'t playing right now. ' + emoji.random()); - } - - if (msg.guild.musicData.queue.length < 1) - return msg.say('This is the only song in the soundtrack queue. ' + emoji.random()); - - shuffleQueue(msg.guild.musicData.queue); - - const titleArray = []; - msg.guild.musicData.queue.map(obj => { - titleArray.push(obj.title); - }); - var queueEmbed = new MessageEmbed() - .setColor(0xF97DAE) - .setTitle('New Soundtrack Queue ' + emoji.random()) - .setFooter(`Bot developed and administrated by sin#1337.`, this.client.users.cache.get('217348698294714370').avatarURL()); - for (let i = 0; i < titleArray.length; i++) { - queueEmbed.addField(`${i + 1}:`, `${titleArray[i]}`); - } - return msg.say(queueEmbed); - } -}; - -function shuffleQueue(queue) { - for (let i = queue.length - 1; i > 0; i--) { - const j = Math.floor(Math.random() * (i + 1)); - [queue[i], queue[j]] = [queue[j], queue[i]]; - } -} \ No newline at end of file diff --git a/commands/voice/skip.cjs b/commands/voice/skip.cjs new file mode 100644 index 0000000..9cac14c --- /dev/null +++ b/commands/voice/skip.cjs @@ -0,0 +1,27 @@ +const { Command } = require('discord.js-commando'); +const emoji = require('emoji-random'); + +module.exports = class SkipVoice extends Command { + constructor(client) { + super(client, { + name: 'skip', + group: 'voice', + memberName: 'skip', + description: 'Skips one song ahead in the soundtrack queue.', + guildOnly: true, + examples: ['msb!skip'] + }); + } + run(msg) { + const voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('Join a channel and try again. ' + emoji.random()); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('The soundtrack isn\'t playing right now. ' + emoji.random()); + } + msg.guild.musicData.songDispatcher.end(); + } +}; \ No newline at end of file diff --git a/commands/voice/skip.js b/commands/voice/skip.js deleted file mode 100644 index 9cac14c..0000000 --- a/commands/voice/skip.js +++ /dev/null @@ -1,27 +0,0 @@ -const { Command } = require('discord.js-commando'); -const emoji = require('emoji-random'); - -module.exports = class SkipVoice extends Command { - constructor(client) { - super(client, { - name: 'skip', - group: 'voice', - memberName: 'skip', - description: 'Skips one song ahead in the soundtrack queue.', - guildOnly: true, - examples: ['msb!skip'] - }); - } - run(msg) { - const voiceChannel = msg.member.voice.channel; - if (!voiceChannel) return msg.reply('Join a channel and try again. ' + emoji.random()); - - if ( - typeof msg.guild.musicData.songDispatcher == 'undefined' || - msg.guild.musicData.songDispatcher == null - ) { - return msg.reply('The soundtrack isn\'t playing right now. ' + emoji.random()); - } - msg.guild.musicData.songDispatcher.end(); - } -}; \ No newline at end of file diff --git a/commands/voice/skipall.js b/commands/voice/skipall.js deleted file mode 100644 index 32800b1..0000000 --- a/commands/voice/skipall.js +++ /dev/null @@ -1,42 +0,0 @@ -const { Command } = require('discord.js-commando'); -const emoji = require('emoji-random'); - -module.exports = class SkipAllVoice extends Command { - constructor(client) { - super(client, { - name: 'skipall', - aliases: [ - 'endqueue', - 'endq', - 'skipqueue', - 'skipq' - ], - group: 'voice', - memberName: 'skipall', - description: 'Skips all the songs in the soundtrack queue.', - guildOnly: true, - examples: [ - 'msb!endqueue', - 'msb!endq', - 'msb!skipqueue', - 'msb!skipq' - ] - }); - } - run(msg) { - var voiceChannel = msg.member.voice.channel; - if (!voiceChannel) return msg.reply('Join a channel and try again. ' + emoji.random()); - - if ( - typeof msg.guild.musicData.songDispatcher == 'undefined' || - msg.guild.musicData.songDispatcher == null - ) { - return msg.reply('The soundtrack isn\'t playing right now. ' + emoji.random()); - } - if (!msg.guild.musicData.queue) - return msg.say('This is the only song in the soundtrack queue. ' + emoji.random()); - msg.guild.musicData.songDispatcher.end(); - msg.guild.musicData.queue.length = 0; // clear queue - return; - } -}; \ No newline at end of file diff --git a/commands/voice/skipallc.js b/commands/voice/skipallc.js new file mode 100644 index 0000000..32800b1 --- /dev/null +++ b/commands/voice/skipallc.js @@ -0,0 +1,42 @@ +const { Command } = require('discord.js-commando'); +const emoji = require('emoji-random'); + +module.exports = class SkipAllVoice extends Command { + constructor(client) { + super(client, { + name: 'skipall', + aliases: [ + 'endqueue', + 'endq', + 'skipqueue', + 'skipq' + ], + group: 'voice', + memberName: 'skipall', + description: 'Skips all the songs in the soundtrack queue.', + guildOnly: true, + examples: [ + 'msb!endqueue', + 'msb!endq', + 'msb!skipqueue', + 'msb!skipq' + ] + }); + } + run(msg) { + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('Join a channel and try again. ' + emoji.random()); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('The soundtrack isn\'t playing right now. ' + emoji.random()); + } + if (!msg.guild.musicData.queue) + return msg.say('This is the only song in the soundtrack queue. ' + emoji.random()); + msg.guild.musicData.songDispatcher.end(); + msg.guild.musicData.queue.length = 0; // clear queue + return; + } +}; \ No newline at end of file diff --git a/commands/voice/skipto.cjs b/commands/voice/skipto.cjs new file mode 100644 index 0000000..aa27add --- /dev/null +++ b/commands/voice/skipto.cjs @@ -0,0 +1,41 @@ +const { Command } = require('discord.js-commando'); +const emoji = require('emoji-random'); + +module.exports = class SkipToVoice extends Command { + constructor(client) { + super(client, { + name: 'skipto', + group: 'voice', + memberName: 'skipto', + description: 'Skip to a certain song in the soundtrack queue.', + guildOnly: true, + args: [{ + key: 'songNumber', + prompt: 'What song would you like the skip to?', + type: 'integer' + }], + examples: ['msb!skipto 5'] + }); + } + run(msg, { songNumber }) { + if (songNumber < 1 && songNumber >= msg.guild.musicData.queue.length) { + return msg.reply('Please enter a valid song number' + emoji.random()); + } + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('Join a channel and try again. ' + emoji.random()); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('The soundtrack isn\'t playing right now. ' + emoji.random()); + } + + if (msg.guild.musicData.queue < 1) + return msg.reply('This is the only song in the soundtrack queue. ' + emoji.random()); + + msg.guild.musicData.queue.splice(0, songNumber - 1); + msg.guild.musicData.songDispatcher.end(); + return; + } +}; \ No newline at end of file diff --git a/commands/voice/skipto.js b/commands/voice/skipto.js deleted file mode 100644 index aa27add..0000000 --- a/commands/voice/skipto.js +++ /dev/null @@ -1,41 +0,0 @@ -const { Command } = require('discord.js-commando'); -const emoji = require('emoji-random'); - -module.exports = class SkipToVoice extends Command { - constructor(client) { - super(client, { - name: 'skipto', - group: 'voice', - memberName: 'skipto', - description: 'Skip to a certain song in the soundtrack queue.', - guildOnly: true, - args: [{ - key: 'songNumber', - prompt: 'What song would you like the skip to?', - type: 'integer' - }], - examples: ['msb!skipto 5'] - }); - } - run(msg, { songNumber }) { - if (songNumber < 1 && songNumber >= msg.guild.musicData.queue.length) { - return msg.reply('Please enter a valid song number' + emoji.random()); - } - var voiceChannel = msg.member.voice.channel; - if (!voiceChannel) return msg.reply('Join a channel and try again. ' + emoji.random()); - - if ( - typeof msg.guild.musicData.songDispatcher == 'undefined' || - msg.guild.musicData.songDispatcher == null - ) { - return msg.reply('The soundtrack isn\'t playing right now. ' + emoji.random()); - } - - if (msg.guild.musicData.queue < 1) - return msg.reply('This is the only song in the soundtrack queue. ' + emoji.random()); - - msg.guild.musicData.queue.splice(0, songNumber - 1); - msg.guild.musicData.songDispatcher.end(); - return; - } -}; \ No newline at end of file diff --git a/commands/voice/volume.cjs b/commands/voice/volume.cjs new file mode 100644 index 0000000..0a59a68 --- /dev/null +++ b/commands/voice/volume.cjs @@ -0,0 +1,44 @@ +const { Command } = require('discord.js-commando'); +const emoji = require('emoji-random'); + +module.exports = class VolumeVoice extends Command { + constructor(client) { + super(client, { + name: 'volume', + aliases: ['vol', 'v'], + group: 'voice', + memberName: 'volume', + description: 'Changes the volume of playback.', + guildOnly: true, + args: [ + { + key: 'wantedVol', + prompt: 'What would you like the volume to be? (1 - 200)', + type: 'integer', + validate: wantedVol => wantedVol >= 1 && wantedVol <= 200 + } + ], + examples: [ + 'msb!volume 20', + 'msb!vol 50', + 'msb!v 70' + ] + }); + } + run(msg, { wantedVol }) { + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('Join a channel and try again. ' + emoji.random()); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('The soundtrack isn\'t playing right now. ' + emoji.random()); + } + + const volume = wantedVol / 100; + msg.guild.musicData.volume = volume; + msg.guild.musicData.songDispatcher.setVolume(volume); + msg.reply(`Volume is now: **${wantedVol}%** ` + emoji.random()); + } +}; \ No newline at end of file diff --git a/commands/voice/volume.js b/commands/voice/volume.js deleted file mode 100644 index 0a59a68..0000000 --- a/commands/voice/volume.js +++ /dev/null @@ -1,44 +0,0 @@ -const { Command } = require('discord.js-commando'); -const emoji = require('emoji-random'); - -module.exports = class VolumeVoice extends Command { - constructor(client) { - super(client, { - name: 'volume', - aliases: ['vol', 'v'], - group: 'voice', - memberName: 'volume', - description: 'Changes the volume of playback.', - guildOnly: true, - args: [ - { - key: 'wantedVol', - prompt: 'What would you like the volume to be? (1 - 200)', - type: 'integer', - validate: wantedVol => wantedVol >= 1 && wantedVol <= 200 - } - ], - examples: [ - 'msb!volume 20', - 'msb!vol 50', - 'msb!v 70' - ] - }); - } - run(msg, { wantedVol }) { - var voiceChannel = msg.member.voice.channel; - if (!voiceChannel) return msg.reply('Join a channel and try again. ' + emoji.random()); - - if ( - typeof msg.guild.musicData.songDispatcher == 'undefined' || - msg.guild.musicData.songDispatcher == null - ) { - return msg.reply('The soundtrack isn\'t playing right now. ' + emoji.random()); - } - - const volume = wantedVol / 100; - msg.guild.musicData.volume = volume; - msg.guild.musicData.songDispatcher.setVolume(volume); - msg.reply(`Volume is now: **${wantedVol}%** ` + emoji.random()); - } -}; \ No newline at end of file -- cgit v1.2.3