#topgg-api

1 messages · Page 141 of 1

sullen nymph
#

You don't see any port forwarding tabs?

vestal jackal
sullen nymph
#

Does it not have a name prepended to the local IP?

vestal jackal
sullen nymph
vestal jackal
sullen nymph
#

Probably

vestal jackal
#

I should be connected now.

sullen nymph
#

Does it work?

short leaf
#

How can I make the background of my bot page animated in top.gg

rain heart
#

-api

abstract mothBOT
#

This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.

If you need help with development about your bot or development in general, feel free to use #development.

pseudo light
#

-help

vale arrow
pseudo light
#

How to check if someone voted for my bot on top.gg ?

rain heart
pseudo light
#

thank you

#

Oooooo thanks a lot !!!

#

I'm looking for this... i don't know how long it was but thanks

#

if i made mistakes, sorry I'm french

jolly veldt
#

i cant get my bots api-key

rain heart
#

read pinned messages

jolly veldt
rain heart
#

there is

jolly veldt
rain heart
#

Then you don't seem to have proper access to that bot

#

do you own it?

#

it should say this

jolly veldt
#

to the web devsbut im the owner??

#

its not the side bar

rain heart
#

which bot are you referring to

jolly veldt
#

my bot, shadow bot

rain heart
#

ID?

jolly veldt
#

765578525818093608

#

@solemn quest

#

anyways i got the api key so

rain heart
#

That bot is not approved

#

that's why it doesn't show up

jolly veldt
#

o

#

then how to i have an api key??

rain heart
#

you need to wait till it is approved

jolly veldt
#

ok.

full ruin
#

How do I get the authorization code for my webhook? I think I asked in the wrong channel before...

#

got this when trying to install the top.gg sdk

npm ERR! code ENOLOCAL
npm ERR! Could not install from "@top-gg/sdk" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/container/.npm/_logs/2021-03-17T14_31_42_322Z-debug.log

I'm running through Plox.Host so I have to install from a package.json

#

It doesn't let me use console commands to install directly basically.

#

nvm i figured out what I did wrong

jaunty steppe
#

if v1 is being worked on, will there still be a way to access v0 until EOL?

rain heart
#

definitely

#

as far as i know

alpine stump
#

how can i setup the webhooks system?

plucky lance
#

Just google how to setup a webhook service regarding the language u wanna use, e.g. PHP, JS etc.

#

it always depends on how u wanna do it

restive otter
#

if i post to dbl using autoposter, do i need to configure a webhook?

plucky lance
#

No.

short leaf
#

I need codes to make a long explanation in top.gg. Do you have them?

novel shell
#

how do i get sb is voted my bot? without the library? i tried this but dont work:

response = requests.get("https://top.gg/api/bot/mybotid/check", params={"userId":myBotId}, headers={"Authorization":myBotToken})```
rain heart
#

-api @terse patrol

abstract mothBOT
#

@terse patrol

This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.

If you need help with development about your bot or development in general, feel free to use #development.

wild lanternBOT
#

Pong!

livid tapir
#

I cant figure out how to get the Activation verification for webhook voting for bots

#

Can I have help?

sullen nymph
#

In the headers you send the bot's top.gg token

#

The rest seems fine

cold root
#

ye... I got node. and then .js

#

I just felt like putting a dot there

spark mulch
#

How can I get data on server votes?

#

ping on reply if possible

#

<3

spark mulch
#

k thanks

paper locust
#

How do you get server count when sharding? Nvm found how

cold root
#

guys um..I get that error, Pls read stuff arrounf that message to studie the code and not ask me for what I have..

heady cradle
#

what do you pass to the api constructor

plucky lance
#

Make sure the client u pass is a valid...

discord.js or eris client (or djs ShardingManager)

restive otter
#

the webhook is not working

#

how to use webhook properly

#

so it sends votes in a channel

rain heart
#

"Is not working" isn't very descriptive, explain what doesn't work

restive otter
#

is there an api documentation for this?

#

cause i don't really need all the things provided in the top.gg client

#

so im writting a handler

#

i just need it to get the vote info

#

and maybe the stats

#

hmm nvm i think i did the request wrong

#
const url = new URL(`https://top.gg/api/${endpoint}`)
if(userId) url.search = new URLSearchParams({ userId })
#

cause this is what i did

rain heart
restive otter
#

thanks

#

this seems to be more updated ig

restive otter
#

How come I'm getting top.gg API token not provided on post_guild_count when i already authenticated the dbl client with the token?

restive otter
brittle spoke
#

oh wait

#

u have the token

#

h

restive otter
#
  • on_dbl_vote does not seem to being called at all
#

Dont know if i should ping a mod/dev

brittle spoke
#

theres a few python? devs here anyway that could help

restive otter
#

Yes that is python but its more of a library issue to me.

restive otter
rain heart
#

That's where the new docs are

restive otter
# rain heart That's where the new docs are

https://docs.top.gg/libraries/python/ links me to https://dblpy.readthedocs.io/en/latest/api.html which contains https://dblpy.readthedocs.io/en/latest/api.html#dbl.on_dbl_vote where theres an invalid link for data

rain heart
#

Wasn't changed yet

restive otter
#

i guess youll forward to devs then

sullen nymph
#

No need to yell at me, no worries

#

I just need to push some changes and update the docs

restive otter
#

Who's yelling weirdo

sullen nymph
#

YOU'RE YELLING AT ME IN NON-CAPS BRO

restive otter
#

OK NOW IM YELLING AT YOU DEAL WITH IT BRO

#

BESIDES YOU WRITE ALL THE CODE IN ONE FILE

#

!!

sullen nymph
#

OK OK I'LL UPDATE THE DOCS SOON SHEESH

restive otter
#

AND YOUR CODING STYLE

sullen nymph
#

IT'S READABLE

restive otter
#

NO ITS NOT

#

ITS BAD PRACTICE

#

USED IN LATE 90s ONLY

