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

jericho-player

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jericho-player - npm Package Compare versions

Comparing version 1.2.0-beta.1658528085.1dfae53 to 1.2.0-beta.1658606419.60e3c3d

src/misc/enums.js

2

package.json
{
"name": "jericho-player",
"version": "1.2.0-beta.1658528085.1dfae53",
"version": "1.2.0-beta.1658606419.60e3c3d",
"description": "LightWeight Framework for discord.js v14 Music Bots and Radio Bots with fast moderation with commands and no memory leak mode",

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

const EventEmiiter = require('events').EventEmitter;
const {
Client, Guild, Message, User, Channel,
Client,
Guild,
Message,
User,
Channel,
VoiceState,
} = require('discord.js');

@@ -8,2 +13,3 @@ const queue = require('./queue');

const eventEmitter = require('../utils/eventEmitter');
const { invalidGuild, invalidQueue } = require('../misc/errorEvents');

@@ -45,2 +51,21 @@ /**

this.eventEmitter = new eventEmitter(this, options?.eventOptions);
this.discordClient.on('voiceStateUpdate', async (oldState, newState) => {
const rawQueue = await this.getQueue(
oldState?.guild?.id ?? newState?.guild?.id,
);
if (
rawQueue &&
oldState?.guild?.id !== rawQueue.guildId &&
newState?.guild?.id !== rawQueue.guildId &&
newState?.channelId !== oldState?.channelId
)
return await this.#__voiceHandler(
oldState,
newState,
rawQueue,
rawQueue?.options?.voiceOptions ?? this.options?.voiceOptions,
);
else return undefined;
});
}

@@ -59,6 +84,3 @@

const guild = await guildResolver(this.discordClient, guildSnowflake);
if (!guild?.id)
throw new Error(
'[ Invalid Guild Snowflake ] : Guild Snowflake is Wrong and Un-Supported for Creation of Queue',
);
if (!guild?.id) throw new invalidGuild();
this.eventEmitter.emitDebug(

@@ -99,14 +121,8 @@ 'queue Creation',

const guild = await guildResolver(this.discordClient, guildSnowflake);
if (!guild?.id)
throw new Error(
'[ Invalid Guild Snowflake ] : Guild Snowflake is Wrong and Un-Supported for Creation of Queue',
);
if (!guild?.id) throw new invalidGuild();
const requestedQueue = this.#__queueMods('get', guild?.id, options);
if (!requestedQueue)
throw new Error(
'[ Invalid Queue ] : Requested Queue has been not Cached or was never created using given guild-snowflake',
);
if (!requestedQueue) throw new invalidQueue();
this.eventEmitter.emitDebug(
'queue Destruction',
'Destruction of Queue Class Instance from Actual Player Class Cahces',
'Destruction of Queue Class Instance from Actual Player Class Caches',
{

@@ -147,6 +163,3 @@ guildSnowflake,

const guild = await guildResolver(this.discordClient, guildSnowflake);
if (!guild?.id)
throw new Error(
'[ Invalid Guild Snowflake ] : Guild Snowflake is Wrong and Un-Supported for Fetching of Queue',
);
if (!guild?.id) throw new invalidGuild();
if (forceGet) return this.#__queueMods('forceget', guild?.id, options);

@@ -207,4 +220,4 @@ else return this.#__queueMods('get', guild?.id);

case 'forcecreate':
let queue = this.#__queueMods('get', guildId);
if (queue) this.#__queueMods('delete', guildId);
const cachedQueue = this.#__queueMods('get', guildId);
if (cachedQueue) this.#__queueMods('delete', guildId);
return this.#__queueMods(

@@ -239,4 +252,64 @@ 'submit',

}
/**
* @private
* @method __voiceHandler() Voice Handlers of Discord Client for moderating cached and working Queue on the respective Guild
* @param {VoiceState} oldState Old Voice State where previous State has been recorded from Client or Api
* @param {VoiceState} newState New Voice State where present State has been recorded from Client or Api
* @param {queue} queue Queue Data from Player's caches
* @param {object} options Voice Options if voiceMod is required
*/
async #__voiceHandler(oldState, newState, queue, options) {
if (
(oldState?.member.id === queue?.current?.user.id ||
newState?.member.id === queue?.current?.user.id) &&
(!options?.leaveOn?.bot ||
(options?.leaveOn?.bot && !newState?.member?.user?.bot))
) {
if (!newState?.channelId && !queue?.destroyed) {
if (oldState?.channel?.members?.size === 1)
this.eventEmitter.emitEvent(
'channelEmpty',
'Channel is Empty and have no members in it',
{
queue,
channel: oldState?.channel,
requestedSource: queue?.current?.requestedSource,
},
);
return await this.destroyQueue(queue?.guildId, true, {
delayTimeout:
options?.leaveOn?.bot && !isNaN(Number(options?.leaveOn?.bot)) > 0
? options?.leaveOn?.bot
: 0,
});
} else if (newState?.channelId && !queue?.destroyed)
return await queue.voiceMod.connect(newState.channel);
else return undefined;
} else if (
oldState?.member.id === this.discordClient?.user?.id ||
newState?.member.id === this.discordClient?.user?.id
) {
if (!newState?.channelId && !queue?.destroyed)
return await this.destroyQueue(queue?.guildId, true, {
...options,
voiceOptions: {
...options?.voiceOptions,
altVoiceChannel: oldState?.channelId,
},
});
else if (oldState?.channelId && newState?.channelId && !queue?.destroyed)
return await queue.voiceMod.connect(
options?.anyoneCanMoveClient ? newState.channel : oldState?.channel,
);
else return undefined;
} else return undefined;
}
get type() {
return 'player';
}
}
module.exports = player;
const { AudioPlayerStatus } = require('@discordjs/voice');
const {
Client, VoiceChannel, Message, User,
Client,
VoiceChannel,
Message,
CommandInteraction,
StageChannel,
} = require('discord.js');
const { Track } = require('../misc/fetchRecords');
const { Track } = require('../misc/enums');
const packets = require('../gen/packets');

