#topgg-api

1 messages Β· Page 126 of 1

modest oar
#

IP the ip of your hoster and Port aswell

wraith raptor
#

How do I get the port?

modest oar
#

default port is 8000

#

you can try it

wraith raptor
#

ok

modest oar
#

u got it?

wraith raptor
#

Yes

modest oar
#

alr

#

then in init

#

webhook_path='/dblwebhook', webhook_auth='Your password', webhook_port=Your Port

wraith raptor
#

Where's init again, Sorry

modest oar
wraith raptor
#

Ok

modest oar
#

you got it?

#

and in self.token there should be your key

wraith raptor
#

Ok

modest oar
#

you got it?

wraith raptor
#

Yes

modest oar
#

alr

#

then do a
on_dbl_test event

wraith raptor
#

Ok

modest oar
#

with get channel where it should send the test

wraith raptor
#

Ok

#
    @commands.Cog.listener()
    async def on_dbl_test(self):
        channel = await self.bot.get_channel(794922248943304706)
#

like that?

modest oar
#

self, data

wraith raptor
#

Ok

modest oar
#

and also await channel.send('test')

wraith raptor
#

Ok

modest oar
#

alr then

#

go back to ur webhooks settings of your bot in top.gg and test it

wraith raptor
#

Ok

modest oar
#

did it work?

wraith raptor
#

no

modest oar
#

is there a error?

wraith raptor
#

no

modest oar
#

Open the webhook url

#

in google

wraith raptor
#

ok

modest oar
#

yeah, then the port is unreachable

wraith raptor
#

What should I put as the port then?

modest oar
#

do u have a hoster?

wraith raptor
#

Yes

modest oar
#

Maybe your host has its own port

wraith raptor
#

I found it's port

modest oar
#

alright then enter it

wraith raptor
#

Same thing

modest oar
#

Is the IP you entered that from your bot?

wraith raptor
#

How do I get the ip from my bot?

modest oar
#

Should be on your panel

wraith raptor
modest oar
#

Does your bot hoster have a panel?

wraith raptor
#

Where would it be?

modest oar
#

Where you can start up your bot etc

wraith raptor
#

At the dashboard of my host

modest oar
#

yeah

#

thats it

#

there should it be somewhere

wraith raptor
#

the ip or port

modest oar
#

you need both

wraith raptor
#

I found the port on the internet

modest oar
#

the port and IP should be on your dashboard

wraith raptor
#

I've looked everywhere and it doesn't say

modest oar
#

well you need to get it

wraith raptor
#

I can't

modest oar
#

You can't do it then I think

dull thicket
#

Is their any ratelimits

wraith raptor
rain heart
#

Any endpoint: 200/second

#

Stats post: 60/minute

#

Ban when exceeded: 1 hour

dull thicket
#

wut

#

so if 60 ppl vote, will my bot get banned?

green comet
#

LMFAO

hot axle
#

He means the route where you post your bot's stats

#

So you can post your stats max. 60/minute

willow spindle
#

"60 times in a minute"

hot axle
#

Wait yea

#

My explanation sucks KEKW

dull thicket
#

soo @willow spindle If I have a event that dms the user when they vote theirs no ratelimit on that?

willow spindle
#

it is not related with top.gg's API

restive otter
modest oar
#

bruh soos

dull thicket
#

@modest oar vote for me bot and see what happenens

wraith raptor
modest oar
uncut granite
#

can anyone help me setting the API up for Discord.py?

twilit obsidian
#

can somebody help me with the api for javascript? im using newest discord.js-version and i am trying to do postStats() but it says me that shard is undefined

restive otter
#

maybe because you didnt define shards

#

do you even use sharding?

twilit obsidian
#

idk what this is xD

#

do i have to use these 2 arguments?

regal harbor
#

@dull thicket @modest oar you guys know that is a test button to test the webhook?

#

@dull thicket @modest oar you guys know that there is a test button to test the webhook?

modest oar
#

??

#

why would you ping us twice tho

twilit obsidian
#

okay thank you got it working πŸ™‚

languid cedar
empty jay
#

@languid cedar look in the docs like you were told in #support

languid cedar
#

ok

restive otter
#

How to make an API for my website.?

hot axle
#

a website runs on a server

#

the server can have an api

#

but how you do it depends on which language you're using and other stuff

restive otter
#

@hot axle JavaScript

willow spindle
tardy coyote
hearty lintel
#

so like server count, shard count etc

tardy coyote
#

oh nice

#

ty

dusty roost
#

discord.js v12:

const client = new Discord.Client({
    sync: true,
    ws: { intents: 1537 }
});
const AutoPoster = require(`topgg-autoposter`);
AutoPoster(my_topgg_token, client);

Error: Unsupported Client

does anyone know why?

willow spindle
#

is this discord.js or eris

dusty roost
#

discord.js

willow spindle
#

i don't think there is sync option in D.js client options

dusty roost
#

i'll see if i remove it

#

still errors

hybrid hull
#

Hello, I am trying to set up a server webhook (not bot) to reward user for voting. How can I obtain the dbltoken?

hot axle
#

go to the api page and go to "my bots"

hybrid hull
#

I don't have a bot

hot axle
#

well you need a bot to get a dbl token

hybrid hull
#

alright

#

I think I am approaching this the wrong way

#

does top.gg has doc for server webhook?

hot axle
#

yeah

#

read the section on webhooks

hybrid hull
#

that is still for bot not for server

#

am I getting it wrong?

hot axle
#

well, technically you can make a webhook without a bot

#

