#topgg-api

1 messages · Page 107 of 1

restive otter
#

yea but i have a python bot that is supposed to run a command if someone hasvoted

regal fjord
restive otter
#

i have see nthat library

#

but that is only for bots.

#

i will try flask

regal fjord
restive otter
#

@regal fjord so now how do i import "top.gg" because the example is only of "django"

regal fjord
#

Try just googling how to setup a flask webhook or something

#

I can’t hold your hand, when you want to accomplish a task try doing it, I’ll be here for when you don’t know how to solve a problem on your own

sullen nymph
#

@regal fjord @oAura#2985 I'd suggest Sanic or aiohttp.web for async webhook

#

Okay

fiery shadow
#

he left 😎

steep pier
#

what is the use of the dbl api?

hollow forum
#
1. POST server count
2. GET bot info, server count, upvote info
3. GET all bots
4. GET user info
5. GET widgets (large and small) including custom ones. See top.gg/api/docs for more info.
6. GET weekend status
7. Built-in webhook to help you handle top.gg upvotes
8. Automated server count posting
9. Searching for bots via the API
steep pier
#

oh cool

signal pendant
#

why does this code not work GWseremePeepoThink ```py
@world.event
async def on_dbl_vote(data):
"""An event that is called whenever someone votes for the bot on top.gg."""
print(data)

#

i have dbl installed and imported

#

provided the token

#

yet this event is never called when i vote for the bot

#

world is an alias for a custom discord bot client

clear shale
#

dragon ball legends@??@?@!@?@?@?

signal pendant
#

?

rapid kettle
#

@signal pendant is your bot approved?

signal pendant
#

yes

fast spruce
#

Its my bot @rapid kettle @restive otter

signal pendant
#

im helping @fast spruce with bot dev

rapid kettle
#

oh ok

fast spruce
#

I gave them api-key

rapid kettle
#

the code looks like it should work but i dont python

#

where are you hosting?

signal pendant
#

wdym

rapid kettle
#

wheres the bot hosted

signal pendant
#

on my laptop

rapid kettle
#

ok so

#

is the port forwarded?

signal pendant
#

i don't follow 😕

rapid kettle
#

your port needs to be forwarded through your router

signal pendant
#

how would i do that and how relevant is it?

rapid kettle
#

its usually in the router settings (generally hosted on 198.196.1.1)

#

No port forwarding
Your server /// Router <--- top.gg server
The router doesn't know where to put it

Port forwarding
Your server <--- Router <--- top.gg server
The router knows where to put it

fast spruce
#

wot.

hot axle
#

u the one who sending the data?

#

Uhh is it using a json parser

fast spruce
#

why am i getting this error

hot axle
#

Whats ur code

rapid kettle
#

@restive otter are you using a json parser?

#

<app>.use(<express>.json())

hot axle
#

Oh lmao

#

Makes sense

rapid kettle
#

👍

#

it'd be best doing the latter

#

you can still check individual votes but you might get rateliimited

night fern
#

code:-

    async def topic(self,ctx):
        vote = dbl.DBLClient.get_user_vote(self,user_id=ctx.author.id)
        if vote == True:
            await ctx.send (random.choice(topic))
        else:
            await ctx.send ("In order to use that command, you need to vote me")```
this error comes up:- 
```RuntimeWarning: coroutine 'DBLClient.get_user_vote' was never awaited
  ret = await coro(*args, **kwargs)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback```

and when i put await before dbl.DBLClient this error comes up:-
```Command raised an exception: AttributeError: 'Fun' object has no attribute '_ensure_bot_user'```

I'm new in this can anyone help me
#

when i put this in TopGG class same error comes

worn marsh
#

Hello, I have put a script so that in top.gg my bot is displayed on the servers that it is, I followed it with the letter as the documentation said but ..

fast rose
#

for the python lib, should the decorator for on_dbl_vote be @commands.Cog.listener() or @commands.event()?

chrome raft
#

c

#

#credit

sullen nymph
#

@fast rose the former

#

@night fern you need to initialize the DBLClient by calling it with proper arguments

restive otter
#

how can i do the vote function?

full jungle
#

x!backup load 41ftwkmsc3

restive otter
#

@sacred shell

#

@dense compass

#

for fucks sake

dense compass
#

Nicu

restive otter
#

ty timoh

queen lotus
#

how can I run dblwebhook on express router?
Mention me

modern dagger
#

Hi

jagged pine
#

@queen lotus you wanna receive webhooks with express?

still dust
#

what should I put in webhookPort? And also, if I'm using both webhooks and posting server count should I make two different DBLs or do I just make one with webhook and client data together? If you know what I mean

jagged pine
queen lotus
#

you wanna receive webhooks with express?
yes but on router

jagged pine
#

what do you mean with router?

queen lotus
#

its like express() just another

jagged pine
#

idk then

#

you simply set up a webserver and listen for POSTs on a route

queen lotus
#

ok

fast phoenix
#

-bot

violet spoke
#

where can I get a sample of what the webhook is gonna send me?

austere swallow
#

you can use the test command, then log it in your bot

#

if not, the specifications are provided on the docs page

violet spoke
#

you can use the test command, then log it in your bot
@austere swallow yeah I already have the thing in my bot

#

but i'll have to do print(data) and then delete the files from my vps and then upload it again and then run the bot again.

#

it's kinda of a hassle

#

lol

austere swallow
violet spoke
#

k

austere swallow
#

go to the section under data format

violet spoke
#

isn't there a parameter for total upvotes the bot has?

#

I guess I'll just have to retrieve that from the url ig

austere swallow
#

thats the api

#

not the webhook

violet spoke
#

ok

violet spoke
#

what's the url for getting upvote count?

sullen nymph
#

/api/bots/<id>

violet spoke
#

is there a way to get the upvote count?

#

I don't see a json parameter for it

fast rose
#

