Update shell

This commit is contained in:
Christopher Cookman 2024-03-24 04:10:15 -06:00
parent 1612a1f4c8
commit fa7d8ae3fa
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42
2 changed files with 7 additions and 12 deletions

View file

@ -123,12 +123,6 @@
"description": "The command to run",
"type": 3,
"required": true
},
{
"name": "timeout",
"description": "The timeout for the command if it doesn't return (in seconds). Default is none!",
"type": 4,
"required": false
}
]
},

View file

@ -1245,24 +1245,25 @@ dcClient.on('interactionCreate', async interaction => {
ephemeral: true
});
let cmd3 = interaction.options.get("command").value;
let cmd3timeout = interaction.options.get("timeout").value;
// TODO: Timeout
//let cmd3timeout = interaction.options.get("timeout").value;
sshConn.exec(cmd3, (err, stream) => {
if (err) {
interaction.editReply(`Error running command: ${err}`);
sendLog(`${colors.red("[ERROR]")} ${err}`);
}
// if timeout is set, set a timeout before
timeout = setTimeout(() => {
stream.close();
interaction.editReply(`Command timed out after ${cmd3timeout}ms`);
})
//timeout = setTimeout(() => {
// stream.close();
// interaction.editReply(`Command timed out after ${cmd3timeout}ms`);
//})
outputStream = ""
stream.on("data", (data) => {
outputStream += `${data}`
})
stream.on('exit', (code, signal) => {
// clear the timeout
clearTimeout(timeout);
//clearTimeout(timeout);
// generate message json
const msgJson = {
content: `Ran command \`${cmd3}\`\n\`\`\`ansi\n${outputStream}\`\`\``