but it wouldn't be of any use, since you can't use it anywhere

hybrid hull
#

so I am trying to make a webhook that return the users who voted my server

#

the user are voting for the server which isn't a bot

hybrid hull
#

how do I setup this webhook?

#

yup

#

I don't have a bot

#

so I am confused about how to use the mybot page for my server

tacit moat
#

Does the widget api route still function properly? It hasn't updated my bot's server/upvote count in quite some time.

hearty lintel
#

New node @top-gg/sdk version 3.0.6

Fixed an issue where if a user was using a different body parser, e.g body-parser, that uses the raw-body package, the parser would fail.
Now returns req.body content if one is available before parsing.

restive otter
#

Hey

#

Guys how to get the API of our discord bot

jaunty plank
#

this channel is for top.gg api support, not discord api support.

vernal pecan
#

how to i setting a voting system like someone voted my bot then my boy sending a message in the dm "Thanks for vote me!"

rain heart
#

Through the webhook mechanics, but remember that your bot cannot dm users that do not share a server with the bot and has dms disabled

vernal pecan
#

oh...

#

Thanks Anyway

restive otter
rain heart
#

Auth is the Key that you can define inside of your code

restive otter
#

oh

rain heart
#

Also, seems like you're using a discord webhook, a discord webhook doesn't work

restive otter
pallid forge
#

It’s just a warning

#

It’s not saying you have it

restive otter
#

ok

pallid forge
#

Make sure to keep to the correct channels though please

restive otter
#

I did the stupidest thing

rain heart
unkempt grove
#

Top.GG API Error: 404 Not Found why?

rain heart
#

More input, what library, what endpoint are you trying?

unkempt grove
#
at Api._request (/home/container/node_modules/@top-gg/sdk/dist/structs/Api.js:74:19)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Api.postStats (/home/container/node_modules/@top-gg/sdk/dist/structs/Api.js:94:9)
(node:11) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2) ``` discord.js endpoint top.gg/sdk
rain heart
#

Code please

#

on where that error occurs

unkempt grove
#
setInterval(() => {
    api.postStats({
     serverCount: client.guilds.cache.size,
      shardCount: client.options.shardCount
    })
  }, 600000)```
rain heart
#

make sure you're using the newest package version

unkempt grove
#

ok

rain heart
rocky frost
#

How do I get the auth of the webhook? I searched and didn't find where that is

rain heart
#

Auth is the authorization you can use to identify the request is coming from top.gg

#

Just to clarify: A discord webhook cannot be used

rocky frost
#

I don't want to use discord's webhook, I want to put this in a bot

#

and you need this to keep me going

rain heart
#

Yeah, then the authorization you used in your code

rocky frost
#

But I don't know where I get this auth, I went to the site and I couldn't find it

#

Ah, is it for me to create the password?

rain heart
#

correct

#

you need to make the auth yourself, name it whatever you want

#

then enter it on the bot page settings under Authorization

rocky frost
#

Ah, thank you so much, I thought I was supposed to get the password somewhere

fallen thistle
#

Hi, could someone give me an example for a dpy top.gg webhook?

stark holly
fallen thistle
#

Cheers

rocky frost
rain heart
#

You cannot use webhooks yet if your bot isn't approved

fallen thistle
#

Okay I am not sure where to go from here. I want to do x when someone voted but I am not sure what I need to do for that, I know the event but Idk how to define dbl

rocky frost
fallen thistle
#

Please ping me when responding, thanks

rain heart
#

Read the docs

fallen thistle
#

I did

rain heart
#

What language?

fallen thistle
#

Python

#

Also, what URL should I enter?

rain heart
#

The url should be something like http://yourserverip:port/context
for example http://1.1.1.1:5000/dblwebhook

fallen thistle
#

the ip being from my pc or from the host I am using or...?

rain heart
#

the ip from where your bot is hosted on

#

a vps for example, would be the vps' ip

fallen thistle
#

Alright

rain heart
#

The one used by your vps

#

yes

#

or used by your host

#

Or where do you host your bot

fallen thistle
#

Don't see anything saying port thoug, do I just use 5000?

fallen thistle
#

?

#

Please again ping if you respong

#

*respond

modest oar
#

How can I cehck if someone voted for my bot?

#

thanks

rain heart
#

You need Authorizaion aswell

#

for the api

#

Yup

#

The Authorizaion header

#

Good job ClapClap

naive galleon
#

const AutoPoster = require('topgg-autoposter')

const ap = AutoPoster('topggtoken', client)

#

Just that !

#

?

rain heart
#

Yeah that should work i think

naive galleon
#

topggtoken=my bot api key?

rain heart
rain heart
#

The documentations should state about the port

#

read the initialisation

fallen thistle
#

Could you give me a link?

rain heart
fallen thistle
rain heart
fallen thistle
#

Again, I have never worked with webhooks

#

Could you give me more specific info instead of referring to the docs?

worn lion
#

I believe you have to pass the kwargs into that class

#

I don't use this API but it seems that does everything for you with the correct kwargs set

young haven
#

I added this to the ready and it didn't work I put my token

const DBL = require("dblapi.js");
const dbl = new DBL('token here', bot);

setInterval(() => {
  dbl.postStats(bot.guilds.cache.size);
}, 1800000);```
fallen thistle
#

Can I just put any URL in that field?

Webhook URL
We will attempt to perform a POST request to this URL when sending you webhook data.

young haven
fallen thistle
#

Is this code correct for now? ```py
import discord
from discord.ext import commands
import dbl

class dbl(commands.Cog):