My code ```py
class topGGVoteHandler(commands.Cog):
"""some bot owner utils"""
def init(self, bot):
self.bot = bot
self.session = aiohttp.ClientSession()
self.dblpy = dbl.DBLClient(self.bot, "token", webhook_path="/dblwebhook", webhook_auth="auth", webhook_port=5000)
self.users_who_voted = []
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print(data)
@commands.Cog.listener()
async def on_dbl_test(self, data):
print(data)

doesn't work
#

I have the correct auth, token, and webhook address

#

and I don't get any errors

violet spoke
#

what did you put for you webhook url in your edit page

fast rose
#

the rest of my ip address is just blocked out for obvious reasons

violet spoke
#

and it doesn't print it?

fast rose
#

no

violet spoke
#

the code looks good to me

#

When I did it, I didn't put self.users_who_voted = []

#

but that's probably not why it doesn't work

fast rose
#

haha it works now
just shut down my bot & restarted it

violet spoke
#

is there a way to get the total upvotes a bot has?

sullen nymph
#

Using dblpy?

violet spoke
#

yeah ig

#

or if there is another way

sullen nymph
#

get_bot_info, returned_value["points"]

violet spoke
#

ok

sullen nymph
#

Directly accessing the API, /api/bots/<bot_id>, parse the response as JSON, get the points key

violet spoke
#

k

#

so I can do that by using aiohttp right?

sullen nymph
#

Yeah

violet spoke
sullen nymph
#

You need to use an Authorization header with your top.gg token

violet spoke
#

so like https://top.gg/api/bots/707641033210593351/authorization:token?

sullen nymph
#

Header, not query param

violet spoke
#

oh

sullen nymph
#

in aiohttp.ClientSession().post it's the headers dict param

violet spoke
#

ok

sullen nymph
#

... or .get, same thing in both any case

violet spoke
#

I have async with aiohttp.request("GET", URL) as response:

#

so do I do headers="token"

#

or something like headers="authorization:token"

sullen nymph
#

headers={"Authorization": "efgkhweh.qweq.qw.gerg"}

violet spoke
#

oh ok

violet spoke
#
    URL = "https://top.gg/api/bots/707641033210593351/"
    async with aiohttp.request("GET", URL, headers={"Authorization":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjcwNzY0MTAzMzIxMDU5MzM1MSIsImJvdCI6dHJ1ZSwiaWF0IjoxNjAxODUzODcxfQ.hh9qb77x9N5vZLggvp2p7zs4joQ6NRF9whQ79_pKgpw"}) as response:
        if response.status == 200:
            json_data = await response.json()

            text_data = await response.text()

            index = random.randint(0, 100)

            upvotes = json_data["points"]

            print(upvotes)
```This is my code but it prints `320`
#

my bot has 20 upvotes

sullen nymph
#

points is total, monthlyPoints is monthly

#

monthly is what you see on bot page

violet spoke
#

oh

#

so is monthlyPoints a parameter in the JSON?

sullen nymph
#

a key in the response JSON

violet spoke
#

k

#

yeah that's what I meant

violet spoke
#
    @commands.Cog.listener()
    async def on_dbl_test(self, data):
        channel = self.bot.get_channel(764951115262853120)
        user_id = int(data['user'])
        user = await self.bot.fetch_user(user_id)

        URL = "https://top.gg/api/bots/707641033210593351/"
        async with aiohttp.request("GET", URL, headers={"Authorization":""}) as response:
            if response.status == 200:
                json_data = await response.json()

                text_data = await response.text()

                index = random.randint(0, 100)

                upvotes = json_data["monthlyPoints"]

        embed = discord.Embed(
            colour=discord.Colour.dark_gold(),
            title=f"Test | {user}",
            description=f"{user.mention} thank you for upvoting Ξ X 0 on top.gg! We now have a total of {upvotes} upvotes!",
            )
        embed.set_footer(text="Note: This is a test")
        await channel.send(f"{user.mention}", embed=embed)
sullen nymph
#

leaking your token

#

blurring it out in the screenshot but not in the code where I can straight up copy it

violet spoke
#

I forgot about it in the code

#

I'll reset my token

sullen nymph
#

mhm

violet spoke
#

do you know why it says aiohttp is not defined?

#

I have aiohttp installed but it's still saying that for some reason

sullen nymph
#

did you import it

violet spoke
#

bruh i'm so dumb

#

i forgot to import it

#

lol

sullen nymph
night fern
#

can someone show me a example of voter only command as im facing errors in my code

grave current
#

idk any

#

lolololol

#

lolololololol

violet spoke
#

