47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
const { exec } = require('child_process');
|
|
|
|
const pool = global.pool
|
|
const fpbx = global.fpbx
|
|
const client = global.client
|
|
const log = global.log
|
|
|
|
|
|
const runCommand = (command) => {
|
|
return new Promise((resolve, reject) => {
|
|
require('child_process').exec(command, (error, stdout, stderr) => {
|
|
if (error) {
|
|
reject(`error: ${error.message}`);
|
|
return;
|
|
}
|
|
if (stderr) {
|
|
reject(`stderr: ${stderr}`);
|
|
return;
|
|
}
|
|
resolve(stdout);
|
|
});
|
|
});
|
|
}
|
|
|
|
module.exports = {};
|
|
|
|
module.exports.execute = async (interaction) => {
|
|
const subcommand = interaction.options.getSubcommand();
|
|
|
|
switch (subcommand) {
|
|
case 'silence': // Run `asterisk -x "channel request hangup all"
|
|
runCommand('asterisk -x "channel request hangup all"').then((res) => {
|
|
interaction.reply({ content: `Silenced`, ephemeral: true });
|
|
});
|
|
break;
|
|
case 'reload': // Run `fwconsole reload`
|
|
runCommand('fwconsole reload').then((res) => {
|
|
interaction.reply({ content: res, ephemeral: true });
|
|
});
|
|
break;
|
|
case 'reboot': // Run `reboot 0`
|
|
runCommand('reboot 0').then((res) => {
|
|
interaction.reply({ content: "Rebooting...", ephemeral: true });
|
|
});
|
|
break;
|
|
}
|
|
} |