#topgg-api
1 messages · Page 123 of 1
if only I could unreproduce it lol
@main prairie if on ready you do const ap = new AutoPoster.DJSPoster('token', client)
is the const ap important?
yea I saw that, with the ap.on
i mean you could just
AutoPoster(...).on('posted', () => {})
without defining it kekw
but yea u dont need to
but try using the structure built
yea I did copy paste it, then just edited the token to make use of my index.json file, apart from that nothing should have changed, that's why it's weird...
Also it worked yesterday, so my bot is now marked with the right number of servers, just not updating
I'll play around with it, maybe there's something small I changed by accident or something silly
again ty for the help!
yeah for sure
Is it possible to set webhook server in runtime rather than providing it when dbl object using DBL class itself in dblapi.js?
What I mean is whether something like this is possible
const dbl = new DBL('token');
dbl.someMethod(/* stuff about webhook server */);
``` Instead of
```js
const dbl = new DBL('token', { webhookServer: serverObject, webhookAuth: 'some password' });
you could create an actual webserver, but idk about creating at runtime
ah
isn't there something like that on the docs?
Well, I'm just gonna uninstall dblapi.js and gonna install @top-gg/sdk since I only need webhook and I need to get dbl object in 3 shards for doing some stuff which is why I wanna assign webhook details later on runtime rather than at start
Is there a way to post server count without using dblpy module in python?
you could send the api requests manually.
not manually, but with whatever http requester you want
Probably will use requests module then
use aiohttp please
Oh ok
Wait, is it like 100% must-use module?
Like it’s a better way to use aiohttp
dblpy isn't must-use
aiohttp is more recommended since it's actually asynchronous and fits discord.py better
Probably should switch to aiohttp then... I used requests only
Mhm
I think there is no a big difference in their syntax 🤷♂️
Eh, a fair bit but in the end it's worth the migration

