#topgg-api
1 messages Β· Page 146 of 1
I don't see why it raises NameError, you don't even reference to channel anywhere, what is possible is that it'd raise AttributeError, because you started the loop even before you attach the channel to the cog
move update_stats.start to the very bottom of the init method
Hello i am trying to do a vote webhook my app for the webhook: https://tickety.top/voteapi and my settings in top.gg panel
is this gonna work?
bcs the test button does nothing
app.use('/voteapi', webhook.middleware(), (req, res) => {
console.log(req.vote.user);
});
@sullen nymph
?
i used the same code and it said
attribute error: nonetype has no attribute send
You need to load the cog after the bot is ready
or just get the channel after the bot is ready
oh ok
so
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
try:
client.load_extension(f'cogs.{filename[:-3]}')
except commands.errors.NoEntryPointError:
pass
inside
on_ready
it worked thanks
You could also do
@update_stats.before_loop
async def before_update_stats(self):
await self.bot.wait_until_ready()
self.channel = ...
oh well, no problem
how would i do an on vote
It might be complicated at first, but it's pretty easy once you get the hang of it
ok
You don't get it, you make it
Think of it as a password, do you get the password from somewhere else? No, right? You create your own password
ah, so can i put any password?
It was not..
Sorry?
is not sending the webhook on the channel after clicking test
Well, that's not related to Authorization whatsoever
I will remove this, thanks for the help
Does anyone know how to setup the authorization stuff with Nginx?
You wanna block if it's unauthorized or you wanna pass the original authorization header? If it's the former, can't you do
if ($http_authorization != "the auth") {
return 401;
}
!play emi 112
Ok thanks for the help!
If you wanna pass it instead, ig you can do proxy_set_header Authorization $http_authorization;, not sure but give it a shot
not even sure if it's not passed by default, ig that's redundant 
@restive otter So I tried it but it didn't work, it would send with a right and wrong one.
Where would it be because I put it in the server section of the Nginx sites-enabled file
Hello @restive otter can you help me?
Have you reloaded nginx?
Yes
Wdym?
I tried putting this into my sites-enabled file and it isn't blocking wrong auth codes
HELLo
how do you make it send webhook to my channel when someone upvotes i cand understand documentation bc im not good at reading
what do i put in authorization
its like the 5th time im asking it
Hello, does anyone know how I should change my voting webhook so that it is comptaible with sharding?
Right now it runs the webhook on all of my separate shards, but this throws an error saying that address is already in use, but I need a client in order to use a webhook. Any ideas?
bro, you can't tell me ?
Hello, I would love to use your API to post a message when there is a new vote on my bot, but I can't. Could you help me or give me the code?
read the link above
Yes I read but I do not understand, in addition I speak French so that does not make things easier
does it take some time for changes to the webhook url to update? i saved it, it worked during testing, but the change didn't do anything at all for users
have you replaced id with your bot id?
it's not a good idea to add logic like this inside nginx. Especially not if statements. Just don't use if in nginx lol
How can I post the shard count with autopost?
// Make sure to install this with 'npm install dblapi.js`
const DBL = require('dblapi.js');
// The webhookPort can be whatever you want but make sure you open that port in the firewall settings (for linux for example you can use `sudo ufw allow 8000`)
// The webhookAuth is set by you, make sure you keep it secure and don\'t leak it
const dbl = new DBL(config.API_TOKEN, { webhookPort: 8000, webhookAuth: 'password' });
// When the webhook is ready log it to the console, this will log `Webhook up and running at http://0.0.0.0:8000/dblwebhook`
dbl.webhook.on('ready', hook => {
console.log(`Webhook up and running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
// This will just log errors if there are any
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
// When the webhook receives a vote
dbl.webhook.on('vote', async vote => {
// This will log the whole vote object to the console
console.log("someone voted lol")
console.log(vote)
// Get the Discord ID of the user who voted
const userID = vote.user;
// If the channel to send messages in exists, we send a message in it with the ID of the user who votes
vote.user.send("Thanks for voting! $20 has been added to your balance.")
})```
is there something i can replace dbl with?
with somethign that isnt depreciated?
any suggestions please
Can't you just use https://npmjs.com/@top-gg/sdk
dblapi is this ^ It's been redone as a whole
alright
so should i just replace const DBL = require('dblapi.js'); with the new one?
Read the page
Make a webhook server
const express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express() // Your express app
const webhook = new Topgg.Webhook('topggauth123') // add your top.gg webhook authorization (not bot token)
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
// req.vote is your vote object e.g
console.log(req.vote.user) // 221221226561929217
}) // attach the middleware
app.listen(3000) // your port```
np
const express = require('express')
const Topgg = require('@top-gg/sdk')
const api = new Topgg.Api(config.API_TOKEN)
const app = express() // Your express app
const webhook = new Topgg.Webhook('password') // add your top.gg webhook authorization (not bot token)
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
// req.vote is your vote object e.g
console.log(req.vote.user) // 221221226561929217
console.log("someone voted lol")
// Get the Discord ID of the user who voted
const userID = vote.user;
// If the channel to send messages in exists, we send a message in it with the ID of the user who votes
vote.user.send("Thanks for voting for Jimmybot! 20 treats have been added to your balance.")
}) // attach the middleware
app.listen(8000) // your port```
would this work
i tested it and I'm not getting a console log
how do i check if a user has voted for my bot? Do i need to use a datastore or can i check it through the api
check it through the api, it's documented there
Oh, interesting. I was just going for a quick dirty approach. What's so bad about if statements? Does that mean you should handle the authorization on the proxied server?
look up "nginx if statements are evil"
Oh, it's even in their wiki 
they lead to a bunch of bugs and it's a good idea to make that check on the application side and use nginx as a reverse proxy instead
I see, didn't know about this. Thanks for telling
Does top.gg API has any voting reward system? If so, do you mind sending the Direct link for the needed docs?
This link is the home page
I searched on it about what I want
And couldnt find
Where do I get the URL that I want a webhook to be sent to so that I can receive it?
It's your bot's IP + port
How do I get that
Where are you hosting?
My laptop
Then it's your IP. Google "my IP address"
Alright ty
You should probably think about using a vps tho π¬
Make sure it's the right port, and that it's open on your network as well
What doesn't? The webhooks or the server count? Have you put your webhook url on your top.gg page? Is the port open?
https://cdn.discordapp.com/attachments/412006692125933568/828875519369543690/Screenshot_20210406-081337__01.jpg
What doesn't work? The server count posting or the webhooks?
I don't know python but it's set to post the server count every 30 minutes by default (recommended). Maybe try reducing that to 1 minute just to test. But set it back to 30 if it works.
You don't need the asyncio.sleep since you're using tasks.loop
Yeah, read what the comments say
Don't just blindly copy and paste
Every time a user votes, save the timestamp from the voting webhook event to your db then every time they run the command check the db for their ID and time since last vote. Or hit the api, but that's probably not ideal.
You can see who voted at https://top.gg/api//bots/<your bot id>/votes
Remember to pass in your DBL token as a header as well. But yeah, you need your bot to be approved to access that
?
Personally I prefer to use timestamps in my db to avoid spamming the api but that's up to you
You need to create a webhook listener yourself to use webhooks
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
You can use this to create one with the library. The port needs to be open for it to work though
Yes, my bot is not approuved
Hello i am trying to do a vote webhook my app for the webhook: https://tickety.top/voteapi and my settings in top.gg panel
is this gonna work?
bcs the test button does nothing
app.use('/voteapi', webhook.middleware(), (req, res) => {
console.log(req.vote.user);
});
well
why this doesnt work
what does that matteer?
are you 100% sure,
yes
what happends
if i click
the test button
in the top.gg dashboard
what should happen
i changed it
hmm
i am curious if something has changed
didnt change any
@restive otter
weird, i tried to post and it worked
auth
token?
this
oh
what about the url
app.post('/voteapi', webhook.middleware(), (req, res) => {
console.log(req.vote.user);
});
i mean the webhook url
ok so you need to fill your auth pass
it should be like this
how to validate it
you can change topggauth123 to anything you want
where do i put my token?
yup
its fine
like error 404
let me vote
huh it says
undefined
if i vote
@restive otter
app.post('/voteapi', webhook.middleware(), (req, res) => {
console.log(req.vote.user);
});
bro i cant restart my bot hole the time
Β―_(γ)_/Β―
weird
nothing get logged
idk why
π
its the same code
what version of @waxen widget-gg/sdk you use
discord
look at package.json
"@waxen widget-gg/sdk": "^3.0.9",
app.post('/voteapi', webhook.middleware(), (req, res) => {
console.log(req.vote);
});
my current code
that does nothing
Do you not need a port in the js lib?
their webhook works but the user id doesnt get logged
And you're reading the response as json?
I think you need a port
Reis
i did console.log(req)
@restive otter
that happends when i do console.log(req)
how is that possible
idk
can you tag someone you know
can fix it
@fresh plover
@restive otter
maybe is other code blocking it
const app = express();
app.set('views', __dirname + '/views');
app.set('view engine', 'pug');
app.use(favicon(__dirname + '/logo.png'));
app.use(rateLimit);
app.use(bodyParser.urlencoded({ extended: true }));
app.use(methodOverride('_method'));
app.use(cookies.express('a', 'b', 'c'));
app.use(express.static(${__dirname}/assets));
app.locals.basedir = ${__dirname}/assets;
app.use('/transcripts/id=:id', (req, res) => res.sendFile('/home/container/web/transcripts/' + req.params.id + '.html', function (err) {
if (err) {
res.render('errors/404');
}
})
);
app.post('/voteapi', webhook.middleware(), (req, res) => {
console.log(req);
});
Does this code work?
Can I post the shard count with autopost in py?
You can install the sdk from the source, it has shard count autopost support. If you have set up a webhook, make sure to check the source code as there's a breaking change
Or just wait until shiv releases v1
what are the rules withe the API
as in i would like to put my bot on top.gg, but i need to make sure that the bot follows the rules...
Explained in the docs at docs.top.gg and #rules-and-info
okie, thx
@Kayex
There is also a guild section for top.gg where can i get the docs where it is written for guild. Like getting events when someone votes for the server
I am specifically looking for python docs
and please ping me while answering my question
well they have webhooks tho
How do I use the authorization header with Nginx?
Is that everything I need?
Can someone help me?
why not put that in your main file( i guess its bot.js)
I tried, didn't work.
what error do you get
None
Shit
also be sure that you filled the token part correctly
umm
people
I got this```js
const DBL = require('dblapi.js');
const dbl = new DBL(apiToken, { webhookPort: 9008, webhookAuth: 'BTSsucksLikeWtf' });// in webhookport: 9008, replace the "9008" with your host's port. in "AnyPassword" u can choose a random password.
dbl.webhook.on('vote', (vote) => {
console.log(${vote.user} has voted me!)
const webhook = new Discord.WebhookClient("821184990104518716","la_KOaHOMUlybKlF897jozaBCL8kZDbMdlEx7LPsHL-xSpWGu1XDmFMp-3Io2B7cb1ZY")//replaces with ur webhook information
webhook.send(<@${vote.user}> (\${vote.user}`) has voted me!`)
});
dbl.webhook.on('ready', hook => {
console.log(Webhook up and running at http://${hook.hostname}:${hook.port}${hook.path});
});
and it does say its connected
but when I vote
it doesnt do anything
and no errors pop up
I tryed fixing it but I can't.
if u gonna help me please ping me.
π
Iβve waited 1 hour and still nothing
@fading mica
Refresh data?
And did it say this in console?
@delicate badge
Well if it didnt say posted stats on top.gg ghe there is something wrong in code
Also
Put that code in the script which u run the bot with
I did
And there shouldnβt be anything wrong with the code, I copied it directly from the website
Where did u place your code?
And did u put the correct token?
Under client.on ready?
Place it under "client.on("ready")"
Bruh u dont have that code already? I thought u did lmao
Remove that and post top.gg code at the end of the script then
Okay
When i run this file with node shard.js i get no error. I'm not exactly sure whats wrong other then that it is in the top.gg api area. If someone could help that would be awesome
Hey guys
I just set up my top.gg webhook
as per the instructions on top.gg
Now my bot will be receiving post request
but before that what will be my webhook url
To be set in the top.gg page
Are you hosting your bot on a VPS?
No
Then I'm guessing you're hosting at home.
So the url would be <your home IP>:<port>/<your webhook path>
where's the port when I type ipconfig in commandprompt
i know the ip is the IPV4 thing
There's no one singular port for your ip
you'll need to forward the port you want yourself
Something here?<your home IP>:<port>/<your webhook path>
how do I do that
Look up port forwarding
-servercount
To have your bot's server count displayed on Top.gg, please read the documentation on server/shard posting.
i need dashboard creator dm me
what language?
The API just breaks
const Topgg = require("@top-gg/sdk");
const { ShardingManager } = require('discord.js');
const config = require("./BotData/Settings/Settings.json")
const discord = require('discord.js');
const shards = new ShardingManager("./bot.js", {
token: config.token,
totalShards: "auto"
})
console.log('Sharding Manger Done.');
//On startup
shards.on("shardCreate", async (shard) => {
console.log('Shard Startup Successful');
console.log(`[${new Date().toString().split(" ", 5).join(" ")}]Launched shard #${shard.id} successfully`);
// Top.gg Bot Stats API
console.log('Loading Top.gg API');
const client = new discord.Client() // Your discord.js or eris client (or djs ShardingManager)
const AutoPoster = require('topgg-autoposter')
const ap = AutoPoster('top.gg token here', client)
ap.on('posted', () => {
console.log('Posted stats to Top.gg!')
})
console.log('Bot online now.');
});
//spawning
shards.spawn(shards.totalShards, 10000);```
please fix the vote webhook system see in this logs 1 guys vote logs 6-7 times
Are you using the node SDK?
I am using python
How are you receiving the requests?
What the fuck
:/
How long has this been happening?
from last 1 month
Try responding with a 204 instead
i reported this before
Are you voting or pressing Test?
its voting
not testing
thats not me
in the ss
see this i also try to vote and for me too its get multiple votes
also getting multiple rewards
i have a question , Can I use a discord webhooks to get the votes ?
No
ok yes i just found out lol
and what about the webhook auth
do i have to make one ?
For JS
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'my dbl_token'
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='auth password', webhook_port=5000)
@tasks.loop(minutes=30.0)
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count"""
ch = self.bot.get_channel(ch_id)
await ch.send('Attempting to post server count')
try:
await self.dblpy.post_guild_count()
await ch.send('Posted server count ({})'.format(self.dblpy.guild_count()))
except Exception as e:
await ch.send('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
@commands.Cog.listener()
async def on_dbl_vote(self, data):
ch = self.bot.get_channel(ch_id)
await ch.send(data)
@commands.Cog.listener()
async def on_dbl_test(self, data):
ch = self.bot.get_channel(ch_id)
await ch.send(data)
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))
i Used This Example From The Docs
It Works Completly Fine With Posting the server counts
but when it comes to the on_dbl_vote and on_dbl_test , it doesn't trigger anything
Can Someone Help Me With That !
Are you sure you entered the correct IP, and that the port 5000 is open on your network?
i used replit
would that work
I successfully got the api to work and I feel accomplished
Hey new
webhook is not sending the voting log
const Topgg = require("@top-gg/sdk");
const webhook = new Topgg.Webhook("mywebhookishere");
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);```
is there anything missing?
hello i have a question how long i need to wait to my bot is verification
+collect
+collect
can someone help ,
all i get is This On My Console
[07/Apr/2021 16:12:47] "POST /dblwebhook HTTP/1.1" 404 -
which is triggered when i click the test button
token = "token"
path = "https://top.gg/bot/735462457061015623/webhooks"
hook = dbl.DBLClient(token=token, bot=bot, webhook_path=path)
@bot.event
async def on_dbl_vote(data):
print(data)
The on_dbl_vote dont work ...how can i run it ? Hey dont give me any data, if i voting the bot.
uh what
replit url
Your webhook_path needs to be a route
oh a root ?
You can and you should with repl
Set webhook_path to a route that you will use locally
it doesn't work though ;-;
can oyu give me a example ? i have problems to understand it right.
did i need a discord webhook for that ?
yeah i used replit url to set my webhook
Fucking hell do y'all have any experience with webservers to at least know what a route is
Do you know what a webhook is
huh ?
i dont understand it rightly...thats my problem.
token = "token"
path = "https://top.gg/bot/735462457061015623/webhooks"
hook = dbl.DBLClient(token=token, bot=bot, webhook_path=path)
@bot.event
async def on_dbl_vote(data):
print(data)
i dont know what i need, that this is working...
A webhook in web development is a method of augmenting or altering the behavior of a web page or web application with custom callbacks. These callbacks may be maintained, modified, and managed by third-party users and developers who may not necessarily be affiliated with the originating website or application. The term "webhook" was coined by Je...
The webhook_path that you need is a /route that comes after the IP and port OR domain in your URL
In http://0.0.0.0:5000/route
/route is the webhook_path here
and also your DBLClient isn't a webhook by itself, so it's better to name it appropriately, something like dblpy
or dbl_client
And, as it seems
someone hasn't read the docs
Nevermind, that's not explained anywhere other than https://github.com/top-gg/python-sdk
see the webhook example
In order to run the webhook, at least webhook_port argument must be specified (number between 1024 and 49151).
Thanks for your help. But you can really let go of that presumption, claiming that I haven't read the docs. I said that I have problems understanding it. Now I have understood it to some extent and will try the docs you sent here.
I will let you know if I made it.
Don't pay much attention to those, my soul has had enough of today to feel exhausted as hell
Anyhoo, to rephrase my point, you need to set webhook_port to something to actually run it
Stuff like path and auth is optional, but recommended
Hi, I think I was already trying to solve this issue here but didn't really manage to resolve it. All of the sudden I started getting those "user aborted request" error from I don't know where, which keep happening until the app crashes with "possible memory leaks" issue. Any ideas about it's origin?
@sullen nymph this should automatically post server count stats to the Top.gg page, right? https://i.imgur.com/LXdyUUj.png
Yeah
the fuck 
I'm planning to add on_autopost_success and on_autopost_error events as a replacement for on_guild_post
oh, is the first arg of DBLClient() supposed to be an int?
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='http://0.0.0.0:80/home/runner/bot/dblwebhook', webhook_auth='', webhook_port = 80)
something like this ?
Oh hold on I'm dumb
;-; ok
Eh no, I don't recall dblpy using the bot object to get its ID in the first place so disregard that
Try posting manually via commands.ext task
hm
Hi
the root thing didn't work for me
i used simple url and it worked
thank you
E
and .... now i have another question ;-;
{'bot': 'bot_id', 'user': 'user_id', 'type': 'test', 'query': '?test=data¬RandomNumber=8', 'isWeekend': False}
what does the query and isWeekend refers to ?
query
https://top.gg/bot/yourbotid/vote?allthatishere=query
isWeekend returns true if it is Friday-Sunday
can be used for things such as double rewards
Where can I find a webhook password?
oh ok thank you !
youtube api is fun, rip realtime however maybe theres a new one for the new feature
I have just implemented sharding on my bot and it is currently using two shards, but on top.gg it says only 1 is being used. Is this something to worry about?
@fluid rock
your api is amazing
yes
How can I give something to a user when they vote for the bot? I mean, how do I give them coins for votes?
How To Fix The Webhook Glitch
Which library are you using?
I Am Using Superagent
elaborate please
What can one do if they get a bot's topgg token?
Hmm ty
That's unlikely to happen though since staff will try to contact the owner and the owner will reset their token
yea
Wcash
thanks
did you respond with 2XX
yes se above
@tepid thunder did you close the connection
we only retry on 3 things
- Network Exceptions
- 5xx Status Code
- Timeout of 5 seconds hit
@elfin solstice check the code
i don't write python
either way
its working for everybody else
its definitly something on your side 
no shivaco check my code he told my code is perfect
no it wont append this before this is happning after you rewrite the vote/webhook codes or whatever
yea cause before the rewrite it was literally hella broken
retrying was broken
it only accepted 200 as response
and more
randomly dropping votes
etc. etc.
its working and i can only tell you to ensure your code is not running for longer than 5 seconds
thats most likely the issue here
Are you using aiohttp?
yes
Try using return aiohttp.web.Response(text=json.dumps({'status': 'success'}), status=204) instead
@night ingot like this
Yeah, I suppose you could just do text='success' as well, if you don't want to return a json object. But shouldn't matter
how are you importing aiohttp? Just import aiohttp?
that's pretty weird
yeah I think @sullen nymph is gonna have to help you. I'm clueless tbh
aiohttp definitely has a web attribute, so I'm not sure why that's happening
the api.getVotes() will notify when a user upvote?
it gets the last 1000 votes
app.post('/dblwebhook', wh.middleware(), (req, res) => {
// req.vote is your vote object e.g
console.log(req.vote.user) // => 321714991050784770
})
``` ohh, this code will notify?
alright, thanks :)
hmm?
and how will i get to know that i am rate limited ?
you will get 429
ah yes ... thanks :P
const { Webhook } = require('@top-gg/sdk')
const express = require('express')
const User = require("../mongoose/User.js");
module.exports = async (client, config) => {
if (!config.api.dblWebhookToken) return console.log('Please enter top.gg webhook api (optional)')
const app = express()
const wh = new Webhook('myBotAuth')
app.post('/dblwebhook', wh.middleware(), async (req, res) => {
const findUser = await client.users.fetch(req.vote.user);
if (!findUser) return;
let userdb = await User.findOne({user: findUser.id});
if (!userdb) return;
userdb.tofus = userdb.tofus + 100;
console.log(`${findUser.tag} upvote! +1`)
})
app.listen(3000);
console.log(`top.gg upvote notify ready`)
}
``` is this code right?
i try voted, but not send on log
(nothing happen)
hello i have some questions !
is their a way that i can detect a server votes ? , if so , can i use webhooks for that ? , and does that server have to be mine or it can be someone elses?
you can use webhooks, not discord webhooks however.
top.gg webhooks are not compatible with discord webhooks.
i already tried the webhooks with voting ,
is it the same ?
yes
oh okeh thank you
My servers aren't updating and its not sending messages to the channel?
import dbl
import discord
from discord.ext import commands, tasks
from discord.ext.commands import Cog
import asyncio
import logging
class TopGG(Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = '' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token)
self.update_stats.start()
# The decorator below will work only on discord.py 1.1.0+
# In case your discord.py version is below that, you can use self.bot.loop.create_task(self.update_stats())
@tasks.loop(minutes=30.0)
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count"""
channel = self.bot.get_channel(828240894800560128)
await channel.send('Attempting to post server count')
try:
await self.dblpy.post_guild_count()
await channel.send('Posted server count ({})'.format(self.dblpy.guild_count()))
except Exception as e:
await channel.send('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))```
Hey im confused on how I am supposed to use the webhook to get when someone votes for my bot. There are not many python examples on the internet that show how to do this
What have you tried so far
Iβve tried to use the βon_dbl_voteβ thing in the documentation but I started reading about the webhooks and now idk what to do
What part confuses you?
the link i need for the webhook
The link will be your public IP, the port you're running the webhook listener on and the path
so <public IP>:<port>/dblwebhook for instance
im running my bot on a server though, so should i replace the public ip with the hostname?
it'd be the IP of the server then, yeah
Ok i'll try that
remember that the port you've chosen needs to be open as well
Don't forget http://
right ^^
How to make the bot assign the user a role after leaving a reaction?
#development if it doesnt apply to the top.gg api
Sorry
ooof
self.dblpy = topgg.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth= auth, webhook_port = 5000)
doesn't work with topgg module
but with dbl it works fine
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth= auth , webhook_port = 5000)
why is that ?
i upgraded dblpy also
Well where are you getting that example from
idk i just updated the lib , and tried that
that my example , i mean it works when i was using v0.4 , but on v1.0 , the event on_dbl_test doesn't trigger anymore
the webhook works but it gives me 404 , but only when i used topgg module
cough v1.0 has significant changes I haven't documented very well publicly
Unless you can read the whats_new file (Sphinx format) it's probably worth giving a try to read the source code since everything that's supposed to be used has a docstring
ok i'll try
How can i make when someone vote me the bot send message in the channel in my server
Ping me when u want to help me
what do i do in api?
c
i read this doc about v1.0.0 guess i have to use aiohttp session
but that didn't go as well for me , any help ?
https://dblpy.readthedocs.io/en/latest/api.html#client
:/
(node:3088) UnhandledPromiseRejectionWarning: Top.GG API Error: 504 Gateway Time-out
at Api._request (C:\Vox\Hideaki\node_modules\@top-gg\sdk\dist\structs\Api.js:76:19)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Api.postStats (C:\Vox\Hideaki\node_modules\@top-gg\sdk\dist\structs\Api.js:96:9)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:3088) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3088) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
...
Is it even close how it should actiauly be looking like?
also idk if 0.0.0.0 is what is should be.
idk my port... π¦
do I need to do a portforward?
right?
0.0.0.0 is not a proper ip
then why are you entering the 0.0.0.0 in there?????
my is is... wait do u need it?
ignore what your bot says
console.log(`Webhook up and running at http://${hook.hostname}:${hook.port}${hook.path}`);```
bruh
ik what webhooks are
just my first time working with APIs.
so wait, how do I know my port?
I cant find any...
I tyed like 50 ports today
and olike 80 yesterday
Is there a software that like... looks ur ip is all ports, and finds it for you?
you're really confused about basic networking, about how ports work etc
please read more about how a port works and networking in general, as that is quite important for working with webhooks.
how do you know I am? ...
wait
I do know how the work
its a connection between computers
devices
0.0.0.0 is not a proper ip
"list all ports" is not a thing when choosing ports
But how do I know MY port?
You need to open it, please read up on how basic networking works
fine.
The one for your library
whichever one works with your library
I read the news site about slow/failing votes and it states it's fixed. I'm getting dozens of reports that people didn't get vote rewards and I got log for only like 1/5 my test votes. Sooo, still undergoing some problems?
seems it's getting better, it were dozens of reports about not counting votes from past few hours tho
hey.... i cant autopost server count it gives an error : "object Lock can't be used in 'await' expression" can anyone help??
i m using discord.py
One message removed from a suspended account.
e
One message removed from a suspended account.
You'll have to downgrade to Python versions below 3.9
Or clone the Git repo but it has significant changes that might break your bot
ohhhk ty
P.S. v1.0 (aka the one on GitHub) fixes that
hmm..... i will downgrade python version
Do you know how to check if someone voted for my bot using top.gg/sdk without a vps ?
my bot is in 15 servers but it still show N/A why??
π΅ π ΎοΈ π¬
-servercount
@heavy crater
To have your bot's server count displayed on Top.gg, please read the documentation on server/shard posting.
yes, read the docs, you can use the hasVoted endpoint of the users section to get a users vote state
thank you
umm no can you teach me?
how do I connect the votes with the webhook it didnt work with me
djs?
Hi, i've posted my server count using bot.dblpy.post_guild_count() on my discord.py bot, it raised no errors but servers don't appear and the widgets won't show anything, is there anything i have to enable?
the ports that are in use it seems
Ah it's showing up now, i think i had to put await before that
it's a coroutine so would be a good idea 
Should this API work I have tested it and it is not working (I use discord.py)
`#DBL API
class TopGG(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.token = "My DBL token" # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes
@commands.Cog.listener()
async def on_guild_post(self):
print("Server count posted successfully")
def setup(bot):
bot.add_cog(TopGG(bot))
#DBL api end`
Sorry that the code it looks like a mess
I want to check if a user has voted for server
url = f"https://top.gg/api/bots/{server_id}/check?userId={user}"
will this help?
DSL doesn't have an API
So no way?
Not without webhooks and storing them locally
does anyone know how to get the money here?
-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.
Sa
-servercount
ok
Good evening,
I always get an error when I work with the server count. I use Python 3.9, can someone help me?
are you trying to use multithreading + asyncio?
I don't think that's how it works-
I have copied it 1 to 1 from the website
hey, how does webhooks work?
How do I send a message whenever someone votes using webhooks? I use python
i keep getting this
at=error code=H14 desc="No web processes running" method=POST path="/dblwebhook" host=messagetracker.herokuapp.com request_id=04e2dd7e-d912-40de-9c11-5d1d04cf7fcf dyno= connect= service= status=503 bytes= protocol=https
how do i tell it what url to use? (instead of IP)
Hmm so I need express to receive the vote and I cant directly do like api.on('vote', () => {})?
you cant use it like that
check pins
wgats the webhookauth?
in the pins
topggauth123
the password you choose
This is the only possible way?
yeah
So i need to add the server link in WEBHOOK url in https://top.gg/<bot_id>/webhooks and then where do I get the password?
http://0.0.0.0:port/path
where 0.0.0.0 is your machine's IP address
port is whatever port you run the webserver on
path is the route to use specifically for top.gg requests
as for the Authorization/password, you create it yourself
How
since that's what it is, a password you use to confirm that requests are coming from top.gg
Well, how do you create a password? You come up with one, and then enter it somewhere
I'm new to express
How do u create a password exactly
Store a random password in .env
Are you using the top-gg/sdk package or express
Then use it where
Both?
express recieves the vote
So I guess you're using topgg.Webhook
where topggauth123 is just the example
You store the password wherever you want and enter it in the Webhook constructor
Yup
here
I have no specific path, it is probably the root. Should I leave it blank?
@smoky swift @fresh plover
...
If you're using the default example, it will be /dblwebhook
dude really ghost pinged bean .-. also why not just ping shiv?
When did I?
const topgg = require('@top-gg/sdk');
const express = require('express');
const app = express();
const webhook = new topgg.Webhook(process.env.TOPGG_WEBHOOK_PASSWORD);
app.get('/', (req, res) => {
res.send('hello world');
});
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
res.send('one req');
console.log(req.vote);
});
app.listen(3000); ```
URL: m.y.i.p:3000/dblwebhook
Passwords are same.
doesn't log
I tested the webhook by pressing the testwebhook
localhost:3000 website says helloworld
myip:3000 website doesnt losd
Don't forget http://
:0
Make sure port 3000 is open
Router settings + firewall settings
This is the only code @sullen nymph
How to check the router settings
Btw how do I get my ip address? @sullen nymph
I just got it in mongodb, network access
Since you are hosting it locally you could either get it via ipconfig or websites like "what's my IP address"
Google your router model
Forward port 3000 to to your device
how to get the time remaining to vote?
will api.getUser(id) return that?
@sacred shell @proud cloud
@fresh plover @smoky swift
Do Not Disturb
You pinged me once
uhh
you have to store that yourself in a db or whatever
That was more than enough. Stop pinging everyone and be patient.
how to get the time remaining to vote? Does api.getUser(id) return that
The API doesn't show when a vote expires
from what I know you have to store the time when someone votes and then obviously u can take the time from your db +12h
No other way other than tis?
That'd require webhooks, which isn't exactly what's being discussed
ohhhhh sry then
Correct
Still helpful tho Tog you're cool
dont mind me
@sullen nymph hello sry for ping, u there?
more or less
How so?
I got a ping here apparently
and I might be able to guess why and from whom
@craggy sentinel oi bro mind taking a wee look in logs for a ghost ping here?
@sullen nymph Dash#7374 ghostpinged you
Of course he fucking did
So is he gonna get a warning to stop ghost pinging or what
@winter tusk if you need help for anything, be patient and wait for responses, ghostpinging just doesn't help
If you continue ghostpinging, i will mute you
:0
Sorry
Is there any way to check the time remaining to vote for an user either manually or via the api? I can't use webhooks without webhooks how can I?
So u think if I suggest it, will that be made?
No suggestion channel?
@rain heart I'm new to webhook thing, is there any way I can use the webhook without express
i doubt it will be implemented, as you can simply do that with webhooks
I cant use express coz.
herolu only allows 1000 hours (41 days) per month host, if I use express, I need 2 working thing called dyno, and only 20.5 days hosting will be available
Heroku*
So I cant do it rn?
Any suggestions?
NO PAYMENT
only free
none
DO offers credits, which you can use to rent a VPS
offers credits?
What tut mean?
DigitalOcean's sorta currency
Btw I didn't intent to ghost ping u.
Intend*
I sent a msg
waited 3 mins
U didnt reply
I wanted u not to see that msg anymore
So I deleted
Sad
You usually rent a VPS on a monthly basis
that VPS will cost you X credits per month
@rain heart Ig I got something, can u say does that work?
api.getVotes() returns all the votes,
so if a user is there, Can I say that he still has the vote cooldown?
yes
@rain heart well another thing in my mind.
On Bot login, getVotes() and then upload to db.
SetInterval 30mins, and checkAgain getVotes(), if the array length differs and one voted is missing, I can say that user's cooldown is over right?
can't help with that, have no js knowledge
sad
Only 1000?
if I get 1000 members, some1 would donate and I can get a fking VPS
One single soul would donate
Possibly
You haven't put your dbl token in there
You haven't put your dbl token in there
@quick needle guys I don't see the create Web hook option in my discord server?
What do I do
Why have u pinged me
How do I create webhooks
read the docs
Yea but I don't see the option to create a webhook
because you need to use code to make one
Guys, how can I see who voted for my bot on top.gg? Please ping me when you respond.
@rain heart
I have been looking there for a while but I donβt see what I am looking for, where can I locate it on the docs?
@rain heart?
Ok
Send your code
Hey
Can anyone help me
Δ° want to learn who woted my bot
Δ° saw webhooks on the Website but i can't understand anything
How can i setup the webhooks?
Δ°f anyone can help me plz ping me
poto
(node:8044) UnhandledPromiseRejectionWarning: Error: 401 Unauthorized
Why do i see this in my log when i run a command which checks if a user has voted for my bot?
have you tried this? https://docs.top.gg/api/bot/#individual-user-vote
const Topgg = require("@top-gg/sdk");
const express = require("express"); const app = express();
const webhook = new Topgg.Webhook("your webhook auth");
app.post("/dblwebhook", webhook.middleware(), (req, res) => {
db.add(`balance.${req.vote.user}.wallet`, 5000)
console.log(req.vote.user);
}); app.listen(80);```
Is this correct for rewards?
Make sure you send the top.gg token along with requests
If you do, try refreshing it
@sullen nymph Can you tell me about this
Idk, is it? Why not try and see for yourself?
can checking if a user has voted for my bot get me ratelimited?
It can. That's why webhooks are highly recommended
I am planning to make some cmds require voting to use, avt 3 cmds from each category of my bots cmds, which will be the best way to check if a use voted, currently i am just using the api to see the bot voted, i have a webhook for vote logs i could just maybe store the users id in my db and check later with my db
So what would be the best way
Req the api or using my own db
I am thinking abt the db option as if a user spams the cmd, i can
Get ratelimited
Correct. Storing the votes locally is the most viable option in this case
Ye ill just do that
Better than having to request the api everytime
Thanks for the answer

@sacred shell multiple channels
I want to see when someone vote for my bot but it doesn't work :
const Topgg = require('@top-gg/sdk');
const express = require('express');
const app = express();
const webhook = new Topgg.Webhook(config.AUTH_PASS);
const api = new Topgg.Api(config.tokenDBL);
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
console.log(req.vote.user + " has voted")
})
app.listen(<Port>)
What do I have to write here
YES I KNOW NOW !!!!
I'm so happy...
π
But I can't send something to the user.
I tried :
client.users.cache.get(req.vote.user).send("Thanks")
I have this error :
......(I don't see the error ^^')
Oh it works
I don't know why it didn't work before
I want to hug everyone i'm so happy ^^
I'll have a good laugh if you're gonna become the person who fixes their errors by themselves by the time someone responds
how do you get your bot's status to show on dbl as online?
You can't as of now
ah is it a feature relating to the bot being in here?
No, just not changeable
what else is there then guild count post?
shard
Shard count
@commands.Cog.listener()
async def on_dbl_vote(self, data):
await self.bot.owner.send(str(data))
doesnt work
bot.owner does work
bruh
Just alike meππ
Are there any webhooks for server voting?
If it does exist, could someone point me to the docs link foe server related endpoints, as I'm not able to find it
Never mind, its just an alternate payload
That means you have the wrong token
I tried top-gg/sdk and doesn't do anything I tried top.gg and it says 400 error
Now I'm trying axios and says 401 error
Did you provide your token in the headers?
For posting server count you need to provide the token
Okay the field called Token or what?