def __init__(self, client):
    self.client = client
    self.token = 'ToKeN-I-wOnT-sHoW'
    self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='Some really creative password', webhook_port=5000)

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

def setup(client):
client.add_cog(dbl(client))```

sullen nymph
#

Is that your IP commented out

rain heart
#

this would be http://yourip:5000/dblwebhook

fallen thistle
#

Well luckily not mine but

fallen thistle
rain heart
#

Did you press save on the webhook setting

fallen thistle
#

I did

#

Webhook URL is what you just told me and Authorization is webhook_auth right?

sullen nymph
#

Make sure port 5000 is open

fallen thistle
#

Wdym

sullen nymph
#

Exactly what it says. It's possible that your machine has a firewall that blocks requests coming to port 5000

uncut lintel
#

hi could someone help me with the webhook ?

#

in the webhook url wha do i put

hot axle
#

the endpoint where your webhook is hosted

uncut lintel
#

ok im hosting my bot on a pi so would i put the pi ip or...

rain heart
#

you need to portforward then

uncut lintel
#

sorry im dumb wha does that mean

hot axle
#

open a port on your pi

#

the one you're using

rain heart
#

And on your router

uncut lintel
#

k

kindred swift
#

Where does it post guild count

#

I don't understand the code, someone explain? And any way I can make it DM me the server count when it updates or send it in a channel

fallen thistle
rain heart
#

it autoupdates automatically

kindred swift
#

Yes

#

But where does it send the guild count?

rain heart
#

Inside the code itself

#

Autoposter

kindred swift
#

oh

rain heart
#

you don't see it

kindred swift
#

ok

sullen nymph
#

Apply listener decorator to on_guild_post

uncut lintel
#

Hi I did the npm thing for top.gg and after installing I got a critical security warning from windows security thing. It said that the app downloads other apps

#

And to remove it

rain heart
#

can be ignored, that's just a warning

#

unless you installed the wrong one

#

make sure it is @top.gg/sdk

sullen nymph
#

Those docs aren't updated

#

see pinned messages in this channel

rain heart
uncut lintel
#

Ok thx

hearty lintel
fallen thistle
#

tf? ```diff

  • AttributeError: type object 'dbl' has no attribute 'DBLClient'```
#
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='If you see this you are cool', webhook_port=57621)```
#

Idk why I did wrong?

#

@rain heart (sorry for the ping)

fallen thistle
#

Please ping me when responding

hearty lintel
#

you did import dbl right?

fallen thistle
#

I did

#

Basically copy pasted the example

glass frigate
sullen nymph
fallen thistle
#

Only my class

sullen nymph
#

Well yeah

fallen thistle
#

I see

uncut lintel
#

So I have an economy system would it be possible to give users a bonus reward when they vote. If do is there anything that could help me code it....

#

So*

jaunty plank
uncut lintel
#

Thx

fallen thistle
#

Code now: ```py
import discord
from discord.ext import commands
import dbl

class vote(commands.Cog):

def __init__(self, client):
    self.client = client
    self.token = 'My-ToKeN' # set this to your DBL token
    self.dblpy = dbl.DBLClient(self.client, self.token, webhook_path='/dblwebhook', webhook_auth='Password', webhook_port=17500)

@commands.Cog.listener()
async def on_ready(self):
    print(dbl.__version__)

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

def setup(client):
client.add_cog(vote(client))```
This prints me the correct version but doesn't react to test webhook sends. The port is open, the IP correct

tulip hatch
#

who's ghost pinging me?

fallen thistle
#

Could someone help me?

fallen thistle
#

I really need help here killua_sweat_smile

torpid anvil
#

how do I set up the webhook?

restive otter
#

with whout

#

wat u need help with

#

@fallen thistle @torpid anvil

fallen thistle
torpid anvil
#

how do I set up de webhook?

restive otter
#

settings

#

server settings

#

its in there

fallen thistle
#

lol

#

You don't know what we're talking about

torpid anvil
restive otter
#

idk

torpid anvil
torpid anvil
fallen thistle
#

Thought so

obsidian tide
#

self.bot scared me

heavy summit
#

so to receive upvote webhooks on python, what's the best library to go about creating a web server for that. I saw many examples, i think http.server seems the best, just wanted a second opinion just in case there is a better way to go about receiving webhooks. thanks!

restive otter
#

im confused about the webhook stuff 😭

#

I dont understand what webhook path, webhook auth or webhook port means, do I need this to use on_dbl_vote

#

im using dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) without it

heavy summit
#

i believe you need to create a webserver for it, i used to use webhooks on my d.js bot with dbl (receive on local machine), for that i created a webserver, port forwarded the port i specified on the website and it worked fine

#

however in the api i never saw the option to specify a server for DBLClient so maybe its different x-x

restive otter
#

aye

#

anyone here

#

use the api with python

#

I need help simp

#

yoi

#

Hi guys

#

@shut flume are you pro at api?

#

of bots

#

yes or no

#

no i mean

#

api of bot

#

Yes

#

@shut flume so you can help me?

#

@shut flume thanks for help bro bye

restive otter
#

same bro 😭

#

it's cancer

#

😭

#

What the hell is webhook_path, webhook_auth and webhook_port I have no idea, I just want my on_dbl_vote thing to work 😭

#

SAME 😦

#

😭

#

devil we should kiss and makeout

#

we relate soo much

#

im scared now

#

lmaooo

#

jk jk

restive otter
#

Im so confused im completely new to webhooks etc

#

I just dont understand any of it

#

lol I dont know what that means as I said Im completely new to all of this stuff

#