const DBL = require('@top-gg/sdk');
const webhook = new DBL.Webhook('topggAPIAuth')
app.post('/dblwebhook', webhook.middleware(), (req,res) => {
console.log('We have arrived.')
console.log(req.vote.user)
})
app.listen(<port number>, () => {
console.log('Listening');
});```
Why doesn't it work? I don't get any errors, the webhook just isn't triggered.
my bot is attached to the site but it does not appear here
Pls help
is it approved?
no

How to do the vote requirement command?
use a database to store users' last vote
there is /check endpoint
!help
maybe you didnt installed it?
yup, and then i install npm i express
but after that i try to test webhook, but nothing
i follow the instruction on pin
where did you host your bot
local host
Did you open port
wait a sec
port has open, must be specific ip?
how can i see my public ip in ubuntu?
idrk didnt use ubuntu
curl ifconfig.co
thanks
i always get error when i run with public ip
i have to use public ip and open port
but why still didn't work
when i test in webhooks top gg, its not respond
use a site and check if the port is open
my code
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(myport) // your port
that code will show in console log when someone voted right?
still closed, but i have to open, idk why
i have no idea, my panel cannot run when i use public ip in bot
is public ip only one?
to get notif when someone vote, must be use webhook?
yes
public ip is only one?
what
u know how to open the port?
i try sudo ufw allow 'myport'
the port added, but when i check, still closed to my ip
port **** is closed on ***.***.*.*
Are you adding the apostrophes
whats that?
' '
btw can i remove req, res ?
what res meaning?
when user has vote, and try to vote again, the webhook will be triggered or not?
how do i setup a new webhook url?
Head over to our documentation for webhooks first
You can find both the section about webhooks and examples of how to use the webhooks depending on what library you are using
alr
also @pallid forge abt the url my friend set it up
apparently he says that he got the url from this bot: Dbl vote
Okay I’m not sure how any external services operate so I won’t be able to help there sorry.
The documentation does explain how to implement the code etc
alr thanks anyway
yes but what url am i supposed to give?
It is not working for me
const TOPGG = require('dblapi.js');
const topgg = new TOPGG(process.env.TOPGG, client);
topgg.on('vote', vote => {
client.channels.cache.get(`790885444794449942`).send(` Upvoted on top.gg!\nID: ${vote.user}`);
});
use new library
Link?
pins
Alr Thanks
But, How I'm going to use like this?
I just checked but, it's for updating stats I guess
topgg.on('vote', vote => {
client.channels.cache.get(`790885444794449942`).send(` Upvoted on top.gg!\nID: ${vote.user}`);
});
This remains same?
Nope
its too ez
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
logChannel = ...
logChannel.send(req.vote.user) // 221221226561929217
}) // attach the middleware
app.listen(3000) // your port
yup
Alright Thanks man
this still doesn't work for me. I dont know why I can't make it work, doesn't even log anything so im still using the dblapi.js module, which works.
but i do wanna switch to this one is there a way to log a webhook ready function?
in the app.listen pass a callback
hello im a js coder but what webhook url can i put like idk what to put there
where do you host your bot
You put your site url
me?
yup
hmm
im waiting
it did not send a message
nor did it console log
it didnt send message
it dint console log to
:c
Come in vc bro @ionic abyss
wich one?
@tight crag
hello
i dont understand you
yes
can u talk little slower
ok
how do i setup webhook url?
@ionic abyss can I see what you’ve put into the site
dbl.webhook.on("vote", async (vote) => {
const user = client.users.cache.get((u) => u.id === vote.user);
const ee = new MessageEmbed()
.setTitle(`${user.username} Thanks for voting!`)
.setDescription(`You got 1000 coins and unlocked 2 commands!`);
await client.channels.cache.get("790923255250419722").send(ee);
await addUserMoney(user.id, 1000);
});```
this is the code that doesnt work
can I see what you put into the site
??
don’t use user.id, use vote.user
and can I see your website config
the config on the site
that uses that
i got this error?
shardId: client.shard.ids[0]
are you sharding?
does that port match the one in your code?
yes
can I see your webhook config line
nope, that will show when i sharding?
remove the shardId and shardCount then
const http = require('http');
const app = express();
const server = http.createServer(app);```
you need to specify the port
i followed this tutorial
oh wait you’re using a server
yeah
is the server listening on port 25635?
okay thanks
server.listen(25635);```
lemme restart and follow what you said
ima restart first maybe that will fix
i think the webserver dint launch
it sends a test vote
const Topgg = require('@top-gg/sdk')
const express = require('express')
const app = express()
const webhook = new Topgg.Webhook('WhosTheGambler')
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
// logChannel = client.channels.cache.get(`790885444794449942`)
console.log(req.vote.user+" has upvoted on top.gg!")
})
app.listen(4000)
This is not working for me
Pls quest command of dank memer bot is not working
Pls repair it
Because I have completed 50 days streak quest
For today it is 52nd day
These many days of my hardwork will go waste so please help
@everyone
i have a webiste
Ask in their support server.
No you don't just ask for a broken command you open a bug request
That's none of our business from there
anyone?
why const user instead of var user and also try
client.user.fetch(vote.user).then((user) => {
var user = user;
let embed = new Discord.MessageEmbed()
.......
try to log
dbl.webhook.on('ready', hook => {
console.log(hook.path);
});
and enter that path in the webhook input in website. without the port.
var is a bad idea
how come?
im not a js developer btw.. i only learned that to get this vote thing going
var is global
that's what i got from the docs 
let can also be reassigned without being const
oh fr?? i thought it cant be assigned as long as the app is running
js is weird
@ionic abyss so i stand corrected.. use const but try user.fetch
guys anyone know how i can post the shards on my top.gg page?
and also how i can give a role to someone who votes for my bot
Woo, did u get the skd version working?
you can use the auto poster for posting shards/servers https://www.npmjs.com/package/topgg-autoposter
and the webhook for getting vote events to add the role
https://www.npmjs.com/package/@top-gg/sdk
im sticking to the deprecated lib until the docs are updated
ok
a man of culture too huh
well, also, probaby was a bad idea to deprecate a library while still recommended it in the sites docs
does perseint change the numbers if its int64? the vote thing sometimes cant find users in the db but they are in the db
in js?
yeah
parseint doesnt work with discord id's
discord id's are too large of a number for js int's
vote.user returns an int or a string?
well..... i use perseint to make it into ints.. damn i see it now..
is there any way to make it into int without changing it up?
my bot is in py 😩
the db is in int
py does the same thing iirc, but am not 100% sure.
treat discord ids as strings i mean
omg, dpy docs got updated a ton
just the docs updated
btw new library docs for the node sdk are here https://topggjs.rtfd.io
what's up
how I do so that a command can be executed when the user has voted for the bot
the webhooks and your discord library are separate
const express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express() // Your express app
const webhook = new Topgg.Webhook('topggauth123')
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
// req.vote is your vote object e.g
console.log(req.vote.user) // 121919449996460033
}) // attach the middleware
app.listen(3000) // your port```
I put that as it is, or should I change something?
I don't think I'm getting
look at this https://www.npmjs.com/package/@top-gg/sdk at the bottom there's an image with the information you need to fill out in top.gg
under the webhook server category
oh
ok
then all I would have to do is create the webhook and what else would I be doing?
opening your webserver to the internet, putting the ip and info into your top.gg panel and hit test
how do i create a webhook
read the docs
How can I find
user.tag
user.username
in
req.vote.user
I have the full code
But I don’t want to do mention in the message, I just want the user tag
@woeful mesa like their tag without the @
what language?
discord.js 👀
is it not ${this.username}
setDescription(`❤️ Just vote <@${req.vote.user}> ❤️\n
id: ${req.vote.user}
tag: ${req.vote.tag}
username: ${req.vote.username}
this my code
what's your code?
@woeful mesa the webhook doesn't provide .tag or .username, use your cache or fetch from the discord api for that info
@hearty lintel which?
const DBL = require('@top-gg/sdk');
const webhook = new DBL.Webhook('topggAPIAuth')
app.post('/dblwebhook', webhook.middleware(), (req,res) => {
console.log('We have arrived.')
console.log(req.vote.user)
})
app.listen(<port number>, () => {
console.log('Listening');
});```
Why doesn't it work? I don't get any errors, the webhook just isn't triggered.
did you open that port
wdym 'open that port'
this is rly starting to piss me off tho
can some one send a upvote checker in py
pretty sure the docs go over it.
thx
you need to open the port to the internet
if you have a firewall allow the port to be passed
I have I think
if you go to the url in your browser does it not respond?
Yea
hey what url should i give in the webhook url field?
what does it say zeedz
http://your.server.ip:port/path
oh alr so i have my host server ip but where do i get the port?
what lib are you using?
python
alr
should say something like Cannot GET /dblwebhook
it says 5000 here so the url shud be http://your.server.ip:5000/dblwebhook ryt
you hit save first right?
demn i get the same error agn
i don't know much about why you'd be getting errors saving unless the url was invalid
ik, it should, but it 'cant be reached'
im gonna have to use a reverse proxy
then your firewall has it blocked
hmm ill try askin in support channel then
yeah if it's available a reverse proxy with a domain or something is the way to go
const client = Discord.Client()
const Topgg = require('@top-gg/sdk')
const api = new Topgg.Api('xyz')
setInterval(() => {
api.postStats({
serverCount: client.guilds.cache.size,
})
}, 1800000)
``` hey so this would go in our main bot file or a ready.js event?
main bot file
okay thank you
const app = express()
const webhook = new Topgg.Webhook('pass')
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
logChannel = client.channels.cache.get(`790885444794449942`)
logChannel.send(req.vote.user+" has upvoted on top.gg!")
})
app.listen(3000)
This isn't working for me
ok so I was wondering I have a bot and I was wanting to use the top.gg api thing so I can see when somebody votes and thank them in a dedicated channel, how do I set this up in discord.py
I dont really use JS
node.js*
you can't
How can i do when i search a bot name and bot shows me bot info (discord.js)
could it be because of i have both of my intents off?
make sure you open the port and put in all the information into top.gg
the dblpy library has webhook support as well
you can only check your own, but via to check if a user has voted in the last 12 hour it's GET /bots/{bot.id}/check?userId=user.id
or use one of the libs with the function built-in
not sure why it's not working as the only required param is .serverCount. However an easy fix would be to use the autoposter package https://npmjs.com/topgg-autoposter
the error seems to be library generated, not entirely sure why, i'll take a look later today
okay ty
(node:5540) 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: 32)
(node:5540) UnhandledPromiseRejectionWarning: Error: 404 Not Found
at IncomingMessage.<anonymous> (root\Projects\ACNHBot\src\node_modules\dblapi.js\src\index.js:118:25)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (internal/streams/readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
anyone else get this?
for the dblapi
ty
const Topgg = require('@top-gg/sdk')
const api = new Topgg.Api('xyz')
setInterval(() => {
api.postStats({
serverCount: client.guilds.cache.size,
})
}, 1800000)
``` i have this in my main bot file i.e index.js, no errors but still shows N/A on the bot page
@jolly moth could ya help?
Did you wait 30 min
yes
it works for me
hmm
You have to save the webhook data to your database and associate the user ID from the webhook event with a timestamp. Then you can check your database to see if the user has voted in the last 12h. That's the only way.
But only for your own bots. Can't check for bots that aren't yours.
incorrect, there's an API endpoint for checking.
Would recommend using a webhook and storing however if you don't need to event a user voting the endpoint can be called when checking
hello i dont understanw where i can find the dbl_weebhook_token and the dbl_webhook_port
etc..
webhook port is the port to run your webhook server on
where ?
your webhook auth/token is set in the webhook section of your edit bot
its up to you
in discord ?
discord ?
i dont think that's how it works, if you don't have a dedicated ip for your hosting you're probably not gonna be able to use the webhook
i would contact your hoster to see if it's possible to port forward a specific port to the open internet
ask them
ok
Because I would like to make sure that as soon as someone votes for my bot then my bot thanks them
yeah you need an open webserver with the webhook and top.gg posts to that webhook
if you're unable to open a port then you can't receive realtime events
okey i ask yo my host
anyone?
@rare quiver setInterval doesn't execute the function at first
so you have to wait 30 minutes
o
But still same thing
panik
Lul
That's true, but after more than 12h you can't tell if a user has voted before or not.
okay
some people seem to be having trouble using the built-in function let me know if that works
the autoposter library also insta posts
so u can check right away after like a min for cache
cool
so My host told me that only the port was dedicated but the IP was not
that is to say
try setting the webhook port to that
okk
Hi
I have an issue with the top.gg website. I am setting up the DBL Vote bot and I need to link it with my URL and token but when I click the link it just has a white screen for ages then I got a cloudfare error with the host
just what is the dbl_weebhook_url ?
@hearty lintel wait so I do remove the top-gg/SDK one or keep that one as well?
the topgg-autoposter relies on the @top-gg/sdk in its package so you don't have to have it independently installed no
ah
It tells me to go to https://top.gg/bot/785420927336579072/webhooks
@dawn solar have you read the docs in the pins?
It doesn't really help me
I am not coding a bot
thats a site issue not api
also do I have to replace the topggtoken in the auto poster with something or leave it as is?
Just using one
@dawn solar what are you trying to do?
Support told me to go to API
And here i am
I have an issue with the top.gg website. I am setting up the DBL Vote bot and I need to link it with my URL and token but when I click the link it just has a white screen for ages then I got a cloudfare error with the host
make it whatever you want, it's what you put in the auth box under the webhook settings
i did that
that doesnt work
hum..
it's not how the webhooks work
@dawn solar what link are you going to? that /bot/12123123/webhooks?
Something like that yes
@dawn solar just to clarify, you're trying to get voting data for a bot that isn't yours?
go back to support, sorry for janking you arround
dbl vote isnt a top.gg bot, its made by a third party
#support wont be able to help you with it either.
It doesn't look like that bot is approved though...
the webhook url is the http://ip:port/dblwebhook
that we just went over getting
Do I need to wait for the bot to be approved?
But yes it was an issue with the host top.gg
The vote bot that you can use to setup webhooks (which isnt a dbl official bot) only works for servers
#support
@dawn solar The DBL Vote bot is for server voting. Not bots. For bots, you have to wait until it's approved, then use the API in the pins here in your bot's index file.
That's why we were confused.
I am still fairly confused. This is what it asks me to do
I am going to wait until the bot is approved and then try and connect the bot again
@Frosty#6992
it does
Oh it does
Disguised I would ask in their support server
As it has been used on another server I moderate
you have a better chance of getting help there
I did
They told me to come here
Oh?
lol
well, we will send you there
Yes that is exactly what the website is supposed to look like
I dont think so
Ok thank you very much. I will try that
No problem
Afaik you dont actually get an api get until you are approved so technically you cant receive votes until then
so best bet it wait until its public anyway
No I know. Was just trying to get everything ready
That's fair
okk
how can i send request to API, I tried to use postman for get that but i always get unauthorized message
nvm fixed

Hey, so my bot is currently in 42 servers. Why does it not display that on the website?
How do I get the api link?
what language do you use?
Python
Guys my bot reaction role is offline?? How do I fix that
go to its support server
has forecast back?
Hey, when I type https://top.gg/api/bots/155149108183695360 , I can get data from a bot (like Dyno in the example) but when I request it in my code I need a token? I'm just curious if there is an alternative to getting bot data without one? Why restrict info that is public? I'm kind of new so there's probably a reason but I don't get it.
you need an api token to access the api
and the only way to get a token is through having a verified bot?
a bot added to the platform yeah, i've never really considered the need to use the api without a bot, you should talk with veld and express the idea of having a way of getting a token without needing a bot
i don't see why you'd need to, tho
i mean you shouldn't really need a bot to request bot info ig
eeh
I have a bot but it's not verified. I have a command that you can get a user's info and, if it's a bot, it'll spit back the bot info too but apparently the publicly available info needs a token 0_o seems kinda weird to me
i think it is
it's not
oh right
I applied but I guess I have to wait weeks or maybe months to get verified?
sad life for me
yeah p much
its like 1 week
oh 😮
if u haven't dm'd veld I can i'm quite curious
ill contact veld via chat.veld.dev 
kek
the autoposter doesn't seem to work for topgg-autoposter either
i get no errors
but it also doesn't update my server count
not yet
nah its not doing anything
whats your code now?
@bitter iris the bot you're trying to post to is added right?
cuz looking at your page your bot has posted stats
?
whats your code now?
91
your code
oh
one sec
const Discord = require('discord.js')
const Client = new Discord.Client()
const AutoPoster = require('topgg-autoposter')
const ap = AutoPoster('token', Client)
ap.on('posted', () => {
console.log('Posted stats to top.gg')
})
am trying the sdk
it's working
i must have without thinking did a capitol c on the client.guilds.cache.size
class TopGG(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.token = 'MY 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):
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))
hey, I have been trying to set up my bot api, and it still is not working. my code is above
Has something changed? My bot isn't able to send updates to the api for server count, etx
Yeah but what exactly is not working
what do i do first
i did
but for the json file all it does is show params
i have no idea what to do w/ it
what json file?
That is not needed if you don't make http requests to the api
you're using a wrapper already
k so what do i do?
I still have no idea what is not working, i am unable to help
the error command just says that there is no such command as update_stats
hello?
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) # Autopost will post your guild count every 30 minutes
async def on_guild_post():
print("Server count posted successfully")
def setup(bot):
bot.add_cog(TopGG(bot))
bruh why don't it work
and yeh i pujt the top.gg token
@eager anchor here
?
How can I use the api at my bot Continue
how do i make a command where a user votes and they'll get cash in return?
just check the docs will you
this is from the official
dbl.getVotes().then(votes => {
if (votes.find(vote => vote.id == "95579865788456960")) console.log("Tonkku has voted!!!")
});
ok thanks my bad
ok
I tried using dbl.getVotes for voting rewards, but it gets all the votes in the bot lifetime. How can I make it only get the votes that haven't expired from the last 12 hours?
there is no way to get last votes
you can use vote webhooks and store this data in your db
Ok, thanks
What should I put in as my webhook authentication?
Oh never mind, I found out it is in the top.gg dashboard settings
Error: Cannot find module '/home/account/folder/node_modules/@top-gg/sdk/dist/index.js'. Please verify that the package.json has a valid "main" entry
``` I ran `npm install @top-gg/sdk`
Hey, so I have this code (copy pasted from the top.gg documentation, and changed to make sure all my variable names are correct):
const DBL = require("dblapi.js");
const dblPoster = new DBL(topggtoken, client);
// mention in support server (staff channel)
dblPoster.on('posted', () => {
client.channels.cache.get('791605633480261652').send(`Posted bot info: ${client.guilds.cache.size} guilds`)
console.log('Server count posted!');
})
//top.gg vote event
const dblVote = new DBL(topggtoken, { webhookPort: 5000, webhookAuth: 'password' });
dblVote.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dblVote.webhook.on('vote', vote => {
client.events.get('vote').execute(vote.user, client)
client.channels.cache.get('791605633480261652').send(`User with ID ${vote.user} just voted!`)
console.log(`User with ID ${vote.user} just voted!`);
});```
The autoposter works fine (just checked the website, it's all updated fine), however the vote didn't work. When I voted, nothing happened, even tho the webhook was ready.
Am I doing anything wrong?
Are there any errors?
nothing at all, doesn't even trigger the vote event
when I log the bot on, I get the ready message webhook running at ... but when I voted nothing happened
okay so I just ran a few more tests, looks like my vote got registered, still can't figure out why the event won't trigger
Welcome
altho how does the test work? Does it trigger a fake vote so I can test it, or do I need other code to detect it's working?
Which one?
the webhookpath
okay ty... means something still isn't set up right then 😂
I'm facing the same issue
I thought you were getting errors tho? I'm getting nothing at all
I'm not
ah okay
Maybe we could see what happens if I try voting for yours
http://0.0.0.0:5000/dblwebhook this is what I should put in as the webhook on the dashboard right?
sure, and I can test if your ID has voted afterwards
I just want when someone votes for my bot to thank them
hey @gaunt steeple @dense basalt I hope the ping isn't an issue, the FAQ says it should be okay to ping a couple of mods for help?
I'm just having some trouble setting up the top.gg vote webhook, I wondered if you could help? I don't know what to put into the webhook URL field in my bot dashboard for it to work. Putting http://0.0.0.0:5000/dblwebhook (the place it says the webhook is running at), doesn't seem to work, and I can't see what else I could add
please can you ping me if you reply 🙂
you need to replace the 0.0.0.0 with whatever ip ur bot is running on
and I mean public ip
ohhhhh okay thanks
Not working for me.
import dbl
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 = '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
async def on_guild_post():
print("Server count posted successfully")
def setup(bot):
bot.add_cog(TopGG(bot))
I don't understand the code, where does it post the server count?

Hey, I've been having trouble setting up vote rewards for my bot.
I have this code:
const dblVote = new DBL(topggtoken, { webhookPort: 5000, webhookAuth: topggpassword });
dblVote.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dblVote.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
client.events.get('vote').execute(vote.user, client)
client.channels.cache.get('791605633480261652').send(`User with ID ${vote.user} just voted!`)
});```
And on the top.gg dashboard I've put the webhook URL as `http://my-server-IPv6-address:5000/dblwebhook`
However when I run a test from the dashboard, nothing happens.
Of course topggtoken, password and my-server-IPv6-address are the actual token, password and address
could someone ping me if they have any info on what I'm doing wrong please?
use the new library for js
which one is that?
pins
ahhh okay I'll try that
const cheweyBotAnalyticsAPI=require("discord-bot-analytics")
const customAnalytics = new cheweyBotAnalyticsAPI("YOUR API TOKEN", client)
Can Anyone tell me what this is how do i onnect discord bot to website
wdym
Hi
I apologize for the question
But when i run dblwebhook + sharding
I have this error
Uncaught Error: listen EADDRINUSE: address already in use :::3000
Is there exposure between them or is the problem from my code?
something else is already running on that port
so you could change the port, or if whatever is taking up that port is something you control you can just add the webhook onto it
Hmmm, I don't think so because this happened after I ran the shard code
the error literally means something else is using that port
it could be anything on your machine
Stupid question, but what is the base url for the api calls?
thnx
np
Maybe, I'll try to change the port, thanks
👍
Which is better
@top-gg/sdk
or
Top.gg AutoPoster
Because I see that they all perform the same thing
they don't
the auto poster uses the sdk to post stats
the sdk has api methods and webhooks
hey, I've been trying all day, still no success, to set up a topgg vote event for my bot (to give rewards).
I've tried @waxen widget-gg/sdk and the older version, I've tried my server's IPv6 and IPv$ addresses as the webhookURL etc etc etc and still get nothing when I test...
This is the code I got from someone (It worked for them):
const http = require('http');
const app = require('express')();
const server = http.createServer(app);
const dbl = new DBL(topggtoken, { webhookAuth: 'topggauth123', webhookServer: server });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running with path ${JSON.stringify(hook)}`);
});
dbl.webhook.on('vote', vote => {
console.log(vote.user)
});
app.get('/', (req, res) => {
// ...
});
server.listen(5000, () => {
console.log('Listening');
});```
I've changed all the topggtoken and passwords to be correct, when I run that on my server I get the console saying it's listening, however when I click `test` on the topgg dashboard, nothing.
I assume using sdk would be better, but atm I just want something that works lol
shoot sorry for pinging top.... didn't mean to do that
Can i use this sdk only
For dblwebhook and postStats?
code?
the url would typically be http://ip:port/path not just ip
yes sorry, I did do that
is there any firewalls on the server blocking the specific port?
according to the server I have no firewalls no
is the server hosted at a company or at home?
it's vultr (VPS)
you can. i would recommend using the autoposter though
FYI when I run the code I get this:
@hearty lintel this is my code
ok thx
like on the site
its showing the correct server count
but i noticed this in my console
when i went to check
vultr seems to have a firewall in their web panel, if applicable youll need to allow it.
add an inbound rule to open that port.
actually the 5000, as in the express app
not sure why it logs the port as 0 🤷♂️
hmmm any idea where I'd go to do that?
I asked the same question to the guy I pasted the code from, he said he got it too, but it worked for him lol
most hosts have all ports open by default
never used vultr so im not sure where it would be
somewhere on the webpanel.
check the ipv4 settings
what would I be looking for? I'd prefer not to send screens of that lol
nothing... only for support and nothing for rules (using control F)
nothing for either of those 4
Do you have iptables or ufw installed?
under that firewall picker what does it say?
I don't really know what they are... I'm pretty sure I don't, but I'd have to look if you can tell me where too
I probably have to buy firewalls
ubuntu 18.04 x64, should be linux (I don't know a lot about all this stuff in case you haven't guessed lol)
alright if you do ufw enable does it work?
it tells me Command may disrupt existing ssh connections. Proceed with operation (y|n)?
when you do y you'll have to do ufw allow ssh
then after that you can do ufw allow [port]
okay says rule added. Should I try running the code again now?
yeah and see if the web server can be accessed
you need to set the port
const http = require('http');
const app = require('express')();
const server = http.createServer(app);
const dbl = new DBL(topggtoken, { webhookAuth: 'topggauth123', webhookServer: server });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running with path ${JSON.stringify(hook)}`);
});
dbl.webhook.on('vote', vote => {
console.log(vote.user)
});
app.get('/', (req, res) => {
// ...
});
server.listen(5000, () => {
console.log('Listening');
});```
This is the code. Where would I be able to set the port?
just for easier support and it's updated, you should use the new library, it's pinned, it uses an express middleware instead so you don't have to mess with this other stuff
the port is set to 5000 properly from what i can tell.
I did try that, but when it failed I found someone who'd got working code, and that's the code (only changed to add my pass and token).
So should I try changing that to the pinned code?
it'll also let you easily debug open ports without having to hit test
yeah it looks like you're already using express
this probably won't fix the issue but will let us figure it out more easily
const Topgg = require('@top-gg/sdk')
const app = express() // Your express app
const webhook = new Topgg.Webhook('topggauth123')
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
// req.vote is your vote object e.g
console.log(req.vote.user) // 121919449996460033
}) // attach the middleware
app.listen(5000) // your port```
Is it normal I never have to use my token in this?
also my password is topggauth123 (I'll change it once I figure all this out)
you set the auth inside of the webhook settingd
the token is only used for making api requests, not receiving webhooks.
👌
but once that's working try to go to the serverip:port on your browser
if it's working it'll say Cannot GET /
you did do ufw allow 5000 right?
yea
it works (the console.log('ready') triggered), but I got nothing else, is that normal?
yea the new webhook doesn't log when it starts
oh yea I should test it lol
you can make it by using a callback in the app.listen
but check for that Cannot GET thing
nothing when I test... wdym by callback? And where should I see the cannot GET?
"site can't be reached"
I tried serverIP:port and serverIP:port/dblwebhook
failed to connect, connection refused
that doesn't look good...
your not using the ip 0.0.0.0 are you?
^
do it on the vps
sorry it does work, I get this: https://gyazo.com/f8fbb94f31efc7cfcc5311e338130a68
yeah so it's a firewall issue
It works better when I keep the app on lol
no, using my server IP as webhook URL
you're sure the IP you're entering is correct?
It's copy pasted, lemme check again
ffs... I somehow added a c3 on the end 😭 , it works now.... sorry for all the time spent, I really appreciate it tho
thank you so much!
👍
How do I set up the API?
@flint olive what operating system and language?
I’m not familiar with the api
You can use the webhooks, the multiplier is just a weekend multiplier.
Some of the libraries have built in webhook support if you want to use those.
use the webhooks
read the docs
yea
the url where you're hosting the webhook server
Bro, one message
anyone get this error?
@restive otter bro pipe down, you are acting like you pay a monthly subscription or something
so I have to pay to get help??
"no one helps me"
"well, tell us what the issue is"
"you can't solve it"
guess why
Also, moderators are not obligated to provide assistance with the API directly
everyone trying to be a smartass when it comes to helping
Stop feeling like someone owes you something and help us help you this time
I explained my issue like 2 or 3 times here
explain it again
I can't say for sure where from and why exactly they are being sent, but you are free to just ignore those with 405s
How often are they sent?
I click "Test webhook"
and it makes a get request
instead of a post
server vote
🤔 interesting
it was working fine all the time it just suddenly started making get requests
^ requests sent via test webhook button
@mighty shuttle Would this happen to be an intended change?
Uh
From the looks of it, I have high doubts it's supposed to send GET requests
The webhook sending a get request?
That doesn't sound right
I'll notify the dev team about it
well I can retry again if you want
thanks qt
this is an old screenshot
@restive otter open your port to the internet then add your serverip:port/dblwebhook add your auth and save then test
are you using a vps?
what firewall do you use
i've no clue if or how to open a port via heroku
oh ok so there's a PORT environmental variable that you can use
but if it changes you can't do webhooks
please stop spamming
there's no need to split your messages
set your port to one of those open ports then put the http://[server.ip]:[port]/dblwebhook into your webhook settings
it's the same thing
server.ip
there's just a . in your ip
you're not actually putting that you're replacing it with your host's ip
yes delete that tho
and then put what you put in the auth into the authorization section
yeah still put it in the section
and i'd suggest changing it
it's already there
you put it in
you hit save first right?
you changed the port in the code too right?
no you use neither
you have to use the port supplied by heroku
google how heroku port forwarding works
then you need to open your firewall still
then you're probably not ready to do webhooks
i recommend doing research on how web servers work and how firewalls work
how to specify bot libraries
that's being deprecated, so don't bother
You can use the api.
https://top.gg/api/docs
You can find your token here
https://top.gg/api/docs#mybots
it's the api key right?
Yep
Thank you 
I can't send request to https://top.gg/api/bots/<my-bot-id> on my .js file
Authorization error but which headers should I send
you probably need an Authorization header with your DBL token
Okey, I'll try
Hey all, I have one question. Is it in real time ?
class TopGG(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.token = 'my 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))```
My API is not working. Do i need a seperate file for my cog? because this is just in my main file. There is no error code it just doesn't work
you dont use setup if its in the same file
so i delete that?
do bot.add_cog(TopGG(bot)) on_ready i think
instead of ```def setup(bot):
bot.add_cog(TopGG(bot))
why dont you try it
Yeees
Server count
pls fix
don't just say "pls fix"
??
and the message explains itself
ohhh you are so smart wow
move the bot role on the hierarchy list
bro can you not be a dick for like once
Fr
I can read the error and this error occurs whenever I refresh the page
move the dsl bot role
it's already over every role
And if i asking for a question, at least behave
probably refresh the page or something
then we literally cannot help?
refresh doesn't fix
it'll be an issue on their side?
@commands.Cog.listener()
async def on_dbl_test(self, data):
print(data)
``` i cant seem to get this event to trigger
can anyone help me?
You need to use the webhook options too
in order to receive vote events
@white trellis
where do i find that
i run my bot on heroku, so does that mean i would need to create a seperate webapp tp listen for the webhooks?
You should be able to do that on heroku aswell iirc, but no clue how
this might be a stupid question but how come i dont have to set up my bot as a webapp but i need to to receive webhooks
you could make the webhook and bot on the same app
use worker for the bot and web for the server
either that, or just make two separate apps
if i make a web and worker on the same app then when the web sleeps the worker sleeps too
im also just new to webapps
hi im a python user may i ask what should i put in webhook_path
That is the path of your webhook for voting
for the voting events
for example this would be http://yourpublicip.com:port/dblwebhook
is it must be to same on the top gg website?
Yes
Does not mean to just put in /dblwebhook
you need your server ip
for example something you could enter would be http://yourserverip:5000/dblwebhook
do i need to provide a port?
ty
If you do not understand anything in https://top.gg/api/docs, then you're not ready to get started yet
i understand some stuff
but i dont understand what i have to do
waiiiiiiiiit
never mind
Hello, I'm using discordjs library, and my bot just got verified by top.gg, and I was wondering how I could handle votes.
I use this code, but it doesn't seem to work : ```js
const app = express();
const Topgg = require('@top-gg/sdk');
const PORT = 8080;
const topgg = new Topgg.Webhook('uneron-auth-777')
app.get('/', (req, res) => {
res.sendFile(path.resolve('test.html'))
})
app.post('/topggwebhook', topgg.middleware(), (req, res) => {
console.log(bot.users.cache.get(req.vote.user).tag + 'just voted')
bot.users.cache.get(req.vote.user).send("Hey ! You just voted for UNERON !").catch(e => {})
})
app.listen(PORT, () => {
console.log('Online on port : ' + PORT)
});
How can make a vote log
کس ننتون
!play papa h
hey my bot got verified and i am not good with webhooks so what do i have to replace the password and webhookserver name with exactly? and what to do on the website
const DBL = require('dblapi.js');
const express = require('express');
const http = require('http');
const app = express();
const server = http.createServer(app);
const dbl = new DBL(xyz, { webhookAuth: 'password', webhookServer: server });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running with path ${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
app.get('/', (req, res) => {
// ...
});
server.listen(4000, () => {
console.log('Listening to port.');
});
Bad idea
