From 8ed2c5948fb40448b121ac3cb0101bbde055e54a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20H?= Date: Thu, 23 Apr 2020 17:15:48 +0200 Subject: [PATCH] part of movehere --- commands/movehere.js | 57 ++++++++++++++++++++++++++++++++++++++++++++ utils/music.js | 3 ++- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 commands/movehere.js diff --git a/commands/movehere.js b/commands/movehere.js new file mode 100644 index 0000000..36c1142 --- /dev/null +++ b/commands/movehere.js @@ -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!') + } +} diff --git a/utils/music.js b/utils/music.js index 3e474b0..76de2f2 100644 --- a/utils/music.js +++ b/utils/music.js @@ -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', () => {