#topgg-api

1 messages · Page 4 of 1

rain heart
#

catch the error if it fails

#

or better yet, just echo back the exception directly

sullen mortar
#

ex.printstacktree not print anything

rain heart
#

can't help then if there's no errors at all

#

completableFutures should have another method call to get the exception

sullen mortar
#

i cant help me too becase there is not here any error

#

i will try something

dawn nexus
#

I see a fellow java user

#

very proud of this

sullen mortar
#

I see you are Java user too

plain panther
#

Has topgg api changed or is there some error in the api.. my bot has 1 one yet it seems it handles or gets 14 votes even the member who voted their usernames aren't updated with votes yet

rain heart
#

elaborate "gets 14 votes" and "usernames arent updated with votes yet"

plain panther
rain heart
#

checked myself, the API returns 3

#

380 total, 3 month

plain panther
hot sigil
#

Yo

solid imp
#

This isn’t the right place for that

restive otter
#

.-.

solid imp
#

A quick Google search would help you however

restive otter
restive otter
#

and when i try someone

solid imp
#

No, sorry. Like I mentioned, this is not the channel for that, for general conversation move over to #general

restive otter
#

it doesnt even work

regal osprey
#

eDDy#0001

restive otter
copper cypress
#

It only takes discord.Client? Not commands.Bot?

#

Oh I probably can't use this anyways, I use nextcord.

restive otter
#

Just make the appropriate POST requests, you don't need the library

restive otter
#

krypton appears to be offline, don't be so pushy

jaunty plank
copper cypress
#

So I'm too sure about that one

jaunty plank
#

I won't be helpful with that.

I've never used python, however the code example I linked to is everything you need.

tribal ibex
#

Does in (replace your bot id) in the webhook tutorial mean the in-app discord id,application id or client id

restive otter
#

The in-app ID, the application ID and the client/bot ID are all the same. Simply copy the ID from either in-app with right click, or go on the developer portal and copy the application ID

tribal ibex
#

uh i dont quite understand what url im supposed to put in the "Webhook URL" part in top.gg

dire lake
#

Is there api to reward people through bot when they vote for servers?

plain panther
#

Once user vote it will send a request to given webhook url from that you can then give user role by using discord api or various other discord api using packages. ig

restive otter
#

like the man above me said

stray halo
#

@jaunty plank

magic terrace
#

Can I make my bot say how many votes it has on TopGG?

solid imp
tribal ibex
#

uh i dont quite understand what url im supposed to put in the "Webhook URL" part in top.gg

jaunty plank
tribal ibex
#

whats a webserver?

restive otter
#

where you host your website

tribal ibex
#

but how do i make one my own

#

im trynna do the voting reward system thing

#

and im very much struggling lol

grizzled flicker
#

@

solid imp
#

They make the job easier, but you could use any http module that can create a server that your language supports

jaunty plank
rain heart
#

can y'all not

opal grove
#

bloxfruit trading discord

#

where i can find?

dim kettle
deft hollow
#

Stats posted but vote system didn't work

rain heart
#

deleted, code contained token

reset the token before asking again

deft hollow
#

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

    init(bot){
    try{
    
    
    
    AutoPoster('', bot)
  .on('posted', () => {
    console.log('Posted stats to Top.gg!')
  })
    
        
      const express = require('express')
const Topgg = require('@top-gg/sdk')

const app = express() // Your express app

const webhook = new Topgg.Webhook("hama1234+") // add your Top.gg webhook authorization (not bot token)

app.post('/dblwebhook', webhook.listener(async (vote) => {
  
  const dUser = await bot.users.fetch(vote.user)
  const member= await User.findOne({userID: dUser.id}) || await User.create({userID: dUser.id});
  member.money = member.money + 1200;
  member.save();
  dUser.send({content:`You are Voted BoBo amd gave your 1200 BoBo money`}).catch(()=>{});
  const logsChannel = bot.channels.cache.get(config.votes.channel);
  if(logsChannel){
    logsChannel.send({content:`${dUser.tag} Voted BoBo bot id: ${dUser.id}`})
  }
  
  // vote is your vote object // 221221226561929217
})) // attach the middleware
//app.listen(8080) // your port
      
      
      
      
      
      
        
        
    }catch(err){
    return console.log(err.message)
  }}

};```
deft hollow
rain heart
#

my fair guess would be, have you set your webhook URL on the webhook section of your bot page settings?

deft hollow
#

I set discord webhook

jaunty plank
deft hollow
stray halo
#

Classic rookie

tidal idol
# stray halo Classic rookie

I wouldn’t call that a rookie thing, whilst it’s not the best option it’s usually the only option they can use within their budget (usually 0)

#

Also that’s kinda off topic for this channel so 👺

stray halo
#

Eh replit isn't good.

deft hollow
#

When my plan of replit ened I will change host

waxen knot
#

Hello! Im trying to setup the webhook but the request body seems to always be undefined

#

nvm figured it out

#

expressjs needs a middlewear to get body

tiny relic
#

Jo Hey

#

I have question, since discord.py was updated to 2.0, topggs server count post isn't working anymore... any fix or something?

restive otter
#

Make a POST request by yourself with aiohttp

restive otter
#

how to make notify upvote bot discord(in my sv discord) in top.gg ( it maybe a webhook?)

#

Same this

#

Create link webhook in sv discord?

restive otter
restive otter
#

In your bot's page when clicking "Edit" and in the "Webhooks" section

restive otter
wild coyote
rain heart
#

reach out to their support in this case

wild coyote
restive otter
#

"Contact" in the bottom left corner

wild coyote
#

cant i get help in the discord server?

rain heart
#

this channel is for support around the top.gg api, not 3rd party tools

#

reach out to their support to receive help

wild coyote
#

@rain heart how can i add webhooks in the profile ? cuz i cant (bot still pending)

last shore
#

@rain heart sorry to say my bot ArPmix that i have sent to verification is offline due to the hosting provider error
Or
I would like say "Host error"

restive otter
restive otter
restive otter
#

In that case it will get declined for being offline, you will always be able to resubmit it

last shore
#

Hmm

last shore
#

Total users 1002 and 16 servers

#

@restive otter is there sevrver count require?

#

Like 75

restive otter
#

We are not Discord, so Top.gg approval has no requirements other than respecting the guidelines

last shore
#

Hmm

restive otter
#

Top.gg Approval != Discord Verification

last shore
#

Oh now i understand

restive otter
last shore
#

Wait

restive otter
#

Discord's verification is once your bot is in 76 servers.

For Top.gg's approval we just ask you to follow our guidelines.

raven birch
#

Hey, is there anything in the api that will let me remind users to vote for my bot? For example once they vote a timer is started to remind them to vote for the bot in 12h but will not reset the timer unless they have voted so it does not message them every 12h even if its not time for them to vote.

solid imp
#

Maybe add in an extra 1 hour as grace which will be a total of 13 hours and once a user crosses this limit, you can remind them

raven birch
#

Oh.

white bison
#

so I've clustered my bot, and that caused by bot's cache to be split between multiple processes. Does top.gg provide a way to sum the counts when posted by each cluster or do I have to use an IPC to upload the total stats?

rain heart
#

top.gg allows you to post the servercount of your shards, read the docs for that

white bison
#

alright, thanks!

humble ermine
#

Not using direct url but ye using my I'd it's a 404 but using my friend's it's working

atomic kettle
#

hi. I`m trying to post amount of guilds of my bot but getting error (language c++)

        dpp::snowflake guilds_amount = dpp::get_guild_count();
        std::multimap<std::string, std::string> tgg_args = {{"Authorization",topgg_tocken}};
        std::string post_data = "{\"server_count\":" + std::to_string(guilds_amount)+"}";
        std::cout << post_data <<'\n';
        bot.request("https://top.gg/api/bots/"+BOT_ID+"/stats",dpp::m_post, [=](const dpp::http_request_completion_t& e){ 
            std::cout << e.body << std::endl;
        },post_data,"text/plain",tgg_args);

and getting output

{"server_count":1}
{"error":"Required parameter server_count or shards missing"}

