#topgg-api

1 messages · Page 147 of 1

night ingot
#

never used that lib, but I would assume so

nocturne quarry
#

okay

#

Same error

silent pivot
#
const webhook = new Topgg.Webhook(...); 
const api = new Topgg.Api(...);

how can i get those keys

nocturne quarry
trail sigil
#

ty

silent pivot
#

Now answering

const express = require('express');
const Topgg = require('@top-gg/sdk');

const app = express();

const webhook = new Topgg.Webhook('...'); 

app.post('/dblwebhook', webhook.middleware(), (req, res) => {
console.log(`${req.vote.user} has voted`)
}) 
app.listen(3000)
#

still same

#

can i use this

sullen nymph
#

How do you expect to use localhost with your webserver on top.gg

silent pivot
#

uhmm

sullen nymph
#

Probably

#

We'll never know.

silent pivot
#

?

sullen nymph
#

Yes

silent pivot
#

okay

silent pivot
#

index.js


const express = require('express');
const Topgg = require('@top-gg/sdk');

const app = express();

const webhook = new Topgg.Webhook(''); 

app.post('/dblwebhook', webhook.middleware(), (req, res) => {
console.log(`${req.vote.user} has voted`)
}) 
app.listen(3000)
#

i have opened this link

wintry glade
#

I have this, but It does not send anything to my server when I test it

silent pivot
wide wigeon
#

yeah i dont quite understand webhooks either

silent pivot
#

sad

wide wigeon
#

never used a webhook before'

#

I get that part

#

javascript

#

node.js

#

what exactly do i put in the webhook url?

#

alright i have that

#

so if i use the code provided it should work right?

#

alright thanks

#

no idea :)

#

oh, yeah

#

i run my bot through the console atm

willow oracle
#

guys when someone votes on my bot , it starts spamming

#

i click on Test button only one time

tired seal
#

based on this example, can I put the number of servers on which the bot is, so that it appears on the website? if so, how do i get my api token?

#

ty... does the token change or will it always be the same?

#

ty

wide wigeon
#

alright so i found a port that's open

restive otter
#

Hmm...So, I am a dev and i still don't know what are shards.Can anyone explain me.

#

ohk

wide wigeon
#

i went to the settings to open the ports, and i saw a couple that're already open

#

so im liike "cool imma use these"

restive otter
#

hi how do u setup server webhooks n what they actually do?

wide wigeon
#

i did not test each and every number do not worry

#

anyways, i have my webhook link set up like this
https://myip:openport/dblwebhook

#

and i hit the test button

#

and nothing showed up

#

ahh ok

#

1030

#

it's one of the open ones, do i have to use 80?

#

ah yeah, done that

#

alright

#

and the app.post thing looks like this, yeah?
app.post("/dblwebhook", webhook.middleware(), (req, res) =>

#

i dont know what result im supposed to get, but the console.log for the bot didnt say anything

vital nebula
wide wigeon
#

a?

#
const Topgg = require('@top-gg/sdk');
const express = require('express');
const app = express();
const webhook = new Topgg.Webhook(topggauth);
app.post("/dblwebhook", webhook.middleware(), (req, res) =>
{
    console.log(req.vote.user);
});
app.listen(1030);
#

just copied this straight from the thing

dire bloom
#

Are webhooks working?
Im receiving no data. Haven't changed the code has been working for weeks and now it's not

wide wigeon
#

a

#

hit the test, nothing happened

jade birch
#

I want to show server count and when someone vote the bot send message in my server in the channel

#

I dont understand this

#

Because iam bad in english

#

Can someone tell me step by step

stable magnet
#

if I use insomnia to test I get 401 "error": "Unauthorized" but if I just go to the url in the browser it works any idea?

wide wigeon
#

yeah the auth is the stuff i put below the webhook url right?

#

i did that

#

it says 'topggauth' cuz i put the thing in the config file

jade birch
#

Can u @shut flume tell me step by step

stable magnet
#

the token on the webhooks page, or my client id?

jade birch
#

iam bad in english

#

Its not my main Language

#

can u just tell me

wide wigeon
#

116

#

i dont know what im doing wrong 🙃

stable magnet
#

can you explain what that would look like

silent pivot
#
const Topgg = require('@top-gg/sdk');
const express = require('express');

const app = express();

const webhook = new Topgg.Webhook('topgg123'); 

app.post('/dblwebhook', webhook.middleware(), (req, res) => {
console.log(req.vote.user)
}) 
app.listen(3000, () => {
console.log(`App listening at http://`)
})

Not working

wide wigeon
#

the code im using is straight lifted from the doc tho

#

i swapped it out to this just in case
const webhook = new Topgg.Webhook('waaaaaaaaaaa4i292039q4rujq390');

#

yes

#

i did

stable magnet
silent pivot
#

yea

wide wigeon
#

:)

hallow zephyr
#

PASS PORN

sullen nymph
#

ok

wide wigeon
#

btw im running the bot on node.js

#

if that changes anything

#

well it's getting late so i'll try again tomorrow

#

btw using some webhook tester i do get the test thing to show up

#

so it's not not sending the thing, its just my thing not grabbing it

#

well whatevs gonna sleep

#

good night :)

silent pivot
#

my server is on but there is no server with my public ip

jade birch
#

Ok write steps in one message like
1-
2-
3-

#

just write it here

silent pivot
#

its now working

jade birch
#

Write here @shut flume

#

Pls

#

