diff --git a/src/Player.ts b/src/Player.ts index 0b90b08..9cbd4fd 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -29,6 +29,7 @@ class Player extends EventEmitter { public readonly queues = new Collection(); public readonly voiceUtils = new VoiceUtils(); public readonly extractors = new Collection(); + public requiredEvents = ["error", "connectionError"] as string[]; /** * Creates new Discord Player @@ -552,12 +553,25 @@ class Player extends EventEmitter { scanDeps() { const line = "-".repeat(50); const depsReport = generateDependencyReport(); - const extractorReport = this.extractors.map((m) => { - return `${m.name} :: ${m.version || "0.1.0"}`; - }).join("\n"); + const extractorReport = this.extractors + .map((m) => { + return `${m.name} :: ${m.version || "0.1.0"}`; + }) + .join("\n"); return `${depsReport}\n${line}\nLoaded Extractors:\n${extractorReport || "None"}`; } + emit(eventName: U, ...args: Parameters): boolean { + if (this.requiredEvents.includes(eventName) && !super.eventNames().includes(eventName)) { + // eslint-disable-next-line no-console + console.error(...args); + process.emitWarning(`[DiscordPlayerWarning] Unhandled "${eventName}" event! Events ${this.requiredEvents.map(m => `"${m}"`).join(", ")} must have event listeners!`); + return false; + } else { + return super.emit(eventName, ...args); + } + } + /** * Resolves queue * @param {GuildResolvable|Queue} queueLike Queue like object