where fist is postdata , second returned body of request.

What am i doing wrong?

rain heart
#

also make sure you're including the content type application/json

atomic kettle
#

thank u a lot

jaunty plank
#

did you fill in the url & auth on top.gg?
This code seems to be for real votes and not test votes, are you using test votes or real votes?

#

Did you fill in the url and auth on topgg?

#

🤔 So you want to use the discord api to receive voting info from topgg?

#

Yeah, that uses topgg webhooks

#

Sends it to discord using the bot once the webhook is received.

jaunty plank
#

Well, The url and setup will depend on how you are hosting it.

#

Ie, a vps will use something like http://YourVPSIP:PORT/PATH

plucky lance
#

he already explained, you can't use Discord's webhooks

#

you have to create your own webserver listening for incoming POST requjests from topgg

#

Then use the data you receive to go on, do whatever u like with it

#

anyone you like to of course

#

you just need to handle the incoming post request

rain heart
#

topgg_ico_bulb Resolving general misconceptions and questions about "Webhooks"

  • To make things clear, a webhook is not only something discord related. A discord webhook is discord using webhooks to allow sending messages into channels.
  • Webhooks allow applications such as a discord bot to talk to other applications such as another discord bot to for example make things happen on that application.
    replyWhite You can read more about webhooks here: https://zapier.com/blog/what-are-webhooks/

topgg_ico_question So what are the differences between a Webhook from Discord and a Webhook from Top.gg?

  • Discord webhooks allow an application to send messages into a discord channel. Top.gg webhooks itself DO NOT, Top.gg webhooks do not support the use of Discord Webhooks.
  • A Top.gg Webhook is a way for your bot or an application to know when someone has decided to vote for your bot or server. That webhook includes data that allows you to know who voted for example.

To again make clear: A discord webhook cannot be used within Top.gg to allow you to know when someone voted. The data Top.gg sends is simply not supported on how Discord wants the data within the requests to be.

topgg_ico_question I only want logging of voting, not rewarding users, how can I do that?

  • You can use something like https://webhook-topgg.com/ to only send a message into a channel when someone has voted for your bot or server. This is not an official tool provided by Top.gg but provided by a volunteer of the staff team.
  • Please note that for support, you should reach out to their support instead, as this channel is reserved for official API questions. Their support server can be found here: https://discord.gg/tUSjPNp7R9

topgg_ico_question I want to reward users with currency/access to commands/anything else after they have voted. How can I do that?

  • It is highly recommended that you have a general understanding of how programming works. If you do not, you should consider hiring a developer on either https://fiverr.com or https://freelancer.com
  • You will need to be able to host a webserver that is publicly accessible. This is often done by hosting that webserver on a bot directly. A few libraries support that directly.

topgg_ico_question My bot can receive webhook requests once someone votes. How can I let Top.gg know about these?

  • You can let Top.gg know about your webhook urls through your server/bot page settings.
    replyWhite on bot pages, under https://top.gg/bot/yourbotid/webhooks
    replyWhite on server pages, under https://top.gg/servers/yourbotid/webhooks
  • The Webhook URL field should contain your publicly accessible webhook url. These can be either a domain for example https://mybot.com/webhook or an IP-Address such as http://1.1.1.1/webhook. Port-based URLs work too, such as https://1.1.1.1:5000/webhook
  • The Authorization should contain text that allows you to confirm that the webhook request indeed came from Top.gg.

More help such as what data Top.gg sends and about the use of Retrials can be found at https://docs.top.gg

Helpful links:

rain heart
#

as mentioned above, you cannot use a discord webhook directly, as Top.gg does not support it. If you're planning on only receiving logs if someone voted, use something like https://webhook-topgg.com/

#

Is your goal rewarding users with currency for example?

#

or for example allowing the use of commands once someone has voted?

#

What language is your bot coded in?

#

You could possibly use part of this tutorial on setting up a webserver that is able to receive requests from top.gg: #topgg-api message

#

And you have a webserver running already, correct? what is the port you've used?

cosmic vault
#

when i go to the api endpoint for bot info, it works in my browser but not with axios or node.js http. I get a 401 error

jaunty plank
#

Do you have a token?

cosmic vault
#

no

jaunty plank
#

Then you cant access that endpoint

#

You as a user can, but not using the api alone.

cosmic vault
#

docs dont say i need one for that

jaunty plank
cosmic vault
#

why does it work without token in browser tho

rain heart
#

it uses your user authorization to use the api

cosmic vault
#

o

rain heart
#

though its mainly used to test endpoints and shouldn't be used as an actual token to use the api

nimble burrow
#

Using topggpy

# bot is defined as a commands.Bot
import topgg
bot.topgg_webhook = topgg.WebhookManager(bot).dsl_webhook("/dsl", "Authorization hidden")
bot.topgg_webhook.run(5000)
@bot.event
async def on_dbl_vote(data):
    await ctx.author.send("dbl")
    await ctx.author.send(data)

