#topgg-api
1 messages · Page 114 of 1
I running on Heroku
So, the IP not is static (I think)
Well heard that name a few times but actually have no clue what it is.
Without a static IP or dns you will have to change the webhook url on top.gg over and over again which makes no sense
It is a host with free and paid plans, in case I use the free ones. And from what I saw there is no static IP
So there's nothing I can do?
Well try to imagine...
You have to enter a webhook URL on top.gg
What will you enter which is static and won’t change?
The url is static
Yes
But I still dunno if you can open ports on a free host service, you will have to try out
I can even try, but I don't think
The only open door was 80
Yeah default webserver port
Makes me think you can host your website on Heroku (for free)
I need a api for NSFW command. Can anyone tell how can I get
Well if so try port 80 and bind the webhook to any path you want for example „dblwebhook“
And test it
Okay now I just have to do it in NodeJs
How does that change the fact u host it on this mentioned free hoster?
Or isn’t your webhook service done yet?
What I meant is that I don't know how to do that
Oh
Well just follow the docs of top.gg
Thought you’re only experiencing issues with the webhook service not receiving any requests
Anyway gonna get some sleep
OK, thanks for the help. I will try to do what you suggested
Tell
hey can anyone use th reddit api or does it say numpy error in the win32 runtime
@here
here is my code
import praw
reddit = praw.Reddit(client_id="UtgfhdgOsI7ww",
client_secret="gsdefgetryhgeritughou8ywwgero8y34",
username = "cmcool_",
password = "ghbfghd",
user_agent = "DiscordBot")
subreddit = reddit.subreddit("memes")
top = subreddit.top(limit=5)
for submission in top:
print(submission.title)
and here is my error code raise RuntimeError(msg.format(file)) from None
RuntimeError: The current Numpy installation ('C:\Users\my name\PycharmProjects\Discord bot\venv\lib\site-packages\numpy\init.py') fails to pass a sanity check due to a bug in the windows runtime. See this issue for more information: https://tinyurl.com/y3dm3h86
Good night, I'm in development and I want to use the api discord bot list on my bot for rewards for those who vote for my bot, but I can't afford a suitable host, so I use repl.it and api discord bot list not there can you help me?
@willow sphinx
Help

Same i tried too but idk how to make it work
same ..
Test ?

