Allvaa / lavalink-musicbot

Music bot that uses Lavalink for its audio player.
MIT License
94 stars 56 forks source link

.join command #151

Open Toyuuu opened 3 years ago

Toyuuu commented 3 years ago

Can you help me? I've got this so far:

const util = require("../util");

var arr = [] module.exports = { name: "join", aliases: ["j"], exec: async (msg) => { const { music } = msg.guild; if (!msg.member.voice.channel) return msg.channel.send(:x: You need to be in a voice channel to run this command!); if (msg.guild.me.voice.channel && !msg.guild.me.voice.channel.equals(msg.member.voice.channel)) return msg.channel.send(:thumbsup: **I've left** ${msg.guild.me.voice.channel} **and joining** ${msg.member.voice.channel}!); await music.leave(msg.guild); await music.join(msg.member.voice.channel); const missingPerms = util.missingPerms(msg.guild.me.permissionsIn(msg.member.voice.channel), ["CONNECT", "SPEAK"]); if ((!music.player || !music.player.playing) && missingPerms.length) return msg.channel.send(Hmm :thinking: I am unable to join you're voice chat! I am missing the permission: ${missingPerms.map(x =>`${x}`).join(", ")}. Do I have access to this voice chat?); else { await music.join(msg.member.voice.channel); }

}

}

How do I make it leave voice channel? I got it to join just not leave to move channel.

Allvaa commented 3 years ago

https://github.com/Allvaa/lavalink-musicbot/blob/f9922d1d20a45917f6be039dd990a7310a7a40df/src/structures/MusicHandler.js#L69

yofukashino commented 3 years ago

Instead of leaving the vc and then joining other vc, move the bot its more efficient.

yofukashino commented 3 years ago

Can you help me? I've got this so far:

const util = require("../util");

var arr = [] module.exports = { name: "join", aliases: ["j"], exec: async (msg) => { const { music } = msg.guild; if (!msg.member.voice.channel) return msg.channel.send(:x: You need to be in a voice channel to run this command!); if (msg.guild.me.voice.channel && !msg.guild.me.voice.channel.equals(msg.member.voice.channel)) return msg.channel.send(:thumbsup: **I've left** ${msg.guild.me.voice.channel} **and joining** ${msg.member.voice.channel}!); await music.leave(msg.guild); await music.join(msg.member.voice.channel); const missingPerms = util.missingPerms(msg.guild.me.permissionsIn(msg.member.voice.channel), ["CONNECT", "SPEAK"]); if ((!music.player || !music.player.playing) && missingPerms.length) return msg.channel.send(Hmm :thinking: I am unable to join you're voice chat! I am missing the permission: ${missingPerms.map(x => ``${x}``).join(", ")}. Do I have access to this voice chat?); else { await music.join(msg.member.voice.channel); }

}

}

How do I make it leave voice channel? I got it to join just not leave to move channel.

ctx.guild.members.cache.get(ctx.client.user.id).voice.setChannel(ctx.member.voice.channel) use this to move channel instead bruh