Hey! So I have a discord bot running in Visual Studio Code and I’m making a site in glitch, but I’m trying to get a value from visual studio code (a variable) into a header on my site, does anyone know how?
Unless you are using the extension, there is no way to connect the bot to Glitch. (Unless, you know, you write it again or you are using a package of some sort, but that is impossible.(I think.))
You can make an endpoint in your bot’s code: (I’m using
require('express')().get('/myVariable', (_, res) => res.send(myVariable)).listen(3000)
Then make a request on the client side:
const variable = await fetch('bot.com/myVariable') header.innerHTML = variable
Ok, im pretty new at this, can you give some more detail please?
Could i use glitch as the site?
So if i put my bot on a vps then leave a glitch website up like what jarvis did, could i fetch that data from the glitch project into a website?
Basically. It is easier on the same project.
You can easily host your bot on Glitch; just create a new project!
@jarvis394 He can do it in the same prject.
@jarvis394 require(‘express’)().get(’/myVariable’, (_, res) => res.send(myVariable)).listen(3000)
That sends it right? Also where it says .get(/myVariable’) is that the site it will send it to
Also, how do i make it so it posts and gets it every 5 mins
You might have a
setInterval on your client side which runs the request and updates the value
Alright where do i put the site i want to post it to @jarvis394