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?
Hello @Milo123459,
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.))
Hello, @Milo123459
You can make an endpoint in your bot’s code: (I’m using express
here):
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?
@Milo123459 What @jarvis394 Is saying means you would have to host the bot and make your IP public. It is easier if you host you bot in the same project as the website.
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.
@Milo123459 Can you message me the edit link so I can fix somethings.
Look at this post, Discord bot not coming online.
You can easily host your bot on Glitch; just create a new project!
@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