#topgg-api

1 messages ยท Page 149 of 1

north trellis
#

requests, dblpy doesnt work in 3.9

#

we do requests.post

sullen nymph
#

cough I do not claim responsibility

#

Show your code

#

p.s. also use aiohttp

north trellis
rain heart
#

remove the second / from bots

#

doesn't make a difference tho i reckon

sullen nymph
#

It does

north trellis
#

it does

#

lol

#

i didnt even see it

#

thanks

rain heart
sullen nymph
#

Also

rain heart
#

didn't expect that to work then

sullen nymph
#

I suggest you rely on 2xx responses generally instead of just 200

sharp totem
#
import dbl
import discord
from discord.ext import commands, tasks
import os
import asyncio
import logging

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

    def __init__(self, bot):
        self.bot = bot
        self.token = "my_dbl_token"
        self.dbl_auth = "my_dbl_auth"
        self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth=self.dbl_auth, webhook_port=8080)
        self.update_stats.start()

    @tasks.loop(minutes=30.0)
    async def update_stats(self):
      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))
      finally:
        print("guild post attempt done")

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

    @commands.Cog.listener()
    async def on_dbl_test(self, data):
      logger.info('Received test vote')
      print(data)
    
def setup(bot):
    global logger
    logger = logging.getLogger('bot')
    bot.add_cog(TopGG(bot))
    print("top.gg loaded")
sullen nymph
#

200 <= response.code < 300:
success

north trellis
#

ok, i'll keep that in mind

#

thanks

rain heart
#

have you attempted to make a test request to your webhook using postman or reqbin?

sharp totem
#

Yes

sullen nymph
#

Where is your webhook hosted

sharp totem
#

what?

sharp totem
sullen nymph
#

Also keep your indents either at 4 or 2 spaces

rain heart
#

what json? it isn't supposed to send you a json

#

it is a post request

sullen nymph
#

How was my question unclear

sharp totem
#

