part of movehere

This commit is contained in:
Lukáš H 2020-04-23 17:15:48 +02:00
parent 78aab0f9f6
commit 8ed2c5948f
No known key found for this signature in database
GPG key ID: E07D6630DBC17195
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, message, query, ignoreQueue) {
guild.playing = true
guild.voiceChannel = vc
guild.channel = message.channel
const connection = await vc.join()
@ -180,7 +181,7 @@ exports.play = async function (client, message, query, ignoreQueue) {
guild.dispatcher = connection.play(await ytdl(exports.getLinkFromID(v.video.videoId), { highWaterMark: 1024 * 1024 * 32 }), { type: 'opus' })
guild.dispatcher.setVolume(0.25)
message.channel.send('Playing **' + v.video.title + '**')
guild.channel.send('Playing **' + v.video.title + '**')
// play next in queue on end
guild.dispatcher.once('finish', () => {