sullen nymph
#

OK DM ME WITH YOUR SUGGESTIONS I'M ALWAYS UP TO HEAR FEEDBACK AND THAT'S EXACTLY WHAT I SEEK ALL THE TIME HERE

restive otter
#

how do you get the vote expiry date??

sullen nymph
#

Use webhooks, count 12 hours from each vote

#

The API does not send vote expiry date

restive otter
#

oh cause im creating a command

#

got it

#

hmm i have an idea

sullen nymph
#

You can just send a request to top.gg API and cache the result for around 1-10 minutes though

restive otter
#

i have an idea anyway

#

ill use redis

#

and update redis with the webhook

#

and ill get my vote status from redis

sullen nymph
#

Sounds a bit extra to me but I'm not stopping you

restive otter
#

im any gonna add redis

#

so i could techinally do that

sullen nymph
restive otter
#

uhh how agn do i recieve data for when someone votes my bot/

#

?

rain heart
#

webhooks

restive otter
#

oooooooooo

#

website updated?

#

ps thanks @rain heart ❤️

#

hey uhhhhh

#

whats my webhook_path?

rain heart
#

http://serverip:port/thispart

restive otter
#
dblpy = dbl.DBLClient(client, gg_token, webhook_path='myip?', webhook_auth='password', webhook_port=5000, autopost=True)
#

ahh ic

#

@rain heart

#

what exactly is meant to happen

#

when i click on test on the dashboard?

restive otter
#

and in my portal i added this

#

but when i press test, absolutely nothing happens

plucky lance
#

If an old error with the website still persists press save in the first place and test after.

civic cradle
#

hi baes

restive otter
#

can some1 help me?

stiff night
#

and u can write it by yourself with flask

restive otter
#

@stiff night ip is is public

plucky lance
#

Make sure to let your webserver pass your firewall for the port you choosed.

#

Protocol: TCP

#

Without that incoming connections for the port may be dropped by default

slow fiber
#

Hello; does the API allow multiple connections to the same auth token?

plucky lance
#

You’re requesting things only not opening socket connections. As long as you don’t reach the rate limits you can do as much requests as you want.

slow fiber
#

Ah okay, what's the rate limit btw?

plucky lance
#

Take at look at the docs

sullen nymph
slow fiber
#

Alright, thanks!

wraith pine
sullen nymph
#

Correct

#

if they have voted in the past 12 hours*

wraith pine
#

Thanks 🙂

toxic thorn
#

did anything about the voting webhook change or any ideas how can this be happening?

#

for some reason people who vote once get the voting reward like 10 times until the app crashes with this erorr

rain heart
toxic thorn
#

ehm, so... how do I make it stop 😂
I just want people to be able to vote for one time reward while not crashing the whole bot with it and the old code doesn't do the job anymore ig?

rain heart
#

respond to the webhook request with a 200

toxic thorn
civic cradle
#

heyo

rain heart
#

-api

abstract mothBOT
#

This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.

If you need help with development about your bot or development in general, feel free to use #development.

rain heart
#

@hearty lintel since you maintain the js library, see #site-status BongoCat

hearty lintel
#

ye already implemented

rain heart
#

poggers

#

@shadow acorn see above

shadow acorn
hearty lintel
shadow acorn
#

3.0.6

hearty lintel
#

yeah update

#

it was patched in 3.0.8

#

current v is 3.0.9

sullen nymph
#

What's this about?

hearty lintel
#

the 200 response causing loops was only implemented recently causing multiple requests for the same vote on older versions

sullen nymph
#

Ah

thorny dagger
#

error: 'Required parameter server_count or shards missing'

#

I get this but I alredy put server_count

#

let me show you

rain heart
thorny dagger
#
        method: 'post',
        server_count: client.guilds.cache.size,
        headers: { "Authorization": "my token" }

    })```
rain heart
#

that isn't valid json you're trying to post

thorny dagger
rain heart
#

What you're sending is not json

thorny dagger
#

is json

#

xd

rain heart
#

did you stringify it like in the docs?

thorny dagger
#

Thanks

#

let me see if now it works

#

same

#

server count or shard required parameter missing

#
 
fetch('https://top.gg/api//bots/myid/stats', {
        method: 'post',
        server_count: JSON.stringify(servers),
        headers: { "Authorization": "token" }

    })```
rain heart
#

not that

#

body: JSON.stringify(text)

#

text being "server_count": servers

thorny dagger
#

thanks for your time

#

SyntaxError: missing ) after argument list
body: JSON.stringify("server_count": servers),

#

I don't see any problem on that

rain heart
#

just do the basic json format then:

{
"key1": value,
}
thorny dagger
#

bruh

#

it can't be that hard

