#topgg-api

1 messages · Page 138 of 1

upbeat hare
#

So I don't know when a user vote for my server ?

rain heart
#

You can use webhooks

hot mulch
#

im trying to do the same thing, and I'm using the code provided in the pin

i'm trying to make it log the request, but when pressing "test" nothing shows up in my log

var express = require('express');
var Topgg = require('@top-gg/sdk');
const webhook = new Topgg.Webhook('bot-token-here')
var app = express();
app.post("/dblwebhook", webhook.middleware(), (request, response) => {
    let authorization = 'authorization-token-here';
    console.log(request);
    response.sendStatus(200);
})
app.listen(5910);
rain heart
#

did you save the webhook?

hot mulch
#

yes

rain heart
#

send the url here if you want to

hot mulch
#

its running under my public ip address so i'd rather not

rain heart
#

also replace bot-token-here with your bot token, unless you removed it for security reasons

hot mulch
#

yeah, i removed it just for the sample

rain heart
#

if it is running on your public ip address, did you portforward?

hot mulch
#

mhm

#

does it usually take a while to post to the url?

rain heart
#

it should work under 10 seconds, did you test it with a rest client such as postman?

#

to make sure it actually works?

hot mulch
#

i'm using a firefox extension called rester and posting to it logs it perfectly fine

rain heart
#

otherwise, send the url here with replacing your IP with x so i can tell you if the format is correctly

#

for example x.x.x.x

hot mulch
rain heart
#

add /dblwebhook

#

as your path is set to /dblwebhook

#

http://x.x.x.x:5910/dblwebhook

hot mulch
#

alright, seems to have worked

rain heart
#

yeah then the path was just missing

hot mulch
#

just one thing that i needed to change, you dont need to set your bot token in the Topgg.Webhook part

#

you only need to put in the authorization token you set

#

thank you though

rain heart
#

the Topgg.Webhook is just for the middleware things, don't know what exactly it does either

jaunty plank
#

it authorizes and checks if its formatted as expected

rain heart
#

ohh

uncut lintel
#

how do i use the voting credits?

jaunty plank
uncut lintel
#

thx

dire trench
#

!aki

rain heart
wild brook
#

#p دورك جى

#

!p دورك جى

rain heart
static field
static field
umbral yacht
#

How's everything going with you guys in here all I'm asking you guys to do is the keep it appropriate if you guys can't keep it appropriate I have to stick to regulation and guidelines so therefore if I get another complaint of anything inappropriate on this sector here done

rain heart
#

@umbral yacht what?

dire mantle
#

a

jagged geyser
#

how do i get my api key? nvmnd pins

nocturne quarry
#
const api  = new Topgg.Api('I put the top.gg token here')
setInterval(() => {
    api.postStats({
        serverCount: client.guilds.cache.size 
        })
}, 1800000)

Why it didnt post server count?

restive otter
#

Did you wait 30 mins?

nocturne quarry
#

Yes

#

From yesterday

restive otter
#

weird

#

it works for me

#

whats your discord.js version

nocturne quarry
#

Latest

#

Also I use dbd.js as the programming language but I can use discord.js

#

Should I use the autoposter?

#

Minute I will do

api.on('posted' => {
console.log("Posted server count!")
})
#

@restive otter Will it work?

#

oof

restive otter
#

use autoposter if you are not gonna do anything abt the top.gg api but only for server count

nocturne quarry
#

I will use the autoposter I really need to post servercount

#

Oof it says unsupported client

restive otter
#

idk how to use dbd.js so

#

¯\_(ツ)_/¯

civic cape
#

Hay

restive otter
#

Hey @rain heart

#

This is not working for me

#

hey anyone please tell me why this is not working for me^^^^

restive otter
#

It worked

#

I posted server count finally

midnight vapor
#

pls help me

restive otter
hollow owl
#

sorry,i do not know java

midnight vapor
restive otter
midnight vapor
#

when i lauch the api?

restive otter
midnight vapor
#

no when i try to make the api that i can use it

restive otter
#

Idk

#

Sorry

midnight vapor
#

sad

restive otter
#

hi

plush python
#

/networth bralter watermelon

long birch
#

@proud cloud

proud cloud
#

?

restive otter
#

ayo i got it set up

jaunty plank
#

pog

restive otter
#

now i just gotta figure out the vote webhook

#

hard cuz i host at home w/ a dynamic ip

#

😩

#

is there a way i can change the webhook ip through the api?

jaunty plank
#

nope

restive otter
#

😩

jaunty plank
#

you will probably need dynamic dns with a domain

restive otter
jaunty plank
#

yeah, so itll change the domain to your ip even if it changes.

restive otter
#

okay

#

i have no idea how to do that tho lol

#

damn it

jaunty plank
#

3 letter tlds are almost always taken

restive otter
#

😩

#

close enough

rapid kettle
#

Did you mean 3 letter domains

jaunty plank
#

top level domains?
second level domains 3 letters are easy to get.

restive otter
#

before i die can someone confirm that reads one dolar per year

#

not 100

#

@jaunty plank

jaunty plank
#

its $1

restive otter
#

okay

#

thats cheaper than i expected lol

#

icb-bot.xyz or icbh.xyz?

jaunty plank
#

whats icb stand for?

#

icbot.xyz

#

?

restive otter
#

its the acronym of my bot name

#

invite counter bot

#

hence icb.xyz

#

but taken

jaunty plank
#

then icbot.xyz is what i would get

restive otter
#

😩

#

my friend said that too

#

but it doesnt sound right to me

jaunty plank
#

iseebot.xyz 👀

restive otter
#

tbh im kinda partial to icbh.xyz but idk

jaunty plank
#

i mean, is it just going to be used for the webhook?

#

if so it doesnt matter

restive otter
jaunty plank
#

then use what you feel is best

restive otter
#

😩

jaunty plank
#

at the end of the day you know best

restive otter
#

what if i just didnt make a voting webhook?