what test ?
How To Get Recent Vote And Recent Donation Messages Of My Bot In My Server Channel?
But How?
Read the api docs
and donationbot probably also has an api
donatebot gives users, who donated, a special role in your server. You could make your bot check on a role add event if the user received that role from donatebot and if that's your particular role
how to get my dpl token
is it my bot token?
@empty gazelle sorry for ping, but can u help me?
ty ^-^
@sullen nymph i get this error
and the token is too long as well that the self.token is now up
well move it up yourself
it will still go up :/
wait nvm
@sullen nymph sorry for many pings but, 'dbl' has no 'DBLClient' member
Did you name any of your folders/files dbl
Rename it
to?
hmm ok
ok now this worked but still one more problem
do i do @commands.Cog.listener()
All methods (functions attached to objects) must have some kind of argument that refers to the object
usually self
and yeah
so self.print
ah
yeah sorry i started coding 3 weeks ago so i don't know much
it works now
ty
need help with
dbl.on('posted', () => {
console.log('Server count posted!');
});
problem not posting
const dbl = new DBL(token,{ statsInterval: 900000 },client)
Is your token defined?
yes
i have the webhook working but i can't get the posted working
const {token,dblToken} = require('./botconfig.json')
const Discord = require('discord.js');
const DBL = require('dblapi.js');
const client = new Discord.Client();
client.login(token)
client.on('ready',()=>{
console.log("ready!")
const dbl = new DBL(dblToken,{ statsInterval: 900000 },client)
dbl.on('posted', () => {
console.log('Server count posted!');
});
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
})
It may be the stats interval option, i believe options go after the client is defined
Try removing it or putting it after the client argument
Hmmm
i followed the doc
Just try removing it to see if that works
sure
Worth a shot
not working
Someone of my bot user voted my bot it says that you have voted already vote again after 12 hours but when I am trying to get data from the api it says he didnt voted today.
Is there a way to get how long it will be until a user is able to vote next? or when they last voted?
Ping me in reply please
Tracking votes yourself with the webhook would be the easiest way to accomplish that as far as I know.
Nope
You have to set up the webhook to work with a database. There's no timestamp info on the vote event so you'd have to set up the webhook so that when a user votes it adds a timestamp and their ID to your database. That way you can work out when their next vote is available.
You have to setup your own webhook service or send requests to the API
What do you want to do? Why do you need to set up server webhooks?
https://top.gg/api/docs#webhooks
^ covers the basics, only major difference is the returned data format is guild not bot.
Soo it can make a message in my server that someone voted
Tracking votes yourself with the webhook would be the easiest way to accomplish that as far as I know.
You have to set up the webhook to work with a database. There's no timestamp info on the vote event so you'd have to set up the webhook so that when a user votes it adds a timestamp and their ID to your database. That way you can work out when their next vote is available.
Alright thanks guys! Yeah already tracking votes so that's no difficulty, just wondered if there was a way to fetch instead of store it but that's no worries. Cheers for the responses
You're going to need to either set up a bot to send the messages or use a service like ifttt.com to get the data from the webhook and convert it for a Discord channel webhook.
k
Use the api link above for help
oh is it ok if i give money (using Unbelevaboat) to people who vote my server?
An easy way is to create an application in Discord (not a bot) and cURL requests to the API to send messages only to channel if that’s enough for u.
Or creating a webhook on your discord server and send requests to it.
The Discord API is easy to use and there are enough code snippets out there how to use it in JS, PHP etc.
Hi, I set everything up and followed the instructions, but the webhook is not working. Am I missing something? I just entered the URL
test your webhook with something like postman for example
I confirmed that the webhook is working. I don't know what else it could be
is the authorization correct etc?
I'm not 100% sure what to put there
just put "testauth" in both fields
on the "authorization" field on your bot page, and the parameter inside your webhook in your code
@rain heart how can i setup the webhooks
?
im python
anyways it says if im not using tasks extension then i use this
is that right?
yeah yeah i got it
i just need to do an event on_dbl_vote
When I run
const DBL = require('top.gg');
const dbl = new DBL(topToken, client);
....
setInterval(() => {
dbl.postStats(client.guilds.cache.size);
}, 1800000);
I get Error: 400 Bad Request :/
any ideas

someone else made it.
im getting these 2 errors
try self instead of client maybe
k
still
;/
@rain heart
the problem is with TopGG i guess
That's not because of top.gg, you're just misunderstanding the api probably
Did you define client?
yes
wait...
they made it bot and not client smh
wait bruh
still same problem
self will be the dbl client right? not your discord bot client.
and user wont exist, youll need to fetch the user.
what the fuck
I understand newbie and all that
but
do you ever read discord.py documentation
yes
The issue isn't dblpy or top.gg
Frankly, self refers to your instance of the TopGG cog
which doesn't have a method get_channel
I assume you have self.client instead
Also .send must be awaited
i didn't await sorry ;/
Apply the cog listener decorator to it
and make sure you use on_dbl_test to receive test requests properly as well
@sullen nymph instance of TopGG has no 'client' member
What does your __init__ look like for the TopGG class
Use self.bot then
finally
now the undefined var 'user'
in the api docs
it says "user" is the id of the voter
Data.user no?
For JS, yes. In dblpy you have to access dict keys instead of properties
Been thinking about adding support both in next version
derp
Yeah read what shiv said.
ow
Is the top-gg/docs repo deployed somewhere?
if this is what you mean
oh wait deployed
isn't that the one that is deployed at https://top.gg/api/docs ?
Doesn't appear to be, missing much of the content
you might need to ask xetera then
As suggested yesterday, I opened the port in which I has my webhook listening on for votes, but my bot still does nothing upon a vote
repo created 3 years ago, never deployed anywhere 