plucky lance
#
Fetch("https://top.gg/api/bots/" + <bot_id> + "/stats", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": <dbl_token> }, body: JSON.stringify({ "server_count": <guild_count> }) })
#

it can't be that hard

yeah it isn't

#

reading the docs carefully will tell you to specify the content-type

thorny dagger
#

server count or shards required

#

;-;

plucky lance
#

do you even send the correct number of your servers?

#

is your bot id correct?

thorny dagger
plucky lance
#

why creating an extra var?

thorny dagger
plucky lance
#
fetch("https://top.gg/api/bots/xxx/stats", {
        method:"POST",
        headers: { "Content-Type": "application/json", "Authorization": "token" }, 
        body: JSON.stringify({ "server_count": client.guilds.cache.size })
    });
#

server count or shards required

#

is this the response you got?

#

which http code?

thorny dagger
plucky lance
#

Well did a manual test real quick.
The endpoint works as it should.

#

Did you post the stats with shards before?

thorny dagger
plucky lance
#

Which lib do you use?
fetch or node-fetch?

thorny dagger
#

node-fetch

plucky lance
#

As I said the endpoint is working fine for me.
I’m not sure what you’re doing wrong.
Make sure the bot id is correct but I guess it would cause a different error if not anyway.

#

You’re practically not doing anything wrong.

plucky lance
#

Try to send the server count as array

#

Hold on!

#

Did you probably use the guilds.cache.size before the client got initialized - before he’s ready?

#

Posting 0 shouldn’t work

#

console.log your guild cache size

thorny dagger
#

it works fine

plucky lance
#

Is it > than 0?
Did you try to send it as array?

thorny dagger
#

when I log it I get 64

plucky lance
#

Alright and question 2?

thorny dagger
#

no**

plucky lance
#

Oof...

#

{"server_count": [64]}

#

Send this manually without using the cache size var

#

Exactly like wrote

thorny dagger
#

I mean

#

if that's possible, anyone could send like 20000000 servers

plucky lance
#

Correct

thorny dagger
#

so I think that wouldn't work

plucky lance
#

And what would be the benefit?

thorny dagger
#

Now I got the fucking error

plucky lance
#

Discord is showing you the correct count anyways.

thorny dagger
#

0 servers

thorny dagger
#

So we can say its the client.guild... problem

plucky lance
#

Nope it’s not

#

{"server_count": 99}

#

Send this to see the result

#

Won’t take long until rate limitation anyway I guess

#

If you’ve logged the cache size and it really shows 64 it can’t be the issue

thorny dagger
#

I console.log the client.guilds.cache.size and I got 0

plucky lance
#

Aye there we go

#

Found your issue

#

Probably because you used it if the client isn’t even ready

thorny dagger
plucky lance
#

Where do you call your fetch function?

#

Told you already what could be issue and you told me you know what you’re doing

thorny dagger
#

also incredible while we trying to solve this, the bot joined 11 servers ^^

plucky lance
#

Alright now answer the question please

#

I’m driving and won’t be here forever

thorny dagger
thorny dagger
plucky lance
#

Where do you call your fetch function?

thorny dagger
#

I was using it on index.js

#

now I put it on ready event

plucky lance
#

You used it before/outside the ready event hmm?

thorny dagger
#

lets see if it works

thorny dagger
plucky lance
#

That won’t work since there’s no cached data before the ready event sends it

#

Use it in the ready event like I wrote and it will work

thorny dagger
#

The bot is starting

plucky lance
#

You will later need to create an interval to repeatedly sending the requests to topgg within the rate limitation

#

For example every 30 min

thorny dagger
#

okk

#

thanks for your time ^^

plucky lance
#

Working now since the cache is loaded?

thorny dagger
plucky lance
#

Wow that’s taking long

thorny dagger
#

it takes a little bit

plucky lance
#

Don’t forget to refresh the topgg site using the “refresh data” button since the site is cached in your browser

thorny dagger
#

how canI be that dumb bro

plucky lance
#

Happens

thorny dagger
#

Thanks

#

Bro you need to be staff in here just for your patiente

plucky lance
#

Alright now consider to create an interval since the ready event being fired only if the bot starts

#

setInterval(() => { fetch... }, 1800 * 1000);

plucky lance
#

Ok

thorny dagger
#

15mins?

plucky lance
#

Sure but not needed I guess

thorny dagger
#

1800 * 1000); I directly put the ms

plucky lance
#

Yeah anybody does how he likes to smirk

thorny dagger
plucky lance
#

Thanks, you too

civic cradle
#

u sleeping ppl

plucky lance
civic cradle
#

ohh sorry

outer fractal
#

I think you have a problem
I voted for my bot
Instead of the vote message coming once, it comes to me 10 times

plucky lance
restive otter
#

Dm me guys if you want to see my nudes for free

slow shuttle
#

proceeds to receive 0 dms

stone coyote
#

i keep getting this after providing a token

#

UnhandledPromiseRejectionWarning: Top.GG API Error: 401 Unauthorized (You need a token for this endpoint)

plucky lance
#

Did you provide your topgg API token?

stone coyote
#

yes

plucky lance
#

Do you use the autoposter lib?

stone coyote
#

no

#

i use

plucky lance
#

Or do you just send a request to the api endpoint?

#

Nvm

stone coyote
#

@top-gg/sdk

#

i just do api.hasVoted(message.author.id) and then i get error

plucky lance
#

Show the line you’re providing the header

#

Hmm don’t know that lib, maybe it’s outdated idk

stone coyote
#
const Topgg = require(`@top-gg/sdk`)
const api = new Topgg.Api('my API key')```
plucky lance
#

U got a link?

#

Ah ok

stone coyote
#

no

stone coyote
plucky lance
#

There aren’t much possibilities causing this.
Maybe your token is wrong for real due a typo for example or the header being sent is wrong.

bronze axle
#

why are webhooks still broken?

#

its been like 4 weeks

severe viper
#

idk, maybe coding a website and a entire api isnt as easy as it looks

vital wolf
#

i need help

#

my code doesnt work

#
import dbl
import discord
from discord.ext import commands, tasks

class TopGG(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.token = 'token here'
        self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password here', webhook_port=5000)

    @tasks.loop(minutes=30.0)
    async def update_stats(self):
        print('Attempting to post server count')
        try:
            await self.dblpy.post_guild_count()
            print('Posted server count ({})'.format(self.dblpy.guild_count()))

        except Exception as e:
            print('Failed to post server count\n{}: {}'.format(type(e).__name__, e))

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        channel = self.bot.get_channel(783598824685436970)
        channel.send('Received an upvote')
        print(data)

def setup(bot):
    bot.add_cog(TopGG(bot))
    print("TopGG Loaded!")```
vital wolf
#

took this code from the docs

#

changed it a little

#

and it doesnt work

bronze axle
#

it being easy isn't the case, this problem has been going on for weeks now. top.gg is too big and has way too much of a following to be pulling stuff like this. I saw on #site-status i believe they are working on a fix, i just feel like it has been way to long

vital wolf
#

?

bronze axle
vital wolf
#

oh

#

ok

restive otter
vital wolf
#

yea

#

but the part i want is the on_dbl_vote

