#topgg-api

1 messages · Page 5 of 1

rigid dust
#

i own the bot..

#

so it'll always be on 0

jaunty plank
#

You can always vote as the owner

rigid dust
#

rlly?

#

it'll be easier for me to just use or thingy

rigid dust
#

ok yea i can vote and it works

fickle lava
#

.

#

How do I get a rank in this server?

dim kettle
wooden juncoBOT
#

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
#

For support please ask in #support next time :)

But to answer your question, you would need to boost, have an approved bot on our site or become a staff member to get a role

warm lake
#

Why does the webhook send a GET method to my webhook URL?

jaunty plank
#

🤔 When you press the test button on topgg? or a real vote?

warm lake
#

Seems to be both for me

jaunty plank
#

Are you using unsupported characters?
like accented characters

warm lake
#

in the url?

jaunty plank
#

url or auth yeah

warm lake
#

nope

jaunty plank
#

🤔 can you show the request headers/body?

#

excluding auth

warm lake
#
"headers": {
        "accept": "application/json, text/plain, */*",
        "accept-encoding": "gzip",
        "authorization": "REDACTED",
        "cf-connecting-ip": "159.203.105.187",
        "cf-ipcountry": "US",
        "cf-ray": "773e0f111d97e6c4",
        "cf-visitor": "{\"scheme\":\"https\"}",
        "connection": "Keep-Alive",
        "host": "WEBHOOK_HOST",
        "user-agent": "Top.gg Webhook/1.0.0",
        "x-forwarded-proto": "https",
        "x-real-ip": "159.203.105.187"
      }```
jaunty plank
#

🤔 weird

warm lake
#

Yeah, it also shows up as a get request, instead of post request.

jaunty plank
#

the only thing I can think of is try sending your own request using something like postman and see what happens.

warm lake
#

ok

jaunty plank
#

I've never seen someone receive a get request like that.

warm lake
#

When I try sending my own POST request, it works fine

#

idk why the test button aand actual votes show up at a GET request

jaunty plank
#

Its so strange.

No chance its a CF setting messing it up right? 🤔

jaunty plank
#

Someone else might have an idea, but I dont think I've seen this before.

warm lake
#

Alright

plucky lance
#

Or does the request hit your endpoint directly?

warm lake
plucky lance
#

I will test it myself in 2-3 mins to see what's goin on

warm lake
#

Ok

plucky lance
#

Interestingly not for me tho...

{

    "HTTPS":"on",
    "SSL_TLS_SNI":"***",
    "HTTP_ACCEPT":"application/json, text/plain, */*",
    "CONTENT_TYPE":"application/json",
    "HTTP_USER_AGENT":"Top.gg Webhook/1.0.0",
    "CONTENT_LENGTH":"81",
    "HTTP_HOST":"***",
    "HTTP_CONNECTION":"close",
    "SERVER_SIGNATURE":"",
    "SERVER_SOFTWARE":"Apache/2.4.51",
    "SERVER_NAME":"***",
    "SERVER_ADDR":"192.168.*.*",
    "SERVER_PORT":"443",
    "REMOTE_ADDR":"159.203.105.187",
    "REQUEST_SCHEME":"https",
    "REMOTE_PORT":"37932",
    "GATEWAY_INTERFACE":"CGI/1.1",
    "SERVER_PROTOCOL":"HTTP/1.1",
    "REQUEST_METHOD":"POST",
    "REQUEST_TIME_FLOAT":1670090922.552303,
    "REQUEST_TIME":1670090922
}```
warm lake
#

hmm that's weird

jaunty plank
#

Not for me either. Using cf workers.

warm lake
#

Everything else seems to work. The only issue is the METHOD

plucky lance
#

Can you actually see more details about the request?

#

Like the content type?

plucky lance
#

hmm no full log then I guess

#

I would like to see the content type

#

is there actually any data send with the request?

#

I mean as GET request what is the entire request uri ?

#

Does it somehow include the GET parameter names and values the post request sends as body?

restive otter
#

yes

#

well

jaunty plank
restive otter
#

use a database and store the unix time they last voted

#

add +12 hours to the unix time they last voted and check if the current unix time is less

plucky lance
#

When this really is the entire log, then it really is a GET request

#

I'm not sure if cf somehow does redirect the post request (data) to a GET request

#

I would like to see the request uri

#

or query string log

#

then

paper crane
#

does anyone know how to setup topgg webhook on oracle vm

warm lake
warm lake
#

I seem to have solved the issue with the request being GET

jaunty plank
teal nymph
#

how can I show server counts?

plucky lance
plucky lance
#

The server count is the body/data not the header

#

You're also missing the content type header

vale grove
#

Dayumm

teal nymph
plucky lance
#

You have to send the data in the body

#

You tried to send it as header

teal nymph
#

oh

cobalt harness
#

reposting from #support
Hey! I've been building a bot using discord.py, and I used to use topgg's python API wrapper to show bot stats on the website. But that doesn't seem to work anymore, now that I've updated discordpy to 2.0
I'm extremely novice at working with APIs, and usually just work with a wrapper, are there any good and updated python API wrappers for Topgg?

jaunty plank
#

What's the error you got on the library?

I dont think we knew it broke? 👀

heavy jetty
#

@jaunty plank hllo sorry ping, there is

#

explain how dblwebhook and password?

#

and confuse

restive otter
#

/dblwebhook => the endpoint for the webhook call, will be needed to be written here:

#

What will be written there is something like http(s)://<ip/domain>:<port>/dblwebhook

#

password => the password that you choose, will be needed to be written here:

restive otter
heavy jetty
#

@restive otter thanks

odd karma
#

Hey, can someone explain how that's 3 arguments?

TypeError: __init__() takes 2 positional arguments but 3 were given
odd karma
#

@restive otter Help?

restive otter
#

How to make bot discord dms people ( thanks people ) after vote top.gg

wooden juncoBOT
#

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

abstract mothBOT
#

@restive otter

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

odd karma
#

Hey, can someone explain how that's 3 arguments?