can someone show me a example of voter only command as im facing errors in my code
@night fern you can use the API to get a list of members that voted for your bot (if you get over 1000 upvotes per month, you'll have to use webhooks). With the list of voters, you can iterate through them and find if a specific user is in the list of voters. Or you can use on_dbl_vote and then put the users id in a database and then search the database for the user. There are a lot of ways you can do a command for voters only.

violet spoke
#
            if response.status == 200:
                json_data = await response.json()

                text_data = await response.text()

                upvotes = json_data["monthlyPoints"]

        embed = discord.Embed(
            colour=discord.Colour.dark_gold(),
            title=f"Test | {user}",
            description=f"{user.mention} thank you for upvoting Ξ X 0 on top.gg! We now have a total of {upvotes} upvotes!",
            )
        embed.set_footer(text="Note: This is a test")
        await channel.send(f"{user.mention}", embed=embed)
````local variable 'upvotes' referenced before assignment`
#

should I indent the embed to be inside if response.status == 200?

sullen nymph
#

yeah

restive otter
#

how does it work 🤔

#

what should the webhook be

jaunty plank
#

http://ip:port/path

#

fill in ip port and path with your info

restive otter
#

path?

#

wait oh

#

so i need to use one of the libraries? i don't know how to program on any of these [python/javascript/c#/java]

sullen nymph
#

Well, it's a thing of convenience, not forcing you to use one of them

jaunty plank
#

you can make a webhook server if you want

restive otter
#

alright

timber warren
#

Good

night fern
#

@violet spoke can you please show one example of get_user_vote python

hoary urchin
#

hewo, i want to ask someting

#

const id = '';

#

what id?

noble iron
#

...

#

your bot id?

hoary urchin
#

well, thanks, i'll try that

stone sierra
#

Why is the dblapi.js npm package marked as deprecated from 2.4.0 on?

#

please ping me with the answer

finite moat
#

For it to publish my bot server count do I have to run in terminal

#

Or is it automatic

silver kelp
#

That’s what the API is for

#

Do you know how to send HTTP requests through what ever language you are using?

restive otter
#

Why is the dblapi.js npm package marked as deprecated from 2.4.0 on?
@stone sierra they did some major changes to stuff with the API iirc
maybe that's why

stone sierra
#

Yes, but what do I have to use then?

restive otter
#

Normally use the API without the wrapper

sudden sable
full walrus
#

@sudden sable read above messages

violet spoke
#

@violet spoke can you please show one example of get_user_vote python
@night fern I don't know what language you are using so I can't really show you one

night fern
#

@violet spoke python smh

#

btw is it important to use close()

sullen nymph
#

Not really.

#

I don't provide it in examples. Feel free to use it whenever attempting to recreate the same DBLClient instance with same arguments (e.g. webhooks)

#

Generally things are closed on bot shutdown

night fern
#

ive figured out somemore of the get_user_vote code but now its preventing the cog from being loaded and saying unclosed client session

#

even after i use close() thing

sullen nymph
#

I assume you're using autoposter

night fern
#
        print(vote)```
#

and some more self arguements in starting

sullen nymph
#

Dear lord no

night fern
#

lol this is my first time doing this thing

sullen nymph
#

eh I don't see the point in using .close at all

#

Initialize an instance of DBLClient in the cog init and use that instead

night fern
#

i was testing if it works there

restive otter
#

on dbl vote wasn't printing anything/ send a dm

async def on_dbl_vote(self, ctx, data):
        print("Received an upvote:")
         await ctx.author.send(f"hey {ctx.author.name}, thanks for voting!")
    ```
sullen nymph
#

There's no ctx in DBL votes

restive otter
#

then how do I send a dm?

sullen nymph
#

access the user key in data, convert it to integer, get user for that ID, send message

restive otter
#

like this?


async def on_dbl_vote(self, data, user: int):
      try:
        print("Received an upvote:")
        voted = int(data.keys(user))
        voted_users = bot.fetch_user(voted)
        await voted_users.send(f"hey {ctx.author.name}, thanks for voting!")
sullen nymph
#

int(data['user'])

#

get_user()

#

but yeah

pearl ibex
#

Can someone help me im getting a 503 Backend fetch failed error

rapid kettle
#

That’s a server side error

pearl ibex
#

Do you know how can i fix it? I havent gotten a error like this in the past so i have no idea whats wrong

rapid kettle
#

A server side error

#

It’s not an error on your side

#

an error on dbl’s side

pearl ibex
#

Weird

sullen nymph
#

-api

abstract mothBOT
#

TOP.GG API ONLY!!!
ANY OFF-TOPIC CONVERSATION WILL BE DELETED AND MUTED
This channel is only for SUGGESTIONS/HELP/BUGS to do with OFFICIAL API LIBRARIES and API DOCS found at: https://top.gg/api/docs

trim glade
#

is there a way to get votes from a server with a bot?

#

I've looked over the docs and there doesn't seem to be

rapid kettle
#

Only with a webhook

trim glade
#

can you send the doc page for that?

rapid kettle
#

There isn’t one

#

basically

#

it sends a POST request

#

and Authorization header contains the auth you set

trim glade
#

kk ty :)

subtle flax
#

Hi

latent slate
#

Hi

dire zephyr
#

Hi, where do I get DBLToken?

jaunty plank
#

you get one when you have a verified bot

dire zephyr
#

So basically if I want to get response when someone votes for my discord server I need a bot there registred as well, right ?

scarlet cobalt
#

One message removed from a suspended account.

#

One message removed from a suspended account.

dire zephyr
#

Yeah exactly, I'm new to this and I don't wanna be spoon feeded but how do I handle 'vote' event when someone votes for my server ?

regal fjord
#

you need to set up a webhook, basically an end-point hosted somewhere to accept vote data.

#

So everytime someone votes, top.gg posts that data to the webhook, with the Id of whoever voted, what time, etc

dire zephyr
#

Thanks

granite ore
#

what do i do

#

there

grim anchor
#

How could I make a vote commands using this? Like what is the structure to use this: get_user_vote(user_id: int)

jaunty plank
#

like vote for the user?

#

@granite ore the url is the url to your webhook server(wherever your running the code)
the auth is the auth you are receiving

granite ore
#

@jaunty plank is the url like an actual url or like 123.456.7.8

jaunty plank
#

if you have a domain you can use one
or the ip works just as well

#

http://ip:port/path
works

granite ore
jaunty plank
#

yeah repl it urls work iirc

granite ore
#

ok thx

#

it didnt work

jaunty plank
#

you need the path

#

and the port

granite ore
#

thats what i put

#

@jaunty plank

jaunty plank
#

should delete that ip leak

#

the repl url is fine, just with the port and path

granite ore
#

its not my real ip

#

i modified it

#

ok

#

IT Didnt work

jaunty plank
#

does replit give you port 5000?

granite ore
#

oHHHHHHH

#

ok

#

thanks

#

ok well it still didnt work lolo

#

i think repl is different from repl.it

violet spoke
#

try port 80

granite ore
#

just 80

#

ok

#

it didnt work

restive otter
#

code not working

 
self.dblpy = dbl.DBLClient(self.bot, self.token,  webhook_path='https://discord.com/api/webhooks/766856937542385695/zldM***', webhook_auth='password', webhook_port=5555 , autopost=True)
jaunty plank
#

you cannot use a discord webhook

restive otter
#

wym?

#

oh

#

how can I create a dbl webhook?

restive otter
#

@restive otter You need an HTTP server listening for POST requests to the /dblwebhook route

sullen nymph
#

@granite ore put repl.co link and use port 8080

dire sand
#

Is there a good module on PyPi for that?

sullen nymph
#

-servercount

abstract mothBOT
#

To have your bot's server count displayed on DBL, please read the documentation on server/shard posting. Click here to see the docs.. You may also find #312614469819826177 useful; however it is strongly discouraged as most of the examples are extremely outdated.

dire sand
#

Ok

#

The Python lib for auto server count keeps giving me this "Method has no argument" error or whatever

sullen nymph
#

Show full traceback please

dire sand
#

Ok

#
    "resource": "/c:/Users/lpkea/moderatus/classic/cogs/owner.py",
    "owner": "python",
    "code": "no-method-argument",
    "severity": 8,
    "message": "Method has no argument",
    "source": "pylint",
    "startLineNumber": 33,
    "startColumn": 5,
    "endLineNumber": 33,
    "endColumn": 5
}```
Hmmm
quiet aurora
#

-help

restive otter
#

like this?

self.dblpy = dbl.DBLClient(self.bot, self.token,  webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5555 , autopost=True) 
full walrus
#

@sullen nymph ^

#

He deleted (or a mod)

sullen nymph
#

Yeah I did

restive otter
#

How to get my vote used print in discord

#

@sullen nymph

sullen nymph
#

Use a webhook and send messages to Discord on votes

restive otter
#

How to bro

#

Give me any screenshot bro

sullen nymph
#

What's the library you use for your bot

restive otter
#

Py

sullen nymph
#

Use dblpy catshrug

restive otter
#

Ok

fossil stream
#

Hi. I was wondering what was the criteria for accepting bots on top.gg?

restive otter
#

Can you change my nickname

#

Please

sullen nymph
#

Hi. I was wondering what was the criteria for accepting bots on top.gg?
@fossil stream see #rules-and-info

fossil stream
#

I have a bot that I am very proud of which should be finished in a few weeks. Would it be alright if I submit it for review now, because it's going to take a while for it to reach the end of the queue?

sullen nymph
#

Sure, 7-8 weeks is plenty of time

fossil stream
#

Awesome, thanks shivaco.

sullen nymph
#

did you enter that in the webhook_path arg

restive otter
#

yes

sullen nymph
#

it's the thingy after the domain

#

webhook_path stays /dblwebhook

restive otter
sullen nymph
#

404 is no

#

so

restive otter
#

🤔

sullen nymph
#

set webhook_path to /dblwebhook

restive otter
#

ok

sullen nymph
#

Restart the repl and try it

restive otter
sullen nymph
restive otter
#

changed the webhook to
'http://127.0.0.1:5000/dblwebhook'

granite ore
#

@granite ore put repl.co link and use port 8080
@sullen nymph ok

restive otter
#

:k3llyhmm:
@sullen nymph what?

#

my bot just approve and now what to do here with the api thing

#

please tell me

#

pls give a best website for my vote webhook

jaunty plank
#

you make the webhook yourself or with one of the libraries

#

no need for another website

restive otter
#

@jaunty plank where do i put it

#

create a new file or in main.js

jaunty plank
#

either one, it would be better as an export in its own file imo, but thats up to your own workflow

restive otter
#

imma create new one

#

imma put it in handlers/ready.js

#

@jaunty plank where do i get the top.gg token

jaunty plank
restive otter
#

they key thing?

#

it said it too long

jaunty plank
#

what said its too long

restive otter
#

it just said like thus

#

thi

#

this

#

cant see anything

#

my eyes are sleepy

jaunty plank
#

""

restive otter
#

nvm

#

i change it to ``

#

it still not work when i put ""

#

KJJIKKHWXJBJYJAS

#

i got so many error

#

i need webhook.js and vote.js

#

how to setup api, webhook, vote thing

#

my mind are blown

jaunty plank
#

the docs do a decent job of explaining it

restive otter
#

im having a brain problem

#

everytime i got error

#

it my discord application token

#

or api key

jaunty plank
#

dbl token

restive otter
#

kk

#

im copying every examples in docs and paste them

#

cause i have no time

#

im about to sleep

granite ore
#

@granite ore put repl.co link and use port 8080
@sullen nymph it didnt work

#

v

sullen nymph
#

host the webhook on port 8080 but don't specify it in the URL

granite ore
#

huh

#

ok

#

it was a 404

sullen nymph
#

webhook_path set to /TopGG?

granite ore
#

yea

#

i changed it to /dblwebhook

#

and it still didnt wokr

#

*work

sullen nymph
#

wtf

jaunty plank
#

repl it would 404 an unknown path too right?

#

even if you dont have an http server

granite ore
#

wdym

jaunty plank
#

just saying 404 doesnt really mean anything on that platform.

#

atleast as far as setting things up right

granite ore
#

but it didnt print anything

jaunty plank
#

exactly

granite ore
#

w h a t

main venture
#

i want to make, so when user votes for my bot in top.gg the bot gives him a special role in bot support server. does beggining of a code looks alright? discord.py

 async def on_dbl_vote(self, data):
        data = int(data.user)
        guild = Bot.get_guild(id)
        topggbot = Bot.get_user(id)
        role = discord.utils.get(guild.roles, name='name')
granite ore
#

bot.get_guild doesnt exist

#

use discord.utils.get(bot.get_all_guilds(), id=id)

main venture
#

Oh

#

Thx :D

#

Lmao, my stupid mistake

#

Wait

#

It exists

granite ore
#

and also for users its the same

#

wait rlly

main venture
#

...

granite ore
#

lmao idk that sorry

main venture
#

Ok oof

#

Wait

#

Is it data.user?

#

i want to make, so when user votes for my bot in top.gg the bot gives him a special role in bot support server. does beggining of a code looks alright? discord.py

 async def on_dbl_vote(self, data):
        data = int(data.user)
        guild = Bot.get_guild(id)
        topggbot = Bot.get_user(id)
        role = discord.utils.get(guild.roles, name='name')

pls help

sullen nymph
#

data["user"]

main venture
#

data["user"]
@sullen nymph
so data = int(data[“user”])

#

Sorry for being dump

sullen nymph
#

eyes

main venture
#

I will try this, thx

#

Hmm

#
async def on_dbl_vote(self, data):
        data = int(data[“user”])
        guild = Bot.get_guil(id)
        topggbot = Bot.get_user(id)
        role = discord.utils.get(guild.roles, name='name')
        if guild == None:
            return
        elif guild.get_member(data) and guild.get_member(topggbot):
            if role == None:
                return
            elif role in member.roles:
                return
            elif not topggbot.guild_permissions.manage_roles:
                return
            await data.add_roles(role)
#

So this must work...

sullen nymph
#

guild not guil

#

are you sure it's Bot and not bot

#

or whtever

#

What is defined as id

main venture
#

My Client = Bot in my case :)