#

i just kept the update_stats there

restive otter
#

Have you entered the correct webhook URL on the site?

#

There are many possibilities why it doesn't work though, idk if it's on DBL or on you. But I just tested it and it worked (though it took a few seconds)

vital wolf
#

oh

#

what webhook url do i enter

#

just create a new one on discord?

#

i mean

#

i just want to print the result

#

do i need a webhook url

restive otter
#

the format would be http://{ip}:{port}{path}. Which in your case it's http://{ip}:5000/dblwebhook

#

Make sure port 5000 is forwarded and you put password here on the site. Because if the auth don't match, it will never get dispatched.

median trout
#

webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000

#

what to fill here?????????

restive otter
#

Those fields are fully up to you

median trout
#

and webhook_auth?

#

and webhook_port?

#

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

restive otter
#

webhook_path is the endpoint the vote handler will be in which top.gg will make post requests to. The webhook_auth will be present in the header so that you can check whether or not it's from top.gg. And the port is just the port where your webserver will be running on.

#

The auth checking is done internally, so what you're supposed to do is just put the same auth on both the site and your code.

median trout
restive otter
#

As I've mentioned, it's fully up to you

median trout
restive otter
#

If you have this webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000, then what's on the site should be

restive otter
#

api bana pava ver

clear willow
#

i need help

#

If you have this

rain heart
#

just ask

proper atlas
#

okay im about to pull my hair out, i got the webhook all setup, i got everything the same code as the npm page, and i confirmed that the page is working, even double checked that the token was right, but i will not get sent a stupid test thing, and i have no idea what to do

#

and also how do i send back a success message? because the new api says it needs that

rain heart
#

have you saved the webhook before testing? peek

#

http://ip:port/path

proper atlas
#

yep

#

heres my code incase im a dumbass

#

this happens when i open in browser, so its for sure allowed through the firewall

#

(this is on a vps btw)

rain heart
#

you need to make a post request

proper atlas
#

isnt that what the test button on the site is meant to do

rain heart
#

Post is what the test button does to your webhook, it posts data

#

Get is when you're not posting data, but just getting it

proper atlas
#

mhmm im not getting anything as far as i can tell

#

nothing in the console at all

rain heart
#

Could you DM me the url if you're comfortable with it, I'll see if i can make a test request from my end

proper atlas
#

👍

rain heart
#

ok sec

proper atlas
#

aight

rain heart
#

Authorization code?

proper atlas
#

i donno how to set one cause the docs didnt say :/

rain heart
#

That's the main reason why it doesn't work when

#

because it isn't authorized

proper atlas
#

a h

#

how do i set it on my end?

rain heart
#

const webhook = new Topgg.Webhook(config.db0Token) // add your top.gg webhook authorization (not bot token)

proper atlas
rain heart
#

config.db0Token replace it with whatever you want

#

use WebhookPass123 for example now

proper atlas
#

hmm aight, i swear i tried that but im probably stupid

#

are there any characters i cant use?

rain heart
#

Not really

#

pretty much everything you can use in a normal string

proper atlas
#

aight

#

ill wait like, a min to see if it goes through

rain heart
#

What have you set the authorization to now?

#

so i can test it on my end

proper atlas
#

dmed

#

YO WAIT

#

oh my godddd

#

it workkksssss

#

tysm!

vital wolf
#

do i need webhook

#

all i want is to get notified when someone votes

rain heart
proper atlas
#

x3 i tested it again on the site

#

oh, while im here how do i send back the 200 code?

#

oop nvm

#

it auto does it

#

thats all i needed then, thanks again!

formal sparrow
#

For some reason, it seems like my bot's webhook is getting POST request many times for 1 vote, is this a problem with top.gg? Cuz I haven't changed anything in my code and it randomly started receiving many requests for a single vote, happens for every votes

rain heart
formal sparrow
#

Didn't read that, sorry for not asking before reading that and thanks for letting me know about it

restive otter
#

I'm currently trying to setup the api thing for my bot, but it doesn't seem to be working...

#

I've tried this and it doesn't update the server count widget

#

It's in Java, any help would be appreciated

rain heart
#

does the server count update on the site?

#

yeah i see it doesn't either

#

any errors?

restive otter
#

no, everything works as intended, except for the api...

#

also my webhook doesn't give any output

rain heart
restive otter
#

yes, ik

#

oh now it works

rain heart
#

probably just forgot to recompile it

restive otter
#

I put it into my ReadyEvent class and restarted the instance, now it works 🙂

#

But the webhook still doesn't give any output 😦

vital wolf
#

which should i pick

#

creating a webhook

barren kestrel
#

I'm making a leaderboard with a db showing all the votes a user has.

How would I say, the second a user votes, (do my db stuff)?

I can do the db stuff but idk how to say if a user votes, then blah blah blah. I have a votecheck command but I don't want them to run that command before receiving their points.

barren kestrel
vital wolf
#

heroku

#

currently looking for an affordable vps

barren kestrel
#

I mean you could

#

But I used repl

#

its free

vital wolf
#

i dont want to host on repl

barren kestrel
#

a webhook?

#

ok

vital wolf
#

it asks me to pick at least one

barren kestrel
#

idk

#

never used heroku

#

i self host

rain heart
#

-api

abstract mothBOT
#

This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.

If you need help with development about your bot or development in general, feel free to use #development.

barren kestrel
#

Mb

barren kestrel
rain heart
#

Not really

barren kestrel
#

Like with a webhook, can we do smth

#

Like there is the code in the webhook part

#

where once the user votes,

#

it sends the message

#

So how can I combine that

#
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
  // req.vote is your vote object e.g
  console.log(req.vote.user) // 221221226561929217
  dwebhook.send(`<@${req.vote.user}> has voted for News Agent on top.gg!`)
});```
#

This part

#

Changed to this part:

(req, res => {
      // req.vote is your vote object e.g
      console.log(req.vote.user) // 221221226561929217
    });```
