#topgg-api
1 messages · Page 153 of 1
btw i only have that as const
the dblapi.js
i havent used it anywhere
Oh lol
dont reset
sry
k
Someone can help me with that
const express = require('express')
const { Webhook } = require('@top-gg/sdk')
const wh = new Webhook(webHookPassword)
const app = express()
app.post('/webhook', wh.listener((vote) => {
console.log(`User with ID ${vote.user} just voted!`);
//do stuff
}))
app.listen(3000)
I am not receiving any votes. I double checked webHookPassword and the WebhookURL.
How to setup a webhooks
Please explain to me like I am 5 years old
Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.
The url is http://<your public ip>:<webhook port>/<webhook path>
And the authorization is whatever you want it to be, it's not mandatory
Does anyone have an idea on this? Thanks for any help!
+1
Is port 3000 open on your network/the network your bot is hosted on?
yes, I also tried with 5000 and it worked before. But at end of April it suddenly stopped working
The same issue with the "old method"
const DBL = require("dblapi.js");
const dbl = new DBL(topggToken, { webhookPort: 5000, webhookAuth: webHookPassword }, client);
dbl.webhook.on('vote', vote => { //vote routine
console.log(`User with ID ${vote.user} just voted!`); //never executed
});
have you tried port 5000 on the new one?
Yes, still nothing
any errors?
No, its just like nothing happens when pressing the "Test" button on top.gg
my URL: http://xyz.blabla.de:5000/webhook

