Initial update to ALSA
This commit is contained in:
22
Client/discord-bot/utilities/executeConsoleCommand.js
Normal file
22
Client/discord-bot/utilities/executeConsoleCommand.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// Modules
|
||||
import { promisify } from 'util';
|
||||
// Debug
|
||||
import ModuleDebugBuilder from "../utilities/moduleDebugBuilder.js";
|
||||
// Global Vars
|
||||
const log = new ModuleDebugBuilder("bot", "executeConsoleCommand");
|
||||
const exec = promisify(require('child_process').exec);
|
||||
|
||||
|
||||
exports.executeAsyncConsoleCommand = (consoleCommand) => {
|
||||
// Check to see if the command is a real command
|
||||
// TODO needs to be improved
|
||||
const acceptableCommands = [ "arecord -L" ];
|
||||
if (!acceptableCommands.includes(consoleCommand)) {
|
||||
log.WARN("Console command is not acceptable: ", consoleCommand);
|
||||
return undefined;
|
||||
}
|
||||
const tempOutput = exec();
|
||||
|
||||
// TODO add some error checking
|
||||
return tempOutput.stdout.trim();
|
||||
}
|
||||
Reference in New Issue
Block a user