Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

130
Views
Opening file with js

I'm trying to make a discord.js bot which whenever someone types a certain command on Discord, it opens a program on my PC:

client.on("message", (message) => {
    if (message.content == "!ping") {
        //here I want to open a program on my pc 
    }
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Assuming you are using Node you can include the execFile function from the child_process package and just call it from the command line.

const { execFile } = require("child_process");
client.on("message", (message) => {
    if(message.content == "!ping") {
         execFile("<path to file>", ["optional arg1", "optional arg2"]);
    }
});

Or if you just want to run a command, just exec

const { exec } = require("child_process");
client.on("message", (message) => {
    if(message.content == "!ping") {
         exec("<shell command>", ["optional arg1", "optional arg2"]);
    }
});

Check out https://nodejs.org/api/child_process.html#child_processexeccommand-options-callback for documentation.

You may need to "npm install child_process"

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!