Update DAB to include dynamic settings
- Settings will now get the active device(s) available on Linux (UNTESTED) - Added CLI handler for interacting with the CLI - Added wrapper for extracting values with regex -
This commit is contained in:
@@ -17,7 +17,8 @@ import { Client, Events, ActivityType } from 'discord.js';
|
||||
import prism_media from 'prism-media';
|
||||
const { FFmpeg } = prism_media;
|
||||
|
||||
const device = "VoiceMeeter VAIO3 Output (VB-Audio VoiceMeeter VAIO3)", maxTransmissionGap = 500, type = "dshow";
|
||||
// Import the DAB settings from the dynamic settings file
|
||||
import {device, maxTransmissionGap, type} from './dabSettings.mjs'
|
||||
|
||||
const player = createAudioPlayer({
|
||||
behaviors: {
|
||||
|
||||
18
client/discordAudioBot/dabSettings.mjs
Normal file
18
client/discordAudioBot/dabSettings.mjs
Normal file
@@ -0,0 +1,18 @@
|
||||
import { executeCommand } from '../modules/cliHandler.mjs';
|
||||
import { extractValue } from '../modules/baseUtils.mjs';
|
||||
import os from 'os';
|
||||
|
||||
// Defaults to Windows values for testing
|
||||
let device = "VoiceMeeter VAIO3 Output (VB-Audio VoiceMeeter VAIO3)";
|
||||
let maxTransmissionGap = 500;
|
||||
let type = "dshow";
|
||||
|
||||
// Set Linux values for use in production
|
||||
if (os.platform() === 'linux') {
|
||||
await executeCommand("pactl", ['list', 'short', 'sources']).then(cliOutput => {
|
||||
device = extractValue(cliOutput, '(?:\d[ ]{4,12}(.+?)[ ]{4,12}(?:.+?[ ]{4,12}){2,4}RUNNING)')
|
||||
});
|
||||
type = "pulse"; // Replace with appropriate type for Linux
|
||||
}
|
||||
|
||||
export { device, maxTransmissionGap, type };
|
||||
Reference in New Issue
Block a user