jaunty plank
#

the alternative is using hasvoted to check if they voted.

#

if your not giving rewards, you dont need either

restive otter
jaunty plank
#

ideally, you would use the webhook if you wanted that

restive otter
#

😩

#

but the webhook is so complicated

#

i go back to

#

what if i didnt

jaunty plank
#

then nothing happens when someone votes

restive otter
#

yea

#

how does it get 12 upvotes when 24/7 offline

jaunty plank
#

just random users voting?

nocturne dirge
#

oops

#

wrong chats

empty gazelle
#

@nocturne dirge yeah please dont

civic cape
#

Hi

restive otter
restive otter
bleak ledge
oblique dew
#

xd

restive otter
#

ecks dee

knotty garnet
restive otter
knotty garnet
#

that's a whole new question

restive otter
wind sun
#

import dbl
import discord
from discord.ext import commands, tasks
import os
import logging

class DSLCount(commands.Cog):
  def __init__(self, client):
    self.client = client
    self.token = os.environ["topgg_key"]
    self.dblpy = dbl.DBLClient(self.client,self.token)
  
  @tasks.loop(minutes=5)
  async def update_stats(self):
    logger.info('Attempting to post server count')
    try:
      await self.dblpy.post_guild_count()
      logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
    except Exception as e:
      logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))

  
def setup(client):
  global logger
  logger = logging.getLogger('client')
  client.add_cog(DSLCount(client))```
#

does this work correctly? Like is this good?

#

This doesn't seem to return any stats (please ping me when you respond, thanks)

restive otter
wind sun
restive otter
#

you can try putting self.update_stats.start() in your __init__

wind sun
# restive otter you can try putting `self.update_stats.start()` in your \_\_init\_\_

import dbl
import discord
from discord.ext import commands, tasks
import os
import logging

class DSLCount(commands.Cog):
  def __init__(self, client):
    self.client = client
    self.token = os.environ["topgg_key"]
    self.dblpy = dbl.DBLClient(self.client,self.token)
    self.update_stats.start()
  
  @tasks.loop(minutes=5)
  async def update_stats(self):
    logger.info('Attempting to post server count')
    try:
      await self.dblpy.post_guild_count()
      logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
    except Exception as e:
      logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))

  
def setup(client):
  global logger
  logger = logging.getLogger('client')
  client.add_cog(DSLCount(client))```
#

this should work then right?

restive otter
#

You might want to cancel the loop on cog_unload, but yes that should do ig

wind sun
#

Now

#

where to find my bot's uptime

#

I mean stats

wind sun
#

but uh

#

I guess user count doesn't share then?

restive otter
#

Only shard and guild count iirc

wind sun
#

on the bot search

#

which is annoying

#

but it did appear

restive otter
#

wdym?

wind sun
#

nothing about total

#

guilds

#

but on the search page

#

then there are

wind sun
#

I found the server count

short roost
#

How do make my bot respond if someone votes her and give that user a role also , and I am using discord.js library , I am kind of new with this api

jaunty plank
#

i would suggest webhooks

short roost
#

Ooookkk

#

Thanks !

restive otter
#

I need someone to help me setup the webhooks for my topgg bot

jaunty plank
#

what part do you need help with @restive otter

restive otter
jaunty plank
#

what about it

restive otter
#

i need help setting it up. when i add a webhook from my server and hit test, nothing is sent to the server

rain heart
#

you cannot use discord webhooks

restive otter
#

what should i use

rain heart
#

a custom one, read the pinned messages

plucky lance
#

You need to setup a webhook service

short roost
#

where i will get webhook URL and Authorization ?

rain heart
#

from your code, webhook url is your webserver and auth is something you define yourself

#

most common format is http://ip:port/dblwebhook

short roost
#

woah

#

Can't I give discord's Webhook Url ??

hearty lintel
#

no you can't

short roost
#

i can't setup then damn

rain heart
#

use a Bot that does it for you then such as Vote Tracker

short roost
#

oooo , btw what happens on Test button ?

rain heart
#

it sends a test request to your webhook

#

a test vote

short roost
#

okk

#

Is there any video which explains every step , because i don't know how to setup the web server now

vast bolt
#

Having an issue with voting, the vote command I am having gets stuck at this function when I'm starting up the bot, it queues and only actually properly checks after the bot is 'officially' up (i.e. out of the limbo state after on_ready is fired), but I do not have any on_ready event and my stuff like webhooks are all initialized within the cog so I'm very confused as to why it isn't working.

check = await self.dblpy.get_user_vote(ctx.author.id)

Does get_user_vote only works when the bot is fully out of limbo state?

#

Just checked the source code

#

apparently

async def _ensure_bot_user(self):
        await self.bot.wait_until_ready()
        if self.bot_id is None:
            self.bot_id = self.bot.user.id

is what affecting it

short roost
#

i am using webhook for getting upvote , how to get all upvotes till then and how much votes have been done by that user ?

restive otter
#

Hi, can anyone help me about api ?

sullen nymph
#

get_user_vote, as you probably already realized, is one of them

#

Yup, _ensure_bot_user affects it

#

If you don't like it, you can go for a workaround with await self.dblpy.http.get_user_vote(BOT_ID, user_id)

vast bolt
sullen nymph
vast bolt
#

Because when the bot becomes too large (mines in over 10k) it takes forever to set up so it wasn't sustainable >_>

sullen nymph
#

Ah, I see

#

Might allow passing the bot ID directly in v1.0 probably tbh

subtle zinc
#

/wifu

hoary nexus
#

Hi there, i want to use:

const AutoPoster = require('topgg-autoposter')

const ap = AutoPoster('Your Top.gg Token', client)