sullen nymph
#

data is a dict and get_member only takes int IDs

main venture
#

guild not guil
@sullen nymph
I turned my pc off, it’s hard to edit the code with mobile

sullen nymph
#

I'm pointing out the issues

main venture
#

Wait

sullen nymph
#

You can edit them later

main venture
#

But data is int

sullen nymph
#

data is a dictionary unless you're emitting the event yourself somehow

main venture
#

Ohhhh

#

So data = int(data[“user”]) is incorrect

#

As it won’t convert into int

sullen nymph
#

it is correct

main venture
#

🤔

sullen nymph
#

data is a dictionary and you get a key

#

and convert it to int

main venture
#

Oh, so everything is fine, as the line does it.

#

Thx a lot 🙏🏻

#

Really helped me :)

#

I will edit the code tomorrow, when I use PC

spice rapids
#

hello
can someone help me with the dblpy module
I am not sure how to make something get called when someone votes for my bot
btw I do not use cogs for my bot```python
class TopGG(commands.Cog):

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='password', webhook_port=5000)

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


    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))```
I am not sure exactly what to put instead of DBL token
and if I have to call these functions somewhere
like setup

#

is there any way to do this without cogs

restive otter
#

p supertramp ain't nobody but me

night fern
#

@spice rapids im not a pro in dbl module but as of dbl token u can get it in website, click on edit option in ur bot and on left there are 4 options and one of them has dbl token generator

#

and itll be kinda messy if u dont use cogs for this one

#

u gotta remove whole def setup at last, commands.cog after class, and replace @commands.Cog.listener() with @bot.event

#

and if u using @tasks.loop then no need to use asyncio i guess

#

and much more

#

which idk how to setup for main file

sullen nymph
#

Fucking Christ

#

You don't use asyncio.sleep with tasks.loop

night fern
#

wont give any error though weirdsip

sullen nymph
#

Pointless and may cause unintended behavior

night fern
#

indeed

main venture
#