{bot: user:

sharp totem
rain heart
#

it isn't

sullen nymph
#

How are you sending the request

rain heart
#

you make a post request to that webhook with the json data

#

not other way around

sharp totem
rain heart
#

so you are sending a post request to your webhook with json data?

sharp totem
#

To post the vote data when someone votes bot

sharp totem
rain heart
#

use reqbin to check if your webhook works correctly

sullen nymph
#

So can we assume that it works properly..?

sharp totem
#

Yes

#

Because it sended me the json data containing the user who voted my bot

rain heart
#

then what's the fuss about?

#

if it works

sharp totem
#

It suddenly stopped

#

and now it is sending 404

#

Instead of json

sullen nymph
#

So it worked

sharp totem
#

Yep

sullen nymph
#

Not works

rain heart
#

get the url you're using on your top.gg webhook and use it in reqbin

sharp totem
#

What is that thing?

sullen nymph
#

Reqbin lets you send custom HTTP requests

sharp totem
#

oh

little citrus
#

Where do i get the webhook url?

wise sphinx
#

you need to make a webhook

#

in your server

#

then copy the link

wise sphinx
little citrus
wise sphinx
topaz axle
#

It appears that my bot page on top.gg does not show any of its most recent reviews, only the first 20 or so, although I can still see the review count going up. How can I fix this?

night ingot
#

Pretty sure that's just a site issue right now, you're not able to view more than 20 reviews

#

I'm sure it'll be fixed with the upcoming updates

fierce fossil
#

what do i put into the authorization box @night ingot

night ingot
#

Whatever you want

fierce fossil
#

:D

#

ok

#

@night ingot i keep getting this error:

discord.ext.commands.errors.ExtensionFailed: Extension '__data__.dbl' raised an error: AttributeError: type object 'dbl' has no attribute 'DBLClient'```
night ingot
#

Did you import the dblpy library?

fierce fossil
#

yes

night ingot
#

Show your code

fierce fossil
#

ok

#

nvm i fixed it

#

@night ingot one last thing,

what would go in the

webhook_path='/dblwebhook'

#

this confuses me

night ingot
#

So your webhook url is supposed to be
http://<public ip>:<port>/<webhook path>

#

that's the <webhook path> part, it can be whatever you want

fierce fossil
#

i thought the webhook was supposed to be a discord webhook?

night ingot
#

so in your case, your url is http://<public ip>:<port>/dblwebhook

#

No, Discord webhooks won't work

fierce fossil
#

i see

sullen nymph
frank salmon
#

I have a problem with the webhook after vote, no send post
Before I had http but I added ssl & changed to https and now the top.gg webhook do not arrive
But if I test it on postman it works correctly

knotty garnet
#

@frank salmon what do you use for serving content?

#

Nginx?

wicked storm
frank salmon
knotty garnet
#

No, i mean, don't you have a request handler?

#

Express is the webserver itself

frank salmon
#

But before putting the ssl it works for me without problem

knotty garnet
#

I know, I just need to know all details

frank salmon
#

My question is, if it works in postman because it doesn't in top.gg? ._.

knotty garnet
#

If you were using nginx/apache I'd say to check the logs

#

They'd have listed what's happening with the request

frank salmon
#

How can I check?

knotty garnet
#

That's what I'm trying to find out

#

Check what proccess is listening to ports 80/443

frank salmon
#

3000 is for express

knotty garnet
#

But what proccess?

#

Wait

frank salmon
knotty garnet
#

Yep looks like you're raw

#

Hm

#

Lemme think

#

Do express have logs for requests?

#

Or a debug mode?

frank salmon
#

Let me check

frank salmon
ebon plover
#

How to dm a user after they vote?

rain heart
#

by using webhooks and sending that user a dm through your bots code

thorn umbra
#

Can anyone help me setup the top.gg vote webhooks

rain heart
languid plaza
#

Sorry wrong channel couldnt see names proprly im so sleepy

woeful moth
#

guys, how do I check if someone voted my bot on top.gg?

#

nvm i found the /check endpoint

topaz axle
#

How do I post my full server count to top.gg if I'm using sharding? (using JS)

knotty garnet
lucid wasp
#

alright so I am attempting to run a few lines of code after someone votes for my bot. I am trash at working with apis and http requests so any help would be much appreciated (discord.net library)

ps. tried myself without any luck

knotty garnet
#

but anyway, you'd need to use a webserver or @Top.gg/sdk

blissful lake
#

does @Top.gg/sdk include any methods related to checking if a user has voted my bot? something like a .hasVoted function?
i am not referring to the api itself

rain heart
#

that is related to the api tho

blissful lake
#

there was a function in the dblapi.js package which allowed me to check if the user has voted
but it seems like in the new package, I cannot find a function like that

rain heart
#

Nah it's still present

blissful lake
#

thanks ThumbsUp

sharp totem
#

Is there any problem with dbl webhook?

#

I tried using the dbl webhook but no webhook path found 404

#

I tried the same path with a custom webhook it worked and prints

#

why dbl webhook not working

#

I am hosting my bot on replit and using flask to run the server

#

So what should I type as the IP?

#

localhost?

#

Anyway it doesn't work with dbl webhook

#

Please help

sharp totem
#

For custom webhook my webhook url I set was https://my_repl.repl.co/dblwebhook

restive otter
#

why does this not work ๐Ÿ˜ฆ

#

token correct bot is working

keen shadow
#

Pls bal 825298180479909918

rain heart
#

-botcommands

abstract mothBOT
#

Hey! Bots aren't given permissions to send responses in this channel. Please use #commands to run commands.

sharp totem
rain heart
#

can't help with repl related things

sharp totem
#

but many have asked the same

#

I just searched the channel history

sharp totem
# rain heart can't help with repl related things
@app.route('/dblhook',methods=['POST'])
def response():
  data = request.json
  print(data)
  user_id = data['user']
  check = str(request.headers['Authorization'])
  token = "Bearer "+str(os.getenv('dbl_auth'))
  if token == check:
    return Response(status=200)
  else:
    return Response(status=410)
#

This is my custom webhook

#

It works fine

rain heart
#

can't help with repl related things

sharp totem
#

But I need a async function which is not possible with this

sharp totem
rain heart
#

because I never used repl in my life and never will

sharp totem
#

Okay let's not talk about repl

#

I'm talking about the top.gg library

#

Help me dude

autumn trellis
#

Hi, can you send me owo cash?

sharp totem
#

what?

naive furnace
#

hi

#

I need help

rain heart
#

just ask

naive furnace
#

I can't virfy my channel

#

of Discord

#

Nad I alos can't invite the bots

#

he tell me to virfy to my Discord Channel

#

please tell me

#

๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ

#

how to invite bots

vapid ledge
#

what is the topgg documentation?

rain heart
vapid ledge
#

Thanks

sullen nymph
#

Yup

#

Because ratelimiter package is ๐Ÿ’ฉ and doesn't work with Python 3.9

#

Downgrade

#

Between 3.6 and 3.8

#

What yells it's not?

sullen nymph
#

Yeah reinstall the package via pip

#

What did you do

#

install not uninstall

#

dblpy

fresh bear
#

any1 got code for discord.py if i wanted a role to be given when ppl vote on the server?

fresh bear
#

ix that your code?

restive otter
restive otter
#

How do I add this bot to the server

jaunty plank
restive otter
jaunty plank
#

like dsl?

restive otter
#

Yes

jaunty plank
#

server listing?

restive otter
#

Yes

jaunty plank
restive otter
#

Ty

sullen nymph
#

rtfd

#

data is a dict

#

You can't get keys as attrs

#

get_member isn't used on data

#

That code by far

#

Is the worst example I have ever seen

gloomy barn
#

sahur ci

frank salmon
solid crest
#
import discord
import asyncio
import dbl
import logging

from discord.ext import commands, tasks

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

    def __init__(self, bot):
        self.bot = bot
        self.token = 'MyRealToken'
        self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/dblwebhook', webhook_port=5555)



    async def cog_command_error(self, ctx, error):
        if isinstance(error, commands.CommandInvokeError):
            await ctx.send(error.original)

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print("received an upvote")
        print(data)

    @commands.Cog.listener()
    async def on_dbl_test(self, data):
        print("Received a test upvote:", "\n", data, sep="")

def setup(bot):
    global logger
    logger = logging.getLogger('bot')
    bot.add_cog(Vote(bot))

Checked everything but still authorization is an error it says
https://cdn.discordapp.com/attachments/412006692125933568/833606944031899698/unknown.png
https://cdn.discordapp.com/attachments/412006692125933568/833607035072937984/unknown.png
https://cdn.discordapp.com/attachments/412006692125933568/833607528994439228/unknown.png

night ingot
hollow lichen
#

Can I use a discord webhook as a webhook for the top.gg NPM package?

willow spindle
#

you can use whatever you want to send vote received message

molten vapor
#

hi i want help idk if i am on right channel for help but yeah
i want to make a vote checker from which i mean
my bot will check who has voted it

then send a thank u dm to user

i can do the dm part but i need vote checking part
also i dont know anything about top.gg api

the language i have to code is js
thanks

rain heart
sullen nymph
#

@rain heart

rain heart
#

@red cradle please don't advertise

#

thanks

pure spire
#

hey would this work

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

if you've setup the webhook parameter in your constructor and the webhook in your bot page, yes that could work

pure spire
#

@rain heart done all of that

rain heart
#

then either test it using top.gg's test vote or use reqbin to test it more controlled

pure spire
#

@rain heart this is for discord server list

rain heart
#

still applies

pure spire
#

perfect lemme try

#

@rain heart also reqbin?

rain heart
#

reqbin is more controlled to test it

#
{
  "guild": "12345",
  "user": "12345",
  "type": "test",
  "query": "?true&isTrue=1"
}
#

use this as test data in reqbin

pure spire
#

@rain heart what would my url be?

rain heart
#

http://yourip:portofyourwebhook/path

pure spire
#

ah ic

#

@rain heart what am i doing wrong?

rain heart
#

what do you get in response?

#

also can't really help with repl stuff, so you need to be 100% sure the url is correct

pure spire
#

the url is correct

#

cuz i get on_dbl_vote

#

perfectly

#

and the test too

rain heart
#

and top.gg doesn't return anything?

pure spire
#

my error is 401

#

unauthorized

rain heart
#

unauthorized

pure spire
#

do i have to add some token or something

rain heart
#

have you set a Authorization header?

pure spire
#

in the bearer?

#

ahh nope

rain heart
#

not bearer

#

just a simple Authorization header

#

Authorization: yourwebhookauth

pure spire
#

what would my webhookauthbe?

#

my pas?

rain heart
#

on your dbl constructor, the auth parameter

#

is your webhook auth

pure spire
#

still 401

rain heart
#

not password and username

#

literally just a basic auth header

#

well not basic auth

#

in reqbin's case, custom

pure spire
#

@rain heart it worked

rain heart
#

that auth is also important on the Authorization field on top.gg

vast hare
#

How can i get the API key?

night ingot
#

You can find your dbl token on your bot's edit page under webhooks, but you won't have access to the API until your bot is approved

vast hare
#

1 question

#

There is any way to make that if somebody votes a server

#

the bot detect that?

restive otter
vast hare
#

How?

#

with the same api key?

restive otter
vast hare
#

Okay

#

I dont find the key ;-;

#

Ah

#

it needs to be approved

#

Well.

#

If i want to get the api key just for the server and i dont want upload the bot?

#

What could i do?

pure spire
#

is dbl and dsl events under the same network?

wide wigeon
#

henlo

#

my webhook isnt working, no idea why, can anyone help

rain heart
#

More input please

#

post your code, what exactly isn't working

#

have you added it to your bot page settings under webhooks etc

wide wigeon
#

i posted about it earlier

#

and yeah, i did add all the stuff i'm supposed to add

#

i have the auth did properly, the url is my public ip

#

set up like this

#

http://my.ip:6950/dblwebhook

#

additionally, i also tried making a new open port

rain heart
#

have you tested it using reqbin for example?

wide wigeon
#

reqbin?

#

not really

rain heart
#

Test it outside of top.gg to see if you're at least getting a valid request to your webhook

wide wigeon
#

sure

wide wigeon
#

alright it works

pure spire
#

@rain heart what exactly does the query do?

rain heart
#

query is the query at the end of your vote url

#

for example

pure spire
#

uhuh

rain heart
#

the query would be in that case ?votedThroughNotifications=true

pure spire
#

@rain heart can queries be empty?

rain heart
#

yes

pure spire
#

last thing

pure spire
#

the query there?

rain heart
#

see what i just said above

#

A query string is a part of a uniform resource locator (URL) that assigns values to specified parameters. A query string commonly includes fields added to a base URL by a Web browser or other client application, for example as part of an HTML form.A web server can handle a Hypertext Transfer Protocol (HTTP) request either by reading a file from ...

#

bit more detailed

pure spire
#

i understand what votedthroughnotifications means

#

but what does true&istrue=1 mean?

rain heart
#

That's just an example

#

query can be used to track where a user voted from

pure spire
#

ahh icicic

rain heart
#

for example you can have ?dmNotifications and check if the query is ?dmNotifications and know that for example this user voted through the dm notifications

pure spire
#

i get it now

#

thanks dude @rain heart appreciate it

pure spire
#

how do i use the get_bot_votes function?

sharp totem
#

Is there a on_dsl_vote event because I have a server private bot and I want it to listen to on_guild_vote if exists

#

That bot is not registered in dbl

restive otter
#

no

#

you can use webhooks tho

modest cedar
#

Was the api being laggy for anyone else yesterday?

sharp totem
#

or is there a way to create dsl webhook

#

like

#

self.dsl = dsl.Client()

restive otter
#

Can you just put whatever port you want here?

#

All that i did before that was this

rain heart
#

That port needs to be free and be opened

pure spire
#

can someone please help?

a user just voted for my bot
and in data it shows this

#

but when i check if the user voted
it shows false
whats going wrong?

#

@rain heart

#

oh wait i dont think i should have pinged, in which case soz

west gale
#

npm ?

rain heart
pure spire
#

id? @rain heart

rain heart
#

which ID?

#

left or right one?

pure spire
#

user @rain heart

#

the user id is what matters right?

rain heart
#

yes

#

are you checking it correctly?

pure spire
#

yeah its not even in the list of users

#

im sure i checked correctly

rain heart
#

use the check endpoint please

pure spire
#

im 100% certain

rain heart
#

instead of fetching all votes

pure spire
#

@rain heart i did both

#

my noob temporary code

#
@client.command()
async def broskis(ctx):
    if ctx.author.id == ownerdude:
        print(await dblpy.get_bot_upvotes())

@client.command()
async def brud(ctx, userid):
    if ctx.author.id == ownerdude:
        print(await dblpy.get_user_vote(userid))
rain heart
#

don't fetch the whole votes just for one vote

pure spire
#

brud shows false

rain heart
#

use the has_Voted or the check endpoint

pure spire
#

broskis does show the name in the weird json list

#

@rain heart check this

rain heart
#

Again

#

use the check endpoint

pure spire
rain heart
#

not the whole list of votes

pure spire
#

im certain it doesnt work @rain heart ive tried different methods

#

but whenever a user votes for me

#

it shows on my repl that it recieved it

#

but doesnt show on ur end

rain heart
#

use reqbin and make a manual request to the api

#

using the users ID in the body

#

then see what it responds with

#

also you're doing it wrong, you're supposed to include the UserID in the query

#

not the body

#

see example response

pure spire
#

@rain heart would you be kind enuf to guide me thru?

#

im in reqbin but idk what to do

rain heart
#

append the correct params to your code above

#

see the example response in the screenshot, you're making your requests wrong

pure spire
#

i put this in my reqbin

#

im not sure how to make requests via reqbin

gritty needle
#

just use webhooks

pure spire
#

@gritty needle i am using webhooks

gritty needle
#

then I don't think you need to check using the API

pure spire
#

@gritty needle in the end of the day

#

it doesnt show that my bot got the vote

#

even though it did

gritty needle
#

hm

#

well

pure spire
#

py

gritty needle
#

okay

#

so are you self-hosting the bot or are you using a host?

pure spire
#

repl

gritty needle
#

okay

#

so

#

let me send you my code

pure spire
#

@gritty needle thatd mean a lot

#

@rain heart one question if you dont mind

#

can i use reqbin

rain heart
#

cant rn

pure spire
#

oh alr

#

later then

restive otter
#

Plz someone share docs for python top.gg api

pure spire
#

my question tho, can I use reqbin to make a post request to using a random id to get my bot think it got upvoted?

sullen nymph
#

You only send your top.gg token as auth

sullen nymph
#

What's your code like in the first place

pure spire
#

@sullen nymph wait

#

@sullen nymph u created dblpy

#

also help me plssss

sullen nymph
pure spire
#

@sullen nymph sorry one sec

#

which part of the code do you want?

sullen nymph
#

Whatever that's even remotely related to your webhook

pure spire
#

@sullen nymph here

#

one sec repl slow

restive otter
pure spire
#

im reloading the pgae one secc

#

oh lord dont use repl, its disappointingly slow

sullen nymph
pure spire
#

got it

restive otter
#

ohhhhhh

sullen nymph
#

Sounds like an issue on your end. I use repl just fine

restive otter
#

ok thanks

pure spire
#
dblpy = dbl.DBLClient(client,
                      gg_token,
                      webhook_path='/dblwebhook',
                      webhook_auth='pass',
                      webhook_port=6500,
                      autopost=False)


#

and then

#
@client.event
async def on_dbl_vote(data):
    print(data)
    k = int(data["user"])
    user = client.get_user(k)
    chanah = client.get_channel(834354286644428810)
    embed = discord.Embed(
        title="",
        url=
        "https://cdn.discordapp.com/avatars/823830590163255296/000ef89b04f9d1abe102b68aa7ae08ab.webp?size=1024",
        colour=int('c72fa7', 16)
    )
    embed.set_author(
        name="Fake TOG",
        url=
        "https://cdn.discordapp.com/avatars/823830590163255296/000ef89b04f9d1abe102b68aa7ae08ab.webp?size=1024",
        icon_url=
        "https://cdn.discordapp.com/avatars/823830590163255296/000ef89b04f9d1abe102b68aa7ae08ab.webp?size=1024"
    )
    embed.set_thumbnail(
        url=
        "https://cdn.discordapp.com/avatars/823830590163255296/000ef89b04f9d1abe102b68aa7ae08ab.webp?size=1024"
    )
    embed.add_field(
        name="We Just Recieved Feedback!!!!",
        value=
        f"**{user.name}#{user.discriminator}** Was Kind Enough To Vote For Us, It Means So __MUCHHHHHHHHHH__ :heart:",
        inline=True)
    embed.set_footer(text=f"User: {user.name}")
    await chanah.send(embed=embed)
#

it sends this

#

and all

#

but when i check if the user voted via

#

these 2 temp commands

#
@client.command()
async def broskis(ctx):
    if ctx.author.id == ownerdude:
        print(await dblpy.get_bot_upvotes())

@client.command()
async def brud(ctx, userid):
    if ctx.author.id == ownerdude:
        print(await dblpy.get_user_vote(userid))
#

doesnt work

#

it shows false

#

and the other doesnt have the name in the json list

sullen nymph
#

API can be slow at updating the voters list

pure spire
#

@sullen nymph same problem on the website

restive otter
#

How can i check if it worked?

pure spire
#

i cant see the add in the vote

sullen nymph
#

What did you enter in webhook URL

sullen nymph
pure spire
#

@sullen nymph here

sullen nymph
#

And does it work

pure spire
#

@sullen nymph it sends the message in the channel

#

that someone voted

#

with the name and all

#

but it doesnt get added in the number of votes on the site

#

or when i check with the api

#

it shows false

sullen nymph
#

Give it anywhere from few minutes to an hour

pure spire
#

@sullen nymph its been 4 hours now

#

more actually

#

im still having the same issue

rain heart
#

once again, have you tried doing a manual request instead of using your code??

pure spire
#

@rain heart thats where this question came

#

my question tho, can I use reqbin to make a post request to using a random id to get my bot think it got upvoted?

sullen nymph
#

Do you realize that your webhook has nothing to do with the API requests you're sending

pure spire
#

i understand that, but this was just a pure unrelated question

#

would that even work?

#

here's a simple code

pure spire
#

would this work?

sullen nymph
#

It can work, yes. dblpy before v1.0 used to use on_dbl_test for test requests

pure spire
#
import requests
from requests.structures import CaseInsensitiveDict

url = "https://ttbot.tog6.repl.co/dblwebhook"

headers = CaseInsensitiveDict()
headers["Authorization"] = "pass"
headers["Content-Type"] = "application/json"

data = """
{
  "bot": "823830590163255296",
  "user": "789435091960463370",
  "type": "upvote",
  "query": ""
}
"""


resp = requests.post(url, headers=headers, data=data)

print(resp.status_code)
sullen nymph
#

Possible, yes

pure spire
#

well that would be broken wouldnt it?

sullen nymph
#

In what sense?

restive otter
#

I am an idiot
I don't know how to request anything. I've never used webhooks before. All i have is a supposed listener on vote
When i console.log(app)
It says that events count is 1

pure spire
#

wait so you're saying if i use this code with random user ids

#

id get a bunch of votes?

#

in which way it would be pretty broken

rain heart
#

no

sullen nymph
#

There's a reason test requests are distinct from upvote requests

rain heart
#

that is not how it works

pure spire
#

yeah that makes sense

rain heart
#

if you're referring to other users using your url to get vote rewards, then that's why Authorization is a thing

pure spire
#

authorization here would be the auth.gg token?

#

or their token in the bearer?

sullen nymph
#

Auth

pure spire
#

ahh icicic, but anyways, why wont it update tho?

pure spire
sullen nymph
#

Because APIโ„ข๏ธ issues

#

Wdym account

pure spire
#

each discord account i mean, different auth.gg token

sullen nymph
#

webhook_auth is the password for your webhook

pure spire
#

uhuh

sullen nymph
#

you enter similar shit on top.gg

restive otter
#

is _eventsCount the number of listeners that are active?

sullen nymph
#

The webhook under the hood checks the auth header

pure spire
#

and then adds the vote

sullen nymph
#

Top.gg uses the password you enter on the website (the Authorization field) and sends it on each request

naive furnace
#

bot รผst sayfalara รงฤฑkฤฑyor

sullen nymph
#

Essentially โ€” yes. After that, it emits the on_dbl_vote/test event with received data

pure spire
#

i see

#

so where does it so go wrong that it emits the on_dbl_vote, but doesnt add the vote?

sullen nymph
#

Internally on its own because API

#

Hence why it's been strongly recommended to use webhooks

restive otter
#

is what you are talking about for the python version?

pure spire
#

i am arent i?

#

@restive otter this guys a legend lol

#

he fking made dblpy

restive otter
#

bruh

pure spire
#

i saw him on github while going thru the docs

sullen nymph
#

Yeah, you're using the dblpy webhook to process the votes in real time

restive otter
#

sadly i'm using the js one

pure spire
#

so where does it go wrong? sorry im so new to all of this

#

its like a whole new language ๐Ÿ˜‚

sullen nymph
pure spire
#

so theres no fix?

sullen nymph
#

None that you can implement to change it

restive otter
#

i've made a new thing here for port forwarding but it still doesn't seem to work
(25565 is for a minecraft server)

#

What else am i doing wrong?

pure spire
#

@sullen nymph last thing, who do i contact to fix?

sullen nymph
#

No one

#

It'll probably be fixed in top.gg APIv1

pure spire
#

also this shows status code 200 meaning it should have worked right?

import requests
from requests.structures import CaseInsensitiveDict

url = "https://ttbot.tog6.repl.co/dblwebhook"

headers = CaseInsensitiveDict()
headers["Authorization"] = "assda"
headers["Content-Type"] = "application/json"

data = """
{
  "bot": "823830590163255296",
  "user": "524918284269912064",
  "type": "upvote",
  "query": ""
}"""

resp = requests.post(url, headers=headers, data=data)

print(resp.status_code)
sullen nymph
#

Yup

pure spire
#

and my bot recieved the message

#

meaning it recieved the vote

sullen nymph
restive otter
#

Ok i added this inbound rule to allow everything both on tcp and udp

#

how about now?

#

there are still 0 listeners

#

@sullen nymph sorry if the ping annoys you i won't send again

sullen nymph
#

How are you running the webhook

restive otter
sullen nymph
#

God help you

restive otter
#

this is the output

#

oh no

#

i must have done a million things wrong

#

sorry i've never used webhooks before

sullen nymph
#

Try to open the url to that route and port locally

#

Nah I just don't know what the fuck is happening

restive otter
#

i don't have a url

#

should i make one?

sullen nymph
#

You do if your PC is connected to internet

#

Try to open localhost:5000/dblwebhook in your browser

restive otter
#

I don't know why but i feel like I missed a step

sullen nymph
#

Ah, so it does run

#

Get your public IPv4 address and use it in the URL

restive otter
#

not the ipconfig one?

#

i thought i only had one IPv4 address

sullen nymph
#

The format is http://your.public.ipv4.address:5000/dblwebhook

#

You are probably seeing your local IP

restive otter
#

yeah

sullen nymph
#

If it starts with 192.168

restive otter
#

yeah

#

it does

#

ok i guess i only have one

#

anyway

#

same thing

sullen nymph
sullen nymph
#

Not that

#

The one above that

#

You get the point

balmy hamlet
#

if they're hosting their bot locally they gotta do some port forwarding on their router first

#

to use their public ip

sullen nymph
#

Done

balmy hamlet
#

alr

restive otter
#

So i'm not going to do ipconfig to get it?

#

Is it the one where i ask google what is my ip

#

and it gives me a number starting with 62?

#

this is what i typed

restive otter
balmy hamlet
#

that's a local ip

restive otter
#

right

sullen nymph
#

Yeah that's a local IP so

restive otter
#

ok how do i get my public ip then

sullen nymph
#

Seems viable

restive otter
#

ah ok thanks

balmy hamlet
#

you need the public ip

restive otter
#

it refused to connect

#

i just did this

#

and then put it here

#

is there something wrong with that

rain heart
#

try visiting that url

restive otter
#

i did

#

it refused to connect

rain heart
#

if you don't get any response, then either port not opened or you have these kind of routers where it doesn't let you connect to it when you're on the same network

#

try using reqbin to make a request to it

#

see if that returns anything

restive otter
#

what is that

rain heart
restive otter
#

and i type the same thing?

rain heart
#

just put the url on the url section and press send

#

see if you get a response

restive otter
#

maybe i didn't port forward correctly

#

although i've already done this for my minecraft server

rain heart
#

yeah then you probably didn't

restive otter
#

in exactly the same way

#

that worked

#

hmm

rain heart
#

If you don't get something like this on the right, very likely it isn't portforwarded correctly

restive otter
#

right

#

ok

#

and then i allowed the port 5000 with an inbound rule

#

both on tcp and udp

#

I don't think there's anything else i have to do

#

i could be wrong though

rain heart
#

inbound should be correct yeah

restive otter
#

do i need to setup dynamic ddns?

rain heart
#

no no, ip works

#

if it works locally, but not externally, then portforwarding is bad

restive otter
#

that's exactly what happened

#

what else is there to do?

#

i'm going to check the inbound rules agai

rain heart
#

is the local ip address you're using, valid aswell?

#

could you try using that local ip in your browser?

restive otter
#

yeah it takes me to my router

balmy hamlet
#

you need the public ip

#

like my current local ip is 192.168.0.2

#

nobody can do anything with it

#

my messages are not sending

restive otter
#

oh

rain heart
restive otter
#

i need to put the public ip in the port forwarding?

rain heart
#

no

#

portforwarding requires your local ip

#

your internal to say

#

not your external

restive otter
#

does they mean i need to put it in the url?

#

i already tried that

rain heart
#

No no

#

look: try using your internal ip, the ip from your ipconfig, in your browser

#

do you get any response with that?

restive otter
#

yes

#

it takes me to my modem

#

oh wait

#

that's not what you asked for

#

ok when i add the other

#

stuff

rain heart
#

your pc-specific ip

restive otter
#

it says cannot get /dblwebhook

#

yeah'

rain heart
#

aight so it's not firewall related

#

then very likely related to your router shrug

restive otter
#

you know what

#

this router is connected to another router

#

do i need to do port forwarding to that one as well?

rain heart
#

then you need to portforward on that other router aswell

#

yes

restive otter
#

bruh

#

wait but how do i get to that router's website

rain heart
#

unless it is a repeater

restive otter
#

no it's another modem

rain heart
#

yes then you do

#

connect to that routers webinterface

restive otter
#

what

#

for this one i just typed my ip

#

what is a webinterface

rain heart
#

the modem's configuration

restive otter
#

is it on the back?

rain heart
#

I can't really help you with that as I don't know what router you have, nor have extensively worked with port forwarding

#

should be

restive otter
#

ah ok

#

one sec

rain heart
#

One of the reasons to use a vps than your own pc

#

to avoid this annoying stuff

balmy hamlet
restive otter
#

is it the wlan security?

rain heart
#

no

restive otter
#

the ds-n?

rain heart
#

no

#

either called gateway or actually configuration

restive otter
#

Product: Home gateway
Model: a bunch of letters?

rain heart
#

no

#

read the manual otherwise

#

can't help with it

restive otter
#

There is nothing else

rain heart
#

can't help then

restive otter
#

Ok thank you for the help so far. I'll come again when i've port forwarded my other router

balmy hamlet
#

your other router's ip is most likely to be 192.168.1.1

restive otter
#

siema

frigid gorge
#

I wanted to know

how do you use the bookshop system @ top-gg/sdk from WEBHOOKS on bots with SHARDS

my bot uses 4 shards and can create shards automatically, but because of that the top-gg/sdk system doesn't work because it is giving an error because of the shards

finite sequoia
#

what url do i send to?

jaunty plank
rancid scarab
#

How would I post to the top.gg API using eris-sharder? I'm using topgg-autoposter

frigid gorge
#

ok

finite sequoia
#

I just wanted my bot to know when to vote for him and who voted for him, how do I do that?

#

what do I do for this code ```js
app.post("/dblwebhook", webhook.listener(vote => {
console.log(vote.user)
}))

to work?
rain heart
#

add your webhook url on your bot page settings

finite sequoia
rain heart
#

Can't help you with repl related things sorry

finite sequoia
restive otter
#

because you need to make post request

#

by visiting it you are making a get request

restive otter
#

I added my webhook from my support server and added a authorization thing to it and it said it couldn't save the webhook

rain heart
#

your bot needs to be approved first

#

and you cannot use discord webhooks

restive otter
#

Oh okay

spark raven
#

I am getting an error 401 message when I use a valid request token, any idea why?

night ingot
#

How are you passing the token?

spark raven
#
(f'http://top.gg/api//bots/830771134177083393/check?userid={message.author.id}', headers={'Authorization': f'TOK:{os.getenv("TOPGGTOKEN")}'})```
#

The token is stored in a .env file

rain heart
#

let your token print out before using it

night ingot
#

Is the TOK: supposed to be there?

#

Because I'm pretty sure it's just {'Authorization' : 'your-dbl-token'}

rain heart
#

yeah only the token should be there

spark raven
#

oh ok!

#

ok

#

still does not work

spark raven
rain heart
#

Simply print your token in your console

#

with a simple log

spark raven
#

yeah, I am using replit, so...

spark raven
night ingot
#

Yes, that should be there

spark raven
#

ok

#

whats the problem tho?

#

does it need a webhook?

night ingot
#

You don't need a webhook to access the api

#

Do like Aurel said and print the token to make sure it's the right one

spark raven
#

ok...

#

it is

restive otter
#

what is topgg api

#

why did we need it ?

#

what is the benefict of it

night ingot
#

It lets you post your bot's servercount, use webhooks to listen for votes, or just access Top.gg data about your bot such as who has voted etc.

#

You can read all about it here

restive otter
#

Does it give examples on how to do something?

#

@night ingot is it possible for the bot itself to listen to votes?

night ingot
#

Yes, that's possible. You still need to setup webhooks though

restive otter
#

Hmm oil

#

Oki

#

Thx ๐Ÿ™

vast moat
#

Can I get if a person has voted or not?

#

And also the time when he have voted?

rain heart
#

has voted, yes

#

time, no, that's what you could do with webhooks

hollow temple
#

why it doesn't work?

#

I did click to test button

#

it doesn't send anything

#

port 80 is open

#

I installed @top-gg/sdk and express

rain heart
#

use a different port than 80

#

80 is the default webserver one

hollow temple
#

I use 3000 now and still the same

rain heart
#

first of all

#

use http, as https automatically sets your port to 443, secure

#

second, define the port in the url by adding :port

#

http://yourip:port/dblwebhook

hollow temple
#

like http://site.xyz:3000/dblwebhook?

rain heart
#

yes

hollow temple
#

it didn't work again

#

:/

#

could there be a problem with the ports?

#

maybe

night ingot
#

Did you check if the port is open?

hollow temple
#

i just use these to open port 3000

firewall-cmd --add-port=3000/tcp --permanent
firewall-cmd --add-port=3000/udp --permanent
hollow temple
#

it is open when i run node server.js

night ingot
rain heart
#

try making a test request or try to access it through your browser

#

if it doesn't respond at all, it is either your code being bad or ports not being open

hollow temple
rain heart
hollow temple
#
const Topgg = require("@top-gg/sdk")
const express = require("express")

const app = express()

const webhook = new Topgg.Webhook("authkey")

app.get('/test', async (req, res) => {
res.json("site acik galiba")
})

app.post("/dblwebhook", webhook.listener(vote => {
  // vote will be your vote object, e.g
  console.log(vote.user) // 395526710101278721 < user who voted\
  
  // You can also throw an error to the listener callback in order to resend the webhook after a few seconds
}))

app.listen(3000)
console.log("basladim")

I use this

night ingot
#

I'm assuming you've hit "save" after changing your webhook url on the page?

hollow temple
#

yea

rain heart
#

again try accessing the site using your browser

hollow temple
rain heart
#

because test.xyz is your website

#

it is trying to access port 80 when there's no port given

#

if 3000 doesn't work, then it is your code

hollow temple
#

I created a new subdomain and it says this site is not available

restive otter
#

lol

rain heart
#

you need to have that subdomain actually point somewhere

#

can't help with it

digital osprey
#

So... Do I need to create a website to receive votes?

spice helm
digital osprey
#

Ooh thanks a lot!

spice helm
#

Np :D

sharp totem
#

Hey

#

Is DSL reward role system broke?

jaunty plank
#

Kindof yes.

sharp totem
#

when will the reward role system be back?

rain heart
#

when it gets fixed

graceful merlin
#

With the API, can I know the time when the user voted for my bot? example: (req.time or req.vote.time)?

rain heart
#

you can't

#

you need to track that yourself using a webhook

graceful merlin
#

Ok, thanks

restive otter
#

So I canโ€™t use this api for my bot?

#

I need. A webhook or a website?

rain heart
#

You can use top.gg's API for your bot when it is approved, but you cannot get realtime-vote events without using webhooks

finite sequoia
#

why doesn't my bot appear to be online when it is online?

rain heart
#

Because it isn't implemented atm, as @abstract moth cannot track presences at the moment

rain heart
#

Bots need to go through a queue before being added to top.gg

restive otter
rain heart
#

yes you could, but remember to also set your webhook url

restive otter
#

Meaning

#

sorry I just started learning about this api today

#

We hook url?

#

Wait so I canโ€™t use my bot?

rain heart
#

??

restive otter
#

So can i track votes , with my bot , without using a webhook?

rain heart
#

no you can't

restive otter
#

Oof ๐Ÿ˜ฅ

#

Will there be an option for that in the future?

rain heart
#

There is one already, using Webhooks

restive otter
#

Ig I have to webhook

#

Where to find this example?

rain heart
#

Again you're only able to use it once your bot is approved

spice helm
#

(mods i'm not sure if this counts as advertising or crosses a line, if it does just let me know)

rain heart
#

meh it's fine

#

more a tutorial than ads

spice helm
#

Ah, that's good, ty :)

restive otter
#

@spice helm thx a lot

spice helm
#

Np :)

vernal trench
#

How to get how many times a user had voted?

rain heart
#

By using webhooks

#

and tracking it yourself

vernal trench
#

okay

molten bramble
#

I am not able to vote

#

Please help

#

I tap on vote but it doesn't count it

#

What should i do?

rain heart
molten bramble
#

Should i ask there

rain heart
#

yes

fathom bronze
#

would this work with a discord webhook

rain heart
#

no

fathom bronze
#

ok

rain heart
#

but actually, do you mind trying something for me?

fathom bronze
#

yeah sure what is it

rain heart
#

Currently working on a new concept that might make using vote webhooks easier for people with no coding language and just want the vote messages than using rewards

#

one sec

#

Do the following:

  • create a webhook in the channel you want vote logs on
  • go to your top.gg page and use the url https://api.discord.re/v1?url=YOURWEBHOOKURL
  • press save and send a test vote
fathom bronze
#

ok

rain heart
#

It should sent a voting message in your webhook url

fathom bronze
rain heart
#

the entire url

fathom bronze
#

and with https://

#

?

rain heart
#

yes

#

It's pretty much a new thing I'm working on for people that just want vote logs

fathom bronze
#

what do i put in authorization

rain heart
#

leave it empty

fathom bronze
#

ok

#

it works

rain heart
#

Pog Thank you, will continue working on it

#

but again you can't use raw discord webhook urls in there

fathom bronze
#

yeah ok

#

i thought so because it would not have any message content

rain heart
#

yeah

restive otter
#

Everyone can use top.gg-core npm, i am using it

#

Is too easy

#

(if this is ad just delete)

rain heart
#

nah it's fine

#

though made that discord.re thing for people with either no coding language (referring to servers), who want a quick solution for logging or just want logging without much coding

dawn solar
#

Not the package. The package might work. I just can't get any ports open. Even with port forwarding enabled on my router, it still says they are closed when I check it on a port finder website

cold root
#

How do I fix this?

#

ping if replying to me.

rain heart
#

dont use 80

#

use a different port

unkempt harness
dawn solar
spark raven
#

hey, I am still getting error 401 no matter what I try ๐Ÿ˜ฆ pls help me? I have tried everything. I am using python, and noting works

cold root
cold root
#

but it still gives the error.

left mesa
#

how can I get total votes of a user?

brittle spoke
ebon plover
#

How to dm a user after they vote?

signal hawk
exotic oyster
#

post requests neva received help!

sullen nymph
#

Details neva received

restive otter
# cold root

thats not how it works, its not a discord webhook

restive otter
#

So if you want vote log, you must use replit, glitch or vps

restive otter
restive otter
#

Repl it better option

obtuse roost
#

I want to know how to setup server webhook .

rain heart
obtuse roost
#

In bot's webhook we have bot token but what about server?

rain heart
obtuse roost
#

then how can i use server vote webhook.

rain heart
#

servers does support webhooks

restive otter
#

Same as bots

#

Dont it?

#

wait it Got removed?

rain heart
#

well servers get different data, but pretty much yeah

restive otter
obtuse roost
#

@rain heart what should I fill here for log votes .

rain heart
#

read the docs for that, you need to make a webhook yourself

#

but pretty much the same way you did on bots

#

just with servers this time

obtuse roost
#

any understandable doc for this :(

rain heart
#

that the most understandable you could get

restive otter
#

Will help u

sullen nymph
#

What the fuck does it mean, "top.gg API"

#

It's not even official

#

You can literally use the official one just fine. Hell, express directly.

restive otter
#

Yup

#

its pretty easy to setup

misty meteor
#

New to API, Is there a way for testing votes, Because you can only vote once in 12 hours?

rain heart
#

use the test button

#

but it only tests your webhook

misty meteor
#

ty

balmy hamlet
#

wha-

restive otter
#

how do i trigger when a member vote
with top.gg/sdk

rain heart
#

using webhooks

restive otter
#

hey guys for some reason my code is not working

#

i am using python and using webhooks frm top.gg api

#

i am trying to reward my users for voting

rain heart
#

have you tested your webhook using reqbin

restive otter
#

s

#

and didnt work

night ingot
#

It'll be hard to tell what's wrong without seeing your code

restive otter
#

hmm

#

okay letme send

#
os.system("pip install dblpy")
import dbl
import discord
from discord.ext import commands


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

    def __init__(self, bot):
        self.bot = bot
        self.token = os.environ.get("dbltoken") 
        #self.dbl = dbl.DBLClient(self.bot, self.token, autopost=True) 
        url = os.environ.get("dblurl")
        auth = os.environ.get("dblauth")
        self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path=url, webhook_auth=auth, webhook_port=5000)

    async def on_guild_post():

        print("Server count posted successfully")
        #channel = bot.get_channel(825627974720159774)
        #await channel.send("Server count posted successfully")

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print("Received an upvote:", "\n", data, sep="")
        #print(data)
        channel = self.bot.get_channel(825627974720159774)
        await channel.send(data)
        user = data['user']
        embed = discord.Embed(description="New Vote! Voter: {}".format(user))
        await channel.send(embed=embed)
        
    @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."""
        #
        #try:
        print("Received a test upvote:", "\n", data, sep="")
        channel = self.bot.get_channel(825627974720159774)

          
        await channel.send("Received a test upvote:", "\n", data, sep="")
        #except:
          #await channel.send("Received a test upvote:", "\n", data, sep="")
          
    @commands.command()
    async def dbl(self,ctx):#,data):
      #C!exec import dbl
      dbl = self.bot.get_bot_votes()
      #dbl =data
      print(dbl)
      await ctx.send(dbl)

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

this is my code

restive otter
rain heart
#

thanks

restive otter
#

ik how to use

rain heart
#

what is dblurl in your env

night ingot
restive otter
#

idk i thought its supposed to confidential

night ingot
#

There's no reason to hide the path

restive otter
#

okay is server channel i created a webhook

night ingot
#

You can't use Discord webhooks for this

rain heart
#

you cannot use discord webhooks

restive otter
#

and then i use the webhook for url

#

oh

#

no wonder

rain heart
#

re-read the docs

restive otter
#

hmm okay

spice helm
rain heart
#

Though they seem to actually want to reward users using it

#

oh wait lol that's new

#

didn't see that landing page yet

restive otter
#

hmm then wut is this

rain heart
#

You cannot use discord webhooks

restive otter
#

the webhook url is not the discord one?

night ingot
#

The url would be
http://<your public ip>:<port>/<webhook path>

rain heart
#

that is a discord webhook

spice helm
#

You need a custom one i think

restive otter
#

public ip?

night ingot
#

Yes, the public IP of your network

restive otter
#

huh

#

wut is that

night ingot
restive otter
#

i have heard of ip addresss

spice helm
#

Hmm, do you have a static IP or dynamic?

restive otter
#

but i dont rlly know

night ingot
#

Well you should probably read into webhooks a bit more then

spice helm
#

Or a server you can expose to the internet? Like a VPS?

restive otter
#

telling me its a current ip iddress

#

is it mine?

night ingot
#

That would be your public IP, yes

restive otter
#

i c

night ingot
#

And then you need to open the port you want to use through port forwarding

restive otter
#

wut shld i put

#

this is wut i got

night ingot
#

Don't share your public IP

restive otter
#

oh