jericho-player
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "jericho-player", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "LightWeight Framework for discord.js v13 Music Bots and Radio Bots with fast moderation with commands and no memory leak", | ||
@@ -28,3 +28,3 @@ "main": "./src/index.js", | ||
"devDependencies": { | ||
"@babel/eslint-parser": "^7.16.0", | ||
"@babel/eslint-parser": "^7.16.3", | ||
"@babel/preset-env": "^7.16.0", | ||
@@ -31,0 +31,0 @@ "cz-conventional-changelog": "^3.3.0", |
@@ -116,8 +116,12 @@ const EventEmitter = require('events'); | ||
} | ||
this.emit( | ||
'botDisconnect', | ||
QueueInstance, | ||
OldVoiceState.channel ?? undefined, | ||
); | ||
return this.DeleteQueue(QueueInstance.guildId); | ||
if (QueueInstance && !QueueInstance.destroyed) { | ||
this.emit( | ||
'botDisconnect', | ||
QueueInstance, | ||
OldVoiceState.channel ?? undefined, | ||
); | ||
} | ||
return QueueInstance && QueueInstance.guildId | ||
? this.DeleteQueue(QueueInstance.guildId) | ||
: undefined; | ||
} | ||
@@ -319,3 +323,7 @@ if ( | ||
); | ||
if (QueueInstance && QueueInstance.destroyed && typeof QueueInstance.destroyed !== 'boolean') clearTimeout(QueueInstance.destroyed); | ||
if ( | ||
QueueInstance | ||
&& QueueInstance.destroyed | ||
&& typeof QueueInstance.destroyed !== 'boolean' | ||
) clearTimeout(QueueInstance.destroyed); | ||
QueueInstance.destroyed = false; | ||
@@ -343,6 +351,7 @@ Player.#QueueCaches[`${guildId}`] = QueueInstance; | ||
const Garbage = {}; | ||
Garbage.Structure = QueueInstance; | ||
QueueInstance = null; | ||
Player.#QueueCaches[`${guildId}`] = null; | ||
delete Garbage.Structure; | ||
QueueInstance = Player.#QueueCaches[`${guildId}`] = undefined; | ||
Garbage.container1 = QueueInstance; | ||
Garbage.container2 = Player.#QueueCaches[`${guildId}`]; | ||
delete Garbage.container1; | ||
delete Garbage.container2; | ||
return void null; | ||
@@ -349,0 +358,0 @@ } |
@@ -811,3 +811,3 @@ const { | ||
* @param {DefaultQueueCreateOptions|void} SearchOptions Stream Options for Query Processing | Same as Queue Creation and Play Method | ||
* @returns {Promise<Objectundefined>|void} Returns Tracks if operation emits green signal or undefined for errors | ||
* @returns {Promise<Object>|void} Returns Tracks if operation emits green signal or undefined for errors | ||
*/ | ||
@@ -814,0 +814,0 @@ async search( |
const { | ||
User, Client, VoiceChannel, StageChannel, | ||
} = require('discord.js'); | ||
const { AudioResource, PlayerSubscription } = require('@discordjs/voice'); | ||
const { | ||
AudioResource, | ||
PlayerSubscription, | ||
VoiceConnection, | ||
} = require('@discordjs/voice'); | ||
const Queue = require('../Handlers/Queue'); | ||
const Player = require('../Handlers/Player'); | ||
@@ -359,2 +365,59 @@ /** | ||
/** | ||
* @typedef {Object} DefaultPlayerEvents | ||
* @property {Object} error Player Error Events and should be handled Properly | ||
* @property {Object} channelEmpty When Noone is there in Channel | ||
* @property {Object} botDisconnect If Bot got disconnected from Voice Channel | ||
* @property {Object} trackEnd Event for Song got Ended Perfectly | ||
* @property {Object} trackStart Event for Starting of Songs | ||
* @property {Object} connectionError Connection Error for Join Channel Configs and Methods | ||
* @property {Boolean} playlistAdd Event for if Playlist has been Parsed and Tracks will be returned | ||
* @property {Object} tracksAdd Event for Tracks Added currently if playlist got stuck and even single Track will also emit this event | ||
*/ | ||
const DefaultPlayerEvents = { | ||
error: { | ||
message: '', | ||
queue: Queue || Player || undefined, | ||
extradata: undefined, | ||
}, | ||
channelEmpty: { | ||
queue: Queue, | ||
voiceChannel: VoiceChannel || StageChannel || undefined, | ||
}, | ||
botDisconnect: { | ||
queue: Queue, | ||
voiceChannel: VoiceChannel || StageChannel || undefined, | ||
}, | ||
trackEnd: { | ||
queue: Queue, | ||
track: DefaultTrack, | ||
}, | ||
trackStart: { | ||
queue: Queue, | ||
track: DefaultTrack, | ||
}, | ||
connectionError: { | ||
message: '', | ||
queue: Queue, | ||
connection: VoiceConnection || undefined, | ||
guildId: String, | ||
}, | ||
playlistAdd: { | ||
queue: Queue, | ||
tracks: [DefaultTrack], | ||
}, | ||
tracksAdd: { | ||
queue: Queue, | ||
tracks: [DefaultTrack], | ||
}, | ||
}; | ||
module.exports = { | ||
@@ -378,2 +441,3 @@ DefaultQueueCreateOptions, | ||
DefaultcurrentTimestamp, | ||
DefaultPlayerEvents, | ||
}; |
@@ -13,3 +13,5 @@ import { | ||
QueueOptions, | ||
DefaultModesTypes | ||
DefaultModesTypes, | ||
PlayerEvents, | ||
Awaitable | ||
} from './instances' | ||
@@ -19,2 +21,3 @@ import { VoiceConnection } from '@discordjs/voice' | ||
export class Player extends EventEmitter { | ||
@@ -30,2 +33,8 @@ public constructor (Client: Client, PlayerOptions?: PlayerOptions) | ||
public DeleteQueue (guildId: Guild['id'] | Snowflake | String): undefined | ||
public on<K extends keyof PlayerEvents>(event: K, listener: (...args: PlayerEvents[K]) => Awaitable<void>): this; | ||
public on<S extends string | symbol>( | ||
event: Exclude<S, keyof PlayerEvents>, | ||
listener: (...args: any[]) => Awaitable<void>, | ||
): this; | ||
} | ||
@@ -32,0 +41,0 @@ |
@@ -14,2 +14,3 @@ import { | ||
Snowflake, | ||
StageChannel, | ||
User, | ||
@@ -20,6 +21,2 @@ VoiceChannel | ||
/** | ||
* | ||
*/ | ||
export type Queue = { | ||
@@ -107,8 +104,8 @@ readonly Client: Client | ||
| { | ||
CompleteIcon: String | '▬' | ||
TargetIcon: String | '🔘' | ||
RemainingIcon: String | '▬' | ||
StartingIcon: String | undefined | ||
EndIcon: String | undefined | ||
} | ||
CompleteIcon: String | '▬' | ||
TargetIcon: String | '🔘' | ||
RemainingIcon: String | '▬' | ||
StartingIcon: String | undefined | ||
EndIcon: String | undefined | ||
} | ||
| undefined | ||
@@ -195,8 +192,8 @@ ): String | undefined | ||
readonly orignal_extractor: | ||
| String | ||
| 'youtube' | ||
| 'spotify' | ||
| 'soundcloud' | ||
| 'facebook' | ||
| 'arbitrary' | ||
| String | ||
| 'youtube' | ||
| 'spotify' | ||
| 'soundcloud' | ||
| 'facebook' | ||
| 'arbitrary' | ||
readonly thumbnail: String | ||
@@ -273,1 +270,40 @@ readonly channelId: String | Number | ||
} | ||
export type Awaitable<T> = T | PromiseLike<T> | ||
export interface PlayerEvents { | ||
error: [ | ||
message: string, | ||
queue: Queue | Player | undefined, | ||
extradata: any | undefined, | ||
] | ||
channelEmpty: [ | ||
queue: Queue, | ||
voiceChannel: VoiceChannel | StageChannel | undefined, | ||
] | ||
botDisconnect: [ | ||
queue: Queue, | ||
voiceChannel: VoiceChannel | StageChannel | undefined, | ||
] | ||
trackEnd: [ | ||
queue: Queue, | ||
track: Track, | ||
] | ||
trackStart: [ | ||
queue: Queue, | ||
track: Track, | ||
] | ||
connectionError: [ | ||
message: string, | ||
queue: Queue, | ||
connection: VoiceConnection | undefined, | ||
guildId: String | Snowflake, | ||
] | ||
playlistAdd: [ | ||
queue: Queue, | ||
tracks: Track[], | ||
] | ||
tracksAdd: [ | ||
queue: Queue, | ||
tracks: Track[], | ||
] | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
136914
3805