ahhh why do I have to do this just to get the on_dbl_vote to workkkkk ahhhh I dont understand anything anymoreeeeeeee

#

why cant that be done through the api, why does it have to be done through webhook

#

I cant find any good guides or explainations how to do this

#

Ah I cant if I dont know what that is, also I cant its not my router so I cant access the settings

#

Why do I need that just to receive data on who voted

#

for example discords api gets users id's etc why cant dbl do the same for who votes

#

how, you just said you needed to use webhooks

#

still confused about all the webhook stuff however Ive found another way to do what I want for now, thanks to this #topgg-api message

Thanks for the help

empty mango
#

do you have a youtube api to get information about the video?

#

?

lean ivy
#

What do i pip install for this to work

rapid kettle
#

dblpy iirc

lean ivy
#

Kk

#

Thanks

final vortex
#

is there any way for me to get the time of when someone voted through the .hasVoted() function in the js library or do i have to use webhooks (pls ping with response)

spark lintel
spark lintel
#

So any body can't help okk

jaunty plank
restive otter
#

man

#

if only who knew how to use topgg api with python 😭

#

I need some help 😭

jaunty plank
fast agate
restive otter
fast agate
#

but u must have ur bot in top.gg I mean ur bot must be applied

spark lintel
fast agate
#

30 minutes waiting xd

restive otter
#

oh

#

sorry

#

I just realized

#

i can't use the api

#

😐

#

@fast agate

#

os I gotta make one on my own

fast agate
#

okie no problem

fast agate
restive otter
#

but..

#

I don't know how to 😭

#

i gotta figure it out

#

i guess

fast agate
#

new in programing world?

red cove
#

Where's the docs for the server vote webhook? I need to reference what data it includes

fast agate
#

this?

red cove
#

That's for bots

#

I had seen the one for servers when I first made my webserver but I can't find it now

fast agate
#

If I find something I will tell u

amber harbor
#

TypeError: Cannot read property 'on' of undefined

const DBL = require("dblapi.js");
const dbl = new DBL('my-super-secret-token', client);
dbl.webhook.on('ready', hook => {
    console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});

what's the issue...

rain heart
#

webhook is undefined

amber harbor
hot axle
#

Well

#

dblapi.js is undefined

#

@amber harbor Check pinned messages

amber harbor
rain heart
#

If you're hosting it locally, yes

amber harbor
#

F

#

i can't, i got a dynamic IP, it won't be possible

hot axle
#

Well, you still had to do it if you were using dblapi.js

amber harbor
#

oh well, i just won't use it for now i guess

restive otter
#

How can i set up the password and the link (webhook)

rain heart
#

Library?

#

Language?

restive otter
restive otter
rain heart
restive otter
#

how can i use discord webhooks for this?

rain heart
#

You cant

#

It's not a discord webhook

#

you need to make your own webhook using that

restive otter
#

oh ok

#

ty

restive otter
#
dbl.postStats({
    serverCount: client.guilds.cache.size
})
}, 1800000)``` this is not working and giving error
#

Error: 400 Bad Request

hearty lintel
thorn hearth
#

Need api foe welcome command

alpine stratus
#

wdym?

restive otter
#

how do i find the ip of a website thats it being hosted ok

#

like repl is where its hosted

lime berry
#

cmd -> ping domain.extension -t

#

will return the server ip unless it's behind cloudflare/other

hearty lintel
#

for repl.it it should give you a url

modest oar
#

How can I check if somone voted for the bot on discord.py?

hot axle
#

make a request to the top.gg api

#

i think there was a /check route or something

#

/bots/{bot-id}/check?userId=some-user-id

modest oar
#

alr thanks

restive otter
#

how to get api key

hot axle
#

api docs -> "My bots"

jaunty plank
restive otter
#

what is password

modest oar
#

bruh

kind hedge
#

Just a quick question. Is the @top-gg/sdk module required for the topgg-autoposter module to work or can i just use topgg-autoposter by itself?

#

Please ping me if you want to reply

rain heart
restive otter
#

hi

kind hedge
old patio
#

Is there any way I can test out my voting system without begging my friends to vote for my bot again?

hot axle
restive otter
#

what is API to bring up the number of servers?

hearty lintel
#

@restive otter u want to post your servers or get other peoples servers? and what language are you using

restive otter
hearty lintel
restive otter
#

what does he do

hearty lintel
#

it posts your stats

restive otter
hearty lintel
#

yes

kind hedge
#

Just a quick question. Is the @top-gg/sdk module required for the topgg-autoposter module to work or can i just use topgg-autoposter by itself?

hearty lintel
#

didnt someone already answer you

#

no it doesnt

#

its a submodule

kind hedge
#

oh thanks

hearty lintel
#

its how node works, itll end up being installed anyways

restive otter
hearty lintel
#

anywhere you want

#

you just have to pass the client and a topgg token

restive otter
hearty lintel
restive otter
#

can I create a file called topgg.js and put it?

hearty lintel
#

sure, you just have to pass the client

restive otter
#

pass client? dont capish

#

ihave key

hearty lintel
#

your client that you made, like const client = new Discord.Client()

#

wherever you put that you just have to pass that along

restive otter
#

where do i put this key?

hearty lintel
#
const AutoPoster = require('topgg-autoposter')

const ap = AutoPoster('topggtoken', client) // your discord.js or eris client

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

replace topggtoken with your key and client with your client

restive otter
hearty lintel
#

no

#

you see topggtoken

restive otter
#

why

hearty lintel
#

its right there

#

that's where you put your token

restive otter
#

OHhh

#

thanks

hearty lintel
#

yup

restive otter
#

2 min

hearty lintel
#

yea

#

just make sure client is defined and you'll be set

restive otter
#

is it in the index.js okay?

hearty lintel
#

yea

restive otter
#

okk is online

#

i check

hearty lintel
#

go to it and hit refresh data

#

and if that still doesnt work just give it a few minutes for cache to load

#

as long as it says "Posted stats to top.gg" in your console it'll work

restive otter
#

again?

hearty lintel
#

then you've done something wrong

#

are you passing the client to it?

restive otter
#

idk

hearty lintel
#

just paste the code under where you define client

sacred delta
#

I'd just like to say i've been watching this struggle the whole time, you have patience i'll give you that

restive otter
#

Guys

hearty lintel
#

try it

restive otter
#

How to create API for my Discord bot

hearty lintel
#

see if it logs

restive otter
#

@hearty lintel hi I wanna Make website but I can't because I need API of the bot how

hearty lintel
#

ah

#

replace client with bot

restive otter
#

why client

hearty lintel
#

cuz u defined your client as bot not client, so put bot instead of client

sacred delta
restive otter
#

@hearty lintel you know when we make website we need to connect the bot with the website but first we need API

hearty lintel
#

does this have to do with top.gg or are you talking about the authorize button on discord?

restive otter
hearty lintel
#

wh

#

no

#

in the AutoPoster(..., client)

#

replace client with the name of what you defined Discord.Client() as

restive otter
#

okkk

sacred delta
restive otter
hearty lintel
#

refresh data and or give it a few minutes to flush cache

restive otter
#

thanks you <3.

hearty lintel
restive otter
sacred delta
restive otter
sacred delta
#

berry nice

hearty lintel
tacit moat
hearty lintel
#

works for me, you're using the widget code right? copying the image

heavy summit
#

is the on_dbl_vote event (python) the non-webhook implementation?

heavy summit
#

like its delayed

tacit moat
#

https://discordbots.org/api/widget/id.svg

@hearty lintel

Used it for a long time, stopped working 500 servers ago though.

hearty lintel
#

so your html code looks like this?

<a href="https://top.gg/bot/394019914157129728">
    <img src="https://top.gg/api/widget/394019914157129728.svg" alt="Censor Bot" />
</a>```
tacit moat
#

