Update shell
This commit is contained in:
parent
1612a1f4c8
commit
fa7d8ae3fa
|
@ -123,12 +123,6 @@
|
||||||
"description": "The command to run",
|
"description": "The command to run",
|
||||||
"type": 3,
|
"type": 3,
|
||||||
"required": true
|
"required": true
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "timeout",
|
|
||||||
"description": "The timeout for the command if it doesn't return (in seconds). Default is none!",
|
|
||||||
"type": 4,
|
|
||||||
"required": false
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
13
index.js
13
index.js
|
@ -1245,24 +1245,25 @@ dcClient.on('interactionCreate', async interaction => {
|
||||||
ephemeral: true
|
ephemeral: true
|
||||||
});
|
});
|
||||||
let cmd3 = interaction.options.get("command").value;
|
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) => {
|
sshConn.exec(cmd3, (err, stream) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
interaction.editReply(`Error running command: ${err}`);
|
interaction.editReply(`Error running command: ${err}`);
|
||||||
sendLog(`${colors.red("[ERROR]")} ${err}`);
|
sendLog(`${colors.red("[ERROR]")} ${err}`);
|
||||||
}
|
}
|
||||||
// if timeout is set, set a timeout before
|
// if timeout is set, set a timeout before
|
||||||
timeout = setTimeout(() => {
|
//timeout = setTimeout(() => {
|
||||||
stream.close();
|
// stream.close();
|
||||||
interaction.editReply(`Command timed out after ${cmd3timeout}ms`);
|
// interaction.editReply(`Command timed out after ${cmd3timeout}ms`);
|
||||||
})
|
//})
|
||||||
outputStream = ""
|
outputStream = ""
|
||||||
stream.on("data", (data) => {
|
stream.on("data", (data) => {
|
||||||
outputStream += `${data}`
|
outputStream += `${data}`
|
||||||
})
|
})
|
||||||
stream.on('exit', (code, signal) => {
|
stream.on('exit', (code, signal) => {
|
||||||
// clear the timeout
|
// clear the timeout
|
||||||
clearTimeout(timeout);
|
//clearTimeout(timeout);
|
||||||
// generate message json
|
// generate message json
|
||||||
const msgJson = {
|
const msgJson = {
|
||||||
content: `Ran command \`${cmd3}\`\n\`\`\`ansi\n${outputStream}\`\`\``
|
content: `Ran command \`${cmd3}\`\n\`\`\`ansi\n${outputStream}\`\`\``
|
||||||
|
|
Loading…
Reference in a new issue