Not exactly sure what to put as the webhook URL (I'm using an aws ec2 instance)

jaunty plank
#

Does ec2 provide an ip?

nimble burrow
#

It provides with a public ipv4 and a private ipv4

#

and also a link i use to connect with

#

ec2-(IP).eu-west-2.compute.amazonaws.com

jaunty plank
#

you would need to use the public ipv4.

http://IP:5000/dsl

nimble burrow
#

Okay, I'll try that

nimble burrow
#

topggpy```py

bot is defined as a commands.Bot

import topgg
bot.topgg_webhook = topgg.WebhookManager(bot).dsl_webhook("/dsl", "Authorization hidden")
bot.topgg_webhook.run(5000)
@bot.event
async def on_dbl_vote(data):
print(data)

Webhook URL: `http://{IP}:5000/dsltestwebhook`

`on_dbl_vote` does not get triggered
jaunty plank
#

/dsltestwebhook but /dsl is used in code.

subtle hearth
#

This hackathon targets me, please stop

jaunty plank
jaunty plank
nimble burrow
#

on_dbl_test?

#

oop sorry for reply ping

jaunty plank
#

on_dbl_test yeah

nimble burrow
#

Alright, thanks

#

I'll be back if I have any more issues 😂

#

I added on_dbl_test event but still nothing 🤔

jaunty plank
nimble burrow
#

Yes

jaunty plank
#

Does ec2 have a firewall on the port you're using?

nimble burrow
#

No idea, should I change port?

#

I have allowed the top.gg ip through my firewall

jaunty plank
#

If they have a firewall it will cover all ports

nimble burrow
#

oh

jaunty plank
#

If youve opened it then its fine

nimble burrow
jaunty plank
#

This is on your server right? not at home.

nimble burrow
#

Yeah

#

This is on the aws online console

#

Anything I can do to fix this?

#

Or will I have to find an alternative?

jaunty plank
#

I dont use ec2, windows server, or python so I think I've helped as much as I'm capable of. Sorry about that.

We've had people use window server and ec2 so I know they work.

nimble burrow
#

alright, thanks anyway

#

I'll try my best to get an alternative

plucky lance
#

Did you open the port for your aws?

#

Regarding your last screenshot you didn’t

nimble burrow
plucky lance
#

well u have to

#

according to the screenshot only 3389 (RDP) is opened up

fringe lily
#

Is this channel the place to post about topgg-autoposter?

restive otter
#

Anything related to the API belongs here. Only official libraries though, if it's not official use #development

rain heart
#

topgg-autoposter is a tool within node-sdk

restive otter
iron mural
#

hey, why im getting this error?

white bison
#

I have 4 shards per cluster, so does that mean I have to make 4 requests per cluster, posting each shard's stats?

solid imp
#

And internally, top.gg would add all those values to show a total server count on the page and the length of that array would be your total shard count

white bison
solid imp
#

Yep, as per the docs, it’s an optional property

white bison
#

thanks, I'll see if this works

iron mural
solid imp
radiant sail
#

@restive otter mach überall prints rein

#

Dann siehst du wo es geht und wo nicht

#

Bzw. Ob es geht

iron mural
rich hazel
#

Why am I getting this error? My goal is to show if the server owners on the servers where the bot is located have voted or not

restive otter
#

Too Many Requests

rain heart
#

aka you got ratelimited on whatever endpoint you wanted to use

restive otter
#

Don't spam the API with requests

#

Only thing you can do now is wait, and after that don't spam the API with requests

rich hazel
rain heart
#

how are you checking that the owners voted

restive otter
#

You're probably checking every X time for every single server, so you're spamming the API and therefore get rate limited.

rich hazel
# rain heart how are you checking that the owners voted
const topSdk = require("@top-gg/sdk");
let topApi = new topSdk.Api(config.api_key, client);
            client.guilds.cache.map(async guild => {
            const owner = await guild.fetchOwner();

            await topApi?.hasVoted(owner.id).then(async voted => {```
rain heart
#

yeah thats your issue

#

you're essentially getting yourself ratelimited right away

#

consider using webhooks, collecting the votes and checking if they voted internally

rich hazel
rain heart
#

yes

rich hazel
# rain heart yes

For example, we save the person after voting, either the time has expired or the right to vote again has come, can we pull it from the topgg api example; app.post('/vote/del')

rain heart
#

I'm not sure what you mean

#

are you referring to when a user can vote again that your webhook should be notified?

rich hazel
plucky lance
#

A much easier way is to progress a delete-on-request action

#

Means you’re storing the timestamp when the user voted in your database

#

Then the next time you have to check the last voting status you check the saved timestamp and the current timestamp to see if it’s older than 12 hours

#

If so delete the record, if not keep it

#

Iterating through the entire database to remove those records doesn’t seem to be really efficient or needed imo

jaunty plank
plucky lance
#

imagine ruining my entire point with this

balmy root
#

I'm getting 400 errors when posting stats, I'm not sure if it's because I'm only sending the server_count field

#

Because the last time I sent it was several months ago, the topgg record was like around 10k servers, and we have grown to over 100k

#

Is it suspected by topgg that the number is incorrect?

rain heart
#

post your code

balmy root
#
fetch(`https://top.gg/api/bots/${bot.id}/stats`, {
    method: 'POST',
    headers: {
        Authorization: process.env.TOPGG_TOKEN
    },
    body: JSON.stringify({
        server_count: counts
    })
})
#

i got twilight-gateway as my gateway, then discordeno for handling commands, so i can only retrieve total guilds

jaunty plank
#

Its possibly because you're missing the content type header

rich hazel
queen inlet
#

umm guys

#
{ error: 'Required parameter server_count or shards missing' }
#

i am getting this error

#
body:JSON.stringify({
    server_count:123456,
  })

while using this

#

how ?

balmy root
#

i always forget to add content type

rich hazel
#

I want him to delete the data after two minutes, but he doesn't delete it, what's the problem?

const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const schema = new Schema({ UserID: String,
expireAt: { type: Date, default: Date.now, index: { expires: "2m" } } });

module.exports = mongoose.model("nsfwvote", schema);```
queen inlet
#

ohh content type header

rich hazel
#

my goal is normally to save it after the person has voted and delete the data after 12 hours

balmy root
#

it returns 200 now but the number is not updated thonk my bot id is 584213384409382953

rich hazel
jaunty plank
rich hazel
balmy root
balmy root
rain heart
#

pins under My bot can receive webhook requests once someone votes. How can I let Top.gg know about these?

#

yes, you're planning on wanting to use webhooks like before

#

yes

#

webhooks

#

that should be enough, might need to change that password later as that is the authorization used by top.gg

#

it will still not work if you have nothing filled out on top.gg, read the pins under "My bot can receive webhook requests once someone votes. How can I let Top.gg know about these?"

#

yes

#

on this channel

#

yes

#

what you're essentially doing here with .run is starting a webserver through your bot. Through this webserver you're able to receive http requests. Top.gg can use that to let you know when someone has voted.

The requirement is though that the port 5000 is publicly accessible. If your bot is on a VPS for example, it would be something like http://yourserverip:5000/dblwebhook

#

I suggest you to read https://zapier.com/blog/what-are-webhooks/ to understand the concept of webhooks

You might have seen webhooks mentioned in your apps' settings and wondered if they're something you should use. The answer, in a nutshell, is probably yes.
Webhooks are one way that apps can send automated messages or information to other apps. It's how PayPal tells your accounting app when your...

#

you need something to handle these http requests, directly doing it through your bot is the most convenient one

ionic mason
#

u have to host ur bot to get an ip

#

or u can also host locally but u have forward ur port

#

which can be done through ur modem or router settings

#

for that particular ip

ionic mason
#

yep thats it

heavy obsidian
#

Hey,
is there something wrong with the api?
Somehow it's not responding...
I'm using Java

rain heart
#

define "not responding"

#

what tells you it is not responding? Post your code

#

we can't do much with that statement

sand sparrow
#

Hi

#

TopGGAPIError: 401 Unauthorized (You need a token for this endpoint)

#

Can anyone help?

#

I have the token already

rain heart
#

You're not using a valid one then

#

press regenerate

#

refresh the site, then copy the token

sand sparrow
#

ok

#

Thnks

atomic nacelle
#

Is this working ?? Please tell

#

Bro how to make this fully please tell

atomic nacelle
rain heart
#

please read the pinned messages

plucky lance
atomic nacelle
plucky lance
#

People can only help u if you tell em what u wanna do

untold ferry
#

I'm using topggpy and this is my code:

client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("/dbl", "myauthcode")
client.topgg_webhook.run(5000)

@client.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 client.dispatch('dbl_test', data)

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

@client.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}")

and im not getting the test vote printed to the console. could anyone help me?

rain heart
#

read the pinned messages

untold ferry
#

what would i put this as?

rain heart
#

also refer to the pinned messages

#

topgg_ico_question My bot can receive webhook requests once someone votes. How can I let Top.gg know about these?

More help such as what data Top.gg sends and about the use of Retrials can be found at https://docs.top.gg/

untold ferry
#

ah

terse birch
#

hola

#

no se si haya un español dx

#

alguien sabe como puedo configurar la api ?

restive otter
#

How do I check if the user with ID 123 has voted for the bot with the xxxx token

rain heart
#

wdym xxxx token

restive otter
#

What I need is to check whether the user with the id 573504001732116490 has voted for the bot. ||Vote Check||

rain heart
iron mural
#

how can i fix this error,????? ping if u have solution

restive otter
#

Wait and try again later

atomic nacelle
#

Hey is it working?

stray halo
#

Idk is it

rain heart
#

-api

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.

atomic nacelle
plucky lance
#

Once again all you need to receive vote webhooks from topgg or how to do api requests is described in the docs

#

If you got trouble with that, post your code and error and a short explanation

restive otter
untold ferry
#

I’m using topggpy and for some reason the test vote event is working (printing to console) but the normal vote isn’t working.

rain heart
#

well we cant do much with code

plucky lance
#

without smirk

rain heart
#

without yeah

jaunty plank
#

🤔 are you sure your incrementing line is actually running correctly?

it might be easier to both sql lines in one.

#

There's no reason you couldn't
insert a new row if the user hasn't voted previously
if they have update the row
and select the data on the row(result)
all in the same query.

rain heart
#

you're using the resultset from before the update

#

also what woo said, it's more efficient to do that

#

or well, more clean

jaunty plank
#

It should be more efficient.

#

Two db requests should be slower, especially if its not a local database.

warm matrix
#

hey i want help.

#

i was trying to listen to topgg webhook

#

whenever i vote it doesn't log anything as well as the test webhook also doesn't logs anything

#

am i doing anything wrong?

rain heart
#

is your webhook URL publicly accessible?

warm matrix
#

anyways thanks for trying to help 👍

tribal ibex
#

anyone here that uses aoi.js idk how to setup the voting reward thing

tribal ibex
#

uhm? no discord.js/aoi.js

astral spear
#

do you need a website to detect votes?

#

just wanting to setup some sort of vote tracker for my own bot

rain heart
#

you need a webserver (either externally or provided through your bot directly) that is publicly accessible

#

refer to the pinned messages

astral spear
#

What is the authorization on the webhooks page?

#

Is that the auth for the webhook?

#

like whatevers after the url

#

@rain heart so you can't detect votes etc with just a discord bot?

restive otter
restive otter
astral spear
#
onst express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express() // Your express app
const webhook = new Topgg.Webhook('redacted') // add your Top.gg webhook authorization (not bot token)

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

app.listen(8059) // your port
restive otter
rain heart
#

refer to the pinned messages

fallen thistle
#

Did topgg remove server count from their widgets?

#

If so, is there a way to opt in again?

#

Pleas ing me when replying

rain heart
#

could you elaborate what tells you server counts were removed

fallen thistle
jaunty plank
fallen thistle
#

Hm but I have... though it is not displaying on the website anymore

#

I have not changed any code

#

Can you check if I got ratelimited?

#

But even then, previous data exists

#

Shouldn't topgg just take the last posted count?

rain heart
#

it should

#

seems like you have posted 0 to it, which essentially resets it

fallen thistle
#

Interesting, I will check if it's the same tomorrow, if so I will investigate. May just be unfortunate timing with caching Ig?

#

Thanks for the help

fast spruce
#

is the api down? we cant seem to reach it even though it worked previously

radiant solstice
#

What is use of top.gg api? Can someone explain?

jaunty plank
#

Covers all the features of the api.

serene pasture
#

I have been trying to create a webhook on a discord bot and ive finally got it but keep getting this error when i send a test from top.gg

#

any idea how to fix this?

jaunty plank
serene pasture
#

yes i am

#

ive got the same code as in the example on the api docs for receiving test votes and votes

#

and when i send a test vote, it sends this error repeatedly every few seconds, i assume a timeout retry

jaunty plank
#

Its strange that it happens on a test vote.

is the test event firing?

serene pasture
#

it doesnt look like it, it looks like it just errors straight as it recieves data, before it can go through any of the events in the code

jaunty plank
#

Everyone always asks this question and I hate it, but is it possible your host is preventing the request from completing?
Are you possibly sending something to discord(or anywhere else) in the event and that's causing the error?
Or that your thread is being pushed really hard, and the request times out before its handled?

serene pasture
#

i will do a few tests using a test bot and other applications and see if i can get any different results, there seems to be some problems with the hosting service at the moment but that might just be on my end, but i will give a couple things a try

jaunty plank
#

The error says its an invalid http method, which if it was a result of a bug on Top.gg's webhooks end I would see it on my webhooks too.

An idea, could you be receiving these errors from someone else(it sounds like its from topgg, but I'm just double checking)?

Another idea, do you have accented characters in your request? ex: é in the authorization on top.gg

I know that can cause some issues.

serene pasture
#

im not sure, ive set up the firewall on the hosting service to accept packets from the ip on the documentation, and my bot is clearly recieveing data when i press the test button, nothing happens until i press test, and then when i press it it starts saying these errors again

jaunty plank
#

Are you using accented or unicode characters in your auth or url?

serene pasture
#

nope :/

serene pasture
#

@jaunty plank i have figured out the problem

jaunty plank
#

o what was it?

serene pasture
#

the link i was using on topgg website i used "https" the secure http request, but obviously python bots dont use that format of http

#

i just changed it to a "http://" requst and i get all of the information

jaunty plank
#

I didn't even think python would give an error on that and just ignore the request, if you had any other issue I would have asked about that!
Fascinating. Thanks for figuring it out.

serene pasture
#

thats actually really interested me, it must just be a completely different format, and it might be to prevent this exact thing so loose code cant just get information from a https request

#

thank you for your help!

restive otter
#

?

#

i get the same bot over and over again

#

@jaunty plank <@&817055174613794826>

jaunty plank
#

I don't have any experience with endpoints that are not documented.
I won't really be helpful here.

restive otter
#

u know who does?

jaunty plank
#

Nope, I dont sorry.
It's an undocumented endpoint Ive never seen anyone ask for support for one.

restive otter
#

Who manages ur api

jaunty plank
#

Our developers? They don't provide customer support.

You might need to send a support ticket, but I have a feeling they will send you here, or tell you we don't provide support for undocumented endpoints.

restive otter
#

i figured it out

#

you inspect element and get the api link

#

its private

rain heart
#

the API endpoint is undocumented and may not return results you'd expect

#

thus no support

restive otter
#

yeah its for the website but it works alot better then the imported api

restive otter
#

😫

#

Maybe it's my time to shine and finally get the occasion to ask this to someone like you

#

Why on earth do people create such useless servers?

restive otter
#

what

#

how are you doing such a thing

scarlet cobalt
restive otter
#

that will not crash the discord api

#

wym

#

Pretty sure you can't get 100k bots in a server nonetheless.

#

Other than that, discussing such things is against Discord ToS and against the rules of the server - so please stop

#

You won't get help to abuse our API and Discord's API.

#

my guy 💀

restive otter
patent lintel
#

im using python top.gg api to run this ```py
client = commands.Bot(command_prefix="$", intents = intents)
client.topggpy = topgg.DBLClient(client, os.environ["topgg_token"], autopost=False)

#

and it is raising this error ```
AttributeError: loop attribute cannot be accessed in non-async contexts. Consider using either an asynchronous main function and passing it to asyncio.run or using asynchronous initialisation hooks such as Client.setup_hook

#

how do i fix

#

pls

patent lintel
#

Pls help

patent lintel
#

bruh

#

i think topggpy is just outdated

lyric sentinel
#

hello, i need some help

#

i need to run a function as soon as a user upvotes my bot….
i also need to get the name/id of the user who upvotes my bot, so that my bot can dm them

#

pls help me

rain heart
#

both things can only be done on an approved bot

lyric sentinel
jaunty plank
#

Got to love luca going down all the time

jaunty plank
#

We dont provide the name with the webhook. We do provide the user ID though, which can be used to fetch the user via your bot & the discord API if you need it.

lyric sentinel
#

ok thanks

restive otter
#

POST /api/bots/:botid/stats?server_count=10 Is it correct?

I'm getting the error how do I do it

{ error: 'Required parameter server_count or shards missing' }```
#

How should I use

solid imp
restive otter
restive otter
#

Simply search on the internet how to make a POST request in the language you're using

gray mantle
#

I want to get request vote reminder, what does it send?

jaunty plank
#

Our webhooks dont provide vote reminders. Vote reminders you would need to create on your end.

gray mantle
#

i mean, when user click on the button remind after vote

#

what does api send to my server?

jaunty plank
#

it doesnt send anything to you

#

only to the user

gray mantle
#

thankyou

restive otter
#

hello, I'd like to know how can I check whether a certain user voted my bot on top.gg with the API

rain heart
#

check weather??

restive otter
#

sorry typo

jaunty plank
#

If you're looking for an event, youll want to use webhooks.

restive otter
#

not an event actually but I'm trying to check if the user voted on not before executing a certain command

#

I assume error: "Unauthorized" means that the user hasn't voted

jaunty plank
#

It means you didnt provide an authorization token.

restive otter
#

ah i need to pass a header

jaunty plank
#

Just a note, the ratelimit on that endpoint isn't very high.

If the command is ran somewhat frequently you probably will hit a ratelimit on topgg.

restive otter
#

oh

#

ugh i hate ratelimits

tribal gust
eager salmon
#

how can i check if a user has voted in the last 12 hours? (JS)

rain heart
eager salmon
#

tysm!

cobalt gale
#

i need some help, i want to add query params safe search for api suggest.google.com but i don't know query about it?

#

it search for youtube music

restive otter
astral spear
#

is there no api response for servers?

#

And why does the api respond null?

restive otter
rain heart
#

and if you were able to discover any using inspect element, these are undocumented and will not receive support for until these are officially supported

gray mantle
#

suddenly my bot webhook does get request from api. I don't know what's wrong with it

#

I haven't made any changes, it still received yesterday but not today.

#

I tried send test, but it still doesn't response

granite mist
#

My Vote endpoint gets triggered seperately multiple time (exactly 10 times) on vote
Anyone else facing this? Could also be an Issue on my Providers site

rain heart
#

if you're not responding with a 2xx and/or the request times out, retrial will occur

#

refer to the docs under retrial

granite mist
#

hm could be that the response takes to long yes

gray mantle
#

My webhook doesn't get request from Topgg API
I added this to my client

makeCache: Options.cacheWithLimits({
        ...Options.DefaultMakeCacheSettings,
        GuildMemberManager: {
            maxSize: 200,
            keepOverLimit: member => member.id === client.user.id,
        },
    }),
    sweepers: {
        ...Options.DefaultSweeperSettings,
        messages: {
            interval: 3600, // Every hour...
            lifetime: 604800000,    // Remove messages older than 7 days.
        },
    },

Does it related?

#

my Webhook from Topgg is now bugged

#

I can no longer receive request from vote

#

is that any changes in API?

rain heart
#

dont randomly ping staff members, wait for someone who can help

gray mantle
#

sorry for that

#

my Webhook got wrong from yesterday, I've tried many ways but unsuccessful

torn basin
#

what the wrong?
send me error AxiosError: Request failed with status code 401

#

idk where proplem

#

These two values are identifiers and have been confirmed more than once

plucky lance
#

Also don't forget to update the token in config after

torn basin
plucky lance
#

Yes

torn basin
#

thx

Not work 843512387599990840

rain heart
#

can barely make out any structure, could you post your code on pastebin or in a codeblock here

orchid spire
#

Can I have help with making a vote webhook for my bot, I’ve never done it before and I’ve tried to do it but it doesn’t seem to work.

#

Maybe I’m doing it wrong, but need help with it in general

restive otter
#

No errors and no code, nobody can help unfortunately

jaunty plank
orchid spire
#

This is confusing, what would I do just to get the test thing to send to a channel?

jaunty plank
#

if that is your only goal, third party sites offer that(you can find them easily on google).

But, if you want to implement it in your code you need to use your own webhooks.

orchid spire
#

I’m trying to implement it into my code, and I have a webhook for my votes channel for testing but not working

jaunty plank
orchid spire
#

uhh, it is a discord webhook I think

jaunty plank
#

Topgg webhooks are not discord webhooks.

orchid spire
#

Ok wait, what are these two fields for?

#

Let’s just start here

jaunty plank
#

The url to your webserver hosting your webhook listener.

orchid spire
#

So I need my own web server?

jaunty plank
#

Odds are your bot is hosted somewhere that has a public ip, or url.

orchid spire
#

My bot is currently hosted on Heroku so I don’t know about that

jaunty plank
#

Heroku provides web dynos with a url.

orchid spire
jaunty plank
orchid spire
#

Ok

mellow mica
#

Hi

full dagger
#

I want to know what is the topgg api for the voting and how to get it to work

solid imp
gray mantle
#

I've made a file called Topgg.js

And written the webhook on that.
then I exports to index.js like this

const { AutoPoster } = require('topgg-autoposter')
const ap = AutoPoster(process.env.TOPGGtoken, client)
ap.on('posted', () => {
    console.log('Đã xuất thống kê lên Top.gg!'.bold.brightGreen)
})
const { init } = require('./Topgg')

init(client)
#

and my process can't receive posted request from TopGG votes..

#

can anyone tell me where I was wrong?

restive otter
#

Well, that is not a webhook listener

#

That simply posts your server counter automatically

gray mantle
#

I mean the init function

#

I called it on my index

#

but it's not working

restive otter
#

"not working" is not very helpful

#

Though that still doesn't change the fact that this is not a webhook, so you can't listen to POST requests which is normal

#

Look at the documentation there are examples for both of them

gray mantle
#

I exported it as a function

#

and called on index

#

but it's can't receive any post even test

restive otter
#

Probably want to use a pasting service to not flood the chat and make it easier for everyone to read

gray mantle
#

wait a sec, I'll post it on source bin

golden plover
full dagger
restive otter
#

What Enigma linked if your way to go, you won't get spoon-fed with code unfortunately

restive otter
#

for the update_stats tasks.loop whats the minimal loop time we can set it to?

jaunty plank
#

You really don't need less than 30 minutes, our site cache only updates every 30 minutes to an hour.

restive otter
#

oh ok

#
@tasks.loop(minutes=30)
async def update_stats():
    try:
        await client.topggpy.post_guild_count()
        print(f"Posted server count ({client.topggpy.guild_count})")
    except Exception as e:
        print(f"Failed to post server count\n{e.__class__.__name__}: {e}"
update_stats.start()
AttributeError: loop attribute cannot be accessed in non-async contexts. Consider using either an asynchronous main function and passing it to asyncio.run or using asynchronous initialisation hooks such as Client.setup_hook```
#

and it not the loop

#

cause i took out update_stats.start()

scarlet cobalt
#

One message removed from a suspended account.

#

One message removed from a suspended account.

jaunty plank
restive otter
#
class MyClient(commands.AutoShardedBot):
    def __init__(self, *, intents: discord.Intents):
        super().__init__(intents=intents, command_prefix=check_prefix)
    async def setup_hook(self):
        for filename in os.listdir('./cogs'):
            if filename.endswith('.py'):
                await self.load_extension(f'cogs.{filename[:-3]}')
        await self.load_extension('jishaku')
        async with client:
         update_stats.start()
         await client.start(token)```
#
AttributeError: loop attribute cannot be accessed in non-async contexts. Consider using either an asynchronous main function and passing it to asyncio.run or using asynchronous initialisation hooks such as Client.setup_hook```
#
Traceback (most recent call last):
  File "main.py", line 69, in <module>
    client.topggpy = topgg.DBLClient(client, dbl_token)
  File "python3.8/site-packages/topgg/client.py", line 98, in __init__
    self.http = HTTPClient(token, loop=self.loop, session=kwargs.get("session"))
  File "python3.8/site-packages/topgg/http.py", line 84, in __init__
    self.session = kwargs.get("session") or aiohttp.ClientSession(loop=self.loop)
  File "python3.8/site-packages/aiohttp/client.py", line 227, in __init__
    loop = get_running_loop(loop)
  File "python3.8/site-packages/aiohttp/helpers.py", line 289, in get_running_loop
    if not loop.is_running():
  File "discord/client.py", line 108, in __getattr__
    raise AttributeError(msg)
AttributeError: loop attribute cannot be accessed in non-async contexts. Consider using either an asynchronous main function and passing it to asyncio.run or using asynchronous initialisation hooks such as Client.setup_hook```
restive otter
#

fixed it

restive otter
#

nvm not loggin now

#

now the bot doesnt want to work

#

@jaunty plank

#

been stuck for 11 mins

#
class MyClient(commands.AutoShardedBot):
    def __init__(self, *, intents: discord.Intents):
        super().__init__(intents=intents, command_prefix=check_prefix)
    async def setup_hook(self):
        for filename in os.listdir('./cogs'):
            if filename.endswith('.py'):
                await self.load_extension(f'cogs.{filename[:-3]}')
        await self.load_extension('jishaku')
        dbl_token = "token"  # set this to your bot's Top.gg token
        client.topggpy = topgg.DBLClient(client, dbl_token)
        await update_stats.start()  
@tasks.loop(minutes=30)
async def update_stats():
    try:
        await client.topggpy.post_guild_count()
        print(f"Posted server count ({client.topggpy.guild_count})")
    except Exception as e:
        print(f"Failed to post server count\n{e.__class__.__name__}: {e}")
jaunty plank
#

I dont know python sorry

restive otter
#

oop

tawdry inlet
#

.start() takes port as parameter afaik

#

oh nvm it was in your task deco

#

mb

tawdry inlet
#

why does it won't send anything even test votes. i already provided webhook url and auth both in top.gg and in code.

library: topggpy (1.4.0)

#
class FirstCog(commands.Cog):
    def __init__(self, client: Client):
        self.client = client

        self.top_gg_client = topgg.DBLClient(bot=self.client, token=topgg_token, autopost=True)
        self.webhook_manager = topgg.WebhookManager(self.client).dbl_webhook("/webhook", auth)
        self.webhook_manager.run(2333)

    @commands.Cog.listener()
    async def on_dbl_vote(self, 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 self.client.dispatch('dbl_test', data)

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

    @commands.Cog.listener()
    async def on_dbl_test(self, 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}")
jaunty plank
tawdry inlet
#

i changed it to http://127.0.0.1:5000/webhook since it was run locally. still no response.

restive otter
#

127.0.0.1 is localhost

jaunty plank
#

we(the site) need to be able to reach your server

restive otter
#

It will never be reachable to the outside

#

You need a proper reachable web server

tawdry inlet
#

alr. i'll try again. thanks

jaunty plank
#

If you're hosting locally youll need to use your public ip address, and you'll need to change some router settings to port forward.

restive otter
#

m using topgg-autoposter

jaunty plank
gritty bobcat
#

One message removed from a suspended account.

restive otter
#

Correct

restive otter
#

NVM it fixed on restarting the bot automatically

golden plover
#

Hey, the python library is still maintained? 'Cause I can't make it work and I'm not the only one

jaunty plank
restive otter
#

i finished setting up a webhook but when i pressed tested nothing came up

rain heart
restive otter
#

ty

golden plover
# jaunty plank I dont think we have anyone currently maintaining it, but it should be working. ...

I followed the example on https://docs.top.gg/libraries/python/ to post the guild count.
At first I didn't understand what bot.topggpy was, so I tried replacing it with several things, including my discord.commands.Bot instance. But that didn't work, and I saw that in the documentation the bot.topggpy.DBLClient function took an instance of discord.Client as a bot parameter. So in my code in addition to doing discord_bot=commands.Bot(command_prefix=config.PREFIX, intents=intents) I did client=discord.Client() but it still doesn't work, in all tests it returns me several errors caused by topgg.DBLClient(). I think the library uses endpoints / functions that no longer exist or are obsolete

jaunty plank
#

Interestingly, when searching the py libraries code, it doesn't seem to use _connector anywhere.

It's possible it's used in a deprecated function(or I just didn't search properly), but I'd have no way of finding if it's a deprecated function not using python before.

That said, if you find any deprecated functions we are using you should submit a pr request and let me know.

golden plover
# jaunty plank Interestingly, when searching the py libraries code, it doesn't seem to use _con...

Ok, i wrote ```python
client = discord.Client(intents = intents)
@client.event
async def on_ready():
print("client")
dbl_token = config.TOPGG_TOKEN
client.topggpy = topgg.DBLClient(client, dbl_token, autopost=True, post_shard_count=False)
@client.event
async def on_autopost_success():
print(f"Posted server count ({client.topggpy.guild_count})")

client.run(config.TOKEN)```
It's not exactly as it says in the link you sent me but it was just to see if it worked once.
And the bot return "Posted server count (116)" so i think its good. There is a delay between the bot posted and topgg show in the website ?

#

Its 2am in my house so i go to bed, i see tomorrow

silent rampart
#

how can i POST stats of my bot with python requests.post?

#

nevermind its above

plucky lance
#

It really is very simply... just don't forget to provide the authorization and content type in the header and your server count as body

silent rampart
#

how long does it take until my server count on top.gg updates

#

nevermind it updated

crude bane
#

for webhooks

jaunty plank
shadow silo
#

how do i find my dbl token?

orchid lance
golden plover
# golden plover Ok, i wrote ```python client = discord.Client(intents = intents) @client.event a...

It works @jaunty plank, even with a discord.command.Bot instance. You just need to redo the documentation. Here is my code :```python
discord_bot = commands.Bot(command_prefix = config.PREFIX, intents = intents)

@discord_bot.event
async def on_ready():
dbl_token = config.TOPGG_TOKEN
discord_bot.topggpy = topgg.DBLClient(discord_bot, dbl_token, autopost=True, post_shard_count=True)

@discord_bot.event
async def on_autopost_success():
print(f"Posted server count ({discord_bot.topggpy.guild_count}), shard count ({discord_bot.shard_count})")

discord_bot.run(config.TOKEN)```
I'll be back in a few days to say if it still works

restive otter
#

Should just make the example more complete, the library itself needs some changes though

#

But since the maintainer is banned from Top.gg, won't happen any time soon until someone decides to do it kryptonShrug

jaunty plank
#

Anyone can submit a PR though, once we have verification the new example works we can have an employee push it.

golden plover
restive otter
#

The thing is that the api is not super complex

#

So lots of people don't even use the sdk hence don't notice the issues with it

golden plover
restive otter
#

Not really no

jaunty plank
#

eh, imo its not easier.

I dont know python and I feel like I could get it setup faster without the sdk.

#

theres so many online resources for learning to use an api in python

golden plover
restive otter
#

tbf most sdks need a rewrite

#

I don't see how, for example in Python, topgg.DBLClient makes any sense

#

And why it has been approved like that

#

Package name clearly shows it was after the brand rename from dbl to top.gg

rain heart
#

is my fair guess

restive otter
#

Doesn't make any sense

#

The package is topgg

rain heart
#

the client that package is based on was DBLClient, aka from back when the term DBL was still used

restive otter
#

Correct

#

Now here comes my question

#

Why was the package renamed from dbl to topgg

#

But the class kept to DBLClient

#

Yes it was named dbl.DBLClient before

#

Or actually just dbl.Client but doesn't matter

#

Old code example

import dbl
import discord
from discord.ext import commands


class DiscordBotsOrgAPI(commands.Cog):
    """Handles interactions with the discordbots.org API"""

    def __init__(self, bot):
        self.bot = bot
        self.token = 'dbl_token' # set this to your DBL token
        self.dblpy = dbl.Client(self.bot, self.token, autopost=True)
        # autopost will post your guild count every 30 minutes

def setup(bot):
    bot.add_cog(DiscordBotsOrgAPI(bot))
jaunty plank
#

It probably just wasn't thought about

restive otter
#

So the package got renamed, but not the class

jaunty plank
#

Ideally someone would rewrite the thing from scratch.

restive otter
#

So I'm surprised it has even been approved

near jolt
#

how do i use api to find if a user has voted?

restive otter
restive otter
#

I want a code. When a person votes, he receives a private message telling him “thank you.” I want the code to be Discord.js

#

We won't spoon feed you and are not working robots as well.
Use the documentation to get at least a base code and then we can help you fix your issues => https://docs.top.gg

keen belfry
#

How can i create a webhook

fleet marsh
orchid lance
#

I know is old post, but this help me, thank you

agile cargo
#

Please help me

#

Am really in need of help now

#

Please

#

Guys

#

Am hungry

#

And I don't have money to eat

#

I and my family have not eating over 2days now,

#

Please 🙏

#

Help me

restive otter
arctic rivet
agile cargo
vague oracle
#

where do I get my top.gg webhook

rain heart
#

check the pins

vague oracle
#

im legally blind

rain heart
restive otter
patent lintel
#

When I am using python API Wrapper, what webhook url should i use

solid imp
patent lintel
#

oh

#

mb

iron mural
#

Hey, is there a way from the topgg api that i save the user's vote and check if it's like a votes streak or not?

#

Like if they voted for 2 days in a row and forget to vote in the 3rd day the total votes reset to 0

restive otter
#

doing it yourself

#

using webhooks

iron mural
#

Okay

uneven pawn
#

guys i have a question for you

#

how can i use webhook

fallen coyote
#

Hi, so I've read the docs for the python on_dbl_vote, but I've put it in a cog and nothing is returning.
Am I allowed to put it in a cog, or does it have to be in the main file

self.bot.topgg_webhook = topgg.WebhookManager(self..bot).dbl_webhook("/dblwebhook", "password")

and is the /dblwebhook this?

restive otter
#

You need to host the webhook on a reachable web server, aka not your computer, and write that down in the webhook URL, will most likely be http://<ip>/dblwebhook

fallen coyote
restive otter
#

Correct

fallen coyote
#

excellent thanks

plucky lance
#

That question isn't specifically api related, so #development is the better place

Just log your var result and you will possibly see the issue already
Since you didn't show the initial statement to get the user data, there's not much more help possible

Also a few tips, when incrementing the data field, use the field as value, e.g. SET votecount = votecount + 1
Also since time and votecount seem to be an integer, then set INT as field type (if you haven't done already)

#

This will also require you to update the INSERT statement

#

The placeholder would be %i for numeric field types

#

Doesn't make any sense to convert the string to a number all the time

#

For any SQL related engine

#

But still that won't fix your issue until you show the initial statement and log result to be able see the issue

restive otter
swift haven
#

can i check how many votes ?
through api

#

like 525 Total votes.

jaunty plank
#

points is the total votes of the bot.

swift haven
#

like Thanks for Voting Kronton
Total Votes is - 500

jaunty plank
formal wharf
#

for some reason i have been receiving this error

#

i tried hosting my bot on other device, and it work

formal wharf
ocean cargo
#

Is there any way to "test vote" just trying to figure out the webhook atm

restive otter
ocean cargo
#

Where do you see this

restive otter
#

same place where you got your webhook token, where you've put the webhook url and where you've set the webhook authorization password

ocean cargo
#

What do you put in the webhook url?

restive otter
#

the url to the endpoint

restive otter
#

no

#

i don't know. my bot still works fine and it's returning a number for me.

#

0 has not voted
1 has voted

#

well it seems like an issue on your end

#

nothing has changed my bot has been running the same code for our vote command for months and it's working fine.

#

have you checked what it's returning?

#

if your checking if its greater than 0 would it not work either way then? i believe it's something on your end though.

#

it's something on your end.
try posting your code in #development. the api is returning 1 and 0 for me.

#

also, why do i randomly get these errors

#
  • gateway timeout
strange palm
#

I've been getting those 401 too for a few days
The weirdest part is how random it seems, sometimes days pass without a problem and sometimes I get three in a single afternoon

restive otter
#

more of them 🙀

jaunty plank
#

👀 are they occurring sporadically?

strange palm
#

Yup
For me the hour always ends in 05 or 35 but I guess it's because topgg-autoposter triggers every half hour and it sometimes just... fails?

#

Look at these for instance. I got a bunch on the 20th, and a few others today. In-between, all good.

#

aaaaand I just got one, right now.

restive otter
jaunty plank
#

just started around the 20th?

restive otter
#

well somewhat recently

#

i wasnt getting them before

jaunty plank
#

Its possibly related to some other issues we've been having with bots voting pages disappearing for a bit then coming back.

restive otter
#

hm

strange palm
#

20th is the earliest I got one yes

jaunty plank
#

Its possible it started on the 19th too.

#

the errors probably can be safely caught and ignored, its most likely a site issue.

A possible solution might be to regenerate the token, but its unlikely to fix anything.

strange palm
#

Aye
What's important is y'all know it's happening

#

It's a bit annoying at worst

restive otter
#

yeah

orchid lance
#

can i post stat without this?

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

Thats just an event

strange palm
#

(so the answer is yes)

warm lion
#

can someone help me fix my python code

strange palm
#

Wrong server

warm lion
#

huh ?

strange palm
#

There are plenty of servers about devving and even more specifically Python but this ain't one of them.

jaunty plank
warm lion
#

oh thx

jaunty plank
#

but generally we don't have many python devs here for some reason.

indigo monolith
#
{ error: 'Required parameter server_count or shards missing' }
#
let todo = {
    "server_count": 312,
    "shards": 1000
};

fetch('https://top.gg/api/bots/1014207340188270673/stats', {
    method: 'POST',
    body: JSON.stringify(todo),
    headers: { "Authorization": botConfig.voteAuth }
})```
jaunty horizon
warm lion
jaunty horizon
#

you mean like this?

your code is here

or sth else?

warm lion
#

someone skilled at it can only help

jaunty horizon
#

we should really change channels though

jaunty plank
indigo monolith
jaunty plank
#

It's one line of code

indigo monolith
# jaunty plank It's one line of code

lets say i make a post request and say my bot is in 1000 servers.
How will it check that thats even true

cant ppl just say there bot is in 10mil servers or will it check for it

jaunty plank
#

It depends.
Some libraeies will add it for you.

#

Yeah, if we receive reports of you posting the wrong count we will manually check.

restive otter
#

you could make it a billion

#

i have

jaunty plank
#

And that's a good way to get banned from the bot list

restive otter
#

😁

jaunty horizon
# restive otter you could make it a billion

would be dumb on antother level 🤡

Server owners see on how many servers a bot is active when they invite the bot. if the desciption reads 1_000_000 and discord tells 'em it's actually 5, it would seem very fish and probably prompt users to abbort the invitation.

bitter basin
#

Hey, i just want to point that some months ago, i had an issue with one users voting in the page, but when i was asking for their vote status the API was returning false. One day, the issue just stopped by itself, but now it's happening again with some other user. Other users are just fine as far as i know

#

I don't know if that's a bug or something related, but yeah, i just wanted to know if you ever had the same issue

jaunty plank
#

It sounds like a really rare issue, and it probably isn't something that can be looked into anytime soon.

restive otter
restive otter
iron mural
#

hey, how can i fix this error?? it's so annoying

restive otter
#

Very simple, you stop spamming the API with tons of requests

iron mural
#

i just send a request once my bot joins a guild or leave

#

what's the minimum requests limit?

#

@restive otter

shell siren
restive otter
formal sierra
#

hey so i have no idea why im getting this error when it should request the person using the bot to vote for my discord bot

formal sierra
#

this is what I have

#

i thought this was going to be easier but i guess i did something wrong and I have no idea what to do

#

soo, im not receiving any errors in the console but the vote that should be required for my commands dont seem to be responding

iron mural
jaunty badger
#

when using api endpoints tying to set the server count i get "error": "Unexpected token s in JSON at position 0"

restive otter
solid imp
#

Those 2 are different

clear thorn
#

-> moving this here from #support : Why is my bot page listing my Server Count as 1 even though it is in 5 Servers and I'm pretty sure I passed the right amount to the api 🤔

restive otter
#

When did you last posted the metrics

clear thorn
#

Yesterday... and it has been on 5 then

restive otter
#

Post again, and make sure you don't have some background tasks that may put it back to 1

clear thorn
#

Didn't change

meager mural
#

what was the nodejs module to check if user has voted

restive otter
#

Can take up to 30 minutes to show

clear thorn
restive otter
meager mural
#

k ty

restive otter
#

Before that it has always been at 0

clear thorn
restive otter
#

So it never showed 5 on the site

clear thorn
#

Actually I just added a check to my bot and it seems it sends 0 🤔 Sent Servercount of 0 to top.gg! I might have to fix something on my side

restive otter
#

Looks like it, feel free to share the code here if you need help regarding that

clear thorn
#

The weird thing is, I used the same code that works somewhere else

#

Oh wait... I think I might be getting the Servercount before the bot is fully started

#

Sent Servercount of 5 to top.gg! Nice :)

meager mural
#
const topgg = require('@top-gg/sdk')
const tapi = new topgg.Api(config.topggtoken)``` is this wrong? because i get you need a token for this endpoint error
#

oh my bad

iron mural
meager mural
restive otter
#

regenerate

#

reload the page

#

and then copy it

meager mural
#

now i receive if the user has voted but still gives an error

#

i dont get any data from top.gg now 😃

restive otter
#

yeah well without errors and code, nobody can help krShrug

meager mural
restive otter
#

Most likely not

meager mural
#

lemme try again

restive otter
#

make sure you regenerate a token and then refresh the page before copying it

meager mural
#

it's working now, i was 100% sure topgg token was true 😃

unique ruin
#
4|ares  | TopGGAPIError: 504 Gateway Time-out
4|ares  |     at Api._request (/home/ubuntu/Ares/node_modules/@top-gg/sdk/dist/structs/Api.js:76:19)
4|ares  |     at runMicrotasks (<anonymous>)
4|ares  |     at processTicksAndRejections (node:internal/process/task_queues:96:5)
4|ares  |     at async hasVoted (/home/ubuntu/Ares/commands/information/profile.js:73:15)
4|ares  |     at async getBadges (/home/ubuntu/Ares/commands/information/profile.js:41:15)
4|ares  |     at async Object.run (/home/ubuntu/Ares/commands/information/profile.js:23:18)
4|ares  |     at async AresClient.<anonymous> (/home/ubuntu/Ares/events/messageCreate.js:104:5) {
4|ares  |   response: Response {
4|ares  |     size: 0,
4|ares  |     timeout: 0,
4|ares  |     [Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },
4|ares  |     [Symbol(Response internals)]: {
4|ares  |       url: 'https://top.gg/api/bots/check?userId=701643179212013568',
4|ares  |       status: 504,
4|ares  |       statusText: 'Gateway Time-out',
4|ares  |       headers: [Headers],
4|ares  |       counter: 0
4|ares  |     }
4|ares  |   }
4|ares  | }
```why is this error coming?
#

is this because of the issue with the api?

plucky lance
#

Yes

unique ruin
#

oki

pulsar sandal
#

@top-gg/sdk is official package right

restive otter
atomic nacelle
#

Vote required command!!
Made by - Me
Follow the steps
Step 1

npm install @top-gg/sdk```

**Step 2** Put this in Index.js
```js
const { Api } = require ("top-gg/sdk");
client.topgg = new Api(top.gg token);  //your top.gg token ```

**Step 3** Put this in InteractionCreate.js
```js
// Starting 
      let hasVoted = await client.topgg.hasVoted(interaction.user.id);
    const voteme = new MessageEmbed()
      .setTitle('Vote me to use this command')
      .setDescription(`You must vote me on [TOP.GG](https://top.gg/bot/1016392200516550736) to use this command`)
      .setFooter('Made by DEVANSH#4075')
      .setColor('#03fcdb')
       const actionRow = new MessageActionRow()
      .addComponents([
        new MessageButton()
          .setLabel('Vote')
          .setURL("https://top.gg/bot/1016392200516550736")
          .setStyle("LINK")
          .setEmoji("1018200886268412017")
          .setDisabled(false)
        
      ])
if(cmd.voteOnly && !hasVoted){
  return interaction.followUp({embeds: [voteme] , components: [actionRow]}
  );
}
//Made by DEVANSH#4075
      //ending```
**After doing this come in your command on module export and put ```js
voteOnly: true,``` and its working!**
Output =>
plucky lance
#

what an horrible solution

#

imagine doing an API request whenever a command interaction happens

jaunty badger
#

Be nice

plucky lance
#

also this isn't a promotion channel especially when recommending possible API spam

restive otter
#

whats the point of the endpoint then

plucky lance
#

to do requests but not to run into rate limitation

#

with cursed code

jaunty plank
# restive otter whats the point of the endpoint then

Ideally when using hasvoted, you would cache results.

ie, if the endpoint returns 1, cache it for a few hours. if they haven't cache it for 5-10 minutes and tell them where and how to vote.

Even then, you're bound to hit ratelimits eventually, and api downtime will break those commands.

#

Ideally, hasvoted should be a temporary solution

restive otter
#

^

plucky lance
#

once a beautiful day it might be a reliable way of handling votes

restive otter
#

what if im lazy

#

😗

#

have fun with ratelimits

#

ill throttle it myself tho so no issues with that

jaunty plank
#

Its one of those things where its not a problem unless many people are using it.

when it does become a problem it can result in dozens or hundreds of people trying to use a command they voted to get, and now cant get.

restive otter
#

also keep in mind that top.gg is cached to hell so you might get false negatives

plucky lance
#

@west shoal

west shoal
#

@cinder moat no ads here

iron mural
restive otter
#

nothing new

#

you have to catch the errors

iron mural
#

i got a lot of errors cause of their api

restive otter
iron mural
#

i catched them already 💀

#

but idk how tf that error appeared

restive otter
#

5xx are server errors, not client

#

but the lib returns it as an error

#

so they have to catch it

hot badger
#

How do you show the server count of bot on topgg

restive otter
#

read the docs

hot badger
#

i figured it out

restive otter
#

my bots servercount isn't showing (it's been recently approved). Is this just a recent approval thing or do i have to do something?

#

oh

restive otter
#

read the docs

hot badger
restive otter
#

thankyou

atomic nacelle
atomic nacelle
pulsar sandal
#

I created new webhook and put link here, but when i do send test it doesn send there. why

restive otter
#

you didnt read the docs

#

webhooks != discord webhooks

restive otter
atomic nacelle
#

@restive otter Does Top.gg bot description support Mark down language

#

?

restive otter
#

Yes, HTML & CSS as well

atomic nacelle
#

Ok

atomic nacelle
#

I changed the description with html

restive otter
#

Waiting time is up to 2 weeks and that for everyone

atomic nacelle
restive otter
#

Seems fine, just note that all your Activities Command are against Discord's ToS

atomic nacelle
#

Should I remove that from description?

restive otter
#

You should remove that from your bot entirely

atomic nacelle
#

Ohk

plucky lance
# atomic nacelle Do you have any better idea?

Yes, either cache the results for a certain time per user using your commands or much better, let topgg send webhooks to your endpoint once somebody votes.

You can still get rate limited quickly when multiple people are using commands fast and frequently, not so when using webhooks.

The data you receive from topgg includes the Discord user ID. The time you receive it, is the timestamp when the vote happens.
Store both in a database and query the database when executing a command.
You can now cache the result for the time you saved in your database + 12 hours.
After the user needs to vote again.

#

Over all the most recommended and useful way.

plucky lance
#

Try to respond in English so others can understand you

atomic nacelle
plucky lance
#

What part of it you don't understand?

atomic nacelle
woeful gale
#

I'm getting this error: Error: 401 Unauthorized (You need a token for this endpoint)
I've tried regenerating the token and applying it, but it persists.

woeful gale
plucky lance
#

It’s an issue on the server site, not your site

#

You don’t need to regenerate your token

#

That won’t fix the issue as you already noticed

woeful gale
#

alright

restive otter
still adder
#

hii, I'm using requestbin to detect votes in top.gg, but the code just isn't detecting, does anyone knows what is the problem?

plucky lance
#

Pretty much doubt you have to add the FQDM and path as option to your app.post() method

still adder
#

I also tried using ip

plucky lance
#

Another thing is regarding your first screenshot the protocol is HTTP not HTTPS

still adder
#

I also changed https to http

plucky lance
#

You usually just specify the path

#

It will be bind to your server ip per default since your didn't specify anything as option inside app.listen() except the port

#

app.post("/dblwebhook", ...);

#

The URL to enter on topgg then is http://<ip>:3200/dblwebhook

#

(or hostname)

#

Must be a valid A record not IPv6 (AAAA)

violet turtle
#

Where do I find the API stuff so I can give rewards for voting?

jaunty plank
violet turtle
#

tysm

violet turtle
#

I'm new to this http stuff and it's hard 💀

ornate kiln
jaunty plank
#

If you recently refreshed your token, try refreshing it again, then refreshing the page, then copying the token.

plucky lance
#

Same goes for me

#

Same error randomly appearing after the app is running for months

jaunty plank
#

did you get the 401 error sporadically(for a period of time) from the 19th-now?
then got them consistently after refreshing the token?

#

I think it may be two issues.

#

the 404 voting page issue I think resulted in bot tokens getting 401's.
Then some devs are refreshing tokens, but getting the refresh token bug

plucky lance
#

But no I haven't regenerate my token for months/years

jaunty plank
#

still getting it sporadically? or did it stop yesterday?

plucky lance
#

Something I need to check

#

Unfortunately can't do that atm

ornate kiln
rigid dust
#

is authorization header required or can we do it in the url

jaunty plank
#

It's required in the header.

rigid dust
#

quick question, im coding a voting only command

#

will voted property only be 1 if they vote?

#

ik weekends count as double votes

#

so will it ever hit over 1? like 2

jaunty plank
#

It's a boolean, 1 meaning true, 0 meaning false.

rigid dust
#

ok thank you so much bro, super excited!

#

ive been looking for a 1 or 2 hours

#

i finally got it to work 🙏

#

wait @jaunty plank