:(

#

Ok send the link of the thing i want

#

Not the main site

#

Discord. Js

silent pivot
#
const Topgg = require('@top-gg/sdk');
const express = require('express');

const app = express();

const webhook = new Topgg.Webhook('topgg123'); 

app.post('/dblwebhook', webhook.middleware(), (req, res) => {
console.log(req.vote.user)
}) 
app.listen(3000, () => {
console.log(`App listening at http://......:3000`)
})
jade birch
#

Can u tell me what is webhook auth @shut flume and where can i get it

willow spindle
#

it is password for confirm that requests are coming from top.gg

jade birch
#

Ok

#

@shut flume

#

Hey

#

I made this webhook

#

now i copy the webhook and paste it in webhook url ?

wet drift
#

you cant use discord webhooks

#

you need to make your own

jade birch
#

Can u tell me what i paste

#

how

#

To make it

#

?

wet drift
#

googl

jade birch
#

uh

#

What i write

jaunty plank
#

you would have to code it, and or use one of the libraries.

jade birch
# jaunty plank you would have to code it, and or use one of the libraries.

This ?

const Topgg = require("@top-gg/sdk");
const express = require("express");

const app = express();

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

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

app.listen(80);

jaunty plank
#

yep, thats the js sdk.

jade birch
#

ok

jaunty plank
#

the url will be the url to that webhook.

jade birch
#

?

jaunty plank
#

anything, its like a password, you chose it.

jade birch
#

Ok

#

the password must be secret ?

jaunty plank
#

yes

jade birch
#

ok

#

The password is || ilikeminecraft||

#

Jk

wet drift
#

for python, is this the correct one? webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000

jaunty plank
#

lol

#

uh thats part of it

wet drift
#

so if i put that, that will work?\

jaunty plank
#

you need more than that

wet drift
#

without django or flask

#

yeah ik

jaunty plank
jade birch
#

Uh
There is something. @Woo#3304

#

@jaunty plank

#

When i put the code and the webhook auth

Then where the bot will send the message

jaunty plank
#

nowhere, you have to develop that yourself.

jade birch
#

._.

#

Ok

jaunty plank
#

top.gg just handles sending it to your code, you do the rest.

jade birch
#

When i open my idiot pc

raven slate
#

Hey

#

How can I find out the number of votes for a bot, for example !vote

#

let voted = await topgg.hasVoted(message.author.id); let votes = await top.gg.hasVoted(message.voted.size);

#

@jaunty plank

jaunty plank
#

that just tells you if one person voted, not how many votes the bot has

rain heart
raven slate
#

So how do I know the number of votes from the bot @jaunty plank

jaunty plank
#

hope linked the explination

rain flame
#

I've read the top.gg documentation but still don't quite understand how to make top.gg show your bots server count. If someone could give a more detailed explanation that would be amazing!

rain heart
#

-servercount

abstract mothBOT
rain heart
#

go to the section of your preferred language

timid haven
night ingot
#

Are you passing in an authorization header with your dbl token?

timid haven
#

Yes man

night ingot
#

And you're sure it's the right token?

timid haven
#

Yes man i have check it

#

Need to renew?

night ingot
#

No, you don't need to

#

Could you show your code, of course edit out the token

timid haven
night ingot
#

Have you recently regenerated your token?

timid haven
#

now

#

have i think 3-4 mouths

subtle trail
#

guys is that about the server counter and how can i get api key

#

okay found it

silk canopy
#

How to get message when someone votes the bot like getting the voter's tag and id?

#

no one there to help me?

rain heart
#

just wait

silk canopy
#

Ok

silk canopy
#

Pls help me

white yacht
#

hello

restive otter
#

I can help you but not spoon feed code

#

Is this what you mean

hushed lodge
#

can you help me here?

#

even a little

restive otter
#

I can help bro

#

What you stuck on

hushed lodge
#

please add me

silk canopy
#

@restive otter yes what to use in that webhook or Api would work?

restive otter
#

But for that it's a web hook for like fetching who voted ect

silk canopy
#

Yeah I also thought the webhook would work but just wanted confirmation

#

@restive otter bro can you help me make webhook?

#

Like from the channel i have to make or like this

hushed lodge
# restive otter Check docs

``const Topgg = require("@top-gg/sdk");
const express = require("express");

const app = express();

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

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

app.listen(80);``

#

Apparently this is the code

#

So should i just add a message command in it

#

i am pretty new to this whole coding

restive otter
hushed lodge
#

i am sorry if i am being annoying

marsh cedar
#

how to show number of bot servers?

silk canopy
#

How to get webhook auth

restive otter
#

you create that

silk canopy
#

means i have one channel id and one long thing so which is the webhook auth @shut flume

#

what is webhook auth

#

means that long thing

next ginkgo
#

I m getting this error:<Response [401]> while i am trying to get indivisual user vote of my bot .. can anybody help me how to do this??

silk canopy
#
const Topgg = require("@top-gg/sdk");
const AutoPoster = require('topgg-autoposter');
const express = require("express");

const bot = new Discord.Client();
const topgg = new Topgg.Api("topgg token")
const webhook = new Topgg.Webhook("channel webhook auth code");
const app = express();

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

ap.on('posted', () => { // ran when succesfully posted
    console.log('Posted stats to top.gg')
})

app.listen(80);```

This is not working for me when i am test voting
trim pelican
#

I'm confused on how to make a webhook

night ingot
#

What part confuses you?

trim pelican
#

Just how to get an app on there

#

I get where you have to go

#

But how to start the app up to work

next ginkgo
#

can anyone help me with how to check if a user has voted for my bot or not

trim pelican
#

Have you got a webhook set up?

#

I think you need that

next ginkgo
#

how to set up that??

trim pelican
#

Idk

#

That's y I'm here rn

night ingot
#

Well do you want to set up your own webhook listener, or are you trying to use the one built into the lib?

trim pelican
#

There's built in?

#

Where do I find it

night ingot
silk canopy
#
const Topgg = require("@top-gg/sdk");
const AutoPoster = require('topgg-autoposter');
const express = require("express");

const bot = new Discord.Client();
const topgg = new Topgg.Api("topgg token")
const webhook = new Topgg.Webhook("channel webhook auth code");
const app = express();

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

ap.on('posted', () => { // ran when succesfully posted
    console.log('Posted stats to top.gg')
})

app.listen(80);```

This is not working for me when i am test voting
trim pelican
#

Cheers

silk canopy
#

pls help

upbeat imp
next ginkgo
#

i need to print the vote data when a user votes for my bot.. how to do that??

trim pelican
#

Ok I set up the webhook

#

But it comes back with a 404

#

Is this normal for the first time

#

?

silk canopy
#

@upbeat imp ik

#

what to write in webhook url on top.gg page

trim pelican
#

I thinks it's ur ip

#

And then /

#

And whatever u set webhook port to

#

It worked for me

silk canopy
#

hw to get ip

#

and port

trim pelican
#

Are you on replit

#

Or on ur own pc

silk canopy
#

No heroku

#

Lol in pc but hosted on heroku

trim pelican
#

K

silk canopy
#

but currently on my vsc

trim pelican
#

Can u make an express?

silk canopy
#

i have express

#

i did it

#

but i wrote app.listen(80);

#

what does 80 mean?

trim pelican
#

I believe that is the port

#

At the end type /80

#

U might have to change it

silk canopy
#

to?

trim pelican
#

Cos it says about being between 1061 and 42000 or something like thag

#

That

#

Change to 8080

silk canopy
#

ok

trim pelican
#

Just for now

silk canopy
#

and in webhook url?

trim pelican
#

The link for the express

#

Then /8080

silk canopy
#

Lol i dont know

#

i am on vsc

trim pelican
#

What is the link for ur express?

silk canopy
#

idk @trim pelican

#

bruh

#

sry

trim pelican
#

U on windows?

silk canopy
#

@trim pelican yes

trim pelican
#

Ok

#

I believe u have to open cmd

#

And type this

silk canopy
#

Ok

#

then

trim pelican
#

ipconfig

#

There should be a number like idk 0.0.0.0

silk canopy
#

should i have to locate the folder also

trim pelican
#

Idk

#

I'm on python so I'm probably doing this worng

#

And I'm using replit lol

silk canopy
#

i got ipv4

trim pelican
#

Yes

#

U need to copy that

silk canopy
#

Ok

#

Then

trim pelican
#

I think u put the IP on the test

#

And type the port

#

In this case /8080

silk canopy
#

Where test 😅

trim pelican
#

So it should be something like this

#

0.0.0.0/8080

silk canopy
#

oK

trim pelican
#

When I did mine it came back with a 404

silk canopy
#

LOl

trim pelican
#

But it still got to the console

#

So put in a random password

silk canopy
#

I am getting error

trim pelican
#

What?

#

Send scrn

silk canopy
#

, expected

#

instead of .

trim pelican
#

Send me where it says the issue

#

Also u did ap.run

silk canopy
#

In the ip

trim pelican
#

On the code up above

silk canopy
#

No

trim pelican
#

I'm using a link

#

Not an ip

#

It might be different

silk canopy
#

Hmm

#

Lol i just need the webhook url

#

then i would be dn

silk canopy
trim pelican
#

What is ur bot

#

Vocal?

silk canopy
#

Yes

trim pelican
#

K

#

I saw it lol

left mesa
#

Hey, I am using dan for hosting so what should I add in webhook url?
http://localhost:port/webhook is this right?

restive otter
silk canopy
#

@left mesa webhook /dblwebhook hoga

restive otter
#

@silk canopy indian?

silk canopy
#

@restive otter yeah @restive otter @left mesa also indian

restive otter
#

nice Me Too

silk canopy
restive otter
#

@trim pelican Bro How Did U Setuped Voting Webhook On repl.it

vapid cape
#

you cant use localhost

abstract nacelle
#

Is there a rate-limit when sending requests to top.gg?

silk canopy
vapid cape
#

hes not using repl

silk canopy
#

@left mesa just for now cuz i am not able to do in vsc

restive otter
trim pelican
#

@restive otter have u made a flask?

restive otter
trim pelican
#

Ok

restive otter
#

Like To Run bot 24/7

trim pelican
#

Same

vapid cape
#

webhooks are always specific for your hosting, so you have to check your hosting for the right webhook url

#

for dan hosting you have to ask them for ip and port

restive otter
night ingot
restive otter
restive otter
brazen patio
#

d

left mesa
restive otter
#

yes

left mesa
#

kk

vapid cape
#

you cannot use localhost

left mesa
#

kk

frank shard
#

d

#

d

#

d

#

d

#

d

abstract nacelle
#

Does this check whether user voted in the last 12 hours or voted at least one time?

spark raven
#

all time i think

#

but how would I do it

#

like where would I put the person's user id?

#

because when I try I get {"error":"Unauthorized"}

night ingot
#

You need to pass in your DBL token as an Authorization header

spark raven
#

I am so sorry that I am so stoopid but: what?

restive otter
#

So it would be /dbl after your local host

abstract nacelle
#

Your request should look similar to this:

"url": "url you are sending request to",
"method": 'method GET, POST, DELETE etc.',
"data": {
    "userId": "user id"
},
"headers": {
    "Authorization": "your top.gg token"
}
spark raven
#

even if I am python?

left mesa
abstract nacelle
#

I used NPM package phin to send this specific request

restive otter
abstract nacelle
#

I just showed you example of a Authorization header, you can try doing similar in python

fallen thistle
#

Hi, I gave up on the webhook a few months ago and am trying again now. How do I get the webhook url to send the data to?

winter tusk
#

So The ratelimit for using the api is 60 requests per second.
I'm setting an interval of 5 mins and using the api.
Thats not api abuse and I wont get banned right?

So code is

setInterval(() => {
console.log(await api.getVotes())
},
60 * 5 * 1000) //5 minutes``` Not my exact code but the `getVotes()` is the only api usage.
fallen thistle
#

I mean it seems fine

smoky marten
#

can anyone give me the link to reset my token

fallen thistle
winter tusk
fallen thistle
#

Yes

winter tusk
#

In my situation, the lower the time

#

the better the bot

#

So what's the max I can lower?

fallen thistle
#

Idk that

winter tusk
#

ty

#

In api.postStats() can any1 list whatever I can post?

#

@fallen thistle

fallen thistle
winter tusk
restive otter
#

That's not helping him

fallen thistle
#

Ik, but I don't know the answer

winter tusk
winter tusk
fallen thistle
winter tusk
#

Lmao

restive otter
fallen thistle
#

Well then, no

restive otter
#

Oh

winter tusk
#

when did I ask s or no?

restive otter
#

I thought he said can I add things there

#

Lol

#

I misread

fallen thistle
#

Silly you

winter tusk
#

Silly

#

So silly

restive otter
#

K

fallen thistle
#

That's why I referred to the docs

winter tusk
#

what is shard btw?

restive otter
winter tusk
#

...

restive otter
#

That's a question for google this is a place to get help with Top.gg API

fallen thistle
#

Now who isn't helpful

restive otter
#

No it's following the channel rules

#

Read

#

No off topic conversations stay on topic

boreal whale
#

hey

fallen thistle
#

Good morning

winter tusk
wide nexus
#

lol

night ingot
#

Is this related to the API at all? If not, move to #development

upbeat imp
#

oh

#

mb

night ingot
#

Could you show your code?

restive otter
#

^

#

Oh I know @night ingot

#

Look there is says it's already in use

#

@restive otter your already running a website in that same server or whatever your using

night ingot
#

Mhm, but the error says they're using port 5000

restive otter
#

Yes but he is probably running his dashboard on the same thing

#

On the same domain

night ingot
#

If you're using multiple shards, make sure the webhook listener doesn't start twice

restive otter
#

^

#

So are you running a website in there

#

Such as your dashboard

#

Was I right Bc if not I'll help you find the right awnser @restive otter

vast phoenix
#

can api track votes?

restive otter
#

Just read over the docs and try to understand it more fully bc you will be better off when you write your code trust me

restive otter
# vast phoenix thx

Np man I don't want to be a jerk and just say read docs I just want to help you and I think in the long run this will help

#

There is the reference

#

If you need any other help just let me know!

vast phoenix
#

e

#

i saw

restive otter
#

Also, you could convert the widget for your bot votes

vast phoenix
#

Ok?

restive otter
#

And you can make it send as a .png

#

Wait

vast phoenix
#

O

restive otter
#

Also this is what it would look like converting the widget this is from my bot

#

Also

vast phoenix
#

wah

restive otter
#

You can add it to an embed

vast phoenix
#

ok

restive otter
#

That's just a command I made for me

vast phoenix
restive otter
#

You can check out widgets in edit section oh see widgets

restive otter
vast phoenix
#

same

restive otter
#

Wdym pure Py

#

It adds everything it needs

vast phoenix
#

Brb

restive otter
#

Alright

vast phoenix
#

One of my friends made his bot work without using DPY

#

idrk how he did it

#

I think he made his own api

restive otter
#

It's a library

#

And @vast phoenix try to stay on topic if you want to talk with me about this let's head over to #development

little citrus
#

Can someone help me setup the vote-webhook in my bot?

#

I can't seem to understand

sleek night
#

how do I make use of people voting for my bot?
Ex. x2 bot currency for voting
Also how do I find out what my API key if for top.gg and do stuff with that?
I'm using the discord.py Lib.

restive otter
#

same question, but with discord.js

little citrus
#

Same

#

Lol

dusk roost
#

is there anyway of getting time information on a user's vote via teh API, or would we need to use webhooks and maintain state

#

/bots/:bot_id/check
is this for the month? or past 12 hours

sudden flare
#

Yeah @dusk roost

#

12 hrs

little citrus
#

Can someone help me setup the vote-webhook in my bot?
I can't seem to understand

little citrus
#

?

restive otter
#

And what do you want the web hook to do exactly

#

anyone have examples of code to check if the user voted

#

discord.js

little citrus
restive otter
#

so what are you having trouble with exactly

#

like an error or somthing like that or

torpid whale
#

Hello

subtle trail
#

guys how can i make a command that you need to vote for using it

#

(only 1 command btw)

#

oh wait wrong channel

frigid urchin
#

whats the api for?

night ingot
#

The API can be used to check for votes and stuff like that

#

also used for posting your bot's stats to the page

frigid urchin
#

oh ok thx

restive otter
#

Oh you said bot stats

night ingot
#

Yes, like I said

restive otter
#

Ye

wintry glade
#

Can I make a command with the top.gg api where if you just use /vote, it will automaticly upvote on top.gg?

#

y?

#

no, there would be the 12 hour limit

rain heart
#

voting has to be manually done by the user, as init said, it could be abused and vote for users behalf without their knowledge.

wintry glade
#

oh yea, true

hearty lintel
#

Top.gg Node SDK has been updated
In v3.1.0

The Webhook.middleware() still works, however there's a new method to work with webhooks,
using the Webhook.listener() method
Here's an example

const express = require('express')
const { Webhook } = require('@top-gg/sdk')

const wh = new Webhook('Top.gg webhook password')
const app = express()

app.post('/webhook', wh.listener((vote) => {
  console.log(vote.user) // 172075838806818817
}))

app.listen(80)

As you can see Webhook#listener() takes a function that is ran whenever a valid vote is passed
You can also error in this function in order to have the webhook re-queue the payload by passing back a 500 (via the retrial flow https://docs.top.gg/resources/webhooks/#retrial).

Docs for the new listener() method: https://topggjs.rtfd.io/en/latest/Webhook.html#webhook-listener-fn

restive otter
#

How To Send Embed Msg in A Specific Channel on Discord When Someone Voted My Bot Using webhooks.
Here Is an example what i actually want-

#

Language - Python

trail anchor
#

Hi!

#

I'm building a Discord bot in Java and I am wanting to use your API to check for votes

#

Your docs state that Official Top.gg libraries acknowledge webhooks automatically.

rain heart
#

the Java library does not have webhook support

#

use a 3rd party one, like topggwebhooks4j

trail anchor
#

I am coming back to say two things
A: I couldn't find it, is it possible you gave me the wrong name?
B: I somehow stumbled upon your GitHub profile in my search and I have to say that I absolutely love it

rain heart
trail anchor
#

Weird, literally nothing came up when I searched it in Google

rain heart
#

yeah Google doesn't index it seems like

trail anchor
#

Do you use the Wii cursor hand for your mouse cursor?

rain heart
#

yes. Just for the memes

trail anchor
#

That is amazing, just made my day :D

#

sorry :(

sudden flare
rain heart
#

you need to use webhooks

sudden flare
#

Thank you

dark scarab
#

Is there a way to use the api for servers?

left mesa
#

how can I get logs from 2 bots in 1 bot
Like I have 2 bots on top.gg but I want logs from another bot

rain heart
#

Just make a second webhook instance

pure spire
#

my webhook here will be /webhook is that correct?

restive otter
#

Hey Why I Am Getting Rate Limited Again And Again I Got yesterday At About 5:12 P.M And Just Now ._.

pure spire
#
dblpy = dbl.DBLClient(client,
                      gg_token,
                      webhook_path='/dblwebhook',
                      webhook_auth='password',
                      webhook_port=5000,
                      autopost=True)


@client.listen
async def on_dbl_test(data):
    print(data)


@client.listen
async def on_dbl_vote(data):
    print(data)
#

this is my code, nothing happens tho?

restive otter
#

it's not listen i guess

#

it's event

pure spire
#

@restive otter

#

what would my webhook url be?

#

on the main page?

left mesa
# rain heart Just make a second webhook instance
const app = express();

const webhook = new Topgg.Webhook('topggauth123');


app.post("/dblwebhook", opwebhook.middleware(), async (req, res) => {
    const user = await client.users.fetch(req.vote.user);
    console.log("Someone voted!")
});




const opwebhook = new Topgg.Webhook('topggauth1234');

app.post("/dblwebhook", opwebhook.middleware(), async (req, res) => {
  const user = await client.users.fetch(req.vote.user);
  console.log("Someone voted!")
});

app.listen(port);
``` like this?
pure spire
#

or

#

or just ip

restive otter
pure spire
#

or

rain heart
#

No clue bout js

pure spire
#

\webhooks

#

@restive otter i thought u figured it out sorry

restive otter
rain heart
#

No

restive otter
#

Not Js Not Python Then?

trim pelican
#

Hey I set up the webhook, but I don't know how to make the bot do something and how to do like a on vote dm/rewards

trim pelican
#

oop dw it crashed

spark raven
#

Can someone help me? I am a low-intermediate coder, and I want to make a voter-only command. I have looked at the docs, and have no clue what to do. Can someone help me? (Python)

spark raven
#

webhook

#

i think

sullen nymph
#

I suggest using Google on how to create a webserver in your programming language

viscid cloud
#

what i need put in it?

next ginkgo
#

can anyone help me in settings webhooks for my bot?/

maiden panther
night ingot
#

What are you trying to do?

maiden panther
#

I'm trying for my webhook aki but I can't

night ingot
#

Well, for the url you should use the IP, port and path of the server you're hosting the webhook listener on

#

And the for authorization you can enter whatever you want, but it's not necessary to have anything there

maiden panther
#

how do I do that?

night ingot
#

Do what?

maiden panther
night ingot
#

Yes, you already showed that

#

I don't understand what you need help with

maiden panther
#

I need help to put the webhook

night ingot
#

What do you mean by "put the webhook"?

sleek night
#

I'm also a bit lost in how to setup a webhook. How do I set up the code for it and track vote data so I can reward users each time they vote? I use Flask on Replit.com to host a web app, so I know the port number, but no clue what IP or path I need to use. Never setup a webhook before.

finite sequoia
#

how i'm catch dbltoken???????

night ingot
#

You can find your DBL token in your bot's edit page under the Webhooks tab

finite sequoia
#

thaaaaaaaaaaanks 🙂

viscid cloud
night ingot
#

I already told you
http://<your IP>:<port>/<webhook path>

night ingot
#

No, the ipv4

#

your public IP

viscid cloud
night ingot
#

That's your local IP

#

You need the public IP of your network

viscid cloud
night ingot
viscid cloud
night ingot
#

You set that up yourself with whatever way you used to create your webhook listener

viscid cloud
#

Ok ThanX

next ginkgo
#

Can someone help me in setting up webhook for my bot. So that i can reward users for voting. I have hosted my bot on heroku so how do i set up my webhooks

finite sequoia
nocturne sonnet
#

Is there a meme api for python?

rare sigil
next ginkgo
#

what should i put here.....

night ingot
#

http://<your ip>:<port>/<webhook path>

next ginkgo
#

then i should put /asdfgh in webhook_path in my code

#

is that what u want me to do??

night ingot
#

Yes

next ginkgo
#

ok ty

#

imma try that

night ingot
#

Make sure port 5000 is open on your network too

next ginkgo
#

ok

restive otter
#

i put the webhook url and made the code but when i clicked test it didnt do anything

#
const Topgg = require("@top-gg/sdk")
const app = express();

const webhook = new Topgg.Webhook('anything123');

app.post("/dblwebhook", webhook.middleware(), async (req, res) => {
    const user = await client.users.fetch(req.vote.user);
    client.channels.cache.get("829103715352838196").send(`${user} voted!`)
});


app.listen(port);```
sleek night
night ingot
sleek night
#

oh

dawn solar
#

I've written some code and added my url and webhook to top.gg but nothing happens when someone votes. Have I done something wrong?

sleek night
#

How do I know if my webhook is working? I tested it on top.gg where it gives the nofification saying it was tested but don't actually get any output in the console. :?

dawn solar
#

Same I didnt either. I then got someone to actually vote and it still didnt work

dull gale
#

api? oh ok, my api code is...

night ingot
dawn solar
#

Ah ok. Is there a better port to use or just any?

night ingot
#

Just use something that isn't used by anything else

#

like 5000 is usually a safe bet

dawn solar
#

Ok

#

I'll try that

night ingot
#

Make sure that port is open as well

dawn solar
#

How would I check that

night ingot
#

Then you need to forward that port

dawn solar
sullen nymph
#

TCP

dawn solar
#

ok

night ingot
#

Also you might wanna delete this if you don't want people to see your public IP

sleek night
#

How can I forward the port 8080 if I don't have access to the router?

dawn solar
#

Yes thanks

dawn solar
night ingot
#

Sometimes it tells you that it's closed despite being open, you can try anyways and see if it works

dawn solar
#

It didnt sadly

#

Nothing happened still

night ingot
#

And you set it to port 5000 in your code too?

dawn solar
#

Yes

night ingot
#

and clicked save after you changed it in your edit page?

dawn solar
#

I'm pretty sure I did but I will do it again

#

No still nothing

dawn solar
night ingot
#

I'm not sure, I don't use js

sleek night
#

I'm also not getting any output from my webhook on port 8080 in python

night ingot
#

It's probably an issue with the port not being open then

sleek night
halcyon pilot
#

How is this

sleek night
#

irrelevant to api discussion^ @sacred shell

dawn solar
languid plaza
#

Do u need any help?

dawn solar
#

Ok. Have you got a top.gg vote webhook?

languid plaza
#

I have made it once for someone

dawn solar
#

I wrote the code for it

dawn solar
#

But nothing happens when someone votes

languid plaza
#

Vote webhook uses POST?

dawn solar
#

yes

languid plaza
#

I had made it with get ig

dawn solar
#

I'm just going off the top.gg docs

languid plaza
#

I was using dblapi.js which is umm
A bit different from the one u are using so ig i cant help.in.this

dawn solar
#

Ok

night ingot
#

I thought dblapi was deprecated?

little citrus
#

Hey! Could someone help me setup the vote-webhook thing? I can't seem to understand how to set it up in my code

night ingot
#

Which part confuses you? Also what language are you using?

toxic tiger
#

how can i create webhook and Authorization for my bot

nocturne sonnet
#

Is it possible to create an upvote web hook that sends a message to a text channel when some upvotes my bot?

night ingot
#

That is possible, yes

spark raven
#

how do I check if a certain user has voted (python) Ping me if you respond

solid crest
#

what is the data you get out of on_dbl_vote

night ingot
#

that will return
{"voted": 1 or 0}

#

The site is having some issues now though, so it's possible that it won't work

solid crest
night ingot
#

How did you set up the webhook listener?

solid crest
#

oh right you need the webhook listener inside ur bot. Can you send a documentation of how to, or more info about it please?

solid crest
#

yeah

#

i kinda have the same as

night ingot
#

You're missing the webhook_path, webhook_auth, webhook_port parameters in the DBLClient

#

well webhook_auth isn't required, but recommended

solid crest
night ingot
#

Correct

solid crest
#

sorry for the lots of questions
But how do you get the webhook url, do u need to do something special for it? or?

night ingot
#

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

#

or if you're hosting your bot on a server, the ip of said server

night ingot
#

so {"Authorization" : "your dbl token"}

spark raven
#

I am so sorry, but I am still really confused

night ingot
#

What lib are you using to make the request?

spark raven
#

I am just going on the url itself...

night ingot
#

How are you making the request, code wise?

spark raven
night ingot
#

Yeah, that won't work unless you're logged in on Top.gg

spark raven
#

i am... i think

night ingot
#

Probably related to the current site issues then

#

Either way, it works, you just can't access it

spark raven
#

oh it works

#

i just needed to log in again

solid crest
spark raven
#

but how do I have my bot do it? like where do I put {"Authorization" : "your dbl token"}

night ingot
night ingot
#

I'd advise you to try to learn it by yourself though

solid crest
night ingot
#

And you hit "save" after putting in the info?

solid crest
#

yeah

#

its prob something with my network tho
My router had trouble before with opening ports too

night ingot
#

You're sure the IP is correct? It's your public IP, not the local one. So not the 192.168...

solid crest
night ingot
#

🤔

#

Haven't seen that error before

solid crest
#

uhh

#

maybe using an open port will help?

night ingot
#

You could try, it won't work if that port is being used by anything else though

solid crest
#

i tried using an open port which i think isnt being used (i think it was my old mc port, but thats offline lol)
i tried a test webhook
there came a firewall pop up, allowed it
tested again, but still nothing

night ingot
#

Try using something like postman to send a webhook and see if it's on our part, or yours

solid crest
night ingot
#

Try just entering your webhook path in the browser and see what response you get

solid crest
#

you mean just putting this in browser
ip:port/dblwebhook?

night ingot
#

mhm

solid crest
#

This site can’t be reached

spark raven
#
There was a problem saving the webhook :Thonk:```
#

what happened?

#

????

solid crest
#

added this code

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

still nothing tho

rain heart
#

do you have the required parameter in your dbl constructor?

#

such as port on context, which are required for the webhook server

solid crest
#

you mean the self.dblpy?

#
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/dblwebhook', webhook_port=9000)
#

this is my dblpy ^^

night ingot
rain heart
#

have you added your webhook url to your bot page settings aswell?

solid crest
solid crest
#

its just a problem with my internet / router

#

Tried adding a new port, get this error again

Internet IP address and LAN IP must be in the same network segment

#

i use my public ipv4 ip and want to enable the port on that (port 5000)
but i get that error

fallen thistle
#

What is the webhook url I have to insert on the website gonna be?

scarlet cobalt
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

solid crest
nocturne quarry
#

Hello, what is the listen emitter of @top-gg/sdk?

winter tusk
#

Aurel

#

Rate limits for bots is 60 per minute

#

I'm setting an Interval of 1 api requests per 3 minutes

#

that's not an api aboos right

night ingot
#

I mean, if the limit is 60 per minute, or once a second if you will

#

1 request every 3 minutes is pretty far off

dapper grail
night ingot
#

I don't think he has 300 bots

winter tusk
#

Lmao

dapper grail
#

Wait isnt that the global number

#

I am stupid

#

Xd

night ingot
#

a rate limit is per-client

winter tusk
#

Just one line in the interval code

#

let api = await api.getVotes() console.log(votes)

night ingot
#

Yeah, then you're safe

winter tusk
#

@night ingot could u say how can u modify the latency? Some1 in #memes-and-media posted that he worked hard and the latency is low?

night ingot
#

How do you mean? Like, the time it takes to make the request?

night ingot
#

That's all depending on your connection, how close you are to the servers etc.

#

I guess you could potentially optimize your code to run faster

#

but there's only so much optimization you can do

winter tusk
#

Tuto?

#

Code?

#

Github?

#

Stack?

night ingot
#

Optimization depends entirely on how your code looks

#

there's no general way to do it

winter tusk
#

These r the results

#

Is that good or bad or not bad or probably good or probably bad?

night ingot
#

I mean, lowest is 33ms which is pretty good

#

Connection speed can vary a lot, so I'd say that's decent

winter tusk
#

Latency is

#

send a msg, and observr date,now

#

Edit the msg

#

Observed date - Date.now() right?

night ingot
#

I believe this should be asked in #development as this channel is meant for Top.gg API questions

winter tusk
#

Answer this question there then

sand nebula
#

The API states You may not reward users for voting for another bot other than the one being used. This includes other bots you may own.

Can I reward people FROM a different bot but I wont give them any currency or commands in this different bot?

rain heart
#

TickNoVerifier Receive rewards on bot A for voting on bot B
TickYesVerifier Receive rewards on bot A for voting on bot A

sand nebula
#

like the api will be used on bot b but it wont give any bot b rewards

rain heart
#

Then why not use bot A directly

#

Don't understand

sand nebula
#

because that bot is there idk

#

instead of adding it to the public one

#

so is it ok or no

#

I will explain it more, The api will be used on bot B and people will get a msg and a role using this bot for voting for bot A which is the public one

rain heart
#

That is considered rewarding for voting for other bots

#

Which is not fine

sand nebula
#

Okay.

spark raven
#

what was it called, the authorization header? the password needed for my bot to use http://top.gg/api//bots/:id/check?userid=:userid

night ingot
#

Yes, you need to pass in a header that looks like this
{"Authorization" : "your-dbl-token"}

spark raven
#

ok thanks

#

so it needs to be r = requests.get('<MY_URI>', headers={'Authorization': 'TOK:<MY_TOKEN>'})

night ingot
#

Yeah, looks good

spark raven
#

ok!

spark raven
#

tysm, @night ingot it works now!

storm loom
#

help

#

what is this

rain heart
#

you have to provide on each request

storm loom
#

basically i want this

rain heart
#

go to the resources -> bots section

#

then find the section related to guild count posting

#

also read pins in this channel

storm loom
#

#resources

#

;(

#

ok

solid crest
#

have some trouble opening my port on my network, maybe someone can help me here?
"Intranet IP address and LAN IP must be in the same network segment"
Is the error, and i need an open port for the api so uhh maybe someone can help?

random creek
#

How do i make a bot listen to server votes ?

vast moat
#

I also want to know how webhooks work. Can I get a python docs

restive furnace
#

just like bots

vast moat
#

I guess I read that on docs

restive furnace
#

hmm

vast moat
#

still i don't know how webhooks works with bots

#

cause me still waiting for my bot approval

#

Okay I have read the docs of webhooks. But how do I know my webhook port and webhook auth?

sleek bolt
#

I made a webhook, copy pasted the link here, still don't know what the auth code does and uhh help?

night ingot
#

The auth code is optional, it's just so you can verify that the webhook comes from Top.gg and not someone else

#

It's not absolutely necessary, but highly recommended that you put something there

sleek bolt
#

ah ok

#

well

#

how do I uh.. make it work? even after I paste the webhook link in there and test it nothing happens

night ingot
#

Is the port you're using open on your network?

sleek bolt
#

uh

#

well all I know is that webhooks work but not on DSL

#

same thing

night ingot
#

How did you set up your webhook listener?

sleek bolt
#

so many words I do not understand (sorry I'm really new to webhooks)

#

do you have any tutorials on setting it up?

night ingot
#

What language do you use?

sleek bolt
#

English and Swedish (preferably english)

night ingot
#

Uh-

#

Programming language

sleek bolt
#

frick

#

well

#

json I guess?

night ingot
#

I highly doubt you made your bot with json

sleek bolt
#

oh ;_; well I don't have a bot

#

I just uh copy paste json bodies or whatever you call them into webhook maker thingies and then everything just works out. I thought I just had to post the webhook link in the server and it would send a premade message thanking whoever voted but if there's a bunch of programming shenanigans then uh guess I'ma go

night ingot
#

You will need to use programming shenanigans to thank a user for voting, yes

sleek bolt
#

dang

#

oh well

#

I'll get there eventually, thank you for you time <3<3<3

vast phoenix
#

how do I check user votes using discord.py and dblpy

normal oriole
#

Oh, I actually thought it would be hard.

#

but it proved easier than expected

random creek
night ingot
#

You can read through the docs, I've never used js myself

random creek
#

oh

normal oriole
#

It's

#

js

random creek
#

i just dont know

normal oriole
#

@night ingot Isn't it?

random creek
#

where to start

night ingot
#

Hm?

random creek
#

from

#

I am tryna make the bot listen to server votes

normal oriole
#

Oh, nvm my bad I only looked at the js part of the docs @night ingot

#

lol

random creek
#

mm

crystal hollow
#

Chocolar is off?

random creek
#

is this for server votes ?

night ingot
crystal hollow
normal oriole
random creek
random creek
normal oriole
#

lol

random creek
normal oriole
random creek
normal oriole
#

you make it

random creek
#

client id ?

normal oriole
random creek
#

<you bot> is client id ?

#

oh

normal oriole
random creek
#

edited the message

#

yikes

normal oriole
#

I don't know

#

maybe

#

try

#

lol

random creek
#

what am i supposed to do here ?

random creek
normal oriole
#

write authorization you want to use

random creek
#

mhm

#

and the url

normal oriole
#

the url

#

follow the tutorial or whatever

#

if there is one

random creek
#

which tutorial ?

normal oriole
#

Idk

#

Don't remember

vast moat
#

waitWhat WTF that dosen't answer even one part

normal oriole
#

Well... In the docs

#

it's explained

vast moat
vast moat
#

thats not my question

#

I want to know how do i know my open port

#

if I am hosting the bot

normal oriole
#

Idk.

vast moat
#

and also is auth the one that I make by my own?

normal oriole
#

Yeah, it's not really required

#

but it is recommended

dawn solar
#

I followed the docs exactly and it doesn't work

random creek
#

is they anyone here who can tell me what a webhook auth is ?

night ingot
#

The webhook auth is used to make sure the webhook is coming from Top.gg and not someone else

#

You set it up yourself in the Webhook edit page on your bot

spark raven
#

<Response [401]>

#

what does this mean?

#

????

sullen nymph
#

It means your auth token is incorrect

spark raven
#

sh it

#

does the bot need to be approved in order for it to work?

sullen nymph
#

Yes

spark raven
#

ok

#

so its not a problem on my end!

solid crest
#

ok so i think i have some trouble with opening my port
so in the router settings (check ss below) i set up my port forwarding with my public ipv4 first. This gave error message:
Intranet IP address and LAN IP must be in the same network segment
I contacted some other ppl and they said i needed to take my computers private ip address (so a 192.xxx.x.xxx)
I did and opened the port on the local ip, as you can see on the photo
In the top.gg webhook page i use my ipv4 ip
still nothing comes through and doesnt print the data, anyone that can help?

https://cdn.discordapp.com/attachments/782034872830918666/832352329725378610/unknown.png

sullen nymph
#

You pointed the port to your device, correct?

sullen nymph
spark raven
#

the bot is not yet approved