Is the server count api related? Or does it auto update once you reach a certain number of servers?
Thanks. Will read em later and check back if I have any questions while implementing
you have to make a post request where you post your guilds count(required), and the shards count(optional) and the shardid(optional)
best is to use the dbl library
so you don't have to go through the hassle of setting up requests
lol "hassle" of setting up requests...
You mean one line code sending a cURL request using POST method? That’s less work then using the DBL lib
not really
you also get the advantage of using the webhooks, dbl api in general (getting vote count etc)
ah yeah yet I have already seen waiters where they work
you will need to go through an external service/server to make top.gg webhooks go through discord.
most cases this is making a discord bot
ah :/
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!`);
});```
Doesn't seem to work.
whats your dbl constructor look like
including the port and auth?
const DBL = require("dblapi.js");
const client = new Discord.Client( { autoReconnect: true, disableEveryone: true, fetchAllMembers: true });
const fs = require('fs');
const dbl = new DBL('key', client);
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
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!`);
});```
oh wait i see where i went wrong
Working now
ty for making me see where i went wrong
That user has to be on your server and has to have dms enabled
How do I set up an automated message to a channel every time someone votes?
I have a basis down following the example on the API docs, but it doesn't work
Webhooks from dbl are the only way
const dbl = new DBL('', { webhookPort: 5000, webhookAuth: '' }, bot);
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
bot.channels.cache.get('778460112313647175').send(`User ${bot.users.cache.get(vote.user).tag} just voted for Tic-Tac-Toe!`);
console.log({channel: bot.channels.cache.get('778460112313647175'), user: user, _user: bot.users.cache.get(vote.user)});
});
You have to enter something in the webhook Auth
You also have to enter your webhook url inside your bot page
When I launch the bot it says my webhook is running on http://0.0.0.0:5000/dblwebhook, is that what I should put in there?
replace 0.0.0.0 with the actual ip
is this running on a home network?
It's running on a server
like from a proper host?
Is the port open?
Did you attempt to connect through a request client like postman
How do I do that?
Look up postman and look up a few tutorials on how to do that
How do I make requests with postman?
What would happen if you changed the options.webhookServer in the code?
WebhookServer is just something with express, scroll a bit further down to see another example on how to do this
Ahh, ok.
what would that Webhook be? where can i get him
For my bot I want to configure Top.gg api with my bot so it will show how many servers does my bot is in but i have no idea what is the right code to put it in to my bot. Can someone help me out please ?
I just dont wich code goes where in that part cuz its little confusing
How do I get a webhook that will work with top.gg
const dbl = new DBL('Your top.gg token', client);
in this code for the "client" what should i write ?
Replace your top.gg token with the api token
after that if i use this code
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
});
will this send all the things above to the top.gg or do i have to change some stuff ?
It will send
I'm pretty sure atleast
do U need to define dbl.postStats somewhere ?
No
dbl.poststats
``` is already defined
Once you called the dblapi.js pacalge
Package
ohh i just have to do npm i dbl
i forgot that
what can cause this?
I was wondering, I just got my bot approved, and I was wondering how to set up it to show how many servers the bot is in and how to use the token
@silk tundra first answer will display the number of servers your bot is in as the status. I believe it doesn't update unless you restart your bot though: https://stackoverflow.com/questions/53643130/discord-py-how-to-display-number-of-servers-bot-is-in
You can send a request to the top.gg API posting your server count as JSON string or use their lib to do so.
The url to the docs is pinned.
${client.guilds.size}
please keep this channel on topic, thank you.
Can anyone help me with getting server or member count on my bot page, I'm using nodejs and everything I have tried doesnt work, any videos available or smth?

Ping me if anyone had a nodejs template I can use
the last one I used didnt work
._.
Take a look at the docs. Pinned.
Docs for webhooks?
I'm trying to post server and member count-
unless that uses webhooks

The DBL docs explain how to do so.
Posting member count wut?
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})```
So I just wallop this in my index then replace top.gg token with the token on my bot page?
Last time I did that nothing happened
Posting member count as in
Members and server count on the bot page
yes
Server count yes, but member count?
Gimme a link
There is no such thing as a member count on bot pages
The code you posted doesn’t send the guild cache size to DBL
That's the docs for it
Then wheres the doc to post member / server count on bot page lol
Once again there’s no member count, you can just post the server count
That link aaa
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
});
So would this post shard count shard id and server count?
@plucky lance
It didnt work
Did you integrate the code into your bot?
yes
I used this exactly
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
});
And replaced
The token
With my bots token
So you didn’t integrate the code into your bot I guess.
Djs doesn’t magically know your bot and it’s token. That’s why you have to use .login(token) as described on djs docs
That code is an example how to integrate the dbl lib not a copy and paste version.
Huh how?
I literally put
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
});
In my index
And replace the token part with my generated token
Where?
Index ? Package or
Did you even login the client?
client.login('token');
^
Idk where
Where do i put that
Do I replace token with bot token too
Dude integrating djs and creating a client still requires to login using your Discord bot token.
Like how you did in your bot
^
Index or package
And do I replace
Token
With the token
How can I know how your build looks like?
Hey I have a question, how would I get the webhooks working if my bot is running on java?
I probably have to host a webserver, right?
Whats your djs version
12 is the best because it’s the least
12.3.1
Oh
@restive otter are you a simp
Then it should be clients.guilds.cache.size
no bruh
Lol but your name says that
Put the P at last and it will be simp
@restive otter ok bye!
this aint general but ok ig
yeah
Installed the dbl api ?
Pasted dbl token ?
ya
oh
i did like that too
hmm
yes
and dbl isnt working for me
u use it too
it will
why :(
how?
code
Make sure to enter your webhook URL
Then to webhook
then this should be your webhook url - http://IP_ADRESS:PORT/dblwebhook
const DBL = require("dblapi.js");
const dbl = new DBL('TOKEN', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
Is there a issue with votes atm ? Tag me for photos.
Bot says 325
oh
Then the analytics says 280
hey
hi
it asks webhook passwords
Yes
help me abt that
Keep it anything you want
im new to webhooks
I would love for a admin to confirm it tho
oh we setting a password?
then you should go to #support and say something like - Can Mods tell me exact count of votes as it's buggy for me ! My bot id - id
Lol
oof
Was told to come here

tell me that
Yep
thx

anytime
Was told to come to this channel
No they were talking about rahul
your question is not about api
your is about bug
Ask there
Already did
They didn’t even reply to me 
and typhoon
Sed life
oof
oh ok thx
is this right?
Client = discord.Client()
@client.event
async def on_ready():
dblpy = dbl.DBLClient(Client, (top.gg token), autopost=True)
?
python*
Use the Java
Read the docs.
There’s an unofficial github repo linked.
can u send the link? I couldnt find it
Pinned in this channel
Hey, anyone know why in discord.py
When I do like bot.guild.members, I only have the bot that's in ?
what do u want to know?
guild.members
or members on context guild?
How to use webhook to get voting information
@gloomy fractal will this link work to post status https://top.gg/api/auth/stats/679029815185113091
Hmmm I might not get the differences
I want a guild context members
Hi, i was wondering how i could give users a role in my support server if they voted for my bot?
this didnt really help tbh.
The "docs" https://top.gg/api/docs#webhooks are not helpful at all.
It didnt tell me how to implement with java.
I just want to listen for a webhook :/
How about using the menu on the left side clicking on JAVA LIBRARY ?
Google "webserver java"
also js api not working
for my bot
someone help
What are the api endpoints of top.gg
As written in the docs: https://top.gg/api
const DBL = require("dblapi.js");
const dbl = new DBL(
"OOIFBOSVFUPASB",
{ webhookPort: 6969 , webhookAuth: "sfugqaufvqsaf" },
client
);
dbl.on("error", e => {
console.log(`Oops! ${e}`);
});
dbl.webhook.on("ready", hook => {
console.log(
`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`
);
});```
I use this and My bot server count is hella a lot behind
I can't use webhook, who can help me
@latent narwhal
filename : guildCreate.js
module.exports = async (bot, guild) => {
await bot.dbl.postStats(bot.guilds.cache.size);
}
filename : guildDelete.js
module.exports = async (bot, guild) => {
await bot.dbl.postStats(bot.guilds.cache.size);
}
As the description above the URL says, you have to set up your OWN webhook service.
What you’re trying to do doesn’t make any sense.
@rich stag http://IP_ADRESS:PORT/dblwebhook
IP_ADRESS:PORT is my Bot id or webhook ?
ip is where the code os been hosted
and the port you make when you set up the webhook in your code
As said you need to run your own webhook service as explained in the docs (pinned in this channel)
You need to define a port you have make sure is being publically accessible and use the public IP of the device the webhook is running on
Imma sorry don’t speak your language which seems to make it impossible to explain you what you actually need to do
i don't understand, so I give up🤣
Thanks !
Hi, I was wondering how I could give a user a role for voting for my bot? Could anyone help?
Hola?
@blissful belfry https://github.com/top-gg/DBL-Java-Library
how do i test vote webhook?? do it and wait until someone votes?
Did you try the TEST button?
where is that, lol
webhook section of your bot/server
my head hurts lol... do i use webhook URL from a discord webhook?
Hi. How to i find dbl token
ok right, this is as clear as mud, what webhook link do i put in there then? the link that is logged in my console after it runs the webhook.on?
the docs expect you to understand what webhooks are and how they work which is probably why its unclear.
the url thats logged is mostly correct, except 0.0.0.0
0.0.0.0 in the web world just means any public ip
or more specifically the public ip the code can use.
all a webhook receiver is is an http server receiving post requests.
ok so i have set my webhook url to http://0.0.0.0:5000/dblwebhook but when i click test nothing happens... what should happen?
@jaunty plank has the votes been fixed on the analytics page sorry for ping.
how can i post server count on Bot page 🤔
0.0.0.0 is not your public ip @wheat copper
I have no idea, i dont keep track of fixes. @restive otter if there was an issue submitted on the github, it would be announced there.
np on the ping
Well on my bot page it says I have more votes than my analysis
Just abit strange
kk
I dont think ive heard of that issue.
might want to post it on the github if its not already there https://github.com/top-gg/issues
@jaunty plank do you want me to send you photos in dm ?
the github would be best, its what the dev team looks at
ok, so i set that to my actual public IP?
yes
@wheat copper am sure that’s ment to be the IP of where the code is been hosted ?
^^
yeah well im testing on a local bot atm so will be my ip? yes?
@restive otter Take a look at the votes diagram. The value may be different because it shows the last 7 days only, if I assume right
I am trying to make top.gg show how many servers my bot is in, I looked at https://top.gg/api/docs#bots but it dose not tell you how to add it into your bot. Do I add the code into my bots main file?
i assume discordjs?
Yeah
just especially explain for discordjs
it should be inside your main file, you can also add it to another file if you wish
Ok, thanks for your help.
but you will have to get your bot approved first in order to be able to use the top.gg api
oh that library is dead
ahh okie
how do i write somebody's username but not mention them: for example, "Hello, user, how are you" without doing @User#6237
like that
Ohh
nvm
feiuafh
wait
nvm
that didnt work
how do i write somebody's username but not mention them: for example, "Hello, user, how are you" without doing @User#6237
or something
Hello PM
Hey help me😔
hi @plucky lance
Actually I just create a new bot but i can't add this in top gg😔😔😔😔😔😔
That's a question for #development not API related
o ok
import dbl
import discord
from discord.ext import commands, tasks
import asyncio
import logging
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, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
# The decorator below will work only on discord.py 1.1.0+
# In case your discord.py version is below that, you can use self.bot.loop.create_task(self.update_stats())
@tasks.loop(minutes=30.0)
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count"""
logger.info('Attempting to post server count')
try:
await self.dblpy.post_guild_count()
logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
except Exception as e:
logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
# if you are not using the tasks extension, put the line below
await asyncio.sleep(1800)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
logger.info('Received an upvote')
print(data)
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))
i copied and pasted this code exactly but when someone votes for the bot it doesn't print anything in the terminal
except dbl_token switched with my token
How can i make a bot that tracks my servers votes?
is it just me why i already get the updates of the votes?
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!`);
});```
Webhook running at http://0.0.0.0:5000/dblwebhook
User with ID 290683144900706304 just voted!
I made it, thanks
hello im having an issue with pushing the server count
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('API-TOKEN', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})```
this is what im using the example script
but nothing ends up happening
import dbl
import discord
from discord.ext import commands, tasks
import asyncio
import logging
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, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
# The decorator below will work only on discord.py 1.1.0+
# In case your discord.py version is below that, you can use self.bot.loop.create_task(self.update_stats())
@tasks.loop(minutes=30.0)
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count"""
logger.info('Attempting to post server count')
try:
await self.dblpy.post_guild_count()
logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
except Exception as e:
logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
# if you are not using the tasks extension, put the line below
await asyncio.sleep(1800)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
logger.info('Received an upvote')
print(data)
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))
i copied and pasted the same exact code and it still doesn't log when someone votes
if anyone every needs to get the text "hello" and/or "world" from the top.gg api, here it is: (code snippet)
const fetch = require("node-fetch");
getWorld();
async function getWorld() {
let req = await fetch(
"https://top.gg/api",
{
method: "get"
}
);
console.log(JSON.parse(await req.text()).hello);
};
@dusky monolith make sure no firewall is blocking requests (and that your port is forwarded if you are hosting locally)
And for Christ's sake mind using on_dbl_test with the Test Webhook to save your own time and effort
I'm seriously starting to consider merging them both into one at this point
Is anything wrong with my code?
@commands.Cog.listener() async def on_dbl_vote(self, data): print('User with id {} has voted for the bot!'.format(data.user))
data["user"]
that's first
Second, are you actually getting votes sent to your webhook
import dbl
import discord
from discord.ext import commands, tasks
import asyncio
import logging
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'Token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/dblwebhook', webhook_auth='MDP', webhook_port=5000)
print(self.dblpy._webhook)
print(self.dblpy._is_closed)
print(self.dblpy._webserver)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
logger.info('Received an upvote')
print("vote")
print(data)
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))```
no vote is captured
why ?
console:
<bound method DBLClient._webhook of <dbl.client.DBLClient object at 0xb4029130>>
False
None```
lmfao how did you even get to printing those
and why
anyway
are you voting or pressing the Test Webhook button?
that wasn't a yes/no question
@sullen nymph
And did you answer this question properly
oh dear god
Discord webhooks aren't what top.gg means by "webhooks"
It means a literal webserver hosted on a physical machine
Get your VPS' IP address and use http://ip:5000/dblwebhook as the URL
where ip is your VPS' IP
thank^^
Also
If you press Test in the webhooks section
Use on_dbl_test
https://dblpy.rtfd.io/ dblpy documentation in case you need it
so, i have to put like a specific code to get the servercount to my bot?
@zenith elm yes
Read channel topic
is the code for the servercount the same for all bots? if so, could someone please paste it here
with port 5000
but does not work
and the code is launched
print(self.dblpy._webserver) is none
um
i didnt understand anything, but mkay
eh i have no idea how to do the servercount thing
lmao
import discord
from discord.ext import commands, tasks
import asyncio
import logging
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)
# The decorator below will work only on discord.py 1.1.0+
# In case your discord.py version is below that, you can use self.bot.loop.create_task(self.update_stats())
@tasks.loop(minutes=30.0)
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count"""
logger.info('Attempting to post server count')
try:
await self.dblpy.post_guild_count()
logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
except Exception as e:
logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
# if you are not using the tasks extension, put the line below
await asyncio.sleep(1800)
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))```@zenith elm
i don't understand your problem
@zenith elm your bot is in python ?
jour, why are you printing those in the first place
if yes, https://top.gg/api/docs#mybots
copy your token
and paste in self.token = 'dbl_token'
Like, I get printing _webserver but why the rest
arf
i go check
my bot's token? like from discord.developer portal?
Passing your client object to the DBL constructor will make dblapi.js automatically post server count every 30 minutes
No, not your bot's Discord token
Get your bot's top.gg token here https://top.gg/api/docs#mybots
and use it to communicate with top.gg API
no, go the token of api of top;gg
ok, so i copied the token, now what do i do?
and ```const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(Oops! ${e});
})```
You enter it in the example
Specifically, the DBL constructor
I just get dbl is not defined error in my code when i do that
install the dbl api
how do i install it?
npm install dblapi.js
Japierdole
import dbl
import discord
from discord.ext import commands, tasks
import asyncio
import logging
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/dblwebhook', webhook_auth='mdp', webhook_port=5000)
print(self.dblpy._webserver)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
logger.info('Received an upvote')
print("vote")
print(data)
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))```
doest work 😭
I'm literally asking you a question that requires specifying which of the listed actions you are doing
and you're just giving me "yes"
please
Use on_dbl_test and press Test in your bot's Webhooks section
could you repeat the question? please
okay
i add @commands.Cog.listener()
async def on_dbl_test(self, data):
print("ok")
i go test on top.gg
but doesnt work
What did you enter in the webhook URL?
http://IP:5000/dblwebhook
(modif my ip)
..........
and the code: self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/dblwebhook', webhook_auth='MDP, webhook_port=5000)
I entered the wrong ip?
ah
https is not http
i test with the protocole http but doesnt work
How can I make the bot detect when it is voted on the page like some bots do?
192.168.x.x isn't a public IP
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
the "yourDBLTokenHere" is the token that is created on the "my Bots" page I guess... but what is the 'password'?
Hi
whatever you set in the Authorization field on the website, Webhooks section in your bot's settings
How I can publish my bot?
Ok
I have to enter a password of my choice there?
Mhm
uh okay
That's what webhookAuth is. It's a password you create and use for confirming that requests are coming from top.gg
How can I get the bot to privately thank a user when voting for the bot?
what do I have to enter here?
like can it be anything?
and what happens if I leave it blank?
That's where you enter your webhook url
ah
Read the documentation closely
that's what I did for the last hour
but okay I will
I'm feeling so dumb rn, here it tells me that I have to set up the url, but what url?? like... "the url you want the webhooks to be sent to", where do I want them? I have no idea... :/
Not the webhook section, check out the section for your bot library
What language is your bot coded in?
On the Java Script section on the documentation, scroll down
hmm k
You should see something that says webhooks
webhook events?
It can’t because you have to setup your own webhook service and use that devices public IP/DNS which you enter on DBL
oh lol
DBL sends POST requests to YOUR created endpoint.
If you think it is complicated, then i suggest getting to it once you have more experience in that field
is there a way to remove server count from your bot's page using the dbl api? (im using js)
i'd imagine it's with the .postStats method but i'm not entirely sure
Why would you want to remove it
👀
ive tried that, it just keeps the old server count
const DBL = require("dblapi.js")
const dbl = new DBL('the top.gg token, I KNOW', bot)
dbl.on('posted', () => {
console.log('Top.gg, successfully posted your server count.')
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
``` doesnt seem to work.
Does it take time to post?
It should send a POST as soon as your client (bot) becomes ready.
After that, 15 minutes.
Nope, you can't remove the last reported server count, even posting 0 doesn't work, which makes no sense in my mind.
yeah thats what i thought
thanks for the help tho
would be nice if they added something to do so in the api, or have an option when you edit your bot's page to turn off server count, shard count, etc
Well shard counts are optional but reporting the server count if so is the minimum.
true
how can i test my voting code
There's a webhook TEST button
Hey guys, is there an event i can use when someone votes for my bot on top.gg? where i can get the users and give them rewards
webhooks.
you would fetch the users using your discord bot client, and give rewards with whatever system you make.
the top.gg api just gives you the event for vote.
thank you!
Is the DBL-dotnet-library still being worked on? I want to contribute but there really hasn't been much activity on the repo so I don't know if it's worth it. If anyone from the team is able to answer that would be great 😄
How do I authorize the api thingy?
why is my server count stuck at 25 servers please help me
looked at the pinned message
no solutions found
@restive otter I suggest DMing Veld for that question
Using the api.
https://top.gg/api/docs
Thank you 🙏
👍
dbl.on('vote', vote => {
client.channels.cache.get("780097750254485524").send(
new EBBdc.MessageEmbed()
.setTitle("Codey DBL Service")
.setDescription(`<@${vote.user.id}> Oy Verdi ! `)
.setTimestamp()
)
client.guilds.cache.get("743584269821149225").members.cache.get(vote.user.id).roles.add("775442552949309512")
})
Pls Help Whats Here The Problem
Should I use POST and GET requests, or should I use the python API.
@restive lintel what are you trying to achieve?
I'm thinking ahead, maybe we can make a stats command which would get the status of the bot on the list, maybe I could make voting rewards.
If you want to get data from an API you have to use a GET request
Alright.
its dbl.webhook.on @viral tinsel
method "on_guild_post" has no argument
could you help ?
(problem on visual studio code) not in console
also getting n/a in top gg
python
Please share your code
read the api documentation
`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")
`
Did you replace dbl_token with your dblapi token?
oh
there i will try that
sorry
also, my bot object is client do i have to change bot for client?
Best is to read the documentation
it doesnt say much
It does mention everything that is important when using the dbl API
If your bot instance is called client, you should rename it to bot, it's a standard
ok thanks
Hi, where do I start with using the dbl api?
Read topic of this channel
you can use the vote webhook
https://top.gg/api/docs
I want to get the webhook working with the voting for my bot ( I am using java )
Is there someone who wouldnt mind helping me?
I am not sure if I need a webserver for that etc. and I couldnt find a good Webhook listener for java to recieve the vote
You should be able to use Httpserver for that
so no extra webserver I need to buy?
thats some good news
Do you got any links going a bit further into the webhook thing? It's the first time working with webhook for me
😦
it says that it's in 38 servers while it's in 45. I copied the api code from python library in the top.gg api page and replaced "dbl_token" with my dbl token, but still its not working
@rain heart could u help?
First of all, I don't think it's a good idea ping people randomly. Btw I think that it should post the server count every 30 minutes, you just need to wait
bruh its been a day, i just woke up
and its still stuck on 38
also yeah im sorry for pinging, but i just saw them chat an hour ago
Can you please share the code? Since you have already posted your server count I thought that it was working correctly but you was impatience to see it change
Everything seems correct to me, I don't why it doesn't updates your servers count
Btw remove "import discord" since you're not using it
which URL do I need to insert there?
huh and I can recieve that then? lol?
No thats wrong.
or is it wait im confused.
wrong
this is not related to discord channel webhooks
ow
This is the url for your webhook you presumably made with httpserver now
lemme send you a better tutorial https://stackoverflow.com/questions/3732109/simple-http-server-in-java-using-only-java-se-api
where is API...
I am so clueless
package de.coaster;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class Webhook {
private static HttpURLConnection con;
public static void main(String[] args) throws IOException {
String url = "http://webcode.me";
try {
URL myurl = new URL(url);
con = (HttpURLConnection) myurl.openConnection();
con.setRequestMethod("GET");
StringBuilder content;
try (BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()))) {
String line;
content = new StringBuilder();
while ((line = in.readLine()) != null) {
content.append(line);
content.append(System.lineSeparator());
}
}
System.out.println(content.toString());
} finally {
con.disconnect();
}
}
}
I got this class now but I have 0 idea if it would work.
Footer
ah k
this is just making a web request do webcode.me, you want it the other way
to be able to get the information from the webhooks
take a look at https://stackoverflow.com/questions/3732109/simple-http-server-in-java-using-only-java-se-api
ye I'll
thanks.
btw what is more recommended automatic server count or manual
I use manual
depends on how fast your bot grows, best is to just post it on start
so manual?
yes
yes
it looks like I need a server in that stackoverflow page 🤔
Well you need a server to host your bot of course
yeah of course
You can implement the httpserver inside your bot
alright i updated the code and now we wait 30 mins
could you actually show me how.. Im not understanding that 100%
like what do I do with that webhook URL
How do I recieve the Data when someone votes
you can make a seperate class for both handling your httpserver and the incoming requests:
so for example, on your main(), you could use the following code to start your httpserver that should receive the code:
HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0); // create a Httpserver listening on port 8000
server.createContext("/dblwebhook", new MyHandler()); // creates a handler for when a requests comes into https://yourserverip.com/dblwebhook
server.setExecutor(null); // creates a default executor
server.start(); // Starts your httpserver
your Handler class could then look something like this: lets just let it return "hello world" when a request comes in
public class MyHandler implements HttpHandler {
@Override
public void handle(HttpExchange t) throws IOException {
String response = "Hello World"; // the response
t.sendResponseHeaders(200, response.length()); // response.length being the length of response, needed in the header
OutputStream os = t.getResponseBody(); // get the response outputstream
os.write(response.getBytes()); // write and
os.close(); // close
}
}
ohh where you wrote "https://yourserverip.com/dblwebhook"
in "yourserverIp" its the IP of my bot? right?
in order to be able to parse your webhook data (as the data format says under https://cdn.hopefuls.de/J3xn https://top.gg/api/docs/webhooks)
yes
try using postman for example, or make a simple wget through your machine
it's not going to work yet, this is just to verify that requests are actually able to go through
you can also just access http://yourserverip.com:8000/dblwebhook through your browser
and it should say Hello World
lemme try.
Ah I think the webserver isnt starting.
Somehow it's not going in the main()
show me your current code