TypeError: __init__() takes 2 positional arguments but 3 were given
boreal monolith
#

If someone votes for my bot while it is offline, how can I give them their rewards/perks once the bot is back online?

plucky lance
#

The vote event contains the user ID you can store in a database
Once your bot comes online, query the database and cache the results and you know who voted

#

But make sure this webhook listener doesn't go offline

#

Or you will most likely miss vote events

#

Alternatively you can also send a request to another endpoint of the topgg api getting the last 1000 users/voters iirc

#

Which you could also run once your bot starts for example

boreal monolith
plucky lance
#

No

#

You know the (current) timestamp of the vote only when receiving it as event

#

While event is the wrong word

#

It's actually a post request aka webhook

#

This isn't available when sending a request to the api to get the latest voters

boreal monolith
#

So other than having an event listener, there is no way to when the user has voted?

#

Can I use await get_user_vote(userid) to check if the user has voted in the last 12h?

plucky lance
#

Like I said you get the last 1000 voters at any time per request but the api will not provide the timestamps

#

If you need to know when somebody voted you will have to create a webhook listener in other words a webserver listening for post requests

restive otter
severe mauve
#

Hey can somebody help me with the topgg webhook? On the page I have it says "Cannot GET /dblwebhook"

#

Not getting any responses when testing it on topgg either

severe mauve
#

Nevermind! Got it all figured out and working! Changed stuff around and used postman til i got a response!

solid imp
#

After that (in your case) you will have to simply dm the user

molten arch
#

Hi , am trying to send a test webhook message from the site , but i keep getting errors

molten arch
#

An error has occurred while processing your request

#

thats all .

jaunty plank
#

on topgg?

molten arch
#

yes

jaunty plank
#

Try logging out and back in, if that doesnt work, try again in 10-15 minutes.

molten arch
#

and nothing , i will wait 15m and c how it goes and give you feedback

#

thanks for you help.

cedar widget
#

does anyone know what a snowflake type is ?
am throwing an int as a userId but am getting a 400 response
if thats the reason for the error tho

#

nvm, problem solved

restive otter
#

In case you're still interested what it is

crisp field
#

is the api required to update my bots server count on top.gg? i thought i read it somewhere!

restive otter
molten void
shut hornet
#

i has regenerate token and update new token to bot and i get this

jaunty plank
#

When you regenerate your token

regenerate
refresh the page
then copy

#

silly site bug

shut hornet
#
  • i regenerate 1 min ago
shut hornet
shut hornet
#

real selfbot

#

that is selfbot

jaunty plank
#

still getting unauthorized errors?

restive otter
#

💀

shut hornet
violet vault
#

Bruh

shut hornet
#
  • check on google
fluid crescent
shut hornet
violet vault
shut hornet
shut hornet
violet vault
jaunty plank
#

just to double check, you're sure you regenerated then refreshed then copied the new token?

#

the refresh is important

arctic rivet
#

It won't affect the Bot's session

arctic rivet
fluid crescent
#

How to post Servercount to top.gg

restive otter
fluid crescent
#

Thanks

shut hornet
shut hornet
shut hornet
stark wagon
#

from where I can get the topgg-auth-token? (ok got it i check pins and I get the video link but bruh I have to add my bot on topgg to get auth-token? is there any other way to get the token without this?)

solid imp
arctic rivet
# shut hornet Lol is not block

discord.py use a own session which inherited from aiohttp.ClientSession and if you use another client session it block the current Event loop if your response was late, also ClientSession handles only 1 ClientSession response at a time so if you creating 2 or more client session there is a chance to block your event loop.

shut hornet
arctic rivet
arctic rivet
shut hornet
#
  • my bot is not block by that
arctic rivet
shut hornet
arctic rivet
arctic rivet
arctic rivet
strong tiger
#

how do i get the api token

tidal idol
strong tiger
#

thx

mint relic
orchid lance
#

Hello it's topgg support blapi to post stats?

shadow silo
#

is server vote tracking supported? i'm yet to find anything on it

solid imp
jaunty plank
#

Webhooks work with bots or servers

#

Note: discord webhooks are not supported.

restive otter
jaunty plank
#

yeah

restive otter
#

Ok thx❤️

odd karma
#

Hey, can someone explain how that's 3 arguments?

TypeError: __init__() takes 2 positional arguments but 3 were given
restive otter
#

@odd karma what kind of tools u got

#

ig wrong channel

jaunty plank
# odd karma Hey, can someone explain how that's 3 arguments? ```client.topggpy = topgg.DBLC...

Hey, I'm not a python dev. I know python arguments can be a bit weird.

Looking around online, I got this.
https://stackoverflow.com/a/68011047

It sounds like you may need to use named arguments rather than positional arguments in your case.

#

I need to look into learning the basics of python, we don't really have a lot of python devs around to help here.

bright inlet
#

Hello, how can I display my monthly votes in my discord.js (please ping me)

jaunty plank
bright inlet
jaunty plank
#

It has examples.

const { AutoPoster } = require('topgg-autoposter')

const poster = AutoPoster('topggtoken', client) // your discord.js or eris client

^ copied from the provided example

bright inlet
#

Yes and where do I enter what I want at the end, in this case votes

jaunty plank
#

Oh, sorry I misread. I'm trying to do too many things at once ^_^.

What are you trying to do? receive vote events? or just use a vote count?

jaunty plank
#

Botinfo returns points & monthly points which is the number of votes.

jaunty plank
bright inlet
jaunty plank
#
console.log((await api.getBot('461521980492087297')).monthlyPoints)
bright inlet
#

thank you

bright inlet
jaunty plank
#

looks like you didnt use it in an async context

bright inlet
jaunty plank
#

try just this

console.log((await api.getBot('461521980492087297')))
#

Make sure you're updating the bot id to your own

indigo ridge
#

D

jaunty plank
#

what does it log?

bright inlet
#

nothink

jaunty plank
#

Is that part of your code running?

bright inlet
#

console.log((await api.getBot('996525009403117679')))
^^^
SyntaxError: Unexpected identifier