vital wolf
#

do i need a webhook

#

for on_dbl_vote

restive otter
#

hi there

#

i couldnt make a webhook

#

its not working

#

i made it

#

but not working

#

i made eveything correct i guess

sullen nymph
vital wolf
#

ok

#

what do i do

#

i use heroku

restive otter
#

@sullen nymph i have it setted up but nope. doesnt send anything

#

i used webhooks before

sullen nymph
#

Show your code

restive otter
#

hmm just copied from the site lmao

#

self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='Test123', webhook_port=5000)

sullen nymph
vital wolf
#

alright

#

also

#

do i add /dblwebhook to the link

sullen nymph
#

Max, was there any firewall that prevented you from receiving incoming requests on port 5000?

vital wolf
#

or do i just keep it

sullen nymph
#

If you change webhook_path to anything else, yes

vital wolf
#

i didnt set it

vital wolf
#

wait

sullen nymph
#

Then you use the port 8080 to run the webhook and simply enter the repl.co URL on top.gg

vital wolf
#

i didnt set webhook_port

sullen nymph
#

There you go

vital wolf
#

so my link should be

#

?

sullen nymph
vital wolf
#

i use heroku

#

no ip

sullen nymph
#

Don't set the port in the URL, Max

restive otter
#

/:port?

sullen nymph
#

You only run the webhook on 8080 and let repl.it reverse proxy them from 443 to 8080

barren kestrel
sullen nymph
#

aka

#

what https defaults to

sullen nymph
restive otter
restive otter
vital wolf
#

i dont get this

sullen nymph
#

Get your Heroku app's URL and use it

vital wolf
#

without any port or anything?

#

i set that up

sullen nymph
#

without, yes

vital wolf
#

on the webhooks part

restive otter
#

this then?

sullen nymph
#

Correct, Max

restive otter
#

where do i put it

sullen nymph
#

Though I was not talking to you just now, but you got it

#

On the bot's Edit page in the Webhooks section

vital wolf
#

?

sullen nymph
#

In the Webhook URL field

#

Yes Kero

restive otter
#

webhook url

#

done

sullen nymph
#

Deal with the Authorization field too and you should be good

#

P.S. it's a password you create

restive otter
vital wolf
#

how do i make sure that it works

restive otter
#

port 8080 right?

sullen nymph
#

You don't specifically "combine" anything. You set the webhook in a scope where you have access to your client object

sullen nymph
sullen nymph
barren kestrel
sullen nymph
#

Make the webhook send a request to your device then

barren kestrel
#

How?

sullen nymph
#

Be it via websockets or HTTP requests

restive otter
#

but i see it on the console

barren kestrel
#

Idk how to do that tho

sullen nymph
#

Google ✨

vital wolf
restive otter
#

yes

#

same

#

but i saw 404 on the console too

barren kestrel
#

Max ur using repl?

#

Let me help you

restive otter
#

dms

vital wolf
#

how is this an api when i have to setup a webhook for it lol

sullen nymph
#

Well less headache for me with you 3 constantly pinging me

barren kestrel
#
const express = require('express')
const app = express() // Your express app
const webhook = new Topgg.Webhook(config.topggwebhookauth)
const dwebhook = new Discord.WebhookClient("id of webhook", "random stuff of webhook")

app.post('/dblwebhook', webhook.middleware(), (req, res) => {
  // req.vote is your vote object e.g
  console.log(req.vote.user) // 221221226561929217
  dwebhook.send(`<@${req.vote.user}> has voted for [BOT NAME] on top.gg!`)
});

