diff options
Diffstat (limited to 'commands/voice')
| -rw-r--r-- | commands/voice/abee.js | 32 | ||||
| -rw-r--r-- | commands/voice/fart.js | 73 | ||||
| -rw-r--r-- | commands/voice/itemshop.js | 36 | ||||
| -rw-r--r-- | commands/voice/join.js | 28 | ||||
| -rw-r--r-- | commands/voice/leave.js | 30 | ||||
| -rw-r--r-- | commands/voice/loop.js | 29 | ||||
| -rw-r--r-- | commands/voice/pause.js | 28 | ||||
| -rw-r--r-- | commands/voice/play.js | 286 | ||||
| -rw-r--r-- | commands/voice/psycho.js | 31 | ||||
| -rw-r--r-- | commands/voice/queue.js | 29 | ||||
| -rw-r--r-- | commands/voice/remove.js | 38 | ||||
| -rw-r--r-- | commands/voice/resume.js | 28 | ||||
| -rw-r--r-- | commands/voice/shuffle.js | 49 | ||||
| -rw-r--r-- | commands/voice/skip.js | 25 | ||||
| -rw-r--r-- | commands/voice/skipall.js | 29 | ||||
| -rw-r--r-- | commands/voice/skipto.js | 39 | ||||
| -rw-r--r-- | commands/voice/squeak.js | 27 | ||||
| -rw-r--r-- | commands/voice/uhhhh.js | 28 | ||||
| -rw-r--r-- | commands/voice/volume.js | 38 | ||||
| -rw-r--r-- | commands/voice/wahoo.js | 28 |
20 files changed, 931 insertions, 0 deletions
diff --git a/commands/voice/abee.js b/commands/voice/abee.js new file mode 100644 index 0000000..80f9df9 --- /dev/null +++ b/commands/voice/abee.js @@ -0,0 +1,32 @@ +const ytdl = require('ytdl-core'); +const { Command } = require('discord.js-commando'); + +module.exports = class ABeeVoice extends Command { + constructor(client) { + super(client, { + name: 'abee', + aliases: ['a-bee'], + group: 'voice', + memberName: 'abee', + description: 'a bee :D 🐝', + guildOnly: true + }); + } + async run(msg) { + if (msg.member.voice.channel && !msg.guild.voice) { + const connection = await msg.member.voice.channel.join(); + const stream = ytdl('https://www.youtube.com/watch?v=lvdnhWhQBdo', { + filter: 'audioonly' + }); + const dispatcher = connection.play(stream); + + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (msg.guild.voice) { + msg.reply('i\'m already playing that lol'); + } else { + msg.reply('you need to join a voice channel first silly'); + } + } +};
\ No newline at end of file diff --git a/commands/voice/fart.js b/commands/voice/fart.js new file mode 100644 index 0000000..f5b1dfd --- /dev/null +++ b/commands/voice/fart.js @@ -0,0 +1,73 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class FartVoice extends Command { + constructor(client) { + super(client, { + name: 'fart', + group: 'voice', + memberName: 'fart', + description: 'gives you a random fart', + guildOnly: true + }); + } + async run(msg) { + if (msg.member.voice.channel && !msg.guild.voice) { + const connection = await msg.member.voice.channel.join(); + var fartNum = Math.floor((Math.random() * 8) + 1); + + if (fartNum == 1) { + msg.reply('you got fart 1, courtesy of Sin'); + const dispatcher = connection.play('./assets/audio/farts/1.mp3'); + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (fartNum == 2) { + msg.reply('you got fart 2, courtesy of Sin'); + const dispatcher = connection.play('./assets/audio/farts/2.mp3'); + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (fartNum == 3) { + msg.reply('you got fart 3, courtesy of Sin'); + const dispatcher = connection.play('./assets/audio/farts/3.mp3'); + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (fartNum == 4) { + msg.reply('you got fart 4, courtesy of Sin'); + const dispatcher = connection.play('./assets/audio/farts/4.mp3'); + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (fartNum == 5) { + msg.reply('you got fart 5, courtesy of Sin'); + const dispatcher = connection.play('./assets/audio/farts/5.mp3'); + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (fartNum == 6) { + msg.reply('you got fart 6, courtesy of nick'); + const dispatcher = connection.play('./assets/audio/farts/6.mp3'); + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (fartNum == 7) { + msg.reply('you got fart 7, courtesy of nick'); + const dispatcher = connection.play('./assets/audio/farts/7.mp3'); + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (fartNum == 8) { + msg.reply('you got fart 8, courtesy of nick'); + const dispatcher = connection.play('./assets/audio/farts/8.mp3'); + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } + } else if (msg.guild.voice) { + msg.reply('i\'m already playing that lol'); + } else { + msg.reply('you need to join a voice channel first silly'); + } + } +};
\ No newline at end of file diff --git a/commands/voice/itemshop.js b/commands/voice/itemshop.js new file mode 100644 index 0000000..6550604 --- /dev/null +++ b/commands/voice/itemshop.js @@ -0,0 +1,36 @@ +const ytdl = require('ytdl-core'); +const { Command } = require('discord.js-commando'); + +module.exports = class ItemShopVoice extends Command { + constructor(client) { + super(client, { + name: 'itemstop', + aliases: ['is'], + group: 'voice', + memberName: 'itemstop', + description: 'use code frozen in the itemshop', + guildOnly: true + }); + } + async run(msg) { + if (msg.member.voice.channel && !msg.guild.voice) { + const connection = await msg.member.voice.channel.join(); + const stream = ytdl('https://www.youtube.com/watch?v=pBiI1hTwU7E', { + filter: 'audioonly' + }); + const dispatcher = connection.play(stream); + msg.reply('USE CODE FROZEN IN THE FORTNITE ITEM SHOP!!!'); + + function timeCheck() { + if (dispatcher.streamTime >= 6000) { + connection.disconnect(); + } + } + setInterval(timeCheck, 500); + } else if (msg.guild.voice) { + msg.reply('i\'m already playing that lol'); + } else { + msg.reply('you need to join a voice channel first silly'); + } + } +};
\ No newline at end of file diff --git a/commands/voice/join.js b/commands/voice/join.js new file mode 100644 index 0000000..0445390 --- /dev/null +++ b/commands/voice/join.js @@ -0,0 +1,28 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class JoinVoice extends Command { + constructor(client) { + super(client, { + name: 'join', + aliases: ['j'], + group: 'voice', + memberName: 'join', + description: 'joins your voice channel', + throttling: { + usages: 2, + duration: 5 + }, + guildOnly: true + }); + } + run(msg) { + if (!msg.guild.voice && msg.member.voice.channel) { + msg.member.voice.channel.join(); + msg.reply('succesfully joined voice channel'); + } else if (msg.guild.voice) { + msg.reply('i\'m already in voice channel'); + } else if (!msg.member.voice.channel) { + msg.reply('you\'re not in a voice channel'); + } + } +};
\ No newline at end of file diff --git a/commands/voice/leave.js b/commands/voice/leave.js new file mode 100644 index 0000000..13009eb --- /dev/null +++ b/commands/voice/leave.js @@ -0,0 +1,30 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class LeaveVoice extends Command { + constructor(client) { + super(client, { + name: 'leave', + aliases: ['end', 'stop'], + group: 'voice', + memberName: 'leave', + description: 'stops voice channel if any playing', + guildOnly: true + }); + } + run(msg) { + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('join a channel and try again'); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('there isn\'t a song playing right now lol'); + } + if (!msg.guild.musicData.queue) + return msg.say('there are no songs in queue rn lol'); + 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 new file mode 100644 index 0000000..64c586e --- /dev/null +++ b/commands/voice/loop.js @@ -0,0 +1,29 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class LoopVoice extends Command { + constructor(client) { + super(client, { + name: 'loop', + group: 'voice', + memberName: 'loop', + description: 'loops currently playing audio', + guildOnly: true + }); + } + run(msg) { + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('join a channel and try again'); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('there isn\'t a song playing right now lol'); + } + msg.channel.send( + `${msg.guild.musicData.nowPlaying.title} added to queue` + ); + msg.guild.musicData.queue.unshift(msg.guild.musicData.nowPlaying); + return; + } +};
\ No newline at end of file diff --git a/commands/voice/pause.js b/commands/voice/pause.js new file mode 100644 index 0000000..2d6630e --- /dev/null +++ b/commands/voice/pause.js @@ -0,0 +1,28 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class PauseVoice extends Command { + constructor(client) { + super(client, { + name: 'pause', + group: 'voice', + memberName: 'pause', + description: 'pauses music if there is any playing', + guildOnly: true + }); + } + run(msg) { + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('join a channel and try again'); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('there isn\'t a song playing right now lol'); + } + + msg.say('song paused :pause_button:'); + + msg.guild.musicData.songDispatcher.pause(); + } +};
\ No newline at end of file diff --git a/commands/voice/play.js b/commands/voice/play.js new file mode 100644 index 0000000..f4e9779 --- /dev/null +++ b/commands/voice/play.js @@ -0,0 +1,286 @@ +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'); // AIzaSyB9xJENORzZt-GmOGx4WsNCPgKSIxhJcds + +module.exports = class PlayVoice extends Command { + constructor(client) { + super(client, { + name: 'play', + aliases: ['p'], + group: 'voice', + memberName: 'play', + description: 'play a youtube video', + guildOnly: true, + clientPermissions: ['SPEAK', 'CONNECT'], + args: [ + { + key: 'query', + prompt: 'what song u wanna hear?', + type: 'string', + validate: function (query) { + return query.length > 0 && query.length < 200; + } + } + ] + }); + } + async run(msg, { + query + }) { + const voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.say('join a channel and try again'); + + if ( + // if the user entered yt playlist url + query.match( + /^(?!.*\?.*\bv=)https:\/\/www\.youtube\.com\/.*\?.*\blist=.*$/ + ) + ) { + const playlist = await youtube.getPlaylist(query).catch(function () { + return msg.say('playlist is either private or it does not exist'); + }); + // remove the 10 if you removed the queue limit conditions below + const videosObj = await playlist.getVideos(10).catch(function () { + return msg.say( + 'there was a problem getting one of the videos in the playlist' + ); + }); + 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( + `playlist - :musical_note: ${playlist.title} :musical_note: has been added to queue` + ); + } + } + + // This if statement checks if the user entered a youtube url, it can be any kind of youtube url + if (query.match(/^(http(s)?:\/\/)?((w){3}.)?youtu(be|.be)?(\.com)?\/.+/)) { + query = query + .replace(/(>|<)/gi, '') + .split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/); + const id = query[2].split(/[^0-9a-z_\-]/i)[0]; + const video = await youtube.getVideoByID(id).catch(function () { + return msg.say( + 'there was a problem getting the video you provided' + ); + }); + // // can be uncommented if you don't want the bot to play live streams + // if (video.raw.snippet.liveBroadcastContent === 'live') { + // 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) { + // return msg.say('I cannot play videos longer than 1 hour'); + // } + // // can be uncommented if you want to limit the queue + // if (msg.guild.musicData.queue.length > 10) { + // return msg.say( + // 'There are too many songs in the queue already, skip or wait a bit' + // ); + // } + msg.guild.musicData.queue.push( + this.constructSongObj(video, voiceChannel) + ); + if ( + msg.guild.musicData.isPlaying == false || + typeof msg.guild.musicData.isPlaying == 'undefined' + ) { + msg.guild.musicData.isPlaying = true; + return this.playSong(msg.guild.musicData.queue, msg); + } else if (msg.guild.musicData.isPlaying == true) { + return msg.say(`${video.title} added to queue`); + } + } + + // if user provided a song/video name + const videos = await youtube.searchVideos(query, 5).catch(function () { + return msg.say( + 'there was a problem searching the video you requested :(' + ); + }); + if (videos.length < 5) { + return msg.say( + `i had some trouble finding what you were looking for, please try again or be more specific lol` + ); + } + const vidNameArr = []; + for (let i = 0; i < videos.length; i++) { + vidNameArr.push(`${i + 1}: ${videos[i].title}`); + } + vidNameArr.push('exit'); + const embed = new MessageEmbed() + .setColor(0xF97DAE) + .setTitle('choose a song by msging a number between 1 and 5') + .addField('song #1', vidNameArr[0]) + .addField('song #2', vidNameArr[1]) + .addField('song #3', vidNameArr[2]) + .addField('song #4', vidNameArr[3]) + .addField('song #5', vidNameArr[4]) + .addField('exit selection', 'exit'); + var songEmbed = await msg.channel.send({ + embed + }); + 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(`${video.title} added to queue`); + } + }) + .catch(function () { + if (songEmbed) { + songEmbed.delete(); + } + return msg.say( + 'an error has occured when trying to get the video id from youtube' + ); + }); + }) + .catch(function () { + if (songEmbed) { + songEmbed.delete(); + } + return msg.say( + 'try again and enter a number between 1 and 5 or exit' + ); + }); + } + 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; + 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 song'); + 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/psycho.js b/commands/voice/psycho.js new file mode 100644 index 0000000..35ae025 --- /dev/null +++ b/commands/voice/psycho.js @@ -0,0 +1,31 @@ +const ytdl = require('ytdl-core'); +const { Command } = require('discord.js-commando'); + +module.exports = class PsychoVoice extends Command { + constructor(client) { + super(client, { + name: 'psycho', + group: 'voice', + memberName: 'psycho', + description: 'plays the psycho by mase', + guildOnly: true + }); + } + async run(msg) { + if (msg.member.voice.channel && !msg.guild.voice) { + const connection = await msg.member.voice.channel.join(); + const stream = ytdl('https://www.youtube.com/watch?v=fnd_HSmAODs', { + filter: 'audioonly' + }); + const dispatcher = connection.play(stream); + + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (msg.guild.voice) { + msg.reply('i\'m already playing that lol'); + } else { + msg.reply('you need to join a voice channel first silly'); + } + } +};
\ No newline at end of file diff --git a/commands/voice/queue.js b/commands/voice/queue.js new file mode 100644 index 0000000..9d9d3f3 --- /dev/null +++ b/commands/voice/queue.js @@ -0,0 +1,29 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class QueueVoice extends Command { + constructor(client) { + super(client, { + name: 'queue', + aliases: ['q', 'song-list', 'next-songs'], + group: 'voice', + memberName: 'queue', + description: 'display song queue', + guildOnly: true + }); + } + run(msg) { + if (msg.guild.musicData.queue.length == 0) + return msg.say('there are no songs in the queue lol'); + const titleArray = []; + msg.guild.musicData.queue.map(obj => { + titleArray.push(obj.title); + }); + var queueEmbed = new MessageEmbed() + .setColor(0xF97DAE) + .setTitle('Music Queue'); + for (let i = 0; i < titleArray.length; i++) { + queueEmbed.addField(`${i + 1}:`, `${titleArray[i]}`); + } + return msg.say(queueEmbed); + } +};
\ No newline at end of file diff --git a/commands/voice/remove.js b/commands/voice/remove.js new file mode 100644 index 0000000..848721a --- /dev/null +++ b/commands/voice/remove.js @@ -0,0 +1,38 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class RemoveVoice extends Command { + constructor(client) { + super(client, { + name: 'remove', + aliases: ['rem'], + group: 'voice', + memberName: 'remove', + description: 'removes a song from the queue', + guildOnly: true, + args: [ + { + key: 'songNumber', + prompt: 'what song u want to remove from q?', + type: 'integer' + } + ] + }); + } + run(msg, { songNumber }) { + if (songNumber < 1 && songNumber >= msg.guild.musicData.queue.length) { + return msg.reply('enter a valid song number lol'); + } + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('join a channel and try again lol'); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('no songs playing right now lol'); + } + + msg.guild.musicData.queue.splice(songNumber - 1, 1); + return msg.say(`removed song #${songNumber} from queue`); + } +};
\ No newline at end of file diff --git a/commands/voice/resume.js b/commands/voice/resume.js new file mode 100644 index 0000000..62124e3 --- /dev/null +++ b/commands/voice/resume.js @@ -0,0 +1,28 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class ResumeVoice extends Command { + constructor(client) { + super(client, { + name: 'resumes', + group: 'voice', + memberName: 'resumes', + description: 'resumes music if there is any stopped', + guildOnly: true + }); + } + run(msg) { + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('join a channel and try again'); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('there isn\'t a song playing right now lol'); + } + + msg.say('song resumed :play_pause:'); + + msg.guild.musicData.songDispatcher.resume(); + } +};
\ No newline at end of file diff --git a/commands/voice/shuffle.js b/commands/voice/shuffle.js new file mode 100644 index 0000000..158fa5c --- /dev/null +++ b/commands/voice/shuffle.js @@ -0,0 +1,49 @@ +const { Command } = require('discord.js-commando'); +const { MessageEmbed } = require('discord.js'); + +module.exports = class ShuffleVoice extends Command { + constructor(client) { + super(client, { + name: 'shuffle', + group: 'voice', + memberName: 'shuffle', + description: 'shuffle the queue', + guildOnly: true + }); + } + run(msg) { + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('join channel and try again k'); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('there is no song playing right now'); + } + + if (msg.guild.musicData.queue.length < 1) + return msg.say('There are no songs in queue'); + + 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 music q'); + 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.js b/commands/voice/skip.js new file mode 100644 index 0000000..c819a67 --- /dev/null +++ b/commands/voice/skip.js @@ -0,0 +1,25 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class SkipVoice extends Command { + constructor(client) { + super(client, { + name: 'skip', + group: 'voice', + memberName: 'skip', + description: 'skip 1 song in the queue', + guildOnly: true + }); + } + run(msg) { + const voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('join a channel and try again'); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('no songs playing right now bruh'); + } + msg.guild.musicData.songDispatcher.end(); + } +};
\ No newline at end of file diff --git a/commands/voice/skipall.js b/commands/voice/skipall.js new file mode 100644 index 0000000..bce9852 --- /dev/null +++ b/commands/voice/skipall.js @@ -0,0 +1,29 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class SkipAllVoice extends Command { + constructor(client) { + super(client, { + name: 'skipall', + group: 'voice', + memberName: 'skipall', + description: 'skip all songs in the queue', + guildOnly: true + }); + } + run(msg) { + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('join a channel and try again'); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('there is no song playing right now'); + } + if (!msg.guild.musicData.queue) + return msg.say('there are no songs in queue now >:)'); + 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.js b/commands/voice/skipto.js new file mode 100644 index 0000000..5c41e66 --- /dev/null +++ b/commands/voice/skipto.js @@ -0,0 +1,39 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class SkipToVoice extends Command { + constructor(client) { + super(client, { + name: 'skipto', + group: 'voice', + memberName: 'skipto', + description: 'skip to a certain song in da q >_<', + guildOnly: true, + args: [{ + key: 'songNumber', + prompt: 'what song u want to skip 2 in da q ???', + type: 'integer' + }] + }); + } + run(msg, { songNumber }) { + if (songNumber < 1 && songNumber >= msg.guild.musicData.queue.length) { + return msg.reply('enter a valid song number dumb'); + } + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('join channel and try again for cool'); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('there is no song playing right now dumby'); + } + + if (msg.guild.musicData.queue < 1) + return msg.reply('there are no songs in queue rn'); + + 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/squeak.js b/commands/voice/squeak.js new file mode 100644 index 0000000..3dbb355 --- /dev/null +++ b/commands/voice/squeak.js @@ -0,0 +1,27 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class SqueakVoice extends Command { + constructor(client) { + super(client, { + name: 'squeak', + group: 'voice', + memberName: 'squeak', + description: 'squeak', + guildOnly: true + }); + } + async run(msg) { + if (msg.member.voice.channel && !msg.guild.voice) { + const connection = await msg.member.voice.channel.join(); + const dispatcher = connection.play('./assets/audio/squeak.wav'); + + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (msg.guild.voice) { + msg.reply('i\'m already playing that lol'); + } else { + msg.reply('you need to join a voice channel first silly'); + } + } +};
\ No newline at end of file diff --git a/commands/voice/uhhhh.js b/commands/voice/uhhhh.js new file mode 100644 index 0000000..0ea364d --- /dev/null +++ b/commands/voice/uhhhh.js @@ -0,0 +1,28 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class MoanVoice extends Command { + constructor(client) { + super(client, { + name: 'moan', + aliases: ['uhhhh'], + group: 'voice', + memberName: 'moan', + description: 'uhhhh', + guildOnly: true + }); + } + async run(msg) { + if (msg.member.voice.channel && !msg.guild.voice) { + const connection = await msg.member.voice.channel.join(); + const dispatcher = connection.play('./assets/audio/uhhhh.wav'); + + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (msg.guild.voice) { + msg.reply('i\'m already playing that lol'); + } else { + msg.reply('you need to join a voice channel first silly'); + } + } +};
\ No newline at end of file diff --git a/commands/voice/volume.js b/commands/voice/volume.js new file mode 100644 index 0000000..e29486d --- /dev/null +++ b/commands/voice/volume.js @@ -0,0 +1,38 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class VolumeVoice extends Command { + constructor(client) { + super(client, { + name: 'volume', + aliases: ['vol', 'v'], + group: 'voice', + memberName: 'volume', + description: 'changes volume of audio if playing', + guildOnly: true, + args: [ + { + key: 'wantedVol', + prompt: 'what volume u want, from 1 to 200', + type: 'integer', + validate: wantedVol => wantedVol >= 1 && wantedVol <= 200 + } + ] + }); + } + run(msg, { wantedVol }) { + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('join a channel and try again'); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('there isn\'t a song playing right now lol'); + } + + const volume = wantedVol / 100; + msg.guild.musicData.volume = volume; + msg.guild.musicData.songDispatcher.setVolume(volume); + msg.reply(`volume is now: ${wantedVol}%`); + } +};
\ No newline at end of file diff --git a/commands/voice/wahoo.js b/commands/voice/wahoo.js new file mode 100644 index 0000000..d89dfe3 --- /dev/null +++ b/commands/voice/wahoo.js @@ -0,0 +1,28 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class WahooVoice extends Command { + constructor(client) { + super(client, { + name: 'wahoo', + aliases: ['mario'], + group: 'voice', + memberName: 'wahoo', + description: 'wahoo', + guildOnly: true + }); + } + async run(msg) { + if (msg.member.voice.channel && !msg.guild.voice) { + const connection = await msg.member.voice.channel.join(); + const dispatcher = connection.play('./assets/audio/wahoo.mp3'); + + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (msg.guild.voice) { + msg.reply('i\'m already playing that lol'); + } else { + msg.reply('you need to join a voice channel first silly'); + } + } +};
\ No newline at end of file |