#topgg-api

1 messages · Page 1 of 1 (latest)

restive otter
#

Ohh

magic canopy
#

How can i get the url of vote count?

hidden ferry
#

Error: Unsupported client

#

??

#

autoposter

#

nevermind

#

i put the code in the wrong bot

#

wait

#

no

#

its still error

#

the client is meant to be the bot client?

#

yes?

magic canopy
#

Try ):

hidden ferry
#

i did

#

it doesnt work

restive otter
#

The response will contain a JSON object that has two values interesting for you:

  • "monthlyPoints": Votes of your bot for the current month
  • "points": Total votes of your bot

cc @magic canopy

broken latch
#

Hello

#

You Must Vote To Use This Command. What is How To Code?

jaunty plank
#

Our suggested method is storing vote data in a database. That data can be received from webhooks.

stiff quiver
#

does the site take a while to update shard count?

#

cause mine said it posted just fine but isnt showing on the bot page lmao

stiff quiver
#

Ooh weird haven't updated on my end.

#

So server count will always be half of what it is because it's split up into two shards

jolly widget
#

you send a server count of each shard and it totals them

royal steeple
#

I am using java to develop, and i wanted to incorporate the top.gg API via gradle. Their examples indicate using
compile 'com.github.DiscordBotList:DBL-Java-Library:2.1.1'
but since "compile" is deprecated I used implementation. I resynced gradle, built the project without problems but I cannot use the api classes in my code (they appear as if I asked for an unknown class). ex. cant use the "DiscordBotListAPI" class.

#

deleting cache/restarting ide/resyncing gradle did not fix the issue

smoky marten
glass heron
#

is there a tutorial for vote locked commands?

abstract mothBOT
#

@glass heron

Your question is likely answered by one of pinned messages.
Please take time to read the pinned messages by clicking on this icon.

glass heron
solid imp
#

no, i don't think so

#

it has a code example i think

#

one of the pins

glass heron
#

Yeah that i see

solid imp
#

shouldn't be hard to implement based on that 😄

dense pebble
#
const express = require('express')
const Topgg = require('@top-gg/sdk')

const app = express() // Your express app

const webhook = new Topgg.Webhook('auth') // add your Top.gg webhook authorization (not bot token)

app.post('/dblwebhook', webhook.listener(vote => {
  // vote is your vote object
  console.log(vote.user)
}))

app.listen(135) // your port 

What did i do wrong?

restive otter
#

Bro

#

Is it not working?

#

Any error

#

Specify that

rain heart
#

I can tell you several things that are wrong, but cant specify anything without you posting errors

zinc vortex
#

I'm kinda confused on what url I put in the webhook url section

smoky marten
#

Your vps / pc, an url, some serverless stuff etc

#

normally it looks like https://YOUR_IP:YOUR_PORT/yourroute

#

example: http://10.10.10.10:5000/dbl

zinc vortex
#

Aah alright so the full thing including the /dbl part

smoky marten
#

yea

zinc vortex
#

Yeah that worked now ty!

royal steeple
#

when i tried using maven(java) to import I got a cannot resolve error. could someone clear up the problem? I tried putting a random string instead in dependecy and i get a different error, could not find, so it is finding the intended maven import but unable to resolve when trying to get the topgg api.
Full maven:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>groupId</groupId>
    <artifactId>untitled</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>
    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>org.discordbots</groupId>
            <artifactId>DBL-Java-Library</artifactId>
            <version>2.1.1</version>
        </dependency>
    </dependencies>
    
</project>
stoic granite
#

does anyone have any python example code on how to give users rewards after they voted?

royal steeple
stiff quiver
#
CLIENT.topggpy = topgg.DBLClient(CLIENT, 'secretheh', autopost=True, post_shard_count=True)
``` how do i make it post my full count, cause its like splitting up my total servers by 2 because i got 2 shards, instead of s howing over 1600 it showing ontopgg i only have 800
paper hound
restive otter
#

How do I get API authorization to read votes?

restive otter
stoic granite
jaunty plank
lime island
#

whats the api for votes?

stoic granite
#

what do i put in place of /dbl?

bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dbl", "password")
#

do i just keep it as /dbl?

stoic granite
#

nvm

dense pebble
smoky marten
#

There's a test webhook button
try it

restive otter
#

ye i give up

#

how do i make it to run with heroku

smoky marten
#

Make it with web process

#

connect to the port heroku gives you

#

If I remember correctly you can get it through env variable

restive otter
smoky marten
#

then why's it getting 503

#

that probably means your server broken

restive otter
#

is there something wrong with it

smoky marten
#

also the route is wrong

#

in the ss I see /dblwebhooks

#

but here /vote

restive otter
smoky marten
#

idk whatever you put in your code

restive otter
#

but when i used the port in the url i didnt get this error + when i vote nothing happens

quiet harbor
rain heart
reef shore
#

How can i send test vote webhook?

#

Nevermind

tame jasper
#

Hello

brisk tapir
#

How can I check if any bot is on top.gg

rain heart
#

you require API access to do any API things, meaning you'll need an approved bot

smoky marten
restive otter
humble ermine
#

Is there any way I can know if the member has voted ever?

#

Not every 12hrs

jaunty plank
#

Yeah, your best bet is storing that information

humble ermine
#

Alr

jade trout
#

Bye

fluid venture
ornate nest
#

just call the api for it

#

i use webhooks only for logging votes and storing it because its better for my usecase

timid walrus
#

hi, How can I solve this error? TopGGAPIError: 504 Gateway Time-out

tidal idol
#

The site will have been down when it tried to post stats

#

Nothing you can do on your end

timid walrus
#

Ty

smoky marten
restive otter
restive otter
#

nvm ig, found my answer

trail shale
#

how could I get the number of votes? I tried this but it's not accurate.

 await fetch(
      `https://top.gg/api/bots/mybotid/votes`,
      {
        headers: {
          Authorization:
            "-",
        },
      }
    )
      .then((res) => res.json())
      .then((r) => (r.length)); // here, this should be the result