Img tag, but essentially.

hearty lintel
#

that seems up to date for me

tacit moat
#

The image loads, but the server count looks behind. Oh, perhaps the post to the endpoint is actually the issue

#

Oh lmao

hearty lintel
#

u sure ur posting didnt break lol?

tacit moat
#

Yeah, now I remember

#

It did, when the domain switched.

hearty lintel
#

what lang do u use?

tacit moat
#

I've updated it since, but now I'm thinking more than the domain changex

#

Changed*

hearty lintel
#

if js should use the new package

tacit moat
#

"new package"?

hearty lintel
tacit moat
#

That... Isn't the issue lol. Did the endpoint change in any way other than the domain?

hearty lintel
#

i see, uh not much changed no

old patio
#

can someone please explain this thing to me is it optional is it not, the documents dont help

hearty lintel
#

it is optional

#

its for if you want events for when users vote

old patio
#

im trying to make a reward system for my bot's users...

hearty lintel
#

so then yes you needa make a webhook

old patio
#

but then how do i make a webhook??? thats what i dont understand

hearty lintel
#

open a port and use the library for your language to handle it

rapid kettle
#

top.gg -> your webhook handler (webserver)

#

you can then process it

#

or store it

#

do whatever the fuck you wanna

restive otter
#

Will this work, I am trying to make a bot that will say bruh whenever you type something

<Client>.on('message', message => {
//handle bruh
});

hot axle
#

yea

restive otter
dapper bobcat
#

how do I see if a user has voted?

hot axle
#

with userId as a query param with the user id you want to check

dapper bobcat
#

but I thought I had to use the @topgg/sdk or whatever?

hot axle
#

oh yeah i just checked

#

the @top-gg/sdk has a method for checking that

#

my bad

winter basin
#

ping me when you wanna answer to me

jaunty plank
#

there used to be a feature to show your bots library, this has been deprecated, its not been removed from the widget yet @winter basin

dapper bobcat
#

when I use the .hasVoted function, does it only return true if they have voted in the last 12 hours?

#

okk

wooden yarrow
#

Hi

mossy bay
#

my dudes does anyone knows how to make a server count actually working with discord.py

#

the example doesn't work for shit

#

could this be because of the environ.get?

sullen nymph
#

Apply cog listener decorator to on_guild_post and make sure you're loading the cog

spice heron
#

it takes 30min iirc

#

to update

#

it does on my bot anyway

sullen nymph
#

Press Refresh Data on the bot's page just in case

mossy bay
#

oh ye but the cog doesnt even load

#

on my heroku

sullen nymph
#

Fun

mossy bay
#

it throws an error

sullen nymph
#

What error

spice heron
#

what's the error then

mossy bay
#

that it doesnt load

spice heron
#

...

#

great

sullen nymph
#

Yeah, that's not helpful

mossy bay
#

like i dont know whats causing it

#

i just have a func when

sullen nymph
#

What's your dblpy version

mossy bay
#

they cant cload

spice heron
#

wait

#

is it doing that only on heroku ?

#

and not locally ?

mossy bay
#

havent tried it locally tbh

spice heron
#

lol try it locally

mossy bay
#

alright yeah i just thought someone had a similar situation so it will be quick fix. I tried the python script just like in console didnt throw any errors

