style: run format:apply

This commit is contained in:
2026-01-13 17:50:33 -03:00
parent 02949e8b16
commit 83569a27e7
+28 -16
View File
@@ -1,8 +1,14 @@
import { AudioPlayer, createAudioPlayer, createAudioResource, StreamType, VoiceConnection } from "@discordjs/voice"; import {
import { AudioMixer } from "node-audio-mixer"; AudioPlayer,
import { PassThrough, Readable } from "stream"; createAudioPlayer,
createAudioResource,
StreamType,
VoiceConnection
} from '@discordjs/voice';
import { AudioMixer } from 'node-audio-mixer';
import { PassThrough, Readable } from 'stream';
import prism from "prism-media"; import prism from 'prism-media';
export class StreamQueue { export class StreamQueue {
private queue: Readable[] = []; private queue: Readable[] = [];
@@ -29,7 +35,7 @@ export class StreamQueue {
await this.mixer.playStream(nextStream); await this.mixer.playStream(nextStream);
} }
} catch (e) { } catch (e) {
console.error("Queue error:", e); console.error('Queue error:', e);
} finally { } finally {
this.isPlaying = false; this.isPlaying = false;
this.processQueue(); this.processQueue();
@@ -65,7 +71,7 @@ export class MixedStream {
sampleRate: 48000, sampleRate: 48000,
bitDepth: 16, bitDepth: 16,
volume: 100 volume: 100
}) });
const chunk = Buffer.alloc(3840); const chunk = Buffer.alloc(3840);
this.silenceInterval = setInterval(() => { this.silenceInterval = setInterval(() => {
@@ -82,7 +88,7 @@ export class MixedStream {
}); });
this.player.play(resource); this.player.play(resource);
this.player.on('error', error => { this.player.on('error', (error) => {
console.error('Error: ', error.message); console.error('Error: ', error.message);
}); });
} }
@@ -102,17 +108,22 @@ export class MixedStream {
channels: 2, channels: 2,
sampleRate: 48000, sampleRate: 48000,
bitDepth: 16, bitDepth: 16,
volume: 100, volume: 100
}); });
const transcoder = new prism.FFmpeg({ const transcoder = new prism.FFmpeg({
args: [ args: [
'-analyzeduration', '0', '-analyzeduration',
'-loglevel', '0', '0',
'-f', 's16le', '-loglevel',
'-ar', '48000', '0',
'-ac', '2', '-f',
], 's16le',
'-ar',
'48000',
'-ac',
'2'
]
}); });
let totalBytes = 0; let totalBytes = 0;
@@ -130,7 +141,7 @@ export class MixedStream {
transcoder.destroy(); transcoder.destroy();
resolve(); resolve();
}, durationMs); }, durationMs);
}) });
transcoder.on('error', () => { transcoder.on('error', () => {
this.mixer.removeAudioinput(mixerInput); this.mixer.removeAudioinput(mixerInput);
@@ -176,7 +187,8 @@ export class AudioStreamManager {
static #instance: AudioStreamManager | null = null; static #instance: AudioStreamManager | null = null;
public static get get(): AudioStreamManager { public static get get(): AudioStreamManager {
if (!AudioStreamManager.#instance) AudioStreamManager.#instance = new AudioStreamManager(); if (!AudioStreamManager.#instance)
AudioStreamManager.#instance = new AudioStreamManager();
return AudioStreamManager.#instance; return AudioStreamManager.#instance;
} }
} }