ap.on('posted', () => {
  console.log('Posted stats to Top.gg!')
})```
Is there any way to store only server count and not shards?
hidden wave
#

Sadly no

hoary nexus
#

Okey, ty for the answer

mellow flame
#

so it has these many dict values, but what url do i have to GET request to access these?

rain heart
#

the bots endpoint, should be mentioned above

mellow flame
rain heart
#

nevermind, that's the bot object

#

you can get it by using the /bots endpoint for example

mellow flame
#

but thats not what i want

rain heart
#

it is /bots

mellow flame
#

just /bots?

rain heart
#

https://top.gg/api/bots/botid

#

making a get request to it

mellow flame
#

mkay thanks

rain heart
#

though you seem to be making a get request to stats

restive otter
#

how do i make it so when someone votes it comes up in a channel i have setup (ping me)

rain heart
#

by using webhooks

topaz axle
#

sorry if i'm missing something, but is top.gg supposed to say that my bot is offline when it's always up? I get that the bot isn't on this server anymore, but virtually ever other bot says "online"

rain heart
#

that is intentional, there is no way to tell top.gg that your bot is online

#

it was a thing when @abstract moth was able to get the presences, but due to all bots being removed here, it isn't possible anymore.

topaz axle
rain heart
#

there's possibly going to be a new system that allows you to set your presence on the site

#

or it will just be removed yeah

topaz axle
#

ok thanks

shell steppe
#

@rain heart ?

rain heart
#

read the channel topic

shell steppe
rain heart
#

look for stats posting

#

servercount

shell steppe
rain heart
#

read the one for your library, that would be easier

shell steppe
restive otter
#

Api

plucky lance
hearty lintel
#

@shell steppe what language do you use

low hatch
#

=2022 fartdarling bw

rain heart
deft anvil
#

?

vocal robin
#

I want to make my webhook server on replit, since I just want to append the count on db. How do I get the ip of the replit server?

sullen nymph
restive otter
#

its https://replname.username.repl.co

vocal robin
#

what happend when my hacker plan expire, will the repo get public?

restive otter
#

yes ig

rain heart
#

lmao that sounds like ransom ngl

restive otter
#

dms open

restive otter
#

@jolly hornet hey not to bother you but this anna person sent "dms open" in all channels

rain heart
#

we're aware

jolly hornet
#

sus

rain heart
#

sus

restive otter
#

imma dm them see what i get

rain heart
dull thicket
#

My bot isnt autoposting the server count anymore

rain heart
#

check your code then

dull thicket
#

self.dblpy = dbl.DBLClient(self.client, self.token, webhook_path='/dblwebhook', webhook_auth='', webhook_port=8175, autopost=True)

#

I had the autopost=True

#

thing

#

it suddenly stoped

#

for some reason

sturdy pollen
#

Hello

quiet wedge
#

form where can i get the Authorization key for webhook ?

#

@rain heart

rain heart
#

You make it yourself

quiet wedge
#

where ?

rain heart
#

There's no where, you can create it yourself

#

that's like a password, it has to match the one you entered in your webhook auth on your code

quiet wedge
#

i have here my webhook

rain heart
#

You cannot use discord webhooks by the way

quiet wedge
#

wich webhooks can i use

rain heart
#

the ones you make through your code

#

read the docs

mellow flame
#

so i use AutoShardedClient and set the shard count to 2 but when i request the shard count via the api, it reurns None please help

#

\

restive otter
#

The vote webhook isnt working

#

I never changed my code

#

My code worked, and it's just not working anymore

#

@ancient plover

ancient plover
#

Because its still BROKEN

strong kestrel
#

Webhooks works fine on my end ?

#

Have you tried troubleshooting your issue ?

mellow flame
#

um how can i post the shard count to top.gg since when i GET request it , it just returns None even though ihave 2 shards

#

@rain heart please help >~<

rain heart
#

you cannot make a get request to posting shards

#

hear the word posting stats

mellow flame
#

oh wait

#

nevermind thanks!

rain heart
#

GET gives you the stats of the requested bot id

#

POST posts the stats given in your post body when correct authorization is given

hushed reef
#

umm lmao

#

what a gamer

#

@jolly hornet

jolly hornet
#

oh

hushed reef
#

i mean

#

he's just really patriotic

smoky swift
#

Classic.

signal snow
#

anyone have a head pat api just like lying around

rain heart
#

this channel is for the top.gg api

pliant oak
#
  File "/usr/local/lib/python3.7/dist-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.7/dist-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "launcher.py", line 30, in viewpost
    headers = await request.headers()
TypeError: 'multidict._multidict.CIMultiDictProxy' object is not callable

``` aiohttps confused about this error
sullen nymph
#

request.headers

#

not request.headers() apparently

green mantle
#

you also dont need to await it

#

it's given as the initial response

#

only things you need to await are the initial request submit and then any body interactions

#

the HEAD of the response will always be loaded the body will not

slow shuttle
#

the dbl-api on npm posts a server count 1 less than true

orchid crystal
#

Hey, i'm french user (this a cause for my english is bad)
How configure api for the vote in your site web ? 😕

orchid crystal
#

Salut, comme je peut configurer les webhook pour que les votes fait sur ma page soit signaler sur mon serveur Discord

slow shuttle
#

ahh you want upvotes on top.gg sent to a discord webhook

plucky lance
#

ahh you want upvotes on top.gg sent to a discord webhook

You can't send it to Discord webhooks but to your own webhook service to receive events like upvotes.

pliant oak
#

technically you could, you'd have to send the webhook to a web server and that web server sends it to a discord webhook

#

reformatting it

ruby kiln
#

for the dbl API (I am coding with python) does it works if we post guild count on_guild_join and in on_guild_remove events ? to avoid using the tasks.loop

green roost
#

Yeah that'll work.

#

But there is the possibility of rate limiting

#

Although I think the official lib handles that (not sure ask the developer or look in the source)

rain heart
#

i generally suggest not having the post stats on guild_join/remove

#

have it trigger every 30-60 minutes or so

green roost
#

But why? What if joins and removes are slower?

rain heart
#

still wouldn't recommend it

#

pretty sure the libraries don't handle ratelimits

green roost
#

Ah

hushed reef
#

can't speak for others, mine doesn't.

green roost
#

I wrote my own thing for this since my python version was having issues with the official one and I figured I'd handle rate limits myself.

hushed reef
#

rate limits are hard to enforce through a library unless you're constantly running everything in a continuous asynchronous loop

ruby kiln
hushed reef
#

I think the current api/v0 is synchronous based, I see no mention of async stuff besides the libraries that incorporate those methods.

ruby kiln
green roost
#

I don't know if I can recommend my own implementation because it's not official. I'd listen to mods advice.

green roost
ruby kiln
green roost
#

I don't get what you mean.

ruby kiln
#

we can use webhooks to auto post on guild join and on guild left to top.gg

green roost
#

You don't want to use a tasks.loop you're saying?

green roost
ruby kiln
#

I would like to post automatically on top.gg when I join a guild, for example with webhooks or in on_guild_join event

green roost
#

You would use aiohttp for this

#

May I ask why you don't want to use a loop?

bitter mantle
#

I can't get the bot webhook working in any way using dblapi.js for some reason
I did port forwarding firewall off everything

dbl.webhook.on("vote", async (vote) => { 
    console.log(vote.user)
  })```
the event doesn't run
ruby kiln
rain heart
bitter mantle
rain heart
#

you cannot use https

bitter mantle
#

even with http it doesnt work

rain heart
#

https is always port 443

#

http:// is the one you need to use

bitter mantle
#

I recently switched it after 2 hours of testing and googling to https only to see if it works

#

http doesn't work, tried it again rn

green roost
#

It uses oauth for that.

rain heart
#

test your webhook with postman

#

if it doesn't work, your code might be bad/wronly portforwarded if hosted on your home network

bitter mantle
rain heart
#

postman is the most reliable one

#

dont know any others

bitter mantle
#

I don't even know how to use it

frosty jacinth
#

Do I have to check for new upvotes myself or is there something that will tell me when there is a new upvote (using python)

rain heart
#

webhooks

short leaf
#

my discord bot has been added to the server i want it to message the server owner and a random room on the server

rain heart
hasty mica
#

Is there a tutorial a little more in depth? Im having trouble getting really anything done with the current instructions and documtations. For example: Everything says "set this to your dbl token" but, im not finding any way to get it not even with a google search.

jaunty plank
#

pins shows how to get your top.gg token

hasty mica
#

What about a tutorial, like on youtube? Do you know of one?

jaunty plank
#

not that im aware of. its just a basic rest api.

rain heart
#

@jagged escarp you made a get request, not post

jagged escarp
#

No I posted

rain heart
#

the response tells me that you made a get request

jagged escarp
#

Here's all the data I got

#

Thats all except the api key

#

Maybe this is what my issue is lol

#

My page is bugged or something

jaunty plank
#

non-capital a in authorization right?

jagged escarp
#

I'll check

jaunty plank
#

the docs say capital a, but ive only ever used lowercase 👀

jagged escarp
#

It was caps, but I did it with a lower case a and still got the 400

jaunty plank
#

dont think it matters then

rain heart
#

Authorization with a uppercase A should work too

jagged escarp
#

mhm

jaunty plank
jagged escarp
#

yea wasn't quite sure how to interpret that since it's just a count

jaunty plank
#

shards_count for the count

jagged escarp
#

Ah

jaunty plank
#

or shard_count

#

sorry

jagged escarp
#

Let me try that

#

Same exact error

rain heart
#

what the fuck is this api

jaunty plank
#

ill take a look at one of the libraries and see what they are using i guess 👀

jagged escarp
#

I use the C# one for whatever that's worth

rain heart
#

got it

jaunty plank
#

not using Content-Type: 'application/json'

rain heart
#

aight

#

set application/json yeah

jaunty plank
#

im just spitballing ideas at this point

rain heart
#

in your headers

#

setting the contenttype made it post through postman

jagged escarp
#

kk, one moment

#

sigh idk why postman does not let me edit these headers...

rain heart
#

what doesn't work

jagged escarp
#

Like the Content-Type header is there I just can't change it lol

#

It's being stubborn

jaunty plank
#

i hate the postman website, the app works really well for me

rain heart
#

click on "hidden", then uncheck Content-Type

jagged escarp
#

Ok, I had to uncheck it and then recreate it lmao

rain heart
#

yes that's correct

#

otherwise it just makes a request in text/plain

jagged escarp
#

Aaaand anotha 400

jaunty plank
rain heart
#

impossible

#

send your headers

jagged escarp
#

sec lemme blur the key

rain heart
#

just with your bot id

jagged escarp
#

Oh uhh

#

my body was form data lol

jaunty plank
#

oops

rain heart
#

same thing, but do raw as you have set your headers to application/json

#

screenshot your whole postman, censor your token

jagged escarp
#

Kk. One sec

#

Alright am I missing anything?

rain heart
#

like how are you getting raw html data when you're posting

jagged escarp
#

¯_(ツ)_/¯

rain heart
#

again screenshot your whole postman, with all the things you have set

jagged escarp
#

Will do

plucky lance
#

Try to post without shard_count

jagged escarp
#

Auth header is under the "hidden" section, everything under hidden is disabled except for the postman token

frosty tiger
rain heart
#

yeah dude's gone

#

-b 689464686026162363 selfbot-behaviour for the past few days

abstract mothBOT
#

dblMod Banned <A/M> | Narox#5808 (@frosty tiger)

jagged escarp
#

👋

restive otter
#

what the hell happened here

jaunty plank
#

nothing intresting

rain heart
#

this dude kept doing selfbot shit

jagged escarp
#

@plucky lance ill try that

#

same thing

rain heart
#

remove the token from the Authorization and only add it into your Headers

jagged escarp
#

kk

jaunty plank
#

oh yeah it needs to be set to API Key or just used as a header

jagged escarp
#

400 again

rain heart
#

How

jagged escarp
#

It's only me lol

#

My bot page got bugged

rain heart
#

ngl I'm about to just say DM me the token KEKW but actually don't

jagged escarp
#

haha

rain heart
#

lemme get your bot id one sec

jagged escarp
#

np

rain heart
#

Can you remove your token from the request

#

and send a post

jagged escarp
#

Sure

#

I think I got the exact same error

rain heart
#

then your setup is wrong

#

it should respond with

{
    "error": "Forbidden"
}
restive otter
#

can you give me, the api to check the user is voted or not? I forget that one

jagged escarp
#

Right I assumed so

jagged escarp
restive otter
#

ok thank you

rain heart
#

@jagged escarp you also don't have any errors through the libraries?

jagged escarp
#

Correct I only handle exceptions, everything seems to run smoothly

#

I'd definitely get an exception for an invalid api key or something

rain heart
#

try this one

jagged escarp
#

Cool this looks easy lol

rain heart
jagged escarp
#

do they need to be in quotes or na

rain heart
#

nah

#

then under content, paste in the json data

#

the url with the api url ofc

restive otter
#

whats the 9876?

/bots/9876/check?userId=1234
#

thats client id?

rain heart
#

bot id

#

1234 is the user id

jagged escarp
#

Ok that time I got a 200 OK code

restive otter
#

ok thank you

rain heart
#

check your bot page now

#

and see if it did anything

jagged escarp
#

Yippee

#

it worked

rain heart
#

then something in your code is shitty KEKW

jagged escarp
#

holy fucking shit

#

Dude I swearrrrr

#

I'll have to check on it... if it goes away in 15m something's wrong with the lib haha

#

Thank you for your help ♥️

rain heart
#

otherwise just make manual requests from time to time if you don't wanna mess with posting stats through your code

plucky lance
#

Just use a different lib, like node-fetch for example

jagged escarp
#

I appreciate it, thank you

#

C# tho?

rain heart
#

oh yeah you could just use request libraries instead

plucky lance
#

Oh nvm js

jagged escarp
#

I actually thought about rewriting the lib in C# cuz it is lowkey neglected Sadge

#

Still called Discordbotlistapi smh

rain heart
#

so is the java library

jagged escarp
#

well, guess I can close the git issue lol

rain heart
#

yeah already went through your code, can't really find anything

jagged escarp
hasty mica
#

hey can someone help me with the python api? im having a lot of issues

rain heart
hasty mica
#

that dosnt help, why i came here

dapper copper
#

@rain heart they meant the lib

#

@hasty mica What database you using

hasty mica
#

wdym database

dapper copper
#

I mean there are 2 ways of handling votes

#

One only works reliably with up to 1000 votes

hasty mica
#

i was in the middle of testing get_bot_votes()

#

suddenly it stoped working

restive otter
#

where i can found my top.gg token bot?

rain heart
#

read pins

restive otter
#

ok

hasty mica
#

like i dont even know what im supposed to have as the self argument

#

and the docs dont even have self as a required argument, and it dosnt tell me what i should put in there anyways

jagged escarp
#

@rain heart fun fact. my code is the problem. that or the C# lib, it just re-updated in code and it made all the values disappear again

rain heart
#

it reset your count again?

jagged escarp
#

yuuuuuuuuup

rain heart
#

welp

jagged escarp
#

Guess its time to lose my lib virginity

hasty mica
#

now i cant even get help here, might as well give up.

jagged escarp
#

Ugh, cloned a forked version of C# lib only to find it's horribly incomplete lol

restive otter
#

Hello

green roost
sullen nymph
#

Read more about Python OOP

hasty mica
green roost
sullen nymph
#

P.S. there's a reason it's not typehinted 😛

hasty mica
#

i dont understand why this complicated stuff is needed when all you are requesting are a bots votes or who voted, also why arent there any tutorials, im a more visual learner

sullen nymph
#

I mean is it that hard of a concept

#

Instantiate DBLClient, use the method get_bot_upvotes of the instance

sullen nymph
#

Doesn't work, as in?

green roost
#

OOP is a fundamental python concept you should ideally have under the belt before you even start off with a project as complicated as a discord bot. Its not that hard to do.
If you want visual aid, there are probably video tutorials explaining classes. And instances.

hasty mica
sullen nymph
#

Show your code

hasty mica
#

well its gone rn, hold on

sullen nymph
#

The reason why there's no tutorials for this library is because you are expected to have experience with OOP in Python beforehand

#

Ideally, the documentation is sufficient

hasty mica
# sullen nymph Show your code
@Client.command(aliases = ['upvote'])
async def vote(ctx, mode = mode):
    client1 = db.Client()
    botlist.DBLClient(client1, "<myToken>")
    userlist = await botlist.DBLClient.get_bot_upvotes(self = client1)
    print(userlist)
    vote = await botlist.DBLClient.get_user_vote(self = self, user_id = ctx.author.id)
    if not vote:
        voted = False
        await ctx.send("You have not Voted! ", voted)
    else:
        voted = True
        await ctx.send("You have Voted!", voted)
#Other, embed

sullen nymph
#

Yeah no chief

#

That's more wrong than my code back when I started using d.py, I swear

hasty mica
#

believe it or not, thats what i got from reading the docs

sullen nymph
#

You instantiate DBLClient and save the returned object in a variable, preferably one that persists between multiple methods

#

aka

hasty mica
#

best i could

sullen nymph
#

x = DBLClient(...) and then use x later in your code

hasty mica
#

yes

sullen nymph
#

Well that's not how docs describe it

#

... though they don't describe this part at all

green roost
#

Hey shivaco while I have you, is the 3.9 compatibility issue fixed?

sullen nymph
#

It is, in v1.0.0

#

Just need to polish the docs about the new webhook system and I believe we'll be good to go

green roost
#

Also does the library wait out rate limits before retrying, or is that left to the user to implement?

sullen nymph
#

I'll have to migrate some stuff too so expect a few "breaking" changes 😛

#

I implemented (more like fixed, actually) a ratelimiter that will only allow 59 requests within 60 seconds

hasty mica
sullen nymph
#

That's the most reasonable and uncomplicated way I thought of to go about this until APIv1, which will very possibly support ratelimits officially

green roost
#

Okay I'll consider switching back to this lib now

sullen nymph
green roost
#

Also any plans to expose the internal Webserver?

sullen nymph
#

aka

Client = commands.Bot(...)
Client.dblpy = dbl.DBLClient(...)

@Client.command()
async def mycmd(ctx):
    votes = await Client.dblpy.get_bot_upvotes() # votes is a list now
#

Hmm. Not sure tbh. Is there any purpose in exposing it?

hasty mica
sullen nymph
#

I thought you'd know since you already have your Client object done already?

green roost
#

To repurpose it for other endpoints since it's already instantiated and ready.

hasty mica
#

Command prefix?
What i have:

Client = commands.Bot(command_prefix = commands.when_mentioned_or('CB '))
``` Not sure abt the second line tho
sullen nymph
#

