#topgg-api
1 messages · Page 185 of 1
ty
Wdym? Do you need a way to get notified about votes?
there's not
Hm.
yes, I want that when the person votes, he already sends a message in the logs channel and seven 12,500 reais (bot currency)
I can't find this Script and what I tried to do didn't work
Assuming you are using javascript you can look into https://docs.top.gg/libraries/javascript/
It has all the info you need
just change the console.log to set and send the message?
You can do whatever you want after you receive the event
@solid imp do I put this vote event in the messageCreate event or drop it in the Index?
index
sorry for the ping, can you tell me how much time it will take to show server count, after posting it?
When I tried it myself, I looked after 1 day and it was showing. I don't know exactly how long it takes but i am sure it doesn't take longer than 1 day to show.
ok ty
np
Index file preferably, you wouldn’t want it to register for every message create event you receive
what do i put in the const webhook = new Topgg.Webhook("")?
I voted and didn't send the webhook
You need to make sure you have added a valid endpoint on your bot vote page
@restive otterplease dont include your secret in your code sent here
const Topgg = require("@top-gg/sdk")
const express = require("express")
const app = express()
const webhook = new Topgg.Webhook("token here")
app.post("/dblwebhook", webhook.listener(async (vote) => {
// vote will be your vote object, e.g
const canal = client.channels.cache.get('996153237918978228')
const user = client.users.cache.get(vote.user)
const userdb = await client.userdb.findOne({
userID: user.id
})
await client.userdb.updateOne({
userID: user.id
}, { $set: {
"economia.votos": userdb.economia.votos + 1,
"economia.money": userdb.economia.votos + 12500
}})
const embed = new Discord.MessageEmbed()
.setTitle('Sucesso')
.setDescription(`**${user.tag} \`(${user.id})\`** recebeu **12,500 ZyaCoins** e o cargo <@&996153127579426967> por votar em mim!\n> Vote você também em **top.gg** [[ Clique aqui! ]](https://top.gg/bot/981256696842317894/vote)`)
.setColor('GREEN')
.setFooter({ text: `${user.username} possuí ${userdb.economia.votos + 1} votos`})
canal.send({ content: `<@${vote.user}> votou em mim!`, embeds: [embed] })
}))
app.listen(80)```
where did i go wrong?
that's not the webhook url
you need to add the endpoint of your express server
like https://domain.com/api/dblwebhook
note that localhost won't work
I don't have express I put it directly on the host
I'll put it in the replica I think it will
@solid imp my express link is not working a https://ZanyVote.vinicius-gabri8.repl.co
are you sure you're listening to post requests on that route on your code?
yea
I'm using this here
the rest is just to turn on the bot
if this is your code, then the url you're using is wrong
I have copy the webhook token but where i have to put this code?js { "Authorization": "your-topgg-token-here" }
thats appears to be from the api, not webhooks.
Yep i mean API sorry
ah, then this is a header sent along with your request to the api.
how you implement that header will depend on your programming language and library used for sending http requests
Does it support aoi.js?
I've never used aoi.js, if aoi.js can send http requests then yes
Ok i will see
not sure how to use a pseudo lang like aoi.js, but heres the method they provide.
https://aoi.js.org/docs/functions/httprequest
still nothing in the vote logs.
try
console.log(`vote received! ${vote.user}`)
on the first line of the event
nothing arrived at all
@jaunty plank I don't think he even arrives, is it something with the webhook?
someone should make a youtube tutorial for webhooks for topgg for those who doesnt know how to use em fr 
yes mine does not stop giving error 😭😭
what error?
the person votes and nothing happens
I've tried everything you said
the issue is so many hosts have unique ways of dealing with stuff that a single youtube video wont cover it.
and giving only the base showing we can do it in several hosts
did you add a line for logging to console?
Is your url set to https://zanyvote.vinicius-gabri8.repl.co/dblwebhook?
is your auth set correctly? https://i.imgur.com/ffnXb74.png
i see
what is this supposed to be?
Your webhook auth for receiving votes from top.gg
You can set it on your dashboard
Don't confuse it with API token or Bot token
The vps?