diff --git a/commands/nowplaying.js b/commands/nowplaying.js index f07cdfa..b3e51b4 100644 --- a/commands/nowplaying.js +++ b/commands/nowplaying.js @@ -5,7 +5,7 @@ exports.conf = { guildOnly: true, aliases: ['np'], permLevel: 'User', - requiredPerms: [], + requiredPerms: ['EMBED_LINKS'], cooldown: 2000 } diff --git a/commands/play.js b/commands/play.js index c3ac80e..346b0f3 100644 --- a/commands/play.js +++ b/commands/play.js @@ -5,8 +5,8 @@ exports.conf = { guildOnly: true, aliases: [], permLevel: 'User', - requiredPerms: [], - cooldown: 2000 + requiredPerms: ['CONNECT', 'SPEAK'], + cooldown: 5000 } exports.help = { diff --git a/commands/removesong.js b/commands/removesong.js new file mode 100644 index 0000000..c1d7daf --- /dev/null +++ b/commands/removesong.js @@ -0,0 +1,51 @@ +// Copyright 2020 Emily J. / mudkipscience and contributors. Subject to the AGPLv3 license. + +exports.conf = { + enabled: true, + guildOnly: true, + aliases: [], + permLevel: 'User', + requiredPerms: [], + cooldown: 2000 +} + +exports.help = { + name: 'removesong', + category: 'Music', + description: 'Removes a song from the queue.', + usage: 'removesong [position]', + parameters: '[position] - The position of the song you want to remove' +} + +const { getGuild } = require('../utils/music') +module.exports.run = (client, message, args, level) => { + var queue = getGuild(message.guild.id).queue + + if (queue.length < 2) { + return message.channel.send('<:error:466995152976871434> Not enough songs are in the queue for this command to work!') + } + + if (!args[0]) { + return message.channel.send(`<:error:466995152976871434> You didn't tell me what song to remove! Usage: \`${client.commands.get('removesong').help.usage}\``) + } + + var input = +args[0] + + if (isNaN(input) === true) { + return message.channel.send('That isn\'t a number! You need to tell me the songs position in the queue (1, 2, etc.)') + } + + if (input >= queue.length) { + return message.channel.send('Invalid (too large)') + } + + if (input < 1) { + return message.channel.send('Invalid (too small)') + } + + var songName = queue[input].video.title + + queue.splice(input, 1) + + message.channel.send(`Removed from queue: **${songName}**`) +} diff --git a/commands/shuffle.js b/commands/shuffle.js new file mode 100644 index 0000000..368586d --- /dev/null +++ b/commands/shuffle.js @@ -0,0 +1,20 @@ +// Copyright 2020 Emily J. / mudkipscience and contributors. Subject to the AGPLv3 license. + +exports.conf = { + enabled: true, + guildOnly: true, + aliases: [], + permLevel: 'User', + requiredPerms: [], + cooldown: 2000 +} + +exports.help = { + name: 'removesong', + category: 'Music', + description: 'Removes a song from the queue.', + usage: 'removesong [position]', + parameters: '[position] - The position of the song you want to remove' +} + +const { getGuild } = require('../utils/music') \ No newline at end of file diff --git a/commands/stop.js b/commands/stop.js new file mode 100644 index 0000000..d82baed --- /dev/null +++ b/commands/stop.js @@ -0,0 +1,34 @@ +// Copyright 2020 Emily J. / mudkipscience and contributors. Subject to the AGPLv3 license. + +exports.conf = { + enabled: true, + guildOnly: true, + aliases: [], + permLevel: 'User', + requiredPerms: [], + cooldown: 2000 +} + +exports.help = { + name: 'stop', + category: 'Music', + description: 'Stops music, clears the queue and disconnects from the voice channel.', + usage: 'stop', + params: '' +} + +const { getGuild } = require('../utils/music') +exports.run = async (client, message) => { + const guild = getGuild(message.guild.id) + + if (guild.queue.length < 1 || !guild.playing || !guild.dispatcher) return message.channel.send('Nothing is playing.') + if (!message.member.voice.channel) return message.channel.send('You need to be in voice channel to use this command!') + + guild.playing = false + guild.paused = false + guild.queue = [] + + guild.dispatcher.end('silent') + + message.channel.send('Playback stopped!') +} diff --git a/utils/music.js b/utils/music.js index b0b938e..9b1244b 100644 --- a/utils/music.js +++ b/utils/music.js @@ -67,7 +67,7 @@ exports.getVideoByQuery = async function (client, query) { exports.play = async function (client, message, query, ignoreQueue) { const guild = exports.getGuild(message.guild.id) - if (!message.member.voice.channel && !guild.voice.channel) { + if (!message.member.voice.channel && !guild.voiceChannel) { return message.reply('You have to be connected to a voice channel to use this command!') } @@ -168,7 +168,8 @@ exports.play = async function (client, message, query, ignoreQueue) { } else { guild.playing = true - guild.voice.channel = vc + guild.voiceChannel = vc + console.log(vc) const connection = await vc.join()