Getting votes via a local webserver
Installation
npm i express
pip install Quart
soon
Setting up a webserver
const express = require("express")
var bodyParser = require('body-parser')
const port = "YOUR_PORT"
const app = express()
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({
extended: true
}));
app.post("/votewebhook", async (req, res) => {
console.log(req.body)
res.sendStatus(201)
})
app.listen(port, ()=>{
console.log("running on port ", port)
})
from quart import Quart, request
app = Quart(__name__)
@app.route("/votewebhook", methods=['POST']) # Path where the vote will go. Do not change anything else.
async def webhook():
if request.method == "POST":
data = await request.get_data()
print(data) # The vote data, after this line you can insert your code like for example insert a message in a channel
return "201", 201
else:
return "403", 403
host = "HOST_IP" # IP from your Server/Host
port = PORT_NUMBER # PORT
if __name__ == "__main__":
app.run(port=port, host=host)
Soon
Response
A response will look like this:
{
user: {
id: '123456789101112131',
username: 'User',
discriminator: '0000'
},
bot: {
id: '123456789101112131',
votes: [
'2021-08-03T10:27:10.330Z',
...,
]
}
}
Last updated