#topgg-api
1 messages · Page 172 of 1
@unborn sparrow
nvm somehow got it working
@blissful belfry https://docs.top.gg
P!start
@client.event
async def on_dbl_test(data):
"""An event that is called whenever someone tests the webhook system for your bot on Top.gg."""
data = int(data["monthlyPoints"])
print(data)```
Is that right to get the monthly vote count?
i dont understand the docs
To get the monthly vote count, call this method https://topggpy.readthedocs.io/en/latest/api.html#topgg.DBLClient.get_bot_info
i dont understand
:/
so i'll tried:
@client.command()
async def votes(ctx):
votes = await topgg.DBLClient.get_bot_info(client.user.id).monthlyPonumbers
print(votes)```
But it still dont worked
can anyone help me to understand? :/
monthylPonumbers?
lol
actually says PoNumbers dafuq
Can assure you its monthlyPoints
lol
check the pr xetera kekw
Yeah was present since the init commit 
Love how nobody noticed that
@restive otter try using monthlyPoints instead of monthlyPonumbers, was a typo in the docs
ok
You should instantiate DBLClient first, e.g., dbl_client = topgg.DBLClient(client, "TOKEN"). Then you can fetch the info data = await dbl_client.get_bot_info(). Then just get it with either data.monthly_points or data["monthlyPoints"]
Note that you shouldn't instantiate the client multiple times, so don't do it inside the command callback
ahhhh thanks
Op, the key is also converted to snake case, so it's data["monthly_points"] if you were to get it using that syntax
i still haven't understood
Do you know what a webhook is?
Well, you need to know what that is first, unless you won't understand
No
A webhook in web development is a method of augmenting or altering the behavior of a web page or web application with custom callbacks.
a webhook is a url to which it sends a post request
i get that
but what do i do in this specific top.gg case
So basically it sends stuff through internet from 1 place to another
i get that
Now where are you hosting ur bot
just a python script
i mean, replit.com if it matters, but i don't think it does
and sometimes on my pc when i'm developing it
does it have a custom ipv4 address for u app
it should do, yes
Are u sure
Ok, then use this example link, but replace the things inside with ur actual things
Yea
where link
You have to port forward whatsoever ever
where link tho
Wdym link
^
which example link
What
wdym
Wdym by automatically opened
route is the path of your webhook
import topgg
bot.topggpy = topgg.DBLClient(bot, dbl_token)
@bot.event
async def on_dbl_vote(data):
print(data)```
A Uniform Resource Identifier (URI) is a unique sequence of characters that identifies a logical or physical resource used by web technologies. URIs may be used to identify anything, including real-world objects, such as people and places, concepts, or information resources such as web pages and books. Some URIs provide a means of locating and r...
ok, thats all fine, but that is never mentioned in the topgg library docs anywhere
it says create bot.topggpy with an instance of DBLClient
and then simply use that event
it shouldn't require me to use a webhook, no? that would make me manually have to process events
^^
@forest trench?
Which docs are you looking at?
Link
top.gg.DBLClient is exactly the same as commands.Bot in d.py, its not for getting data, webhooks are for getting data
WebhookManager is what you need
^
oh wow, i'm stupid
I'm not sure where you got that outdated example from
i just used the bot.topggpy = DBLClient as shown under Examples on the Python page on docs.top.gg
under Manual server post count
without realising i needed something else for vote events
Brb
How do I make the bot send a message when someone gives vote
i need a Code for NodeJS
use webhooks
@restive otter https://docs.top.gg
Thanks
ok
The url to the webhook listener. Depends on where the server is
Like vps/replit/heroku/home etc
http://yourvpsip:80/webhook
The authorization on the page you found the url
Like the url field, below that it says authorization
You are the one that decides it. It just needs to be the same on the site and your code
try it and see
you really wish this message gets pinned dont you 
Hi. I followed the webhook server tutorial at https://www.npmjs.com/package/@top-gg/sdk but this is not working for some reason, it’s not logging the user’s id when voting
I set the correct http://ip here:port/dblwebhook but it seem to not be working
Ok i fixed, I was using my bot’s token/api key instead of the authorisation string.
What do i type here if i want my bot to take the token from env file
Gives me error with that
Ah got it forgot it was "or empty string" with TS
🤦♂️
sorry for mention
Yeah, one moderator can handle the issue
ok
yo how can I get my top..gg token?
Go to bot profile > edit > webhook there is
thank you
Why I have this error?
aiohttp.http_exceptions.BadStatusLine: invalid HTTP method
I use http (not https)
code:
thanks bro
from discord.ext import commands
import discord
import asyncio
import topgg
class TOPGG(commands.Cog):
def __init__(self, bot):
self.bot = bot
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "psw")
bot.topgg_webhook.run(5000)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print("ok")
def setup(bot):
bot.add_cog(TOPGG(bot))```
no problemo
pls help me lol
why when I do ```py
curl -d '{"user":"640518207257444374", "bot":"893494390142697493"}' -H "Authorization: token" -X POST http://ip:5000/dblwebhook
it works but not with top.gg
token = password that I choose
ip = ip du vps (not localhost ip)
I can't get the voting information
const webhook = new Topgg.Webhook('PASS')
router.post('/vote', webhook.listener(vote => {
console.log(vote)
}));
Result :
{}
I would just like to get the id
is the event firing?
Yes, vote = {}
test button in https://top.gg/bot/mybot/webhooks
you may want to try without using the webhook listener middleware.
router.post('/vote', function (req, res) {
console.log(req.body)
}));
help me^^
you can see stats with https://dblstatistics.com
View the historical performance of up to 29401 bots listed on Discord Bot List (top.gg). Updates hourly.
the same
req.body = {}
is the event firing, but empty body?
(with top.gg)
yes
trying to see if others have your same issue
no, no event detected
OK thanks for trying
oh
If I launch curl command with not data
He not detect
It is possible that we have the same problem
also try removing any middleware and logging the body directly.
I launch that
deleted because ip leak
oh thanks^^
using the js library too?
if I remove the body directly, I get an internet error
no topggpy
500 Internal Server Error
error
but
500 Internal Server Error
not error
but not detect
I thinks it's a top.gg issue
just to double check, you are hosting on a vps right? @blissful belfry
yes
are you running your curls locally?
ie on the same server the webhooks on
or on your computer
I launch curl on my computer, and send request to ip of my vps
not localhost
You can test if you want lol
(but mp)
so curl isnt being used from ssh?
yes

curl on my computer -> webhooks on my vps
not same network
so it's not in localhost
I can give you the order if you want (in mp) to prove you
yeah, just needed to double check.
it does seem to be top.gg's side, but its weird its only you two.
We dont have this issue known anywhere, so I'm kinda stumped.
I have send mp :p
@placid loom hey, we may have found it.
does your authorization have any characters with accents in them?
such as é.
it seems accented characters mess with the request
I just found ! I use "bodyparser" and it is deprecated 😅
Thanks for the help
@client.event
async def on_dbl_test(data):
"""An event that is called whenever someone tests the webhook system for your bot on Top.gg."""
user = client.get_user(int(data["user"]))
guild = client.get_guild(811730903482761246)
channel = guild.get_channel(840666055777058836)
astra = client.get_user(int(data['bot']))
embed = discord.Embed(title="Test Vote successfull ", description=f" ``{user}({user.id})`` voted up for {astra}\n\nYou can vote **[here](https://top.gg/bot/811733599509544962/vote)** every 12 hours.", colour=discord.Colour.red(), timestamp=datetime.utcnow())
embed.set_thumbnail(url="https://media.discordapp.net/attachments/813029623277158420/901963417223573524/Idee_2_blau.jpg")
embed.set_footer(text="Thank you for your Support", icon_url="https://media.discordapp.net/attachments/813029623277158420/901963417223573524/Idee_2_blau.jpg")
await channel.send(embed=embed)```
why is the member None?
on my other bot, it still works
is it because my bot was added today?
oh that
how did that no give any error then damn
cause if user is none then it should have given attr error when using .id
uh wait not i get an error
Ignoring exception in on_dbl_test
Traceback (most recent call last):
File "/home/container/.local/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "/home/container/bot.py", line 114, in on_dbl_test
embed = discord.Embed(title="Test Vote successfull ", description=f" ``{member}({member.id})`` voted up for {astra}\n\nYou can vote **[here](https://top.gg/bot/811733599509544962/vote)** every 12 hours.", colour=discord.Colour.red(), timestamp=datetime.utcnow())
AttributeError: 'NoneType' object has no attribute 'id'````
which dont helps me
that is indeed true
i mean the same code is working fine on my other bot
thats why i dont understand why the bot cannot get the user
can it be because i dont have intents=discord.Intents.all in my client = commands.Bot?
or something else like that
why would that be a problem discord and top.gg is different things
but u can go ahead and try
now it worked
but why? when you say that discord and top.gg are different things, intents can be the problem lol? that dont makes sense
but thanks for your help haha
wlcm
have a nice day :)
you too :D
^^
can anyone send an example code?
what should the webhook be? can it be discord webhook?
nvm i fugured it out
Well yeah
You don't use the members intent, hence no member objects are cached, meaning get_member will return None
Ahh ok thanks
why isn't my on_dbl_vote event getting called?
import topgg
from discord.ext import commands
import logging
logger = logging.getLogger('apollo')
class TopGGCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.topgg_token = ""
self.client = topgg.DBLClient(bot,
self.topgg_token,
autopost=True,
post_shard_count=True,
session=bot.session)
self.webhook_manager = topgg.WebhookManager(bot)
self.dbl_webhook = self.webhook_manager.dbl_webhook("/dblwebhook", "")
self.dbl_webhook.run(5000)
@commands.Cog.listener('on_autopost_success')
async def on_autopost_success(self):
logger.info("Autoposted guild and shard count.")
@commands.Cog.listener('on_dbl_vote')
async def on_vote(self, data):
logger.info("Received vote: {data}")```
the on_autopost_success event is getting called tho
yes
yes, but i never tried posting something to an endpoint , if you could give an example code, it would be better
test it using postman
thats mentioned on the docs aswell
wait where
especially https://docs.top.gg/api/bot/
ok lemme look
try making a test vote
but I don't get the info from the logging module
oh god i hate discord.py, should have studied js
hi, guys , need help! Using webhooks I can receive event when click "test" button in dashbord on top.gg, but can not receive any callbacks when vote in bot page.
both of you try using postman or reqbin to test the request
Have you setup your webhook listener correctly?
Do you have an active connection listening to requests?
Is the webhook somewhat hindered by a firewall?
You could test webhooks with one of the following tools to make sure they work:
- reqbin
- postman
if you're not sure about any of these, nor about what any of the tools mentioned above are useful for, I'd suggest reading over https://sendgrid.com/blog/whats-webhook/
I can receive callback when click "test" button on top.gg dashbord, but I can't receive any callback when voted on botpage.
I follow the guide here. https://docs.top.gg/libraries/javascript/#webhooks
please help
see above
@rain heartI made test vote and it works, but real vote on bot page can not work
try making a vote using reqbin or postman
m following the same
but still it dont work in mine
and also m using repl
const webhook = new Votegg.Webhook('here my pass')
const app = express()
app.post('/dblwebhook', webhook.listener(vote => {
console.log(vote.user)
}))```
@tawny blazeI fixed the problem, we can only receive callback when user vote your bot or server, not rating
yea dude
as i tested with my webhook
nothing happened...
yep
as m on repl
so i have to add the webhook URL of my repl link na?
@raw raven
yes, you have to
I again suggest testing it with postman or reqbin
Documentation for @top-gg/sdk
try this
// In this situation, your TopGG Webhook dashboard should look like
// URL = http://your.server.ip:80/dblwebhook
// Authorization: webhookauth123
the url should be accessable
without the : 80
http compulsory or any?
https wont work if you're using a basic webhook
unless it is proxied, which it is in repl's case iirc
You'll have to figure out your repl url
wdym?
:3000 wont be needed
iirc repl provides a web-based port for you
You'll have to read the docs on their end for that
there's no port definition on repl
it uses a proxy to force every 80 port on your repl url
so you'd need to set your port to 80, define a endpoint, then your webhook url would be [yourrepl].[yourname].[repl].[co]
it is not, just you not being able to understand how repl works
yea bcoz the hosting i was using
shutted due to some reason
so m not so experienced on repl
yea i got it
its like u get it by creating a file
server.js
const server = express();
server.all('/', (req, res) => {
res.send(`OK`)
})
function keepAlive() {
server.listen(3000, () => { console.log("Server is Ready!!" + Date.now()) });
}
module.exports = keepAlive;```
so what now with the [yourrepl].[yourname].[repl].[co]?
https://docs.top.gg/libraries/javascript/#webhooks I applied what is described here, but I don't know how to integrate it into the command, can you help?
Hey, this is the topggpy support server?
Integrating webhooks into a command doesn't make much sense.
It's nothing less than a webserver constantly listen for POST requests on your specified route/path/ressource.
There's nothing you can trigger or do by using a command at all.
So.. what are you actually trying to do then?
i'm trying to make a special command for the one who voted
Well then you have to receive the requests if someone has voted and need to store this data (the user ID) in your environment, speaking about a database.
If somebody is running your command, you gonna query your database and check if the user is in the list.
You could manually send a request to the API to check if a specific user ID has voted in the last 12 hours.
But that might result in spam if more and more people are using the command.
So what method would you recommend
database way is way better
I cannot get post request even though I turned off my firewall. You have any idea why this happens?
Setting up a webhook listener, which does receive the POST requests from topgg if someone has voted and store the user IDs in your database.
trying to test it on my localmachine
Did you port forward?
no
You'll need to from home networks
http://portforward.com/
Has guides for most routers
A port forward is a way of making a computer on your home or business network accessible to computers on the internet even though they are behind a router. It is commonly used in gaming security camera setup voice over ip and downloading files.
how do I do it
Taking the webhook code as example to store vote.user in your database.
As well as a timestamp to make sure later, the user has voted within the last 12 hours.
is this really mandatory to do? I remember I was testing it without doing this
😮💨
If its on your home network and you want to recive votes from topgg yes
If you only want to recive tests from the same computer then no
It seems not working with port forwarding either
Well if you setup port forwarding properly and added a rule for your firewall and it's still not working, you may not have a public accessible IPv4 address.
Caused by ISPs nowadays using DS Lite to tunnel your IPv4 for internal identification
You better not use port 80 at all
I tried it with 3000 also
Does https://icanhazip.com/ shows a IPv4 address for u or IPv6? Not that I wanna see it, just know it.
ipv6
IP address lookup, location, proxy detection, email tracing, IP hiding tips, blacklist check, speed test, and forums. Find, get, and show my IP address.
here shows ipv4 also
That means what I assumed .
You don't have a public accessible IPv4 address then.
:(
There's actually no ISP I know supporting port forwarding for IPv6 yet, in 2021
I guess I will write the code hoping it works properly on actual bot 
Yeah servers do have a (static) public address.
yep
No port forwarding but setting up firewall rules can still be a thing.,
If the default input policy is drop.
np
how do i make a server on top.gg and when they vote for the server it will send in a webhook?.
@true brook https://topgg.js.org/classes/api.html#hasvoted
thx so much
so what language @undone crane
uh java, but why is this relevant
i'm only asking if there is an endpoint to get the users who voted on my bot
oh ok
is the last 1k people ok?
oh found it
thanks
do I need to have webhook and thing to update joined server details?
like server counts? no
Ty for telling
i

heroku requires us to run a web dyno in order to listen to web hooks
right?
or can i just make do with worker
i tried a lot but it seems to not work without a web dyno if anyone knows a way around it hit me up
Out of this channel topic
@rain heart
I'd like to include a counter of the servers the bot is in but I don't know how
Api always returns status 401, I tried resetting the token also
I actually posted server count using top.gg API but it gives an error topgg.error.Unauthorized: Unauthorized (status code: 401)
i hosted my bot by repl
and putted the webhook url as the url provided by the repl
and added in the code
but when i send a test
it doesnt do anything
Im a little bit confused, when posting to the API, do I do it on one shard or on all of them?
I feel only one but idk
How does the guild count work with multiple shards? Each shard is posting the total number of guilds for the whole bot, but top.gg seems to be doubling the number I send.
I am following the steps of https://docs.top.gg/api/@reference/, I change the :yourbotid in https://top.gg/bot/:yourbotid/webhooks but I am getting error 403
Your class is named discordbotlists, but you try to refer to a class named TopGG
this is because you need to have an authentication token.
your http header must have
{
"Authorization": "your-topgg-token-here"
}
you cannot use webhooks when your bot is not approved
@jagged nimbus here
Ok
https://webhook-topgg.com is great for just seeing who voted
Ohhhh
If you want to integrate features such as vote rewards into your bot etc, try https://docs.top.gg
u want to know each time someone votes?
@jagged nimbus follow this then
I will reward them with my economy system....it is a bit childish but... 😶
What language?
Js
Okay I will
go to libraries choose js
K
Will it work fine for commando structure?
Not in particular, but not wanted either
You aren’t authorized then
isnt that 403?
you need to send your topgg along with the header
No that’s forbidden
ok
so its kinda frowend appon but still not against tos?
A proper endpoint requiring an authorization will at first check if you’re authorized or not returning a 401 if not before restricting access to the resource returning a 403
According to the RFC
It just depends on for what
No prob and thanks a lot for help ☺️
@tidal idol where do I put authorisation and URL which I got from webhook-topgg.com
404
replace botid with your bots id
Where I put
But I can't go to
When I click 404 come
403
Yeah webhooks cannot be accessed on unapproved bots
is dblapi.js not a thing anymore? my bot keeps logging the warning
[dblapi.js autopost] The provided client is not supported. Please add an issue or pull request to the github repo https://github.com/top-gg/dblapi.js
I still use dblapi.js and everything works fine
Dblapi.js is super out of date
It's been deprecated for atleast 8 months maybe a year
thanks 🙏
It doesnt work with the current version of djs does it?
it does actually
Hmm intresting
It does work
is it any different in terms of code or can i just reuse the same code for the voting webhook?
It's very diffrent in terms of code
gotcha
I would like to know how I can authorize my bot
It needs to be added to the website and approved
when setting my webhook url, do i need to use the webhook url template provided in the docs? the one thats http://your.ip.here:port/dblwebhook
asking bc i cant really get it to work, so i want to use an existing ngrok subdomain i have instead
i make a vote log but i also want to add total votes of voted member how i can ?
You'll need to store user votes in a database and access the database to get vote counts
To update my bot I use the stats api. How does the api know I’m not doing a fraudulent number. Meaning if I do 10000 how does it know if it’s legit or not?
the api doesn't know, though we see you doing that, kindly ask to set it to the correct number
otherwise your api access will be removed
Excuse me, is there a way to remove the stats?, I'm using @top-gg/sdk
i hosted my bot by repl
and putted the webhook url as the url provided by the repl
and added in the code
but when i send a test
it doesnt do anything
Have you setup your webhook listener correctly?
Do you have an active connection listening to requests?
Is the webhook somewhat hindered by a firewall?
You could test webhooks with one of the following tools to make sure they work:
- reqbin
- postman
if you're not sure about any of these, nor about what any of the tools mentioned above are useful for, I'd suggest reading over https://sendgrid.com/blog/whats-webhook/
please help me on #support
Wait for someone who can help
getting attention in different channels does not change
sorry but i have no idea what u r saying
as its a repl project
how to do that?
visit these sites and enter your repl webhook url and make a test request
kk
yea it worked
as it said OK
in the content when i putted by repl link and send it
also try real voting instead of test
yea but do i have to add something
like /dblwebhook
/voted
etc..
??
do i? @rain heart
the path you set in your code
of course
Webhook
?
Updated for the new design: How to get your Top.gg token
- Press the edit button on your bot page
- Open the webhook section on the left menus
- Press reveal (possibly required to first generate a token)
Webhook help
What exactly do you need help with it
You need to create yourself a webhook through code, if you're using a server and just want messages instead of rewarding, consider using https://webhook-topgg.com/
screenshot what you have entered on your webhook section field
reset your token please
Oh from here thanks i wanna make myself but need codes
then refer to the docs: https://docs.top.gg
There are only 4 things
There's everything provided on what exactly top.gg sends with your webhook, you can also use a library mentioned on the pinned messages
k
will it not work if i remove it
you'll also need to remove that line it is using
its for server count on bot page
Username#0000 (usermention) has voted to servername and now has 00 votes.
Yeah you'll need to read the docs, making a webhook requires programming knowledge
Link
scroll up, already sent them
Is this
is this the token of bot that i have putted in .env ?? so i need to replace its name instead of token i need to pu .env name right >?
or what i need to do
idk
@rain heart
no clue about python, but I dont think set_auth is right
with the self.api
where's api coming from
idk xd
i took this thing from yt
refer to the docs instead: https://docs.top.gg
https://docs.top.gg/libraries/python/ this section
how do i get my api token?
on webhhooks in ur bot editing
im confused.
read pins
saw it?
ty
yea it is
see @rain heart
and is the authorization correct aswell?
yea
and it is still not sending anything?
const webhook = new Votegg.Webhook('here my auth') @rain heart
yea..
and testing the request yourself including the authorization works too?
wait..
i jst filled the url
not the auth
in which section should i fill the auth?
Bearer Token
or
Basic Auth
or
Custom
yea it also worked..
custom is the one you need to test with
Send the url and the authorization
dm?
sure
done
Did you receive anything with top.gg data?
also, try having a simple "Hello" instead of already trying to fetch the data in it
by testing?
k wait
with the vote data included
do you get anything
no..
not sure then
@rain heart ok it is working now..
what was the issue
its like repl users have a file name server.js
that shows the url and says OK
so i was putting the listener thing in index.js instead of putting it in server.js
and it worked when i putted listener in server.js
@rain heart
when i put console.log(vote.user)
it gives id
how can i make my bot dm that person?
You can fetch the user from the provided id and then use that user object to DM them
Refer to the docs of the discord Library
kk
where do i find my webhook auth?
That’s something you set
is it this?
Yep
oh ty
No problemo
What must be in here?
im getting an http 400 error when i try to post my bot's stats to topgg
return await got.post(API_URL, {
headers: { Authorization: TOPGG_TOKEN },
json: { server_count: guilds, shard_count: shards }
}).catch(err => {
console.error(`Unable to post stats to Top.gg: ${err}`);
});
nvm
Not sure if you can only post the shard count without the other shard parameters
Try to just post the guild count
I have the same questionq
The url that topgg will send an http request to
What?
The place that your web server is listening on
It’ll recirve the http request and do what it wants to do with it
But I don't have a web
U need one
U can make one with nodejs or python
??
Any language, really
Yes but I don't have any domain
? Whattt
You seem to be entirely confused about the concept of webhooks
read this
is it possible to track top.gg votes entirely through a bot, or do i still need a webhook?
- yes
- what language?
python
Hey
Hello?
Anyone here?
I need a help in python like when user votes my bot it should give some reward to the voter just teach me anyone
Hey pls help
But I have trouble
what maybe the cause of this?
pretty sure i got the token right
i'll try getting a new one
nope
do i have to import tasks from top.gg for this?
it's the auto posting server count part
something's prob wrong here but yeah
tasks is defo not topggpy thing
@frank turtle u using discord.py?
You're already using the autopost, no need to worry making your owk task
yeah
Wow I too use it
Do u know how to make vote rewards when user is voted?
oh that's not what im doing
Hmm then?
will do something like in the future but now my bots in its infancy
just server count in the site thing
Hmm
Okok
Good luck
I need some help with making vote rewards when user is voted
@restive otter can u help me with making vote rewards when user is voted?
Sry to ping
Hmm after school can u help me?
Ok thx :)
@modest fjord read the docs in the meantime
Hmm yes I read it
Oh
@frank turtle from discord.ext import tasks
@tidal idol can u help me how to do vote rewards when user is voted
Umm.. I read it but I have some doubts and problems
i did
What problems
That someone said I should use Webhooks for vote reward that confuses me
Then
Ok can u explain how to do it in detail?
That gets the person who voted and from there you could give them X rewards
I’m on mobile and at school so I can’t
Yes I saw but it has only print function
Then replace print function with code for giving the reward
Oh ok after school can u help me pls?
Yep I have no idea about how to make it
Then don’t add it until you know
Don’t code outside of your comfort/knowledge zone
I can understand the code but I need some help
just ask
What?
state what you're having troubles with
Oh
I need help doing a vote rewards when user is voted I saw the top.gg docs and I can understand the code but it has only print function I don't want print function I need it to do automatically
the print function gives you an example on how to use the user id from the vote.
You can for example use that id to then change certain values in stuff like a database etc
You can take use of the following endpoints
and no I'm not going to help through direct messages as I'm at work right now
Okok
read through that, it explains what you need to check if a specific user has voted
Hmm kk
there's also libraries https://docs.top.gg/libraries/javascript/
Umm I need python
select python on the libraries then
Hmm
i want to fetch all total votes amount of voted members how to get ?
My intention is to make that in my bot I have urban dictionary command but I want the command to be used by users who voted my bot, and if user is not voted it should send a msg like this "you need to vote if u want to use this command"
Aurel u there?
The documentation gives all the details you need
the vote response gives you user id's
or you could do an API lookup to see if a user voted but then it will be slower
ghost ping??
ah
@jagged nimbus remove your token
const Topgg = require("@top-gg/sdk");
const webhook = new Topgg.Webhook("test")
app.post("/voted", webhook.listener(vote => {
let channel = client.channels.cache.get("907041749845811271")
let user = client.users.cache.get(vote.user)
if(!channel)return console.log("channel was not found")
if(!user)return console.log("user was not found")
channel.send(`${user} voted for us, thank you`)
}))
where is the error
im replit
you're replit?
ya
soo what is the wrong?
tias
try it and see
what i put in here?
@tidal idol@restive otterany one know?
bro ask for discord bot script
wtf?
@tidal idol discord webhook, right?
for the room he will send it?
Pls Give Discord Bot Script
this?
This is a script top.gg
Nope
The url to the webhook listener you made
oh mb mb
I have changed it
regenerated*
Where I make it
Is there isn't Any tutorial video,
Just the docs
https://docs.top.gg/
It will be useful,?
I am also not able to work with top.gg api
it is not showing any error
nor it is working
I think I'm running out of luck
@modest fjord Have you got it working?
Nope trying other way afterwards
Other way?
Yep
Do u know how to restrict command in discord.py?
I'm not asking code
Just teach me
I'd personally do DB calls rather than REST calls. So setup a webhook and store the timestamp and the user ID and just have a check for the command. The other way is to make a request to the API each command invocation which I don't think is ideal
Kk thx
Is this for restrict command or vote rewards?
Restrict
Hnm
It's not that different. If you wanna restrict it, then store the user ID and the timestamp in the DB. If you wanna reward users, then just give them something once you got requests from Top.gg. Both are doable with webhooks
Hmm
For vote rewards I'm gonna try some other way
What? Parsing Discord webhook messages you redirect the requests to? Sounds hacky
self.topgg_webhook = topgg.WebhookManager(self.bot).dbl_webhook(WHAT MUST BE IN HERE???))```
What must be in the ()
And the route, I'd suggest you see the example or read the docs
thanks
Not the whole URL lawl
Mine neither
let author = context.params.event.author.id
const Topgg = require(`@top-gg/sdk`)
const api = new Topgg.Api('blah blah')
let userVote = await api.hasVoted(`${author}`)
it says it cannot find the module @top.gg/sdk
then... install it?
i did
TypeError: AutoPoster is not a function
const poster = AutoPoster(process.env.TOKENTOPGG, client)```
My code is this
why is not wokring
yes
const { AutoPoster } = require('topgg-autoposter')
regenerate it then
#play klay bbj
What the command for the link
the what?
Link for this site
What is this for?
const DBL = require('top.gg');
const dbl = new DBL('my token', { 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!`);
});
``` why isnt this logging anything on console even though i have voted?
somebody?
yes
the url printed on console right ? http://0.0.0.0:5000/dblwebhook
0.0.0.0 means being able to connect from anywhere
So replace 0.0.0.0 with your servers public ip
but this should also work right?
It is a visualised IP to tell you that you could connect on localhost, within the network etc
Check your heroku docs for that
so if i am hosting locally now.. and i put my public ip insted of 0.0.0.0 and it says Your form contained some validation errors , Invalid url
Has to be a proper URL aswell
http://yourip:port/path
Also, using it locally requires you to portforward
Its not only private 😛
It can be used to declare.
you cannot use 0.0.0.0 as an ip to connect to
E.g. For minecraft servers, it’s often use to declare any IP of the server
Of course, you cannot reach 0.0.0.0
But it can be declared as any ip of the pc
declare that there's no definition of where that server can be reached
In the context of servers, 0.0.0.0 can mean "all IPv4 addresses on the local machine". If a host has two IP addresses, 192.168.1.1 and 10.1.2.1, and a server running on the host is configured to listen on 0.0.0.0, it will be reachable at both of those IP addresses.
Yes i know its private
But if he is trying to listen to a IP or somethinr, 0.0.0.0 may work also
You can’t reach another server using 0.0.0.0 but another server can reach that computer
But not using 0.0.0.0 to reach it, either through localhost, a network ip or a public ip
Hey guys now my bot sends a thank you msg in user's dm for voting
But still need help with vote rewards
Now just simply change data with the same thing
Me?
U talking to me @rain heart ?
I
Hey guys I'm new to webhooks so plssend me how to do vote rewards in discord.py pls Don't send me api docs coz I already read it and I understood the python code but some says webhooks should be implemented so pls help me
well https://docs.top.gg literally has the code you need
if you dont know how to impliment vote rewards then don't
only proceed with it if you know how to do it
also, what do you want the vote rewards to be?
an example of a flask application in python
additionally to this, u wanna import requests from flask and inside ur app() u wanna print(requests.json)
Like In my bot i have urbandictionary and a meme command, so i need to restrict those 2 commands for the user's who didn't vote my bot and the command should be executed only by the user's who voted my bot
What is this for?
@jaunty plank 1. iirc you can get vote status via api, is this truei and 2. s it advisible to make api requests every command to see if user voted?
tyia
You can get vote statuses from the api using the has voted endpoint.
It's not advisable to go that route every time a command is run though.
Our api does have ratelimits and could result in no one being able to run these commands
It's advisable to store the vote data in a database and pull from that
alr ty woob
I read it few seconds ago
hey @jaunty plank could you help me setup a vote tracker for my bot...i am using the code given in the docs and nothing is logged when i vote.?
Did you fill in the url and auth on topgg?
yess
What are you hosting with? Home/server/vps/replit etc
i am testing it locally but i actually host on heroku
If you want to do it locally you'll need to port forward and allow the port on the system firewall
A port forward is a way of making a computer on your home or business network accessible to computers on the internet even though they are behind a router. It is commonly used in gaming security camera setup voice over ip and downloading files.
there's doc available for the vote object definition using webhook? I'm a bit confused about guild, type and bot 🤔
can we let users vote directly from servers using the bot itself?
it sounds weird to me
ok, so what's guild string then ?
its the id of the guild voted for
so if i am hosting on heroku i need to only use the code directly? with ip adress as 0.0.0.0??
when they vote they can select the server in their server list?
i never voted for any bot, then i'm a bit confused 😓
so the guild id is always the support guild server specified on the website
not a guild which would be represented by the vote
if they voted for a bot, the bot parameter will be used. if they voted for a server the guild parameter will be used
oh i finally found something
this should definitely be directly exposed on the readme
/**
* If webhook is a bot: ID of the bot that received a vote
*/
bot?: Snowflake;
/**
* If webhook is a server: ID of the server that received a vote
*/
guild?: Snowflake;
/**
* ID of the user who voted
*/
user: Snowflake;
/**
* The type of the vote (should always be "upvote" except when using the test button it's "test")
*/
type: string;
/**
* Whether the weekend multiplier is in effect, meaning users votes count as two
*/
isWeekend?: boolean;
and then type must be explicitely typed as 'upvote' | 'test' on the node SDK
i'm making a quick PR
whats the api that shows how many votes your bot has?
this is the votes im guessing?
yeah, overall. monthly points is what you have this month(what shows on the counter on the site)


