Answer the question
In order to leave comments, you need to log in
How to make discord bot show website status?
Good afternoon, how can I make the discord bot send the status about the site?
Let's say there is google.com, you need that when you write a command (for example: !status ) it shows the website's response time, etc.
And for example, when the site went down, it was written that the server was not online, etc.
But the problem is that the site does not have a status page, etc., and you need to get information from somewhere.
Answer the question
In order to leave comments, you need to log in
rama_jecboom , make a curl request to the desired site, if it responds with 200 status, then the site is available.
For example, you hang a handler on the !status command, where name is the resource whose status is to be found out.
You must also have a json file, or some other file or source of information with site names and their urls, for example:
/* urlBase.json */
[
{
"name": "google",
"url": "https://google.com"
},
{
"name": "vk",
"url": "https://vk.com"
}
]
/* ... */
import urlBase from "./urlBase.json"
/*...*/
const targetSite = urlBase.find( e => e.name === name )
return getTargetSiteStatus(targetSite)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question