app.listen(3000)```
sullen nymph
barren kestrel
#

So basically

restive otter
#

yes

barren kestrel
#

Then all you need to do

restive otter
barren kestrel
#

oh

#

xD

#

one sec

sullen nymph
#

Cool assumptions

vital wolf
#

ofc not

barren kestrel
#

Is this on the same code aas youe discord bot?

#

as*

#

If not then it matters

vital wolf
#

you told me to use heroku url

barren kestrel
#

Like I habve webhook on one repl, and my bot on another

vital wolf
#

i was trying to setup a webhook

#

from heroku

restive otter
#
import discord
from discord.ext import commands, tasks

import asyncio
import logging


class TopGG(commands.Cog):
    """Handles interactions with the top.gg API"""

    def __init__(self, bot):
        self.bot = bot
        self.token = 'dbl_token' # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='pass', webhook_port=8080)

    # The decorator below will work only on discord.py 1.1.0+
    # In case your discord.py version is below that, you can use self.bot.loop.create_task(self.update_stats())

    @tasks.loop(minutes=30.0)
    async def update_stats(self):
        """This function runs every 30 minutes to automatically update your server count"""
        logger.info('Attempting to post server count')
        try:
            await self.dblpy.post_guild_count()
            logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
        except Exception as e:
            logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))

        # if you are not using the tasks extension, put the line below

        await asyncio.sleep(1800)

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        logger.info('Received an upvote')
        print(data)

def setup(bot):
    global logger
    logger = logging.getLogger('bot')
    bot.add_cog(TopGG(bot))
vital wolf
#

this is same

#

as my code

barren kestrel
#

Ok dms

sullen nymph
#

Did you connect that as a cog to your bot, Max

barren kestrel
#

max

vital wolf
#

except i use print

sullen nymph
#

elite are you sure you're qualified to provide assistance with this

sullen nymph
#

To be specific, load as an extension

vital wolf
#

ofc

#

the problem is with the webhook

#

which honestly

#

i still dont get why its required

sullen nymph
#

What do you mean by "required" exactly

vital wolf
#

why do i need to setup a webhook

#

just to get votes

sullen nymph
#

You can use the API to receive recent votes but using webhooks is optimal

vital wolf
#

i just want on_dbl_vote

#

what do i need

sullen nymph
#

Make sure you are loading the cog, probably with a print in the cog's init method

vital wolf
#

so it works

#

without a webhook?

sullen nymph
#

How is it gonna be called without a webhook, using magic?

vital wolf
#

ok

#

what do i do for webhook

#

thats what im asking

#

i was trying to create a heroku webhook

sullen nymph
#

Initialize DBLClient with webhook args

vital wolf
#

and asked what i should pick

sullen nymph
#

That's pretty much the bare minimum

vital wolf
#

what url

#

do

#

i

#

use

sullen nymph
#

I thought you used it prior to this point

vital wolf
#

no

#

i was trying to set one up

#

because i dont have a vps

#

i use heroku

#

heroku doesnt have ip

#

so i couldn't figure out what to do

sullen nymph
#

Heroku has a URL which you asked me about

vital wolf
#

yea

#

it didnt work

#

cant open it

#

let me try it with code tho

sullen nymph
vital wolf
#

yes

#

i asked you

#

how do i check it works

#

you said

#

visit the url

#

why did it get deleted

sullen nymph
#

Don't use dots

vital wolf
#

oh

sullen nymph
#

Just use - or ^

vital wolf
#

ok

sullen nymph
#

dots get automatically deleted

vital wolf
#

oh wait i made a typo

#

now i get this

#

2021-03-19T13:52:40.588524+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/dblwebhook" host=appname.herokuapp.com request_id=4130beea-2f6a-4e77-afc1-1c574da024b3 fwd="159.203.105.187" dyno= connect= service= status=503 bytes= protocol=https

#

@sullen nymph

#

does this mean its working?

rain heart
#

there's no web processes running on that path

vital wolf
#

what?

#

what should i do

restive otter
#

if your bot is discord.js

vital wolf
#

py

barren kestrel
#

@vital wolf i cna still do

vital wolf
#

ok

#

i just need the webhook

barren kestrel
#

dms

#

pok

#

ok

restive otter
#

hmm anyone herE?

#

i dont know how to make voting required command

restive otter
#

..

little matrix
#

hello, whenever a guy votes, i receive the same webhook 10 times, so when someone votes onec, he gets total 10 votes.. why?

rain heart
restive otter
rain heart
#

send a 2xx to the webhook request

#

can't help with that sorry

restive otter
lament cairn
#

how can i test vote to check if the vote checker thing is working

lament cairn
#

nvm i got it

pliant valve
#

where can i get my bot token in topgg?

jaunty plank
#

Hit the Edit Button on your bot page
Press the Webhooks button on the sidebar
Hit Show Token
Copy

pliant valve
#

i wanna post my bot stats

#

i click on the edit button but it shows this to me

jaunty plank
#

log out and log back in

pliant valve
#

uh

#

that still appears

jaunty plank
#

did you transfer the bot to a team, or transfer ownership?

dire zephyr
#

Hi, I'm using express.js to handle post requests and when I sendStatus(200) to make sure that top.gg doesn't spam me with 9 more requests it skips the whole function body... Basically if i put console.log('some text') at the first line and then sendStatus under it, it doesn't log anything except 200 OK in the console, any idea why?

pliant valve
jaunty plank
#

teams are broken right now on top.gg

pliant valve
#

i think not

#

im as a creator

rain heart
#

most likely related to the team issue too

pliant valve
#

ah ty anyways

jaunty plank
past otter
#
from discord.ext import commands
import dbl
from funct import func




class TopGG(commands.Cog):

    def __init__(self, bot):
        self.bot = bot
        self.token = 'proper token is here'  # set this to your DBL token
        self.dblpy = self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='kurwa', webhook_port=5000)  # Autopost will post your guild count every 30 minutes

    @commands.Cog.listener()
    async def on_guild_post(self):
        print("Server count posted successfully")

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print("Vote recived")

    @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 upvote: {data}")


def setup(bot):
    bot.add_cog(TopGG(bot))

can someone tell me if this is right or am i dumb?

rain heart
#

Remove the /

#

From before :5000

past otter
#

i tried with and without / and neither is working

rain heart
#

Dm me the url, i'll tell you if it is correct

#

Yeah that should work, do you not get anything when you make a request?

past otter
#

i mean bot console shows nothing, should i look somewhere else?

jaunty plank
#

where are you hosting? home, a vps, dedi machine?

restive otter
#

Does the API work if I use localhost

#

Or do I need a port forwarded ip

jaunty plank
#

the api doesnt care, webhooks will need portforwarding and ip yes.

restive otter
#

😭 okie 🙏

past otter
#

i'm testing it on my pc

jaunty plank
#

youll need to port forward then

#

and use your public ip

restive otter
#

The issue is my dad doesn’t want me to port forward

#

I have my own server and everything but my dad doesn’t like the idea of anyone of having potential access to it

dire zephyr
restive otter
#

Yes

dire zephyr
#

Then setup localhost express server and make it public using ngrok

restive otter
#

Ngrok? I’ll google it

past otter
#

quite similar for me, i just dont have acces to router, although i can try to use vps, what should i do then?

restive otter
#

Looking at it Ngrok looks decent but how can I trust it?

dire zephyr
#

Everything has it's vulnerabilities

restive otter
#

Fair point, is it open sourced

rain heart
#

if you don't want to use ngrok, consider getting a proper vps

dire zephyr
#

Yeah that'd be best

past otter
restive otter
#

I bought a server because it’s cheaper in the long A good VPS can be very expensive and with Covid I can’t find a job

#

But I’ll try ngrok

dire zephyr
#

I use VPS that's about 2$/month for my discord bot, it's the best option if you don't want to port forward or use tools like ngrok

restive otter
#

Yeah, I would use a vps but my dad gave my money and I spend it too quick

#

But thanks I’ll try it

jaunty plank
#

If your father is okay with using his credit/debit card, google and amazon have free trials for a year for some of their hardware.
he can have full control over the money/account part, while giving you full access to the servers.

restive otter
#

The issue with that is I have my own debit card and he only uses it on things like my anime subscription while he knows I wish to be a programmer he doesn’t like the idea of him paying for one

#

It’s just the type of person my dad is snickyShrug

jaunty plank
#

well, its free for the first year, google also has free small VPS's forever as long as a card is attached.

#

yeah

restive otter
#

I’ve already used digital ocean back when I was a idiot programmer

jaunty plank
#

you can easily get away with a 2 years of free VPS's currently

restive otter
#

In my dads words
You have your own card deal with it yourself

#

Can you link me some of them that are offering free trails

#

^not this one please I already used up my trail

restive otter
#

Thank you 🙏

jaunty plank
#

oh heck vultr has free stuff too

#

psh, at this point 4-5 years of free servers 👀

#

I wonder if any of these could host a MC server reasonably well 👀

rain heart
#

small one, definitely

#

if using a budget-friendly server version

jaunty plank
#

well, everyone pretty much always uses paper anyway

#

totally on topic 👀

hybrid gate
#

did i miss something? yesterday i see some api changes but idk what i need do

after someone vote to my bot, they get 1-5-10 times reward

rain heart
hybrid gate
rain heart
#

You need to respond to the webhook with a 200 OK

#

As it says there

#

Otherwise i can't explain it

hybrid gate
barren kestrel
#

I'm making a leaderboard with a db showing all the votes a user has.

How would I say, the second a user votes, (do my db stuff)?

I can do the db stuff but idk how to say if a user votes, then blah blah blah. I have a votecheck command but I don't want them to run that command before receiving their points

#

Ping me if you know

lament cairn
#
class TopGG(commands.Cog):
  
    def __init__(self, bot):
        self.bot = bot
        self.token = 'my token is here'  
        self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='dbl_password', webhook_port=5000)

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print("Received an upvote:", data) ```
so i have this code but when my friend votes nothing happens, is there something I am doing wrong
barren kestrel
#