Hm. I see where you're getting at, but I'm contemplating the reasoning for making it an accessible middleware

sullen nymph
green roost
#

How about an optional webserver kwarg?

sullen nymph
#

no, the other way around

green roost
#

For example bots with dashboards in place that want to use the library

#

Say I'm more comfortable with quart than aiohttp web

sullen nymph
#

Technically they could be handling all that stuff manually, but

#

sounds like an interesting feature

green roost
#

It would be unofficial and hence unsupported here correct?

#

So you can't leave it for manual implementation cause it might have some side effects
I could be missing something but at first glance this shouldn't be hard to patch

hasty mica
sullen nymph
#

x = botlist.DBLClient(...)
x.yada_yada()

hasty mica
#

ok

#

ill try that then

sullen nymph
#

It's just that the system I already have in place in v1.0 is tricky and was done in a "if it works, it works" way

#

Mind submitting this idea on the GitHub repo?

green roost
#

As an issue? Or would you like me to PR it?

#

I can get around to it over the weekend

sullen nymph
#

Whichever you feel like doing 😛

#

Up to you really

green roost
#

Sure thing. Thanks 👍

sullen nymph
hasty mica
#

@sullen nymph mb, something else broke ofc. "AttributeError: type object 'Client' has no attribute 'loop'"