And I am using the webHookPassword from "Authorization" listed on top.gg (not the Token)
@fading inlet try the one on the docs https://docs.top.gg/libraries/javascript/#webhooks
I dont think its much different
other thanit saying /dblwebhook
have you tried it?
Are you clicking save then test?
This happened with my friend too @gray yew
Routers are very strange and strict when it comes to this stuff
I copy pasted, but its still not receiving anything. I only changed port 80 to port 5000 (because port 80 is already used for me)
+1
And I can exclude firewall issues because it worked in April with this Port (I did not adjust anything).
Also I can see it is listening on that port
Can you scan your own external IP to see if the ports open, and if so can you access it using a browser?
@fading inlet (sorry for ping)
Doing an external port scan it says the port is closed
Do I have to restart my VPS for opened ports to register?
Oh, are you sure it's open on the router then?
Idk my VPS doesn't have a router thingy (or at least when ever i open a port i don't have to configure anything)
:/
I got it to work by using iptables -A INPUT -p tcp --dport 5000 -j ACCEPT , restarting my VPS and adding an extra firewall rule in my VPS dashboard. I dont know which of these fixed the problem, but it somehow works now. Thanks for your help.
I'm looking for an api that can give me a Turkish word.
I'm pretty sure this channel is for top.gg api
-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.
I cant update my stats with the java API and when I set the stats it does nothing and blocks my code :/
I set them with discordBotListAPI.setStats(guilds.size());
-api
I'm sorry, maybe you know.
Hey, so on my ```js
dbl.on('posted', () => {
console.log('Server count posted!');
});
My server count does not post too
api erroring out i guess 👀 will probably return shortly.
504 errors typically means its server side.
CollectAPI.com, serves as a marketplace for users looking for API.
Try the one above, but you can also just create a list of words one by one
What API is used in place of dbl.js for Javascript to post stats on site?
@waxen widget-gg/sdk
thanks discord for that ping
wtf
@jaunty plank
.then(res => res.text())
.then(body => {
console.log(body);
});```
When i try to fetch if the user has voted or not, it gives me back "Unauthorized", how can i do?
you need to send the auth header with your token.
Someone know? :/
we dont get a lot of java devs here.
the java lib hasnt been updated in 3 years, not sure if it even works tbh.
discordBotListAPI.setStats(guilds.size());
isnt it supposed to be
api.setStats(serverCount);
with this init line
DiscordBotListAPI api = new DiscordBotListAPI.Builder()
.token("token")
.botId("botId")
.build();
I made exact this
I only gived it a other name
guilds.size = serverCount
and discordBotListAPI = api
use debug lines
catch the exception if there's any
make sure the token is correct
you never actually posted the server count I assume
use what woo said, api.setStats(ServerCount);
catch that
yes
post your stats
-servercount
To have your bot's server count displayed on Top.gg, please read the documentation on server/shard posting.
@fresh plover
hey guys so we have a bot hosted in a centronodes server, and when we try to access the webhook path this shows up
it worked in repl.it tho
alright nevermind we had a small http issue
we used https instead of http which it uses so yea
it's fixed
And autopost also worked
I did
Well, any errors?
hi there, don't know if I post right here. I want to ask if there is a way to retrieve the total guilds my bot is invited so I can display them in my website
there's a function that exists that the gets the guilds your bot is in
so just take the length of that list
thnx. I am aware of that function, I use it in a command to retrieve the list of guilds, but how do I call that from my website ?
can I use top.gg's API to get the total number of guilds ?
oh from the website?
you could send a webhook ig, and then when you receive it you send the guild count back
@rain heart
System.out.println("UPDATING STATS TOP.GG");
discordBotListAPI.setStats(guilds.size()).whenComplete((unused, throwable) -> {
if (throwable != null) {
throwable.printStackTrace();
return;
}
System.out.println("DONE UPDATING");
});
"Done updating" does never executed
And no error
if you think that will work can you perhaps guide me how to do it ?
uh, Imma be real, I don't know much about web interfaces so I doubt I can help you much
ok, thnx
Fixed it. Put it in a new thread and then he said me a error
But I never received a error without new thread..
-docs
Use webhooks, i have a guide here : https://comhad.github.io/webhook.html
How do I make it so that voting for the guild gives you rewards?
can someone tell how can i put this back to N/A? If thats even possible
-servercount
To have your bot's server count displayed on Top.gg, please read the documentation on server/shard posting.
-servercount
luca commands are mod only, the response is -servercount is given above.
I pass the dbl token like 'DBL TOKEN' right not "DBL TOKEN"
Still cannot get the API to work lol
-servercount
mod only command
To have your bot's server count displayed on Top.gg, please read the documentation on server/shard posting.
Thats wut the command sayd
says*
oh I cannot post links
as long as its a string, it doesnt matter.
Is this all I need, not working 4 me dunno why do not think my cogs r loading?
i think the problem is @commands.Cog.listener() because mine does not have that
helloo what do you put for the url in place of the dbl hook thing and auth?
ahh i get it ignore me
Just be patient than saying "ahh I get it ignore me"
the url to your webhook receiver(not discord).
The auth you make.
? i found the answer in the mean time
mky
wasnt trying to be sarcastic qwq sorry if it came off that way-
ohh sorry wasn’t responding to you there 😭😭 on pc my msg came before urs
both showed up at the same time on my end, i knew dw ❤️
:) ❤️
Hi, how can i access the API in python so i can keep track of the number of votes of each person and when they can vote again ?
Uhm, a Question: How do I use Webhooks?
Webhook
The definition of a webhook is basically automated action on trigger
Trigger is webserver that listens to HTTP requests
I know, but how do I use them with the topgg API?
You run one on your machine, make sure the port it's on is open and no firewall is blocking requests to that port
The URL is http://1.2.3.4:5000/path
Where 1.2.3.4 is your IP address
5000 is the port
/path is the route
How can I make a poll in discord
I made a little guide for a flask app : https://comhad.github.io/webhook.html
What is the difference between "Manual server count" and "automatic server count"
But do u need to restart ur code every time to update on the "Manual server count"
Sorry I'm idiot, its joke which is only funny to me
From python docs it looks like automatic is when you let the library handle it and manual is when you call the function yourself
oh kk ty
@abstract moth
Manual means you run a function that uses DBLClient.post_guild_count yourself in a loop
Automatic means an internal function is called every X minutes
everything is allowed if they don't find out /s
That's not what I asked...
has the most recent version of topggpy been added to pypi?
I would assume no
@loud token i have a question
okay
can i use multiple Authorization tokens instead of one?
to count the votes etc
like multiple webhooks
why would you want to do that?
Okay, so you want to use the same webhook for the two bots?
or are you using 2 different webhooks?
yeah idrk what the question is because you can set a unique "authorization token" for each bot
string?
I'm confused as to what you're asking
okay
and you want to know whether the authorization can be different
you personally set the authorization, why couldn't they be the same or different?
yea
personally I would make them different
just for extra security
but I mean you don't have to ig
for 1 bot?
2 bots
you can
but they both give me different tokens bro
tokens are not authorization
like the codes are different for setting the webhook
they're different things
the token is for the topggpy package or the js equivalent
the authorization is something you choose
this for example rn a bot that already set to my server
i can't add another because it gives me different codes
why would you want to add another
there's a different page for your other bot
where?
wdym where
what these bots does is basically when someone votes they give a member a role
each bot has its own editing and analytics stuff
i have one set
i want to add the other
if i can set the other
tell me how
to the same server
I'm so confused rn, servers have nothing to do with webhooks
i will start from the beginning
i have a server with 2 bots which serve the same purpose
each bot has it's own way of setup they are not identical
and i can fill only 1 bot here
can't fill for 2
Open up the editor, click on this to set the webhook. The two separate bots do not have the same editor, so I don't understand what you're asking
this is an example with my bot
where did you get that panel
?
i don't have it
have you been to the topgg website
link?
wut
can you send me the link to it @loud token
how do you not know the link
https://top.gg/
yea yea
it's the saame as the one i am on right
but where do you get the panel
this also a different example
of what people do
like you can't add more than 1 option there
bruh
THE TWO BOTS ARE COMPLETELY SEPARATE
i know
but where do i insert the info of the second bot then?
like where do i insert the second auth token and URL?
isn't that kinda obvious, how can u be asking this
pretty sure thats pay outs
-credits
@median lagoon
Auction Credits
What are they?
- If enough people vote for your bot or server per month, you have the ability to get credits that you can then use for auctions.
- Don’t know what auctions is? See here for how to apply.
- These auction credits can be used to pay for any winning bids you may make
- You CANNOT “withdraw” them for real money
How does the System Work?
- Each month, bot monthly votes reset
- If you get 100 votes on your bot in the month, you can redeem $15 worth of voting credits (can’t redeem till you actually get 101 votes)
- Any vote after 100 will be worth $1 per 1000 votes (or $.001 per 1 vote)
How Can I Redeem Them?
- At the end of the month, you will be eligible to redeem your credits (you redeem them on your bot or server's
Votespage on your bot’s dashboard). You will have 30 days to redeem them before they expire. - After you redeem them, you have 31 days to use them before they expire (so you can technically stack 2 months worth)
**How can I Use them to Pay? **
- When you pay for your winning bid, you have the option to use your credits
- If your winning bid cost is more than the amount of credits you have, make sure to apply the credits first and then pay the rest with the supported payment providers
A more simplified, less detailed version can be found in #580510490074152961 after you get auctions access and any questions can be asked in #auctions-general.
advertise
can someone teach me exactly what to do in VC?
In what?
i wanna learn how to spent them
Did you read the message?
yea but seem hard
how?
hi, my bot isn't in Top.gg since it's a custom bot
i want the bot to be able to track down the number of votes of the server and when the member can vote again to the server, can someone help?
Only way is using a webhook, as servers does not have an api
hmm so something like this?
import topgg
# This example uses topggpy's webhook system.
# The port must be a number between 1024 and 49151.
dbl_token = 'Top.gg token' # set this to your bot's Top.gg token
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "password")
bot.topgg_webhook.run(5000) # this method can be awaited as well
@bot.event
async def on_dbl_vote(data):
"""An event that is called whenever someone votes for the bot on Top.gg."""
if data["type"] == "test":
# this is roughly equivalent to
# return await on_dbl_test(data) in this case
return bot.dispatch('dbl_test', data)
print(f"Received a vote:\n{data}")
@bot.event
async def on_dbl_test(data):
"""An event that is called whenever someone tests the webhook system for your bot on Top.gg."""
print(f"Received a test vote:\n{data}"```
i found it in a GitHup rep
@rain heart sorry for the ping but how do i get my dbl token ?
You can only get it with a bot
is it the bot's token?
so i have to put the same bot or another bot?
wait but all i need is to get the server's info
like the number of votes the server has
how many this member has voted for this server
and when will that member be able to vote to this server again
do i have to put the bot in Top.gg?
actually, just remove the dbl_token variable
as it doesn't seem to be used anywhere anyways
You don't need the dbl token to use webhooks
hmm then what do i need?
i have searched for any documents/GitHup repos but all the things i found included a dbl token
You only need the dbl token to access the API, which isn't necessary if all you're looking to do is to listen for votes
oh
All you need to do is make sure the port you're using is open on your network, and that your webhook url is correct in the webhook page
import dbl
import discord
from discord.ext import commands
voters = []
class TopGG(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.token = 'token'
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
user = data['user']
voters.append(user)
def setup(bot):
bot.add_cog(TopGG(bot))
I'm trying to add new voters to a list in python. Unfortunately, I get this error:
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x00000188B5A4A580>
i am sorry but can you give me an example?
i am new to webhooks and url and i am not sure if i understand this well
The URL would be http://<your public ip>:<port>/<webhook path>
So in your case: http://<your public ip>:5000/dblwebhook
Does anyone have a real and working Token Gen?
I need it to test out my friends bot.
It's an Anti-Nuke, and we wanna see if some nuke bots can bypass it.
-api
@leaden ice
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.
I'm also 99% sure that a token gen would be against ToS. so I'd advise against that
const Topgg = require("@top-gg/sdk")
const express = require("express");
const app = express();
app.use(express.static("public"));
app.engine("html", require("ejs").renderFile);
app.set("view engine", "html");
const webhook = new Topgg.Webhook("TheSuperDuperSecretAuthKeyForEastsideDiscordsVoteWebhooks69")
app.post("/dblwebhook", webhook.listener(vote => {
// vote will be your vote object, e.g
let votechannel = client.channels.cache.get("840050870661021716");
votechannel.send(`<@${vote.user}>, has voted for the server!`);
console.log(vote.user) // 395526710101278721 < user who voted\
// You can also throw an error to the listener callback in order to resend the webhook after a few seconds
}))
const listener = app.listen(25654, () => {
console.log("Your app is listening on port " + listener.address().port);
});
I use this but it isnt working
@night ingot sorry to ping you again, but how do i use the webhook?
do i use flask or django?
or do i use requests?
sorry again for the ping
If you want to implement the webhook inside of your bot, it's suggested to use Quart, Sanic, or aiohttp.web
Since they're asynchronous
oooh thx
shivaco, is the most recent version of topggpy on pypi?
is there a way to get my public IP address?
i think i am messing something cause it's giving me this error
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientConnectorError: Cannot connect to host "idk if i should show my public IP":5000 ssl:default [The semaphore timeout period has expired]```
@commands.command()
async def test(self, ctx):
url = "http://idk if i should show my public IP:5000/dblwebhook"
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
print(response)
``` code
It doesnt log anything or send message when i hit test webhook
why is my dblpy autopost for my guild counter stopped working?
I have not touched it since I set it up
Not yet
Will be next week though
okay, thanks
?
you asked how to find your public ip
oh i thought that link was an image link
thx i will try that
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientConnectorError: Cannot connect to host "My new IP address":5000 ssl:default [The remote computer refused the network connection]```

Is dblpy been recently changed?
hellooo i thought i figured the webhook url out but i cant get it to work D: the url has my public ip and port 5000, the code im using is
async def on_dbl_test(self, data):
print(f"Received a test upvote: {data}")```
nothing happens when i test, what can i do?
http://PublicIPHere:5000/dblwebhook
is the url your using?
yep!
whats your hosting provider?
home/vps ?
just my pc
did you port forward?
whats that?
on home networks since there are multiple devices per public ip, you need to tell your router which device to send requests on a specific port to
for example
1 ip serves maybe your pc, phone and xbox.
you need to tell your router, port 5000 goes to your pc.
oh that makes sense, thank you!!
can someone help me with the webhook thing?
i have no idea how to do it
for your bot?
amm
i want to track the members who vote for my server using my custom bot
like i can check who voted and store the number of votes in a database
and when can the member vote again and etc
@jaunty plank ^
sure, what programming language/lib are you planning on using?
the python library actually has webhook support built in, might be easier.
https://docs.top.gg/libraries/python/
https://dblpy.readthedocs.io/en/latest/api.html#topgg.WebhookManager.dsl_webhook
the token is only used for making requests to the api, not webhooks
oh so i can remove it from the code?
I think you can just put whatever you want there(dont think its optional?, not sure). as long as you dont attempt to use the api methods, should be fine.
alr
@jaunty plank is this one an event?
https://dblpy.readthedocs.io/en/latest/api.html#topgg.WebhookManager.dsl_webhook
the docs are kinda all over the place. uh, lets see
looks like thats part of the initialization.
https://github.com/top-gg/python-sdk#using-webhook
^ this has an example kinda showing it.
its using dbl, for the bot list, but it should be the same for dsl.
the token is mainly for server posting, but it's required for initialization
hmm so what should i change to make it trigger when a member votes the server?
there's a function for that
hmm?
@bot.event
async def on_dbl_vote(data):
"""An event that is called whenever someone votes for the bot on Top.gg."""
print(f"Received a vote:\n{data}")
but i want it for a server and not the bot
same exact thing, just dsl
lol idk where dsl goes
@client.event
async def on_dsl_vote(data):
"""An event that is called whenever someone votes for the bot on Top.gg."""
if data["type"] == "test":
# this is roughly equivalent to
# return await on_dbl_test(data) in this case
return client.dispatch('dbl_test', data)
print(f"Received a vote:\n{data}")``` like this?
oh
I'd look through the github code to get a better understanding of the library
so if i used that in the code and voted for the server, it will get triggered and print "data"?
yeah, idk what the return thing would do though
i don't think you should be returning anything
sure, i will try reading them
think it handles that
the webhook event should give you this data
https://docs.top.gg/resources/webhooks/#server-webhooks
it comes in the form of a python dictionary so you can get the info using the correct keys
oh thx alot guys
@jaunty plank i don't think it worked
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("/dblwebhook", "password")
#client.topgg_webhook.run(5000) # this method can be awaited as well
@client.event
async def on_dsl_vote(data):
"""An event that is called whenever someone votes for the bot on Top.gg."""
if data["type"] == "test":
# this is roughly equivalent to
# return await on_dbl_test(data) in this case
return client.dispatch('dbl_test', data)
print(f"Received a vote:\n{data}")```
hmm nope, i mean where do i fill that?
oh man
like i said lol it's my first time with webhooks
👀 servers
agh
your servers page, webhook section
it gives 404
ah
lmk if it works
alr, and thx alot
is this voted in the past 12h or in the past month?
Past 12h
ive looked into it a bit more and cant seem to get it to work- i think its because i ahve a dynamic ip :(( what can i do?
Does anyone here know how to remove someone from being an owner of your top.gg bot page:D
@loud tokenhi i am back and sorry i was outside and just came back
after i open the server in top.gg what should i do ?
there should be a section for webhook stuff
yep
@loud token ```py
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("URL", "Authorization")

client = commands.Bot(command_prefix=prefix, intents=intents)
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("URL", "Authorization")
@client.event
async def on_dsl_vote(data):
"""An event that is called whenever someone votes for the bot on Top.gg."""
if data["type"] == "test":
# this is roughly equivalent to
# return await on_dbl_test(data) in this case
return client.dispatch('dbl_test', data)
yes
you still shouldn't be returning anything
hmm why?
do i change this py client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("URL", "Authorization") to py client.topgg_webhook = topgg.WebhookManager(client).dsl_webhook("URL", "Authorization") ?
dbl_webhook --> dsl_webhook
@loud token sorry for the ping
oh for servers yeah
nice
and you don't return anything because why would you
yeah i removed the return part
okay
@client.event
async def on_dsl_vote(data):
print(f"Received a vote:\n{data}")```
so with that it will print the voter data?
i still have 5 hours to vote again
hmm ?
in the same place where you set the webhook on the topgg website
just scroll down a bit
maybe the url is wrong
if you want to personally haven't used it yet so idk what the issue might be
wait how do i do the test votes lol
oh.....i feel rage.....sorry
lmao it's fine
wait i have been clicking that and nothing happened
i just received a pop up
it should say something like webhook sent
to whatever url you put
oh that
god i was scared lmao
@loud tokennope i used this format and nothing happened http://<your public ip>:5000/dblwebhook
this should be: client.topgg_webhook = topgg.WebhookManager(client).dsl_webhook("/dblwebhook", "Authorization") then
alr
dbl_token = 'Top.gg token' # set this to your bot's Top.gg token
bot.topggpy = topgg.DBLClient(bot, dbl_token)
that's the connection step
there is no DSL api
ohhh
there's a differend function for tests
@bot.event
async def on_dbl_test(data):
"""An event that is called whenever someone tests the webhook system for your bot on Top.gg."""
print(f"Received a test vote:\n{data}")
i also tried that
but no response
import topgg
# This example uses topggpy's webhook system.
# The port must be a number between 1024 and 49151.
dbl_token = 'Top.gg token' # set this to your bot's Top.gg token
bot.topgg_webhook = topgg.WebhookManager(bot).dsl_webhook("/dblwebhook", "password")
bot.topgg_webhook.run(5000) # this method can be awaited as well
@bot.event
async def on_dsl_vote(data):
"""An event that is called whenever someone votes for the bot on Top.gg."""
if data["type"] == "test":
# this is roughly equivalent to
# return await on_dbl_test(data) in this case
return bot.dispatch('dbl_test', data)
print(f"Received a vote:\n{data}")
@bot.event
async def on_dsl_test(data):
"""An event that is called whenever someone tests the webhook system for your bot on Top.gg."""
print(f"Received a test vote:\n{data}")
did you copy paste that code
except replace dbl with dsl
so something like that
yeah for every dbl i putted dsl
bot.topgg_webhook.run(5000) this one gives me errors
you might have to await it
in an async function?
and idk how to await something lol
no i mean awaiting it outside a function
There isn't in topggpy
just type await in front
u realize that won't work right?
lmao
yeah lol
I'll update that
what docs aren't fucked
?
that's how to await it
asyncio.get_event_loop().run_until_complete(client.topgg_webhook.run(5000))``` ?
well not like i got a response from the webhook
still why is it not giving a response?
Because the one on github returns a Task object. So you're not necessarily required to await it...
I meant the test function
What about it?
shivaco said it doesn't exist
Did you see that I manually dispatch it?
@bot.event
async def on_dbl_test(data):
"""An event that is called whenever someone tests the webhook system for your bot on Top.gg."""
print(f"Received a test vote:\n{data}")
This one?
?
This line
this is the one I was referencing
I see that you manually dispatch that, but it doesn't change that there exists a on_dbl_test event in the github README docs
Because the dispatch line also exists, duh
aaa
Ye, the on_dbl_vote function itself is meaningless and won't be called if there's nothing dispatching it
okay, that makes sense then
wait so what should i do?
if you have the if data["type"] ... you'll need the event, but if you don't have it I don't see a reason why the webhook wouldn't work without on_dbl_vote
so like it's essential for the event to work?
and is there a function called on_dsl_vote ?
You can also do if else branches if you don't want to have extra events
rn his problem is that the webhook's not doing anything I think
yeah
also @pseudo sierra just let us see your code
I have no idea what you've written
Try doing a GET request to it, it should return 405 iirc
side note: why do you need all intents
So, you put http://ip:5000/dblwebhook on the site?
yes
Btw, you can do client.loop.run_until_complete(...) for a shorter code
i used http://ip4.me/ to get the IP
and your authorization is yamizero31 correct?
yes
okay
Do you self-host it?
yes i am hosting it locally for now
Have you forwarded the port?
sorry i don't understand?
Welp, then this might be the issue. Your webserver isn't reachable if you don't port forward
just to prevent issues if i ever had to add something
hmm what's port forward ?
wait so what if i hosted the bot in a hosting site?
would i need to get the IP address of it or just put 0.0.0.0 instead?
what site are you thinking of
you would need an ip, but you wouldn't have to port forward
oh
I assume that's a VPS
i believe so
i tried testing it from the site and it didn't print
hmm
......why is not working then lol
then the issue wasn't from the router but something else?
idk man
same
wait
?
did you get a new public ip for the vps?
yeah
i used the public ip
I think the VPS has a different public ip than your home computer, so you have to find that one
idk if you did that
i am using that one lol
just making sure
also you can get rid of import dbl btw
hmm
you could try sending a bot vote, see if that works
see if it works with bot votes
i tried that as well
ah
i even put 4 events
on_dsl_vote
on_dsl_test
on_dbl_vote
on_dbl_test
nothing got called
well on_dbl_test won't get called if the dispatch statement isn't there
wut
idk what the issue is, do you not get any error statements?
no
welp, you can try running it on heroku or smthn that gives a url
what url?
i have a question tho, how does the bot get info of the voting ?
I'm just suggesting as a test
webhook
like all i specified was the url and the auth_pass
but their might be others who has the same auth_pass and url?
lmao

you should go to sleep then, it's not like this needs to get done today
unless it does
yeah it's just a bad habit of mine
but I'm reaching the end of my day as well so I'm gonna log off in a bit anyway
bruh
yeah, if you can't think, then you're just wasting time
If nothing is called, make sure the port you specified is open
Hello. I need help.
I got object Lock can't be used in 'await' expression I want to check if a specific user has voted. Then if they did, reward them. But i got the said error.
class Currency(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.dblpy = dbl.DBLClient(self.bot, os.getenv("DBL_TOKEN"))
@commands.Cog.listener()
async def on_dbl_vote(self, data):
user = data['user']
embed = discord.Embed(
title=f"Reward for <@{user}>",
description="xxxxxx",
color=discord.Color.purple(),
)
channel = self.bot.get_channel(user)
await channel.send(embed=embed)
@commands.command(name="vote", help="Vote for rewards.")
async def vote(self, ctx):
if await self.dblpy.get_user_vote(ctx.author.id):
print("You've voted!")
see topggpy
Alright thank you.
hi
idk why since i used topgg api, my bot has stopped working
const Topgg = require("@top-gg/sdk");
const AutoPoster = require('topgg-autoposter');
const ap = AutoPoster(config.DBL_TOKEN, client) ;
ap.on('posted', () => { // ran when succesfully posted
console.log('Posted stats to top.gg')
})
const dbl = new Topgg.Webhook(config.DBL_TOKEN);
dbl.on('error', (error)=>{ console.log(error) })
dbl.on('vote', (vote)=>{
const eco = ecoschema.findOne({userID: vote.user.id})
const webhook = new Discord.WebhookClient('839215460624891915', 'OZ7wMQqK-wlzBlA33Lh0bwFYJvSAeXCQE_V_tcxBx1GRQEck5kRmxxZl_7hy--Fmx5Bb');
const voteembed = new Discord.MessageEmbed()
.setAuthor(`Thanks for Voting!`, client.displayAvatarURL())
.setDescription(`Thanks **${vote.user.tag}** for voting for Cyte Bot! \n You can vote again in 12 hours!\n [Click here to vote again!](https://top.gg/bot/754765403489828946/vote)`)
.setFooter("I have provided you your vote rewards successfully!")
.setColor("#0afa08")
webhook.send(vote.user, voteembed)
eco.money += Number(2000000)
eco.save()
vote.user.send(new Discord.MessageEmbed().setAuthor("Thanks for voting for me!", vote.user.displayAvatarURL({dynamic: true}))
.setDescription("I have successfully provided you `2,000,000` coins as your vote rewards!")
.addField("Please consider voting for me in the next 12 hours again!", `[Click here to vote again in the next 12 hours!](https://top.gg/bot/754765403489828946/vote)`)
.setColor("RANDOM")
)
})
this is my code
someone pls help
any error?
Is it necessary to use webhook to check and give rewards to voters?
The API is unreliable if you want to make everything instant
so that means webhook should always be used for that purpose?
As of right now, it's the most optimal option
You could set up some constant check towards the API. But it wouldn't be optimal at all
Very well. Thanks guys.
nope
2021-05-08T12:38:02.000000+00:00 app[api]: Build started by user herokuhost91@gmail.com
2021-05-08T12:38:46.084314+00:00 app[api]: Release v4 created by user herokuhost91@gmail.com
2021-05-08T12:38:46.084314+00:00 app[api]: Deploy ed7c31fc by user herokuhost91@gmail.com
2021-05-08T12:38:46.307905+00:00 heroku[Worker.1]: Restarting
2021-05-08T12:38:46.311161+00:00 heroku[Worker.1]: State changed from up to starting
2021-05-08T12:38:47.749202+00:00 heroku[Worker.1]: Stopping all processes with SIGTERM
2021-05-08T12:38:47.911272+00:00 heroku[Worker.1]: Process exited with status 143
2021-05-08T12:38:53.947688+00:00 heroku[Worker.1]: Starting process with command `node index.js`
2021-05-08T12:38:54.692693+00:00 heroku[Worker.1]: State changed from starting to up
2021-05-08T12:38:55.000000+00:00 app[api]: Build succeeded```
gets stuck here
@brittle spoke
how do i check that?
Firewall settings
oh
If on a local network, also make sure that the port is forwarded to the correct device
i can't login to our router TwT
i will try to contact the support service for that
Good luck
thx
@sullen nymphhttps://support.video.ibm.com/hc/en-us/articles/207852137-How-to-open-ports-in-your-firewall#:~:text=For%20PC,rules%20in%20the%20left%20side. i found this, is it what we want?
The general idea, yes
@sullen nymphsorry for pinging again but i managed to login in my router
i found out that port forward is in a section called Applications from the same site but i don't know what to do after that
it's fine if you don't know i can contact the support center later and ask them
Try to search for Port Mapping Configuration or anything similar
What's your router model?
You should be able to google "how to port forward <router model>" then
oh alr
it seems something is messing in my part, i will contact the support center and ask them why i can't see the "post forward" tab
https://portforward.com/
These guys have guides for most routers.
import discord
from discord.ext import commands, tasks
import requests
import aiohttp
from aiohttp import web
import logging
import dbl
import math
from config.config import la_couleur, lien_vote
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = "token"
self.dblpy = dbl.DBLClient(self.bot,
self.token,
autopost=True,
webhook_path="/dblwebhook",
webhook_auth='password',
webhook_port=20209,
post_shard_count=True)
async def webserver(self):
async def handler(request):
return web.Response(text="Hello, world")
async def handler2(request):
return web.Response(text="Heyy")
app = web.Application()
app.router.add_get('/dblwebhook', handler)
app.router.add_get('/', handler2)
runner = web.AppRunner(app)
await runner.setup()
self.site = web.TCPSite(runner, '0.0.0.0', 20209)
await self.bot.wait_until_ready()
await self.site.start()
@commands.Cog.listener()
async def on_dbl_vote(self, data):
vote_data = data
voter = await self.bot.fetch_user(vote_data['user'])
channel = self.bot.get_channel(824737862779273230)
em = discord.Embed(title=f"[Nouveaux vote]({lien_vote})", colour=la_couleur, description=f"{voter} vient juste de voter !")
em.set_footer(text="Vous pouvez voter toutes 12 heures")
await channel.send(embed=em)
logger.info("Received an upvote")
print(data)
def setup(bot):
global logger
logger = logging.getLogger("bot")
bot.add_cog(TopGG(bot))
top = TopGG(bot)
bot.loop.create_task(top.webserver())```
it's not working
future: <Task finished coro=<TopGG.webserver() done, defined at /home/aurore/bot discord/star bot python/cogs/dbl.py:25> exception=OSError(98, "error while attempting to bind on address ('0.0.0.0', 20209): address already in use")>
Traceback (most recent call last):
File "/usr/lib/python3.6/asyncio/base_events.py", line 1062, in create_server
sock.bind(sa)
OSError: [Errno 98] Address already in use
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/aurore/bot discord/star bot python/cogs/dbl.py", line 38, in webserver
await self.site.start()
File "/usr/local/lib/python3.6/dist-packages/aiohttp/web_runner.py", line 104, in start
reuse_port=self._reuse_port)
File "/usr/lib/python3.6/asyncio/base_events.py", line 1066, in create_server
% (sa, err.strerror.lower()))
OSError: [Errno 98] error while attempting to bind on address ('0.0.0.0', 20209): address already in use
dose anyone know free 24/7 hosting?
-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.
oh sorry
Mate
self.dblpy = dbl.DBLClient(self.bot,
self.token,
autopost=True,
webhook_path="/dblwebhook",
webhook_auth='password',
webhook_port=20209,
post_shard_count=True)
self.site = web.TCPSite(runner, '0.0.0.0', 20209)
await self.bot.wait_until_ready()
await self.site.start()
Can you explain to me what you think these snippets mean
You can use topggpy also
It is a webhook creation
Twice
-api
You tried
You may wanna just read the channel topic instead
Cuz, you know
It says exactly what that tag would
autoposter works for repl?
Hey is there anyone that can help me out with tracking votes with on_dbl_vote i have no idea what im doing and cant seem to get it to work
Anyone know where I can look for discord.py for the wrapper?
UnhandledPromiseRejectionWarning: Top.GG API Error: 502 Bad Gateway
?
what does this mean ?
what exactly are you trying to do
helo, ive moved my bot to a server but im getting the error ValueError: path should be started with / or be empty when i send a test vote D:
well, does your path start with a / ?
no , but all the things here start them with a http:// , and when i added a / i got another error 😔
I just send information to top.gg
import discord
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, autopost=True, webhook_path="http://ip:5000/dblwebhook",webhook_port=5000) # Autopost will post your guild count every 30 minutes
@commands.Cog.listener()
async def on_guild_post(self):
print("Server count posted successfully")
@commands.Cog.listener()
async def on_dbl_test(self, data):
print(f"Received a test upvote: {data}")
def setup(bot):
bot.add_cog(TopGG(bot))```
your webhook_path is supposed to be only /dblwebhook
ahh if someone remembers me the issue was that my router is a bit old and doesn't support port forword
is the error ERROR:asyncio:Unclosed client session releveant here
That's more of a warning, but you should probably find a way to close the connection
ok, how can i do that? im not getting the print even though ive changed to /dblwebhook D:
Is port 5000 open on your server's network?
how can i check?
says its open!
And you entered the correct url on your webhook page?
http://<your server's ip>:5000/dblwebhook ?
And you hit "save" after you changed the url, yes?
yep!
If you want to, you can try using topggpy instead. Made by the same person
https://pypi.org/project/topggpy/
ill have a look at it, ty!
hmm, i just keep getting client closed warnings but no prints
how can i close the session?
THERE'S vote like rewards for vote like :
if(vote) give him coins & send a message in direct for hin
I can make it
Hi
Any idea @livid orchid bot in my server offline
I am new here
I don't think that's a bot
and join the support server of the bot for that kind of questions do not ask here
i installl npm i topgg-autoposter
i use this ```const AutoPoster = require('topgg-autoposter')
const ap = AutoPoster('TOKEN', bot)
ap.on('posted', () => {
console.log('Posted stats to top.gg')
})```
for repl its show Error
What's the error
show your index.js
const ap = AutoPoster('TOKEN', bot)
ap.on('posted', () => {
console.log('Posted stats to top.gg')
})
``` your this code will be after you defined bot
Good job leaking your token
const bot = new Discord.Client()
//rest of te code
Oh seriously
okey
Well it says he used bot before it was initialized
Eugh
can i obtain username from user id without intents?
@minor pine do you realize what you're doing
What a nice answer.
Good job, you're trying to blindly copy shit and cram it into a file until it works
Instead of trying to actually figure out what's going on
You are telling my code shit ;-;
i use this for autoposter
What you NEED to do is understand that you need your OWN Client object and pass it to topgg autoposter
Yes good job that's literally a copy paste
It won't magically work because there's no bot variable that fits your use case
ok wait
Maybe you should learn and practice more
Get a grasp of basic JS PLEASE
For the love of God and all living things in this world
Save yourself the hassle of blindly copying shit
Love of God? really
Putting that aside, what does your code look like in your other file that involves a discord.js client? @minor pine
its call aoi.js
He already has a client he just needs to switch the lines for that autoposter to work as simple as that
Seemed to me as if he copied it in a separate file
And only created a bot var because you told him to
Well this
Simply copied it and crammed it into a file with the autoposter
Maybe I'm worse at explaining
You need to break it down to people like these
api bana para ver
You can't expect them to use coding knowledge because clearly they've fucking neglected the fact that coding needs learning
So true
Do you handle this daily?
Maybe he left.... after your sweet messages. Idk just a guess
I'm not the kindest person here as you can see as I prefer to be strict with people when it comes to learning
@minor pine you need to put the example you copied in your file where you already work with tour aio.js client object
What you did was create a completely isolated file where you don't have access to your aoi.js client that you use for working with events and commands and so forth and so on
You are not wrong. You only face this here but I get dms that "fix my code", "Setup this and that bot in my server" and you can't even say no, because at the end of the day you might need their help
When in fact you want to have access to the client because you will use it to identify the bot's ID
you see })
There's a polite way of saying "no"
after that line your autoposter will go
I would love to know
Because I get really tired of this
"I'm busy" 
what do you mean ?
😂 nice
mhm, i have both packages
Suggest you use either not both tbh 😛
Maybe you can directly make a post request and send the data
Preferably the newer one
ya i mean i have them both download ed
installled*
A
I'll still suggest make a post request with the topgg api direclty rather than using a package for that simple work
well when i make a post req with topgg nothing happens 😔
Me in the meantime trying to avoid packages whenever possible
cough while True: instead of python-crontab
Have you tried sending a manual request?
through another website ya
Made sure the port is open I assume?
all open
What are you trying to recieve votes?
i’m kind of an ip newbie are public ips ok to share lol
Not suggested to do it publicly, hence why I suggested DMs
Aye, no worries
Hmm
Maybe avoid sending public ips to every people.
It's a trust thing really
Yeah.
Is there are a way to get user vote cooldown?
it's 12 hours
Yes I mean time left
When a user votes just store it in some db
okay thanks
ok
Means server error
f
which server, Topgg or mine?
report where?
5xx codes are server-side issues, most of the time not being related to your input or whatever
@pastel raptor see above
But that honestly spams my logs ;-;
read
Which endpoint are you sending requests to?
Maybe catch it and fail it in silent
(async () => await someFunction().catch(() => null))();
Something like that
Ehhh
I'd rely more on the fact that the response isn't in a JSON format
Silencing all errors isn't feasible and/or advised
Then? What will be the advised way?
Parse response in JSON and if that fails, oop oop silence
Not sure what's used here and definitely not sure if you can get the response code directly in topggjs
Hmm
Oh! He was making a http request. I didn't read the messages properly I thought it was something else
kekw
Need to add many things in my bot and one of the things is keeping a cache of the votes
setInterval(() => {
topggapi.postStats({
serverCount: client.guilds.cache.size,
});
client.user.setActivity(`...${client.guilds.cache.size} guilds!`);
}, 60 * 30 * 1000); //30 minutes
Then maybe go with my solution
Because you are not directly making http request
For now it's not a permanent fix
Or maybe do something Sh#t like
Store your error in a set
And check if it is already there or not
If not log it and set it to the set
Or if it is there return
Never tried and don't know it is a good practice or bad
Because I'm really thinking to try something like that
hi this is my code:
const Topgg = require('@top-gg/sdk')
const Discord = require("discord.js")
const db = require("quick.db")
const bot = new Discord.Client()
const express = require("express")
const app = express()
const webhook = new Topgg.Webhook('somepassword')
app.post("/topggwebhook", webhook.listener(vote => {
res.send({status: 200})
bot.users.fetch(vote.user).then(async someuser => {
console.log(someuser)
if (someuser) {
someuser.send("Thanks for voting! You have recieved 200:Qp:")
db.add(`wallet_${someuser.id}`, 200)
}
})
}))
when i test the webhook, nothing happens
is this for a server?
no for a bot
only approved bots can use webhooks.
it might be easier if they ask for help then, playing a game of telephone while helping a dev is a lot harder.
i am a dev actually, but i don use that account anymore, I can come back on that acc if that's okay?
ah, then your the one developing it?
wheres it being hosted then?
home/vps/hosting site
if its at a home, youll need to port forward
youll also need to add the url and auth to the bots page(to the webhook)
me
vps
did you fill in the url and auth on the bots edit page?
yup
even when i tried voting, i was given no response
for other bot sites, it works
yup
http://VPSIP:PORTHERE/topggwebhook
^ url looks something like that? filling in vpsip and porthere(note http, not https, unless you have a valid SSL cert)
'somepassword'
auth should be ^
next thing to check would be if you have any firewalls blocking the specified port.