bright inlet
jaunty plank
bright inlet
#

yes

jaunty plank
#

hmm, I'm not sure then.
If you fixed the async issue I don't see why it wouldn't log.

jaunty plank
#

Or, you get an error that says cant read 'getBot' of undefined.

bright inlet
jaunty plank
#

Can you show the code you've used?

bright inlet
jaunty plank
#

Looks like you deleted the await, which is needed to resolve the promise.
It also looks like you commented out the console.log, which means it never runs.

plucky lance
#

cough token

jaunty plank
#

deleted for your protection

bright inlet
#

I had the await in it, but it didn't work either

#

the token and the password were not the real ones

jaunty plank
#

You have to resolve the promise

#

I provided a resource earlier for learning about promises

bright inlet
#

wait

#

console.log((await api.getBot('996525009403117679')).monthlyPoints)
^^^
SyntaxError: Unexpected identifier

jaunty plank
#

Yep, youll need to use that in an async context

jaunty plank
jaunty plank
bright inlet
jaunty plank
#

That page literally is covered in examples

bright inlet
#
   console.log((await api.getBot('996525009403117679')).monthlyPoints)
    }```
#

is this right?

jaunty plank
#

You could do that yeah, then call the function.

bright inlet
#

how do i do that then?

jaunty plank
#

You can call it like any other js function

#

test()

#

You wont be able to use it outside of that function though

bright inlet
#

do you have a example

jaunty plank
#

write test()

bright inlet
#

and then

jaunty plank
#

I dont know what else to say mm_cry

bright inlet
jaunty plank
#

Can you show the test function?

bright inlet
jaunty plank
#

and what are you logging?

bright inlet
#

[object Promise]

jaunty plank
#

I mean show the console.log

bright inlet
jaunty plank
bright inlet
jaunty plank
#

Just a small piece of advice, when asking for help. Tell someone when you're changing the code to something else.

Its so hard to follow what's going on when you just try stuff & I don't know it.

#

This was a 2 minute problem that took over an hour

cinder salmon
#

hi, i am trying to get the bots stats to put it on its site and i noticed to get the data i hade to first set the servers the bot is in to top gg i did like this (the java code one) and then i tried to import the package and access them in js but it got stuck on this line (the javascript code one)

cinder salmon
restive otter
cinder salmon
#

theres no errors

#

it just closes the file after that line

#

and also

cinder salmon
cinder salmon
#

gave u the things u asked

restive otter
#

You're not awaiting anything, plus it needs to be in an async context

#

Also, you can use console log to debug your code and help us in helping you

cinder salmon
#

i cant use console.log i am using react with vite

restive otter
#

You always can

cinder salmon
#

it doesnt work idk why

restive otter
#

It will show up in your browser's console

#

And these frameworks most likely have an alternative to log in your terminal as well

#

So you can either use console log or use the alternative for the framework, though console log works

cinder salmon
#

also adding await didnt change anything

restive otter
#

You're not awaiting anything, plus it needs to be in an async context

#

Otherwise just make a normal GET request to the API with the Authorization header

#

Though do note that everyone will see your token, it's frontend

cinder salmon
#

ok

cinder salmon
#

i did this (i am new to js thats why the bot is not in js) and it gave
ReferenceError: require is not defined (site)

jaunty plank
#

🤔 are you running this in nodejs?

jaunty plank
#

require is a feature of nodejs

cinder salmon
#

well its a node js project

#

by the package json and node modules

#

soo

#

?

#

bruh

#

when is someone answering.

jaunty plank
#

ah, well youll probably need to use imports, https://www.w3schools.com/js/js_modules.asp

plucky lance
#

does getStats(...) do the request?
If so you're doing two requests at once for no reason

cinder salmon
#

is this how u do it
import Topgg from '@top-gg/sdk'

#

cuz for me it doesnt work

#

says
SyntaxError: Unexpected identifier 'Topgg'

plucky lance
#

Show us how you execute your code

cinder salmon
plucky lance
#

Show us how you execute your code

cinder salmon
#

wdym

#

it executes right there and then it fails

plucky lance
#

How do you execute this code?
In which environment do you start it?

cinder salmon
#

this script is imported from an html file

plucky lance
#

I can't open txt files on mobile

#

So you're not running the code inside the nodejs environment

#

It won't work then

cinder salmon
#

well it imports it at the end and uses its passed values in here

cinder salmon
plucky lance
#

Those are nodejs modules
You're trying to run the shit as script in your site

#

Makes no sense and will never work

cinder salmon
#

i said i am new to js so idk what really i am suppose to do

#

so can u give a little help

plucky lance
#

If you wanna make the request then use native JS methods like fetch

#

You can't import the nodejs package into your native JavaScript script

cinder salmon
#

well i did try that but idk how to pass the token

plucky lance
#

As part of the header

#

{ "Authorization": "token" }

cinder salmon
#

ok

plucky lance
#

What u can also do is to create a nodejs project fetching that api stats from topgg and saving em in a database

#

Then query the database in your backend and show the stats on your website

#

Generally fetching the api stats on your website will get you rate limited really quick if it happens on each request

#

If I'm gonna spam F5 for a few seconds hundreds of requests will be made

#

So... you should rethink your concept probably

#

And go with a save method like storing the stats in your database and query this database

cinder salmon
#

but i dont have a database so how am i going to do that

#

also is this how u fetch with the token

#

oops put my token

plucky lance
#

Anything is better than doing the request if somebody loads your site

cinder salmon
plucky lance
#

brb good time for @jaunty plank to jump in

cinder salmon
#

i gtg soon like in 5 mins

jaunty plank
#

tbh, this is out of the scope of what I can help with tonight.

cinder salmon
plucky lance
#

Yeah that's the native fetch api

plucky lance
#

but it should be fetch(url, { headers: { ... } });

#

iirc

#

As reference

cinder salmon
#

thx it works now i am going to make it save the data on a db

twin galleon
#

Do i have to list my bot to the website to get the api details even if its a bot only my server uses? is there like a toggle option to now list the bot?

#

^ if so can i link another bot application and use my tokens on another bot?

jaunty plank
jaunty plank
twin galleon
jaunty plank
#

You can track votes without listing a bot.

Servers get webhook access, you can store webhook requests in a database to track it.

twin galleon
#

Amazing thank you, i was attempting to do it through npm package but this will work perfectly, thank you for your help!

fervent pasture
#

What link do I provide for users to vote for my bot?

crisp field
#

just got a Gateway Time-out on the api is this normal or?

restive otter
#

it's an issue on top.ggs end, nothing u can do

icy aurora
fierce elbow
#

Guys hello,

#

I want to do voting is required to use the command. how can I do it?

restive otter
hazy kayak
#

Any reason why I keep getting this error when attempting to post stats?

hazy kayak
icy aurora
#

You can’t do anything about it

plucky lance
icy aurora
#

?

plucky lance
#

His system can not reach the host

hazy kayak
icy aurora
#

Usually it’s top.gg end most of the time

plucky lance
plucky lance
hazy kayak
#

Oh wait

#

it says the address is unreachable now..

#

erm

icy aurora
plucky lance
#

Yeah either an issue with your dns server or a firewall block connections to port 443

hazy kayak
safe pewter
#

Hi, how can I use on_dbl_vote on discord 2.0? I tried a lot of things but nothing worked

hazy kayak
plucky lance
#

It's the first time happening?

hazy kayak
#

Mhm

plucky lance
#

Definitely an issue on your end

#

I tried many different hosts now and all without issues

#

IPv4 and v6

hazy kayak
#

Is there a way I could possibly fix it?

plucky lance
#

Just to test add a different nameserver

#

sudo nano /etc/resolv.conf

#

Add a new nameserver below

#

nameserver 8.8.8.8

hazy kayak
#

Mk

plucky lance
safe pewter
plucky lance
#

(a few times)

#

See if it fails again

hazy kayak
plucky lance
#

Ok this is much more confusing then

hazy kayak
#

😵

plucky lance
#

Add nameserver 127.0.0.53

#

As first line

#

If that still doesn't work you will probably have to check or and edit the netplan

#

To see what nameservers are configured in there

hazy kayak
#

Mk

plucky lance
#

Gtg right now unfortunately

#

But also try different nameservers

hazy kayak
#

Sad

#

Mk

#

Thanks

plucky lance
#

Maybe opendns etc

#

If the issue still persists get back to me tomorrow

#

Just ping me and I will reply asap

#

Good luck topggWink

hazy kayak
#

Alr thanks!

jaunty plank
safe pewter
#

dpy 2.0

jaunty plank
#

are you getting an error?

safe pewter
#

I want to know if the function on_dbl_vote support dpy 2.0, if not, what I can do for this works and get in real time who voted

jaunty plank
#

I dont see why it wouldnt

safe pewter
#

I lot of people are asking the same think as me here in this chat, nobody get a solution?

#

.

#

.

jaunty plank
#

Did you configure your webhook on the site?

safe pewter
#

yes sir, I can get the wekbook work with the test function

#

but the vote function not

jaunty plank
#

👀 show the code please

safe pewter
#

do you know python and know dpy 2.0?

#

if not u cant help me

jaunty plank
#

I just tested the py library last week and confirmed it works.

#

Sure, gl then 👀

safe pewter
#
...
import topgg
...
class Bot(commands.Bot):
...
    @commands.Cog.listener()
    async def on_dbl_test(self, data):
        print("voted test")
        print(data)

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print("voted oficial")
        print(data)
...
    async def on_ready(self):
        self.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "pass")
        self.topgg_webhook.run(5000)  
        await self.on_dbl_test(self)
        await self.on_dbl_vote(self)

I tried to insert the topgg_webhook in setup_hook but same problem, I dont have a response from on_dbl_vote

#

I appreciate if someone that are using dpy 2.0 help me

restive otter
#

Second, you're missing self as the first parameter. You might want to look at how OOP works in Python

safe pewter
#

I receive the webook when I click the test button and when someone vote, but I want that I bot get his ID to reward him

restive otter
safe pewter
#

abotu the self, I edited my post, but I already tested it and I dont get the vote from my bot

restive otter
#

You are running a web server on port 5000

#

That web server needs to be reachable by Top.gg, hence have a public IP that allows connections to the port 5000

#

And you need to write http(s)://<ip/domain>:5000/dblwebhook in the bot's webhook settings

safe pewter
restive otter
#

Correct, as you make the handling of posted webhooks yourself

safe pewter
#

self.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("https://IP:5000/dblwebhook", "pass")

jaunty plank
#

On topgg

#

Also http not https

safe pewter
#

oh I see

#

in this case, auth I put something or I dont need it?

jaunty plank
#

The auth is what you have in "pass"

safe pewter
jaunty plank
#

The auth webhook-topgg uses is just the discord webhook auth.

Which you're not using here.

safe pewter
#

how can I get the data from on_dbl_test? I need to do something in "on_ready"? I even need it? dpy 2.0 is complicated

#

await self.on_dbl_test(self) i'm getting the data from my bot when I click on test, not from myself

quartz parrot
#
//top-gg vote tracker
const express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express()
 
const webhook = new Topgg.Webhook('psiIBvCxfGbSNggHJ') 

app.post('/dblwebhook', webhook.listener(async vote => {
    console.log(`[Vote Logs] ${vote.user} voted for ${vote.bot}`);
}));

app.listen(3000) 
console.log(`[Webhook] Top.gg webhook is ready`);

this is what i have in my code rn and the webhook url i have set to http://123.123.37.107:3000/dblwebhook

but nothing is being logged into the console when i try sending a test
also the ip i need to use is my IPv4 right? i am running this locally

restive otter
#

When I try to ping the IP I get 100% packet loss.
Top.gg won't be able to reach the IP either so it won't be able to send you any webhooks.

You can also see yourself that it will never work by going on the website yourself with another device, e.g. your phone.

#

If it's the IP of your computer, you need to do port forwarding. You can search on Google how to do that.

#

If it's the IP of a VPS, contact your VPS provider to make sure the port 3000 can be used and double check the IP, as it should be obviously be possible to ping it, even if the port 3000 is blocked.

#

Seeing that the IP comes from

China Unicom
I suppose that is your personal, computer, IP. Unless your VPS uses that company obviously..

#

Nonetheless, nothing we can do before you did both things above.

quartz parrot
restive otter
unique ruin
#

is it possible to run the webhook server on VS code

jaunty plank
unique ruin
jaunty plank
#

Yeah, youll need to port forward though

unique ruin
#

how can I do that?

#

like on the top.gg page in webhook, i set the webhook url to https://my_ip:51705/dblwebhook

#

ah i got it

native dust
#
const webhook = new Topgg.Webhook(my bots topgg auth)
app.post("/dblwebhook", webhook.listener(async vote => {
console.log(vote)
}))

why this code isn't working?

native dust
#

where is the problem

dire lake
jaunty plank
jaunty plank
restive otter
#

what do i put in webhook url if i use the example in top.gg python library?

jaunty plank
restive otter
jaunty plank
# native dust yes

Just to clarify, you didn't use a discord webhook, nor a third party service(webhook-topgg for example) as the url correct?

jaunty plank
restive otter
#

alright thank you i love you

jaunty plank
#

I think the default example port is set to '5000' in the py lib, and the path is '/dblwebhook'

jaunty plank
jaunty plank
#

did you set the port&path correctly?

jaunty plank
dire lake
#

Where can i see server count that i posted using api

restive otter
dire lake
restive otter
#

on your bots page

#

and beside the name in searches

dire lake
#

Gotcha

viral bobcat
#

In here i put the url of my webhook right?

restive otter
#

no

#

top.gg webhook != discord webhook

viral bobcat
#

Oh

#

Then what do i put there?

jaunty plank
#

It'll be the url to your webserver

hazy kayak
candid vale
#

I am also getting that error

jaunty plank
#

When you run the code from a home computer does it work?

valid sage
#

how i can get total of votes with package (topgg/sdk something like this ....)?

valid sage
jaunty plank
valid sage
#

To get votes i will use methon getVotes()?
@jaunty plank

#

method*

jaunty plank
#

Get votes will get all users who voted within the past 12 hours.

somber matrix
#

YEPW Am i the only one who somehow cant install topgg-autoposter? Like everytime i install it and start the bot the log says that this module is missing and when i check if its there its somehow gone. Any ideas how to fix this?

jaunty plank
somber matrix
#

It wont even start on local

#

So i didnt bother to try there

jaunty plank
#

Are you getting any warnings/errors during install?

somber matrix
#

No

jaunty plank
#

I'd add it directly to the package.json and do npm i

npm i installs everything in the package.json dependencies

jaunty plank
#

If you install another library and use it does it also not install?

#

Like express or something

somber matrix
#

No it does install, i have topgg already installed but the autposter is somehow buggy or something.

#

I already contacted the support of the hosting to try to help me with resolving this issue

quasi fjord
#

how do you specify port in this example shown

restive otter
quasi fjord
#
import discord
from discord.ext import commands
import asyncio
import topgg


@topgg.endpoint("/dblwebhook", topgg.WebhookType.BOT)
async def on_bot_vote(vote_data: topgg.BotVoteData, client: commands.Bot):
    if vote_data.type == "test":
        print(f"Received a test vote by:\n{vote_data.user}")
    else:
        print(f"Received a vote by:\n{vote_data.user}")
        user = await client.fetch_user(vote_data.user)
        await user.send("Thanks for voting for our bot on top.gg!")


@topgg.endpoint("/dslwebhook", topgg.WebhookType.GUILD)
async def on_guild_vote(vote_data: topgg.GuildVoteData, client: commands.Bot):
    if vote_data.type == "test":
        print(f"Received a test vote by:\n{vote_data.user}")
    else:
        print(f"Received a vote by:\n{vote_data.user}")
        user = await client.fetch_user(vote_data.user)
        guild: discord.Guild = await client.fetch_guild(vote_data.guild)
        await user.send(f"Thanks for voting for {guild.name} on top.gg!")


class Topgg(commands.Cog):
    def __init__(self, client: commands.Bot):
        self.client = client
        self.webhook_manager = topgg.WebhookManager().set_data(self.client).endpoint(on_bot_vote).endpoint(on_guild_vote)

    @commands.Cog.listener()
    async def on_ready(self):
        if not self.webhook_manager.is_running:
            await self.webhook_manager.start(port=5000)


def setup(client):
    client.add_cog(Topgg(client))
    print("Topgg cog loaded")
#

this should work right

#

im still waiting for my bot to get accepted so i cant test

#

i tried doing a post request using https://reqbin.com/

#

didnt seem to work

#

im using https://railway.app to host my bot btw
i did add port as a variable

Railway

Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.

quasi fjord
jaunty plank
#

Is it just a connection error?
Are you sure you're using the correct url?

quasi fjord
#

yeah I'm sure

#

I'll wait till my bot gets accepted so I can actually test it

grave geyser
#

Do I use top.gg autoposter to get "Top Discord Servers Using This Bot" on my top.gg bot page? Or how does it work?

#

oh nvm

restive otter
#

what is the webhook authorisation

#

If you're running that code from your computer, have you setup port forwarding correctly and given the right IP in the bot's settings on Top.gg?

restive otter
compact lily
restive otter
#

Define

it doesnt seem to be working
Saying "it's not working" is not helpful at all, you can provide error codes etc.
Also share code as well

restive otter
#

is the top.gg api broken?
im providing a valid user id but it gives an error of not found
in

 let user = await api.getUser(userid)```
