user14925918
user14925918

Reputation:

Discord.JS Start and Stopping the bot

I'm trying to make an electron control panel so I made 2 buttons one to start and stop the bot but I've been trying for a week and I've not gotten a way to stop the bot without making a child process coz making child processes give lots of problems so yeah any help? I've tried client.destroy() but after running client.destroy() even if i make client into new Discord.Client again it still doesn't work so yeah any help?

Upvotes: 0

Views: 3614

Answers (2)

Justaus3r
Justaus3r

Reputation: 423

As @swift gaming said you can automate the task using a batch file ,but you will have to install node js.assuming you already have node js (if not then install from following link) ,i have modified his script a little bit and here it is(not tested):

@echo off
color 0c
echo 1:Start
echo 2:Stop
set /p var = Choose your option:
if '%var%' == '1' goto start
if '%var%' == '2' goto stop
:start
cd "botfilepath"
node bot.js
echo Started
goto :eof
:stop
cd "botfilepath"
killall node
echo Stopped
goto :eof

Upvotes: -1

swift gaming
swift gaming

Reputation: 142

if you are using the discord.js library you can just start and stop the bot using node I would just make 2 batch files and name one start and one stop and do this inside the files start.bat

cd "botfilepath"
node bot.js

stop.bat

cd "botfilepath"
killall node

Upvotes: -1

Related Questions