diff --git a/Client/discord-bot/commands/join.js b/Client/discord-bot/commands/join.js index dc0eded..292ea9a 100644 --- a/Client/discord-bot/commands/join.js +++ b/Client/discord-bot/commands/join.js @@ -39,7 +39,7 @@ export default async function join({interaction= undefined, guildID= undefined, selfDeaf: false, }); - const audioInstance = createAudioInstance(); + const audioInstance = await createAudioInstance(); audioInstance.on('data', buffer => { buffer = Buffer.from(buffer); diff --git a/Client/discord-bot/controllers/audioController.js b/Client/discord-bot/controllers/audioController.js index 124c77d..60435af 100644 --- a/Client/discord-bot/controllers/audioController.js +++ b/Client/discord-bot/controllers/audioController.js @@ -16,8 +16,8 @@ const log = new ModuleDebugBuilder("bot", "audioController"); * @param deviceId The ID of the device being queried * @returns {unknown} */ -export function confirmAudioDevice({deviceName = undefined, deviceId = undefined}){ - const deviceList = getAudioDevices(); +export async function confirmAudioDevice({deviceName = undefined, deviceId = undefined}){ + const deviceList = await getAudioDevices(); if (!deviceName && !deviceId) throw new Error("No device given"); if (deviceId) return deviceList.find(device => device.id === deviceId); if (deviceName) return deviceList.find(device => device.name === deviceName); @@ -28,9 +28,9 @@ export function confirmAudioDevice({deviceName = undefined, deviceId = undefined * * @returns {unknown[]} */ -export function getAudioDevices(){ +export async function getAudioDevices(){ // Exec output contains both stderr and stdout outputs - const deviceList = executeAsyncConsoleCommand("arecord -L"); + const deviceList = await executeAsyncConsoleCommand("arecord -L"); log.DEBUG("Device list: ", deviceList); } @@ -40,8 +40,8 @@ export function getAudioDevices(){ * * @returns new portAudio.AudioIO */ -export function createAudioInstance() { - const selectedDevice = confirmAudioDevice({deviceId: getDeviceID()});//{deviceName: "VoiceMeeter VAIO3 Output (VB-Au"}); +export async function createAudioInstance() { + const selectedDevice = await confirmAudioDevice({deviceId: getDeviceID()});//{deviceName: "VoiceMeeter VAIO3 Output (VB-Au"}); log.DEBUG("Device selected from config: ", selectedDevice); // Create an instance of AudioIO with outOptions (defaults are as below), which will return a WritableStream return new alsaInstance({