My on_dbl_vote doesn’t work ;(

dense basalt
#

We need a bit more info than that to help

#

Show your code, show the errors you're having, etc..

main venture
#

One second, I am pasting the code...

#

Sorry for being dump or smth.

#

I am 99% sure I am just too dump to understand python, I am like sure I have some stupid mistakes there.

#

OHHHHH

#

Wait

main venture
#

Guys

sullen nymph
#

add cog listener decorator to on_dbl_vote

#

actually initialize the webhook by setting the webhook arguments

main venture
#

Webhook_path is...

#

What lol XD

sullen nymph
#

leave it so that it's set to /dblwebhook by default

main venture
#

add cog listener decorator to on_dbl_vote
@sullen nymph
Is it not optional?

#

Oh ok

sullen nymph
#

Cog listener decorator isn't optional

main venture
#

K thx

sullen nymph
#

discord.py doesn't just assume any function name of which starts with on_ is an event

main venture
sullen nymph
#

P.S. the very bare minimum for the webhook to start is to set webhook_port

#

also

#

wtf

#

from cogs.Variables.Prefix import Bot why is this there

#

use self.Bot, not Bot

main venture
#

Oh it’s...

sullen nymph
#

you are importing a class, not an instance

main venture
#

I define after self.Bot = Bot

sullen nymph
#

you don't need that import there

main venture
#

Oh ok

#

Sorry for being that dump

#

I feel so stupid right now XD

sullen nymph
#

also on_dbl_vote only takes data argument but since it's a cog listener (in a class), it must have self as first parameter

#

there's no "bot" object being passed to the function

main venture
#

Yeah, ok :)

sullen nymph
#

aka it's on_dbl_vote(self, data)

main venture
#

Also

#

So I should set up my webhook in Heroku

sullen nymph
#

Why?

main venture
#

Oh XD

sullen nymph
#

If you have a VPS, you can set up a webhook

main venture
#

Well, it’s not vps, so there is no need to

#

Thx a lot :)

#

Sorry for wasting your time

#

I am being dump

sullen nymph
#

catshrug it's fine

main venture
#

I am okeh

restive otter
#

wheres the api?

#

so when we listen to on_dbl_vote(self, data), does it automatically detect new votes?

rapid kettle
#

No

#

You need to setup a webhook

#

and set it up on the page

restive otter
#

is there any docs for that

sullen nymph
main cradle
#

wheres the api?

#

btw I do not use cogs for my bot

#

hello
can someone help me with the dblpy module
I am not sure how to make something get called when someone votes for my bot
btw I do not use cogs for my bot

obtuse roost
#

@main cradle ^

restive otter
#

hi, i have an idea on creating a reward for those people who vote the server, then what command do i have to make?

golden adder
rapid kettle
#

You need to use a webhook

golden adder
#

You'll get a link to the api docs

rapid kettle
#

unless it’s role rewards

restive otter
#

ok

#

i see

#

thanks

#

i dont understand

#

can you explain with the code

#

i dont understand

golden adder
#

The docs are pretty easy to follow. What language are you using?

#

@restive otter

restive otter
#

javascript

#

@golden adder

golden adder
#

Go down to "Webhook events"

restive otter
#

ok

golden adder
#

The example code is in the docs

restive otter
#

tysm

#

it is working

#

thanks

golden adder
#

Awesome

#

Np

restive otter
#

@golden adder but an error has occured

#

where i find dbl api key something

golden adder
#

On your bot's page. Click "edit" go to "Webhooks" tab on the side @restive otter

restive otter
#

ok

#

then

obtuse roost
#

Can anyone please explain me about Authorization process please

jovial kiln
#

What is the webhookport and webhook auth?

patent lintel
#

What is the name of the file that DBL requests the webhook?

#

is it request.json?

jaunty plank
#

the file it requests?

patent lintel
#

yeah

#

like request.json or what? it says that it isnt that

jaunty plank
#

i dont understand the question, the webhook is sent to your webhook server. it doesnt look for a request.json

patent lintel
jaunty plank
#

Not in a file, just in the body of the post request

patent lintel
#

oh ok i did some more research and i get it now

jovial kiln
#

Confusing at first but the nice you figure it out it is easy

patent lintel
#
   File "/app/app.py", line 126, in respond
     if data['Authorization'] == 'my_auth':
 KeyError: 'Authorization'``` why am i getting this?
sullen nymph
#

Oh yeah

#

no wait

#

wtf are you doing

#

What's data?

#

The Authorization is in the request headers

patent lintel
#

oh ok

#
    data = request.json
    print(data)
    return Response(status=200)```
and it returned `{'bot': '748670819156099073', 'user': '697628625150803989', 'type': 'test', 'query': '?test=data&notRandomNumber=8', 'isWeekend': True}` so how am i supposed to see the auth? i dont get it
rapid kettle
#

It’s in the headers

uncut verge
patent lintel
#

you need to like have a website

jaunty plank
#

not true

#

you can use your public ip

patent lintel
#

that too

jaunty plank
#

http://ip:5000/dblwebhook

uncut verge
#

So I should start a web server?

#

with express

jaunty plank
#

the library is making a webserver and starting it

restive otter
#

Hello, I want to make a command. When I vote with dbl, it will send a message to the specific channel without using the command.

I didn't do it I would be very happy if you could help from dm

patent lintel
#

http://ip:5000/dblwebhook
@uncut verge do that, ur ip address goes in ip

restive otter
#

Hello, I want to make a command. When I vote with dbl, it will send a message to the specific channel without using the command.

I didn't do it I would be very happy if you could help from dm

google translate is used

patent lintel
#

@restive otter its kinda complicated

#

well it is complicated just to explain

restive otter
#

well can you help

jaunty plank
restive otter
#

just send the command 🙂

jaunty plank
#

the docs have the code for the libraries

#

theres a bunch of libs, so i cant just send code

patent lintel
uncut verge
#

@uncut verge do that, ur ip address goes in ip
@patent lintel I am using repl.it to work on the bot and they provide a domain,

restive otter
#

just send the code 🙂

jaunty plank
#

you can do it with your repl domain

patent lintel
#

yeah

jaunty plank
#

what lib/language @restive otter

restive otter
#

js

jaunty plank
patent lintel
#

^

restive otter
#

thank

patent lintel
#

also i dont get how to access authorization header in python

jaunty plank
#

what lib are you using?

uncut verge
jaunty plank
#

yeah looks right to me

uncut verge
#

Nothing is happening when I vote thou

jaunty plank
#

not sure what ports repl allows

uncut verge
#

hmm, ill check

jaunty plank
#

so you might wanna look at their docs

uncut verge
#

How would I know if it is working?

#

Cause I already used my vote