Would that be my webhook url if this is my code:

app.post('/dblwebhook', webhook.middleware(), (req, res) => {
  // req.vote is your vote object e.g
  console.log(req.vote.user) // 221221226561929217
  dwebhook.send(`<@${req.vote.user}> has voted for News Agent on top.gg!`)
});

app.listen(5000)```

http://127.0.0.1:5000/dblwebhook```

#

App is express btw

willow spindle
#

yes

barren kestrel
#

ok ty

willow spindle
#

but not 127.0.0.1

barren kestrel
#

oh

#

what would I put there

willow spindle
#

your server ip

barren kestrel
#

how do I find that

willow spindle
#

which OS?

barren kestrel
#

windows

#

10

willow spindle
#

is that your pc

barren kestrel
#

yes

willow spindle
#

do you host it on your pc

barren kestrel
#

yes

#

I host my bot on my pc

willow spindle
#

then just open browser and search what is my ip

barren kestrel
#

and then put that :5050/dblwebhook

willow spindle
#

yep

barren kestrel
#

ok ty

#

@willow spindle my ip would be my public ip right

willow spindle
#

yes

barren kestrel
#

ok

#

@willow spindle it doesnt work

#

where do I find my ports again

rain heart
#

You need to portforward

barren kestrel
#

how do I do that

#

@rain heart

rain heart
#

Look it up, can't really help with that

barren kestrel
#

ok

#

what do I port forward

rain heart
#

The port you want to use

barren kestrel
#

ok but like where do I find available ports

#

@rain heart

#

I hagve no idea what to port forwrd

#

Like what type do I forward?@willow spindle do you know?

willow spindle
#

I don't know much about the ports in windows

barren kestrel
#

Ok

unborn turret
#

I’m getting this error:
ServerDisconnectedError: server disconnected
From a upvote.get_user_upvote(id)

barren kestrel
#

is it for a webhook?

#

@unborn turret

unborn turret
#

Na

barren kestrel
#

What is it for

unborn turret
#

My webhook is working fine

#

Api

#

It works for some users but not others

barren kestrel
#

Oh

#

So wait, what are you tryng to do?

unborn turret
#

Check if the user has upvoted or not

barren kestrel
#

Oh ok'

#

Djs?
or py

unborn turret
#

Py

barren kestrel
#

hm, what are you using to host it

unborn turret
#

Digital ocean

barren kestrel
#

oof idk

unborn turret
#

Rip

barren kestrel
#

How could I say, once a user has voted, do something....

#

djs

unborn turret
#

Hmmmm

barren kestrel
#

@unborn turret I have a friend who could help you

#

add me

unborn turret
#

Alright

mental adder
#

you're such an... READ THE MF CHANNEL DESCRIPTION

ionic halo
#

how do you implement a vote command that can check if a user has voted or not?

rain heart
ionic halo
#

I tried

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print('Vote recieved!')
        print(data)
#

but it isn't doing anything

rain heart
#

if you want to receive realtime votes, you have to use webhooks with that

ionic halo
#

oh

#

how do you do that?

restive otter
#

1xbet

inland violet
#

hi

#

WHY DOES NO ONE KNOW THAT I MADE A BOT!!!!!!!!!!!!!!!

willow spindle
#

because no one cares

sudden lagoon
#

you are not the first one, who made a bot

topaz axle
#

Hello, I have just changed my bot to a different VPS, and have noticed that the webhook for my voting system doesn't work. I changed the IP on my bot page, and when I use the "test" button on the page, the bot successfully sends a DM, but when users try to vote for the bot they don't get the DM. I am using the "dblapi.js wrapper". What could be the issue?

plucky lance
#

Maybe the users did disable direct messaging like a lot of people are doing

topaz axle
#

I don't think this is the issue, it only became a problem as soon as I changed VPS

plucky lance
#

Well if you’re receiving the test webhook at least your firewall is allowing incoming connections on the port you choosed

#

I’m not aware of any other issues with webhooks

topaz axle
#

yeah I think it's working now ^^ thanks anyway

plucky lance
#

Alright

bold ice
#

Hello

empty peak
#