spice heron
#

if it doesn't work, change the env function to os.getenv

mossy bay
#

ill try running the bot locally though

#

see what happens

spice heron
#

you should have done that first tbh

#

likely os.environ.get is throwing

#

due to not having that environment variable

mossy bay
#

but it is on heroku

#

i have bot token as the same thing

#

and it works just fine

mossy bay
#

sorry

spice heron
#

kinda off-topic

mossy bay
#

i mean yeah sure

#

but isnt that about api? lol

spice heron
#

more than likely not

mossy bay
#

alright

spice heron
#

I still wanna know why it doesn't load tho

#

what's the exact error ?

gusty socket
#

While sharing the number of DBL servers, socket hang up gives an error, same code on the site

modest oar
#

how do I check if someone voted with an if statement in discord.py?

modest oar
#

thanks

modest oar
#
    @commands.command()
    async def votereward(self, ctx):
        if ctx.author isVoted == 1:

@shut flume something like this?

#

well i get invalid syntax lmao

#

and I can't find anything in the docs about that

sullen nymph
#

Jesus Christ

#

Lord help my soul

modest oar
sullen nymph
#

Anyway

#

Back to what I wanted to say

modest oar
#

must have gone blind

modest oar
odd valley
#

How can I make my bot give currency when someone votes for it?

sullen nymph
#

Either use dblpy's webhook feature or host an async webhook manually with aiohttp.web/Sanic

odd valley
#

I didnt understand hald a word

sullen nymph
#

Which part exactly did you not understand?

odd valley
#

Ehm, the webhook feature

#

Where is it

sullen nymph
#

top.gg used to be named Discord Bot List (Discord Bots) before and I've been too busy with random shit to fully migrate to the recent changes

odd valley
#

Oki, thx

restive otter
#

Doesn't the client.hasVoted() boolean reset every 12 hours?

distant oak
#

Good question

rain heart
#

ofc it does, as you can revote every 12 hours

restive otter
#

its been 12 hours but i dont think that hasVoted() function working probably

hearty lintel
#

how long exactly has it been?

restive otter
#

let me check

#

16 hours

hearty lintel
#

is it you? like are you checking yourself?

restive otter
#

yep

hearty lintel
restive otter
#

voted 0

hearty lintel
#

what's your hasVoted code?

restive otter
#
if (topgg.hasVoted(data.user.id) === false) {
      alert("You need to vote ZAP-UP on top.gg for using dashboard.");
      return router.push("https://top.gg/bot/789629205611937792/vote");
    }
hearty lintel
#

are you using it in your browser?

restive otter
#

yep

#

next.js

hearty lintel
#

are you passing a token?

restive otter
#

yes

hearty lintel
#

i hope not

#

so anyone that goes to your site can see the token..

restive otter
#

i dont think so

hearty lintel
#

i think you're getting an error its just the library doesnt handle it properly

restive otter
#

Can you check it?

#

I can dm you dashboard link

hearty lintel
#

can you show where you define topgg

restive otter
#

const topgg = new Api(dashboard.dblkey);

#

import { Api } from "@top-gg/sdk";

hearty lintel
#

try and console.log topgg.getVotes()

#

just to see if it's a request issue

#

OH

restive otter
#

ah

hearty lintel
#

await topgg.hasVoted(...) ...

restive otter
#

...

#

thank you!

hearty lintel
#

np

covert lark
#

Hey, I'm trying to make a request to top.gg/api/bot/:bot_id (obviously the bot id is there) and it says err: Not found, any ideas? I'm sending a request from chrome.

rain heart
#

don't have the actual : in the url

covert lark
#

I know that

rain heart
#

Good Hehe

covert lark
#

Nothing shrug

rain heart
#

replace bot with bots

#

that should work

covert lark
#

okay

#

it is documented wrong then lol

#

thanks

rain heart
#

yeah figured that it is

covert lark
#

oh

#

must of read wrong

median tulip
#

Hi, I wanted to ask: How do I get my top.gg token?

sullen nymph
median tulip
#

oh ok

uncut quartz
#

I am trying to run the webhook and when it starts i get the start message just it doesn't get when someone votes

rain heart
#

Oh fuck nvm brain fart

#

Make sure you entered it inside your bot page settings

#

under "Webhooks"

uncut quartz
#

oh ll

#

i am stupid

acoustic sierra
#

Hi! emm, i do a code for the votes in discord bot, but it don't send the webhook

#

can i send my code?

jaunty plank
#

did you fill in the webhook url on your bots edit page?

#

and the auth

acoustic sierra
rain heart
#

Discord webhooks still do not work

acoustic sierra
#

hu, why?

jaunty plank
#

because discord webhooks have their own format that is different than top.gg's

#

which is why you make your own webhook receiver with code.

severe quiver
#

Sorry if this is a stupid question, but how do I interact with the api without posting guild counts (using the js lib)?

shy vortex
#

normally it doesn't even post the guild count unless you explicitly code that in

#

so just use the lib like normal

#

and don't use the post method

#

Β―\_(ツ)_/Β―

severe quiver
#

Oh fair enough, thanks

abstract zealot
#

I'm confused on how to setup a webhook for the api

#

would it just be https://serverip/port?

shy vortex
#

yes

abstract zealot
#

hmm ok

#

is there any way to add 2? 1 for local machine and 1 for server

shy vortex
#

no

#

only 1 url

abstract zealot
#

rip is there any cooldown for changing it?

shy vortex
#

dunno

#

probably the same as editing ur bot info stuff on top.gg

#

ig

#

idk

abstract zealot
#