trail shale
restive otter
#

ty

restive otter
trail shale
#

well, on the website

#

and on the server

#
let totalvotes = await fetch(
      `https://top.gg/api/bots/mybotid/votes`,
      {
        headers: {
          Authorization:
            "-",
        },
      }
    )
      .then((res) => res.json())
      .then((r) => (r.length));
    await votesChannel.edit({name: "Votes: " + totalvotes});
dim kettle
#

On weekends the votes count twice :)

trail shale
#

uhh, I am trying to understand how are calculated otherwise

restive otter
#

One user votes, so one entry is added - though in the frontend they're added

#

You could get them from https://top.gg/api/bots/905134681199104020

#

And get the monthlyPoints field, which is currently 101

trail shale
#

so change the API request url to the one you provided me?

restive otter
#

Yup, also no need of an Authorization header

trail shale
#

and I should get a response like

{  
  { monthlyPoints: 101 }
}
```?
restive otter
#

Correct

trail shale
#

thanks!

dim kettle
#
{
  "defAvatar": "6debd47ed13483642cf09e832ed0bc1b",
  "invite": "",
  "website": "https://discordbots.org",
  "support": "KYZsaFb",
  "github": "https://github.com/DiscordBotList/Luca",
  "longdesc": "Luca only works in the **Discord Bot List** server.    \r\nPrepend commands with the prefix `-` or `@Luca#1375`.    \r\n**Please refrain from using these commands in non testing channels.**\r\n- `botinfo @bot` Shows bot info, title redirects to site listing.\r\n- `bots @user`* Shows all bots of that user, includes bots in the queue.\r\n- `owner / -owners @bot`* Shows all owners of that bot.\r\n- `prefix @bot`* Shows the prefix of that bot.\r\n* Mobile friendly version exists. Just add `noembed` to the end of the command.\r\n",
  "shortdesc": "Luca is a bot for managing and informing members of the server",
  "prefix": "- or @Luca#1375",
  "lib": "discord.js",
  "clientid": "264811613708746752",
  "avatar": "7edcc4c6fbb0b23762455ca139f0e1c9",
  "id": "264811613708746752",
  "discriminator": "1375",
  "username": "Luca",
  "date": "2017-04-26T18:08:17.125Z",
  "server_count": 2,
  "shard_count": 1,
  "guilds": ["417723229721853963", "264445053596991498"],
  "shards": [],
  "monthlyPoints": 19,
  "points": 397,
  "certifiedBot": false,
  "owners": ["129908908096487424"],
  "tags": ["Moderation", "Role Management", "Logging"],
  "donatebotguildid": ""
}
restive otter
#

You have points and monthlyPoints

trail shale
#

I think authorization is required 😅

dim kettle
#

Yep, all endpoints need auth

restive otter
#

Interesting, works fine for me ASthink

arctic rivet
#

Can I be the dev of topggpy? 😌

restive otter
#

Feel free to contribute to the project

trail shale
#

Thank you guys topggThumbsUp

restive otter
#

It's open source

arctic rivet
#

How can I contribute?

restive otter
arctic rivet
#

Okh

trail shale
#

what does certifiedBot mean?

smoky marten
smoky marten
#

They used to add custom url and stuff to good popular bots before

trail shale
#

ah. alright

fluid venture
rain heart
#

nevertm

fluid venture
#

😔

shy ridge
#

update top.gg server count using discord.js?

hot locust
dim kettle
#

I would highly recommend storing votes in a database and use that to dedupe votes to prevent duplicates

hot locust
#

Okay thank you

unkempt hill
#

how can i send a message after a user vote's?

shy ridge
shy ridge
#

how long does it take for the short desc to update?

tidal idol
dim kettle
tidal idol
#

Yeah that too ^

smoky marten
#

And for search even longer i guess

#

cuz they probably index things and they don't change often

paper elk
#

Can I get my top.gg token before my bot is verified so I can post my bot stats to my page? I want to be able to push this as an update for my bot the second my bot is approved on top.gg

smoky marten
#

Also if you want to try out other api endpoints and features besides bot stats

#

You can just log in top.gg with your browser

#

And try them out then

#

The user token works pretty much same for other endpoints

#

Edit: They don't have tokens but use cookie header instead but it still works

paper elk
restive otter
#

JSON structure is pretty easy, you can already write the code quite easily

paper elk
smoky marten
#

I see php
I leave chat

shy ridge
#

same

#

php gay

smoky marten
#

bro
gays deserver better than php

paper elk
#

Where can I get my top.gg api token for use to check for a server vote from a user?

smoky marten
#

Wait till your bot gets approved

#

Then

paper elk
#

So I cant set up an integration to work through my website to give users a role and a credit for use on things in my website and server per vote via the server vote webhooks until after my bot is verified?

violet bramble
#

hey guys, how would i send a webhook after someone voted on my server? Is there any way i can track that as i right now have no clue

smoky marten
smoky marten
#

Oh

#

you can do that

paper elk
#

Yeah, where do I get the top.gg token for that?

smoky marten
#

servers don't have tokens

#

you have to set up webhooks and do that manually

#

servers have only webhooks

paper elk
#

yes but to listen for webhooks I need a token according to the docs

smoky marten
#

That's auth token

#

You set that

#

Under webhook section

#

of the server

paper elk
smoky marten
paper elk
#

I am, like surely that says I need the token for the api?

smoky marten
paper elk
#

ah ok, is the authorisation sent as post or get?

smoky marten
paper elk
#

How do I view the result of my webhook

smoky marten
#

.......

#

view what?

paper elk
#

im getting 0 errors on my server that it sends to, I just dont know if its working like it should be

smoky marten
paper elk
#

Got an issue there

#

Already voted lol

smoky marten
#

