#topgg-api

1 messages · Page 116 of 1

sullen nymph
#

webhookAuth is what you come up with

#

It's a password you create and enter both in your code and top.gg

#

dblapi.js will rely on it to confirm that requests are coming from top.gg

slow dove
#

sooo how do i do it?

#

@sullen nymph

sullen nymph
#

do

#

uhhhhh

#

what

vocal ledge
#

tried it nth happened!

sweet sandal
#

when i tried to post the server count i got an error of Error: 401 Unauthorized

thorny parrot
#

Are the api docs open source somewhere? I noticed a broken link and wanted to PR.

jaunty plank
#

The docs are in a complete rework iirc.

restive otter
#

dbl.get_user_vote(ctx.author.id) i get error that dbl has no attribute get_user_vote(), why?

#

im using python btw

paper torrent
#

how to post server count?

jaunty plank
paper torrent
#

i generated token

#

now?

jaunty plank
#

follow the api docs.

restive otter
#

GUys,
in python,
this:
yeah = await dbl.get_user_vote(ctx.author.id)
gives me this:
AttributeError: module 'dbl' has no attribute 'get_user_vote'

#

can someone help

sullen nymph
#

An instance of DBLClient has that method

#

and the dbl module itself has the DBLClient class

restive otter
#

hmm so,

#

self.dblpy.get_user_vote ?

sullen nymph
#

mhm

restive otter
#

ty

paper torrent
#

how to make this server visiable in .js

misty blade
#

hey so I code in python and I need help setting up webhooks for top.gg for voting

#

how would I get started?

pine heart
restive otter
rapid kettle
#

your string isnt closed

restive otter
#

@rapid kettle no the error is not there when i paste the token i get the error

#

i closed the string but didn't work

pine heart
#

send a new screenshot? because the one you sent showed an unclosed string

restive otter
#

@pine heart

pine heart
#

yes

restive otter
pine heart
#

where exactly is the error?

restive otter
#

when i paste the token i get the error

#

i'm trying to show the server count on my bot page

pine heart
#

ohh

#

did you paste the dbl token?

restive otter
#

yeh

pine heart
#

it's not your bot token

#

hmm

restive otter
#

i know

pine heart
#

give me a sec

restive otter
#

take your time

pine heart
#

ig "client" is defined?

#

can I see the error msg?

restive otter
#

yeh i do

pine heart
#

hmm

#

so do you get the error when you insert the token into the "new DBL()"?

#

or where exactly

restive otter
#

the error is

#
const DBL = require("dblapi.js");
      ^

SyntaxError: Identifier 'DBL' has already been declared
pine heart
#

ahhh

#

well that says everything

#

seems like it's already declared somewhere

#

maybe search for "DBL" in your file and check if you defined it twice

restive otter
#

its my first time testing it

#

oh sorry my bad i copied a wrong error

pine heart
#

ah xD

restive otter
#
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

SyntaxError: Invalid or unexpected token
pine heart
#

ohh

#

did you close the string??

#

because here it's not closed

restive otter
#

yes

#

the error not showing the whole code

pine heart
#

okay then I dont really get it I'm sorry

restive otter
#

thats why its looks like it not closed

#

its fine

misty blade
#
    def __init__(self, bot):
        self.bot = bot
        self.token = os.environ["dbltoken"]
        self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True,
        webhook_path="/dblwebhook", webhook_auth="password", webhook_port=5000)

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

    @commands.Cog.listener()
    async def on_dbl_test(self, data):
        print(data)

    @commands.Cog.listener()
    async def on_guild_post(self):
        print("Posted to top.gg")

Nothing gets printed

#

well for voting

pine heart
#

so maybe check for typos

restive otter
#

@craggy sentinel

#

can you help me please

pine heart
#

try to save your token in a json file and import that and put it that way maybe?

#

just to try something else I think

restive otter
#

yeh i was thinking to do that

pine heart
#

I also did that, like you can see in my screenshot

#

also it's better practise to do it like that

restive otter
#

yeh it worked

#

sorry for the mention Veld

pine heart
#

uhh but now I'm interested what the error was

#

u havent mentioned veld cutepeek

misty blade
#
class TopGG(commands.Cog):

    def __init__(self, bot):
        self.bot = bot
        self.token = os.environ["dbltoken"]
        self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True,
        webhook_path=os.environ["dblweblink"], webhook_auth=os.environ["dblwebpass"], webhook_port=5000)

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print(data)
        webhook = discord.utils.get(await self.bot.get_guild(720871110266191954).webhooks(), id=781938786158247967)
        await webhook.send(data)

    @commands.Cog.listener()
    async def on_dbl_test(self, data):
        print(data)
        webhook = discord.utils.get(await self.bot.get_guild(720871110266191954).webhooks(), id=781938786158247967)
        await webhook.send(data)

    @commands.Cog.listener()
    async def on_guild_post(self):
        print("Posted to top.gg")
os.environ["dbltoken"] = "/dblwebhook"
os.environ["dblweblink"] = "Mochipass"

Nothing happens when someone votes help please

#

or even if I press the test button

pine heart
#

well is this python... I dont know much python but I think you have made a password and provided the token and the link

#

right?

#

lik

#

e

misty blade
#

/dblwebhook

pine heart
#

you haven't just pasted "dbltoken" there in your real code right?

misty blade
#

no its using the correct token becuase it prints "Posted to top.gg"

pine heart
#

hmm

#

well if you have entered correct token, password and link then I can't help you since I barely know python

misty blade
#

oh okey thanks for trying

pine heart
#

I'm sorry I can't help more :c

misty blade
#

its fine 👍

trail hearth
#

So for the webhook to work, what kind of port do I need to open in my servers firewall to receive them (TCP, UDP, HTTP, etc...) And what ip will it be coming from so I can allow it to access the port?

plucky lance
#

TCP for the port you selected, guessing requests come directly from top.gg
Just resolve the domain name to get the IP

trail hearth
#

Ok, cool, thanks. I didn't want to just open it up to any ip, lol

agile quail
#

so im trying to make my bot give credits over the past 12 hours every time someone votes, problem is there is no visible way to sort by date/time voted

#

all it returns is user, discrim, id, avatar url

plucky lance
#

It doesn’t mean the top.gg IP can’t change sometimes, dunno if they change the IP sometimes or use a service like Cloudflare etc.

plucky lance
agile quail
#

now how the hell would i do that, i cant make it run constantly

#

thats just highly inefficient

plucky lance
#

Well I wonder why you need the exact time and date but top.gg sends it’s requests to your webhook service for example at the time the event got triggered

agile quail
#

so the webhook sends when the event is fired?

plucky lance
#

You can cache the time and date atm you receive this event

#

Yes

#

That’s the actual time the event happens - somebody votes for example

agile quail
#

so how exactly do i use the webhook, im confused on that part

worldly saddle
#

Hey

#

How Do I Do

#

Like

#

User Has Voted For Bot Thanks For Voting Turn On Notifications!

pulsar palm
#

It would be like

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

Oh Ok

agile quail
#

How the hell do i even use the webhook im confused

worldly saddle
#

Hey

#

Token = Authorization Token?

agile quail
#

yes

#

not discord one

#

the one listed under api

worldly saddle
#

Hey @agile quail

agile quail
#

pong

worldly saddle
#

Can You Try to Vote For My bot?

agile quail
#

sure

pulsar palm
#

ok

worldly saddle
restive otter
#

You can use test webhook lol

worldly saddle
#

Oh XD

agile quail
#

voted

#

or do that

worldly saddle
#

Thx

#

Lemme See

pulsar palm
#

voted

agile quail
#

but still how do i use the webhook in the first place

restive otter
#

Which library

worldly saddle
#

aww man

agile quail
worldly saddle
#

didnt work

#

: (

#

XD

restive otter
#

Dunno :D

agile quail
#

like,

#

what do i do at the webhook configure page im confused

restive otter
#

It took me 7 months to fix this vote thing. Just imagine how complicated things are

worldly saddle
#

yea

agile quail
#

Mine "works"

#

i just need to fix it because its sending currency to the user ID 0

restive otter
#

What's issue

agile quail
#

and i need to make it check every 30 mins if the person still voted, ID is easy to get

pulsar palm
#

dbl.webhook.on('ready') Doesn't send anything for me, even after voting

restive otter
#

Why do you need to check that, You can instantly give rewards on vote?

agile quail
#

No, i want to give rewards every hour

#

automatically

restive otter
#

Or just save the data inside a file when someone's votes.

On other side put a infinite task which runs every hour, check if the user is in the file and then send rewards?

agile quail
#

so that people dont gamble everything away at once

#

well someone said check when the user voted fires

#

from the webhook

#

and i can start a timer from there

#

for 12 hours

#

every hour it gives a reward

#

every time it sees the user voted fired it resets the timer for that user

restive otter
#

You don't have to do that, Just save the User ID in the file with the time stamp. Put some conditions in the loop, if time is bla bla then send rewards else pop the ID.

agile quail
#

well i dont want to store unnecessary data

#

problem us current api sends the last number of users who voted, instead of when and how many times

#

thats all the data that the api gives

plucky lance
#

I mean the info should be enough to reward voters by a script requesting this list time by time from the API.

If you wanna react "live" if the event got triggered you will have to use the webhook service.

pulsar palm
#

could you test my webhook to see if voting works on it?

plucky lance
#

May the info you can get by the API is limited due privacy concerns, who knows

#

You can test it yourself using the test button.

#

On your bots edit page at top.gg

proper atlas
#

yo wheres the api page?

#

havent messed with it in a while and i need to get pp god's token

opaque jetty
proper atlas
#

aight thx

restive otter
#

what does this api do

loud jewel
#

Can someone help me with the API and an error I get when trying to add the server count

paper torrent
loud jewel
paper torrent
#

read it carefully

stuck loom
#

uh

#

is there a way for it to auto-update the server count?

rain heart
#

There's an example on the api docs

stuck loom
#
dbl.on('posted', () => {
  console.log('Server count posted!');
});
#

i tried it already

rain heart
stuck loom
#

hm

rain heart
#

the dbl.on('posted') is just the event when it was posted successfully

#

scroll down to the methods part of the docs

stuck loom
#

aH

#

oki

#

@rain heart uh

#

my bot doesnt need to use shards yet

rain heart
#

that part is optional

#

read the arguments table

stuck loom
#

it still wont work when i take it out

#

the shards part it says postStats requires 1 argument

rain heart
#

that one requirement is your server count

stuck loom
#

it is

#

i have server count in it

#

it still says 1 argument

rain heart
#

dbl.postStats(client.guilds.size) says that the shard id is a requirement?

stuck loom
sullen nymph
#

what arguments do you pass to postStats

stuck loom
#

uH

rain heart
#

that one argument should be your server count, im confused

stuck loom
#

client.guilds.size

#
setInterval(() => {
        dbl.postStats(client.guilds.size);
    }, 180000);
rain heart
#

That is, according to the arguments table on the docs, correct

#

unless I'm missing something

stuck loom
#

idk

sullen nymph
#

Interesting

stuck loom
#

paniK

willow spindle
#

@stuck loom what is your djs version

stuck loom
#

12.4.1 @willow spindle

willow spindle
#

it is client.guilds.cache.size

stuck loom
#

aH

#

bruh i was gonna put cache.size

#

but i thought it was part of the api

#

so i didn't change it lol

worldly saddle
#

Hey How Do I Use API?

#

So I Used What It Said

#

And Nthin Happened

#

I Voted For It

#

And Nthin

#

Happened

rain heart
#

then your webhook isn't working correctly

#

check with a rest api maybe

worldly saddle
#

Well Wanna See My Webhook?

#

or code?

rain heart
#

did you add the url in your bot settings?

worldly saddle
#

yes

rain heart
#

the correct one? not 0.0.0.0 or localhost or 127.0.0.1?

#

your public server address?

worldly saddle
#

I Used

#

0.0.0.0

#

0.0.0.0:5000

willow spindle
#

it is not your public address

worldly saddle
#

Thats What I use

#

Wait

#

Lemme Make It In a Bin

willow spindle
#

you should use your vps' ip

worldly saddle
#

I use ptero Panel

#

A Public Panel

#

That Is Code

rain heart
#

you need to enter your public ip-address of the bot inside the bot page settings

#

not 0.0.0.0

worldly saddle
#

This Is What I Use To Do It Or smthin

#

localhost:3862

#

Like That?

#

Its nOt Rlly My IP

willow spindle
#

it is not localhost

#

where is your bot hosted

worldly saddle
#

DanBot

willow spindle
#

?

worldly saddle
#

Oops Wrong Pic

#

That One

#

so help?

willow spindle
#

hmm idk about danbot.host

worldly saddle
#

Aww Man

willow spindle
#

Does it give you a public website address? Like glitch or heroku

worldly saddle
#

I can go to source

#

@willow spindle

#

Yes I do

jolly escarp
#

So if your bot is offline but you have a feature so whenever someone votes for your bot they get something in return, is there anything you could do in case they vote for it while it's offline

rain heart
#

i suggest logging your votes on an external program

#

then log them inside your database for example Shrug

jolly escarp
#

So having two seperate things online.

floral orchid
#

Can I check if the specific bot is available on the Top.gg site?

rain heart
#

referring to what? see if a bot exists on top.gg?

floral orchid
#

I want to do this by bot. That's why I asked

winged widget
#

@worldly saddle

rain heart
#

you can technically make a getBot request and see if you receive 404

#

if 403, then the bot is not approved yet

little mason
#

Hello, I'm posting the shard_count but it looks like it's not showing on my bot page, any idea why?

rain heart
#

caching

#

wait a bit and see if it appears after a bit

little mason
#

Okey, thanks!

floral orchid
#

Ghost ping ?

wintry sable
rain heart
#

that's mostly your bots server ip

#

but refer to your libraries documentation for that

wintry sable
#

My bot's ip address?

rain heart
willow spindle
#

your server's

wintry sable
willow spindle
#

https://your server's ip adress:port/path

little mason
#

@rain heart It's still not showing the shards

edgy hamlet
#

😂👋

#

🇷🇺

#

🧍> 🇷🇺

restive otter
fallen drift
#

My server's page is having issue on top.gg - some users are unable to vote due to the ad either refreshing or not starting. Is this the right area to ask for support?

sullen nymph
fallen drift
#

My apologies.

restive otter
sullen nymph
#

#general if you want to talk about something

#

Or DM me

jaunty plank
elder violet
#

Please tell

sinful knoll
#

Is there a post request I can send instead of using the library?

rain heart
#

yes

sinful knoll
rain heart
sinful knoll
rain heart
#

your own bot id

sinful knoll
#

Ty

rain heart
#

your top.gg token is most likely Authorization

#

not sure though

sinful knoll
# rain heart not sure though

Would this request work? Sorry, this is my first post request lol:

        data = {'server_count' : len(client.guilds)}
        requests.post(url = "https://top.gg/api/bots/757286567906770965/stats",data=data)
rain heart
#

not sure if it does, no clue about js

#

though for posting it, you might need authorization

restive otter
#

how i can show the servers count in my top.gg bot page?

pine heart
#

pins

willow spindle
jade kayak
#

I'm pretty sure dblpy is broken with py 3.9

#

It worked fine, now I keep getting TypeError when trying to fetch vote after updating to py 3.9

restive otter
#

i don't know how i can setup it,_,

sullen nymph
#

I'm very aware of the issue and will release a fix for it in next version

potent jolt
#

Hello, i want to make a "vote" command for my bot but i dont understand how to check if an user voted...

pine heart
#

you'll have to do it via webhook

#

what library/coding language are you using?

potent jolt
#

discord.js in javascript

pine heart
#

okay

potent jolt
#

but i dont understand how to use webhooks...

pine heart
#

ah

#

have you already read the javascript section?

potent jolt
#

yes but i dont understand...

pine heart
#

hmm

#

so basically u gotta copy+paste that code

potent jolt
pine heart
#

hmm

#

that's exactly what you need

potent jolt
#

yes derp

pine heart
#

have you set up a password?

#

and have you got your dbl token?

potent jolt
#

yes

pine heart
#

okayy

#

did you enter the webhook url in the edit page of your bot?

potent jolt
#

but what is the webhook url...

#

it is in local...

pine heart
#

ohh

plucky lance
#

top.gg needs to send a request to your endpoint, which means you have to provide a public IP/DNS

pine heart
#

it's the public ip of your host

#

exactly

potent jolt
#

oh ok

pine heart
#

so where are you hosting your bot on?

potent jolt
#

and in the "autorisation" field i put my passworld ?

pine heart
#

yeah exactly

potent jolt
#

i test one sec

pine heart
#

okayy do that

#

(you can test with the "test" button at the bottom of the page where you have to enter your webhook url)

potent jolt
#

yes

pine heart
#

👍

#

uhh if you need more help just ping me

potent jolt
#

yes...

#

it doenst work @pine heart

pine heart
#

hmm

#

well you shouldn't show me this

#

delete that message again

#

good :)

#

but it looked good

#

and what's the code in your editor?

potent jolt
#
const DBL = require('dblapi.js');
const dbl = new DBL("mytoken", { webhookPort: 5000, webhookAuth: 'mypassword' });
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!`);
});```
pine heart
#

hmm

#

okayy

#

well I also get the 0.0.0.0 ip in the console but it works with me

plucky lance
#

Used your public IP? Opened the required port? Firewall configured?

pine heart
#

ahhhh yesss

#

you have to open the port

potent jolt
#

?

plucky lance
#

webhookPort: 5000

pine heart
#

uhh I don't really know how to do that

#

maybe FakE knows...

plucky lance
#

OS?

#

Hosting at home or on a VM?

potent jolt
#

I must create a server at port 5000?

pine heart
potent jolt
#

yes

pine heart
#

nah you don't have to do that

#

just somewhere in your firewall settings I think...

plucky lance
#

You created the webhook service at port 5000 already.

potent jolt
#

ow

plucky lance
#

But need to allow incoming connections to pass port 5000

pine heart
#

yeah exactly

potent jolt
#

ok...

plucky lance
#

By default most firewalls will block requests for ports like these

#

But I don't know replit

potent jolt
#

and how do that ?

#

oh... one min

plucky lance
#

Well I can tell you how to do on Unix system and Windows bot no clue how to do so for repl.it

potent jolt
#

ok... thank you anyway

pine heart
#

they probably have some settings somewhere

potent jolt
#

yes

pine heart
#

then search for firewall settings and "port forwarding"

jaunty spade
#

Hey, I know this question has been asked probably like 1000 times but can I create a webhook endpoint for use with Top.gg using Heroku? Thx in advance

jaunty plank
#

Heroku you'll need to enable a web thingy(its in the heroku docs)

jaunty spade
#

I'll look for it

jaunty plank
#

Called dynos

jaunty spade
#

ok

jaunty plank
#

You'll also need to use the PORT environment variable heroku provides

jaunty spade
#

ok

sinful knoll
#

I'm brand new to making any sort of APIs, and only really know Python. I want to make a POST API for my votes that would then run code in Python with the info. Could someone give me a guide or walk me through on how to do that?

Thanks so much!

cloud sorrel
#

im confused

#

is it possible to find the servers ur bot is in?

plucky lance
#

Keep the update interval in mind

dapper copper
#

@restive otter You need to continuously post your server count

restive otter
#

L

fervent portal
#

How do I make the server count for my bot 0.o

rain heart
fervent portal
#

ok.

turbid fulcrum
#

hope wdym submit it? i saved it if thats what you mean

rain heart
#

entering it into your webhook field, then submitting it

#

if you haven't done that yet

turbid fulcrum
#

i already did

frank estuary
#

Can i ask
How do i connect my bot to top.gg?

turbid fulcrum
#

do i have to have the /dblwebhook?

rain heart
#

you need to have your full url of the webhook

turbid fulcrum
#

with the port too?

rain heart
#

yes

#

so for example if my servers ip is example.com, it would be
http://example.com:5000/dblwebhook

#

though changing 5000 with your port you set

#

if my servers ip is 192.22.22.2, then it would be
http://192.22.22.2:5000/dblwebhook

#

and so on

turbid fulcrum
#

ok so also the other thing is at the bottom i have server.listen(5000) but when i do hook.port its saying 0

#

i tried having my port as 5000 and 0 on the site and neither worked

rain heart
#

that's something you can ignore, 0.0.0.0 is just another word for being able to connect to it from anywhere

turbid fulcrum
#

the port not the ip lol

rain heart
#

dm me the webhook url, i'll test it

potent jolt
#

but on repl.it how to enable port fowarding

#

?

sullen nymph
#

You host the webhook on port 8080 and don't specify it in the URL you use

restive otter
#

Can someone help me with the webhook?

rain heart
#

What exactly doesn't work?

restive otter
#

I don't really understand how to set it up...

rain heart
#

Instead of 0.0.0.0, use your servers ip

#

So for example if your ip is 192.33.33.3, then http://192.33.33.3:5642/dblwebhook

restive otter
#

where can i change it?

rain heart
#

It is changed

#

0.0.0.0 means you can connect to it from anywhere

#

Use your public ip address of the server your bot is running on

restive otter
rain heart
#

Yeah

#

Everything that is directed to your server address

restive otter
rain heart
#

Token?

#

You mean the Authorization

#

That's something you can decide for youself, as long as they're the same on the Authorization field of your bot page and your webhook code

restive otter
#

oh wait

#

do i have to run the webhook from an express server? @rain heart

rain heart
#

Nah you should be able to run it from the example on the documentation

restive otter
#

yea it's not working .-.

rain heart
#

Dm me the url you're using

outer summit
#

Where do I get dbltoken

rain heart
median river
#

Hi, I was wondering how I could give a role to a user if they vote for the bot? Is it possible?

rain heart
#

you can do that with webhooks

#

the webhook returns the voters user id, which you can use to assign that user a role

median river
#

O thankyou is it possible in the website or do I add it to my bot?

rain heart
median river
#

Thankyou

potent jolt
#

@rain heart i am on repl.it, what is the ip ?

rain heart
alpine sierra
#

bruh

potent jolt
#

its the url of the project ?

#

i tested all i dont understand

alpine sierra
#

what is the module name for repl.it?

restive otter
#

hِttps://repl.it:port/path KEKW

alpine sierra
#

there is no dblapi.js

#

:/

#

need some help here

potent jolt
#

const DBL = require('dblapi.js');

#

he install

alpine sierra
#

no it does not

#

it says MODULE_NOT_FOUND

#
const DBL = require('dblapi.js')
const dbl = new DBL('dbl token', client) 

#

so this is the beginning of the code

#

which uses discord.js v11

potent jolt
#

webhooks doenst work on repl

#

.it

#

?

alpine sierra
#

i don't know

#

your sentence was too weird to answer bruh

#

does it work or nah

#

I don't have an idea

potent jolt
#

who already make a vote system for hes bot in javascript (PLEASE ping me)

median river
potent jolt
#

yes

rain heart
#

just go to your bot settings, then webhooks

median river
#

Oh ok lmao

#

Thanks

#

@rain heart Are there any examples on how to do it, as i do not really get it?

rain heart
#

depending on your library, you should find examples on the same page

median river
#

Oh yes i see now sorry i was being blind thanks

#

I am really confused again lol, How do i create a webhook?

rain heart
#

scroll down all the way

median river
#

On what?

rain heart
#

on your library section of the api documentation

median river
#
dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
#

So i need that?

rain heart
#

yes presumably

median river
#

Ok thankyou for all your help

#
dbl.webhook.on

TypeError: Cannot read property 'on' of undefined

#

Does anyone know why that is

median river
rain heart
#

No it's not a discord webhook

median river
#

So i have to get it from the dbl.webhook.on?

#

Or if not how do i get it

rain heart
#

I can't tell you how it's done because i don't work in js, the documentation is the most accurate information about the api you can find

median river
#

Ok np

potent jolt
#

i am on repl.it and it doenst work...

pine heart
#

hellooo

restive otter
#

The

pine heart
potent jolt
#

yes

#

it doenst work

pine heart
#

hmm

#

what's the problem now?

potent jolt
rain heart
#

Have you tried making a manual request to the webhook through postman for example

potent jolt
#

but when i click on "test " button he doenst respond

#

in the url field i put project-name.user-name.repl.co:5000/dblwebhook

rain heart
#

Well you need to replace the things, you know that right?

#

the project-name and user-name

potent jolt
#

yes

#

i replaced

#

but he doenst respond

rain heart
#

dm me the full url

#

i'll see if it's valid through a test request

potent jolt
#

I FOUNDDDDDDDDDDD

#

FINALY

#

i found

pine heart
#

yayyyyy

#

congrats

potent jolt
#

the url is just project-name.user-name.repl.co/dblwebhook and no project-name.user-name.repl.co:5000/dblwebhook

#

the port is useless

pine heart
#

lol

median river
#

Hi, so i am trying to give a user a role for voting for my bot could anyone help how i could do that? and also i have it log who voted but it does not log it?

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

is the api working?

#

cuz its not giving the server count

#

on bot page

restive otter
#

you have to update it yourself

wind flame
#

its empty

#

completely

#

only shards coming

#

for my bot

#

but for my another bot

#

its coming

#

servers are showing

restive otter
#

did you update it for that bot?

wind flame
#

okay worked

#

i was doing the parameter wrong

#

lmao

quaint rapids
silk reef
#

hmmm any idea why this never gets trigged even tho it posts the guild count? pepowot

#

    async def on_guild_post():
        print("Server count posted successfully")```
restive otter
#

what;s not triggered

violet spoke
jaunty plank
#

Your using the same port twice.

reef sonnet
#

hello everybody.. I realised that dblpy's "user_get_vote" doesnt work on py3.9

#

according to the issue i should send requests manually

#

how do i do that

quick wedge
#

Hello

fast spruce
quick wedge
#

i get it thank you

#

If someone voted, i want that the bot ssay directly in a channel that he vote, is there an event or something that helps me do it?

pine heart
#

yes, webhooks

quick wedge
#

thank you

sullen nymph
#

Nothing fucking works in dblpy with py3.9

sullen nymph
reef sonnet
#

and most of the shit i wrote doesnt work on anything before 3.9

sullen nymph
reef sonnet
#

fuckin hell

sullen nymph
#

I'll be pushing out a release with some stuff soon

rain heart
#

fucking hell is a bit too hot

reef sonnet
#

i mean i been suffering since the morning with this

#

playing around with everything

#

and turns out its just python being an asshole

sullen nymph
#

I feel your pain

reef sonnet
#

jesus

#

no walk around?

#

or will the release be soon?

sullen nymph
#

All I can say is it will be in December/January

#

The only way around is to rewrite the system yourself that doesn't involve asyncio.Lock

reef sonnet
#

well i just need get_user_vote

sullen nymph
#

(Feel free to steal the dblpy code if you are lazy)

reef sonnet
#

and im terrible at requests

sullen nymph
#

you can refer to dblpy code still ¯\_(ツ)_/¯

reef sonnet
#

so i'll just play around with that

sullen nymph
#

Aye fair enough

reef sonnet
#

thanks man

#

appreciate it

sullen nymph
median river
#

Hi, I was wondering how I could give a user a role in my server for voting for my bot? Could anyone help?

plucky lance
#

Set up a webhook service, use top.gg to send webhooks to your endpoint and use the provided user ID (the voter) and assign a role on your server.

#

Easiest way is to integrate the dblapi into your bot or well run a second instance of it just listening to the webhooks and to assign roles.

sharp vigil
#

@plucky lance any way without webhooks? my internet doesnt really allowe em :/

rapid kettle
#

not really

sharp vigil
#

ah F

#

alright ill try and find a way to make them work Salute

sharp vigil
#

what do i type at "webhook_path"

rapid kettle
#

http://yourip:port/dblwebhook

sharp vigil
#

ah oki ty ty

tacit bloom
#

hmmm

sharp vigil
#

uhm i got this error
ValueError("path should be started with / or be empty")

#

okay idk what to do it doesnt work for me..

#

this is the code

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

import asyncio
import logging
from utils.db import db

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

    def __init__(self, bot):
        self.bot = bot
        self.token = 'mybottoken' # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='http://myip/webhooks/', webhook_auth='myauth', webhook_port=8080)

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

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

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

        await asyncio.sleep(1800)

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):

        logger.info('Received an upvote')
        print(data)

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

and this on the webhook topgg site

thick fern
#

I have been going at it for a while now, and still cannot seem to figure out how to send an automated message when someone votes

#

Can someone help?

#
const Discord = require('discord.js')
const DBL = require('dblapi.js')

const bot = new Discord.Client({fetchAllMembers: true})
bot.login('')
bot.on('ready', async () => {
    console.log('ready')
})


const dbl = new DBL(
    '',
    { webhookPort: 5000, webhookAuth: 'password' },
    bot
);
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!`);
});

Here is my code, and it does nothing when a vote happens

plucky lance
#

Can be via. script or manually any time you’re online for example, however you want.

sharp vigil
#

Ooh how would i do that @plucky lance ?

plucky lance
#

Sending requests to top.gg and receive the list of voters only has one disadvantage - you don’t know the time to voter has voted.
But that’s unimportant if you just wanna assign some roles.
Doesn’t need to be live.

#

Just take a look at the top.gg API docs.
It’s not complicated to send requests and receive the results.
(bots lists, voters etc.)

hard chasm
#

What code do i use for my bot to do something if it gets voted
Im using python

rich umbra
#

that pops upp when I search it..

floral spade
#

Hey are there any ratelimits on fetching user votes?

silk reef
sullen nymph
#

catshrug fetch the API values for your bot info directly and see if it posted properly

vast oriole
#

Hey guys

#

My api error

#

its doesn't show library

#

its show but its undefined

rain heart
#

Read the documentation correctly

rugged quarry
#

Hey guys what is api

zealous vapor
#

An application programming interface is a computing interface that 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 follow, etc.

haughty rune
#

how do i get my api webhook password

#

or do i leave it as 'password'

restive otter
#

you make one

#

if you are in the edit bot/server page

#

scroll down and you will see webhook password and url

severe adder
#

is there a api for wikipedia>

#

?

restive otter
severe adder
#

k

restive otter
#

i dont know how to create a voting log with discord webhook, does anyone know it?

rain heart
#

Just listen for webhook requests, then send the Message on your preferred channel

#

Parse the User ID etc

restive otter
#

How Should i create a webhook on my vps?!

#

Linux

patent widget
#

What to do if nothing happens when you click the Test webhook button?

willow spindle
rain heart
restive otter
rain heart
#

Can't help you then, come back to it once you understand documentations

lament smelt
#

help me

thin breach
#

A P I

lament smelt
#

yes

restive otter
#

hello

lament smelt
#

I want to do that when someone votes for my bot that they give my bot a gift

pine heart
#

if you want your bot to do something when someone votes for it, best thing are webhooks

willow spindle
#

create a webserver and handle requests

pine heart
#

read here about webhooks

lament smelt
#

How do I do that? is that I am new in programming

pine heart
#

if you are new you shouldn't start with this honestly

#

but if you still want to try I suggest to read the section of your library on the top.gg api site (link I sent above)

lament smelt
#

okey

main venture
#

Guys

#

How dblpy autopost works?

#

Like

#

It posts every 30 minutes

#

But does it post exactly when the bot launches?

rapid kettle
#

yep

#

it should

main venture
#

Wai

#

How do I make it

#

So

#

After the bot launches

#

It waits for example 15 minutes

#

Then the loop with 30 minute begins

brave glen
#
class TopGG(commands.Cog):

    #TopGG
    def __init__(self, Bot):
        self.Bot = Bot
        self.token = ''
        self.dblpy = dbl.DBLClient(self.Bot, self.token, autopost=True)

def setup(Bot):
    Bot.add_cog(TopGG(Bot))
main venture
median river
#

Hi, so i have a webhook and it does not work when someone votes for my bot it does not log it in my console could anyone help?

rain heart
#

Test your webhook with something called Postman

ripe ether
#

to post my stats i tried using the following url https://top.gg/api/bots/707686027468472330/stats?server_count=69 But its just returning the server count instead of updating it, how do I get it to update?

stray quail
#
2020-11-30T16:59:00.880959+00:00 app[Worker.1]:     at IncomingMessage.<anonymous> (/app/node_modules/dblapi.js/src/index.js:118:25)
2020-11-30T16:59:00.880960+00:00 app[Worker.1]:     at IncomingMessage.emit (events.js:326:22)
2020-11-30T16:59:00.880961+00:00 app[Worker.1]:     at endReadableNT (_stream_readable.js:1241:12)
2020-11-30T16:59:00.880961+00:00 app[Worker.1]:     at processTicksAndRejections (internal/process/task_queues.js:84:21)
2020-11-30T16:59:00.881019+00:00 app[Worker.1]: (node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
2020-11-30T16:59:00.881100+00:00 app[Worker.1]: (node:4) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
is this a problem with the api or in my code?
ripe ether
#

yeah, thats what the docs said

#

@rain heart

rain heart
#

"Json params"

ripe ether
#

oh, wait

rain heart
#

Your request body is what you need to use

#

Not the query from the request

ripe ether
#

alright, thanks

quick wedge
#

Hello

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

Here i want that the webhook send the message and not to send in my console

#

How can i do it?

median river
#

@rain heart Would you mind sending the link please

misty blade
# median river <@!669452973755072524> Would you mind sending the link please
rain heart
#

Yup

median river
#

Ok thankyou

modest cave
#

any meme api?

rain heart
modest cave
#

oh ok

#

srry

#

xde

stray quail
#
const DBL = require("dblapi.js");
const dbl = new DBL('process.env.tokenDBL', client);

dbl.on('posted', () => {
    console.log('Server count updated!');
})
  
  dbl.on('error', e => {
   console.log(`Oops! ${e}`);
})```
gives this error: `Oops! Error: 401 Unauthorized`
rain heart
#

You're sending "process.env.tokenDBL" as a string

#

Remove the ' from process.env.tokenDBL

#

@stray quail

stray quail
#

thanks

thick fern
#

If I have my webhook running off my computer's terminal, what should I put in the Webhook URL in top.gg to send my votes through?

rain heart
#

You need to portforward the port of your webhook then

misty blade
#

in voting what is the type if someone acutally votes?

rain heart
#

the type is "upvote" when an actual vote comes through

misty blade
#

ok thanks

rain heart
#

"test" when it's a test vote done through the "test" button on your bot page

misty blade
#

is there any other type?

rain heart
#

Nope, these are the only two

misty blade
#

ok thank you

thick fern
#

So the webhook URL in top.gg should be http://IP:port/dblwebhook?

rain heart
#

Yup

thick fern
#

What if it didn't work?

rain heart
#

remember to press "save" and then test

#

because top.gg tests your currently saved webhook

thick fern
#

I did hit save

rain heart
#

not the one you entered inside the webhook field without testing

#

dm me the url

#

I'll see if it's valid

glass plover
#

How do I see how many votes the person gave to my bot? Using the dbl.js api thonk

rain heart
#

track them with webhooks

pine heart
#

yeah make a databade

#

database*

#

and put every vote there

glass plover
#

ok, thnks

rain heart
#

i suggest using a seperate node js program for tracking then

#

instead of implementing it into your bot

outer summit
#

In js dbl api, can I put it in the main file thing, or should it be in ready event?

thick fern
#
const DBL = require('dblapi.js')
const dbl = new DBL('', { webhookPort: 5050, 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!`);
});

Can someone help me figure out what is wrong with this code? The code doesn't give any errors but it will not run the webhook

restive otter
#

@analog lark New York

#

@analog lark name New York

sharp vigil
#

when i do ipconfig my ip starts with 192 but when i search on internet my ip is says it starts with 82??? and the webhook wont start on 82 only on the 192ip
i get this error with the public ip

OSError: [WinError 10049] The requested address is not valid in the context of the address

#

anyidea how to fix?

rain heart
#

192 is most likely your local ip

#

if you're running your bot on linux, you should be able to do curl icanhazip.com to get your ip

sharp vigil
#

windows

rain heart
#

local pc? or on a windows server somewhere?

sharp vigil
#

local pc

rain heart
#

you need to portforward in order to get your port to be accessible from external connections

sharp vigil
#

and it said it works

rain heart
#

what's your code you used for creating the webhook?

sharp vigil
#
import asyncio
import random
import os, re, aiohttp
from utils.db import db
from utils.defaults import guilddata, userdata
from discord.ext import commands
from random import choice as randchoice
from utils.dataIO import fileIO
import time
import dbl
import sys
import json
from flask import Flask
from flask import request

app = Flask(__name__)

@app.route('/', methods=['POST','GET'])
def webhook():

    if request.method == 'GET':
        print("Solyx GET request?!")
        return '<h1>This is for top.gg only, what are you doing here?!</h1>'

    elif request.method == 'POST':
        print("Yessir")
        if not request.headers.get('authorization') == "myauth":
            return
        data = request.json
        print("SOLYX VOTE: {}".format(request.json["user"]))
        print(data)
        userinfo = db.users.find_one({"_id": data['user']})
        # Account check
        if userinfo["class"] == "None" and userinfo["race"] == "None":
            return
        if request.json["isWeekend"] == "True":
            userinfo["voted"] = "weekend"
        else:
            userinfo["voted"] = "True"
        db.users.replace_one({"_id": data['user']}, userinfo, upsert=True)

        return '', 200

    else:   
        abort(400)

if __name__ == "__main__":
    app.run(host='mylocal 192 ip', port=8080, threaded=True, debug=True) # will listen on port
rain heart
#

yeah can't help you

sharp vigil
#

adn when i chance my local ip to the one google gives me it saus that error

#

;-;

#

no worries

#

thanks for trying anyway

sullen nymph
#

This hurts to read as I'm not used to big codeblocks

#

@sharp vigil run the webhook on 0.0.0.0

sharp vigil
#

Sorryyyy

#

Ill try

#

nope doesnt work

#

same error

sullen nymph
#

Oh well I tried

#

Did Google help btw?

sharp vigil
#

nope :)

sullen nymph
#

Great

#

We're fucked

sharp vigil
#

i guess i wont be able to check if people vote or not ;-;

sullen nymph
#

Okay let's see how many prayers this will take

sharp vigil
#

i have to do it with the webhook right?

#

cuz the uuh server post thingy works

#

although it sends the same amount as shards

#

;/

sullen nymph
#

Ok this is weird

#

Are you sure you saved the file before running it

plucky lance
#

You need a webhook only in order to receive a live event not if a user has voted or not

sharp vigil
#

ye

sullen nymph
#

Specifically, are you .running the application on 0.0.0.0?

sharp vigil
#

i have a command that gives users rewards whenn they vote atm i just trick them ;/

plucky lance
#

OS?

sharp vigil
#

OSError: [WinError 10013] An attempt was made to access a socket in a manner prohibited by the access permissions

#

windows

plucky lance
#

Make sure to allow the app to pass the firewall and open/forward the port to your device the app is running on

sullen nymph
#

Are you high

plucky lance
#

That’s a problem for u KEKW

#

Oh you’re speaking about the error, thought you don’t receive the webhook

#

lmao

sharp vigil
#

its uuh google translate CBKermitLmao

#

me dutch Run

plucky lance
#

Don’t worry shivacos weird name confuses me

#

That’s why I didn’t read carefully

sharp vigil
#

it gives me ✨ Distrust ✨

plucky lance
#

Is your Windows user (running the app) an administrator or just a user?

sharp vigil
#

Admin

#

I think its cuz i have a router on a router

#

So www -> router -> router -> my pc

plucky lance
#

The webserver is running and is accessible and no anti-virus shit is blocking your app?

#

Tried a different port already? May some other webserver uses port 8080 already.

sharp vigil
#

the uuh GET function works

#

just the post doesnt

#

if i try the post from topgg

#

O_O

#

tried port 8081

plucky lance
#

You can’t actually just run a webserver to receive a POST request on your endpoint.
It has to be a webhook service in order to work.

sharp vigil
#

uuh me confused

#

anyway

#

how would i get the list of voted users?

#

or like check if a certain user has voted?

#

without the webhok?

plucky lance
#

Python?

sharp vigil
#

yup

plucky lance
sharp vigil
#

will do

lean ivy
#

Hi i added the api cog to update how many servers the bot is in to top.gg anyone know why the status stopped working after i did this

restive otter
#

3

lucid osprey
#

trying to test a webhook for bot running locally on my pc. It doesn't arrive, anything I am missing? Did the port forwarding, password is the same
(solved it)

grim grotto
#

the get_bot_upvotes is returning [] when I have 11 votes

#

pls help

wraith sleet
#

One message removed from a suspended account.

woeful escarp
#

Googletrans API IS DRUNK AF

#

every bot has the same Error

rain heart
sullen nymph
#

The number is there because no one has voted after the reset yet

grim grotto
#

Oh it could explain it then

boreal mist
#

anyone know how to fix the issue that heroku cant find module dblapi.js? it works on self host but not on heroku/github

polar verge
#

is possible to .hasVoted() return also the left time to vote again? I am trying to avoid storage each vote in the db

sullen nymph
polar verge
#

I see, thanks turtles

rain heart
#

You could technically track that yourself using webhooks

random jasper
rain heart
#

in your main file it seems like

#

i dont think you define the client inside other files

restive otter
rain heart
tribal sky
#

hii

#

is there a way to test if on_dbl_vote works without waiting for 12hrs ?

#

in the python lib

#

?

vivid schooner
#

Can someone help me how can i setup vote weebhook?

rain heart
#

@tribal sky use the test webhook with on_dbl test

#

Read the docs

vale moon
#

How to fix "servers"? is that it appears that it is at 1 when in reality it is at more than 50

rain heart
#

You need to frequently post it yourself

#

Topgg doesn't do that for you

restive otter
rain heart
#

eris is js

#

So yes

restive otter
#

ok

merry stump
#

Should i add some password in py self.dblpy = dbl.DBLClient(self.client, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)

#

Anyone

#

cmon atleast someone

#

;-;

rain heart
#

in the password field yeah

#

you can define it yourself

#

it should match the one on your bot page settings

merry stump
#

What ?

#

Like hmm password?

#

Ok u mean i can make my own password and insert it in there

#

@rain heart ?

rain heart
#

any password

merry stump
#

Ohk

rain heart
#

you can call it PineapplePizza

#

or CheesePizza

#

or whatever

merry stump
#

Ohk thanks

tiny heart
#

In webhook URL, which URL do I have to write?

rain heart
#

your servers ip:port/dblwebhook

tiny heart
rain heart
#

Where are you hosting your bot?

rain heart
#

the ip of where your bot is running on

#

can't help you then, google how to get the repl.it ip

tiny heart
#

ohh

#

ok

#

thx 😄

tiny heart
rain heart
#

lol

#

wrong

tiny heart
#

than?

rain heart
#

look closely, if you dont know it, look through the knowledgebase of replit, otherwise ask their support

tiny heart
#

ok

tiny heart
rain heart
#

no clue

#

i dont use replit

#

i use a vps

tiny heart
rain heart
#

That's up to your code you used

tiny heart
rain heart
#

it sends a request to it

#

a request to your webhook

#

and then you can make your webhook use the data from the request for for example rewarding the user

tiny heart
rain heart
sullen nymph
#

@tiny heart repl.it webhook is reached via the project URL

tiny heart
#

than what to write in webhook url if i use repl.it?

sullen nymph
#

That's exactly what I just explained

tiny heart
#

???

#

i am very confused

sullen nymph
#

I'm generally amazed how you people manage to make bots without reading comprehension

#

repl.it should/does give you URLs to use for repls

tiny heart
#

yes it does

sullen nymph
#

So

#

When you open it, what do you get

sullen nymph
#

I sincerely hope you are simply fucking with me and actually seeing the URL to the fucking right of the code editor

tiny heart
sullen nymph
#

Did you handle the incoming request in any way?

tiny heart
sullen nymph
#

Send me the URL in DMs

tiny heart
#

ok

tiny heart
#

No request coming in my webhook URL
My Code :-

const express = require('express');

var bodyParser = require('body-parser');

const server = express();

server.use(bodyParser.json())

server.all('/', (req, res)=>{
    res.send('Your bot is alive!')
})

function keepAlive(){
    server.listen(3000, ()=>{console.log("Server is Ready!")});
}

module.exports = keepAlive;```
rain heart
#

dm me the url, i'll test it through a request maker

tiny heart
#

ok

subtle hare
#

Dbl Webhook nasıl oluşturabilirim

tiny heart
#

what to do of the information which i got when i clicked on test in webhook?

vale moon
#

Could you tell me how to fix that? or pass me a "reply" code to do it...

willow spindle
jovial verge
#

Hi

worldly saddle
#

how? you do that like vote thing

undone hill
#

Im having too much high latency on my bot and keep getting this error
any help?

willow spindle
#

ratelimit

#

what are you doing

undone hill
#

i just required the api

restive otter