patent lintel
#
from Flask import from flask import Flask, request, Response
#Some Code and setup stuff
@app.route('/webhook', methods=['POST'])
def respond():
    data = request.json
    if data["Authorization"] == "geronimostilton12":
        print('I got a vote from ' + data["user"])
    return Response(status=200)```
And `data["Authorization"]` doesn't return the auth.
jaunty plank
#

test button on your bots page @uncut verge

#

"request.headers.get('your-header-name')"

uncut verge
patent lintel
#

now it tested

uncut verge
#

so did it work then?

restive otter
patent lintel
#

see ur thing

#

like what does your webhook do?

restive otter
#

please can you vote? i want to try

#

Does anyone code in Python?

uncut verge
#

listen for votes

jaunty plank
#

use the test button @restive otter

restive otter
#

Does anyone code in Python?

#

Does anyone code in Python?

uncut verge
#

STOP FLOODING CHAT

patent lintel
#

pls stop spamming

restive otter
#

I didn't flood chat

jaunty plank
#

looked like discord lag

#

lol

restive otter
#

You dumbass

patent lintel
#
from Flask import from flask import Flask, request, Response
#Some Code and setup stuff
@app.route('/webhook', methods=['POST'])
def respond():
    data = request.json
    if data["Authorization"] == "geronimostilton12":
        print('I got a vote from ' + data["user"])
    return Response(status=200)```
And `data["Authorization"]` doesn't return the auth.
jaunty plank
#

its not in data

#

its in request.headers

restive otter
#

I want to use the command in the basement to see if it will work when you vote

patent lintel
#

oh ok

#

kool

#

thanks

#

@jaunty plank u should be mod

#

lol

jaunty plank
#

nah, mods have to do stuff

patent lintel
#

lol

#

ok

#

but ur smart so like

jaunty plank
#

theres way smarter people than me here

restive otter
#

Anyone codes in Python?

patent lintel
#

i do @restive otter

#

need help or something?

restive otter
#

Can you help me make a unban command for my mod not

#

Bot

#

?

jaunty plank
patent lintel
#

yeah

jaunty plank
patent lintel
restive otter
#

@patent lintel

#

dms

patent lintel
#

and also i dont do mod commands

uncut verge
#

If nothing happens does that mean the test failed?

#

I saw in the docs that test triggers the vote listener?

jaunty plank
#

well, it depends on what you set it to do

#

if you set tests to do nothing, it will do nothing

uncut verge
jaunty plank
#

it will log the vote then

#

no matter what

uncut verge
#

but nothing happens

jaunty plank
#

repl it right?

uncut verge
#

ye

jaunty plank
#

your setting it to port 5000?

uncut verge
#

I switched port to 5001

jaunty plank
#

on both the code and the top.gg url spot?

uncut verge
#

ye

jaunty plank
#

does repl it support 5001?

uncut verge
#

hmm, lemme try 3000 bc i know it supports that

jaunty plank
#

also, try making your link start with http:// rather than https://

#

i dont know how repl handles https

uncut verge
#

k

restive otter
#

Ew

sharp reef
#

Is there a ratelimit on the server count post?

lone bough
#

hey, not sure if this was already found but there's an mistake/typo in the api doc example (for python):
In the first example with automatic server count, on this part

async def on_guild_post():

it needs a self inside the () since it's inside a class

restive otter
#

R

sullen nymph
lone bough
#

yeah

sullen nymph
#

Mhm, admins are aware

#

Docs are planned to be reworked so that'll stay there for a while I believe. Feel free to refer to the README on Github or dblpy.rtfd.io

lone bough
#

alright thanks :)

sullen nymph
restive otter
#

hello what do i see if my webhook is successfully working? im trying to test it first

nimble chasm
#

@jaunty plank

#

🙂

jaunty plank
#

means application programming interface

nimble chasm
#

what is api

#

oh....

jaunty plank
#

its how everything happens on the internet

nimble chasm
#

ah

jaunty plank
#

your bot uses the discord api to talk to discord servers

#

for example

nimble chasm
astral owl
#

hmm, lemme try 3000 bc i know it supports that
@uncut verge 3000 always worked for me hmm

restive otter
#

is it possible

#

to make the dbl ready event

#

inserted to another file instead of index.js?

molten lantern
#

Is making join for join possible?

willow spindle
#

Wdym @molten lantern

#

@restive otter of course

molten lantern
#

Example:Member+

sullen nymph
#

-api

abstract mothBOT
#

TOP.GG API ONLY!!!
ANY OFF-TOPIC CONVERSATION WILL BE DELETED AND MUTED
This channel is only for SUGGESTIONS/HELP/BUGS to do with OFFICIAL API LIBRARIES and API DOCS found at: https://top.gg/api/docs

molten lantern
#

Sorry

ember swan
#

where can i find my server's dbl ? and the webhookAuth pasword

hybrid charm
#

-help

ember swan
#

where do i put these command ?

restive otter
#

Wdym @molten lantern
@willow spindle how do u start on ready event in another file

rapid zealot
#

In an example, it says should use dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);, shouldn't i be using client.guilds.cache.size instead of client.guilds.size?

rapid kettle
#

yes

#

it’s just old

rapid zealot
#

same goes for the shards right

rapid kettle
#

yup

#

it’s now client.shard.ids and client.shard.count

rapid zealot
#

I'm getting the error ReferenceError: client is not defined at const dbl = new DBL('Your top.gg token', client);

#

and yes, i did replace the top.gg token with my token

#

nvm

#

it was in a seperate file without the require('discord.js')'s

restive otter
#

i am facing a issue. When i vote using my alt on my bot i see that when i try to see if the user voted api sends false as i voted it takes 5 mins before it actually sends true

uncut verge
#

Do you need a password for the webhook

uncut verge
#

What does this mean? (node:22) UnhandledPromiseRejectionWarning: Error: 401 Unauthorized

tribal halo
#

How do I solve the error No module "dbl" found?

jaunty plank
#

Py?

tribal halo
#

yes

jaunty plank
#

pip install dblpy
?
Hope that's it. Otherwise no idea

tribal halo
#

I have it installed... I am getting that error on Heroku

restive otter
#

is it possible
to make the dbl ready event
inserted to another file instead of index.js?

jaunty plank
#

Yes

uncut granite
#

Anyone knows how to setup a vote webhook for .Net?

jaunty plank
#

Could be a terrible guide, not a .net dev not sure

cinder locust
#

does anyone know how to add guildcount to bot like other ones have? like if you go on https://top.gg/list/top, then you can see that.. for example 'Dank Memer' has 3,602,011 servers. does anyone know how to do this?

