forked from embee/woomy
update music to support playnext
This commit is contained in:
parent
cfcdf359f5
commit
caeeafa3bb
2 changed files with 15 additions and 8 deletions
|
@ -12,12 +12,12 @@ exports.conf = {
|
||||||
exports.help = {
|
exports.help = {
|
||||||
name: 'play',
|
name: 'play',
|
||||||
category: 'Music',
|
category: 'Music',
|
||||||
description: 'Plays or adds to queue requested music.',
|
description: 'Plays the song you request, or adds it to the queue.',
|
||||||
usage: 'play [query]',
|
usage: 'playnext [song]',
|
||||||
parameters: '[query] - A query to find video by or a link to the video.'
|
parameters: '[song] - The name or youtube URL of the song you want to play.'
|
||||||
}
|
}
|
||||||
|
|
||||||
const { play } = require('../utils/music')
|
const { play } = require('../utils/music')
|
||||||
exports.run = async (client, message, args, level, data) => {
|
exports.run = async (client, message, args, level, data) => {
|
||||||
await play(client, data.guild.music, message, args.join(' '))
|
await play(client, data.guild.music, message, args.join(' '), false)
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ exports.getVideoByQuery = async function (client, query) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.play = async function (client, data, message, query, ignoreQueue) {
|
exports.play = async function (client, data, message, query, playNext, ignoreQueue) {
|
||||||
const guild = exports.getGuild(message.guild.id)
|
const guild = exports.getGuild(message.guild.id)
|
||||||
guild.message = message
|
guild.message = message
|
||||||
|
|
||||||
|
@ -162,7 +162,11 @@ exports.play = async function (client, data, message, query, ignoreQueue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add video to queue
|
// Add video to queue
|
||||||
guild.queue.push({ video: video, requestedBy: message.author })
|
if (playNext === true) {
|
||||||
|
guild.queue.splice(1, 0, { video: video, requestedBy: message.author })
|
||||||
|
} else {
|
||||||
|
guild.queue.push({ video: video, requestedBy: message.author })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Figure out if the bot should add it to queue or play it right now
|
// Figure out if the bot should add it to queue or play it right now
|
||||||
|
@ -172,7 +176,10 @@ exports.play = async function (client, data, message, query, ignoreQueue) {
|
||||||
guild.playing = true
|
guild.playing = true
|
||||||
|
|
||||||
guild.voiceChannel = vc
|
guild.voiceChannel = vc
|
||||||
guild.channel = message.channel
|
|
||||||
|
if (!guild.channel) {
|
||||||
|
guild.channel = message.channel
|
||||||
|
}
|
||||||
|
|
||||||
const connection = await vc.join()
|
const connection = await vc.join()
|
||||||
|
|
||||||
|
@ -189,7 +196,7 @@ exports.play = async function (client, data, message, query, ignoreQueue) {
|
||||||
guild.playing = false
|
guild.playing = false
|
||||||
|
|
||||||
if (guild.queue.length > 0) {
|
if (guild.queue.length > 0) {
|
||||||
exports.play(client, data, message, null, true)
|
exports.play(client, data, message, null, false, true)
|
||||||
} else {
|
} else {
|
||||||
guild.queue = []
|
guild.queue = []
|
||||||
guild.playing = false
|
guild.playing = false
|
||||||
|
|
Loading…
Reference in a new issue