I want send bot statistics to my website

I want send bot statistics to my website;

however, I cannot use require in the script file.

how can i get it?

You need to expose the information through an API, or you could use a template engine and expose the information through variables.

Can you explain more about what I should use?

You can use express and do something like this:

app.get("/api/client/users", (req, res) => res.status(200).end(client.users.size.toString()));

If I send you an edit, can you prepare 1 sample for me please?

I don’t really have the time atm, but you can google something like “how to make an express api”

1 Like

thanks you very much :))

how can i show this source on my html page?

What?

You can use the Fetch API to fetch the data.

For example:

fetch("/api/client/users")
  .then(response => response.json())
  .then(users => console.log(users))
  .catch(error => console.error(error));

How can I show this number on the site by fetch?

fetch("/api/client/users")

.then(response => {

var kullanıcılar = document.getElementById(response)

})
<div id="clientusers">Please wait, fetching amount of users...</div>
fetch("/api/client/users")
  .then(response => response.json())
  .then(users => document.getElementById("clientusers").innerText = users.toString())
  .catch(error => document.getElementById("clientusers").innerText = "Failed to get the amount of users: " + error.message);
3 Likes

you are best…Thx for your support

No problem! Happy to help, as always!