@elfin solstice - Wouldn't the correct response to the vote webhook be 204 rather than 200? We're not returning data, just that the request was successful.

elfin solstice
#

204 will work (and makes the most sense) the same as 200 does

empty peak
#

I'm responding with 204 and getting the retries

elfin solstice
#

make sure that you close the connection and don't take longer then 5 seconds because we timeout after that

#

i tested it heavily and it works as expected

#

can you show me the code you are using?

empty peak
#

I'll try and grab a screenshot on my break. The requests aren't taking 2s to process on my end

elfin solstice
#

i just tested it again, we only retry on network issues, timeouts & 5xx status code

#

its either of that

#

204 is accepted like any other 2xx status code

fading mica
#

Are we able to use the api before getting approved or thats not possible?

plucky lance
#

Nope it’s not possible

fading mica
#

Okay thank you!

knotty garnet
#

What does 204 represents again?

#

Accepted?

empty peak
knotty garnet
#

Thx

empty peak
knotty garnet
#

Better if you send the status before doing anything else

#

Just in case it's taking longer than expected

elfin solstice
#

that won't really work that way in nodejs

knotty garnet
#

Really? Meh

elfin solstice
#

i would check if the insert takes too long maybe or if you actually don't close the response (a lot of people had that issue with express before, they set the status code but the connection was never closed and so we timeout after 5 seconds and retry)

#

cause they forgot to call .end() and only called .status() and not .sendStatus() or .stats().end()

devout sparrow
#

@rain heart

rain heart
#

Your bot needs to be approved first in order to use webhooks

devout sparrow
#

o

#

🤦‍♂️

#

server vote logs?

#

is that possible

#

since my server is verified lol

rain heart
#

oh server

#

you can't use discord webhooks either

devout sparrow
#

uh so what do I do

#

I use dbd.js if language matters for logs

rain heart
#

yeah you won't be able to with dbd, i'd suggest using a vote tracker bot instead

devout sparrow
#

do u know any? @rain heart

rain heart
#

Vote Tracker is one i can recommend

devout sparrow
#

okie got it

#

thanks so much!

restive otter
turbid umbra
#

how to impelement vote, If someone vote my bot, it will be give users a rewards or dm it?

rain heart
turbid umbra
#
const express = require("express");

const app = express();

const webhook = new Topgg.Webhook("your webhook auth");

app.post("/dblwebhook", webhook.middleware(), (req, res) => {
  // req.vote will be your vote object, e.g
  console.log(req.vote.user); // 395526710101278721 < user who voted
});

app.listen(80);
restive otter
#

?

turbid umbra
#

where should I put my webhook url?

restive otter
#

at your bots edit page > webhooks

turbid umbra
rain heart
#

the port

#

don't use 80

#

use 5000 for example

turbid umbra
#

just it?
will it response if someone vote on the bot?

rain heart
#

you also need to answer the request with a 200 or it keeps retrying

#

and add it to your top.gg webhook settings under your bot page settings -> webhooks

restive otter
#

I know there is a way to check if a user has upvoted a bot using the top.gg API, but is there a way to check if they upvoted a server?

#

Yönetici lazım bana

rain heart
restive otter
#

@rain heart

rain heart
#

?

restive otter
#

Yönetici lazım bana @rain heart

rain heart
bronze axle
#

webhook tests aren't working

short isle
blissful belfry
#
from discord.ext import commands, tasks
import discord
import dbl


class TopGG(commands.Cog):
    """
    This example uses tasks provided by discord.ext to create a task that posts guild count to top.gg every 30 minutes.
    """

    def __init__(self, bot):
        self.bot = bot
        self.token = 'Yout token'  # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token)
        self.update_stats.start()

    def cog_unload(self):
        self.update_stats.cancel()

    @tasks.loop(minutes=30)
    async def update_stats(self):
        """This function runs every 30 minutes to automatically update your server count."""
        await self.bot.wait_until_ready()
        try:
            server_count = len(list(self.bot.guilds))
            await self.dblpy.post_guild_count(server_count)
            print('Posted server count ({})'.format(server_count))
        except Exception as e:
            print('Failed to post server count\n{}: {}'.format(type(e).__name__, e))


def setup(bot):
    bot.add_cog(TopGG(bot))```
#

@short isle full code for that

short isle
#

oh thanks

#

i get this error

#

and it still says N/A

cursive steppe
#

When the topgg servers performs a post request when a webhook is tested it sends wrong user id

rain heart
#

it sends to top.gg one, i think that's known

#

or which one does it send

cursive steppe
#

And I'm sure requests are from topgg

rain heart
#

user seems to be a valid id

#

pretty sure

#

Can you send the id in here

cursive steppe
#

A min

rain heart
#

actually

#

739679013773246486

#

that's a test request isn't it?

cursive steppe
#

7972206033080352768

#

Yes

#

Test request

short isle
#

for me on my bot's page it still shows N/A

rain heart
short isle
#

wdym?

rain heart
#

@cursive steppe yeah very likely your top.gg ID

rain heart
short isle
#

where?

rain heart
#

read the docs

cursive steppe
#

But doesn't it shows user id instead of topgg id?

short isle
#

i dont get it

#

i cant find it

cursive steppe
#

Also when i actually vote a server it returns correct id

rain heart
short isle
rain heart
#

Look for the one for your language

#

use the search function

cursive steppe
#

This started to recently happen, i remember few weeks before it was working well even with test

rain heart
short isle
#

dude i did it's not there for me

cursive steppe
#

So is there a way to fetch user id from topgg id?

rain heart
#

posting bot stats includes server count

short isle
#

thats for js

#

mine is py

rain heart
#

then go to python

short isle
#

i did

#

and i used that but the server count still don't show up

rain heart
#

maybe check for error? shrug

cursive steppe
short isle
barren kestrel
#

Ok how can I say, once a user has voted, do this (in discord.js).....
Please ping me if you know. I'm making a lb, where everytime a user votes, they get a point

trim flame
#

owos