This commit is contained in:
Emily 2020-04-24 17:51:00 +10:00
commit 9ab8731f90
2 changed files with 59 additions and 1 deletions

57
commands/movehere.js Normal file
View file

@ -0,0 +1,57 @@
// Copyright 2020 Emily J. / mudkipscience and contributors. Subject to the AGPLv3 license.
exports.conf = {
enabled: true,
guildOnly: true,
aliases: [],
permLevel: 'Moderator',
requiredPerms: ['CONNECT', 'SPEAK'],
cooldown: 10000
}
exports.help = {
name: 'movehere',
category: 'Music',
description: 'Moves ' + client.config.botName + ' into your voice channel and/or text channel.',
usage: 'movehere',
parameters: ''
}
const music = require('../utils/music')
exports.run = async (client, message, args, level, data) => {
// get guild music data
let mGuild = music.getGuild(message.guild.id)
if(!mGuild.playing) {
return message.channel.send('<:error:466995152976871434> Nothing is playing.')
}
// change text channel
let textChannelChanged = false
if(mGuild.channel.id != message.channel.id) {
mGuild.channel = message.channel
textChannelChanged = true
}
// move to another voice channel
let voiceChannelMoved = false
if(message.voice.channel && mGuild.voiceChannel && (message.voice.channel != mGuild.voiceChannel.id)) {
// TODO: this
voiceChannelMoved = true
}
// response
if(textChannelChanged && voiceChannelMoved) {
return message.channel.send('<:success:466995111885144095> Music playback moved to your voice channel and music messages to your text channel.')
} else if(textChannelChanged) {
return message.channel.send('<:success:466995111885144095> Music module will send messages to your text channel.')
} else if(voiceChannelMoved) {
return message.channel.send('<:success:466995111885144095> Music playback moved to your voice channel.')
} else {
return message.channel.send('<:error:466995152976871434> Music is already playing in your voice channel!')
}
}

View file

@ -172,6 +172,7 @@ 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
const connection = await vc.join() const connection = await vc.join()
@ -180,7 +181,7 @@ exports.play = async function (client, data, message, query, ignoreQueue) {
guild.dispatcher = connection.play(await ytdl(exports.getLinkFromID(v.video.videoId), { highWaterMark: 1024 * 1024 * 32 }), { type: 'opus' }) guild.dispatcher = connection.play(await ytdl(exports.getLinkFromID(v.video.videoId), { highWaterMark: 1024 * 1024 * 32 }), { type: 'opus' })
guild.dispatcher.setVolume(data.defaultVolume) guild.dispatcher.setVolume(data.defaultVolume)
message.channel.send('Playing **' + v.video.title + '**') guild.channel.send('Playing **' + v.video.title + '**')
// play next in queue on end // play next in queue on end
guild.dispatcher.once('finish', () => { guild.dispatcher.once('finish', () => {