ig I'll just have to wait if there is a delay

#

webhook_path='/dblwebhook' is this supposed to be the webhook url?

main nexus
#

how i make this

tall tundra
jaunty plank
#

make what? the url?

jaunty plank
#

http://ip:port/path

abstract zealot
#

what is the path?

jaunty plank
#

well in the example you gave the path you set is dblwebhook

abstract zealot
#

I just copied that from the docs bc I have no clue what it is used for

#

do I need it?

jaunty plank
#

it sets the path of the url

#

if you dont use it your path will be the default of the lib, or blank depending on the lib.

abstract zealot
#
Traceback (most recent call last):
  File "/home/container/libs/aiohttp/web_protocol.py", line 275, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 523, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: invalid HTTP method

I keep getting that

#

I'm not sure why

#

I have the correct token, webhook_auth and webhook_port

jaunty plank
abstract zealot
#
@commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print("Got upvote")
        print(data)

that method is not being called though?

jaunty plank
#

you filled in the url and auth on the website correctly?

abstract zealot
#

url is https://ip/:port right?

#

and auth can be any string?

jaunty plank
#

do you have ssl?

#

http if you dont, https if you do.

#

http://ip:port/path

abstract zealot
#

ah that's prob it

jaunty plank
#

filling in ip and port and path

abstract zealot
#

ah ok

pure shell
#

@jaunty plank ?

jaunty plank
pure shell
abstract zealot
#

after fixing the path I am still not getting anything

jaunty plank
#

your using the actual ip correct?

#

aswell as the actual port.

abstract zealot
#

yes

jaunty plank
#

do you have any firewalls blocking the port?

abstract zealot
#

shouldn't

jaunty plank
#

if on a home network is it port forwarded

#

or even some VPS's require portforwarding

abstract zealot
#

I am using a professional server so it should be fine

#

it works with other apis

jaunty plank
#

webhooks are kind of like backwards api's

#

the top.gg server sends a request to you, rather than you sending a request to it.

abstract zealot
#

just to make sure

#

the auth can be any string?

jaunty plank
#

any string as long as its the same between your code and the website.

abstract zealot
#

and if the webhook url is http://ip/:port/dbl
webhook_path = '/dbl' should work?

jaunty plank
#

you shouldnt set it as the variable name and value

#

just the value

#

^`

abstract zealot
#

ah ok

#

is webhook_port required? is it supposed to be something different from the port I provided for the webhook url?

jaunty plank
#

you should be setting a port yes, it can be any valid port you want that is not being used already.

abstract zealot
#

sorry if this is a dumb question I know almost nothing about webhooks but if I am using the port for something like accessing the reddit api would it still work for dblpy?

jaunty plank
#

i dont think the reddit api requires a port, unless they also have a webhook feature.

#

but mostly, no ports cant be used twice.

#

but since theres 10's of thousands of valid ports, its not really a problem to use another one

abstract zealot
#

yeah but rn I only have 1 port available from my hosting service

jaunty plank
#

does the reddit api require a port? πŸ€”

abstract zealot
#

wait nvm I am thinking about another bot

#

the port should be free

jaunty plank
#

i dont think the reddit api even uses ports

abstract zealot
#

would I have to setup anything in my server for the webhook to work?

#

other than that?

#

hmm

#

well it seems like it is getting a request

#
Error handling request
Traceback (most recent call last):
  File "/home/container/libs/aiohttp/web_protocol.py", line 275, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 523, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: invalid HTTP method
#

but the method is not being called

@commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print("Got upvote")
        print(data)
jaunty plank
#

the lib dev says that error shouldnt affect anything πŸ€·β€β™‚οΈ

abstract zealot
#

I am using dblpy

jaunty plank
#

are you using the test button to test it?

abstract zealot
#

yes

jaunty plank
#

that method is only for real votes

abstract zealot
#

🀦

jaunty plank
#

the on_dbl_test method is for test votes.

abstract zealot
#

it was working from the very beginning then >_<

#

alright got it works thanks

tall tundra
#

I need to port forward for setting up a webhook for my bot?

jaunty plank
#

if its on a home network yes.

#

or on a network that requires port forwarding.

tall tundra
#

Ok thanks

acoustic sierra
jaunty plank
#

in the url field, you put the url of your webhook receiver.
in the auth field you put the auth of your webhook receiver.

acoustic sierra
#

and how i get this?

acoustic sierra
#

@jaunty plank

jaunty plank
#

the url?

acoustic sierra
#

yes

jaunty plank
#

its typically http://ip:port/path

#

ip is your servers public ip

#

port is defined in your code

#

path is defined in your code

heavy summit
#

now this isnt completely related to the API but, i'm using aiohttp web App to handle the webhooks in my bot code (bc i dont want multiple connections to the DB)

(assuming this is inside the on_ready event of the bot)

app = web.Application()
routes = web.RouteTableDef()

@routes.post('/post')
async def post_handler(request: web.Request):
    print("here")
    return web.Response()
app.add_routes(routes)
runner = web.AppRunner(app)

await runner.setup()
site = web.TCPSite(runner, 'localhost', PORT)

await site.start()

however, whenever i test the webhook, it doesn't seem to be handled by the handler. Any suggestions on what i'm doing wrong?

acoustic sierra
#

servers public ip?

#

what

jaunty plank
#

the public ip for top.gg to send the webhook to.

heavy summit
#

is this the correct way to go about it?

#

i tried changing the decorator to @routes.post('/dblwebhook') also but no effect. I can confirm the URL on website is correct, as i tested it through a local http server on the same port and it works fine

jaunty plank
#

if it functions locally but not remotely its typically a sign a firewall is preventing it from working.

heavy summit
#

alright, thanks i'll look into it!

heavy summit
#

seems you were right its only external connections

heavy summit
jaunty plank
#

the webhook is just an http server, so im not sure.

outer heart
#

With the python library, how would I reward the user that votes my bot on an on_dbl_vote event?

outer heart
#

I dont understand how to get their user id

sullen nymph
#

Get the user key and you get the user ID in a string

old patio
#

Yo, so when I launch my bot and it runs the webhook it returns with ```
Webhook running at http://0.0.0.0:2002/dblwebhook