@@ -11,2 +15,8 @@ const eventEmitter = require('../utils/eventEmitter');

const player = require('./player');
const {
destroyedQueue,
invalidQuery,
invalidVoiceChannel,
invalidTracksCount,
} = require('../misc/errorEvents');

@@ -71,12 +81,2 @@ /**

this.packet = new packets(this, options?.packetOptions);
this.discordClient.on('voiceStateUpdate', async (oldState, newState) => (oldState?.guild?.id !== this.guildId &&
newState?.guild?.id !== this.guildId &&
newState?.channelId !== oldState?.channelId
? await this.packet?.__voiceHandler(
oldState,
newState,
this.options?.voiceOptions,
)
: undefined));
}

@@ -87,4 +87,4 @@

* @param {string} rawQuery String Value for fetching/Parsing with the help of extractors
* @param {string | number | VoiceChannel | Message} voiceSnowflake voice Channel Snowflake in terms of further resolving value using in-built resolvers to connect to play song on it
* @param {string | number | Message | User} requestedBy requested By User Data for checks and avoid the further edits on it by some stranger to protect the integrity
* @param {string | number | VoiceChannel | StageChannel | Message} voiceSnowflake voice Channel Snowflake in terms of further resolving value using in-built resolvers to connect to play song on it
* @param {string | number | Message | CommandInteraction } requestedSource requested By Source Data for checks and avoid the further edits on it by some stranger to protect the integrity
* @param {object} options queue/play Options for further requirements

@@ -94,8 +94,8 @@ * @returns {Promise<Boolean | undefined>} Returns extractor Data based on progress or undefined

async play(rawQuery, voiceSnowflake, requestedBy, options) {
async play(rawQuery, voiceSnowflake, requestedSource, options) {
try {
if (!(rawQuery && typeof rawQuery === 'string' && rawQuery !== ''))
throw new TypeError(
'[ Invalid Raw Query ] : Wrong Query for Songs is Detected for queue.play()',
);
if (this.destroyed)
throw new destroyedQueue('Queue has been destroyed already');
else if (!(rawQuery && typeof rawQuery === 'string' && rawQuery !== ''))
throw new invalidQuery();
const voiceChannel = await voiceResolver(

@@ -105,6 +105,3 @@ this.discordClient,

);
if (!voiceChannel)
throw new TypeError(
'[ Invalid Voice Channel ] : Wrong Voice Channel Snowflake/Resolve is Detected for queue.play()',
);
if (!voiceChannel) throw new invalidVoiceChannel();
this.eventEmitter.emitDebug(

@@ -118,5 +115,4 @@ 'Packet get Request',

);
this.packet =
this.packet ??
new packets(
if (!(this.packet && this.packet?.destroyed))
this.packet = new packets(
this,

@@ -128,3 +124,3 @@ options?.packetOptions ?? this.options?.packetOptions,

voiceChannel,
requestedBy,
requestedSource,
options?.packetOptions,

@@ -159,3 +155,3 @@ );

if (this.destroyed || !this?.packet?.audioPlayer?.state?.status)
throw new Error('[Destroyed Queue] : Queue has been destroyed already');
throw new destroyedQueue();
else if (

@@ -168,5 +164,3 @@ !(

)
throw new Error(
'[Invalid Track-Count] : Track Count has Invalid Counts to skip on queue.tracks',
);
throw new invalidTracksCount();
this.packet.__cacheAndCleanTracks(

@@ -200,3 +194,3 @@ { startIndex: 0, cleanTracks: trackCount },

if (this.destroyed || !this?.packet?.audioPlayer?.state?.status)
throw new Error('[Destroyed Queue] : Queue has been destroyed already');
throw new destroyedQueue();
this.packet.__cacheAndCleanTracks(

@@ -231,8 +225,11 @@ { startIndex: 0, cleanTracks: this.tracks?.length },

async destroy(delayVoiceTimeout = 0, destroyConnection = false) {
if (this.destroyed)
throw new Error('[Destroyed Queue] : Queue has been destroyed already');
const timeOutIdResidue = await this.voiceMod.disconnect(this.guildId, {
destroy: Boolean(destroyConnection),
delayVoiceTimeout,
});
if (this.destroyed) throw new destroyedQueue();
const timeOutIdResidue = await this.voiceMod.disconnect(
this.guildId,
{
destroy: Boolean(destroyConnection),
delayVoiceTimeout,
},
this.tracks?.find((t) => t.requestedSource)?.requestedSource,
);
this.packet.__perfectClean();

@@ -239,0 +236,0 @@ delete this.packet;

@@ -62,7 +62,7 @@ const { User } = require('discord.js');

* @param {string} rawQuery String Value for fetching/Parsing with the help of extractors
* @param {User} requestedBy requested By User Data for checks and avoid the further edits on it by some stranger to protect the integrity
* @param {User} requestedSource requested By Source Data for checks and avoid the further edits on it by some stranger to protect the integrity
* @param {object} options options Downloader Options for extractor's scrapping Options
* @returns {Promise<Boolean | undefined>} Returns Raw Extractor Data on completion of processing and extracting
*/
async get(rawQuery, requestedBy, options) {
async get(rawQuery, requestedSource, options) {
if (!(rawQuery && typeof rawQuery === 'string' && rawQuery !== ''))

@@ -73,3 +73,3 @@ return undefined;

rawQuery,
requestedBy,
requestedSource,
options?.playdlOptions,

@@ -82,3 +82,3 @@ );

* @param {string} rawQuery String Value for fetching/Parsing with the help of extractors
* @param {User} requestedBy requested By User Data for checks and avoid the further edits on it by some stranger to protect the integrity
* @param {User} requestedSource requested By Source Data for checks and avoid the further edits on it by some stranger to protect the integrity
* @param {object} options options Downloader Options for extractor's scrapping Options

@@ -88,3 +88,3 @@ * @returns {Promise<Boolean | undefined>} Returns Raw Extractor Data on completion of processing and extracting

async getPlaydl(rawQuery, requestedBy, options) {
async getPlaydl(rawQuery, requestedSource, options) {
this.eventEmitter.emitDebug(

@@ -95,2 +95,3 @@ 'playdl - Extractor',

rawQuery,
requestedSource,
downloaderOptions: options,

@@ -102,3 +103,3 @@ },

eventReturn: {
metadata: { requestedBy },
metadata: { requestedSource },
},

@@ -105,0 +106,0 @@ streamDownload: true,

@@ -12,9 +12,23 @@ const {

const {
Message,
User,
CommandInteraction,
VoiceChannel,
StageChannel,
Guild,
} = require('discord.js');
const queue = require('../core/queue');
const downloader = require('./downloader');
const { Track, Playlist } = require('../misc/fetchRecords');
const { voiceResolver, userResolver } = require('../utils/snowflakes');
const { Track, Playlist } = require('../misc/enums');
const {
voiceResolver,
messageResolver,
interactionResolver,
} = require('../utils/snowflakes');
const player = require('../core/player');
const eventEmitter = require('../utils/eventEmitter');
const voiceMod = require('../utils/voiceMod');
const { invalidRequiredSource } = require('../misc/errorEvents');

@@ -105,4 +119,4 @@ /**

* @param {string} rawQuery String Value for fetching/Parsing with the help of extractors
* @param {string | number | VoiceChannel | Message} voiceSnowflake voice Channel Snowflake in terms of further resolving value using in-built resolvers to connect to play song on it
* @param {string | number | Message | User} requestedBy requested By User Data for checks and avoid the further edits on it by some stranger to protect the integrity
* @param {string | number | VoiceChannel | StageChannel | Message} voiceSnowflake voice Channel Snowflake in terms of further resolving value using in-built resolvers to connect to play song on it
* @param {string | number | Message | CommandInteraction } requestedSource requested By Source Data for checks and avoid the further edits on it by some stranger to protect the integrity
* @param {object} options packets Options for further requirements

@@ -112,7 +126,19 @@ * @returns {Promise<Boolean | undefined>} Returns Extractor Data from the defalt extractors

async getQuery(rawQuery, voiceSnowflake, requestedBy, options) {
async getQuery(rawQuery, voiceSnowflake, requestedSource, options) {
try {
if (!this.destroyed) return undefined;
if (this.destroyed) return undefined;
else if (!(rawQuery && typeof rawQuery === 'string' && rawQuery !== ''))
return undefined;
requestedSource =
interactionResolver(this.player?.discordClient, requestedSource) ??
(await messageResolver(this.player?.discordClient, requestedSource));
if (
!requestedSource ||
(requestedSource &&
(requestedSource?.user?.bot ||
requestedSource?.author?.bot ||
requestedSource?.member?.bot ||
requestedSource?.member?.user?.bot))
)
throw new invalidRequiredSource();
const voiceChannel = await voiceResolver(

@@ -129,3 +155,3 @@ this.queue?.discordClient,

);
await this.voiceMod?.connect(voiceChannel, options?.voiceOptions);
await this.voiceMod?.connect(voiceChannel, requestedSource);
this.eventEmitter.emitDebug(

@@ -139,10 +165,5 @@ 'Downloader',

);
requestedBy = await userResolver(this.player?.discordClient, requestedBy);
if (!requestedBy)
throw new TypeError(
'[ Invalid User Data - Requested By ] : Invalid Guild Member/User or User Data has been given for avoiding songs and queue collapse on listing on order',
);
return await this.downloader.get(
rawQuery,
requestedBy,
requestedSource,
options?.downloaderOptions,

@@ -175,3 +196,3 @@ );

async __audioPlayerStateMod(oldState, newState) {
if (!this.destroyed) return undefined;
if (this.destroyed) return undefined;
else if (newState?.status === AudioPlayerStatus.Idle) {

@@ -191,3 +212,5 @@ this.eventEmitter.emitDebug(

track: this.tracksMetadata?.[0]?.track,
user: this.tracksMetadata?.[0]?.track?.user,
remainingTracks: this.tracksMetadata?.slice(1) ?? [],
requestedSource: this.tracksMetadata?.[0]?.track?.requestedSource,
},

@@ -199,2 +222,8 @@ );

else if (this.tracksMetadata?.length === 0) {
const lastTrack =
this.__privateCaches?.completedTracksMetadata?.length > 1
? this.__privateCaches?.completedTracksMetadata?.[
this.__privateCaches?.completedTracksMetadata?.length - 1
]
: undefined;
this.eventEmitter.emitEvent(

@@ -205,9 +234,6 @@ 'queueEnd',

queue: this.queue,
track:
this.__privateCaches?.completedTracksMetadata?.length > 1
? this.__privateCaches?.completedTracksMetadata?.[
this.__privateCaches?.completedTracksMetadata?.length - 1
]
: undefined,
track: lastTrack,
user: lastTrack?.user,
previousTracks: this.__privateCaches?.completedTracksMetadata,
requestedSource: lastTrack?.requestedSource,
},

@@ -221,4 +247,2 @@ );

// async __voiceHandler(oldState, newState, options) {}
/**

@@ -234,3 +258,3 @@ * @method __cacheAndCleanTracks Cache and Clean Tracks on Track End event Trigger/Requirement

) {
if (!this.destroyed) return undefined;
if (this.destroyed) return undefined;
else if (

@@ -276,3 +300,3 @@ !this.tracksMetadata?.[0] ||

try {
if (!this.destroyed) return undefined;
if (this.destroyed) return undefined;
const streamData = rawTrackData?.streamData;

@@ -299,3 +323,8 @@ if (!streamData) return undefined;

'Processed Track will be Played now within few seconds',
{ queue: this.queue, track: rawTrackData?.track },
{
queue: this.queue,
track: rawTrackData?.track,
user: rawTrackData?.track?.user,
requestedSource: rawTrackData?.track?.requestedSource,
},
);

@@ -336,5 +365,4 @@ this.__privateCaches.audioPlayerSubscription = voiceConnection.subscribe(

__playlistMod(playlist) {
if (!this.destroyed) return undefined;
const userData = playlist?.customMetadata?.requestedBy;
delete playlist?.customMetadata?.requestedBy;
if (this.destroyed) return undefined;
const parsedPlaylist = new Playlist(playlist);
return this.eventEmitter.emitEvent(

@@ -345,4 +373,5 @@ 'playlistAdd',

queue: this.queue,
playlist: new Playlist(playlist, userData),
userData,
playlist: parsedPlaylist,
user: parsedPlaylist?.user,
requestedSource: parsedPlaylist?.requestedSource,
},

@@ -363,8 +392,3 @@ );

try {
if (!this.destroyed) return undefined;
const userData =
metadata?.requestedBy ?? rawTrack?.customMetadata?.requestedBy;
delete metadata?.requestedBy;
delete rawTrack?.customMetadata?.requestedBy;
delete playlist?.customMetadata?.requestedBy;
if (this.destroyed) return undefined;
this.eventEmitter.emitDebug(

@@ -375,4 +399,3 @@ 'Tracks Modification',

rawTrack,
playlist: new Playlist(playlist, userData),
user: userData,
playlist: new Playlist(playlist),
extractor,

@@ -382,4 +405,3 @@ metadata,

);
if (this.queue?.destroyed) return undefined;
const track = new Track(rawTrack, userData);
const track = new Track(rawTrack);
const streamData = track?.__getStream(true);

@@ -393,5 +415,6 @@ this.tracksMetadata.push({ track, streamData });

track,
playlist: new Playlist(playlist, userData),
user: userData,
playlist: new Playlist(playlist),
user: track?.user,
tracks: this.queue?.tracks,
requestedSource: track?.requestedSource,
},

@@ -398,0 +421,0 @@ );

@@ -53,6 +53,5 @@ const fileSystem = require('fs');

eventVariable?.queue ?? eventVariable?.player,
config?.errorName ?? eventMetadata?.name ?? '[Error]',
eventMetadata,
eventVariable,
eventLocation,
processedError,
);

@@ -82,3 +81,8 @@ if (config?.debugRegister)

if (config?.emitPlayer && eventName)
this.player?.emit(eventName, new Date(), extraMetadata, ...eventVariable);
this.player?.emit(
eventName,
new Date(),
extraMetadata,
...Object.entries(eventVariable)?.map((d) => d?.[1]),
);
if (config?.debugRegister)

@@ -85,0 +89,0 @@ this.emitDebug(

@@ -10,2 +10,5 @@ const {

User,
ButtonInteraction,
CommandInteraction,
SelectMenuInteraction,
} = require('discord.js');

@@ -79,2 +82,11 @@

snowflake &&
(snowflake instanceof ButtonInteraction ||
snowflake instanceof SelectMenuInteraction ||
snowflake instanceof CommandInteraction)
)
return (
snowflake?.user ?? snowflake?.message?.author ?? snowflake?.member?.user
);
else if (
snowflake &&
typeof snowflake === 'string' &&

@@ -92,4 +104,31 @@ snowflake?.trim() !== ''

}
static async messageResolver(discordClient, snowflake) {
if (!(discordClient && discordClient instanceof Client)) return undefined;
else if (snowflake && snowflake instanceof Message) return snowflake;
else if (
snowflake &&
(snowflake instanceof ButtonInteraction ||
snowflake instanceof SelectMenuInteraction ||
snowflake instanceof CommandInteraction) &&
snowflake?.message
)
return snowflake?.message;
else return undefined;
}
static interactionResolver(discordClient, snowflake) {
if (!(discordClient && discordClient instanceof Client)) return undefined;
else if (
snowflake &&
(snowflake instanceof ButtonInteraction ||
snowflake instanceof SelectMenuInteraction ||
snowflake instanceof CommandInteraction) &&
snowflake?.message
)
return snowflake;
else return undefined;
}
}
module.exports = snowFlakes;

@@ -9,2 +9,3 @@ const {

const queue = require('../core/queue');
const { invalidVoiceChannel } = require('../misc/errorEvents');

@@ -25,3 +26,6 @@ class voiceMod {

async connect(voiceSnowflake, options) {
async connect(
voiceSnowflake,
requestedSource = this.queue?.current?.requestedSource,
) {
try {

@@ -33,5 +37,7 @@ const voiceChannel = await voiceResolver(

if (!voiceChannel)
throw new Error(
'[ Invalid Voice Channel ] : Wrong Voice Channel Snowflake/Resolve is Detected for voiceMod.connect()',
throw new invalidVoiceChannel(
'Wrong Voice Channel Snowflake/Resolve is Detected for voiceMod.connect()',
);
if (this.queue.destroyed && typeof this.queue?.destroyed !== 'boolean')
clearTimeout(this.queue?.destroyed);
const rawVoiceConnection = joinVoiceChannel({

@@ -57,3 +63,3 @@ channelId: voiceChannel?.id,

errorMetadata?.message ?? `${errorMetadata}`,
{ queue: this.queue },
{ queue: this.queue, requestedSource },
this.options?.eventOptions,

@@ -65,10 +71,17 @@ );

async disconnect(guildSnowflake, delayVoiceTimeout, options) {
async disconnect(
guildSnowflake,
delayVoiceTimeout,
requestedSource = this.queue?.current?.requestedSource,
options = this.options,
) {
try {
const guild = await guildResolver(this.discordClient, guildSnowflake);
if (!guild)
throw new Error(
'[ Invalid Discord Guild ] : Corrupt/Invalid Guild Data by guild Snowflake has been resolved',
throw new invalidVoiceChannel(
'Wrong Voice Channel Snowflake/Resolve is Detected for voiceMod.connect()',
);
const queue = await this.player.getQueue(guild);
if (queue.destroyed && typeof queue?.destroyed !== 'boolean')
clearTimeout(this.queue?.destroyed);
if (queue?.packet?.audioPlayer && (queue?.playing || queue?.paused))

@@ -79,13 +92,27 @@ queue?.packet?.audioPlayer?.stop();

(queue?.playing || queue?.paused)
)
queue?.packet?.__privateCaches?.audioPlayerSubscription?.unsubscribe();
const voiceConnection = getVoiceConnection(guild?.id);
if (!voiceConnection)
throw new Error(
'[ Invalid Voice Connection ] : Corrupt/Invalid Voice Connection has been fetched',
);
if (options?.forceDestroy)
) {
queue.packet.__privateCaches.audioPlayerSubscription.unsubscribe();
queue.packet.__privateCaches.audioPlayerSubscription = undefined;
}
const connectedChannel = await voiceResolver(
this.discordClient,
options?.altVoiceChannel ?? guild?.members?.me?.voice?.channel,
);
if (!connectedChannel) return undefined;
else if (options?.forceDestroy)
return delayVoiceTimeout && delayVoiceTimeout > 0
? setTimeout(() => {
const voiceConnection = getVoiceConnection(guild?.id);
if (!voiceConnection) return undefined;
voiceConnection.destroy(true);
this.eventEmitter.emitEvent(
'botDisconnect',
'Discord Client got Disconnected from the Channel',
{
queue: this.queue,
channel: connectedChannel,
requestedSource,
},
);
return true;
}, delayVoiceTimeout * 1000)

@@ -96,3 +123,15 @@ : true;

? setTimeout(() => {
const voiceConnection = getVoiceConnection(guild?.id);
if (!voiceConnection) return undefined;
voiceConnection.disconnect();
this.eventEmitter.emitEvent(
'botDisconnect',
'Discord Client got Disconnected from the Channel',
{
queue: this.queue,
channel: connectedChannel,
requestedSource,
},
);
return true;
}, delayVoiceTimeout * 1000)

@@ -104,3 +143,3 @@ : true;

errorMetadata?.message ?? `${errorMetadata}`,
{ queue: this.queue },
{ queue: this.queue, requestedSource },
this.options?.eventOptions,

@@ -107,0 +146,0 @@ );

@@ -10,5 +10,7 @@ import EventEmitter from "events";

VoiceChannel,
Awaitable,
CommandInteraction,
ButtonInteraction,
SelectMenuInteraction,
} from "discord.js";
import { Options, Playlist, Track } from "./Instances";
import { Options, Playlist, Track, Awaitable } from "./Instances";

@@ -19,13 +21,56 @@ declare interface playerEvents {

queue: queue | player | void,
message: string,
error: Error,
variables: object,
location: string | void,
metadata: string
metadata: string,
requestedSource:
| Message
| CommandInteraction
| ButtonInteraction
| SelectMenuInteraction
];
raw: [data: Date, metadata: string, variables: object];
debug: [eventName: string, message: string, variables: object];
trackEnd: [queue: queue, track: Track, remainingTracks: Track[]];
queueEnd: [queue: queue, track: Track, previousTracks: Track[]];
trackStart: [queue: queue, track: Track];
playlistAdd: [queue: queue, playlist: Playlist, user: User | GuildMember];
debug: [eventName: string, eventMessage: string, variables: object];
trackEnd: [
queue: queue,
track: Track,
user: User,
remainingTracks: Track[],
requestedSource:
| Message
| CommandInteraction
| ButtonInteraction
| SelectMenuInteraction
];
queueEnd: [
queue: queue,
track: Track,
user: User,
previousTracks: Track[],
requestedSource:
| Message
| CommandInteraction
| ButtonInteraction
| SelectMenuInteraction
];
trackStart: [
queue: queue,
track: Track,
user: User,
requestedSource:
| Message
| CommandInteraction
| ButtonInteraction
| SelectMenuInteraction
];
playlistAdd: [
queue: queue,
playlist: Playlist,
user: User | GuildMember,
requestedSource:
| Message
| CommandInteraction
| ButtonInteraction
| SelectMenuInteraction
];
trackAdd: [

@@ -36,5 +81,26 @@ queue: queue,

user: User | GuildMember,
tracks: Track[]
tracks: Track[],
requestedSource:
| Message
| CommandInteraction
| ButtonInteraction
| SelectMenuInteraction
];
connectionError: [queue: queue];
connectionError: [
queue: queue,
requestedSource:
| Message
| CommandInteraction
| ButtonInteraction
| SelectMenuInteraction
];
channelEmpty: [
queue: queue,
channel: VoiceChannel,
requestedSource:
| Message
| CommandInteraction
| ButtonInteraction
| SelectMenuInteraction
];
}

@@ -41,0 +107,0 @@ declare class player extends EventEmitter {

@@ -1,2 +0,9 @@

import { User } from "discord.js";
import {
User,
VoiceBasedChannel,
Message,
CommandInteraction,
ButtonInteraction,
SelectMenuInteraction,
} from "discord.js";

@@ -26,2 +33,10 @@ export type eventOptions = {

delayTimeout?: Number | 0;
leaveOn: {
end: number | Boolean | false | 0;
empty: number | Boolean | false | 0;
bot: number | Boolean | false | 0;
};
anyoneCanMoveClient: Boolean | true;
altVoiceChannel: string | number | VoiceBasedChannel;
forceDestroy: Boolean | false;
};

@@ -47,4 +62,10 @@

public readonly author: object;
public readonly metadata: any;
public readonly user: User;
public get raw(): object;
public get requestedSource():
| Message
| CommandInteraction
| ButtonInteraction
| SelectMenuInteraction;
public get user(): User;
public get metadata(): object;
public get type(): string | "playlist";

@@ -67,4 +88,10 @@ }

public readonly lyrics: string;
public readonly user: User;
public get raw(): object;
public get requestedSource():
| Message
| CommandInteraction
| ButtonInteraction
| SelectMenuInteraction;
public get user(): User;
public get metadata(): object;
public get type(): string | "track";

@@ -71,0 +98,0 @@ }

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