Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

discord-player

Package Overview
Dependencies
Maintainers
1
Versions
359
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discord-player - npm Package Compare versions

Comparing version 1.0.7 to 1.1.0

2

package.json
{
"name": "discord-player",
"version": "1.0.7",
"version": "1.1.0",
"description": "Complete framework to facilitate music commands using discord.js v12",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -49,3 +49,4 @@ # Discord Player

**options.leaveOnEnd**: whether the bot should leave the voice channel when there is no more song in the queue.
**options.leaveOnStop**: whether the bot should leave the voice channel when the `stop()` function is used.
**options.leaveOnStop**: whether the bot should leave the voice channel when the `stop()` function is used.
**options.leaveOnEmpty**: whether the bot should leave the voice channel if there is no more member in it.

@@ -86,2 +87,5 @@ ### Features Overview

message.channel.send(`Now playing ${newSong.name}...`);
})
.on('channelEmpty', () => {
message.channel.send('Stop playing, there is no more member in the voice channel...');
});

@@ -88,0 +92,0 @@ ```

@@ -15,6 +15,8 @@ const ytdl = require('ytdl-core');

* @property {Boolean} leaveOnStop Whether the bot should leave the current voice channel when the stop() function is used.
* @property {Boolean} leaveOnEmpty Whether the bot should leave the voice channel if there is no more member in it.
*/
const PlayerOptions = {
leaveOnEnd: true,
leaveOnStop: true
leaveOnStop: true,
leaveOnEmpty: true
};

@@ -57,2 +59,19 @@

this.options = mergeOptions(PlayerOptions, options);
// Listener to check if the channel is empty
client.on('voiceStateUpdate', (oldMember, newMember) => {
if(!this.options.leaveOnEmpty) return;
// If the member leaves a voice channel
if(oldMember.voice.channel && !newMember.voice.channel) return;
// Search for a queue for this channel
let queue = this.queues.find((g) => g.connection.channel.id === oldMember.voice.channel.id);
if(queue){
// Disconnect from the voice channel
queue.connection.channel.leave();
// Delete the queue
this.queues = this.queues.filter((g) => g.guildID !== queue.guildID);
// Emit end event
this.emit('channelEmpty');
}
});
}

@@ -256,7 +275,10 @@

// Leaves the voice channel
if(this.options.leaveOnEnd) queue.connection.disconnect();
if(this.options.leaveOnEnd && !queue.stopped) queue.connection.channel.leave();
// Remoces the guild from the guilds list
this.queues = this.queues.filter((g) => g.guildID !== guildID);
// Emits stop event
if(queue.stopped) return queue.emit('stop');
if(queue.stopped){
if(this.options.leaveOnStop) queue.connection.channel.leave();
return queue.emit('stop');
}
// Emits end event

@@ -263,0 +285,0 @@ return queue.emit('end');

@@ -64,2 +64,7 @@ const { EventEmitter } = require('events');

/**
* Emitted when the voice channel is empty.
* @event Queue#channelEmpty
*/
/**
* Emitted when the song changes.

@@ -66,0 +71,0 @@ * @event Queue#songChanged

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc