#topgg-api
1 messages Β· Page 139 of 1
all the ports are open properly and whatnot?
does it console.log?
if u go to the link in your browser what does it say
which link?
the webhook link
The webhook link is my vote logs webhook link
I mean i created a channel named vote logs in that channel i created a webhook
u cant use discord webooks in the url field
then?
what're u hosting with?
Editing with glitch and hosting with google script
How can I make a command saying
n!leaderboard
(Display how many votes each user has)
Can the top.gg api do that?
Ping me if you know c:
Thanks!
You could use webhooks for that and store vote counts in a database of yours
@barren kestrel
what's api usage iirc?
?@winter jasper
What's the context
I have no clue what you're asking
API usage is API usage
Iirc stands for if I remember correctly
ok ty
How would I setup the webhook?
Create a Webserver and set up the webhook endpoint
Your library docs will have instructions
discord member intents are no longer working for me?
-api
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://docs.top.gg
Sorry!
object 'Client' has no attribute 'loop'
upvotes = dbl.DBLClient(db.Client, token).get_bot_upvotes()
Nmmnnnmknnnn
?
Force-exit while some task was running
how am i supposed to get vote data then
oh God what are you doing
Create one object, ONE ONLY
Save it in a VARIABLE
And then just use its methods
but its being awaited
Yeah where
votes = >>>await<<< dbl.DBLClient(db.Client(), token).get_bot_upvotes()
Oh well whatever
Does it work
i just called it from my commands
i have print(votes) after it
nothing is happening
yeah nothing is happening
not even errors
@Client.command(aliases = ['upvote'])
async def vote(ctx, mode = mode):
token = "token"
upvotes = await dbl.DBLClient(db.Client(), token).get_bot_upvotes()
print(str(upvotes))
embed = db.Embed(title = "Vote for Case Bot", color = db.Color.gold())
embed.add_field(name = "Top.gg Bot List:", value = "[Vote Here!](https://top.gg/bot/767633990701678602/vote)", inline = False)
embed.add_field(name = "Vote Rewards:", value = " - 100k Credits \n - Credit Multiplier (need to activate)\n - 20k Tokens")
embed.set_thumbnail(url = thumbnail)
embed.set_footer(text = "Thank You For Voting :)")
await ctx.send("<@" + str(ctx.author.id) + "> - You wont recive items yet, that feature is being added.\nSill feel free to Vote CB tho :)\n", embed = embed)
Disaster of random object creation
naming convention π©
yes ty
Use your Client instead of db.Client
lol
Create only one object and use it
Stop with this fucking mess before it bites you AGAIN
how would i call this
found the bot area
Call what
shiv meant you're supposed to pass Client instead of instantiating a new object.
Client instead of discord client
Client is a discord.Client instance 
it's kinda confusing, so kindly rename it to client or something
ok so put in a variable
Yes please
ok
I was saying yes to norizon
low sounds like he's a pro
But yeah put your DBLClient in a variable that's shared between other functions
Yes because VSC is just a text editor
And code is text
You could even use notepad
mmm
ah got it
low has been on vsc for 9h
Is there an easy way to get the number of upvotes
without dbl
like with just an api GET request
Sure, docs are at docs.top.gg
https://docs.top.gg/api/bot/#last-1000-votes or just /bots/:bot_id actually since you only want the sum
im trying to give users rewards for voting tho
Thank you norizon for being cool
dang wifi went out ofc
the latest and greatest
idk i think so yea
could i convert this to a dictionary?
What? I was telling the other guy, just use that get_bot_upvotes method
Send the code
client = db.Client()
upvotes = await dbl.DBLClient(client, token).get_user_vote(ctx.author.id)
print(str(upvotes))
I think you've been told not to instantiate a new object. You already got it, just pass it...
why isnt it printing tho
Because it's waiting for the client to be ready, which is never gonna happen
No, it's a list of dict
You can do {int(data['id']) for data in upvotes} so that it'll be a set of user ids
Sure, you can do the generic for loop
Yes
π
its telling me upvotes is a boolean
nvm mb
still nothing is happening
@restive otter why wont anything happen bruh
so how am i supposed to save the DBLClient
in a variable in on_ready?
@restive otter
@restive otter bro thats not gonna happen i have seen a guy make his first bot and he has succeeded ....
now his bot is 250+ servers
listen here I'm new to coding and don't understand sh1t
You will learn easily brother
dont be hard ya self
dude it's like learning spanish
na
yes
na
π€£
is getting the bot from api in every 15 sec is ok?
I would not recommend it, but it is possible
depends on what endpoint you make a request to
/bot/:id
read this
this api
again i still wouldn't recommend it, but it is possible
ohk
plz post the status of the bot tooo. like online , offline idle etc
use pastebin and wait for someone that can help you
hatebin?
whatever you prefer to post the error code in
use pastebin and wait for someone that can help you
P.S. it's strongly advised to use the top-gg/sdk package instead of dblapi.js
And the 504 error is a server-side issue, aka you just need to try again later
i already telled him in another server 
ππͺ
nee bit of help here
const client = new Discord.Client() // Your discord.js or eris client (or djs
do i need change anything here as i am using discord,js
let me know if i need to change anything
what do i put in to replace this
just get rid of that
in the const ap = ('', client) do put my token inside
done that
but where do i put the token from the togg
i have to put my token
do u where i can find my token
-pins
also mentioned on the docs
And almost anywhere else
done what happen next done what tell me to do
it still say N/A on the top.gg
i got error message
post it here
opGGAPIError [Top.GG API Error]: 401 Unauthorized (You need a token for this endpoint)
at Api._request (C:\Users\jakem\Desktop\EvalZero-main\node_modules@top-gg\sdk\dist\structs\Api.js:76:19)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
at async Api.postStats (C:\Users\jakem\Desktop\EvalZero-main\node_modules@top-gg\sdk\dist\structs\Api.js:96:9) {
response: { error: 'Unauthorized' }
}
you need to add your token to the constructor
don't know where
i am so dumb can't see it
This is the part where i recommend reading the docs
this tbh
Where all of your basic questions get answered
It's almost a waste of time reciprocating something already said.
await self.bot.dblpy.get_user_vote(ctx.author.id)
All the times I voted, sometimes it returns False, sometimes True. What is going on here?
The API can be delayed in that sense. It can take a while for the endpoint's value to update after a vote
And since it returns status of an individual vote, yeah
I mean it doesnt take too long for me.. But does take atleast 10-15 seconds after voting and checking
Yeah, there's no definite delay. I remember it being delayed for like up to 10-30 minutes after voting
Hey How to get our webhook link?
http://ip:port/path
Should i search with that on google?
"Search"?
ip is your machine's IPv4 address
port is the port your webhook runs on
path is the route used specifically for your vote handler
How are you hosting your webhook in the first place?
wdym
Ik discord webhooks lol
Why do you need it in this case?
For giving voting rewards to the users
Discord webhooks for rewarding users
Connect the two and tell me how that's possible in the first place
const Topgg = require("@top-gg/sdk")
const express = require("express")
const app = express()
const webhook = new Topgg.Webhook("my api key");
app.post("/dblwebhook", webhook.middleware(), (req, res) => {
db.add(`balance.req.vote.user.money`, 5000)
console.log(req.vote.user);
});```
This is my code ^^^
Ok
what code is this?
Why i have to give this one again?
const { webhook } = require("@top-gg/sdk")```
It's a middleware that checks request authorization and passes the vote data to your function, I guess
I already gave the code like this
const Topgg = require("@top-gg/sdk")```
for servercount
Ohk
This is unnecessary since you have const Topgg instead
Ohok
So you just do Topgg.Webhook to access the webhook
Ohok
That is our auth key right?
am i the only one here who uses node.js here-?
No
This seems impossible, as top.ggβs whole model is getting people to vote and making them watch ads.
okay, sad... thanks
Allowing to vote via Discord commands is impossible due to authentication
The ads have nothing to do with this
This wouldn't be possible cause easy to fudge. An official hot with a command like this would be possible but that's an entire other discussion
The most viable option to keep it running well is via captcha on a webpage
aka what it is
Except for the ad wall. But I suppose that's by design
Shrug. The ads don't bother me personally
Though, yeah, that's a different story, kind of
a
When. Will. Webhooks. Be. Fixed.
They're working?
I absolutely love the webhooks. Just figured out how to use them and they work perfectly.
(The test feature is very nice)
I just figured it out to with my vps so nice indeed
Hmm
So it works with the test feature but when someone votes nothing happens
Question if you vote on same ip adress with different account does it only register one. I tried testing real time and only 1 of the 3 came trough
I'm pretty sure you're not supposed to be able to vote twice on the same IP, but I might be wrong
voting on multiple accounts is against our rules
I beg your pardon then, I wanted to test the thing out with different accounts. Wont do it again then. Will use postman to recreate the request.
oh dont worry about it, i understand you just where testing π
we do have a test button next to the webhook if you want to test it
ah, i understand. yeah postman is your best bet
π
I cannot see my bot's approval process as%, what should I do?
can anyone help me with this?
how can I show the amount of servers it in
please ping me if you know
By using the DSL API to post your server count https://docs.top.gg/
Thanks! But is there a youtube video on how to do this..? I'm sorry its very confusing.
I finally added emojis to my bot so when I type +about it says some stuff and when I do +sheesh it does π₯ π π₯
lol
A simple API wrapper for top.gg written in Python. Contribute to top-gg/python-sdk development by creating an account on GitHub.
i found this-
do I put this in my bot?
how do I use this?
yes?
?
do you code boys
discord bots
yep!
yep
do you understand error messages
-api
This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.
If you need help with development about your bot or development in general, feel free to use #development.
sorry
It would be good to include in the endpoint (to see the last 1000 votes), the date a user voted
well ... I was referring to the endpoint. but thanks for informing me
-api
AttributeError: 'Client' object has no attribute 'add_cog'
im trying to post my server count
but im getting this err
Python
This is a dpy error not a python-sdk one
You need to use a commands.Bot instance
Actually I think this point should be made clear in the docs (although it should be obvious)
At least for the cog example it should be mentioned that you need a commands.Bot instead of discord.Client
Cause client can't use cogs
i just deleted the add_cog
its working.....
ya cause Client can't access the commands extension
What do you think about making the code examples more "cog-less"?
Should he fine actually. None of this relies on the commands extension
I voted to my server, after setting vote tracker then it shows 0 votes to my server but in website 6 votes
A note can be added on how one can also use Bot.listen() instead of Client.event to listen for the webhook events.
Hm. Is .listen necessary here? I could just rely on the event deco 
I suppose not, but it allows for multiple handlers.
event decorator overrides because you can't change the function name.
Is it necessary to have multiple handlers for that
Yeah, I usually prefer to encourage the event deco just because there's usually no need for multiple handlers
... especially with the Python SDK π
It's more like a d.py example then if it uses listen one
shiv, have you considered returning self on WebhookManager methods? 
Bro I literally already have that implemented, just not pushed to the repo yet
Oh great
Cool idea
Now I can chain it 

Hello,
I'm using Top.GG .NET Api.
I have two clusters, one updating shards from 0 to 1 and the other updating shards from 2 to 3. However, it seems only the latter is working. I am getting no errors. The Top.GG page only has 2 shards and the guild count of the shards 2 and 3.
This is how I update the stats:
await me.UpdateStatsAsync(FirstShard, TotalShardsInBot, guildCounts.ToArray());
First cluster:
FirstShard = 0
TotalShardsInBot = 4
guildCounts -> a list containing two numbers
Second cluster:
FirstShard = 2
TotalShardsInBot = 4
guildCounts -> a list containing two numbers
Can anyone help me? What am I doing wrong?
Thanks
I do have listeners for votes in multiple cogs actually.
Also a database bulk insert that depends on it.
So it could be a valid use case.
I see, but if it was cog-less, would you need multiple handlers in the main file?
How many bots made with dpy that are listed here do not make use of the commands extension?
Its really hard to not want cogs when you have a large bot
I see the point about making examples cog less though
I'm just asking for a note on how it would work with the command extension, since the SDK would work perfectly with just a discord.Client instance.
Since the example with cogs also specifies that the dbl.Client constructor takes a discord.Client, but discord.Client doesn't have access to commands.Cog
I hope I'm making sense here
I was genuinely asking about listen use case with the SDK out of curiosity
webhook testing broken?
I didnt change anything from my code from yesterday but now when I presh the test button nothing happens.
I was thinking I did something wrong
though only on servers, not bots
It works 2 out of 15 for me
I saw server only too but bots Idk
does it not work with your bot?
I've tested on mine and it works
Hmm
You should try using a webhook tester online to see if it would work with it
If it does then there's something wrong with your code
It worked yesterday havent touched it since then π I will just look into it maybe its the vps acting up
webhook_path='/dblwebhook' what is supposed to be in this? the complete webhook url?
The route that comes after the IP and port in URL
ok sorry i tough it was discord api that sends the kicked trigger to my bot
i am so sorry i tough i was on the discord.js server
I'm trying to get the webhook post using php, I used another program and it works, but when I tested it using the test button, it didn't
I tried to get the value "user" in post
have you saved the webhook before testing?
have you tested your webhook using postman?
yea
I will use the postman now
1 sec
Using it didn't work for me
did you just test example.com?
no haha, it was just not to show my url
Good i was about to lose my mind lmao

again what exactly are you trying to do?
I am wanting to get the user id that voted and send for some things on my php site.
(I'm using the translator to chat, sorry for any mistake)

the base url is https://top.gg/api
read https://docs.top.gg
as you're trying to make a request to our api it looks like
ye
https://sourceb.in/mZbKOaScwV
Should this still work?
its been awhile since i last touched it so
Well, my intention was to use the webhook post
Isnt dbl a old npm package that is now deprecated, since the coming of webhook in the top.gg package
so since we use webhooks i only need to export the code then?
so put the code in another file then define to run the express file in the index.js?
I just have it in the index.js
The req.vote return the following object: {
"bot": "",
"user": "",
"type": "upvote",
"query": {},
"isWeekend": false
}
test requests from top.gg needs a url the they can acces
If you use localhost they cant
well how would i go about this without spending any money?
since i cannot find a job with covid
I would not know. I use a vps for 4 euro`s. But I think this is going off topic.
I would guess you can try opening one of your ports then use your IPv4
Kinda sus
high sus. also off topic for here
Hello, I need some clarification about the stats.
What should I do if I have two servers, each of which containing more shards?
For example, if I have Server 0 with shards from 0 to 4, and Server 1 with shards from 5 to 9:
From Server 0 I post:
shards should be an array of 5 numbers with the count per guild.
shard_id = 0
shard_count = 10
From Server 1 I post:
shards should be an array of 5 numbers with the count per guild.
shard_id = 5
shard_count = 10
With this setup only the latest server posting works (so I only have 5 shards instead of 10).
Any help? Thanks
(This method is from here: https://github.com/AbnerSquared/DiscordBotList.Net#updating-stats but it's not working)
A C# API wrapper for the top.gg (Discord Bot List) API. - AbnerSquared/DiscordBotList.Net
you have to get your bot on botghost.com then go to settings then click online
NOO
All of you people get out of this channel unless you're asking top.gg API-specific questions
its not hard just log in with your bots token and your in
Stop using this channel and come back when you can read channel topics
Tty using shard_id with values 0 and 1 for each according server in separate requests
I remember having issues with that, so what I did instead was post an array of guild counts per each shard myself
https://github.com/top-gg/python-sdk I put this in my code for my code but it didn't work, can someone help me?
A simple API wrapper for top.gg written in Python. Contribute to top-gg/python-sdk development by creating an account on GitHub.
@keen arch WHich language?
javascript
thanks <3
Show how you used the Python SDK in your code
from discord.ext import commands, tasks
import dbl
class TopGG(commands.Cog):
"""
This example uses tasks provided by discord.ext to create a task that posts guild count to top.gg every 30 minutes.
"""
def __init__(self, bot):
self.bot = bot
self.token = 'dbl_token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token)
self.update_stats.start()
def cog_unload(self):
self.update_stats.cancel()
@tasks.loop(minutes=30)
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count."""
await self.bot.wait_until_ready()
try:
server_count = len(self.bot.guilds)
await self.dblpy.post_guild_count(server_count)
print('Posted server count ({})'.format(server_count))
except Exception as e:
print('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
def setup(bot):
bot.add_cog(TopGG(bot))
i used it like this
i imported this into my code
You imported it where
Do you use commands.Bot or discord.Client?
discord.Client
Remove the setup function and get rid of the class
All you'll need is fhe DBLClient instance and the update_stats function
Thanks!
π
?
def __init__(self, bot):
self.bot = bot
self.token = 'dbl_token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token)
self.update_stats.start()
def cog_unload(self):
self.update_stats.cancel()
@tasks.loop(minutes=30)
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count."""
await self.bot.wait_until_ready()
try:
server_count = len(self.bot.guilds)
await self.dblpy.post_guild_count(server_count)
print('Posted server count ({})'.format(server_count))
except Exception as e:
print('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
do I do it like this?
You don't need the init function
def cog_unload(self):
self.update_stats.cancel()
@tasks.loop(minutes=30)
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count."""
await self.bot.wait_until_ready()
try:
server_count = len(self.bot.guilds)
await self.dblpy.post_guild_count(server_count)
print('Posted server count ({})'.format(server_count))
except Exception as e:
print('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
?
like this?
who have a ban script?
I do
u using py?
thanks!
@cunning basin do you ever read channel topics by any chance?
how do I know if my bot has been approved?
#support question
I'm really sorry to bother you again but its isn't working.
Show your code
def cog_unload(self):
self.update_stats.cancel()
@tasks.loop(minutes=30)
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count."""
await self.bot.wait_until_ready()
try:
server_count = len(self.bot.guilds)
await self.dblpy.post_guild_count(server_count)
print('Posted server count ({})'.format(server_count))
except Exception as e:
print('Failed to post server count\n{}: {}'.format(type(e).name, e))
oops
well i get no errors though
cog_unload not needed
where the fuck is your DBLClient
self.bot replace with whatever your d.py client instance is
self.dblpy with a variable that points to your DBLClient instance
I'm using something else and I'm good now
what do you use
is it better than botghost.com
You people need glasses that specifically enlarge channel topics
How don't you know?
Sounds like one of your strings isn't closed properly
prob
Also, #development
bruh
For like a third time within the past day
i went there
I did say multiple times to read the fucking channel topic
-api
@restive otter
This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.
If you need help with development about your bot or development in general, feel free to use #development.
because this
how do i set up vote rewards?
fully read then, you will know then
how do i make the webhook connect to the bot tho
like to give people special items or coins or something
You create a webhook through your bots code, set that on your bot page settings, then handle the webhooks that come in to reward users
You cannot use discord webhooks, that's a almost different thing
a webhook is usually ran in the same process as the bot
not sure how to create a webhook tho
You can wrap one up with aiohttp.web and attach it to your client object or use dblpy
uhh ok
i got muted
im not 7
mhm
-api
This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.
If you need help with development about your bot or development in general, feel free to use #development.
please change channel
why
What is @bot.event
in the api
I want to post a message in a channel whenever a user votes the bot
event decorator is just a d.py decorator that binds a function to the client or its subclasses object as a method
TypeError: object Lock can't be used in 'await' expression
I am getting this error
@tasks.loop(minutes=30)
async def update_stats(self):
await self.dblpy.post_guild_count(len(self.client.guilds))
print("Count updated!")
I am not able to understand what's wrong
Ig it's an issue that's been fixed on v1, maybe try to build from the source since it's not out yet
I don't get it, what source?
The repo on github, or just downgrade to py 3.8
-api
Ok thanks, I'll try. By the way this should be updated because docs are misleading
Which ones?
So I am about to create code to recognize a vote, what kind of webhook do I need? (I am new to webhooks)
is there a tutorial to get the webhook for dbl?
Yea I found the docs, is there any way I can check if someone votes without a webhook? I don't have a domain so I don't think I can create a webhook
You only need a machine with an open port
Right, I do have one I'll check if I can make it work
MMMMMWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
the page won't let me change the webhook url
it just says: "There was a problem saving the webhook
"
@restive otter
This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.
If you need help with development about your bot or development in general, feel free to use #development.
o okay
no
π€ Muted Εmietaaa#3040 (@warm vigil)
is this my dbl token?
using top.gg python api, it's not updating my server count, with no errors in logs. anyone else having the same experience ?
yes
don't post your token dude
oh
for what it's worth, this is my code: ```py
import os
import dbl
from discord.ext import commands
import logging
logger = logging.getLogger('hangman')
class BotList(commands.Cog):
"""Handles interactions with the top.gg API"""
def init(self, bot):
self.bot = bot
self.token = os.getenv('DBL_TOKEN', 'Token Not found')
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes
async def on_guild_post(self):
logger.debug("Server count posted successfully")
any idea why no posting is happening ? and no errors either
no idea man, sorry
from discord.ext import commands
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = token # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/webhook', webhook_auth='jK2n06Df', webhook_port=5000)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print(data)
@commands.Cog.listener()
async def on_dbl_test(self, data):
print(data)
def setup(bot):
bot.add_cog(TopGG(bot))
this is the code
It is, but I think test webhook is broken or something
Need logs to debug this. Check the status of the post.
he he im still waiting for my bot to be added to the site
-api
This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.
If you need help with development about your bot or development in general, feel free to use #development.
how would I do that? it logs nothing
literally nothing
these are my logs
It doesn't? Huh. Feature request time then.
Question regarding 'test webhook' for the server - I'm assuming it's sent with a user ID other than my own? π
It is sent with your own user ID
I mean, I can see that it isn't currently being sent with my discord ID - I'm wondering if it's just the 'test webhook' bit that is doing something different or if I'm getting user IDs from the wrong place π
I doubt you can even test a webhook with a pending bot
Test webhook for the server lol π
Pretty sure test webhooks dont work for servers currently
Oh, well it's definitely pinging my server at least - Just pinged with an invalid user ID (at least one that my bot doesn't know about: 812030732107710464)
I'll just add handling to check that it's a valid user my end and it should be fine π
How dare you correct my incorrect assumptions? π€
That's probably your top.gg ID
... yup
Oh... So do I have to convert it to a discord ID? π
I... don't think you can?
You can just hardcode the user ID to yourself if the request type is test
Honestly, though, not sure why top.gg IDs are sent instead
π€· I don't need it to be correct for test so I'll just add some logic to check if the ID is a real 'player' for my bot to prevent errors lol - thanks for the help all :+1:

it takes around 2 weeks for my bot to get approved/denied right ?
This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.
If you need help with development about your bot or development in general, feel free to use #development.
the python sdk is either really terribly made or just won't work for me
what the heck is supposed to happen now
it's been like this for 5 mins
it's probably because of python 3.9 right
yep, fixed it
it doesn't
last I saw anyway
unless my pipenv didn't automatically update anyway
let me check
@sullen nymph is 1.0 not on pypi? I get this: Skipped Update of Package dblpy: 0.4.0 installed, 0.4.0 required (Unpinned in Pipfile), 0.4.0 available.
Yeah not yet
press test vote
from discord.ext import commands
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = token # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/webhook', webhook_auth='', webhook_port=23919)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print(data)
def setup(bot):
bot.add_cog(TopGG(bot))
url?
You need to set your webhook url in your bot page settings
cannot be a discord webhook
according to your code it would be http://yourserverip:23918/webhook
You need to use a port from heroku iirc
nah that's correct
no clue how heroku works. can't help with that
I'll just try to make the webhook handle upvotes since this won't work
app = Flask(__name__)
@app.route('/webhook', methods=['POST'])
def webhook():
if request.headers.get("Authorization") == auth:
if request.method == 'POST':
return 'success', 200
else:
abort(400)
else:
abort(400)
if __name__ == '__main__':
app.run()
does that even run it
I did but it still didnt work so I used the port that app uses which is 23919
but still nope
@sullen nymph ?
thats yours?
yeah
cool
how come it didn't work with webhook_port=5000 when the Flask script defaults the port to 5000 
its not running on my pc
its running on heroku
https://github.com/shivaco/DBL-python-webhook I'll take some code from here
Flask script mainly to handle POST requests from top.gg - shivaco/DBL-python-webhook
while I wait to become owner of ratelimiter, here: pip install --target=./ --no-cache-dir --upgrade git+https://github.com/gear4s/ratelimiter.git@master
fixes TypeError: object Lock can't be used in 'await' expression for python 3.9
Did you contact PyPi to have the project transferred to you
yep
I know
but it's not been released yet has it
and I'm kinda sick of my bot spitting that error anyway
Wouldn't go as far as taking over a package, but you do you Β―_(γ)_/Β―
Β―_(γ)_/Β―
it needs to be updated and the maintainer is not updating it
so
w/e
I've had py3.9 since release and it's bugged me ever since
I managed to have the port be 5000
Can I have a notification system every time someone votes for my bot without using webhooks ?
no
if you want realtime notifications, use webhooks
there's no other way except spamming the heck out of the api that could get you ratelimited multiple times
alright, thanks. I'm asking the question because I'm self hosting on my raspberry Pi
so I can't get a server that has a fixed IP to send the webhooks to
How do I send a message with the bot whenever someone votes a bot
btw my bot runs on repl
using webhooks https://docs.top.gg/
I tried but its not working
what did you try?
Question:
With
https://top.gg/api//bots/798634937606864937/check?userId=468384658653184040
It returns
{"voted":1}
But I have voted twice, once last month, once this month. Is there a way I can get all votes for a user, not just monthly votes?
Reply and ping me
did you fill in the webhook url and auth on the site?
yeah
voted: 1 is true/false, not the number of votes total.
there is no way to do that, you need to track it yourself.
https://REPL_NAME.repl.co
it was in this format
then for auth
i put
MESSAGE_TRACKER
(my bot name)
hmm ok, I have a postgres database with users table and a votes column how would I reliably update the votes column without accidently giving the user extra votes?
using webhooks would be the best method
the bottom section https://docs.top.gg/libraries/python/
so yes?
yes
eaeaeaeaeaeaeaeaeaeaeeaeaeaeaeaeaeaeaeaeaeeeeeeeaaaaaaaeeeeeeeaaaaaaaaeeeeeeeaaaaaaaaaeeeeeeeaaaaa
The examples are cog-oriented, but you are not forced to use them for dblpy
yay, shiv save me. my lack of py knowledge 
All you really need is an instance of DBLClient saved in a variable and events attached to the same client you pass to DBLClient
is @ bot.event same as the discord.client.event
In a way
I have this code:
And it prints nothing when I test/vote
from discord.ext import commands, tasks
import dbl
import libs.database as db
import os
KEY = os.getenv('TOPGG_TOKEN')
class TopGG(commands.Cog):
"""
This example uses tasks provided by discord.ext to create a task that posts guild count to top.gg every 30 minutes.
"""
def __init__(self, bot):
self.bot = bot
self.token = KEY # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='never', webhook_port=5000)
self.update_stats.start()
def cog_unload(self):
self.update_stats.cancel()
@tasks.loop(minutes=30)
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count."""
await self.bot.wait_until_ready()
try:
server_count = len(self.bot.guilds)
await self.dblpy.post_guild_count(server_count)
print('Posted server count ({})'.format(server_count))
except Exception as e:
print('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
@commands.Cog.listener()
async def on_dbl_vote(self,data):
print(data)
print(data.isWeekend)
print(data.bot)
print(data.user)
await db.query(
f'''
UPDATE users
SET votecount = votecount + 1
WHERE id = {data.user}
''')
@commands.Cog.listener()
async def on_dbl_test(self,data):
print(data)
def setup(bot):
bot.add_cog(TopGG(bot))
ok
What'st the URL you entered on top.gg?
Ah missed the message above
http://ip:5000/dblwebhook
where ip is your machine's IP addrss
I host it on heroku...
i host on repl
so what ip would I use?
i actually have the same question as creare
what url would I put if I have it on repl
For repl you host on port 8080 and use the repl.co URL
For Heroku, as it seems, you need to get the PORT environment variable passed by Heroku itself
that means you can't just do run(port=xxx)
You can usually easily get it when running your repl
what should I put for auth
dont forget to add /dblwebhook btw
Anything you wanna use as a password
Auth is just that, a password you create and enter in your code and on top.gg
should I add /dblwebhook after repl
yes
oah thx
172.18.0.1 - - [11/Mar/2021 19:01:56] "POST /dblwebhook HTTP/1.1" 404 -
172.18.0.1 - - [11/Mar/2021 19:02:56] "GET /dblwebhook HTTP/1.1" 404 -
this popped up
same,
you should censor the ip
oah gosh thx
Enable the web dyno
Are you sure you are running the TopGG cog successfully?
im not sure
Let's take a step back, then. Are you using commands.Bot or discord.Client?
commands.,bot
How do you load your cogs/extensions?
client.load_extension("file_name")
Do you think I could view your repl manually?
quick question I have my error, I my issue that I just don't have the right port? I am using webhook_port=5000 is that wrong? for heroku
gtg, If you have a response dm me
ok
dms
the returned value will be what you will use as a port
i think shiv answered your issue. enable a web dyno.
i dmed you @sullen nymph
apart from enabling the dyno, there's a special case with ports for Heroku @jaunty plank
There's no specific port Heroku sticks to, but instead it's a dynamic system
according to a few SO posts, one must rely on env vars for the port
oh good lord
@exotic hinge you have a keep_alive running that occupies your port 8080
yeah
You can't have two scripts running on the same port
wdym how else woujld I do it
One way is to have your keep_alive script use a separate route for top.gg requests
and then to INTERNALLY redirect it to your dblpy webhook
aka keep_alive in port 8080, dblpy webhook port 5000. on request to keep_alive, route /dblwebhook, send a request to port 5000 localhost
so do i make another file?
Not exactly
The thing here is you need to modify your keep_alive in order to make it work with a webhook running locally
I wish I wasn't dead tired to explain this in detail but my brain is barely putting together two sentences
keep_alive is a Flask webhook, right?
yeah
So that means that it's a webhook, but a publicly accessible one
well yeah cuz its on repl
Your dblpy webhook, on the other hand, will not be publicly accessible through a repl.co URL
Instead, it will run locally under some port like 5000, which is not publicly accessible
In your Flask webhook, you might want to create a specific route for top.gg requests, like /dblwebhook
what it will do is send POST request to the local webhook, port 5000, with the vote data and headers, etc.
essentially becoming middleware
Yeah I could already tell
should I make another function with port 5000
You don't set a port to a function
from flask import Flask
from threading import Thread
app = Flask('')
@app.route('/')
def main():
return "Your bot is alive!"
def run():
app.run(host="0.0.0.0", port=8080)
def keep_alive():
server = Thread(target=run)
server.start()
I have this
how would I modify
use the @app.route thingy in keep_alive that will send a POST request to http://127.0.0.1:5000/dblwebhook
from flask import Flask
from threading import Thread
app = Flask('')
@app.route('/')
def main():
return "Your bot is alive!"
def run():
app.run(host="0.0.0.0", port=8080)
@app.route('/')
def keep_alive():
server = Thread(target=run)
server.start()
?
google how to set up a route in Flask
ok
#general-int for spanish
Si
Yes
how do I write this in the new version of dplapi.js?
dbl.hasVoted(message.author.id)
the "new version" is @top-gg/sdk
._.
someone help me so that users have to vote for the bot to be able to use the command
please help
Just read the docs
I don't understand xd
API Error: 429 Too Many Requests is topgg down?
What you don't understand?
I do not understand anything xD
okey
API Error: 429 Too Many Requests how can I prevent this error?
Ping me with the awnswer
are you spamming the api
No
429 means you are being ratelimited
Like one of my commands need to vote to be used
i think someone spamming that command
The command have 3s cooldown
you should really store shit like that and use a webhook
Wym?
How should I use a webhook
I changed today from dblapi.js to the new one
So yea I'm a little confused
with webhooks you can receive an event when someone votes, and store it to use any time someone runs a vote locked command. https://docs.top.gg/libraries/javascript/#webhooks
So that will stop the ratelimit?
well, you dont send any requests at all, so you cannot get ratelimited
Hm ok
Please Tell
yes
client.dispatch dispatches to both internal and external listeners
actually Bot since Client doesn't have external listeners other than wait_for
sir this is #topgg-api not #graphics-design
Yes
This is one of those if you did it right it would work properly situations.
Did you try testing your webhook?
dbl_client = dbl.DBLClient(bot = client,token=dbl_token,webhook_path=dbl_webhook)
No I DIdnt try
testing my webhook
Well test it
Is this right way to construct?
Then your webhook isn't working. Check the logs.
Unsure if you need to specify a port as well Hmmm
Try specifying a webhook port in the constructor
Oh it's a Discord webhook
yes
Oh
You need to specify a port in the DBLClient constructor
And the webhook URL should be http://your_server_ip:your_webhook_port/your_webhook_path
I Dont know anything about webhooks so i created one from a channel
F
Where Can i Create one
The python sdk creates a webserver for you that handles the webhook
Just pass an unused port to webhook_port and a webhook_path
I keep on getting this error on my VPS does anyone know a possible fix?
Did you install it?
nope, i've re-installed it a couple of times but that issue keeps on occuring
That emoji is perfect
Kaka
Are you installing to the right project?
ye
@azure pollen do you know any fixes?
i believe @hearty lintel is the maintainer for that?
i would just make sure you are installing it in the right place, node_modules can be super tricky
Should I dm him?
i pinged him here, he's offline atm
ok, Thanks
continue to see if you can get it working, it looks like an install problem rather than a lib problem
i'm going to check the doc
s
But this seeems like an isolated issue on my vps
Berry maintains the js sdk
Hi
So how do I make it when someone votes 5x they get voted 5x role 10x Ythey get votes 10x role and so on
track the vote count using the webhooks, then give them roles on the 5th vote
It requires coding knowledge though
save the votes in db and the do what Hope said
e
I am getting such an error on my discord bot what should I do please help me
Fix it!