Fix that and try 12 hours to test it again

#

In this meantime
Think about your life problems

#

and question reality

paper elk
#

Oof

jaunty plank
paper elk
smoky marten
jaunty plank
paper elk
#

It’s just a post request to the php page so I shouldn’t need some fancy webhook handler should I?

jaunty plank
#

its just a post request yes.

paper elk
#

Yeah nothing.

#

I’ll show code

smoky marten
#

@paper elkI works just fine
Just tested

jaunty plank
#

the webhook site I run requires users to use the test button, I have quite a few people using it daily fine.

smoky marten
smoky marten
#

too lazy to create a server and test

paper elk
#

This is what my php server recieves and handles

smoky marten
#

eww php

paper elk
#

I removed the emails and credentials... for obvious reasons... But it sends nothing when the test server runs

shy ridge
jaunty plank
#

is it possible the mail server doesnt work?

shy ridge
paper elk
#

Nah the mail server 100% works because it’s sending payment receipts currently and working.

smoky marten
#

Can't you try doing console.log or something similar?

#

To make sure the server received the vote

paper elk
#

Its showing $_POST as empty

jaunty plank
#

this is one of those moments I wish I knew php at all.

these two seem conflicting dont they?

https://i.imgur.com/I02f0Ct.png
does $_GET refer to a get request? or getting something.

#

or, what does

