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,8 +162,12 @@ exports.play = async function (client, data, message, query, ignoreQueue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add video to queue
|
// Add video to queue
|
||||||
|
if (playNext === true) {
|
||||||
|
guild.queue.splice(1, 0, { video: video, requestedBy: message.author })
|
||||||
|
} else {
|
||||||
guild.queue.push({ video: video, requestedBy: message.author })
|
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
|
||||||
if (guild.playing) {
|
if (guild.playing) {
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
if (!guild.channel) {
|
||||||
guild.channel = message.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