@top-gg/sdk btw
silk echo
#

what are you trying to do?

restive otter
empty gazelle
restive otter
#

w h a t

empty gazelle
#

yeah im a js pro

restive otter
#

🗿 ..

silk echo
compact lily
#

where do you put the authorixation code in a link?

compact lily
#

its giving me {"error":"Unauthorized"}

silk echo
compact lily
#

i have but it doesnt show were to but the thing

empty gazelle
vapid tulip
#

Hello @restive otter

restive otter
#

Hello @vapid tulip

vapid tulip
#

Hello

restive otter
#

is the top.gg api broken?
im providing a valid user id but it gives an error of not found
in

 let user = await api.getUser(userid)```
@top-gg/sdk btw
#

repost

vapid tulip
#

they don't even know it

compact lily
silk echo
#

what programming language do you usually use?

compact lily
#

wait nvm im stupid i found it

silk echo
#

lmao ok

tardy skiff
tight willow
#

/leaderboard

wicked nacelle
#

do i need to own a domain to set up a webhook?

restive otter
#

just a public ip and a web server

wicked nacelle
#

im not good with domain/ip stuff

jaunty plank
#

It might help to read a few things so you understand them.

All a domain does is refer to an ip(super simplified)

So for example

https://google.com/

Might turn into

https://2.2.2.2/

#

Imo, a good 10-15 minutes of research on how http and domains work will make the process of implementing webhooks way faster.

wicked nacelle
#

thank you!

modest sandal
#

what's this error supposed to mean

#

it keeps crashing my bot whenever it pops up

fluid crescent
#

Ig u put wrong link

#

Ig this is the link

#

@modest sandal

mint cloak
#

Is there any way to post the status of the bot without using the package?

jaunty plank
mint cloak
jaunty plank
#

Post stats uses the body for that information.

I dont think it supports url parameters.

mint cloak
#

I'm confused...

#

because using the package, the status only updates when the bot restarts, at least for me that's how it is

candid vale
# modest sandal what's this error supposed to mean

I was having this issue the other day (connect EHOSTUNREACH 2606:4700::6810:ae38:443). I use the topgg-autoposter library. It was happening even when restarting the server, but now it is working fine. Any help?

lime island
#

how i can update bot stats?

#

only say {"shards":[]}

#

nvm forget

hollow gate
#

Yes

#

const ap = AutoPoster(process.env.topggtoken, client)

ap.on('posted', () => {
console.log('[AUTOPOSTER] Posted Stats to Top.gg!')
})

#

@lament pawn

#

And for example two-three days ago worked, now not

#

already done that.

mint cloak
hollow gate
vocal robin
#

Is there an endpoint to get all bots of an user?

restive otter
#

Is the api down? I am getting a Gateway time-out

vocal robin
#

yes

thin talon
#

...

near burrow
#

Hi

restive otter
mint onyx
#

@restive otter hello my brother

latent frost
#

Having 504 error

restive otter
#

Wait some time, should resolve by itself

#

Hello, I got this in the conole
TopGGAPIError: 504 Gateway Time-out

#

look above

#

it’s a issue with top.gg should fix itself

#

Ah sorry, seems to fine now

#

Thanks

untold osprey
#

I need to get information about those who vote for the server (not a bot)

#

i use topggpy

hasty valve
#

Hello, how do I use the api to find out when the user voted on my server?

solid imp
kind barn
#

...

empty flame
#

the topgg api for what it is

jaunty plank
thin violet
#

How can we check if the user voted for our bot in past time ?

thin violet
solid imp
thin violet
# solid imp you need to pass an auth token while making requests to the api

Here's what I tried !
Note : I've assigned my top.gg bot token to the variable self.tgt
When I was trying to get the value of "voted" variable I wad getting an error so took complete data as an output which was something like {"error" : Forbidden}
Please do tell my what's the mistake in this code

async def check(self,ctx, user: discord.Member):
      async with aiohttp.ClientSession() as s:
        async with s.get(f'https://top.gg/api/bots/751100444188737617/check?userId={user.id}', headers={'Authorization': self.tgt}) as r:
          data = await r.json()
          await ctx.send(pain)
          if data['voted'] == 1:
            return "True"
          else:
            return "False"
lime island
#

i dont understand

#

the bot only return {"error":"Required parameter server_count or shards missing"}

#

i used post

restive otter
#

You need to pass the parameters in the body as JSON

#

Not sure what method you use to post but with fetch a basic example would be:

fetch("URL", {
    method: "POST",
    headers: {
        "Content-Type": "application/json",
        "Authorization": "TOKEN",
    },
    body: JSON.stringify({
        "server_count": 1337
    }),
});
lime island
#

ohhhh okay

restive otter
#

Using ?x=y and &x=y are so called query parameters and more used for GET requests CatJAM

#

Hey, i need a api key for my bot please, how to get one?

jaunty plank
restive otter
#

Okok, thx ^^

hasty valve
#

How do I get the webhook and authorization from a server? I want the bot to get information when x user votes on the server

#

when I open the "webhook" tab in the dashboard, it only shows empty fields

heavy oriole
#

I am unable get notification via webhook in discord.

rain heart
#

you cannot use discord webhooks as you've been told already

restive otter
icy aurora
#

http://<your ip or domain>:<port>/dblwebhook

restive otter
#

Not necessarily /dblwebhook either

icy aurora
heavy oriole
icy aurora
#

your webhook server

unique ruin
#

@restive otter

restive otter
#

Yup

unique ruin
#

You're using js?

restive otter
#

Python

unique ruin
#

Okay wait

restive otter
#

Serum owner...oh

#

Kronton bro ko toh phir jante hoge

restive otter
#

Hm

#

Thx

unique ruin
restive otter
#

Yup

#

@unique ruin how I can get top.gg id

unique ruin
#

which id?

restive otter
unique ruin
#

where did you saw that?

restive otter
#

-topggid

wooden juncoBOT
#

topgg Finding Your Top.gg User ID

You can find your Top.gg User ID on your Top.gg profile.

Follow these steps to find your Top.gg User ID:
topggDotRed Click here to navigate to your profile.
topggDotRed Copy your Top.gg User ID from the address bar.

abstract mothBOT
#

topgg Finding Your Top.gg User ID

You can find your Top.gg User ID on your Top.gg profile.

Follow these steps to find your Top.gg User ID:
topggDotRed Click here to navigate to your profile.
topggDotRed Copy your Top.gg User ID from the address bar.

unique ruin
#

💀 oh the user id

restive otter
restive otter
#

How I can get??

unique ruin
#

the token is the webhook one i guess

restive otter
#

You can get it on your bot's page when clicking "Edit" and going into the webhook section

#

Ok

#

getting error

#

Without code, can't help

#

w8 i am giving

#

Have you actually defined bot

#

It is supposed to be your bot instance in your code

#

yup

#

wait

#

Why bot = bot = ... and is it in the same file

#

still getting same error

restive otter
#

i solved

#

it

#

and it is in

#

same file

#

Then I recommend to reorder your imports and where you have them located

#

As said, I recommend to reorder them

#

You never have a random import in the middle of your file

#

Imports go at the top of your file

#

ok

#

Still getting

#

Same error

#

Thought you solved it..?

#

Regenerate your Top.gg token on your bot's page, then refresh the page and then copy the token.
Make sure to refresh the page between regenerating the token and copying it.

restive otter
#

Ok

restive otter
#

how much time did it take

#

profile

#

Approximately 30 minutes CatJAM

restive otter
#

how could i make vote only command?

#

Yeah

restive otter
#

Nothing static

#

You will need to have there the ID of the user you want to check if they have voted

restive otter
#

I don't know, depends where you want to check if a user voted

#

ok

#

If you want to check if a user voted for the bot in an event, it will be in the event's function

#

If you want to check if a user voted for the bot in a command, it will be in the command's function

#

If you want to check if a user voted for the bot in a task, it will be in the task's function

#

etc.

#

Then you will need to add the code in your command's function

#

which one

#

Every command you want to have the user to vote to use it?

#

like this?

#

Why an event?

#

You just said you wanted in commands

#

yes

#

Then write it in your command, not in a new event that will never get fired

#

yeah

#

like this....

#

Try it and see

#

error

#

Your bot object doesn't have the topggpy attribute, as the error says

restive otter
#

Define the topggpy attribute for your bot's object

#

how

#

Have you learned Python already?

#

yes

#

Have you learned about classes

#

yes

#

Then you know how to fix it CatJAM

#

ok i understand

ebon kite
#

-topggkey

#

-topggapi

#

wow f

#

man how do you get your api key

#

so can you check if someone has voted

restive otter
#

You can get it on your bot's page when clicking "Edit" and going into the webhook section

ebon kite
#

alr lemme

#

thanks

#

btw

restive otter
charred flower
#

Is the api closed?

restive otter
#

No, try again later

orchid badger
#

How can I make servers appear like that?

orchid badger
brave raven
orchid badger
restive otter
orchid badger
#

Thanks

orchid badger
restive otter
orchid badger
restive otter
#

there also some libraries that could make it simpler for you

#

what language are you using?

orchid badger
#

javascript

restive otter
orchid badger
orchid badger
# restive otter probably?

I made it like this:

const client = new Discord.Client() // Your discord.js or eris client (or djs ShardingManager)
const { AutoPoster } = require('topgg-autoposter')

const ap = AutoPoster(process.env.token, client)

ap.on('posted', () => {
  console.log('Posted stats to Top.gg!')
})```

