Skip to content

Discord bot that can run batch files on the deployed server! Can also take in input and push output from/to Discord!!

Notifications You must be signed in to change notification settings

Zo-Bro-23/batch-file-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

batch-file-bot

Discord bot that can run batch files on the deployed server! Can also take in input and push output from/to Discord!!

Instructions to run: Download the files and extract the ZIP to a folder. Navigate to the folder on your terminal. Run the following commands:

npm i
npm i -g nodemon

Now create a file called cred.json in the same folder as the other files (index.js, package.json, etc) and edit it using the following syntax:

{
    "token": "xxxx-your-discord-bot-token-xxx"
}

All done? Great! Now edit the options.json to configure your batch files! Here is the syntax:

{
    "commands": [ // array of all commands
        {
            "type": "message", // leave the type as message for now - I will add more types such as slash commands in the future
            "trigger": "!run", // the trigger for the command
            "replies": { // replies to send with various stages in the batch file execution - leave blank string to not send any reply
                "replyOnSpawn": "Running simple batch script! Reply to this message to get an echo!", // reply when batch file is spawned
                "replyOnFinish": "", // reply when batch file closes - add {{$code}} to insert exit code
                "replyOnError": "Error: {{$error}}", // reply on server error - path wrong, etc. - add {{$error}} to insert error message
                "replyOnStderr": "{{$stderr}}", // reply on stderr - error generated within the batch file - add {$stderr}} to insert the error message
                "replyOnStdout": "{{$stdout}}", // reply on stdout - output generated by the batch file - add {{$stdout}} to insert the output message
                "replyToStdin": [
                    "SPAWN", // which messages should the user reply to in order to input text into the batch file - for example: SPAWN means that if the user replies to the replyOnSpawn message, it will go as input to the batch file
                    "STDOUT"
                ]
            },
            "preventFromSimultaneousExecution": true, // whether user should be able to run the same batch file multiple times simultaneously
            "filter": {
                "type": "none", // none, exclusive or exception - exclusive means only specified users should be able to run command, exception means all users except specified users should be able to run command - none means anybody can run command
                "users": [
                    "xxxxxxxxxxxxxxxxxx" // userId of users for the above specified filter - enable developer mode in Discord to copy user id
                ]
            },
            "batchFile": "D:\\Documents\\My Stuff\\batch-file-bot\\{{$userId}}-run.bat" // full path of batch file to run - can use {{$username}}, {{$discriminator}}, {{$userId}} to insert variables into the path
        }
    ]
}

And last but not least, run the following command to start the server:

nodemon index.js

The server should automatically restart if either index.js or options.json changes, but type in rs to restart otherwise.

About

Discord bot that can run batch files on the deployed server! Can also take in input and push output from/to Discord!!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published