sullen nymph
#

Show your code

hasty mica
#
client1 = botlist.DBLClient(db.Client, "<my-token>", db.Client)
    userlist = await botlist.DBLClient.get_bot_upvotes(self = client1)
    print(userlist)
    vote = await botlist.DBLClient.get_user_vote(self = self, user_id = ctx.author.id)
    if not vote:
        voted = False
        await ctx.send("You have not Voted! ", voted)
    else:
        voted = True
        await ctx.send("You have Voted!", voted)
hasty mica
scarlet cobalt
#

One message removed from a suspended account.

sullen nymph
#

Don't do anything with self

#

use client1

#

instead of botlist.DBLClient everywhere

hasty mica
#

@sullen nymph object Client dosnt have attribute 'loop'

#

MyProblems = int(♾️)

#

welp ig thats it.. gn

sullen nymph
#

Wtf is db.Client

hasty mica
green roost
#

Okay that explains it. This is another class vs instance issue

#

You should already have a Client/Bot

hasty mica
green roost
#

Again I suggest understanding OOP

hasty mica
#

ok

vale rain
#

Hi, I just published a bot on top.gg and wanted to create a webhook for the votes.
I don't really know how they work: does anyone know what URL am i supposed to use?
Thanks

green roost
#

http://{your_public_ip}:{your_port}/{your_webhook_path}

serene rivet
#

Hallo

sacred shell
#

cringe

wanton kettle
#

haha

short leaf
#

Overview of my bot on top.gg
how do i add the place

merry tendon
#

i got this error:

#

nothing fixed what i have tried

rain heart
#

You got ratelimited

#

You made too many requests

merry tendon
#

how to fix it

#

and i made nothing

#

lol

rain heart
#

Wait an hour, if it doesn't do anything, full 24 hours

merry tendon
#

oke

#

lucky me bcuz when i applied it was broken

#

so i can resubmit and it get fixed 😂

rain heart
#

Also, accessing the api isn't possible without being approved anyways

hearty kiln
#

how to send webhook to a discord channel when someone upvote my bot?

jaunty plank
#

you will have to receive the webhook then send a message via a bot, or create another webhook and forward it.

#

top.gg webhooks are not directly compatible with discord webhooks

hearty kiln
#

ok and how to do that?

jaunty plank
bronze axle
#

Hey, why do I get an error talking about "WARNING: An Illegal reflective access operation has occurred"

#

using the Java version

night matrix
#

With the webhook API, does top.gg send the 'next vote' time across at all? (i.e. when the user can vote next) or shall I just do 'now + 12h'
(note - for both server and bot)

rain heart
#

the webhooks don't send anything about when the next vote is

night matrix
#

Thanks - I figured as much, will just do now+12h then

jagged escarp
#

still wondering why the C# lib is acting up or if I am doing something wrong

twilit topaz
#

where can i find my bot dbl token

#

@rain heart

rain heart
#

read pinned messages

twilit topaz
#

ok

rain heart
#

no need to ping

twilit topaz
#

ok thanks

tender veldt
#

Hey, the site shows a wrong number in servers count

#

And this bot on 88 guilds

jaunty plank
#

are you posting your server count still?

tender veldt
#

no

jaunty plank
#

so its on what you last posted

#

it only updates when you update it

#

using the api, or whatever library you where using.

tender veldt
#

Okay thanks .

tender veldt
jaunty plank
#

yeah

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

const poster = AutoPoster('topggtoken', client) // your djs client/shardingmanager or eris client
tender veldt
#

ok thanks

restive otter
#

when i regenerated my webhooks token then what that error is came Unauthorized (You need a token for this endpoint)

#

@rain heart

#

When I regenrated it then i got that error

#

replace your old token with new token

#

I replaced

#

but then after it still not working

restive otter
#

see the error

#

Ewww pirated windows

bold perch
#

Rip

restive otter
#

lol

#

what to do

wheat cipher
#

Hey I have a question while using /bots/:bot_id/check does it check for if a user voted after 12 hours or if a user just voted once ever like a week ago

sullen nymph
#

in the past 12 hours

wheat cipher
#

Aah copy that

#

Thank you

cinder lichen
#

Hello, can someone help me with vote-logs for my bot, I tried by best with the webhook but nothing worked!

jaunty steppe
#

What happens when you try to use the /votes endpoint with >1000 votes/mo? Does it 40[1|3] you? Or just return the first 1000 votes?

frozen lark
#

djs

#

hehehehe

jaunty steppe
sullen nymph
jaunty steppe
#

Have you forwarded your port?

#

and put the right IP/domain in

cinder lichen
#

does the bot test webhook button work?

jagged escarp
#

Yea

cinder lichen
#

I don't get anything in console

#

@jagged escarp can you help me with the vote-webhook?

jaunty steppe
#

did you forward your port

meager bridge
#

Ah cheers guys. That was super simple to setup

jagged escarp
cinder lichen
#

ok

jagged escarp
#

Give rewards to user ID at that point

jaunty steppe
#

I don't know your setup

#

so

sullen crystal
#

Can I use the api token of my bot in another bot to test code before uploading it to the original bot?

rain heart
#

As long as you don't accidentally post the wrong count

outer wharf
#

Wow

#

Hey

#

Bye

willow spindle
#

🤔

vernal trench
#

why i cant install?

green roost
#

Because that's... Not where you install from

#

I am surprised you developed a bot without knowing how to install packages tbh

restive otter
vernal trench
#

Yes

#

I’ve installed pillow with pip and asyncio

restive otter
#

Try this: -m pip install dblpy

#

@vernal trench

green roost
#

Mate you're not even in your terminal.

restive otter
#

wait...

#

he is in the weird website

#

lel

green roost
#

Lovely.

#

Anyway you should know how to install packages. This is not in scope of this channel.

vernal trench
restive otter
#

open up command prompt

vernal trench
#

Windows

midnight parcel
#

So I tried the dblpy thing to get vote webhooks, but it doesn't seem to respond. I took this from the Github README, is there some glaring error here?
Thanks!

#

(btw, dbl_token and TOKEN are not placeholders)

green roost
#

If they're not placeholders then change them lol

restive otter
pine heart
#

lol

restive otter
#

Hello

restive otter
#

Ty

pine heart
#

lol

#