But it returns that Discord is not defined
restive otter
#

Import it or use your current client object

#

It clearly says that it's your discord.js client definition, so you know what it should be

runic creek
#

And I hope process.env.token is indeed a top.gg token and not your bot's token

mystic yew
#

Does voice connection still exists?

#

Or chat GPT is outdated

restive otter
#

Never existed, don't rely on AI as source of information

flint dust
#

does the DBLClient class close itself after sending out the request, because I don't see the coro being used afterwards ... ?

#

asking for the API library in py

delicate moth
#

Hello i have question i want add code to my bot if anyone vote the bot send dm thank to user is there package or smt do like that

rain heart
#

depends on language you're using

earnest dove
#

you can either use the request api:

https://top.gg/api/bots/<botID>/check?userId=<userID>
or use socket (webhook), which is recommended for your use case, you can find package in pins if there is one

rain heart
#

socket? why would you need socket for that

earnest dove
#

meant the webhook thing

restive otter
#

For their use case only webhooks make sense

tired hamlet
#

How do I setup Fibo? I cannot find webhooks at all on Top gg

rain heart
#

Fibo?

tired hamlet
#

Fibobot

wooden juncoBOT
#

topggDotRed Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Discord Support Server" button on the bot's page of the bot you need support for. If there isn't a button that says "Discord Support Server" or nothing else mentioned about a support server, the server invite is invalid or you were banned from the bot's support server, then we can't help you. Sorry :(

