Discord Bot "Dashboard"


#1

So I’m really having trouble making this. On a html file there is a simple little “form”, I want to make it so when I click send it tell’s the index.js script to do some code(I’ve tried linking the index.js with the html and using onclick but the index.js is the starting script for the whole bot)


#2

In the HTML you want to tell the form to POST to a particular URL e.g.

<form action="/dreams" method="post">
<input name="dream" type="text" />

and then in your index.js file, using Express, define a route to handle it e.g.

app.post("/dreams", function (request, response) {
  dreams.push(request.query.dream);
  response.sendStatus(200);
});

In this case it’s appending whatever you’ve put in the ‘dream’ input box to an array on the server-side called ‘dreams’, but you can replace that with whatever code it is you want.