if ($_GET['action'] == 'vote') {

actually do?

paper elk
#

oh I have another thing going to that webhook page ?action differs the response

#

my url on the top.gg website sends ?action=vote to make sure I am eecuting this code

#

So yet $_GET is a get request

smoky marten
#

?

paper elk
#

only got one IP for this server

smoky marten
#

/vote

paper elk
#

its not a pure url yet as its testing

jaunty plank
#

so wouldn't be false every time?

if ($_GET['action'] == 'vote') {

and then the next if statement would never run.

paper elk
#

nope

#

because the url I pass in includes ?action=vote which is where the get comes in

jaunty plank
paper elk
#

no

#

get refers to anything after a ? in the url

#

so localhost/webhook.php?action=vote

#

the get pulls down action as a get variable called action with the value test

jaunty plank
#

just to clarify, you're not using localhost in the webhook url you put on topgg right?

paper elk
#

no

#

I have a test server ip rn

jaunty plank
#

just making sure, a lot of people make that mistake

paper elk
#

thats working, it passes the get check, but the post check fails as $_POST comes as empty

smoky marten
jaunty plank
#

$_POST is entirely empty?
post is checking what part of the request? headers? body?

smoky marten
#

probably body

jaunty plank
paper elk
#

nope

jaunty plank
#

topgg sends the data as json

smoky marten
paper elk
#

i just have the issue of, what is the authorisation logged as

jaunty plank
#

its in the headers

paper elk
#

nope post is empty

jaunty plank
#

$_POST should be empty according to the php docs

#

unless I'm misunderstanding it

paper elk
#

$_POST refers to all post data as an array of key and value

jaunty plank
#

for form data right?

paper elk
#

yeah but all post requests work like that... give me a second

strange thorn
#

DELETE endpoint not working

#

can't leave a team

#

idk how many months it has been

jaunty plank
#

I think thats a known issue

strange thorn
#

but it's been months

#

is that on your guys to-do list?

jaunty plank
#

it should be, but I'm not a site developer

strange thorn
#

i also opened a ticket requesting to remove me from the team manually but you guys said it's not possible

#

i mean, you have my perms and it's my data after all and I want to remove myself from a team

abstract mothBOT
#

topgg This channel is for suggestions, help, and bugs related to our official API libraries and documentation found at https://docs.top.gg/

If you need help with other development, please use #development.

dim kettle
#

If you want help for support related issues you got #support :D
You can as you said, follow up on your support ticket to continue talking with the person who originally dealt with your ticket

abstract mothBOT
paper elk
jaunty plank
#

let me know if you need anything else.

paper elk
#

Will do thanks

quartz scroll
#

Hi

smoky marten
#

Hi

violet bramble
#

Hey guys, how do I get the authorization token for my server that I published on topgg? I need it for t he vote event

smoky marten
#

you don't get it

#

you set it

#

From your server page
Go to edit > webhooks

#

Fill the auth and webhook field and click save

#

done

#

copy / save the Authorization value to receive vote requests

visual sierra
#

how can I make my bot vote reward system?
Like it send rewards to the user when someone vote?

jaunty plank
visual sierra
#

when user vote > server webhook send message in channel > my bot have to detect the user ?

#

like this?

jaunty plank
#

topgg webhooks do not work with discord webhooks if thats what you're asking

visual sierra
jaunty plank
visual sierra
jaunty plank
visual sierra
#

I want to do a little bit different thing tho... i want that my bot give reward when our vote our server

smoky marten
#

I think that's against tos

visual sierra
#

oh

smoky marten
#

You can make that
But IDK anything else

#

Make webhook for server
Then giv reward in bot

visual sierra
#

still i have to know about how to make it... i am checking those above links

smoky marten
#

idk anything else
@jaunty plank might help

jaunty plank
#

it depends.

if the two entities are tied together its fine. for example a bot giving a role in the bots support server on vote.

visual sierra
jaunty plank
#

yep! I might not be able to help much though, I dont know python.

visual sierra
#
import topgg

#This example uses topggpy's webhook system.
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "password")

# The port must be a number between 1024 and 49151.
bot.topgg_webhook.run(5000)  # this method can be awaited as well


@bot.event
async def on_dbl_vote(data):
    """An event that is called whenever someone votes for the bot on Top.gg."""
    if data["type"] == "test":
        # this is roughly equivalent to
        # `return await on_dbl_test(data)` in this case
        return bot.dispatch("dbl_test", data)

    print(f"Received a vote:\n{data}")


@bot.event
async def on_dbl_test(data):
    """An event that is called whenever someone tests the Webhook system for your bot on Top.gg."""
    print(f"Received a test vote:\n{data}")```
#

exact same as example to understand how this work

jaunty plank
#

did you fill in your webhook url and auth?

visual sierra
#

the Webhook 'i entered in top.gg' and password 'authorise that I entered'

#

@jaunty plank bro can you tell me a thing? how I am supposed to enter webhook in this?
example: my webhook is https ://test
I enter it like:

bot.topgg_webhook = topgg.WebhookManager(bot)dbl_webhook("/dblhttps ://test", "testpass")```
or 

```py
bot.topgg_webhook = topgg.WebhookManager(bot)dbl_webhook("https ://test", "testpass")```
jaunty plank
#

neither, thats just a path

#

ie: /dblwebhook

visual sierra
#

no change in it?

jaunty plank
visual sierra
jaunty plank
#

the number in webhook.run is the port

visual sierra
#

yep...

#

and then /dblwebhook will be the link?

#

right?

jaunty plank
#

/dblwebhook is just a path

visual sierra
#

a little bit confusing.
can you tell me an example?

#

wait... maybe I got it

#

let me try

molten jay
#

hello top gg devs, is there any api to search bots by owners id?

rain heart
#

there is not

#

nor is there access to the API without an approved bot

distant chasm
#

Hello Dev's, is there any api to get if a user has voted the server or not?

smoky marten
#

wait that's for bots only

#

nvm

#

use webhooks

distant chasm
smoky marten
#

it's basically a webserver

#

top.gg sends vote data as post request to that url

#

read the docs for more info

#

Also if you just want vote notifications

#

use this

#

no coding knowledge required

restive otter
#
TopGGAPIError: 401 Unauthorized (You need a token for this endpoint)
    at Api._request (C:\Users\k-van\Desktop\CoffeeBOT V2\node_modules\@top-gg\sdk\dist\structs\Api.js:76:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Api.postStats (C:\Users\k-van\Desktop\CoffeeBOT V2\node_modules\@top-gg\sdk\dist\structs\Api.js:99:9) {
  response: Response {
    size: 0,
    timeout: 0,
    [Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },
    [Symbol(Response internals)]: {
      url: 'https://top.gg/api/bots/stats',
      status: 401,
      statusText: 'Unauthorized',
      headers: [Headers],
      counter: 0
    }
  }
}
```What is the error reason
restive otter
#

I did error persists

dim kettle
#

Would you be able to show the code you use? Just hide the API token

restive otter
#

@dim kettle

dim kettle
#

Where do you define dbl?

restive otter
#

for total vote data

dim kettle
#

Are you setting the token in the dbl client?
const dbl = new Topgg.Api('Your top.gg token')

restive otter
#
const express = require("express")
const app = express()
const Topgg = require('@top-gg/sdk')
const DBL = require("dblapi.js");
const dbl = new DBL(`${settings.url.topgg}`, '893949713047519273')
dim kettle
#

Dont use https://www.npmjs.com/package/dblapi.js
it has a massive deprecation warning

restive otter
#

i don't use glitch

#

vds I use

dim kettle
#

Thats fine, that has nothing to do with what NPM lib you use

restive otter
#

i think i solved it i will test

restive otter
#

hello i need help how to activate the bot?
Nivatus

#

and also i need a list of commands

dim hatch
#

With the api can I do vote rewards?

shy ridge
dim hatch
#

I'm going to learn to use it

paper elk
#

The webhook from top.gg triggered neither.

fluid venture
paper elk
fluid venture
#

confused 😕

#

o wait that

#

prolly wrong url in ur bot app ig

paper elk
#

works perfectly fine when I connect to the endpoint for a post curl or by using a web browser.

fluid venture
#

o

paper elk
fluid venture
#

same thing with webhooks

paper elk
#

Exactly. The URL was correct. I changed and saved 3 times lol.

fluid venture
#

can u show the url u put Thonk

paper elk
#

No...

fluid venture
#

eh

paper elk
#

I cannot. As the testing one I used is pure ip

fluid venture
#

just hide the ip weirdsip

paper elk
#

with http before it lol

fluid venture
#

did u add the port after ip?

paper elk
#

yup

fluid venture
paper elk
#

uhm.

#

its ip:port

#

not ip/:port

fluid venture
#

uh

#

i wrote the same?

paper elk
plucky lance
fluid venture
#

kekw

plucky lance
#

Probably longer

paper elk
#

weird.

plucky lance
#

Only for invalid URL combinations

paper elk
#

just do that

tidal idol
#

easiest way to write for discord is like this

paper elk
#

cloudflare dont care

tidal idol
#

http://ip:port

paper elk
#

Still have the issue of why topgg webhook isnt triggering a get or post request on the express app.

plucky lance
#

The link parser just has this bug but who cares

paper elk
#

half tempted to change it to .on('post')

plucky lance
paper elk
#

lol

plucky lance
#

Well maybe not functional atm then

#

Happens from time to time people complaining about this

#

The site is.. just an ongoing nightmare

paper elk
#

yeah but I tried yesterday as well. Just today I am trying it as pure express request and response data, excluding the topgg webhook element from the code.

#

Because you DONT need it for the vote webhooks.

fluid venture
paper elk
#

unless I am completely wrong and I need it 100% to handle any request from topgg webhook on express lol

plucky lance
#

No firewall blocking your requests?

paper elk
#

0 firewall and 0 cloudflare rules

#

thats why I wont share the IP.

plucky lance
#

No it’s not required

paper elk
#

Glitter asked earlier

plucky lance
#

Well didn’t ask for the IP

#

Just wanted to make sure nothing is in place

paper elk
#

for the sake of being an idiot I am half tempted to use azure endpoint option to test. Ensure it isnt me.

plucky lance
#

Also no proivder firewall?

paper elk
#

Mate the server is sat next to me going straight out on fiber connection.

plucky lance
#

Oh

paper elk
#

Its a microserver.

plucky lance
#

So at home?

#

Port forwarding for the TCP port done correctly then?

paper elk
#

yup its the spare build server I use for work. on the same outgoing 10gb/s down and up fiber connection work installed, just this is wired into the non-firewall ports on the switch

#

...

fluid venture
plucky lance
#

But still there’s a router in front

paper elk
#

If I set up webhook endpoints on this connection to use a self made api to handle my works app build requests using express, I am pretty sure this one that has the same configs minus the port and ip, should work.

plucky lance
#

U tried an external tester tool to figure the connections works?

#

So requests can be send ?

paper elk
#

Yes

#

I made my website send a request to it. And I used he US serer that hosts my site, not the UK one.

#

it worke

plucky lance
#

Then try a different browser logging into topgg (again) and try sending the webhook again

paper elk
#

So the endpoint worked. I just wanna know what topgg thing I am doing wrong to make their webhook request not work.

plucky lance
#

Always hitting save before test button

paper elk
#

ive tried 4 different devices...

plucky lance
#

No there aren’t any requirements to receive the webhook

#

It either works or not which means the site might have some issues (again)

#

You just need to confirm the request and respond with a 2xx status code

paper elk
#

FFS, and I am testing this to help 3 people that have had an issue using the javascript endpoint to handle bot/server vote requests...

#
const express = require("express");
const app = express();
let port = 3000;

const util = require("util");

app.post('/', async (req, res) => {
  console.log("post");
  console.log(util.inspect(req, false, null, true));
  res.send("We see you");
});

app.get('/', async (req, res) => {
  console.log("get");
  console.log(util.inspect(req, false, null, true));
  res.send("We see you");
});

app.listen(port, () => console.log(`Webook listener running on port: ${port}`));
```the .send(messsage) is a 200 response
plucky lance
#

Could also be an issue with your IP which cf might have blocked temporarily if the test requests also pass cf

#

Not sure about that

#

But you can easily find out

olive owl
#

shouldnt it be res.write?

paper elk
#

I know it is... cus I accessed via my web browsser.

#

it showed the message and dev tools showed 200 res in headers

plucky lance
#

Did you try changing the request path?

paper elk
#

yeah

plucky lance
#

To some@other path

paper elk
#

ive done full circle lol

plucky lance
#

Well yeah, then a site issue or CF

paper elk
#

ClouFlare isnt blocking my ip lol.

#

and my ip isnnt blacklisted or anything.

tidal idol
#

is it cf proxied

paper elk
#

Nope

plucky lance
#

You aren’t able to figure out temporary blocks

paper elk
#

Cloudflare doesnt touch this endpoints IP

#

so no proxie no nothing

paper elk
plucky lance
#

Well then welcome to the topgg environment troll

#

May doesn’t like your endpoint KEKW

paper elk
#

im shuttng it down and returning my webhook to the actual vote handler endpoint I configured on my php server

plucky lance
#

Only thing to test is to regenerate your token

#

Do that a few times before trying

paper elk
#

its server...

#

no token

#

my bot hasnt been approved yet

plucky lance
#

This helped a few people in the past

#

Oh server webhooks

#

Ok

#

Didn’t you say vote webhooks?

paper elk
#

yes server vote sends a webhook

plucky lance
#

Ahh thought we were talking about bot votes

#

But anyways

#

Yeah seems like it won’t do the job for you today

paper elk
#

I just voted for my server, and my php endpoint added the top.gg voter role you can see here.

#

So, what is the GD problem with the test button not triggering any requests lol

jaunty plank
#

Just to clarify, it works when you vote just not test without changing anything?

paper elk
#

Yes

plucky lance
#

Like I said that has been an issue for many people in the past

paper elk
#

The PHP endpoint is reporting nohing when I send a test either.

#

so its not the express endpoint at fault.

jaunty plank
#

When you've saved your settings are you refreshing the page then testing?

paper elk
#

yes

#

ill try again...

jaunty plank
#

If this ^ works with the test button it's something on your end.

plucky lance
#

Woo and his shameless ads

jaunty plank
#

Sorry 😔

#

Just trying to determine if it's a site issue.

plucky lance
#

Charging $1 per IO

paper elk
#

Did it work?

#

Because yet again connecting to my webhook listener pasted a get req to console and a curl post posted a post req to the console... the test button did nothing.

plucky lance
#

Can’t you test it yourself?

paper elk
#

I literally have a website hosted in america to test webhooks I make for me using get and post options lol

#

they make a request that I configure the sent items of.

plucky lance
#

Guess you won’t be lucky today anymore

jaunty plank
#

Doesn't mean it's not an issue on your end though

#

You're lol, I English

paper elk
#

res => 200; logged req to console.

plucky lance
jaunty plank
#

Fixed it, nvm ^_^

plucky lance
#

Woo drunk?

paper elk
#

Doubtful, woo is working.

jaunty plank
#

Nah, I'm out of office

paper elk
#

right so my listener is on http://<ip>:3000

#

i put that into the webhook url of topgg... saved, refreshed, pressed test and nothing triggered.

#

I go to my site that tests my webhook and sent one of get and one of post to the same url, it triggered no issue.

plucky lance
#

Sounds weird but do not reload the site , jut hit save then test

paper elk
#

And, that's the documentation standard for handling get and post requests via express.

#

im doing nothing special or different to their docs other than logging the req instead of handling it.

jaunty plank
#

Test votes using express work fine for me.

paper elk
#

so I am 99.9999% certain its not my endpoint.

plucky lance
#

Site randomly picks people it doesn’t like it seems

paper elk
#

You seem trustworthy lol

jaunty plank
#

I'd need the auth too

#

We will have to be fast

paper elk
#

0 auth needed rn

jaunty plank
#

You're using the js lib?

paper elk
#

No

#

rn im just logging the req from express .post()

#

I am trying to make it handle without the topgg api rn, then use the API

jaunty plank
#

For anyone searching this in the future, seems the issue was using a local ip not a public one.

plucky lance
#

lol

#

How did he mess this up KEKW

paper elk
#

Some issue with the port I put the server on at the switch...

#

It blocked all external connections...

#

Like it goes out and functions for a bot... and allows my sites to get through... Anyone else? nah.

plucky lance
#

But I asked you if theres anything blocking incoming requests

paper elk
#

Literally checked and saw nothing...

#

I was looking at the wrong port...

#

Im tired ok

plucky lance
#

As long as it works now

paper elk
#

yeah and I can give the code to people to use now lol.

#

Thats the only reason I did this. To make this listener code so people that fail following the topgg docs can just clone a repo an boom

fluid venture
dim hatch
#

Help me, I don't understand how to use the api, I'm from aoi.js

paper elk
dim hatch
#

Register the id of the user who has voted to make a daily

fluid venture
#

so webhooks?

paper elk
#

You don't need the API for that.

dim hatch
#

Seriously?

#

How do I do it?

rain heart
paper elk
#

I'll show you when done for node.

dim hatch
rain heart
#

the documentation mentions how webhooks work. You'd need to wait for someone who can assist you in setting up then

#

of course not spoonfeeding

smoky marten
#

not official
so no

paper elk
#

the node topgg-autoposter is meant to update my page with the stats of my bot, how often is this and how long does the page take to display the data? I want to know if its once a minute or once an hour or once a day etc to make sure if I log the event to console it wont spam...

jaunty plank
#

The autoposter by default is 30 minutes, it can be longer but ideally not any less.

#

The site can take an hour to update.
Generally not any more than that

paper elk
#

I can’t really see any documentation to modify it.

jaunty plank
#
GitHub

Top.gg Auto-Posting made easy. Contribute to jpbberry/topgg-autoposter development by creating an account on GitHub.

GitHub

Top.gg Auto-Posting made easy. Contribute to jpbberry/topgg-autoposter development by creating an account on GitHub.

paper elk
#

Ty

vital star
#

Hello, i recently got my bot accepted, and I'm trying to figure out how to get my voting systems working. I was looking around, and came across webhook-topgg.com, for the webhook conversion, but the problem is that the BOT doesnt detect anything on the listeners.

const Topgg = require("@top-gg/sdk")
const express = require("express")

const app = express()

const webhook = new Topgg.Webhook("this is my auth :(")

app.post("/dblwebhook", webhook.listener(vote => {
  console.log(`vote detected ${vote}`)
}))

app.listen(80)
#

the webhook does work, it shows the test requests in the discord, but not in my console.

(Feel free to mention me when replying)

jaunty plank
#

Topgg doesn't send messages in discord on vote, so I would think you're using another service to do that.

Sadly topgg webhooks can be sent to your webhook listener or to one of those third parties but not both at the same time.

fierce socket
#

Could someone help me to make a message when someone votes my bot? I didn't understand from the docs.

fierce socket
jaunty plank
vital star
jaunty plank
vital star
#

wym

#

oh

#

hmm

vital star
jaunty plank
#

So topgg only supports sending one webhook at a time.
Both your code above and webhook-topgg uses webhooks.

vital star
#

would a discord webhook work fine for what im trying to do?

jaunty plank
#

Nope, topgg webhooks don't work with discord webhooks

vital star
#

hmm

wide stream
#

im using the send test on topgg and its not logging anything

smoky marten
#

Most possible issues:

  • Your pc/vps is behind a firewall
  • You entered wrong url
  • Your code is wrong
  • You're behind a vpn
  • Your hosting provider blocking the request
  • You have the wrong port
vague prairie
#
Error [ERR_TLS_CERT_ALTNAME_INVALID]: Hostname/IP does not match certificate's altnames: Host: normal-api.ml. is not in the cert's altnames: DNS:*.parkingcrew.net, DNS:parkingcrew.net```
#

what is this error ?

rain heart
#

An error likely not related to this channel

#

-api

abstract mothBOT
#

@timber gale

topgg This channel is for suggestions, help, and bugs related to our official API libraries and documentation found at https://docs.top.gg/

If you need help with other development, please use #development.

timber gale
rain heart
#

because this channel is not a channel to post that

timber gale
#

Ok but its still rude from you to do that

rain heart
#

once again

#

-api

abstract mothBOT
#

topgg This channel is for suggestions, help, and bugs related to our official API libraries and documentation found at https://docs.top.gg/

If you need help with other development, please use #development.

rain heart
#

continuing to talk about unrelated topics will get you muted

timber gale
#

You also dont talk about api so why should i

rain heart
#

Again

#

last warning, change to #general or get muted

tawdry spoke
#

Can anyone help me , my bot showing server count 0 in top.gg

dim kettle
tawdry spoke
dim kettle
tawdry spoke
#

I did this

dim kettle
dim kettle
#

Do you see the console log when you start your bot?

dim kettle
#

Nice. The site may take an hour or two before it shows the stats

tawdry spoke
#

console

wide stream
plucky lance
#

Does a firewall block the incoming requests on port 80 (tcp)?

wide stream
#

something i also noticed

#

is that when I define the webhook and log it

wide stream
plucky lance
#

Some providers put one in place being enabled by default with their ruleset

#

Just to make sure, it’s not a server you’re running at home?

wide stream
#

and the firewall is inactive

plucky lance
#

Do iptables —list-rules

#

Oh

#

2x minus

wide stream
plucky lance
#

Damn my phone auto converts it wtf

wide stream
#

lol all g

plucky lance
#

Ok still no response after changing the port?

wide stream
#

i changed to 219 and i tried 1020 last night

#

still no responses

plucky lance
#

Did you update the URL after changing the port on topgg?
Also please choose a port of a non-reserved range

#

Idk like 3000 or 5000 etc

#

I mean it would complain if the port is already in use but still…

wide stream
#

still no response

#

ok I set it to 0 which is obviously reserved and still no log at all

plucky lance
#

URL updated, pressed save then test?

wide stream
#

yep

plucky lance
#

Remove the authorization please

wide stream
plucky lance
#

Completely both in your code and on topgg

wide stream
#

ok

#

then what

plucky lance
#

Then regenerate the token a few times, hit save then test again

fluid venture
plucky lance
#

Just to get rid of known site bugs unfortunately

wide stream
tawdry spoke
plucky lance
wide stream
zenith lantern
#

get request to https://top.gg/api/bots/:bot_id/check

how often does this reset to saying the user has not voted? (ie. 12 hours, 24 hours, weekly, monthly)

fluid venture
zenith lantern
fluid venture
#

np

plucky lance
#

Or simply by sending a curl request to it?

wide stream
#

only thing running on that port is the topgg script

#

firewall is disabled

#

idk what is wrong

plucky lance
#

Try from an external device

#

Outside the servers network

wide stream
plucky lance
#

Hmm

wide stream
plucky lance
#

Yeah i mean it’s accessible

#

So hmm

#

Looks like a site issue then

restive otter
#

@craggy sentinel Is this an actual bug or we doing something wrong here ?

rain heart
#

its likely something related to the webhook, not top.gg

#

also no need to ping a community manager unrelated to it

#

check your ufw logs, your ports are very likely blocked by another default setting

plucky lance
#

Well since the endpoint is accessible externally it looks like a site issue

#

Wouldn’t be the first time unfortunately

rain heart
plucky lance
rain heart
#

was Auth provided

plucky lance
#

So… the endpoint is accessible

#

No just a test to see if the endpoint is accessible

rain heart
#

they should try providing Auth too

#

if that works, then top.gg would be able to send one too if the Auth matches there too

plucky lance
#

Im not gonna use any auth key too

#

Wouldn’t be a surprise if the test button isn’t working again

#

But to make sure it’s working just send a test webhook to another endpoint

#

Can you test em using reqbin?

#

Does it provide a test endpoint

#

Or can you send requests only?

rain heart
#

thing is: depending on how they tested it on top.gg

#

it literally will not send anything in the logs if the webhook feature is used from the library

#

since it will not log anything

#

if no Auth is provided

#

thus, please test it with auth too

plucky lance
#

So… the lib requires an auth key?

rain heart
#

That's what I'm assuming

#

since that would make the most sense, to throw away the request when no auth is provided

#

per github, it responds with "unauthorized" and doesn't do anything else

#

as far as I understand the code

plucky lance
#

The authorization is optional

rain heart
#

likely if no authorization is provided in the constructor

#

unless the user posted their code too

plucky lance
#

He said he removed it from the code and site

#

Hmm

#

Might be worth to double check

#

@wide stream you wanna double check, please?

#

lol now realized we both posted the same code freerealestate

rain heart
#

works fine

verbal cape
#

Using share X for editing images?

rain heart
#

yes

#

not related to this

verbal cape
#

Okk !!

rain heart
# rain heart

also guessing the last one had the authorization not set since I haven't saved it

plucky lance
# rain heart

Well your hostname actually has a record to your IP

#

You might wanna remove that image

rain heart
#

nah idc really

plucky lance
#

lol just wonder why you hide the IP then

rain heart
#

for people that dont know how to obtain an ip by the hostname

plucky lance
rain heart
#

but essentially, webhooks work and is likely a setup problem with the user

#

ufw-allowing 1234 made it essentially work even if I have a bunch of forwarded ports for dockers, no issues at all

plucky lance
#

His firewall is okay

#

We checked that before

#

No rules and ACCEPT policy

rain heart
#

using iptables is complicated nonetheless

plucky lance
#

Must really be the auth key then or something I don’t think of yet

rain heart
#

ufw is better for managing it

plucky lance
#

Tf iptables isn’t complicated

#

At the end it won’t matter as ufw is just an interface for iptables

#

Since it’s disabled and the policy for iptables are right nothing blocks incoming requests

rain heart
#

they should start a netcat session using nc -lvnp port and see if they're even able to get any request from top.gg at all

plucky lance
#

iirc he hasn’t got anything

#

Lemme watch his pictures again

rain heart
#

then:

  • iptables blocks it
  • they haven't saved it before pressing "test" (had that so often)
  • webhook isnt properly setup
  • wrong port
  • port is privileged when using on a non privileged user
#

but I can confirm, the top.gg-side of webhooks work

#

since I was able to get it to connect and we havent had reports of any issues yet

plucky lance
#

Wait

#

Port listener for IPv6

rain heart
#

yes that should say ipv4

#

but would default ot ipv6 if no public ipv4 is configured for some goddamn reason

#

assigned*

plucky lance
#

Well there are providers don’t providing an IPv4 by default anymore

rain heart
#

exactly

#

that's why node might default to ipv6 if none usable

plucky lance
#

You can buy it as add on and assign it as primary ip

rain heart
plucky lance
#

But this somehow looks like an IPv4 provided as URL

#

but I’m not really sure of course

rain heart
#

well once they're back

#

ask

#

lol

plucky lance
#

Not sure if topgg even sends requests to provided IPv6 addresses

rain heart
#

am sure it would

#

well technically

#

should

plucky lance
#

As long as it supports IPv6

#

Actually ever tested this tbh

rain heart
#

could actually test brb

plucky lance
#

Alr

rain heart
#

hoping my vps has an ipv6 too

#

next to the ipv4 one

plucky lance
rain heart
#

turns out

#

it does not

plucky lance
#

So wasn’t totally wrong with my assumption

rain heart
#

at least not visibily

#

nah I mean my vps doesnt have an ipv6

plucky lance
#

Or do you mean it hasn’t an IPv6?

#

Ah lol

#

Well and I can’t test it on mobile atm

rain heart
#

nvm has one

#

brb

plucky lance
rain heart
#

just not configured

#

honestly effort to configure

plucky lance
#

Well I guess let’s wait if he responds anyways to what we suggested

latent pasture
#

Hello, I'd like to write an API wrapper for top.gg in my favourite language, what is the way to submit it to the top.gg team to make it "standard" once it's done ?

rain heart
#

there's already official ones for mostly every programming language, the only ones that could be made standard are the ones that don't exist yet and are entirely open source

#

I doubt the team would add another library though, best to have it noted down as a third party library

latent pasture
#

Yeah I just realised there is already a wrapper for Rust, but it seems that it's no longer maintained, I'm looking forward to find the contributing rules then try to PR to complete the existing project

#

thanks

rain heart
#

Yup that would be cool to contribute to, yes!

round salmon
#

i cant update the server count on top.gg

#

after using api.setStats()

#

it still doesnt update

jaunty plank
cyan wyvern
#

Why i vote the bot once and i 2-3 webhook requests?

rain heart
#

Seems like you're not properly responding. Check the docs about "retrial"

cyan wyvern
#

i have responed 200

rain heart
cyan wyvern
#

yes i did sent a 200 response

#

but i still got mutiple response

rain heart
#

post your code here

broken latch
#

You Must Vote To Use This Command. How will I do?

broken latch
#

@fluid venture

#
const { QuickDB } = require('quick.db')
 const db = QuickDB({ filePath: "./db/vote.sqlite" })
#

?

fluid venture
#

new QuickDB()

#

check official docs

broken latch
west shuttle
#

Cane were hel me with the api? I don't know what to do...

fluid venture
#

for v7

broken latch
#

@fluid venture

#

I Voted But It Didn't Show Up On Console

#

45.131.3.74:3000 This Way

rain heart
#

as the text says

#

cannot GET

#

it is only available through a post request and on the endpoint you set

#

which will top.gg make a request to

broken latch
rain heart
#

probably ask the maker of that then

broken latch
rain heart
#

otherwise ask the creator of the gist for help or ask here and wait

broken latch
rain heart
#

through the bots endpoints

#

check the Endpoints

west shuttle
#

Pls any help? I have no idea

dim kettle
#

I got no python experience, so won’t really know. Just wondering that the issue you are seeing

west shuttle
dim kettle
#

Yeah so in that URL field you would put the IP or domain name and path of where your hosting your webhook api

west shuttle
#

from my server?

dim kettle
#

It’s a API call going from Top.gg to your bot

#

So it would be your server IP or domain

west shuttle
#

Okay

dim kettle
west shuttle
#

And here is all correct?

west shuttle
fluid venture
dim kettle
#

As glitter said the top.gg site needs to match that route you added there, and also password needs to match

west shuttle
dim kettle
#

so use /dblwebhook in your code as you had it before, then on the site have: http://YourIpHere/dblwebhook

west shuttle
#

oh ok

dim kettle
#

Did you update your code to just have /dblwebhook as the first argument?

west shuttle
jaunty plank
#

where are you hosting?

west shuttle
#

So btw i cant cklick Send Test its not working

jaunty plank
#

refresh the page

west shuttle
west shuttle
#

I was my browser wtf

west shuttle
fluid venture
#

did u click the save button after making changes?

west shuttle
#

Is here an error?

jaunty plank
#

is it possible your host limits you to specific ports?
I don't speak german so its hard for me to find it.

west shuttle
#

I tested with my ip

#

and this from my host

jaunty plank
#

if you're testing on your home ip youll need additional setup

#

such as port forwarding

west shuttle
#

hmm ok

west shuttle
jaunty plank
#

Port 22 is often already in use by ssh.

#

Are you changing your port in code too?

jaunty plank
west shuttle
#

oh i must change it?

#

ok wait

#

ok, not working KEKW

west shuttle
broken latch
west shuttle
broken latch
#

:/

jaunty plank
broken latch
jaunty plank
#

Yep

west shuttle
#

What reasons are there for it not to work?

west shuttle
deep comet
west shuttle
#

which for example?

deep comet
#

Anything really. I use 3000

#

🤷‍♂️

#

you can use 6969 ;)

west shuttle
#

xD

#

Not working KEKW

#

no error

deep comet
west shuttle
#

IPv4? example: 46.12.35.654 ?

deep comet
west shuttle
#

http://46.12.35.654:3000/dblwebhook This is on top.gg?

west shuttle
west shuttle
#

Thats correct?

jaunty plank
#

And this is being tested on your server rented from host-unlimited?

west shuttle
rain heart
#

are you maybe using some sort of ufw

west shuttle
#

ufw?

summer nebula
#
await fetch("https://top.gg/api/bots/stats", {
    method: "POST",
    headers: {
      Authorization: env.TOPGG_API_TOKEN,
    },
    body: JSON.stringify({
      server_count: stats.guilds,
      shard_count: stats.shards,
    }),
  }).then(() => console.log("Posted to top.gg"));

is there any reason this wouldn't be posting to top.gg?

jaunty plank
west shuttle
jaunty plank
rain heart
west shuttle
rain heart
#

is your bot already running?

west shuttle
#

jes

rain heart
#

stop it

west shuttle
#

ok

rain heart
#

then try checking if the port is available

#

using the netcat above

west shuttle
rain heart
broken latch
#

Not working

rain heart
#

I was referring to Knoxxi

broken latch
#

Not Working

rain heart
#

this is not related to your issue

broken latch
#

Are you angry with me, my friend, you are acting very strange :/

rain heart
#

???

#

I'm currently in the process of helping @west shuttle

west shuttle
jaunty plank
rain heart
broken latch
rain heart
#

could you do ufw status? maybe ufw is installed

broken latch
#

Ports Open Firewalls Off

west shuttle
jaunty plank
rain heart
#

ufw status

west shuttle
rain heart
#

did you get anything from netcat when going to the website?