abstract mothBOT
#

topggDotRed Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Discord Support Server" button on the bot's page of the bot you need support for. If there isn't a button that says "Discord Support Server" or nothing else mentioned about a support server, the server invite is invalid or you were banned from the bot's support server, then we can't help you. Sorry :(

orchid lance
#

Hello, how to get Total vote and Vote Strike ? in user

rain heart
#

you need to track that yourself, Check the pins

vestal wasp
#

hi, is there any way of getting reviews/the amount of stars of a bot?

rain heart
#

theres not

#

and will not be a Feature possibly, according to the feedback site iirc

earnest dove
#

not an official way, but, everything's possible 😏

restive otter
#

yes scrape your bots page

earnest dove
#

POST https://api.top.gg/graphql gives reviews (look up in network log for more info 🤓)

vestal wasp
#

yeah I might just use some user token

#

if it even requires one

rain heart
#

also undocumented endpoints = probably no Support

earnest dove
#

well it wouldn't necessarily be detectable but yeah

jaunty plank
#

Reccomending it is probably not a good idea though

vestal wasp
#

then make an public endpoint lols

rain heart
jaunty plank
#

Reviews probably will never be a public endpoint.
Since rewarding/incentivising users reviews is against our policies and most people would use it to give rewards its probably not a good idea

