Skip to content

Instantly share code, notes, and snippets.

@weskerty
Last active February 2, 2025 06:54
Show Gist options
  • Save weskerty/b1547a15f59e554d78620b781318b43b to your computer and use it in GitHub Desktop.
Save weskerty/b1547a15f59e554d78620b781318b43b to your computer and use it in GitHub Desktop.
// Original: https://gist.github.com/adityaparsad01/454bfaee41fd8eab580b2a3d1cb3aba6
const lib = require("../lib");
const { exec } = require("child_process");
lib.bot(
{
pattern: "cmd ?(.*)",
fromMe: true,
desc: "get linux machine",
type: "machine"
},
async (message, match) => {
const command = match || "ls";
exec(command, (error, stdout, stderr) => {
const response = `${stdout.trim() || ""}\n` +
`⚠️${stderr.trim() || ""}\n` +
`❌ ${error ? error.message : ""}`;
return message.send(response);
});
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment