#topgg-api

1 messages · Page 118 of 1

willow spindle
#

No. Learn JS syntax first

rain latch
#

Please

#

🙏

willow spindle
#

Dont beg

rain latch
#

I will learn it too

willow spindle
#

Learn now

mortal ore
#

lmao

rain latch
#

Well, where should I start? Do you know any site?

turbid ocean
#

.........

willow spindle
#

Yes, google

mortal ore
#

does anyone know dblpy here?

rain latch
#

where should i start

radiant tendon
#

so i'm using this api but when i try to post the server count it says "Error: 404 Not Found" anyone knows how i can fix this? or is it because my bot is not yet accepted?

willow spindle
#

Hmm can you show your code

mortal ore
radiant tendon
#

alright thanks

turbid ocean
#

'\

willow spindle
#

How did you know that

mortal ore
#

if it is accepted and not working send ss

mortal ore
radiant tendon
mortal ore
#

then that may be the error

willow spindle
#

Then thats why

mortal ore
#

i think they have provided the code needed to post the guild count on their website

#

so u cant go wrong with that

#

@willow spindle pls tell me if you know how to solve this

willow spindle
#

I don't know python

mortal ore
#

aah, sorry for the ping thn

#

If anyone knows python please help me.

queen current
#

Hey
How can I learn shortly how to make my bot sending a thanks message when someone vote for him (ping me when you answer pls)
Thanks for your help

mortal ore
#

which language?

queen current
#

javascript (ping me, there is no problem to ping me)

jaunty plank
#

@queen current

queen current
#

yes but how setup the webhook 😁

#

I guess it's very easy but

#

and short

#

but

jaunty plank
#
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!`); });
queen current
#

yes I see this

jaunty plank
#

Then on your bots edit page in the webhook section fill in the url and auth

queen current
#

but it's saying there is a error in a file in the dblapi module

jaunty plank
#

What error

queen current
#

Don't remember, I tried this a month ago kind of

#

sorry

#

I can do this again wait

#

401 Unauthorized

#

at this line ⬆️

jaunty plank
#

Unauthorized would be a bad token, or a bad authorization.

#

You need to make sure your authorization is correct mainly, your token doesn't need to be correct if your just using the webhook.

queen current
#

ok

#

how can I see my top.gg bot token

jaunty plank
queen current
#

ok thx

#

is it that?

jaunty plank
#

Yeah

queen current
#

ok

#

I've paste it on 'Your dbl tooken here'

jaunty plank
#

Authorization is whatever you make it(its like a password.

queen current
jaunty plank
#

Nope that's just an event

queen current
#

ok but password

#

hook.hostname

#

etc

jaunty plank
#

Hook.hostname is in an event

queen current
#

ok

#

so I replace 'password' with a password that I paste on 'Authorization' on the website

jaunty plank
#

You need to fill in the url and auth on the site.
The url will be something like http://ip:port/dblwebhook

And yeah, id look into making it something secure though, since its the password the webhook will use.

queen current
#

where can I find the ip?

rapid kettle
#

WHEEre are you hosting?

queen current
#

it's the host ip?

rapid kettle
#

yea

queen current
#

oh

#

ok so when I have it

#

0.0.0.0??

#

don't think it's good

jaunty plank
#

It always logs 0.0.0.0

#

0.0.0.0 just means any ip available to the code.

#

You'll want to use your proper ip

queen current
#

ok

queen current
#

sorry for ping

queen current
jaunty plank
#

Just on the top.gg page use the real ip

#

The one that is logged doesnt matter.

queen current
#

ok

#

so I haven't any error !!!!

#

Am I right?

#

@jaunty plank sorry but I'm very excited at the ideea that it can work

queen current
#

doesn't work

#

I have vote and nothing happen

#

RIP

jaunty plank
#

Do you have any firewalls?

queen current
#

yes but I have Autorise acces

#

I think I need to re-autorize

fast meteor
#

wdym is the library not compatible with python3.9?

sullen nymph
#

Yeah, it's not KEKW

queen current
#

Thé évent ready is working but not thé vote one

#

(ping me when you answer)

jaunty plank
#

You said your hosting on a vps right?

queen current
#

Nope

#

On a server nodeJS

#

Is it a problem?

jaunty plank
#

So wheres it hosted.

queen current
#

On a basic server

#

I don't what's thé name

floral spade
#

I'm using @restive otter/sdk

#

ooops i tagged someone

rain heart
#

why is there some dude called top.gg Kek

#

and that is most likely due to bad requests

floral spade
#

Nah that's all the test requests

#

why would that be bad requests?

#

does it have ratelimits?

rain heart
#

nope it shouldn't

#

Oh

#

you're getting the webhooks?

floral spade
#

Yes

rain heart
#

then there's something screwed up with the auth of the request

floral spade
#

nah it's the same request all the time...

#

how...

#

So is there something wrong on top.gg's side?

rapid kettle
#

getting requests is normal

#

its how shit gets there

floral spade
#

but shouldn't it be a post request?

rapid kettle
#

oh shit

#

i just overlooked the

#

get bit

#

lmaoo

floral spade
#

Thats kinda weird...

#

And why are half the requests without a correct authorization header getting through

rain heart
#

maybe that's just random requests from people who accidentally access it

#

or test it

#

would explain both the 403 (post request without authorization) and the get (accessing the url from a browser)

floral spade
rain heart
#

log the auth code

#

see if it matches

floral spade
rain heart
#

you need to press save

#

in order to apply the change

#

and be able to test it

floral spade
#

Yup, it is not getting updated on top.gg

#

still sending me requests somehow

rain heart
#

very weird, try making a test request using postman maybe

floral spade
#

so what should be my body?

#
{
    "bot":xxxx8172109165xxxx,
    "user":xxxx3598873234xxxx,
    "type":"test",
    "isWeekend":true
}

This right

rain heart
#

yeah use that as test data

floral spade
#

Uhh wait that worked...

#

sooo what's happening with top.gg?

#

it's using wrong auth half the time?

rain heart
#

very very weird then

#

never had that issue happen to me

floral spade
#

403 is wrong auth right?

rain heart
#

once i changed the value, it worked perfectly

#

correct

#

502 is always wrong request method

floral spade
#

weird...

rain heart
#

indeed

floral spade
#

atleast no one can post votes without the proper header that's good to know

#

or maybe i just got ratelimited to changes on their site or something...

#

And i'm still getting weird get requests although no one has the url except me and i'm not opening it in a browser...

rain heart
#

you can't get ratelimited from webhook requests

#

unless ngrok ratelimits requests which i highly doubt Kek

floral spade
#

Ahh i mean requests to update settings on dbl...

rain heart
#

shouldn't cause an issue either

floral spade
#

sooo it's not updating anything which save on top.gg....
so it's using the old header and url...

#

but that shouldn't cause half of the requests to be unauthorized...

rain heart
#

i can only suggest try testing webhooks in like 1-2 hours again

#

maybe you did get ratelimited in any way

restive otter
#

Api ne

rain heart
#

what?

floral spade
#

It's sometimes using the old url and sometimes the new one... Weird...

rain heart
#

yeah try it later then

floral spade
#

yup...

rain heart
#

really weird, haven't seen that before

floral spade
#

Yup i spot an error which it gave 1000 years later after i clicked save...

rain heart
#

check your inspect element console

#

and look for the error code

floral spade
restive otter
#

I think

#

I can't open it too

rain heart
#

nah now you actually got ratelimited Kek

floral spade
#

Nevermind it took like 40 secs to load...

rain heart
#

check your console when you try to save

floral spade
#

not ratelimited... Their servers are prolly having a bad day today....

restive otter
#

?

rain heart
floral spade
rain heart
#

nah that error has always been there

floral spade
#

ahh ok...

restive otter
#

I knoe

#

I used dbl

#

But dbl is depracted ...

rain heart
#

then use the new library

floral spade
restive otter
rain heart
floral spade
rain heart
#

bad gateways happen from time to time

restive otter
#

Thx

floral spade
#

ANd now it worked finallyyyy!!!

restive otter
rain heart
floral spade
#

ig... some things took too long to update everywhere...

restive otter
#

appi oiu hiriin quuyr le

rain heart
#

English please

restive otter
#

дай мне кувшин вина

floral spade
restive otter
#

Одно пиво, пожалуйста

molten glen
#

1

#

2

floral spade
restive otter
#

почему ты переводишь это предложение

restive otter
#

ок

hot apex
#

@vital anvil how come the top.gg bot server counter is wrong on my page all the time?

lucid rock
#

sa

#

mesaj silen bot çalışmıyo bende

floral orchid
#

@lucid rock hangi bot çalışmıyorsa o botun destek sunucusuna gidip yardım alabilirsin

lucid rock
#

mc-at botu mesaj silmiyo

#

ve sunucu linki yok

#

mc-at botunun

#

atarmısın rica etsem

willow flint
#

how do i get the webhookAuth

#

for my bot

rain heart
#

That is something you define for yourself

#

it has to be the same on your bot page settings and your code

willow flint
#

?

rain heart
#

Yup

willow flint
#

Okay

rain heart
#

also, you need a webhook url too

#

most likely your servers ip and /dblwebhook iirc

willow flint
#

Okay

rain heart
#

is that a valid webhook url?

#

it has to be your webhook url which is most likely your servers ip or domain

#

and :yourport

willow flint
#

Idk how to get that

#

:/

rain heart
#

read the webhook documentation from the library you're using

willow flint
#

ok

hearty lintel
#

no

#

learn how webservers work please

willow flint
#

?

hearty lintel
#

google it

quartz quest
#

Hi, does anyone know how I can do a webhook for Top.gg votes?

rain heart
hearty lintel
#

@quartz quest what language?

quartz quest
hearty lintel
#

use the example at the bottom

quartz quest
#

Thanks

restive otter
#

Hello
Authorization
You can use this value to verify the requests are coming from us.
How do i get on that?

rain heart
#

you can define it yourself

#

it has to be the same in your bot settings page

#

and your code

shell steppe
#

when someone votes, he sends a channel @rain heart

#

how

#

:"(

rain heart
#

You might have seen webhooks mentioned in your apps' settings and wondered if they're something you should use. The answer, in a nutshell, is probably yes.
Webhooks are one way that apps can send automated messages or information to other apps. It's how PayPal tells your accounting app when your...

shell steppe
rain heart
#

Then you are not ready to do something with webhooks yet

#

i recommend coming back to it once you have more experience

shell steppe
#

shiiit

#

ok,ty

ripe ether
#

I got an error saying "there was a problem saving"
what could be the problem?

#

^

#

the bot has not been approved yet, could that affect it?

#

the exact message is: There was a problem saving the webhook :Thonk:

hearty lintel
#

it might be

#

yeah i can save webhooks the best guess is that it's not been approved yet

#

on your other bot can you save it fine?

ripe ether
#

yeah, it did

#

so thats probably the error

#

thanks!

#

I am trying to get the user that voted

#

but it is not working:

#
app.get('/webhook', async function (req, res) {
  console.log(req.body.user)
  await res.send('Successful')
})```
#

using express, what am I doing wrong?

hearty lintel
#

it's a post not a get

ember kayak
#

are the backend or cloudflare servers having issues currently i have been continously getting 500 Internal server errors with the Node.js Package. the error body says server is cloudflare but there is a "database error"

ripe ether
#

why wont this recieve:

#
app.post('/post-test', (req, res) => {
    console.log('Got body:', req.body);
    res.sendStatus(200);
});
#

it just has a blank json object

rain heart
#

i mean if you're going to send empty data, you wont get any data

ripe ether
#

@rain heart

#

it does that whenever i test the webhook

hoary urchin
#

i got this error when running my bot in local

    at IncomingMessage.<anonymous> (/Users/smh/Documents/Bot/Music Bot/ChilledChino 2/node_modules/dblapi.js/src/index.js:118:25)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:4584) 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```
Is it just my slow internet or something?
dusk hound
#

There is a way to send a "test" vote to see if a webhook is working?

blissful notch
#

It's on your bot's edit page I believe.

dusk hound
#

Oh, yeah I just saw it. Thank you!

frail gorge
hoary urchin
#

ooh. thank you :D

grim cave
#

ayy im new here, what does top.gg api do?

restive otter
#

yeah

#

i was wondering the same thing

hearty lintel
trail gazelle
#

Hey, how can I connect my discord.py bot to top.gg's website so I can track votes and pay in bot currency rewards from python?

rain heart
#

Through webhooks

ivory valve
#

sdasdas

restive otter
#

what is the ratelimit for top.gg api?

sullen nymph
#

60/60s

restive otter
#

wtf? how can i make vote reminders then
bruh thats so hard ratelimit

autumn pendant
#


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!`);
});

``` This should console log who voted right?
restive otter
#

@sullen nymph wdym webhooks?

rain heart
#

Webhooks you can enter on your bot page settings

restive otter
#

no but i want to make a vote reminder command

sullen nymph
#

Create a webhook, receive votes in real time, check if user opted-in for vote reminders, if yes, send vote reminders

restive otter
#

no an event for receiving vote

sullen nymph
#

An event for receiving votes is iterally why you'd use a webhook

autumn pendant
#

idk if im doing it right

restive otter
#

hm idk if you are understanding what im trying to say, so i want to do like

  1. i have made a vote reminder command to enroll user for vote reminders.

  2. It will checks the list of users in vote reminders every 6h and tell them to vote for bot.

  3. if i just use the api it will get rate limited as there will be many users in the vote reminder list

sullen nymph
#

Why would you need the API in this case?

restive otter
#

how will i check if the user have voted or not then

rain heart
#

webhooks

sullen nymph
#

Yeah, using the API in this case sounds painful

#

So use webhooks mmlol

restive otter
#

how? can u give a example im confused

sullen nymph
#

Most official top.gg libraries support running webhooks

restive otter
rain heart
#

Correct

restive otter
#

how do i use it i mean there is nothing related to that

rain heart
#

There is, go to your library on the navigation to the left

#

Section tools

#

Depending on your library, there's also something about webhooks

restive otter
#

this is the only thing related webhook

#

but its for receiving votes via webhook

sullen nymph
#

Yeah, receive votes via webhook, store them locally, and rely on them instead of fetching the API

restive otter
#

what? we need to store that locally? bruh

sullen nymph
#

In your case it's easier to do that

bitter dove
umbral cobalt
#

how to reward users when they vote for my bot ?

rain heart
#

webhooks

umbral cobalt
#

like ..
how exactly ...

rain heart
umbral cobalt
coral valley
#

How long should it take until my bot publishes?

rain heart
#

1 week if you just submitted it

umbral cobalt
#

what to put in webhook URL ?

rain heart
#

most likely your public server address you're hosting the bot from

#

the 0.0.0.0 is just replaced with your public ip address of the server you're hosting it on

umbral cobalt
#

@rain heart can i DM you ?

rain heart
#

about webhooks? can't really help you with coding it

umbral cobalt
#

;-;

#

i am totally confused ..

restive otter
#
const Topgg = require('@top-gg/sdk')

const app = express() // Your express app

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

app.post('/dblwebhook', webhook.middleware(), (req, res) => {
  if(req.vote) {
      
    const vote = req.vote;
    
    let uservotes = db.fetch(`votes_${vote.user.username}`);
    if(uservotes === null) {
        db.set(`votes_${vote.user.username}`, '1');
        votes = '1';
    } else votes = uservotes;

    const channel = client.channels.cache.get(id);
    if (!channel) return console.log('Bot Voting Log Channel ID Is Not Correct'); 

    if (weekend === 'true') {

    channel.send(`${vote.user.username} Baraye Bot Vote Dad!\nVotes: ${votes}`);
    db.add(`votes_${vote.user.username}`, '2');

    } else {

    channel.send(`${vote.user.username} Baraye Bot Vote Dad!\nVotes: ${votes}`);
    db.add(`votes_${vote.user.username}`, '1');

  }
  } // your vote object
}) // attach the middleware

app.listen(5000) // your port```
why this is not working when someone vote?
#

tag me for answer pls

hearty lintel
#

@restive otter are you getting an error or is it just not posting?

#

oh i see

#

vote.user is just a user id the webhook provides no info like username etc

restive otter
#

i can't get username?

hearty lintel
#

just get the user form your cache

haughty rune
#

what do i need to do to set up my vps for recieving webhook posts

hearty lintel
#

open your firewall for the port of your webhook p much

haughty rune
#

like if i leave it as <my.vps.ip>/dblwebhook will that work

restive otter
#

ok thx

#

but

hearty lintel
#

if you have no firewall setup a) yes that'll be fine b) set up a firewall lol

restive otter
#

im not getting error about vote.user.username

haughty rune
#

ok ty jpb

hearty lintel
#

np

restive otter
#

it's not giving anything when i vote

hearty lintel
#

ah

restive otter
#

ye

hearty lintel
#

ok make sure your webhook port is open

restive otter
#

wait lemme check

hearty lintel
#

if you want to test if it's open add app.get('/', (req, res) => res.send('test'))
then go to the ip:port in your browser

restive otter
hearty lintel
#

does it work?

restive otter
#

nope

hearty lintel
#

seems like a heroku issue i suggest doing research on how to do it

#

it might only allow specific ports etc

restive otter
hearty lintel
#

http?

restive otter
#

both of this is giving error

hearty lintel
#

you should be able just to go to it in your browser

restive otter
#

it gives me Your App Is Listening Port 5000

#

uh then i can't log votes in heroku D:

#

is there a php source to interact with top.gg?

restive otter
#

Ok i truned my pc off
i am going to try it tomorrow

tall salmon
#

Hello, I want to show the server count on my bot's page
I put this line in the client.on("ready") event

    const dbl = new DBL('my token here', client);

But I get the error "TypeError: Cannot read property 'run' of undefined"

#

I did write const DBL = require("dblapi.js"); before that too

#

Can someone help me with this?

jaunty plank
#

the error is happening on that specific line?

#

or can you show the line the error is happening on.

tall salmon
jaunty plank
#

whats on line 81

tall salmon
#

This command.run(client, message, args);

jaunty plank
#

that error isnt for the api, its your command handler erroring.

tall salmon
#

When I remove the api stuff, it works fine

hearty lintel
#

then you probably put it in the wrong place

tall salmon
#

const DBL = require("dblapi.js"); is at the top of the script
const dbl = new DBL('token', client); is in the client.on("ready") event

#

where else does it have to be?

jaunty plank
#

is the error happening at startup?

tall salmon
#

Yes

jaunty plank
#

did you accidentally delete a }) somewhere

tall salmon
#

Uh

#

just a sec

jaunty plank
#

specifically the one for your on ready event.

tall salmon
#

Yeah, it was missing there, but still the same error

jaunty plank
#

put it back at the end of your ready code.

#

if its still erroring there then you probably accidentally deleted more closing brackets.

tall salmon
#

wdym back of the ready code

jaunty plank
#

so everything you run in your ready event needs to be inside the ({ and })

tall salmon
#

const dbl = new DBL('token', client); is the last line in ready event

jaunty plank
#

okay then }) on the line after that

tall salmon
#

Yeah, it's there

jaunty plank
#

and same error when you save and restart?

tall salmon
#

Yeah

jaunty plank
#

are you using an ide?

tall salmon
#

Yeah VS Code

#

Actually this time it didn't give any error

#

but it didn't update on the site either

jaunty plank
#

the site takes time

tall salmon
#

hmm

jaunty plank
#

give it 5 minutes, then shift+f5

tall salmon
#

Alright

#

Thanks

hearty lintel
#

or hit the refresh data button i think

solar quartz
#

How i create my own endpoint to get votes ?

jaunty plank
#

your trying to make your own api?

tall salmon
#

@jaunty plank it gave the same error after 5 minutes in the IDE 😅

#

cannot read property run

jaunty plank
#

so, that seems like a command handler issue still.

#

which is why i was asking if it was running at startup

#

someone ran a command i think, and the command handler errored.

tall salmon
#

umm

#

but then it works without the api

#

the cmd handler is fine without the api

#

and Im calling const dbl = new DBL('token', client); in the ready event, not in the message event

jaunty plank
#

yeah, so hows it affecting your message event.

tall salmon
#

so I don't think someone using a command should affect it

jaunty plank
#

but the error is happening in your command handler

#

index.js line 81

#

and the error specifically says, your command is undefined(potentially someone running a command that doesnt exist?)

#

which is why it not running on startup was important.

tall salmon
#

umm

#

well, my bad, I used a command that doesn't exist, and it gave me the same error

jaunty plank
#

lol, np.

tall salmon
#

how would I fix it tho

#

@jaunty plank so does it send the servers data to top.gg tho?

jaunty plank
#

it should send the server count, if you want to be sure its posting you can add the optional events

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

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

Nah, it doesn't send lol oof

#

and this happened on start

#

@jaunty plank This happened on start, when nobody used a command that doesn't exist

#

doesnt send any log either

hearty lintel
tall salmon
#

@hearty lintel it literally gives the same error on start when using that module

#

.__.

hearty lintel
#

yeah i'm just saying

#

the error you're getting is an issue with your code

#

i suggest using a proper IDE which can show you errors and describe them

tall salmon
#

It's VS Code

jaunty plank
#

check the problems section

tall salmon
#

nothing there

hearty lintel
#

paste lines 76-85

tall salmon
#

um

#
        if(command.timeout){
            if(Timeout.has(`${message.author.id}${command.name}`)){
                return message.channel.send(`Wait ${ms(command.timeout)}econds to use that command again. DON'T BREAK ME!`)
            }
            else{
                Timeout.add(`${message.author.id}${command.name}`)
                setTimeout(() => {
                    Timeout.delete(`${message.author.id}${command.name}`) 
                }, command.timeout);
            }
        }
        command.run(client, message, args);```
#

I made a timeout for that, doesnt really matter in this case I guess

restive otter
#

what is a good interval for posting statistics?

hearty lintel
#

30 minutes is the default

restive otter
#

like it handles by it self?

hearty lintel
#

if you use the library yes

tall salmon
#

Hey, how will I go about fixing that the bot also reads messages about commands that dont exist?

hearty lintel
#

@tall salmon well i'm not sure what's wrong it's not an issue with the top.gg api so this channel isn't correct

tall salmon
#

Like I made a typo in -ping and mistakenly changed it to -pung, but the prefix is still there, so the bot reads that message

hearty lintel
tall salmon
#

hmm

restive otter
#

i need an https server running to get votes right?

hearty lintel
#

no just an http works

restive otter
#

ok

tall salmon
#

I have a question

#

When we call the postStats function in the client.on ready event, does it happen after 30 minutes or happens then and there and again happens after 30 mins?

#

In the setInterval

#

It's not logging and not updating on the site either

#

I've been waiting and it's not posting the stats

jaunty plank
#

Which lib are you using?

tall salmon
#

dblapi.js

jaunty plank
#

The auto poster should post for you.

tall salmon
#

It's not logging/sending anything

jaunty plank
#

Is the constructor outside the bots ready event?

tall salmon
#

No

#

Inside it

torpid compass
#

could someone help me with detecting votes for my bot?

robust whale
#

@torpid compass There is a ready-made boat that can do this for you

torpid compass
#

I was going to use the API

robust whale
#

but I don't know how to add it to your own bot

jaunty plank
#

Pretty sure it should be outside the client ready event @tall salmon

tall salmon
#

hmm

#

Ok let's test

torpid compass
mortal crag
#
const dbl = new DBL("token", { webhookPort: 5000, webhookAuth: "password" });
dbl.webhook.on('ready', hook => { 
console.log(`Webhook on`); 
}); 
dbl.webhook.on('vote', vote => { 
console.log(`User with ID ${vote.user} just voted!`); 
});``` but when a person vote not worl
#

Work*

jaunty plank
#

Your constructor needs to have an auth and port set.

torpid compass
#

I have the same thing @mortal crag

mortal crag
#

My?

torpid compass
#

@jaunty plank where can we find the WebhookAuth

jaunty plank
#

You define the auth as whatever you want

torpid compass
#

ohhh

jaunty plank
#

Just needs to be the same between both the bot and website

mortal crag
#

Of the bot page

#

(The webhook password)

jaunty plank
#

Webhook password is the webhook auth

mortal crag
#

Yes

#

I Think

#

That

torpid compass
#

Where do I find the webhook auth on the website

jaunty plank
#

Edit bot webhook section

torpid compass
#

aah

jaunty plank
#

Yep they need to be the same

tall salmon
#

@jaunty plank It updates on site but doesn't log for some reason

torpid compass
#

ahh thanks so much

jaunty plank
#

Ah, then no problem, the log doesn't really matter.

tall salmon
#

erm

ripe ether
#
const DBL = require('dblapi.js');

yourDBLTokenHere = "my_token"

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!`);
});```
#

that doesnt recieve anything

#

when i test the webhook

#

with password "password"

#

what could have gone wrong in the code?

#

wait, nope, it worked, i was just forwarding to the wrong url lmao

torpid compass
#

When I test the webhook, nothing happens

#

what's supposed to happen?

dusk hound
#

please i beg lmao

torpid compass
#

@dusk hound does your voting work because mine doesnt

#

I think I did something wrong

dusk hound
#

wdym

#

"it doesn't work" doesn't really tell me the isuse

torpid compass
#

Does your bot detect voting

#

so when someone votes it logs in the console or something

dusk hound
#

yup

torpid compass
#

how did you do it?

dusk hound
#

express Thonk

torpid compass
#

?

dusk hound
#

the node library

#

express

torpid compass
#

Did you find a tutorial or something or did you do it yourself?

dusk hound
#

well i read the docs of the lib im using

#

and i made it so it sends a request to my webserver and my webserver sends a payload to my database

torpid compass
dusk hound
#

you're server ip, port, and path

#
server ip -> 127.0.0.1
port -> 5000
path -> vote
```the server ip i provided wouldn't work.
torpid compass
#

do you know where I can find this stuff? I didn't find anywhere in the docs that told me I had to do this xd

dusk hound
#

Well, I don't use the api's listed on the api page. I use, top-gg/wrapper

#

Is their a endpoint to check when a user voted, or do I have to store it myself?

restive otter
#

I used the Api to get info about bot, and got the "points" from it, and it says 271, while my bot has like 95. Anybody knows why?

torpid compass
#

Could someone help me with detecting my bots votes

hot axle
steady cove
#

having errors with ```py
async def on_guild_post():
print("Server count posted successfully on DBL")

#

it says

#

method has no argument

sullen nymph
#

self

steady cove
#

???

#

self

#

where would i put that?

#

@sullen nymph

sullen nymph
#

in the function arguments

steady cove
#

soooo??

#

like

#

not my full token

steady cove
#

in the cog

sullen nymph
#

You just leaked your top.gg token

steady cove
#

i did not

#

doont worry

sullen nymph
#

Anyhow

steady cove
#

i cut out some of it

sullen nymph
#

You people can't just crop any sensitive data out from the public, can you

steady cove
#

sorry

sullen nymph
#

All methods in Python must implement an argument that refers to a current instance, usually named self or cls. In this case your on_guild_post method doesn't have a self argument and a cog listener decorator

steady cove
#

???????

#

soo what do i have to do??????
@sullen nymph

sullen nymph
#

I did literally give you an explanation but it seems to happen that you are not familiar with OOP in Python whatsoever

steady cove
#

well

sullen nymph
#

