#topgg-api

1 messages · Page 185 of 1

restive otter
#

hey, i hope i am right here: i want to list my server on top.gg, but it doesnt show up. can anybody help me?

rain heart
restive otter
#

ty

restive otter
#

does anyone have the vote logs script on top.gg?

solid imp
restive otter
#

is there any api to vote on top gg?

#

endpoint*

rain heart
#

there's not

restive otter
#

Hm.

restive otter
#

I can't find this Script and what I tried to do didn't work

solid imp
restive otter
solid imp
#

You can do whatever you want after you receive the event

balmy sleet
#

what is the body to post bot server count?

#

returns the same url

restive otter
#

@solid imp do I put this vote event in the messageCreate event or drop it in the Index?

balmy sleet
# native dust index

sorry for the ping, can you tell me how much time it will take to show server count, after posting it?

native dust
balmy sleet
#

ok ty

native dust
#

np

solid imp
restive otter
solid imp
restive otter
solid imp
#

You need to make sure you have added a valid endpoint on your bot vote page

signal hawk
#

@restive otterplease dont include your secret in your code sent here

restive otter
# solid imp You need to make sure you have added a valid endpoint on your bot vote page
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?

solid imp
#

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

restive otter
#

I'll put it in the replica I think it will

restive otter
solid imp
#

are you sure you're listening to post requests on that route on your code?

restive otter
#

the rest is just to turn on the bot

magic canopy
#

I have copy the webhook token but where i have to put this code?js { "Authorization": "your-topgg-token-here" }

jaunty plank
magic canopy
jaunty plank
#

how you implement that header will depend on your programming language and library used for sending http requests

magic canopy
#

Does it support aoi.js?

jaunty plank
#

I've never used aoi.js, if aoi.js can send http requests then yes

magic canopy
#

Ok i will see

jaunty plank
restive otter
jaunty plank
#

try

 console.log(`vote received! ${vote.user}`)

on the first line of the event

restive otter
#

@jaunty plank I don't think he even arrives, is it something with the webhook?

fluid venture
#

someone should make a youtube tutorial for webhooks for topgg for those who doesnt know how to use em fr Thonk

restive otter
jaunty plank
restive otter
restive otter
jaunty plank
restive otter
#

and giving only the base showing we can do it in several hosts

jaunty plank
quartz reef
restive otter
#

what is this supposed to be?

jolly widget
smoky marten
restive otter
#

But what should the link be thou

#

I am very confused about this

smoky marten
#

*server

restive otter
#

The vps?

smoky marten
#

If you're running on your pc / vps it'd be something like

#

http://YOUR_IP:YOUR_PORT/your_route

#

example: http://10.10.10.10:5000/dbl