is this something I should worry about?
#

ipv4 ip?

restive otter
#

@old patio curl -sL api.ipify.org to see ur public ip

rain heart
#

Because webhooks are understandable through both common sense in programming, aswell as the documentation, which most people don't even read

#

Everyone who has done atleast one thing with ips know that ips starting with 192.168 are normally local ones and that you cannot connect to them from external connections

keen sleet
#

I know the conversation is finished, but you can also forward your localhost through a service on your behalf to test the webhook. That's what I did, at least.

#

ngrok was a fairly useful / free tool to do this with.

hearty lichen
#

ello

#

may I ask how to receive vote updates

#

and what webhooks

keen sleet
#

What about them?

hearty lichen
#

how do I receive vote updates

rain heart
#

The webhooks can receive votes that go through your bot

restive otter
#

hey

#

May i ask something

keen sleet
#

sure

hearty lichen
#

tbh I dont understand how this works

#

what should be the webhook?

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...

hearty lichen
#

so

#

we need our own webhook server?

rain heart
#

Correct

#

That can be done through your bots code

#

some libraries have a webhook built-in you can use

hearty lichen
#

ngl still dont understand lol

hearty lichen
rain heart
#

What library are you using

hearty lichen
#

discord.js

rain heart
hearty lichen
#

it has webhook server built in?

#

still dont get it :D

rain heart
#

Then you're not ready to do it yet imo

hearty lichen
#

lmao

#

Im more like confused then not knowing how to do it (if I were to knew them)

restive otter
#

what is webhook auth ?

#

how to get it

#

in dbl api

rain heart
#

That's something you can define yourself

#

Inside your code where your webhook runs on

restive otter
#

ok

#

thks

errant timber
#

I want to see the voters of my bot in my question, how can I do this?

gusty elbow
#

with the new @restive otter/sdk package, can i still post stats on the guildCreate event?

sullen nymph
#

Yes

gusty elbow
#

ok

arctic bloom
#

Hols

#

Hola

gusty elbow
#

mk

rapid kettle
#

i'd just post every 30 minutes

restive otter
rain heart
restive otter
#

thanks

supple raptor
#

SELAM ARKLAR

#

BEN TÜRKÜM

rain heart
heavy summit
#
from aiohttp import web

PORT = 1234 #Some Number that is Port Forwarded

app = web.Application()

async def post_handler(request: web.Request):
    # STUFF
    return web.Response()

async def handler(request: web.Request):
    return web.Response(text="Hello")

app.add_routes([web.get('/', handler), web.post('/dblwebhook', post_handler)])

runner = web.AppRunner(app)
await runner.setup()

site = web.TCPSite(runner, 'localhost', PORT)
try:
    await site.start()
    print('listening on Port:', PORT)
except:
    pass

I'm using aiohttp web App (with application runner so i can run the code with my bot code). For some reason, it works just fine locally, but trying to send GET / POST requests from outside doesn't work. I can confirm its port forwarded correctly and it doesn't seem to be an issue with firewall either. Any suggestions? (Tbh, i've asked this question before but hoping to find some resolution today)

EDIT: All of this is inside the on_ready event of discord Bot.

ornate abyss
#

does POST return anything? like a message or something

rain heart
#

depends on endpoint

#

stats doesn't return anything

#

yeah none of the post-ones return anything

#

just 200 on a successful post, 403 without any authorization/wrong authorization, and 429 if ratelimited

ornate abyss
#

yes stats

#

ty

sullen nymph
heavy summit
#

its my public ip

heavy summit
sullen nymph
#

Either that or see if you're entering it correctly

heavy summit
#

well its MY_PUBLIC_IP:PORT/dblwebhook

#

its only with aiohttp web server that i cant get it to work, it works fine with http.server library

#

but since its not asynchronous, i'm forced to resolve to aiohttp

sullen nymph
#

Prepend http:// to the URL

heavy summit
#

okay i'll try that

restive otter
rain heart
#

get it from the My Bots section of the apidocs

restive otter
#

πŸ†— thx

heavy summit
sullen nymph
#

Interesting

restive otter
#
if(args[0].toLowerCase() == 'vote') {
    if(dbl.hasVoted(msg.author.id)) {
      msg.channel.send(':white_check_mark:')
    }else{
      msg.channel.send(':x:')
    }
  }

its always sends βœ… what's the problem

rain heart
#

wrong channel, this channel is for the top.gg api

restive otter
#

so? its api

#

dbl api

rain heart
#

Then that user has most likely voted already, let the hasVoted print out

restive otter
#

i did it for another account but its still βœ…

rain heart
#

let the dbl.hasVoted print out and see if it returns true or false

restive otter
#

ok

#

msg.channel.send(dbl.hasVoted)

#

Im adding this

#

its printed: Promise { <pending> }

#

are you here

heavy summit
#

you need to use then

#

since its a promise

restive otter
#

ok

heavy summit