Add a fucking self argument to your function

steady cove
#

sooo

#

like self.

#

im tired right now

sullen nymph
#

So like on_guild_post(self)

steady cove
#

please be easy on my

#

k

#

so

#

lemme run it

sullen nymph
#

It should be ingrained into you to the point where you do and notice it without realization

#

Yeah no shit

#

I said apply cog listener decorator

#

The event won't fire at all otherwise

steady cove
#

then it will print smthin

#

once it joins or leaves a server

sullen nymph
#

You people ever read documentation

steady cove
#

SORRY

sullen nymph
#

What does "on guild post" that doesn't even come from discord.py have to do with guild join or leave

steady cove
#

ok

#

so

sullen nymph
#

on_guild_post is an event that's emitted whenever dblpy's autopost posts a server count successfully every 30 minutes (if it's enabled)

steady cove
#

how do i know if its enabled

#

?

#

?

sullen nymph
#

you would do autopost=True in the DBLClient parameters to enable it

mortal ore
#

Can someone tell me how to use the event references in python?

#

like on_dbl_vote()

heady cloak
# mortal ore like on_dbl_vote()

yeah I find it kind of confusing too, since they say that it should be inside the class one time but outside (as a bot event) another time

rain heart
#

test votes are the votes you trigger with the test button on your bot page

#

There's 2 types of Votes: upvote (vote done through voting your bot on the page) and test (the test button)

rain heart
#

on your bot page settings

#

on the webhook section

heady cloak
#

ooh thanks ill look into it

#

oh yeah i found it now thanks

#

@rain heart these are the parts i use to implement the api to my bot, but it does not work, did i miss something?

import dbl

class TopGG(commands.Cog):
    def __init__(self, bot):
      self.bot = bot
      self.token = os.getenv("TOPGG_API_TOKEN")
      self.dblpy = dbl.DBLClient(self.bot, self.token)

@bot.event
async def on_dbl_vote(data):
    print(data)
rain heart
#

can't help you, no clue of python

#

what is the ip you entered though? make sure it's not either 0.0.0.0 or localhost or 127.0.0.1

heady cloak
#

oh

#

no it's a custom domain

rain heart
#

dm me the url, i'll test it on my end with some test data

heady cloak
#

the url to what?

rain heart
#

the webhook

#

you have to enter your webhook url in your bot page settings

#

no wonder it doesn't work if you haven't done that

heady cloak
#

I'm not using a webhook...

#

It's just a bot

rain heart
#

The thing you seem to be doing now is listening to the event when someone votes. That is done through webhooks

#

the wrapper does not simply make that happen, you need to enter the webhook url inside your bot page

heady cloak
#

do I need a separate webhook or can I implement it into my bot?

rain heart
heady cloak
#

yeah i looked into that but I couldn't find anything about webhooks

rain heart
#

on the client initialisation

hollow arrow
#

!p klay

rain heart
#

you could set the path to something like /dblwehook and the port to 5050 for example

#

your webhook url should then be something like http://example.com:5050/dblwebhook

#

this is needed for getting new votes

heady cloak
#

oh so it's just an https request?

rain heart
#

that is what a webhook is, yeah

heady cloak
#

oh okay

#

thanks

#

but how is the "dbl" library connected to this?

rain heart
#

the dplpy library creates a small webserver to listen to requests to that webhook, then fires your on_dbl_webhook or on_dbl_test_webhook when a request came through depending on what type of vote it is

heady cloak
#

oh okay

#

but I already have a webserver

rain heart
#

That shouldn't matter, unless you're using port 80 on your webhook of the bot

#

then it wouldn't work

heady cloak
#

okay so i have the library and I'm using it; how do I set or know what the path is?

sullen nymph
#

There's no webhook in the events

#

they're just on_dbl_test and on_dbl_vote

heady cloak
#

https://mywebserver.ok/THISPART

rain heart
#

inside the bot page settings

sullen nymph
#

Fuck, I meant the webhook part in event names

#

Also

rain heart
#

oh yeah Kek

sullen nymph
#

SPECIFY YOUR FUCKING PORT AND AUTH

#

READ THE DOCS

#

thank you for coming to my TED talk

rain heart
#

Trying my best on my end without any python knowledge, just knowing how to read docs

sullen nymph
#

webhook_port must be set in order for the webhook to actually run

#

The rest is for it to work as needed

heady cloak
sullen nymph
#

Thus

#

THIS

#

I can't type

heady cloak
#

yes but what path?

sullen nymph
#

/dblwebhook

heady cloak
#

is that the exact default?

sullen nymph
#

mhm

heady cloak
#

thanks

sullen nymph
#

It's the default value to enter after ip:port (or domain) in the URL

heady cloak
#

and the port is 80?

sullen nymph
#

Whatever you set in webhook_port

heady cloak
#
class TopGG(commands.Cog):
    def __init__(self, bot):
      self.bot = bot
      self.token = os.getenv("TOPGG_API_TOKEN")
      self.dblpy = dbl.DBLClient(self.bot, self.token)

like this is my code

#

ooooh ok

sullen nymph
#

Pain, pain of existence

#

You haven't specified webhook_port and webhook_auth in your DBLClient

heady cloak
#

found in the docs, it's webhook_auth, webhook_path and webhook_port

sullen nymph
#

Mhm

heady cloak
#

yeah but the thing is i looked at another code snippet and they didn't say anything about this

sullen nymph
heady cloak
#

maybe

sullen nymph
#

Or the github repo but wrong example

heady cloak
#

not github

sullen nymph
#

Yeah, then it's on the docs page on top.gg

#

That'll be reworked soon anyway so I'd suggest referring to the official dblpy docs (soon to be renamed officially to python-sdk possibly)

heady cloak
#

didnt topgg remove the server count thing in the newer design?

#

since i cant see it

sullen nymph
#

Shard count is planned to be removed completely, but server count will stay afaik

mortal ore
#

so how to use the events?

heady cloak
#

alright sammy I will try to make a python snippet for this and i will tell you how to do it

mortal ore
#

ooh wow. Thank you very much.

heady cloak
#

alright i think i need help again, this isn't working

#
class TopGG(commands.Cog):
    def __init__(self, bot):
      self.bot = bot
      self.token = os.getenv("TOPGG_API_TOKEN")
      self.webhook_auth = os.getenv("TOPGG_AUTH")
      self.dblpy = dbl.DBLClient(
        self.bot,
        self.token,
        webhook_auth=self.webhook_auth
      )

@bot.event
async def on_dbl_vote(data):
    print("SOMEONE VOTED!")

@bot.event
async def on_dbl_test(data):
    print("SOMEONE TESTED!")

this is my code

#

It's not printing anything during test, I don't know what to do...

mortal ore
#

wht is bot there?

heady cloak
#

?

mortal ore
#

is it the client u use for discord?

heady cloak
#

yes bot is client

#

for discord

rain heart
#

you still didn't define a port

#

that is needed for the webhook

heady cloak
#

but i did before

#

and it didnt work either

mortal ore
#

and the bot.event is outside the class?

#

right?

heady cloak
#

and it says port is optional and i guess the default is 80 because someone said that

#

yes

mortal ore
#

just to confirm

#

ok thanks, i will try this out

heady cloak
#

but it does not work...

rain heart
#

god fucking sharex

heady cloak
#

wth

#

Optional

mortal ore
heady cloak
#

but i did actually try with a port

rain heart
heady cloak
#

6000

rain heart
#

did you enter that port in the webhook url too?

rain heart
#

so for example http://example.com:6000/dblwebhook ?

heady cloak
#

yep

rain heart
#

remember that you can't use https by the way

heady cloak
#

i did

rain heart
#

try http if you always tried https

heady cloak
#

ok

#

YES finnaly it's showing SOMETHING

rain heart
#

because https then refers back to 443 and that just breaks it entirely

heady cloak
#

lol

#

i'll try with a port again

rain heart
#

make sure the path is correct

heady cloak
#

since this may be for the wrong webserver

rain heart
#

nah it's not

heady cloak
#

but i have 2

rain heart
#

look: http:// is always used for website stuff, if no port (in the sense of example.com**:6000**) is given, it will always refer to 80, your default webserver port as you know it

mortal ore
#

i tried many ways

#

none seem to work

rain heart
#

Nope, no clue about python Kek i just understand docs

mortal ore
#

lmao

heady cloak
#

oh god my bot is popular

#

already 10 servers

mortal ore
#

how many servers your bot is in (in total)?

heady cloak
#

now it's not working again :(

#

10 servers

mortal ore
#

nice

#

cool.

rain heart
heady cloak
rain heart
#

to where? the webhook url?

heady cloak
#

yes

rain heart
#

dm me the url, I'll try testing it from my end

heady cloak
#

to my webhook?

rain heart
#

is the bot not running?

#

what port did you enter on the client initialisation?

heady cloak
#

uhh

#

port 80 if i restart

rain heart
#

set it to 4000

#

you cannot use ports that are occupied

heady cloak
#

i had 4000 before

rain heart
#

80 is occupied by your main page

#

set it to 5000 then maybe

#

because it just times out for me

heady cloak
heady cloak
#

alright i set it to 5k

rain heart
#

does it say any errors in your console?

heady cloak
#

1

#

404

#

but i dont get it

#

i tried to reconnect but no more messages occur

rain heart
#

I have no clue then sad

heady cloak
#

oh

#

did you connect without a port?

#

then it connected to the main page

#

or the main webserver

#

so what can i set my main webserver's port to to make this work?

rain heart
#

main server does work

heady cloak
#

yes

rain heart
#

it just says Your bot name is alive

heady cloak
#

yeah

#

maybe i should just skip the whole client thing and use the main webserver instead

#

or delete the main webserver

#

it's a keepalive server

#

maybe i can delete the main webserver and just use the topgg webserver

#

YES

#

IT WORKS

#

FINALLY

rain heart
#

you just deleted the webserver and it worked?

heady cloak
#

yep

#

so that was a keepalive server

#

maybe i can just use the dbl server instead as a keepalive?

rain heart
#

probably yeah

worn vine
#

Is this code correct to show server count? Do I need to add something different?

client.on('ready', () => {
    setInterval(() => {
        dbl.postStats(client.guilds.cache.size);
    }, 1800000);
});```
rain heart
#

did you set your token through const dbl = new DBL('Your top.gg token', client);?

worn vine
#

oh i forgot that

torpid compass
#

Could someone possibly assist me with setting up vote detection? So when someone votes it does something

#

I've been trying but It's not working

torpid compass
#

I think that's what's causing me issues

rain heart
#

You need to create a webhook

torpid compass
#

I made a webhook

#

do I have to put the link in there?

#

When I paste it in there it says its not designed for that

rain heart
#

It is not for discord webhooks

#

You have to make a webhook through your bot

torpid compass
#

How do I do that

rain heart
#

Look for your corresponding library

#

you're using for your bot

torpid compass
#

I did this and used the code

rain heart
#

Post what you're using

#

also, you need to add the url of it in your bot page settings afterwards

torpid compass
#
dbl.webhook.on('vote', vote => {
    console.log(`${vote.user} has voted for Counter!`)
    const webhook = new Discord.WebhookClient('id of webhook', 'webhook stuff here in code')
    webhook.send(`${vote.user} has voted for me!`)
});
torpid compass
rain heart
#

You need to add the url of your webhook

#

you started your webhook on a specific port

#

that port is used for sending requests to it

#

it most likely looks like http://example.com:5000/dblwebhook

#

just instead of example.com:5000 replacing it with your servers ip and the port you defined

torpid compass
#

Where can I find my servers IP? I use Heroku for my hosting

rain heart
#

Can't help you with heroku stuff

#

google how to get the ip

torpid compass
#

Okay, so If I were to get the IP for my server

#

I would then paste the URL into the webhook URL

#

and it would work?

rain heart
#

it should if you started the webhook correctly

#

if you followed the documentation correctly

torpid compass
#

lovely

#

uh okay, thanks for the help though <3

#

@rain heart is there a bot that's already made to detect votes?

rain heart
torpid compass
#

okay thanks

timid dawn
#

so like im running something

#

on heroku

#

if i ping

#

it

#

it pings as down because they keep ICMP off on their servers

#

but you can

#

so

#

if you

#

are

torpid compass
#

wait what

timid dawn
#

whats the url for your app?

torpid compass
#

For Heroku?

timid dawn
#

like mine is

#

like that

still shore
#

how can I enable server count for my bot on top.gg

#

?

timid dawn
#

yes for heroku

#

like this whenever you build you app

rain heart
timid dawn
#

you will see the url on the bottom of the build output you can see your newest or previous build in the activity section of your apps heroku dashboard

torpid compass
#

hang on let me find it

timid dawn
#

ok

#

why do you need the ip though?

still shore
#

@rain heart Im pretty much confused about the api code , can you pls help me out btw Im hosting on glitch console

#

server count one **

rain heart
#

if you're confused with the documentations, then i cannot help you

#

Come back to it once you're able to understand documentations

still shore
#

you got it wrong

#

Im just saying I am confused about that server count one

#

Just sort me out pls

timid dawn
#

wheres the api docmented

rain heart
still shore
#

oh okay

#

thanks a lot

bold socket
#

anyone knows any good sites that can help with the webhooks for notifications when a server gets a vote?

dense shale
#

define notification?

bold socket
#

like for example when someone votes a server, it'll send a message in a channel? or any other way so my bot can know that someone voted

dense shale
#

¯_(ツ)_/¯

torpid compass
#

do I put it like this

#

0.000.000.00:5000/dblwebhook

rain heart
#

instead of the 0.000.000.00 your servers ip then

torpid compass
#

yes

sinful current
#

Hello

nocturne magnet
#

i need some help with the server count thing for pyhton

#

im unsure if the count is actually going there

#

it isnt

#

can you help me fix that?

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

    def __init__(self, client):
        self.client = client
        self.token = 'mytoken' # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.client, self.token, autopost=True) # Autopost will post your guild count every 30 minutes

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

def setup(client):
    client.add_cog(Topgg(client))
#

@slim storm

#

i did

#

im not getting errors

#

so whats wrong?

#

like

#

i followed the tut

#

the Doc

#

self.token = 'mytoken' # set this to your DBL token

#

yep

#

in my token

#

just dont wanna leak that

#

yes

#

the doc uses bot

#

these are im imports ```
import dbl
import discord
from discord.ext import commands

#

no :/

#

my bot was online all night last night and all of today

#

no post yet :/

#

no :/

#

thats the thing

#

ive even reloaded the cog

sullen nymph
#

Add the cog listener decorator

nocturne magnet
#

can you help?

sullen nymph
#

I'm really starting to question whether maintaining dblpy was a good idea

#

Really though

#

Use the commands.Cog.listener decorator, apply it to your on_guild_post function

nocturne magnet
#
class Topgg(commands.Cog):
    """Handles interactions with the top.gg API"""

    def __init__(self, client):
        self.client = client
        self.token = 'mytoken' # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.client, self.token, autopost=True) # Autopost will post your guild count every 30 minutes

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

def setup(client):
    client.add_cog(Topgg(client))
#

like this?

#

so

#

yes no?

acoustic dove
#

Bruh

#

How did you make the rest of the bot

nocturne magnet
#

wdym

#

?

acoustic dove
#

You don't know what a decorator is

#

Look it up and you'll understand what to put there

nocturne magnet
#

i did look it up

#

but

#

im am still confused :/

#

can you help

#

please

#

@sullen nymph @acoustic dove

sullen nymph
#

What is a decorator

nocturne magnet
#

aghhhhhhhhhhhhhh

nocturne magnet
#

im just confused

acoustic dove
#

Then maybe find out what a decorator is

nocturne magnet
#

can you just tell me?

#

like i get this every time i ask for help here

acoustic dove
#

Get what?

nocturne magnet
#

go look this uo

#

up

#

:/

acoustic dove
#

Yeah because you're missing basic knowledge

nocturne magnet
#

ok

#

but

#

i want to learn

acoustic dove
#

If you look at the links I sent, you will definitely have your answer

nocturne magnet
#

this is frustrating

acoustic dove
#

It's really not

#

The answer is literally in the second link

nocturne magnet
acoustic dove
#

sigh

nocturne magnet
#

?

#

im confused

acoustic dove
#

Just try it

nocturne magnet
#

i did

acoustic dove
#

And..?

nocturne magnet
#

nothing happens :/

#

doesntprint anything

acoustic dove
#

what do you have

nocturne magnet
#

wdym

#

like the code?