jaunty plank
acoustic peak
#
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, autopost=True) # Autopost will post your guild count every 30 minutes

    async def on_guild_post():
        print("Server count posted successfully")

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

Does this only work if your bot uses cogs?

I've added it to my bot (one .py page) that doesn't use cogs, but it doesn't seem to update the server count (count still shows N/A)

jaunty plank
#

How long did you wait @acoustic peak ?
The websites are cached

cinder locust
#

ok.. so i see that in the javascript library, it shows the code

const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client);

// Optional events
dbl.on('posted', () => {
  console.log('Server count posted!');
})

dbl.on('error', e => {
 console.log(`Oops! ${e}`);
})

but why would you make a new client? do i just use the client i am already using? and which token do i use? the one that is attached to my bot?

jaunty plank
acoustic peak
#

How long did you wait @acoustic peak ?
The websites are cached
@jaunty plank I did it about 12pm, its 5pm now and still says N/A

jaunty plank
#

Is the print your doing printing from time to time? @acoustic peak

acoustic peak
#

let me check

cinder locust
#

ooh! it worked thank you @jaunty plank!

jaunty plank
#

Np

acoustic peak
#

@jaunty plank no output either

jaunty plank
#

Are you putting your top.gg token in the spot it asks for it?

acoustic peak
#

I have

cinder locust
#

does it post over and over, or just when i restart the bot? if it only posts when i start the bot, how can i make it so it posts when the bot joins or leaves a server?

jaunty plank
#

Over and over in 30 minute intervals iirc @cinder locust

cinder locust
#

awesome. thank you so much!

acoustic peak
#

but my bot is just a 1 .py file bot, the api part for the server count includes cogs

#

but my bot isn't build with cogs

jaunty plank
#

Honestly, im not a python dev.
Shiv will probably be on soon to help with this issue @acoustic peak

acoustic peak
#

Alright, thank you 🙂

teal kiln
#

Node.js:

how do i make the vote event, because i dont understand the code on the website

cinder locust
#

one last thing: to get an update when someone votes, what do i use for the password? the example gives this code:

const DBL = require('dblapi.js');
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});

up there where it shows '{ webhookPort: 5000, webhookAuth: 'password' }' what do i use for the 'password' part? do i leave it as is?

jaunty plank
#

Password can be whatever you want. Dont leave it as is however

teal kiln
#

and the port?

jaunty plank
#

You need to update the spot on your bots edit page where it asks for webhook url and path

#

Port is any available port you have

teal kiln
#

ok

jaunty plank
#

3000 or 5000 are typically available

cinder locust
#

what should i put for the webhook url? i dont own any websites, do i just choose a random thing?

teal kiln
rapid kettle
#

no

#

you use your VPS ip

cinder locust
#

ah ok

teal kiln
#

ill try it later

acoustic peak
#

@rapid kettle, Woo said you might be able to help lol

rapid kettle
#

sure

#

whatcha need

jaunty plank
#

This isnt actually shiv

#

Fake shiv

cinder locust
rapid kettle
#

yea

#

expected

cinder locust
#

ah ok i didnt know if it would keep that or say the path i put

jaunty plank
#

0.0.0.0 is just logged to all users. Just means whatever public ip

cinder locust
#

ohhh ok ok ok cool

acoustic peak
#

@rapid kettle

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, autopost=True) # Autopost will post your guild count every 30 minutes

    async def on_guild_post():
        print("Server count posted successfully")

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

Does this only work if your bot uses cogs?

I've added it to my bot (one .py page) that doesn't use cogs, but it doesn't seem to update the server count (count still shows N/A)

#

I added the code about 5 hours ago

#

but the website is still showing N/A

rapid kettle
#

idk

acoustic peak
#

okay

jaunty plank
#

This is a fake shiv. The moderator shiv is the one who made this library

sullen nymph
#

That was a good nap

#

@acoustic peak you don't specifically need a cog for dblpy, it's just that the example snippets do

acoustic peak
#

@sullen nymph ah right! That's probably why the snippet isn't work 😂

sullen nymph
restive otter
#

hello how to run the dbl event one time only when i use ->vote

#

cause everytime i send ->vote it runs again

golden adder
#

@restive otter what do you mean? The vote event only fires when there is a vote or if you test the webhook.

restive otter
#

the dbl event is tied to ->vote command

golden adder
#

Show us your code

#

You put this in a command?

restive otter
#

yes

golden adder
#

It goes in your index file

restive otter
#

all the dbl events goes into index file?

golden adder
#

Where you have client login

#

Yeah

restive otter
#

okay noted, thank you.

#

i have a prob

golden adder
#

See the pins here for examples

restive otter
#

in calling the documents in index file

#

so i thought it'll be possible to be tied in a command

#

mongodb documents **

#

i successfully set it up

#

just having problem in rewarding

golden adder
#

Oh

#

So the api is working for you?

restive otter
#

thanks for the note though

#

that it shouldnt be called in a command

#

my mistake

golden adder
#

👍

restive otter
#

if the api key binded to the application id cause my bot has a dev version and i dont wana upload that one to top.gg

golden adder
#

Is your dev version running off the same code but it's a different client? @restive otter

restive otter
#

well its running a diffrend js main file

#

and its ran locally rather then on the vps

golden adder
#

But it's a separate bot?

#

Different id?

restive otter
#

yes

#

client id is diffrend

#

but its the same bot just testing new features on it

golden adder
#

Just do something like

