Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request] Leave Command & No auto leaving when queue ends #38

Closed
LegalSmeagol opened this issue Jun 1, 2020 · 6 comments
Closed

[Request] Leave Command & No auto leaving when queue ends #38

LegalSmeagol opened this issue Jun 1, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@LegalSmeagol
Copy link

Hello. This bot is amazing and has so many features, but would it be possible to stop the bot from disconnecting when the queue ends and instead follow in suit with Groovy whereby they have a "leave" command to disconnect the bot at any point and have an additional failsafe of disconnecting the bot after X minutes of inactivity. If this could be achieved, could this be made a configurable option to give bot owners the ability to choose whether to leave when the queue ends or remain until "leave" is entered or there's X minutes of inactivity?

Thanks!

@Vanawy
Copy link
Contributor

Vanawy commented Jun 1, 2020

I think this is great feature and if @eritislami doesn't mind i can try to implement this

@eritislami
Copy link
Owner

I think this is great feature and if @eritislami doesn't mind i can try to implement this

Absolutely, feel free to do it. Appreciate the suggestions as well

@eritislami eritislami added the enhancement New feature or request label Jun 1, 2020
@alhassanv
Copy link
Contributor

Is there an ETA on this feature?

@Vanawy
Copy link
Contributor

Vanawy commented Jun 3, 2020

Is there an ETA on this feature?

Hello, not yet, but I will try to make it work this weekend. I started working on this but it's harder than i thought

@NokkaTsui
Copy link

NokkaTsui commented Jun 10, 2020

I have tried to implement these 2 features, so far they work fine.
For the 'leave' feature, create a 'leave.js' file in the 'commands' folder, then implement the code:

module.exports = { name: "leave", description: "Leave the current channel", execute(message) { const { channel } = message.member.voice; const serverQueue = message.client.queue.get(message.guild.id); if (!channel) return message.reply("You need to join a voice channel first!").catch(console.error); if (!message.guild.me.voice.channel) return message.reply("I am not in a voice channel!").catch(console.error); if (channel.id !== message.guild.me.voice.channel.id) return message.reply("I am not in your voice channel!").catch(console.error); if(serverQueue) { serverQueue.connection.dispatcher.destroy(); channel.leave(); message.client.queue.delete(message.guild.id); serverQueue.textChannel.send('I have left the channel. See you again.').catch(console.error); return } channel.leave(); message.client.queue.delete(message.guild.id); message.channel.send('I have left the channel. See you again.').catch(console.error); } };

For the 'leave after x minutes of inactivity', open the 'play.js' in the 'include' folder, then replace
queue.channel.leave(); with the code:

setTimeout(function() { if (!queue.connection.dispatcher && message.guild.me.voice.channel ) {queue.channel.leave(); queue.textChannel.send("I have left the channel. See you again.").catch(console.error);} else return },120000);

12000ms=2mins, change the number if you prefer another one.

@dylanjamesdev
Copy link

@NokkaTsui,

Just to be clear, the timeout only works after music has stopped playing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants