#topgg-api

1 messages · Page 160 of 1

rocky sedge
#

well cool thanks

sullen nymph
#

Should probably edit that

#

I'm not sure if a sane person would think this is comprehensible

wild spoke
#

Does anyone know how I can get the number of servers that my bot has on the page?

rain heart
empty violet
#

can i get who voted for my bot using an api instead of using webhooks?

violet sorrel
#

Means when anyone vote our server the bot will embed the message

coarse rune
#

@violet sorrel djs or dpy

true dagger
#
module.exports = (client) => {
    console.log("-------------------------------")
    console.log(`Logged in as ${client.user.tag}!`)
    console.log("-------------------------------")

    client.user.setPresence({
        status: "online",
    });
    client.user.setActivity('e!help', { type: 'WATCHING' });
    //topgg stats
    const Topgg = require('@top-gg/sdk')

    const api = new Topgg.Api('my topgg api token')
    
    setInterval(() => {
      api.postStats({
        serverCount: client.guilds.cache.size
      })
    }, 1800000) // post every 30 minutes
}

any ideas why this isn't working?

#

topgg-autoposter won't work as well, it returns Unsupported Client

small wraith
#

But where can i das which bot is mean by the vote

restive otter
#

What exactly do you mean by that?

#

The payload has a bot field which is the ID of the voted bot, if that's what you mean.

small wraith
sullen nymph
cosmic plume
#

I have a question:

const fetch = require("node-fetch");

let url = `https://top.gg/api/bots/${bot ID}/check?userId=${user ID}`;

  fetch(url, { method: "GET", headers: { Authorization: `${your top.gg bot token}` }})
    .then((res) => res.text())
    .then((json) => {
      var isVoted = JSON.parse(json).voted;
      if(isVoted === 0) return message.channel.send("No");
      else return message.channel.send("Yes");
  });

How can I get my top.gg bot token?

sullen nymph
#

Here

cosmic plume
#

@sullen nymph 😦

meager nebula
#

just refresh it

restive otter
#

how to get my topgg api?

jovial idol
#

How can I fix this?

jovial idol
cinder cobalt
#

hey how i can put the server count in my bot?

iron gust
#

. fef

cinder cobalt
#

Pls help

small wraith
#

I have the Same Problem

cinder cobalt
#

Thanks

restive otter
#

I keep getting the error

#
AttributeError: aexit```
#

everytime I try to post the guild count

#

I'm using python wrapper of the api

#

and this is my code

#
dbl_token = tings
client.topggpy = topgg.DBLClient(client,dbl_token,autopost=True)

@client.event
async def on_autopost_success():
    channel = client.get_channel()
    await channel.send(f"Posted server count ({client.topggpy.guild_count})")

@client.command()
async def update_stats(ctx):
    await ctx.send("triggered")
    # try:
    #     a= await client.topggpy.get_guild_count()
    #     await ctx.send(a)
    # except Exception as e:
    #     await ctx.send(e)
    try:
        await client.topggpy.post_guild_count()
        await ctx.send(f"Posted server count ({client.topggpy.guild_count})")
    except Exception as e:
        await ctx.send(f"Failed to post server count\n{e.__class__.__name__}: {e}")```
#

my token was actually there lmao

balmy hamlet
#

You shouldn't try to fix a car if you don't know what an engine is

quaint compass
#

True

#

mb sry

marble raptor
#

so to see a person has voted on top.gg, I should send a request to top.gg/api/bots/<bot_id>/check?userId=<user_id>?

#

nvm

slim cloak
#

Un

random owl
#

nvm

#

not sure if this is the place to ask this but,

#

i did this and it says "dbl-stat deprecated" on my website

#

This is what it what I did
<dbl-stat bot-id="bot-MyBotId" stat="guilds">Loading...</dbl-stat>

#

also, where do I find my dbl token

half compass
random owl
#

where in the bottom

#

nvm found it, thanks!

pearl lava
#

How i acces to webhook of my bot?

#

If i click there i get 404

sullen nymph
random owl
sullen nymph
#

Oh yeah

random owl
#

it doesnt work anymore

sullen nymph
#

That and this ain't the place, yeah

random owl
#

yea i was told

sullen nymph
rocky gale
#

hi guys

#

i am adding a webhook to my bot, but
when i click test webhook
the webhook doesn't actually go through

#

i tried it with postman, and it worked so its not the fault with the webserver

#

ok now it worked

restive otter
#

where is webhook password stored ?

#

link to the page please

#
import discord
from discord.ext import commands

import topgg

client = commands.Bot(command_prefix="--",member_cache_flags=discord.MemberCacheFlags.none())
# This example uses topggpy's webhook system.
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("/dblwebhook", "pass")

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