(it's backwards)

restive otter
#

Im spanish

#

Dk

#

But dont use lol

#

Pls

#

Ty <3

woven ravine
#

hey whenever i save my webhook i get an error pop up saying There was a problem saving the webhook :Thonk: Any solution?

jaunty plank
#

for a bot?

#

You cant add a webhook to a bot which isnt approved.

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

const app = express()

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

 app.post('/dblwebhook', webhook.middleware(), (req, res) => { 

 console.log(req.vote.user)
}) app.listen(3000)```

Where should i add the voting rewards here^^^?
jaunty plank
#

where console.log(req.vote.user) is is the location you can give rewards

restive otter
#

I have to do db.add?

jaunty plank
#

if thats what your db uses yeah

restive otter
#

Oh ok

#

Can i replace console.log(req.vote.user) to

client.channels.cache.get(channel id).send(req.vote.user)?

jaunty plank
#

sure, or put it above it.

restive otter
#

Ohk

#

Because i want to get my voting notifs to my server channel

daring palm
#

Btw i got channel with [Read Message History] = false, my bot/me cannot add reaction to new message even i set [Add Reactions] = true, it still error "Missing Access"

#

Is this bug?

jaunty plank
#

no. pretty sure bots without read message history cannot add reactions.

daring palm
#

Not just bot, me too cant add reactions

jaunty plank
#

yeah

#

thats how it works

daring palm
#

I see

jaunty plank
#

you lose access to the message, its only cached and thats it

#

nothing you can do with it

daring palm
#

I was thought it only lose cache for past message

jaunty plank
#

its kept in cache, but discord doesnt know whats cached

#

so its instantly a past message

#

only thing you can do is delete it

daring palm
#

So for bot invitation i should add role for Read Message History right? Not just Add Reactions

jaunty plank
#

yeah. it will be given it anyway unless the staff of the server specifically removes it

daring palm
#

Thanks for the info

vast bolt
#

Any idea how are votes rate limited?

#

I'm getting hella ton of memory leak because of the vote backlogs

jaunty plank
#

if your ratelimited, you should stop sending requests

vast bolt
#

i'm not sending the requests

#

my users are the one sending the requests

#

I only have a vote command that checks if someone has voted or not

#

I don't believe I'm misusing the API until the point where it gets rate limited

#

it's been happening only recently over the last couple days

jaunty plank
#

ideally youd have a built in method for preventing requests being sent at all until the ratelimit ends(which is sent with each request)

sullen nymph
#

I'd ask what the fuck but even that doesn't describe my confusion

#

How are you getting users' votes?

jaunty plank
#

after a certain point you should also be saving users vote status's in a database and using webhooks to receive when they vote.

vast bolt
#

I'm only checking if they're not in the database (basically when its expired)

jaunty plank
#

are you using the webhook?

vast bolt
#

I'm using this

 check = bool((await self.HTTPClient.get_user_vote(self.bot.user.id, ctx.author.id))['voted'])
jaunty plank
#

so, the ratelimit is 60 requests a minute for that

vast bolt
#

To be fair, it was never an issue until very recently like since last week, hence my confusion

jaunty plank
#

did your active member count go up?

sullen nymph
#

Do you have anything that prevents users from using the command multiple times at once?

vast bolt
#

its been increasing steadily yes

sullen nymph
#

You can try logging the command usage and see how many times it's used per minute

vast bolt
#

Yeah I kinda figured that's the issue, but my question is how does the bigger bot handle this? Mine's in over 10k for perspective and it starts acting up

sullen nymph
#

They use webhooks and store them locally

vast bolt
#

I've been storing locally as mentioned above, so guess webhook is the one I'm missing then

sullen nymph
#

How do you even store the votes without webhooks

#

HTTPClient/DBLClient.get_user_vote is an API request at all times

jaunty plank
#

guessing its requesting every time unless they are in the database

sullen nymph
#

How does one use a database with /bots/id/check is my question

rain heart
rain heart
#

-api

abstract mothBOT
#

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

rain heart
untold cliff
#

I need help with api because I never use
It before

rain heart
#

read the docs

untold cliff
#

‘’’const client = new Discord.Client() // Your discord.js or eris client (or djs ShardingManager)
const AutoPoster = require('topgg-autoposter')

const ap = AutoPoster('Your Top.gg Token', client)’’’

ap.on('posted', () => {
console.log('Posted stats to Top.gg!')
})

#

Is that all I need

rain heart
#

technically yes

vestal field
#

const webhook = new Topgg.Webhook("I put my auth here");

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

app.listen(80);```
#

this is giving an error

#

I just used the code in the Docs

vocal robin
vocal robin
vestal field
austere swallow
#

where are you running this bot?

rain heart
#

Use a different port

vestal field
vocal robin
austere swallow
#

ah

vocal robin
#
const Topgg = require("@top-gg/sdk");

const webhook = new Topgg.Webhook("I put my auth here");

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

app.listen(3000);
vestal field
#

hm

#

ok

austere swallow
#

try another port then

#

yeah like 3000

vocal robin
vestal field
#

it worked now

vocal robin
vestal field
#

can anyone vote for my bot to see if the Webhook is working?

austere swallow
#

you can use the "Test" button on the webhook page

vestal field
#

oh

#

ok

#

ty

vocal robin
#

Was this Advertising o.o BantmuoXD

vestal field
#

cause it didn't sent nothing

austere swallow
#

uhh should be almost instant?

vestal field
#

oof

#

it didn't send anything

austere swallow
#

make sure you added the port in the webhook url too

frail epoch
#

how do you get the token to post stats

vestal field
#

oh

austere swallow
#

http://<address or ip here>:3000/dblwebhook

vocal robin
austere swallow
austere swallow
vestal field
#

I didn't find any 80 on the link

restive otter
vocal robin
vestal field
vocal robin
austere swallow
#

yea make sure your webhook url is correct

vestal field
#

bruh I don't understand. Is my repl link my webhook link??

restive otter
#

y e s

vestal field
#

hm

#

and what to put in /dblwebhook ?

#

or leave this way?

#

@restive otter

restive otter
#

wdym put there

vestal field
restive otter
#

leave it there

vestal field
restive otter
#

also be sure that webhook auth is not wrong

vestal field
restive otter
#

ok then save it

vestal field
#

I did

#

they told that this change can take up to 48 hours

restive otter
#

w h a t

vestal field
restive otter
#

bruh

vestal field
#

;-;

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

const webhook = new Topgg.Webhook("Topgg authorization key");

app.post("/dblwebhook", webhook.middleware(), (req, res) => {
  db.add(`balance.${message.author.id}.money`, amount)
  console.log(req.vote.user);
});

app.listen(3000);```

Is this correct?
restive otter
#

its req.vote.user

restive otter
#

that means js db.add(`balance.${req.vote.user}.money`, amount)

#

yes

restive otter
rain heart
#

you need to get the user through your discord library

#

use the ID in the req.vote.user for that

restive otter
#

you mean req.vote.user.tag?

rain heart
#

no, user returns a ID

restive otter
#

oh ok

restive otter
rain heart
#

don't know js, can't tell you if that works

restive otter
#

Hmm Ok

carmine prawn
#

dbl has golang api wrapper?

vocal robin
#

${} just works in a string

restive otter
vocal robin
restive otter
restive otter
#

@rain heart Can you tell me where can i find my webhook auth key?

stoic flame
#

@restive otter i so t think s9 1 is beeded for discord

stoic flame
#

autocorrect

#

s91 = so

#

beeded = needed

#

idk why it works in reverse

restive otter
#

Hello anyone tell me where can I find my webhook auth key?

umbral garden
#

how can I make it to show how many server its in?

restive otter
restive otter
umbral garden
restive otter
umbral garden
restive otter
gloomy fractal
#

I think there’s a section on the sidebar for it

restive otter
gloomy fractal
#

What

restive otter
#

webhook

gloomy fractal
#

This

#

Ah I pinged berry sorry berry

hearty lintel
#

weary

restive otter
gloomy fractal
#

I really don’t know, I don’t use the API

hearty lintel
#

you set it yourself

gloomy fractal
#

In the future, please just drop your question here and don’t ping moderators

restive otter
#

My own?

#

Ok boss sorry

gloomy fractal
#

More than likely community members like frog man berry can you help more than I can

hearty lintel
#

you can set that field to whatever you want and you can use the request headers to verify it's from top.gg

restive otter
#

so i can keep only one letter also?

hearty lintel
#

i mean u can make it nothing if you wanted but i would recommend using an actual password

restive otter
#

Ohok

hearty lintel
#

if anyone found your endpoint they could abuse it without a password

restive otter
#

ohok

restive otter
hearty lintel
#

you dont put in your api key

restive otter
hearty lintel
#

you put in the authorization header that u put in that field

restive otter
#

i dont wanna leak

hearty lintel
#

ik

#

but u said its the api token

hearty lintel
restive otter
#

sorry not token

#

Auth key

#

or password