#topgg-api
1 messages · Page 162 of 1
Have you tried opening http://ip.address.of.machine/dblwebhook when running the webhook
im using replit
Your URL will be something like https://yadayada.xxx.repl.co/dblwebhook
What the hell is "that /dbl thing" in your code
this /dblwebhook
Am i supposed to put Something like this
But with my repl.co
?
in your code just keep /dblwebhook think.
In your bot page give your repl.co/dblwebhook link
It says cannot GET /

wtf else are you running
Apart from the webhook on your repl
and your bot
are you running a keepalive script
Now here's the thing right
repl technically works with just one webserver running at the time
(unless you do some weird ass magic trickery with forwarding the requests yourself)
so guess what
you're running 2 webservers
Repl is only reacting to the first one that's running
So I can't have both?
You can, but you must combine them into one webserver
It can be a webserver running within your bot as you can see from the webhook example
since it relies on express
Wait but one has listen 3000 and one 80
Same logic still applies
Try adding a route to your keepalive that responds with whatever text and see what happens when you visit your repl.co URL with that route
The problem is, like I said, you hosting 2 fucking webservers on one repl
Combine them into one
How to make this work
how?
Create a GET/POST/(whatever method) handler on a specific route you will have your pinging service send requests to
man im not smart
Look up express examples/tutorials
This is to complicated for me, i have another host that doesn't need pinging or anything, if i use it, will it emit the event when someone votes?
If it's accessible through the internet, sure
Uhm kk
Thank you
@sullen nymph one more quick question, if ik the ip of the host, how do i add it on top.gg
The webhook
http://ip.address.yada.yada:port/route
How to make a get request to get how many people have voted?
I looked at the documentation, and it seems that it is only acessable using express
I'm trying to use the topgg api for python and im trying to get the vote event to work but it's not working
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "password")
bot.topgg_webhook.run(5000)
@bot.event
async def on_dbl_vote(data):
print(f"Received a vote:\n{data}")
@bot.event
async def on_dbl_test(data):
print(f"Received a test vote:\n{data}")
do you get an error or you just dont receive anything
what is the DBL_API_KEY and where do I find it?
in the webhook section of bot edit page @wet arrow
This is redundant because nothing's dispatching the event.
just don't revive anything
I think I know what causing it
are you using a vps or?
for me i have a vps and i just direct the webhook to my vps ip like
ok thanks I will keep that noted when I get that ready
make sure you open a port ehen u do also
like i use port 8080
all depends on what type of vps u get
ok
why 0/1 instead of boolean
nope, youll need to track that yourself.
o
^ this
I mean 0 and 1 are booleans as well, but still
UHM, I've looked around for a hot while(1 month) and I can't find a single thing which allows you to send a message to your discord channel telling when someone votes.
im trying to set up a webhook but i get an error:
Task exception was never retrieved
future: <Task finished name='Task-1' coro=<WebhookManager._run() done, defined at /opt/virtualenvs/python3/lib/python3.8/site-packages/topgg/webhook.py:142> exception=ValueError('path should be started with / or be empty')>
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/topgg/webhook.py", line 144, in _run
self.__app.router.add_post(webhook["route"], webhook["func"])
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/aiohttp/web_urldispatcher.py", line 1167, in add_post
return self.add_route(hdrs.METH_POST, path, handler, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/aiohttp/web_urldispatcher.py", line 1094, in add_route
resource = self.add_resource(path, name=name)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/aiohttp/web_urldispatcher.py", line 1071, in add_resource
raise ValueError("path should be started with / or be empty")
ValueError: path should be started with / or be empty
Here is my code:
#in my code i replaced myip with my ip
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("http://myip:5000/dblwebhook", dbl_token)
client.topgg_webhook.run(5000)
@client.event
async def on_dbl_vote(data):
if data["type"] == "test":
return client.dispatch('dbl_test', data)
print(f"Received a vote:\n{data}")
The route passed to dbl_webhook is the /dblwebhook part
aka the route
The rest is your URL, aka something that only ENDS WITH the route
so what could the code be like?
Literally just said here
You can admit that you don't have experience with working with HTTP APIs generally
Give me a sec
yep
that's true
A Uniform Resource Locator (URL), colloquially termed a web address, is a reference to a web resource that specifies its location on a computer network and a mechanism for retrieving it. A URL is a specific type of Uniform Resource Identifier (URI), although many people use the two terms interchangeably. URLs occur most commonly to reference web...
I don't know a single thing about API's
path = route
So, the path/route you handle on your machine and the port you run on
You don't set those in the route
Usually you would specify either localhost or 0.0.0.0 as the IP (placeholder for "all available IPs" when running the webserver manually via some other framework DIRECTLY (since topggpy uses aiohttp.web under the hood, you don't need to set the IP. topggpy will do it for you, but you MUST provide a port to run on, which, by default, is set to 5000 in the example(s))
Oook
You run a webserver on your machine either as localhost or all available IPs on a port. The webserver itself handles whatever routes you add handlers for. topggpy (as you can see) provides helper methods for that via dbl_webhook and dsl_webhook methods on WebhookManager.
oh ok thanks
OSError: [Errno 10048] error while attempting to bind on address ('0.0.0.0', 5000): only one usage of each socket address (protocol/network address/port) is normally permitted
im getting that error for this
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("/dblwebhook", "password")
client.topgg_webhook.run(5000)
Try a new port
ok
any port works right?
Its better if it is > 1024
same error
Wait what
Hi, I have a question how to make a message when someone votes?
Try some unusual port like 28473
i tried 5040, but ill try that
same thing 
i'm getting error
Failed to post server count
Unauthorized: Unauthorized (status code: 401)
import os
os.system('pip3 install -r requirements.txt')
import discord
import datetime
import keep_alive
from discord.utils import get
from discord_slash import SlashCommand
import json
from giphy_client.rest import ApiException
import giphy_client
from discord.ext import commands, tasks
import asyncio
import random
from prsaw import RandomStuffV2
import DiscordUtils
import aiosqlite
from discord_components import DiscordComponents, Button, ButtonStyle, InteractionType
import youtube_dl
from async_timeout import timeout
import functools
import itertools
import math
import topgg
intents = discord.Intents.default()
intents.members = True
intents.presences = True
client = commands.Bot(command_prefix=',', intents=intents, case_insensitve=True)
client.remove_command('help')
slash = SlashCommand(client, sync_commands=True)
rs = RandomStuffV2(async_mode=True)
dbl_token = "sercret"
client.topggpy = topgg.DBLClient(client, dbl_token)
@tasks.loop(minutes=30)
async def update_stats():
try:
await client.topggpy.post_guild_count()
print(f"Posted server count ({client.topggpy.guild_count})")
except Exception as e:
print("--------------------")
print(f"Failed to post server count\n{e.__class__.__name__}: {e}")
print("--------------------")
update_stats.start()
nvm, i forgot i was trying that webhook thing with my other bot and it was running mb 😂
Hi, I have a question how to make a message when someone votes?
Sry but i don't understand the modules
Is there something different for the webhook if you'r hosting from your pc?
guys, why this doesn't work?
//------------Top.gg------------
const Topgg = require('@top-gg/sdk')
const express = require('express');
const app = express();
const webhook = new Topgg.Webhook("nope")
app.post('/dblwebhook', webhook.listener(vote => {
bot.channels.cache.get("860843237022498856").send(`${vote.user}`)
}))
``` Made in js
Try but i think no
Try idk x)
Error ?
nope
are you hosting it on ur pc or a vps?
vps
Try vote
You use a webhook
idk
const { AutoPoster } = require('topgg-autoposter')
const ap = AutoPoster(process.env.topgg, client)
ap.on('posted', () => {
console.log('[+] Stats Posted on Top.gg')
});
My Code
@still flume Is this correct?
I'm trying to help you, I think we have to do a webhook server
Why can't they make a simple API?
Idk x)
I like read that 25 times
And i didnt understand a thing
Me too i don't understand too
const { AutoPoster } = require('topgg-autoposter')
const ap = AutoPoster(process.env.topgg, client)
ap.on('posted', () => {
console.log('[+] Stats Posted on Top.gg')
});
Error : {Token} is not a legal HTTP header value
Well I think we're all lost x)
How can i track votes made to my server with my own bot?
I've looked at the API docs, but it is not simple to understand and only explains how to track bot votes and not server votes
I think you can't have the server vote
Idk
pardon, i just seeking $_POST but i was needed read php://input
i excepted like POST with parameters
but that's POST with json
so it was my mistake :_)
works
Oh ok
Who can explain to me how without using a webhook I can send a message when someone votes?
U cant
Of course you can.
You have to send a request to the topgg API to get the voters of the last 12 hours.
Cache and or save the IDs of the voters and send a message to them.
The interval between the requests you send to topgg will be the maximum “delay” if somebody votes until the message being send.
That doesn’t require webhooks but continues HTTP requests to the API.
this.client.snek.get(`https://top.gg/api/bots/${this.client.user.id}/check`, {
params: { userId: msg.author.id },
headers: { 'Authorization' : this.client.config.dbl }
}).then(i => i)
``` hey anyone knows why this is returning me 403?
oh wait
nvm
I used wrong client id
The client ID has to be your bot id
What URL do I really have to put in the Webhook URL box? Is it the Discord webhook URL?
no
Oh ok
you need to setup a webhook server
Ik this might make me sound like a noob, but how to do it?
what do you use(coding lang) and where do you host your bot
can you host a webserver on it because i never used it so ¯\_(ツ)_/¯
Hmm idk. It has lots of hosting services, but i use discord bot one
I dont really have a VPS myself
yeah you can host it, just read from their site
so you need @top-gg/sdk to do webhook server
check pins for an example
What does the Top.gg Webhook Password means then?
In pins
Wait a min. Can i use my hosting server's ip address?
Will it work?
@shut flume should it look like this?
Not the best
U just gotta test them to see if they suit u
But just a good hosting
Rn im hosting local to get bot working
But almost completed
Hmm. I would find the one that uses Pterodactyl servers
Alr
Cuz it's easy to manage (for me)
Alright
Is it easy to transfer a ton of files there?
Or can I get just git clone?
Yea. Just use sftp
Im pretty sure u can
Idk why, but i spent 6 hours working on the vote webhook. But nothing works
I provided my top.gg token
I put the correct port
I put the correct webhook auth
But when i try it out, nothing happens.
No console, message, nothing.
What am i doing wrong?
Ping me if anyone can help
can some one help me with my ip
like idk what to put in the top.gg dashboard
so can someone help me
i use js
I changed it 3 times
Welp, my hosting server says 2000, so i sticked to it
You're using 23 in your url
And use http because HTTPS makes no sense when you have a port added
Oh that one. I didnt realize the 2000 one
The 23 one was for sftp
Actually, that whole url is for sftp (except the /dblwebhook and http:// part)
The current one im using is http://0.0.0.0:2000/dblwebhook
Cuz it says so in my server
Idk
Not 0.0.0.0, replace it with your server ip
0.0.0.0 is a way to say "can connect from anywhere, localhost, internal, external"
Use the URL they give you
Yes
If that doesn't work, you're better off asking your hosting provider tbh
Hmm ok
So, if i use the https one, do i need to put the port?
Use the URL they gave you
So it's just https://service-6035.something.gg/dblwebhook?
Or no /dblwebhook
Yes, that should work
As long as you're also using the port 2000 in your code
app.listen(2000)?
Im still confused, which one is better to use. dblapi.js or the original @top-gg/sdk
isnt https more secure website then http?
idk i heard that somewhere might be confused tho
http(s) is more secured than just http
i see
i own just a http
bc at first i didnt really want to do anything with the website
sry wrong channel
I was reading something here and accidentally ctrl v + enter the command
pls don't mute me, the channel description is quite scary...
Accidents happen
any1 recommend any hosting websites to host my bot 24/7
-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.
Vote Credits what does it means?
Top.GG API Error: 401 Unauthorized (You need a token for this endpoint)
why am i getting this error?
Did you add top.gg webhook token?
yes but still i am getting this error.
is it because i am testing it on my test bot and not on the main bot?
yes you need to test on the main bot
oh i was confused between that thanks for the help.
yw 🙂
@gaunt steeple hey, going to DM you abt. smth.
(totally not pinging you because i didn't forget your username 💀)
Why does my api token keeps on getting reset after a few users check there vote stats?
it doesn't get reset
everytime i reload the page and press "show token" its a different token each time
breaking my code
what's the url you're reloading on
that's a known issue, but refreshing does not reset your token
kinda works the same like discord does
Any way to prevent the 401 unauthorised issue?
again it's a known issue iirc, no eta on a fix
oh okay, so i'll just have to reset token when it appears and pray it works lol
sure, what library?
Discord.js
All code added to my bot but I can't find webhook auth
auth is a password, you make it.
Rely on the environment variable PORT
Vote Credits what does it means?
@restive otter
So, I want to check if an user voted for my bot
In browser ( https://top.gg/api/bots/685166801394335819/check?userId=581146486646243339 ) it works fine, but if I try it with my bot I always get { error: 'Unauthorized' }, even if I provide the api token... How can I prevent this?
if you are using python:
import requests,json
headers = {
"Authorization": "token"
}
page = requests.get("https://top.gg/api/bots//check?userId=", headers = headers).json()
print(page['voted'])```
@solemn vessel
I use js
And I used it - again, I tried with a token too but it didnt work
and the token is valid as I can update the server count with it
bots/ not bots//
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.listener(vote => {
// vote is your vote object
console.log(vote.user) // 221221226561929217
})) // attach the middleware
app.listen(3000) // your port
how to create a webhook for a dbl
like if i need topgg vote count for a user and user dm after vote and bot alert send in here support server if some one vote
i know i need to make webhook but how anyone can explain
thats all you need to make the webhook.
what part are you having issues with?
how can i make a webhook
thats the code above to make a webhook
can you send an example
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.listener(vote => {
// vote is your vote object
console.log(vote.user) // 221221226561929217
})) // attach the middleware
app.listen(3000) // your port
👀
oh man
maybe rephrase the question, because I'm really not sure what your asking for? thats the code to make a webhook
oh, the url is just the url to the webhook.
https://discord.com/api/webhooks/854908126814011392/1EpSbAURRbEGuqeDlJEvRZ1u_DzaENWdmgztz9gztE0rSnJUWTpO2DROkZyui0yLmFL4
be like this
looks something like http://IPHERE:3000/dblwebhook
no
top.gg webhooks are not discord webhooks
how can make be like this
this is my question
you just fill in the relevant information.
like?
uff!
Hi
Hey
Hello I am new to discord.js bot coding and I would like to know how to announce that a person has voted for the bot on top.gg if you can mp me
Ugh. 3 channells... SPAM!!!!
import topgg
# This example uses topggpy's webhook system.
# The port must be a number between 1024 and 49151.
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}")
So how do I customise this code to send webhooks for my bot?
do you also find it difficult to reward your members for votes?
I'm not trying that yet. I just have absolutely no clue how to set up a simple webhook. All I want is for every time a user votes for my bot, a message outputted
like what do I put in the password?
Whatever you put as Authorization field on top.gg
To receive the test data, do you need to put the webhook as "http://0.0.0.0:port here" or would it have to be "http://myip:port here" ?
myip
site issues rn
Hi, i see that some bots can manage/track server voting, but i only see things for bots on the docs. How am i able to track my own server votes with my own bot?
Then how do i go about creating a webhook?
read above
This?
const express = require("express")
const app = express()
const webhook = new Topgg.Webhook("your webhook auth")
app.post("/dblwebhook", webhook.listener(vote => {
// vote will be your vote object, e.g
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
}))
app.listen(80)```
how can i configure the webhook?
So can someone please help me with this? Its really annoying
One message removed from a suspended account.
hi
docs only shows how to get info on bot or user how do i get info on server
How has the bot in 165 servers yet not been verified?
bonjour comment on a notre clée api j'ai mon bot enregistrer https://top.gg/bot/780847349467316264 et j'ai besoin de l'apo
api
NITRO SCAM!!!
its always not shwoing servers number if the bot is new or need change settings ?
-servercount
To have your bot's server count displayed on Top.gg, please read the documentation on server/shard posting.
HEllo?
how do i get all votes this month?
Afaik you can get the last 1000 votes but after that you need to use the web hooks
Why do i have here 6 votes:
https://top.gg/bot/855372526875574273
But as an api response i only get 3:
Im using
https://top.gg/api/bots/855372526875574273/votes
U need to verify with legal identification and stuff
hello
please help me guys
i cant figure out why the api is not working
const Topgg = require(`@top-gg/sdk`)
module.exports = {
name:"check",
async run(client,message){
const api = new Topgg.Api('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjgwMDYyOTM1Mjc1MjM0OTE5woooooooooooooooooooooooooooiaWF0IjoxNjI3MDU1NzM0fQ.8WgdoovRk2_q5m8MPCFpsiz0rNaIz0f2vGHOrAMF1xE');
await api.hasVoted(message.author.id)
}
}```
its giving me authorization error 401
and saying that this end point needs token
however i have provided the token
please ping me if someone is responding
🙏
why?
Because you posted it here
no i m not that dumb
but do u k a solution?
do u k whats the error tho?
Make sure to create only one Api object and reusing it instead
yes yes
made sure
But putting that aside, just try resetting your token multiple times until it works
make sure you copy it fully and without extra characters
This is pretty much a known issue I believe and you're not the first person to experience this
i reset three times?
lemme try couple of more times
yes yes, made sure
;(
(It gets recreated with each run function execution though)
wait
can u tell me one thing
i have to use the token from the webhook page right?

someone please help
node:563) UnhandledPromiseRejectionWarning: Error: 401 Unauthorized (You need a token for this endpoint)```
this is the error
you need to use your token
the tokens of the bot or top gg
it
what do I have to replace
what do I have to replace for it to work ?
idk what you mean
res.statusCode = 200;
return res.end(JSON.stringify({ message: "Successful" }));
``` responding with 200 and closing connection still periodically getting multiple requests
any ideas>
I tested the route and the requests do respond with 200
res.send
You forgot an "s"
When i run a test i get invalid HTTP method
I fixed it i used https instead of http
https://top.gg/api/bots/:bot_id/votes
does this endpoint require authorization?
when i try to fetch stuff it says
Yes
any one top up diamond
What can you all do with the api?
hack topgg read/write info about your bot
thats it?
yeah
you can post your guild count, get the total number of votes, check when a user votes your bot, etc.
Ok Thanks!
Xdddd
just now i check the pins XD
when I go to the edit page of my bot, it shows me this error
Known issue, not related to api tho
ok
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.listener(vote => {
// vote will be your vote object, e.g
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
}))
app.listen(80)
So let’s say I put this in my index file how do I lock a command to voters only
Documentation for @top-gg/sdk
Best thing to do is to log votes in your database. Hitting the api every time someone runs the command isn't a good idea.
its okay at small scales, but your very likely to get issues after a certain point.
best to do it right from the beginning.
lolo
?
bot.topggpy = topgg.DBLClient(bot, constants.TOP_GG_TOKEN)
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook(f"http://{EXTERNAL_IP}:3000/dblwebhook", "topggvote")
bot.topgg_webhook.run(3000)
Should something like this work? Or do I need to create a server with Flask or something? (to listen for post requests)
You should only pass the path there, i.e., /dblwebhook
? Like this
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook(f"/dblwebhook", "topggvote")
Yup
Anytime I test the vote nothing happens
does not enter the on_vote method
Are there any reasons this could be happening?
Is there a known issue with an incorrect number of votes in the /votes endpoint
My API is telling me top.gg is sending back this many votes
Which is disproportionate when I have 88 votes and that's 13
How to detect if somebody vote? Python
Read the docs: https://docs.top.gg
Hi I want to know that can i claim my votes rewards next month also or it will expire before 31st ?
Bot doesnt do anything
I get this after clicking save & send test , how do i fix it ?