vestal wasp
#

then just give devs the total ⭐ of the bot itself?

jaunty plank
#

That's something that I'd like to see added yeah.

vestal wasp
#

or like some sort of widget to embed on a website that shows the total stars

#

like trustpilots

silk echo
#

i am getting 401 error when posting stats

#
const token = process.env.topgg as string

AutoPoster(token, bot)
  .on('posted', () => {
    console.log('Posted stats to Top.gg!')
  })```
restive otter
#

Why does the topgg api ratelimits too fast?

#

I've vote only cmds. After every restart in 1h only it ratelimits

#

Top gg should increase ratelimit time

restive otter
#

How do I do that

#

Use it?*

#

read the docs

#

click the link

#

Why not <Api>.hasVoted(user id)

#

SuS

#

?

#

Topgg should increase ratelimit duration.

#

no

#

webhooks exist for this reason

restive otter
#

use webhooks and dont abuse api

#

simple

#

How to setup webhook.*

rose briar
#

how to get list of who voted for my bot or server? in python

restive otter
tight crane
#

Fibobot

#

-topggid

#

-botinfo 1024717443916107786

rain heart
floral egret
#

Not always but sometimes while posting bot status to top.gg I get this error.

I got this from console:

response: {
status: 504,
statusText: 'Gateway Time-out',
headers: AxiosHeaders { ... },
.....
}
restive otter
#

nothing u can do bout it

normal ridge
#

Not always but sometimes while posting bot status to top.gg I get this error.

restive otter
floral egret
restive otter
#

5xx errors are server errors you can't do much about as a user/client other than trying again later

floral egret
#

Hm okay. Thanks 👍

frail meteor
#

Anybody else having issue sending stats through the API?
Confirmed the API token we are using is valid.

restive otter
#

Error suggests API token is not valid.

#

Reset the token, refresh the page and then copy it

frail meteor
#

I figured that at first, and have reset the token and confirmed the new token is being used, still getting the same message

restive otter
#

Error still says the token is invalid

rain heart
#

have you refreshed the page after regenerating the token? as regenerating the token will not display the correct one until the site was refreshed

normal ridge
#

Owo hunt

old forge
restive otter
#

how to get topgg token

wet sun
#

Hello I was wondering if someone could help me and explain how to set up a webhook in my python bot to receive a user id of anyone who votes for my bot

solid imp
solid imp
restive otter
#

Hello! My bot has a vote based command, meaning the user can't use it unless they vote but it seems like most of the time the API is returning 504 Gateway error which is causing trouble for my bot, why is it? am I hitting rate limit?

#

no, as I said it’s an issue on top.ggs end

#

@restive otter sorry for pinging you here, but if it's not on their end then what's the issue?

#

there’s nothing you can do about it

#

except trying again

#

I mean what is the actual issue and why is this happening?

#

A gateway timeout, as it says

#

but there’s nothing you can do sadly

earnest dove
#

top.gg is experiencing some issues currently (allegedly)

restive otter
#

I see :/

#

yeah

#

It usually is

#

😁

#

I didn't had an anticrash and my bot was crashing over and over

earnest dove
#

fun

restive otter
#

catch the error

#

yeah added it

#

the thing is I coded this bot just for fun, so my codebase is hella messy and the bot skyrocketed out of nowhere. Now I need to rewrite the whole thing if I wanna fix it

compact lily
#

how do i get when a user voted

#

eg: 1828 (secs ago)

restive otter
tulip mist
#

how to make topgg show the right number of bot servers

jaunty plank
#

youll need to post your bot's server count to topgg using our api or one of our libraries

jaunty plank
#

Youll need a topgg token, which can be found on your bots edit page in the webhook section.

tulip mist
#

k

#

i did post it and nothing changed @jaunty plank

jaunty plank
#

it can take 30 minutes to update

tulip mist
jaunty plank
#

users see your real server count when inviting your bot.
if we catch you posting incorrect counts we will ask you to fix it or you may be banned from our site.

tulip mist
jaunty plank
#

how will your bot? or us?

tulip mist
#

how will the user who add my bot see its server count

jaunty plank
tulip mist
#

alright

jaunty plank
#

its on the page users invite your bot on

tulip mist
#

just noticed it

solemn shard
#

💀

rain heart
#

welp

#

follow ratelimits, check the docs for the ratelimits

restive otter
#

Why not, why can't. How to?

rain heart
restive otter
#

Oki

astral egret
#

now that my bot is approved i need to reward my users who votes the bot

#

does api generate any event when user votes the bot?

restive otter
astral egret
restive otter
astral egret
#

im hardly getting by by hosting bot on free vps service

#

guess i dont have any choices then

#

getting events in api itself sure sounds nice tho

jaunty plank
#

The api is just an api.
It can't provide events like a websocket does.

#

The way an api like topgg provides events is webhooks. Which is pretty standard.

short verge
#

nvm

restive otter
#

…?

#

ghost ping

short verge
#

sry

#

i was just dumb

restive otter
#

alr

candid vale
#

I am getting this error when using the topgg-autoposter package. It does not happen every time, but it is fairly common. Any help or idea of what's causing the issue?

jaunty plank
candid vale
wet sun
solid imp
wet sun
#

I havent found any

wet sun
wet sun
#

Okay so I found the code but I dont understand what "route" is like is it the "Webhook URL" posted on your Top.gg bot?

#

Cause I used that in the code and im not receiving anything

#

Or maybe I am and I cant see it I dont know

#

I think most likely none of this is running at all and im doing something super wrong

wanton sluice
#

hello i use topgg autoposter to post stats on bot but it only show one cluster information (i use discord-hybrid-sharding npm for shard staff)

#

is there any way to fix this ?

astral egret
#

isnt there any way to get when user voted the bot in c# library without using webhooks?

rain heart
#

no, the api does not provide that data

#

has to be tracked yourself using webhooks

lime island
#

To update the statistics of the bot I only use the same method of server_count?

wet sun
#

Can anyone on this discord server please help me and explain this to me

jaunty plank
wet sun
#

The webhook to discord thing you made is very impressive btw