if (client.id === IDHERE) {
//dbl code
} ```
restive otter
#

i did

golden adder
#

Should be ok then

restive otter
#

so the token isnt connected to the clientid

#

good

golden adder
#

Yeah. It won't post because the client id is different. If you didn't have that if statement it would post.

restive otter
#

oh i see

golden adder
#

But basically no, the token isn't linked to the client id

restive otter
#

good

golden adder
#

So if I had your token I could post to your page from my bot if I wanted to 😂

restive otter
#

i see

midnight kite
#

hey, im attempting to use the dblpy module, using the webhook example in the api docs.

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='password', webhook_port=5000)

This is the code used in the example. For webhook path, what url do I use? I am generating the webhook for a discord channel so do i just paste that in? and for webhook_auth, what do i put there? and does the port number matter?

#

Please ping me if anyone responds :)

teal kiln
#

If someone votes for my bot, how long does it take to get logged in the console?

quiet zodiac
#

hi I’ve been getting a issue on tracking votes

#

Can anyone help me

#

Who’s experienced

#

With dblapi.js

sullen nymph
#

hey, im attempting to use the dblpy module, using the webhook example in the api docs.

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='password', webhook_port=5000)

This is the code used in the example. For webhook path, what url do I use? I am generating the webhook for a discord channel so do i just paste that in? and for webhook_auth, what do i put there? and does the port number matter?
@midnight kite A webhook is a reverse API, you're the one receiving requests

#

webhook_path is the string that comes after the URL, http://ip:port

#

by default it's /dblwebhook so your URL becomes http://ip:port/dblwebhook

midnight kite
#

Thanks a lot :) but I decided to just go with using the regular api since I didn’t really have a need to use webhooks and regular requests seemed easier

sullen nymph
#

Fair

rapid kettle
#

@trail sigil my merry friend

trail sigil
#

uhh

#

-api @silent finch

abstract mothBOT
#

TOP.GG API ONLY!!!
ANY OFF-TOPIC CONVERSATION WILL BE DELETED AND MUTED
This channel is only for SUGGESTIONS/HELP/BUGS to do with OFFICIAL API LIBRARIES and API DOCS found at: https://top.gg/api/docs

trail sigil
#

ty

tulip crown
#

how do you find your dbl token for the api?

jaunty plank
tulip crown
rapid kettle
#

no

tulip crown
#

k

tulip crown
jaunty plank
#

points?

tulip crown
#

it calls votes points

sullen nymph
#

Last 1000 votes - /api/bots/votes

#

number of total and monthly votes - /api/bots/

regal harbor
#

how webhook works?

golden adder
#

@regal harbor every time your bot gets a vote on top.gg, it fires the vote event in the code.

#

See pins for more info

frosty quail
#

what link do i put here?

jaunty plank
#

http://ip:port/path

#

fill in ip port path with your stuff

frosty quail
#

my stuff?

jaunty plank
#

ip is the public ip of the vps/server/network your on

#

port and path you define in your code

regal harbor
#

i really dont get it

#

when i set up something of the example codes my bot in console says this

#

or

#

what im supose to do with that i put it on the page and i press "test" and nothing happens

frosty quail
#

i dont understand the port and path

restive otter
#

what im supose to do with that i put it on the page and i press "test" and nothing happens
@regal harbor you need to wait a bit for it to send the webhook
do anything while the test is going and it'll stop

spring flicker
#

How to set a message when you use a discord webhook?

#

So you can skip the code in your bot itself

restive otter
#

@spring flicker you can't use a discord webhook

#

discord webhooks are different from top.gg webhooks

spring flicker
#

Huh

#

Oh ok

copper bough
restive otter
#

uh help i am not able to get top.gg webhooks to work

restive otter
#

someone help

sullen nymph
#

well what have you tried up until this point

rapid kettle
#

You’re providing absolutely no info here

#

what are you trying

restive otter
#
this.dbl = new DBL(this.config.tokens.dbl.token, {
                webhookPort: this.config.tokens.dbl.webhook.port,
                webhookAuth: this.config.tokens.dbl.webhook.pass
            });

            this.dbl.webhook.on('ready', async (hook) => {
                console.log(`Top.gg webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
            });


            this.dbl.webhook.on('vote', async (voter) => {
                console.log(voter);
                const user = await this.users.cache.get(voter.user);
                voteRewards(this, user);
            });
#

my code

#

to receive webhook

#

but i am receiving nothing if i click test

rapid kettle
#

Looks like valid stuff

restive otter
#

but if i click test

#

doesn't work

rapid kettle
#

where are you hosting

restive otter
#

for now testing in my local machine

rapid kettle
#

bingo

#

you’d need to port forward

restive otter
#

how?

rapid kettle
restive otter
#

K

#

i allowed port through the firewall

sullen nymph
#

Did you forward it in the router settings?

restive otter
#

doing rn

#

like fill in what here

#

what to fill in ip address

sullen nymph
#

oh dear lord

restive otter
#

i am nub at these type of stuff

#

never tried to do port forwarding

#

i don't wanna mess up the router

rapid kettle
#

service port would be the port you run the webhook on

#

Internal Port would also be the port the webhook runs on

#

and IP address would be your computer’s private IP address

median badger
#

Don't bother

#

Someone that doesn't know about these kind of things will get them selves into a security pickle

rapid kettle
#

security pickle

restive otter
#

well how to do port forwarding in a azure vm tho?

#

anyway i did forward it in the router settings

#

i hope it works now

teal kiln
#
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });

What do i need to enter for "yourDBLTokenHere"

rapid kettle
#

your dbl token

teal kiln
#

where do i find it, and what is it?

rapid kettle
teal kiln
#

is it the APi key?

foggy kelp
#

Yes

teal kiln
#

ok ill try it

#

it doesnt work

#

nothing got logged

#
const dblweb = new DBL('API Token', { webhookPort: 5000, webhookAuth: '12345' });
dblweb.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});

dblweb.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});
#

nothing got logged

rapid kettle
#

where you hosting

teal kiln
#

the bot?

#

with my phone

#

self host

pale fulcrum
#

if you are trying to get the webhook to work when self hosting you may have to port forward to get the network pointing port 5000 to where you are hosting it

teal kiln
#

ok

acoustic peak
#

Why is there only a snippet for the Cog version of the server count for python on the API Docs page?

quiet zodiac
#

How do I get a webhook to send a message every time someone votes

#

I’ve tried all the ways and it doesn’t work

hazy adder
#

I'm having some trouble with getting the widget to work anyone got a template of how it should be set up?

#

<img src="https://top.gg/api/widget/745358062025703445.svg"> this is how mine is set up

teal kiln
#

i opened port 5000, but it still doesnt work

molten lantern
#

hello how can i make my bot online?

#

i am trying to make my own music bot

golden adder
foggy kelp
lost geode
#

wth is a snowflake

#

can i just convert it to an integer normally?

#

or is it already an int

sullen nymph
#

it's a string but you can convert to integer manually, yes

lost geode
#

ty!

regal harbor
#

how to open ports in a vps any guide?

#

I made webhook to work in my pc but I cant in the vps

white onyx
#

Is there a way for me to fetch current amount of votes for a specific bot/guild through an api?

#

@regal harbor you have to tell your firewall to open the ports, a lot of vps'es use UFW, so it would be sudo ufw allow <port>

regal harbor
#

@white onyx thanks!

wintry oracle
#

whats api

ebon fulcrum
#
API

An application programming interface (API) is a computing interface which defines interactions between multiple software intermediaries. It defines the kinds of calls or requests that can be made, how to make them, the data formats that should be used, the conventions to foll...

wintry oracle
#

hmmmm

#

still dont understand

wide sigil
#

site is down

remote hollow
#

api. you request something from a server's api endpoint that performs a CRUD operation which means it Creates something, Reads something(server reads something and you get it back), Updates something on the server, or Deletes something on the server. basically.

#

when you request a webpage you (client) request data from the website (server) such as the latest news or top discord servers or some shit. that's a read or a http get request