@shut flume and then?
@shut flume do you know somebody who uses top.gg with python? because it doesnt work for me
anyone ?
Do you use dblpy or topggpy?
topggpy
How do you use WebhookManager?
What happens when you send a manual request to that URL?
it gets request and sends with discord webhook
I meant, what does the server respond with when you try sending a manual request to that URL yourself?
a
Use reqbin
Send a request to that URL yourself
POST method, whatever JSON you feel like throwing at it
IMO you should only use either integromat or your own webserver in which case you can use topggpy to set it up, not both.
i use 1
Using the former, you can catch the webhook message and parse it, but tbh it's rather hacky.
Then don't expect the dbl_vote event to fire.
I believe it's from some random YouTube video, shiv 
Yes, because there is no any docs for this
I remember someone here suggesting Integromat
You know what
Apparently people don't know how to get this shit working without tutorials
Guess I'm making a separate section in the docs just for this
That'd be useful for starters.
So what do i need to use?
Either Integromat or topggpy. If you use Integromat to send a request to a Discord webhook, then you don't need topggpy. Pointless to use both at the same time
And how i will use topggpy?
@restive otter just got an idea of Integromat -> Replit -> Heroku -> Glitch -> VPS -> local webserver
The URL would then be http://your.machine's.ip.address:port/route where /route is /dblwebhook in your case
The vote data travels the internet 
does the python client have post users or is that not a topgg thing
That's not a feature on top.gg
hmm can anyone help me
how can i set it up?
why does https://top.gg/api/widget/802585482625941514.svg have my old username from years ago
and how do i change bot lib (whatever is shown in the wiget)
Bruh
well what language at least

but
can i do it without db?
database for storing vote time?
no, you probably have a db anyway for your bot so
no
i have JSON

json is not meant for databases lol
you should change that
if u use python, asqlite/aiosqlite is not hard to use anyway and just learn sql
ik it but its easy to use
sql is just as easy and more readable if you open it in a viewer lol
its the auth to the webhook, its what you fill in on the site.
your the one who decides it
youll want to use webhooks.
https://docs.top.gg/
i am not able to understand
;-;
what do you not understand?
What do I put here?
thats the URL to your webhook receiver that you make in code.
will probably look something like this
http://IPHERE:PORTHERE/PATHHERE
port and path are defined in your code, ip is the ip to the server.
If your using a host which doesnt provide an IP youll want to use the projects web url, with the path.
this?
thats not your ip, thats the ip webhook data is sent from.
you need to use the ip of the server, or network your hosting your bot from
nice
I already have my token, now what do I do?
you dont really need a valid token for webhooks.
the token is for the api, not webhooks
what I want to achieve is that some commands are not allowed to be used without first voting
so, you'll need a database for that with webhooks, or check the hasvoted endpoint(generally less recommended for any kind of scale).
It is somewhat complicated to do this, and more if I do not speak English hahaha
i did this but the stats are not getting posted ("Yes i added my api key")
is their someone who can help pls?
Somebody can help me to make webhook using heroku? Python
i'm using replit with express so it was pretty easy for me, heroku also has a webhook system ig
make sure the webserver is running
remove the :80
as 80 is the default for http
and depending on if you have something on there already, use a different port
like 2000 or 12345 etc
Good evening, I would like to make a code that allows you to see who voted for my bot
Could help me please
const client = new Discord.Client() // Your discord.js or eris client (or djs ShardingManager)
const { AutoPoster } = require('topgg-autoposter')
const ap = AutoPoster('Your Top.gg Token', client)
ap.on('posted', () => {
console.log('Posted stats to Top.gg!')
})
const Topgg = require("@top-gg/sdk")
const express = require("express")
const app = express()
const webhook = new Topgg.Webhook("WHEBOOKS")
app.post("/dblwebhook", webhook.listener(vote => {
// vote will be your vote object, e.g
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
}))
app.listen(80)``` how i find the top.gg token
-pins
somehow the webhook for the server doesnt work and gives error when trying to test it
webhooks for servers dont work properly.
@woeful prairie hey, whats your code look like for your web-hook receiver?
I use @top-gg/sdk npm package
I will share the code
did you fill in the webhook url and auth on the site?
whats your hosting location
Yes I filled
I hosted using railway.app
Can I share GitHub code link?
does railway app give you an ip or project url? do you know what ports they allow?
sure, just make sure the github doesnt have tokens visible
Yes, it gives. They allow all ports
It doesn't have 👍
https://github.com/Welcome-Bot/welcome-bot/blob/feat/dashboard/dashboard/routes/dblwebhook.js
It is hosted in the same place of dashboard, btw dashboard isn't fully ready.
then your webhook url will look something like this.
http://IPHERE:PORTHERE/dblwebhook correct?
Yes
Hmm, wait
I didn't specify any port, because railway anyway only allows 1 port
Should I specify port @jaunty plank
if your using a port other than 80 youll need to.
webhooks for servers dont work properly.
@jaunty plank ohh i see
im getting frustrated
Yeah, servers doesn't work too for me also. At least bots should work out
I use 8000
Okay, I will specify port
I changed
1 second, I will test
Hmm, no. Nothing came in the vote-log channel
@jaunty plank I forgot to say, they don't give me an ip, it is domain. It is in the format of <PROJECT NAME>-<ENV>.up.railway.app
If project name is already used, some random number will be added I think
<ENV> is environment, I use production for environment
If I specify the port, I can't get the 404 page in my browser itself. Maybe railway redirects requests to the port on which my app is running
Hmm, wait
maybe it was a miscommunication, because i explicitly asked about these things.
wdym
Why shouldn't you ask?
yeah, you will need to use the projects web url, with the path at the end.
typically these typed of providers have a preferred port for websites to use, which you should refer to their documentation to find.
Railway doesn't give a preferred port, but they redirect requests to the port specified in the env vars, i.e PORT environment variable, they automatically block reqs where the app isn't listening on the PORT var and repond with "Bad gateway" as the status.
yep thats the normal way of doing a preferred port.
so your url will look like <PROJECT NAME>-<ENV>.up.railway.app/dblwebhook
unless you added other routes to the path
note youll also want to include http, or https to the url depending on what they allow.
Yes, exactly. I included https
It could be problem with router or top-gg/sdk package
the most basic way to debug that part is with postman(a program for sending https requests) or with more logging.
I just tried logging, I added console.log("/dblwebhook") in the code, I got nothing logged, and if I visit the url, it shows 404 page
this is a post endpoint. visiting the url will never give a valid response.
visiting the url = get.
Oh, yeah, am a fool
I will see this afterwards
Can we claim vote rewards next month also or it will expire this month only ?
welp?
yes the vote reward that we get
$15
after 100votes
can we redeem it next month or will it expire before the start of next month ?
thx for the info
for bot or server ?
u have to make one
and while creating the webhook in code u need to provide the password to authenticate with the top gg webhook
um
use cmd
@void obsidian yoooooo
elo
Isn't it npm -i ?
i dont think so i do npm i and it works..
but i got it
no i dont
it says connect to github but it dosent ;-;
pog
/*-------------------------------------------VOTE-TOP.GG-----------------------------------------*/
const { Topgg } = require("topgg-votes")
bot.topgg = new Topgg({
token: "I was on top.gg/webhooks/token I copy the long token that I have pasted", // Your top.gg token
auth: "I put the entire webhooks" // Webhook password
})
bot.topgg.postWebhook(bot);
bot.on("newVote", (user, bot, isWeekend, query) => {
if (query == "bot") {
let embed = new Discord.MessageEmbed()
.setTitle(`New bot vote!!`)
.addField("User", `<@!${user}>`, true)
.addField("Bot", `<@!${bot}>`, true)
.addField("Weekend", isWeekend, true)
bot.channels.cache.get("866691364245602364").send(embed);
// Enter the ID of the logs channel at ID
}
else if (query == "server") {
let embed = new Discord.MessageEmbed()
.setTitle(`New server vote!!`)
.addField("User", `<@!${user}>`, true)
.addField("Server", `${bot}`, true)
bot.channels.cache.get("866691364245602364").send(embed);
// Enter the ID of the logs channel at IDun temp
}
})```A kind person could help me please I'm lost
topgg-votes isnt a official module
how to get top.gg token
See pinned messages
sending test to webhook seems broken, and webhook doesn't really seem to send anything to the webhook url and info i have added.
Why events require webhook? Why doesnt it work with token?
because you have to process the events yourself
for what this then
why does the API randomly return 504 errors?
sometimes the site goes down, and cloudflare returns 504's.
Is it a problem you're working on or can't you do anything about it?
when the site goes down, it goes down.
theres nothing that can be done. no matter what it will happen sometimes.
best to just handle the errors.
Okay
const express = require('express');
const { Webhook } = require('@top-gg/sdk');
const initialize = () => {
const wh = new Webhook(process.env.TOPGGWEBHOOKAUTH);
const app = express();
app.post('/dbl', wh.listener((vote) => {
// dblwebhook
console.log(vote.user);
}));
app.listen(process.env.TOPGGAPPPORT, () => console.log('[Express] The server is running.'));
};
module.exports.initialize = initialize;
i tried using this code to track votes, but when i voted it didnt register in my console, are there any issues in my code?
As per me there aren't any issues, but it is some problem from top gg library or top gg webhook I believe
I have the same problem.
My code for reference: https://github.com/Welcome-Bot/welcome-bot/blob/feat/dashboard/dashboard/routes/dblwebhook.js
What's code for bot title vote
@jaunty plank
what do you mean bot title vote?
Sorry it's totle
Code for totle bot votes
I don't know what totle is either, so I won't be much help with that.
like vote.user gives the id
how do i get the monthly vote count?
and does vote.isweekend display if its 2x rewards
how to do automatic vote rewards in discord.py
It's a boolean, so true or false
It's the ip you use to connect with ssh, or it'll be provided by your hosting company somewhere
hello
I'm using the api's webhook
How do I know who voted for the bot?
this information arrives through the
request.post()
or
request.headers
why is that an f string if you're not interpolating anything
request.body
thx
how to make vote rewards or voted dm message in javascript?
alright
my bot will soon use "wa2000" which is a great bookstore for a bot that takes RATELIMIT monthly, weekly or to lower the ping
but I'm not sure why I use "topgg-autoposter" to post my bot info on the site, but the new bookstore I'm going to use doesn't have most of the shards' functions
Is it ok to use the "topgg_autoposter" in the event that says if the bot is online?
How do I make a vote tracker system in discord.py with top.gg?
how can make webhook url?
I voted for the bot, but no information came to the console, does anyone know where I made a mistake? By the way, I don't know about this voting thing, please don't be angry.
@jaunty plank I fixed my Webhook
Well, how to know if the Webhook I received is a my bot guild or my bot?
Maybe you didn't add the URL in top.gg
What about me ?@woeful prairie
You have to host your app somewhere, to get the URL.
The app is the code
You have to put the token you added in top.gg website, you first go to your bot page or server page and then click on Webhooks
You can tell me in hindi for easy understanding
Yea yea
That whebhook url
What to do there
Vaha ap Apne url ko paste ki jiye
Url kaha se lau ;-;
Host your app somewhere, mei https://railway.app mei host karta hu
Yes, use that.
I don't know if replit is online always
Okay
Welcome
@jaunty plank I think you know js
Can you help?
the webhook for guilds have diffrent parameters than bots.
https://docs.top.gg/resources/webhooks/#schema
But I use the same @top-gg/sdk package and it worked
yep, that sdk works with both guilds and bots.
So is their a way to differentiate, pass a argument or do something
yes, look at the parameters they return
Or should I create another route
see https://docs.top.gg/resources/webhooks/#schema for more info
The vote object?
you can make a separate route yes.
yep
either way works.
if you want them both on one route, look at the returned vote.
if you want two routes, then that works too
Oh, I can check if vote.bot is defined
Here, it is given
Okay, I will see
Not working idk why
No
Any password string you want
It will have to be the same as your Authorization field on your bot's Edit page in Webhooks section
what are we going to enter here
can you wait a minute
Are we going to write what we wrote here?
Yes
Posting server count via official Top.gg library or making manual HTTP requests
um is the password mentioned here
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "password")
the authorisation thing or the top.gg token?
Not top.gg token, it's fully up to you. But it needs to match the one you put on the site.
also this doesnt have to be in a cog to work right?
thanks
hey, how to detect if someone voted my bot? and how to get the token?
To get the token read pins
thx
To get vote
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.listener(vote => {
// vote is your vote object
console.log(vote.user) // 221221226561929217
})) // attach the middleware
app.listen(3000)
this works?: https://www.npmjs.com/package/dblapi.js
deprecated I guess
okay thx
np
i want to make a voter only command which is accessible to voters only but i am new to these all so can anyone help me?? in discord.py library
l
its somple
simple
sure it is it did not work
you can see tutorials on my yt
oh ping
#discord #discord.js #realcoder
Hey am official member of realbot
Source Code - https://github.com/RealPukhraj/Stats-Count-For-topgg
Github - https://github.com/RealPukhraj
If you need any help join
Discord Server - https://discord.gg/k9zFcucTKp
Thank You
Regarding Real e-Sports
Always We are waiting for your joining.
Social Links :
✔ We...
you see here
its a tutorial
ok
hi
Im making a voting system
def __init__(self, bot):
self.bot = bot
self.token = 'token'
self.dblpy = dbl.DBLClient(stuff here)```
can someone explain these things to me>?
Please help
don't put repl.co:3000
just keep the original link
wdym orginial link?
please explain py webhook_path='', webhook_auth='', webhook_port=5000)`````` to me!!
WEBHOOK URL should be https://brrr...........rrrr.repl.co/dblwebhook
ohk
Ah, okay. Gotcha! For some reason, it crashes one of my shards each time that happens. I guess I need to implement some proper error handling for that. Odd
Yeah 😅
I appreciate that, Gugu!
Np!
I am unable to import the topggpy documentation into my script
Have you tried putting where "WebhookAuthCode'" is? replace by putting the token in place
In pytnon is about to put a "password" I also didn't understand very well hahaha
i still use it works fine
how u going to use Embed in the route? you have not defined discord functions
@neat sierra that wasn't the prblm nvm it's fixed
do i need the authorization token for getting server_count with php ?
yes
Why do the webhooks need to be acknowledged? Just curious
Is there a way to get your bots server count on the top.gg page, instead of having it just stay [N/A]?
I saw someone above post something in js but is there maybe a python way or only js?
How make a vote event listener ? I don't understand what we need to put in this line :
const webhook = new Topgg.Webhook("your webhook auth")```
What is webhook auth ?
:(
We put https://top.gg/bot/:your-bot-id/webhooks in the webhook URL and the webhook auth is the Authorization or the webhook URL ?
Auth. Is the shortened word for authorization so I would say authorization
See topggpy on PyPi
I also want to know why I searched on youtube but couldn't find it
On command send request to API, store returned value in cache, work with that value
Or use webhooks and a database
I tried this but it doesn't send anything it's logging in anymore when it's time to pull the vote it doesn't pull
Sounds like an issue with your code
Unless you're talking about the delay between voting and actually being able to get it from the API
I suspect that it is in the part of the webhook url that asks to be put on the site
So you're using webhooks?
it's this part of the webhook I didn't know if it's mandatory so I put it
I'm using this code
const DBL = require('dblapi.js');
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
stop using dblapi
use @top-gg/sdk
what should i do at authorization??
anyone...?
how to use the top.gg api to vote
i recreated the request in python
but i get {"error":"Invalid vote"}
instead of already voted
the endpoint isn't documented 
this is the end point i am hitting
import re
def addUpvoteRecord(userid) :
@bot.event
async def on_message(message) :
if message.channel.id == XXXXXXXXXXXXXXXX :
data = message.content.split(" ")
user = re.sub("\D", "", data[0])
addUpvoteRecord(user)
await bot.process_commands(message)
This is the code
i want to make a command restricted to voters only how can i do it can anyone please help??

can someone fricking explain how to use self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='', webhook_auth='', webhook_port=5000) pls
dblpy is deprecated by the way, you'd better migrate to topggpy
yes
anyone got a tutorial on how to make that webhook thing
so it emits an event when someone votes
please
how do i get the ip server
what library?
discord.js
after following the tutorial try this code
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.listener(vote => {
// vote is your vote object
console.log(vote.user) // 221221226561929217
})) // attach the middleware
app.listen(3000)
hmmm ok
thanks 😄
Can anyone help me personally to do this? I will pay for that.
put this code in your bot
const client = Discord.Client() // Your discord.js client or any other
const { AutoPoster } = require('topgg-autoposter')
AutoPoster('topgg-token', client)
.on('posted', () => {
console.log('Posted stats to Top.gg!')
})
and donate the money to yourself
should i have to put this in my index.js?
I have tried but it's giving error
@smoky marten, @meager mural bro I have done everything but still not showing in the website. Does it take time?
If im not mistaken, information will appear on the website after 30 minutes.
ok thank you bro
def addUpvoteRecord(userid):
with open("vote.json") as f:
vote_list = json.load(f)
if not userid in vote_list:
vote_list[userid] = []
with open("vote.json", "w+") as f:
json.dump(vote_list, f)
@client.event
async def on_message(message) :
if message.channel.id == 870147153706750022 :
data = message.content.split(" ")
user = re.sub("\D", "", data[5])
addUpvoteRecord(user)
await client.process_commands(message)
i am getting this error TypeError: list indices must be integers or slices, not str
can anyone help me??
Anyone know how many time it takes to show the info like the image after editing bot's code.
can someone please give me the correct code which adds the id of user in json file and then remove it after 12hrs
pls help me this is important
can someone help me with the bot event on_dbl_vote
like when i vote the bot
it doesn't show the data
@bot.event
async def on_dbl_vote(data):
print(data)
very likely an issue with your code
can you possibly post your code
as soon as you run the bot
Full source code?
just the api part
i just helping but ok- just saying it works
sorry
that's spoonfeeding, not helping
//const client = Discord.Client() // Your discord.js client or any other
const { AutoPoster } = require('topgg-autoposter')
AutoPoster('topgg-token', client)
.on('posted', () => {
console.log('Posted stats to Top.gg!')
})
both of these bot events are working fine
@rain heart i had to make the 1st line as comment bcz it was giving error saying that client has already been added.
well no wonder it wont work
Why?
do you get the log line of "Posted stats to top.gg"?
remember it posts every 30 minutes
No I didn’t get anything like that
But before putting the code i have installed all the modules from npm i @top-gg/sdk
So, what i have to do now?
Have you waited for 30 minutes?
because that particular bot has not posted shards yet
it should respond with the Server count if it has been posted
Yes.
then your code is faulty, wait for someone who can help
It’s been 1 hour.
check the docs
@restive otter can u give the code that you gave earlier.
just an int and bool , right?
if the docs say that, yes
It also contains the fields VoteDataDict has: https://topggpy.readthedocs.io/en/latest/models.html#votedatadict
It's the same endpoint
so how do i test vote
like i have voted from my id it didn't show up in terminal
then i refactored the code
and when now i vote
the 12 hour limit

Test vote on your bot page webhooks
There's a button for that
this?
ohuuu