@client.event
async def on_dbl_vote(data):
    """An event that is called whenever someone votes for the client on Top.gg."""
    print(data)
    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 client on Top.gg."""
    print(f"Received a test vote:\n{data}")

client.run("token")``` is anything wrong here ?
meager knot
#

Aah
Ig it should work I am also trying to work on this now

restive otter
#

it isnt working

meager knot
fallen thistle
#

Euh is it known that the webhook menu of the edit page is broken?

#

And widgets

#

and announcements

#

and analytics

dapper copper
#

try logging in and out

fallen thistle
#

Did not work

#

@dapper copper

dapper copper
#

Hmm

#

cc @craggy sentinel

craggy sentinel
#

F5

fallen thistle
#

F5?

craggy sentinel
#

refresh the site while being on the broken page

fallen thistle
#

That did work

#

Very very strange

vocal solar
#

how do i get the headers from the vote webhook post request?

#

the auth token or whatever it is

#

@dapper copper

#

nvm found out how

fallen thistle
#

Do the test webhooks work?

#
import dbl
import json
with open('config.json', 'r') as config_file:
    config = json.loads(config_file.read())

class Vote(commands.Cog):

    def __init__(self, client):
        self.client = client
        self.dbl = config["dbl"]
        self.token = self.dbl["token"] # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.client, self.token, webhook_path='/dblwebhook', webhook_auth=self.dbl["password"], webhook_port=self.dbl["port"])

    @commands.Cog.listener()
    async def on_ready(self):
        print(dbl.__version__)

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print('Someone voted')
        print(data)```Because this isn't triggered
restive otter
fallen thistle
#

Because this isn't triggered

#

This is the third time I am trying to figure this out

#

As always I barely get help here which leads me to abandon it for another month

restive otter
#

Does it show 405 when you do a GET request through your browser? Is the port open? Does the auth match the one on the site? Also, it's advised to migrate to topggpy.

distant vale
#

where i find my api?

fallen nymph
solemn geyser
#

It doesn't show how many servers my bot is on, why?

rain heart
#

-servercount

abstract mothBOT
sturdy gorge
#

Alguien me pasa la api de topgg

stable helm
#

Can anyone help me to do this in my bot?

subtle pulsar
vivid tendon
#

how i can get dbl api ?

crisp socket
stable helm
subtle pulsar
#

You already have the code snippet

stable helm
subtle pulsar
#

what error?

#

Make sure you did change the things you have to change

subtle pulsar
subtle pulsar
#

You're welcome!

novel shell
#

if you know to make a http post request, dont use libraries. it just makes it more complex

fallen nymph
willow spindle
#

https://top.gg/bot/BOT ID/webhooks

fallen nymph
willow spindle
#

?

#

read error

#

read error

heady prawn
#

😐

fallen nymph
#

i thought i miss spelled it

#

how to get this token?

willow spindle
#

you don't read my messages, do you?

willow spindle
fallen nymph
restive otter
#

what is the required webhook in DSL?

#

the discord webhook doesn't work

plucky lance
#

You need to host your own webhook service in order to receive webhooks from topgg.
Discord webhooks has nothing to do with that at all.

surreal hollow
#

can someone help me with webhooks

#

if im using the example on the python page

#

do i have to make a webhook on the admin dashboard for my bot

#

over here

surreal hollow
#

What is my webhook url

#

Do I have to host smtn

#

Is there any easier way to do this

#

but idk my ip

#

And what if it change

#

My rpi

#

How

#

Ok wait

#

I have a domain

#

How can I use that shit

#

@shut flume

#

nw

#

Thanks

#

I think imma just use the manual req/post stuff

scenic bane
#

umm....i can't understand where am going wrong abt it

torpid trout
#

🚨ALERT🚨 watch out! ford Fiesta 2018 is on the run killed 1guy 🚨🚨🚨

novel shell
#

do u use d.js?

#

you can use node-fetch

const fetch = require("node-fetch");
await fetch("https://top.gg/api/bot/yourbotid/stats", { method: "POST", body: JSON.stringify({ server_count: client.guilds.cache.size }), headers: { Authorization: "your topgg token" } });
safe comet
shut remnant
#

I want to use the API for my bots vote. After going to the page I can't access the widget page,Webhook page.

#

How can I get the api for vote?

small shard
#

This error always showing

green mantle
#

the fuck do you read anything on that page?

shut remnant
#

What are the api option? or how can I prevent rate limits?

restive otter
#

How do I thank users For voting my bot

#

Ping me when replying

lilac flare
#

Hi

shut remnant
#

how to get autoVote instance?

safe comet
#

how do i check if the user has recently voted my server?

safe comet
#

js

coarse rune
#

Ok

#

hasVoted(userid)

#

@safe comet

safe comet
#

uhhh example?

#

i dont know where do i execute that method from

coarse rune
#
const { Webhook } = require('@top-gg/sdk')

const wh = new Webhook('Top.gg server webhook password')
const app = express()

app.post('/webhook', wh.listener((vote) => {
  console.log(vote.user) 
}))

app.listen(port)```
#

There

safe comet
#

that doesn't explain hasVoted method or that just doesn't exist

coarse rune
#

Oh sorry

#

const Topgg = require(`@top-gg/sdk`) const api = new Topgg.Api('Your top.gg token') if(message.content == "test") { const userid = message.author.id; if(api.hasVoted(userid) == true) message.channel.send('voted') else { message.channel.send('not voted') } }

#

Here

safe comet
#

the token will be my auth right?

coarse rune
#

Yes

safe comet
#

also how long will that be disabled??

coarse rune
#

Wdym

safe comet
#

like after a 3h hasVoted will be false

coarse rune
#

12 hours

safe comet
#

oh hmm

coarse rune
#

Till ur voting period is ovef

#

Over

safe comet
#

sad that server webhooks r down tho

#

wait does that only apply to real votes

#

not just test?

safe comet
#

i wont

#

since that wont work cuz message aint defined

#

the only thing I'll "copy" is the api

coarse rune
#

Try it

#

Or give me your server link i will do it

safe comet
#

nah ill do it myself

coarse rune
safe comet
#

wait if webhooks r down will the api says false or true

#

nvm ill find it out myself cursedpog

coarse rune
#

I meant give me your server link for voting it

#

@safe comet

safe comet
#

im gonna test it myself sad

coarse rune
#

Check dm@safe comet

safe comet
#

pls just leave it to me sad

gloomy prism
#

so i have this now so how can i get it to send the server count

plucky lance
#

The webhook service won’t post your server stats.

gloomy prism
#

nvm i got it

#

it was through autoposter

plucky lance
#

Aye

gloomy prism
#

i literall figured it out a second before u said that lol

plucky lance
pallid cedar
#

I'm so confused with webhooks, is it not as simple as installing the api and copying the code?

#

or do I have to set up server stuff?

gloomy prism
#

does this update everytime someone adds the bot to the server or does it only update when the bot starts

plucky lance
#

The auto poster should run an interval which updates the guild count every X minutes

#

Think it’s 30 mins but dunno anymore

gloomy prism
#

ohhh can u change the interval?

#

or nah

plucky lance
#

You can but that’s not needed.

fast hornet
#

I don't really know what to do

#

or did I do it wrong

green mantle
#

doesnt use discord webhooks

#

the webhook url is a url to a webserver you host

#

that expects a POST request and returns 200 OK

royal plover
#

i need someone's help, i don't know how to pull the time left to vote again.

strange briar
#

.nw

restive otter
#

@shut flume

#

what is 403 actually

#

Post stats

#

Well my bot posted stats without any error

#

But it gave error now

#

wait a sec

#

lemme grab ss

#

Hmm i am using autoposter to post stats

#

yep

#

its top gg token yes

#

not client

#

my code btw

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

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

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

Ok lemme do it

#

well i am sure my token is correct. I double checked it

#

Should I try regen the token?

sullen nymph
#

That's 401

restive otter
#

huh postman?

#

lmao

sullen nymph
#

403 is forbidden access

restive otter
#

I am getting 403

#

yeah

sullen nymph
#

api//bots

#

Ofc

#

How does that even happen

restive otter
#

ag again erro

#

error

#

403

sullen nymph
#

????????????????????????????????????????????????????

restive otter
#

it showed me "Posted stats" and again it returned error

sullen nymph
#

Have you tried updating topggjs

restive otter
#

@waxen widget-gg/sdk

#

oof

#

ping

#

nvm

sullen nymph
#

This is weird

restive otter
#

Does autoposter got any update?

sullen nymph
#

Fuck knows ngl I don't keep up with the JS stuff

restive otter
#

My Autoposter version is 2.0.0 btw

#

sad ok

#

who is the developer of js?

sullen nymph
#

You could just report it as an issue on the GitHub repo for the autoposter

restive otter
#

ok

stuck forge
#

Can someone help me with top.gg api? With the webhook hosting thing, im not sure where to begin

safe flicker
#

whats the best way to find out if a user has voted for my bot and then store it to a database? I want some specific commands to work only when the user voted

shut remnant
#

Anyone know about the webhook?

verbal locust
#
const Topgg = require("@top-gg/sdk")
const api = new Topgg.Api(process.env.APIKEY)

client.on("message", message => {
  if (message.content == "+control") {
    const userid = message.author.id;
      if(api.hasVoted(userid) == true) message.channel.send(':white_check_mark: Voted.')
      else message.channel.send(':negative_squared_cross_mark: Not voted.')
  }
})```is it true?
#

code

#

i voted 15 minutes ago and it still says "not voted"

restive otter
#

it is a command>

verbal locust
#

i found it stackoverflow and never changed

restive otter
#

oh no

#

that's more of the .has method in js

#

which returns an array not a boolean

verbal locust
#

so

#

how can i check if user voted

restive otter
#

console.log things

#

and see if the event is emitted

verbal locust
restive otter
#

noo

restive otter
#

idk if it returns an array but ok

verbal locust
#

Console:

Promise { <pending> }```
subtle pulsar
#

The promise will always log pending as long as its results are not resolved yet. You must call .then on the promise to capture the results regardless of the promise state (resolved or still pending):

userid.then(function(result) {
   console.log(result)
})```
willow spindle
#

umm...resolve promise then??

restive otter
#

uhm you need to resolve the promise

subtle pulsar
verbal locust
#
userid.then(function(result) {
           ^
TypeError: userid.then is not a function```
restive otter
#

no

willow spindle
rocky tree
willow spindle
#

learn basics of js before making a bot

verbal locust
#

Why do you say learn something instead of showing you how to do it?

rocky tree
#

cuz it doesnt need those .then

verbal locust
#
api.hasVoted(userId).whenComplete((hasVoted, e) -> {
    if(hasVoted)
        console.log("This person has voted!");
    else
        console.log("This person has not voted!");
});```?
willow spindle
#

don't spoonfeed

restive otter
#

I tried it and worked lol

restive otter
verbal locust
#

thank you

restive otter
#

he justs need to put a simple await

#

¯_(ツ)_/¯

willow spindle
#

not asking for code

verbal locust
#

i deleted await because it gives error

willow spindle
#

😩

restive otter
#

use async in message event

verbal locust
willow spindle
#

oh really

restive otter
#

you would have to add more to this code

verbal locust
willow spindle
#

@rain heart spoonfeed case

verbal locust
restive otter
#

It's more than that ok thanks bye

restive otter
willow spindle
#

you don't even know what you did eyuq

rain heart
verbal locust
restive otter
willow spindle
#

not my problem

verbal locust
#

and if you're over 8, stop making fun of people with disabilities

willow spindle
#

your disabilities??

rain heart
#

Can we drop it please, thanks

willow spindle
#

lmao are you serious

rain heart
#

@restive otter avoid spoonfeeding please

#

Drop it

restive otter
rain heart
#

Thank you ThumbsUp

restive otter
ripe wharf
willow spindle
ripe wharf
#

Thanks

stuck forge
#

Can someone help me with top.gg api? With the webhook hosting thing, im not sure where to begin

willow spindle
stuck forge
verbal locust
willow spindle
#

so whats your problem

restive otter
#

tried reading pins?

stuck forge
#

Im still confused where/how to host a webhook

willow spindle
#

do you use js

stuck forge
#

Yes

willow spindle
#

you can use official library

stuck forge
#

And where do i get the webhook?

willow spindle
#

https://top.gg/bot/BOT ID/webhooks

shut remnant
#

Anyone know about the webhook?

#

I am having trouble to use the webhook

sullen nymph
#

Webhooks in context of Top.gg are webservers hosted on physical machines and listening to HTTP requests. To host one, you need to use a framework (most official Top.gg libraries support webhooks).

shut remnant
#

How?

#

I have tried

#

But didn't work while. I voted

verbal locust
#

how can i use "if someone people voted" event

#

when someone people voted, send message to #channel

rocky tree
#

What dict is returned on topgg.on_dbl_vote()?

#

i mean

#

the structure

verbal locust
rocky tree
verbal locust
#

js

rocky tree
#

and what does that return

#

?

#

ok

#

i found

#

it

unique ruin
#

Ok

toxic copper
#

while running my bot I got this error

TopGGAPIError [Top.GG API Error]: 403 Forbidden (You don't have access to this endpoint)

how to resolve this?

warped portal
#

where in the code do i have to add the thing that shares the server number and shards?

hushed reef
restive otter
distant vale
#

Where i get my bot's api?

brittle grove
distant vale
#

i get it

brittle grove
distant vale
#

how to get shard count?

fallen nymph
#

@smoky swift

#

Someone tried to mention everyone

#

with a hacking link

oblique jewel
#

Before there was a thing were I hit submit were is that now?

#

In webhooks

#

pls help

solemn geyser
#

Why is it that when someone votes, it is issued several times?

#

When someone votes, the API sends me 10 requests. Why?

#

HELP!

dry sail
#

i keep getting this error for some reason

hidden brook
#

how can I set my bots staus on the tog.gg website

rain heart
#

GET is a http method

dry sail
#

so what should i do?

rain heart
#

Do a proper request if you wish to test it

safe comet
#
const client = require("../other/client.js")
const {Webhook} = require("@top-gg/sdk")
const voteWh = new Webhook(process.env.serverWebhookToken)
module.exports = {
  run(app){
    console.log("Listening to votes.")
    app.post("/webhook/vote",voteWh.listener(async(vote)=>{
      console.log(vote)
    }))
  }
}

is this correct :hmm:

restive otter
#

Hey, I'm pretty confused with the API, how can I track User ID's of people that vote for the bot? I just want to make a command so that people can claim things if they voted for the bot on that day.

dusky monolith
#

Regarding the port of the webhook, I'm hosting my bot on a hosting service and the server's port is 1111. Is that the port I should use?

dusky monolith
restive otter
dusky monolith
#

Total times they've voted

restive otter
#

m well im tryna make it track if theyve voted on that specific day

dusky monolith
#

You want to reward them when they vote or you just want to know when they vote?

restive otter
dusky monolith
#

Well, you can get the amount of times they voted using this and check if it's 0 ask them to vote, otherwise give them the reward.

#

The only problem here is that you cannot decrease the amount when they redeem since this is data given from topgg's database itself.

restive otter
#

alr

#

ty

dusky monolith
#

Dude this is frustrating. I've been trying to make it just print the ID of the voter for 2 months now. And there's barely any support or answers when I ask.

#

What is that exactly?

#

@hidden crow can you please help me?

hidden crow
#

Wait for someone to assist you, I’m busy Rn

dusky monolith
#

Okay.

opaque flame
#

Can anyone give me api to see who had voted to your bot

humble violet
#

I cannot access the Webhook section of my bot? Is this because it has recently been accepted?

restive otter
dusky monolith
opaque flame
#

Oh ok thanks

dusky monolith
#

What is the webhook_path?

opaque flame
#

How to use this?
https://top.gg/api/bots/:855375485529227276/votes

sullen nymph
#

Remove the :

#

In the ID

opaque flame
#

Ok it works

#

Btw can I make it in command?

sullen nymph
#

If the command isn't used frequently, sure

opaque flame
#

Wdym?

sullen nymph
#

What's not clear about my answer?

#

If you fetch directly from that endpoint, it's gonna get your bot ratelimited if the command is used too often

opaque flame
#

Ok

royal shuttle
#

can i use middleware like IFTTT with the api?

rain heart
#

Doubt ifttt can do it alone as you need to provide authorization etc

#

I really suggest either using a bot or coding your own

royal shuttle
#

okay, imma just make my own one then

manic sparrow
#

why does it doublesend the vote webhook?

rain heart
#

You're probably not acknowledging the request through a 2xx

#

It retries when it doesn't get one, check docs

manic sparrow
#

it does send a 200 empty body res

#
  • it would retry more than only once if it didnt succeed
#

it does 204

#

does it retry bc its 204?

rain heart
#

204 should work too

#

Are you properly closing the connection too?

#

It also retries when timing out

manic sparrow
#

hold on

royal shuttle
#

i like that ur url is "weebhook" lmao

manic sparrow
#

the heroku app went to sleep and it took some time to get it back online and in the meantime the request got sent again i assume

manic sparrow
#

i set uptimerobot to ping the app so it doesnt go to sleep

hidden brook
#

how can I set my bots staus on the tog.gg website

sullen nymph
#

You don't

worldly reef
#

when appending the auto-poster to discord's sharding manager, do i append it after the spawn() or before

restive otter
#

in topgg py how to message people that "thank u for voting"?

rain heart
hot swan
#

Hello how I can make if someone make vote to bot bot send in room and give him voter

hallow night
#

my bot gets ratelimited coz of get_user_vote being used too often, is there any other way to check votes other than this and on_dbl_vote

sullen nymph
#

Caching results

rain heart
#

Or webhooks

#

Which I would def recommend if you have a high usage of vote checks

cobalt jetty
#

My bot keeps crashing with Error: 520 Origin Error, any way I can avoid it crashing when the site goes down?

solemn geyser
celest gorge
#

Hello, I am trying to use top.gg webhooks, am I doing this correctly?

import discord
from discord.ext import commands
import dbl
class TopGG(commands.Cog):
    def __init__(self, Client):
        self.Client = Client
        self.dblpy = dbl.DBLClient(self.Client, "token", webhook_path="/dblwebhook", webhook_auth="auth", webhook_port=5000)
    @commands.Cog.listener()
    async def on_dbl_vote(self, Data):
        print(Data)
    @commands.Cog.listener()
    async def on_dbl_test(self, Data):
        print(Data)
def setup(Client):
    Client.add_cog(TopGG(Client))

But nothing is printed when I test the webhook?

#

am I supposed to put the IPv4 address in the "Webhook URL"?

shut remnant
#

hey can anyone help me with the webhook of top.gg for getting vote notification when someone voted?

#

I have tried a lot but nothing is working

sullen nymph
celest gorge
sullen nymph
#

Ah well if it works it works

solemn geyser
#

HELP!!

sullen nymph
restive otter
#

how can we do n/a to server count

sullen nymph
#

You can't

restive otter
sullen nymph
#

Because God knows

restive otter
#

N/A to 227,179 Servers

#

only

sullen nymph
#

Oh fuck's sake

restive otter
sullen nymph
#

Your top.gg library probably has a function to post your bot object's guild count

sullen nymph
restive otter
sullen nymph
#

You can refer to official Top.gg documentation if you want to use the API directly yourself (docs.top.gg), or use a library that simplifies the process for you

restive otter
#

aviable

#

docs have full tutorial

#

you can check it

sullen nymph
#

Docs have examples

#

You don't need a tutorial for everything

restive otter
#

can you pls give me exact link @restive otter

#

docs

restive otter
sullen nymph
#

How lazy are you

restive otter
sullen nymph
#

Literally go to https://docs.top.gg and find it yourself for whatever programming language you use for your bot

Top.gg documentation

Welcome to Top.gg

restive otter
#

lol

#

it to easy

#

sos

#
const fs = require("fs");
const keep_alive = require('./keep_alive.js')
const { Collection, Client } = require("discord.js");
const client = new Discord.Client() // Your discord.js or eris client (or djs ShardingManager)
const { AutoPoster } = require('topgg-autoposter')


const client = new Client();
const ap = AutoPoster('Your Top.gg Token', client)
client.commands = new Collection();//Making client.commands as a Discord.js Collection
client.queue = new Map()
require('discord-buttons')(client)```
#

is this right

#

or wrong

sullen nymph
#

Try it

worldly reef
#

asddh how am i supposed to send the userID and not the word snowflake...

sullen nymph
#

In a string

worldly reef
#

like "snowflake"?

sullen nymph
#

What are you trying to do is my question

worldly reef
#

oh

#

so basically I'm appending snowflake onto herokuappname/webhook/discord/serverid/token

#

and it's not sending the userID, instead it's sending the word snowflake

#

like: herokuappname/webhook/discord/serverid/tokensnowflake

forest trench
#

how do i get my api token?

#

nvm

worldly reef
#

what's a middleware?

stray lynx
#

import topgg

This example uses topggpy's webhook system.

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

The port must be a number between 1024 and 49151.

bot.topgg_webhook.run(5000) # this method can be awaited as well

#

what password do we need to add here ?

solid imp
#

While registering a webhook url, we have to make a route on our server for example say /webhook and then listen to whenever a request is made to this endpoint, right?

sullen nymph
#

Correct

sullen nymph
stray lynx
#

oh okok thanks

restive otter
#

Is on_dsl_vote triggered on voting bot or server?

forest trench
#

dsl = discord server list

restive otter
forest trench
#

Can we use DBLClient instead of WebhookManager for the on_dbl_vote event?

sullen nymph
restive otter
sullen nymph
#

Wtf how tired was I when writing it

forest trench
#

or do we need to have a webhook

sullen nymph
#

Well without a webhook there's no receiver

#

You may be sending crap like wherever but it needs to be received and processed

#

Sooooooo

#

No webhook no vote events

forest trench
#

ah

#

i see

sullen nymph
#

You can use the API yourself but make sure you follow ratelimitz

forest trench
#

ye

forest trench
#

@sullen nymph how do i set up my bots webhook?

sullen nymph
#

WebhookManager.dbl_webhook weeeeee

forest trench
sullen nymph
shut remnant
#

I need help with webhook

sullen nymph
#

Don't we all

forest trench
#

ah

shut remnant
#

Middleware is not working

#

In webhook

sullen nymph
#

Show code

shut remnant
#

The code is in the pins of this channel. I got no err... But it is not giving the info of who is voting

forest trench
sullen nymph
forest trench
#

alr

forest trench
#
raise ValueError("path should be started with / or be empty")
ValueError: path should be started with / or be empty
``` @sullen nymph idk im confused
sullen nymph
#

Don't set your route to the complete URL

#

It's the /route at the end of the URL after ip:port

solemn geyser
#

||***```js
throw new ApiError(response.status, response.statusText, responseBody);
^

TopGGApiError: 520

rocky tree
#

Hey

#

What if someone posts wrong server count?

#

like someone abuses the api and posts 10000 servers

#

count

restive otter
#

Get 🔨

restive otter
#

i know i guess so

worldly reef
#

does anyone know how to make a webhook url with heroku for top.gg? I'm kinda completely lost

subtle pulsar
#

from there, you'll see copy url for the webhook

worldly reef
#

and then what do i have to do after that?

#

just post that url in the webhooks section of top.gg?

subtle pulsar
#

I am not sure what you're goin to do with it

#

What are you trying to do?

worldly reef
#

Uh I'm trying to get voting to work. I'm a bit stupid when it comes to these things lol

subtle pulsar
#

Like a voting log?

sullen nymph
worldly reef
#

Oh, I should also mention that I'm using it for the discord bot section

worldly reef
sullen nymph
#

Make sure your web dyno is on and that you added the route you use specifically for bot votes to the URL

stray lynx
#

Im using this but still not getting any response on testing
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("http://my_vps_ip:5000/dblwebhook", "password")

sullen nymph
#

dbl_webhook("/dblwebhook") please

#

You set up a route on the machine the listener runs. That means you don't set your URL there

stray lynx
#

oh ok i'll try that

#

i tried
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("/dblwebhook", "password")

and http://my_vps_ip:5000/dblwebhook in webhook url on site

getting this on reboot:
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f460642a908>

restive otter
#

That's just a warning and not related to WebhookManager.

stray lynx
#

ok but its still not working for me

sullen nymph
#

Are you running client.topgg_webhook in the first place

stray lynx
#

yes

#

it works for server count thing

sullen nymph
#

client.topgg_webhook.run(...)?

stray lynx
#

ya ya

#

client.topgg_webhook.run(5000)

sullen nymph
#

Interesting

stray lynx
#

dbl_token = "xyztoken"
client.topggpy = topgg.DBLClient(client, dbl_token)

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

client.topgg_webhook.run(5000)

@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()

@client.event
async def on_dbl_test(data):

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

this is the exact thing im writing there

sullen nymph
#

Where's your on_dbl_vote event

river spindle
#

uhmm will it not work without it

#

just the test part

sullen nymph
#

on_dbl_vote is now used both for test and upvote types

#

It's up to you to handle them differently now

river spindle
#

ok i'll try with that brb

stray lynx
#

i tried removing test part thinking vote one worked but then it didnt so i added it back and now it return me info like id and stuff

#

and the output is from the test event

sullen nymph
#

...?

#

What do your on_dbl_vote and on_dbl_test look like?

stray lynx
#

@client.event
async def on_dbl_vote(data):

if data["type"] == "test":

    return client.dispatch("dbl_test", data)

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

@client.event
async def on_dbl_test(data):

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

output -
Received a test vote:
| {'bot': '759758239109087252', 'user': '710497600431849545', 'type': 'test', 'query': '?test=data&notRandomNumber=8', 'isWeekend': False}

restive otter
#

Cuz you dispatch it manually bloblul

stray lynx
#

It's same as documentation freerealestate

hallow night
#

ah thanks shivaco and grimm, i got my code working looking at your convos here

fast heath
#

How i make vote for coins in my bot?

cobalt jetty
#

My bot keeps crashing with Error: 520 Origin Error, any way I can avoid it crashing when the site goes down?

stray lynx
hallow night
restive otter
#

||***```js
throw new ApiError(response.status, response.statusText, responseBody);
^

TopGGApiError: 520

#

Woah

eternal warren
#

throw new ApiError(response.status, response.statusText, responseBody)
^

TopGGApiError: 520

#

Woah

#

~ye~

#

yee

#

?purge 27

#

Hahaha

jaunty plank
#
const Discord = require('discord.js');
const client = new Discord.Client();

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

const ap = AutoPoster('Your Top.gg Token', client)

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

client.once('ready', () => {
    console.log('Ready!');
});

client.login('your-bot-token-goes-here');

@devout cairn

#

^ example js bot using the library

devout cairn
#

what does client look like

jaunty plank
#

thats all client is. or do you want it logged?

#

its just an object

{
id: 412006692125933568,
name: stuff,
//a ton more methods and variables
}
#

the library is VERY specifically for discordjs and eris. it wont help you with making it for ruby.

devout cairn
cobalt jetty
#

I mean it's for help with the API, as the channel description says...

jaunty plank
jaunty plank
cobalt jetty
#

All I'm really doing is posting my servers, ok

daring pagoda
#

hey how do i know if the user has voted for the bot

jaunty plank
daring pagoda
#

I couldn't understand something when I looked there, can you tell me?

jaunty plank
#

well, there is two methods, are you looking for an event(you getting told when someone votes) or are you looking to check later if someone voted.

daring pagoda
#

check if you have voted

jaunty plank
#

what programming language?

daring pagoda
#

nodejs

jaunty plank
daring pagoda
#

so how do i pass it to command

jaunty plank
#

not sure what you mean by that, just in your commands file.

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

const api = new Topgg.Api('Your top.gg token')

const voted = await api.hasVoted(USERIDHERE)

// voted = true or false


daring pagoda
#
const Discord = require("discord.js");
const db = require("quick.db");

module.exports.run = async (client, message, args) => {
const Topgg = require(`@top-gg/sdk`)

const api = new Topgg.Api('')

const voted = await api.hasVoted(763700505280118805)

message.channel.send("you voted") 
return message.channel.send("you didn't give")
}

module.exports.conf = {
  enabled: true,
  guildOnly: false,
  aliases: [],
  permLevel: 0
};

module.exports.help = {
  name: 'voted',
  description: '',
  usage: 'voted'
};
#

If she hasn't voted, how will I respond?

jaunty plank
#

just a basic if statement

daring pagoda
#

Is it valid for all users?

jaunty plank
#

yep

daring pagoda
#

I don't quite understand how to do the if thing

#

can you post a sample of it

#

or will this code work

#
if(status === "true") {
  message.channel.send("you gave")
}
  if(status === "false") {
    message.channel.send("you didn't give")
  }
jaunty plank
#

yep should do, if status is the variable you put it in

daring pagoda
#
let status = message.mentions.users.first()
#

is it possible

sullen nymph
#

What

jaunty plank
#

thats just a user, you need to use the actual hasvoted method.
await api.hasVoted(useridhere)

daring pagoda
sullen nymph
#

What makes you think I'll understand whatever you tried to explain in Turkish now

daring pagoda
#

sorry :d

#

i'm bad at these things

sullen nymph
#

api.hasVoted iirc returns a boolean value

sullen nymph
#

You can use it in an if statement

hallow night
#

Hey there, if my bot is offline and someone voted during that time, will on_dbl_vote miss the vote?

copper sundial
#

Hi! I'm using python. I saw that there's an event reference in the docs called on_dbl_vote which is called when a user voted for a bot. Does an event like this existing for servers? Something like on_dsl_vote?

#

or do I have to use on_dbl_vote at dsl_webhook() too?

hallow night
#

i see

copper sundial
#

Hi again. At the WebhookManager, when I do that:

client = commands.Bot(command_prefix="-", case_insensitive=True)

topgg_webhook = topgg.WebhookManager(client).dsl_webhook(route="/dsl", auth_key="")
topgg_webhook.run(5000)

@client.event
async def on_dsl_vote(data):
    print(data)

How can I track the votes of my server? Don't I have to put the server ID somewhere or something like that?

sullen nymph
shut remnant
#

How to test the webhook in localhost or my own machine

#

?

restive otter
zealous crown
#

webhooks not working properly this week?

Send Test =>

An error has occurred while processing your request```

Have already tried refreshing the page, logging out, logging in, clear cookies, turning on and off beta mode
storm vale
#

can someone tell me step by step how to set up the servers counts for bot widget

gritty torrent
#

Hi, I don't understand what value i should indicate

plucky lance
#

Obviously a password (you can choose).

gritty torrent
#

Okay

plucky lance
#

Which needs to match the one on topgg if you even need one.

copper sundial
plucky lance
#

It’s the IP/DNS of the host system the webhook service is running on

#

(and port of course)

gritty torrent
plucky lance
# gritty torrent

Yeah as the placeholder 0.0.0.0 will be bind to your public IP assigned to the machine

#

Get the public IP of the system and there u go

twin reef
# gritty torrent

If ur on a vps, go to your control panel where you bought it and get that ip, and then it should work :)

gritty torrent
twin reef
#

nice congrats

visual oxide
#

can someone tell me why on_dbl_vote is not working?

#

client.topggpy = topgg.DBLClient(client, dbl_token, autopost=True, post_shard_count=True)

@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)
    votes_channel = client.get_channel(861992864162643998)
    print(f"Received a vote:\n{data}")
    await votes_channel.send(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}")
    votes_channel = client.get_channel(861992864162643998)
    await votes_channel.send(f"Received a test vote:\n{data}")


sullen nymph
#

Where's your WebhookManager

visual oxide
#

oh, do i need a webhook manger for that?

sullen nymph
#

Yeah, because on_x_vote events rely on a webhook to be invoked in real-time

visual oxide
#

oh, i see

#

ty

visual oxide
#

or smth like that

#

is that possible?

willow sphinx
#

that's what a webhook is

broken cypress
#

is it possible for me to access another bot's vote count?

sullen nymph
#

No

#

Well, only the count

visual oxide
forest trench
#
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("/dblwebhook", "password")

client.topgg_webhook.run(5000)
``` would this work? i doubt it cuz its the same thing from the pypi example.
sullen nymph
#

It would work

torpid coral
#

Will the votes be reset after new month ?

worldly reef
#

So i have been playing around with top.gg's stuff and it's been like 2-3 days of a bloody struggle PepeHands I changed hosts and everything, how do i get this to work?

vocal robin
worldly reef
vocal robin
worldly reef
#

uh it's not open-source so i prefer if people don't see it but okay if it has to be shared here

vocal robin
jaunty plank
#

realistically you only need to share the parts related to top.gg, all requests to or from top.gg's api looks the same so its opensource anyway.

worldly reef
#
const setupVote = require('../events/new_vote');
module.exports = {
            name: 'ready',
            once: true,
            execute(client) {
            setupVote(client)
           console.log('Ready to serve!')
            }
        }``` this is the function being called in my ready.js
jaunty plank
#

probably will want to reset your token

vocal robin
#

uff, regenerate your token

worldly reef
#

woops

#

yeah so i regenerated my token

#

and now i have to resend the message :,)

vocal robin
#

yeah, just remove the token..

worldly reef
#

So this is in my events folder ( where ready.js & message.js goes). I'm trying to get it to get the userID and then send a dm telling the user what they got

#

@vocal robin is that better?

umbral scaffold
vocal robin
#

" console.log(Webhook running at path http://${hook.hostname}:${hook.port}${hook.path});""
Does this part come? @worldly reef

vocal robin
vocal robin
#

and the second one?

worldly reef
worldly reef
vocal robin
worldly reef
#

oh my server

#

on*

worldly reef
vocal robin
#

thats the vote webhook path

worldly reef
#

yes

#

do i send the server ip here?

vocal robin
#
http://`ip`:`port`
#

like this

worldly reef
#

so you want me to go to that http link?

#

I dont think i understand what you're trying to say

#

okay so it seems the web hook path is working when i went to the http thing because it gave me a 404

vocal robin
worldly reef
#

without /dblwebhook?

plucky lance
#

It will of course throw a 404 as it’s just listening to POST requests

vocal robin
plucky lance
#

And the path doesn’t physically exist

worldly reef
#

I've done that rn but without the ``

vocal robin
stuck pivot
worldly reef
#

okay, what do i need to do now?

plucky lance
#

Because you didn’t add an authorization

stuck pivot
plucky lance
#

To the header as mentioned in the docs?

vocal robin
stuck pivot
plucky lance
#

Request header

stuck pivot
plucky lance
#

That’s not the way to send the authorization header

#

Appending it to the query string will not work

stuck pivot
vocal robin
#

use npm i @top-gg/sdk

plucky lance
plucky lance
#

getting started is the right page to begin with

worldly reef
#

everything*

vocal robin
worldly reef
#

it didnt do anything

#

using the test button

worldly reef
vocal robin
#

yes

plucky lance
#

Save the changes before hitting test

worldly reef
#

still didnt do anything in the console

plucky lance
#

Then make sure the port you choosed is accessible

worldly reef
#

how do i do that?

plucky lance
#

Depends on the OS

worldly reef
#

uhh i'm not sure what os my host uses

plucky lance
#

Well if you don’t host it on your machine you need to study your hoster’s docs

#

Can’t help you with that

#

The port you specified needs to be opened up for incoming TCP connections

worldly reef
#

So pterodactyl is what the host uses to manage servers

#

and the os is Linux Ubuntu 20.04

stuck pivot
#

:/

plucky lance
#

Hee what?

stuck pivot
plucky lance
#

How do you send the request? Using cURL or XMLHTTP requests?

plucky lance
#

That's a question or an answer? KEKW

stuck pivot
#

Answer xd

plucky lance
#

Do you use plain JS or a library?

stuck pivot
#

A library

plucky lance
#

Which one?

stuck pivot
#

Aoi.js

plucky lance
#

hmm never heard that one

stuck pivot
#

Hm

#

We use $httpRequest

plucky lance
#

That thing is a lib for Discord bots not sending http requests

stuck pivot
#

We can create any djs command in that library

plucky lance
#

Yeah you're confusing me even more... your bot command has nothing to do with a http request

#

Or should a command trigger that request?

stuck pivot
#

Wdym

#

😶

plucky lance
#

I've got no clue what u actually wanna do.

#

You should try to explain what you wanna do exactly and within which environment

worldly reef
#

okay so my ports seem to be open

opal warren
#

How can I let send a message when a user upvotes my Bot?

worldly reef
#

if my console logs 'You need a token for this end point' do i use the bot token from top.gg or the auth token which we make up

#

nvm i fixed the error & yes i realized that was a dumb question

copper sundial
#
client = commands.Bot()

topgg_webhook = topgg.WebhookManager(client).dbl_webhook(route="http://MY_PUBLIC_IP/dbl_webhook")


@client.event
async def on_dbl_vote(data):
    print(data)

I put http://MY_PUBLIC_IP/dbl_webhook to my bot's webhook on top.gg.
It doesn't print anything when I click on Save and then Test

shadow palm
#

recently started getting this error. how can i fix it?

Caught unhandled exception in <Task finished name='Task-12538296' coro=<WebhookManager._run() done, defined at /root/redenv/lib/python3.8/site-packages/topgg/webhook.py:139> exception=OSError(98, "error while attempting to bind on address ('0.0.0.0', 5400): address already in use")>:
Task exception was never retrieved
Traceback (most recent call last):
  File "/root/redenv/lib/python3.8/site-packages/topgg/webhook.py", line 145, in _run
    await self._webserver.start()
  File "/root/redenv/lib/python3.8/site-packages/aiohttp/web_runner.py", line 121, in start
    self._server = await loop.create_server(
  File "uvloop/loop.pyx", line 1740, in create_server
OSError: [Errno 98] error while attempting to bind on address ('0.0.0.0', 5400): address already in use```
#

was working fine uptil a few days ago

shadow palm
copper sundial
shadow palm
#

/dbl_webhook yes

copper sundial
#

ah yeah. Thanks

shadow palm
#

np

copper sundial
#

okay I have now:

import discord
from discord.ext import commands

client = commands.Bot()

client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook(route="/dbl_webhook")
client.topgg_webhook.run(5000)

@client.event
async def on_dbl_vote(data):
    print(data)

And on the top.gg Webhook URL: http://MY_PUBLIC_IP:5000/dbl_webhook. Still doesn't work...

shadow palm
#

dk then. i use cogs

shadow palm
copper sundial
#

do I have to use the top.gg token? It says that I have to use the token to check who has upvoted the bot. But at the webhook example at the docs it hasn't a token in the code

sullen nymph
#

Uhh

#

Are you making sure client is running and all?

copper sundial
#

yes it does

shadow palm
#

hey shivaco

#

umm can ya have a look at my prob too?

sullen nymph
#

Make sure your ports are open and no firewall is blocking incoming requests to port 5000

sullen nymph
shadow palm
#

i made sure to allow the port with sudo ufw allow 5400

sullen nymph
#

Because that's the issue

shadow palm
#

rerunning as in?

copper sundial
copper sundial
shadow palm
#

instantiating it twice?

sullen nymph
#

As in somehow running WebhookManager(...).run(...) more than once

#

or that if you're using dblpy still...

#

Make sure you close the webhook when unloading the cog and run when it's loaded

shadow palm
#

didnt know that lol

#
self.topggpy = topgg.DBLClient(self.bot, self.token, autopost=True, autopost_interval=3600)
self.bot.topgg_webhook = topgg.WebhookManager(self.bot).dbl_webhook("/dbl", "password")
self.bot.topgg_webhook.run(5400)```
this is waht i have
sullen nymph
#

Well it's an HTTP listener running on a port and you can't reuse a port while something is occupying it

shadow palm
#

ohhh

#

so uhhh i do topgg_webhook.close() in cog_unload iirc?

sullen nymph
#

I uh

#

give me a second I don't remember

shadow palm
#

kk np

worldly reef
#

okay so i swapped over to using top-gg/sdk

sullen nymph
#

It does have a .close() method

worldly reef
sullen nymph
#

oh fuck's sake it's a coroutine

worldly reef
#

i use d.js not py lol

shadow palm
worldly reef
#

oh nvm

shadow palm
#

i nest an async task within the cog_unlaod lipbiteMmmmmmm

sullen nymph
#

Ah good, so long as you know what you're doing bahahaha

shadow palm
#

yea i do ||mostly||

sullen nymph
#

Mmm beautiful

shadow palm
#

thanks shivaco

#

helped again bj_pray

sullen nymph
#

I don't remember you or the fact that I helped you ever but

copper sundial
#

@sullen nymph I deactivated my firewall now. It still doesn't work..

sullen nymph
#

happy to help

worldly reef
#

now nothing works, am i supposed to add anything else?

shadow palm
sullen nymph
copper sundial
#

how can I check that? And yeah I host it locally

sullen nymph
#

Your router settings! Google time!

copper sundial
#

okay xD

earnest roost
#

Uhm, can anyone tell me how should i make something like when the bot is upvoted, it will dm that user

worldly reef
#

uh where is the middleware supposed to go, is it supposed to be after the })) ?

worldly reef
# worldly reef uh where is the middleware supposed to go, is it supposed to be after the })) ?
const express = require('express')
const Topgg = require('@top-gg/sdk')

const app = express() // Your express app

const webhook = new Topgg.Webhook('topggauth123') // 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(3000) // your port```
for reference
copper sundial
#

@sullen nymph It seems that the port is forwarded. But I get that error:

Error handling request
Traceback (most recent call last):
  File "C:\Users\andri\AppData\Local\Programs\Python\Python38\lib\site-packages\aiohttp\web_protocol.py", line 314, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp\_http_parser.pyx", line 546, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'invalid HTTP method'"

It's weird because a few seconds before it got sended but now I got this error.

sullen nymph
#

Whatever that is, I think we can ignore it if it works with test requests

copper sundial
#

mh wdym?

#

first I thought it's because of the "https" instead of "http" but it doesn't seem like that.

sullen nymph
#

Oh wait did you set HTTPS instead of HTTP in the URL

copper sundial
#

first yeah. But I updated at that point already. Maybe it was delayed. Or the bot was running twice idk. Now it works fine

#

thanks for your help

sullen nymph
#

Ah neat I can go back to gaming

#

you're welcome

shadow palm
#

ummm shivaco the close method no work bj_pray

sullen nymph
#

Show code I'll be right back

shadow palm
#
def cog_unload(self):
        self.task.cancel()
        async def stop() -> asyncio.Task:
            await self.config.userdata.set(self.data)
            await self.bot.topgg_webhook.close()
        
        super().cog_unload()
        return asyncio.create_task(stop())```
#

this is it

sullen nymph
#

Eugh hold on

#

Either I do something stupid or Python is weird

#

Maybe I do, can't test it right now. Try doing await self.bot.topgg_webhook.webserver.shutdown() along with await self.bot.topgg_webhook.webserver.cleanup()

shadow palm
#

umm k

sullen nymph
#

first before second

shadow palm
#

both right?

sullen nymph
#

Yeah

shadow palm
#

yea wait lemme try

#

yea taht dont work either

#

nvm i think i fixed it-

#

tied the variable to the class instead of the bot and then did webhook.close

#

im trying to vote rn if the vote is recieved then im good to go

sullen nymph
#

Use the test button ezpz

shadow palm
#

yea it worked

#

thanks shivaco

sullen nymph
#

I have no idea wtf just happened

#

but if it works I'll have to take a closer look at what I'm doing in topggpy

shadow palm
#

python acta weird sometimes

surreal hollow
#

why does get_user_vote(user.id) return false even when a user has voted

#

and also, how can i test vote?

sullen nymph
sullen nymph
tardy osprey
#

whenever i vote or test vote for the webhook, i get AttributeError: 'DBLClient' object has no attribute 'dispatch'
i can send the code im using for the webhook if needed

surreal hollow
#

will it work better with a webhook?

#

like will it update instantly with a webhook

sullen nymph
#

it would be up to you to either store them or do whatever

tardy osprey
#
dblpy = topgg.DBLClient(self.bot, "DBL TOKEN")
topgg_webhook = topgg.WebhookManager(dblpy).dbl_webhook(route="/dbl_webhook")
topgg_webhook.run(5000)

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.bot.dispatch("dbl_test", data)
    print(f"Received a vote:\n{data}")

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}")```
this is all the code related to dbl things
sullen nymph
#

uhhhhh

#

why the self

#

where event deco

tardy osprey
#

the self is because its running on red

#

so this is a cog rather than running alone

sullen nymph
#

oh God I see

#

WebhookManager constructor takes a discord.py Client instance, not DBLClient

tardy osprey
#

oh

tardy osprey
#

when i replacedblpy with self.bot for WebhookManager im still getting the exact same error, tbh im not 100% sure that bot is the same as client for red, but if it isnt shouldn't i be getting an attribute error but for something other than DBLClient if that was the issue?

#

yeah even just using discord.Client() directly still gives the same error

surreal hollow
tardy osprey
#

under Webhook URL

sullen nymph
#

This is interesting

#

What does self.bot return here?

surreal hollow
#

cause it changes right

#

if my router restarts/

sullen nymph
#

Yeah, you'll have to somehow get a static hostname to use on Top.gg

tardy osprey
sullen nymph
#

the former

tardy osprey
#

<redbot.core.bot.Red object at 0x7f74f07071f0> when i print it

sullen nymph
#

wtf

tardy osprey
#

i also get this with just discord.Client(): <discord.client.Client object at 0x7f74c5dee3d0>
im pretty sure this is what im supposed to be using inside of WebhookManager but i still get the same AttributeError: 'DBLClient' object has no attribute 'dispatch'

sullen nymph
#

Do you have the full traceback?

tardy osprey
# sullen nymph Do you have the full traceback?
│ /home/Fear/.local/lib/python3.8/site-packages/aiohttp/web_protocol.py:422 in _handle_request                         │
│ ❱ 422                 resp = await self._request_handler(request)                                                    │
│ /home/Fear/.local/lib/python3.8/site-packages/aiohttp/web_app.py:499 in _handle                                      │
│ ❱ 499             resp = await handler(request)                                                                      │
│ /home/Fear/TerminalGlobal/cogs/Downloader/lib/topgg/webhook.py:130 in _bot_vote_handler                              │
│ ❱ 130             self.bot.dispatch("dbl_vote", data)                                                                │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'DBLClient' object has no attribute 'dispatch'```
#

formatting is very weird, idk why it was changed to be like this since... who cares how errors look in console just as long as they give info
i can take a screenshot of the traceback if the formatting is off for you

sullen nymph
#

I'll take a closer look tomorrow

tardy osprey
#

alright, thanks

ornate fox
#

What is top.gg api and do i have to use it since my bot is approved on top.gg

ornate fox
#

and how do i do it

ornate fox
#

Why does it show me this when i open webhook

half compass
#

The page

ornate fox
half compass
meager wigeon
#

Hey everyone,

I currently setup the server count for my Discord Bot on the Top.gg website and it's showing the invalid Server Count of my bot, how could I fix this?

#

@dense basalt

hushed reef
#

please don't ping random staff 😦

#

It depends on what API wrapper/library you're using

meager wigeon
#

1, I didn't ping "random staff, the person who I pinged was online at the time."

2, Your able to ping 1 staff member ( that I know of. )

hushed reef
#

which API wrapper/library are you using?

meager wigeon
#

js

hushed reef
#

are you using autoposting or manually sending information?

meager wigeon
#

auto posting.