#topgg-api
1 messages Β· Page 90 of 1
vote event and check if vote.type === 'test'
okay
why does the webhook on ready say it's running on 0.0.0.0 ? xD
Did I do something wrong? 
And testing isn't working somehow...Guess it's because of that
No, it says that on purpose
Replace it with your actual public IP when pasting the URL somewhere
is that correctly set up?
okay
Hodd I was having the same issue
oh okay
yeah I can't figure it out so if you end up getting it will you ping me with the solution?
o-k so it doesnt load when theres a vote for the bot
console.log(`User with ID ${vote.user} just voted!`);
});```
I assume that's an actualy IP and your port 5000 is open and forwarded
like idk how do I open and forward my port? xD
send help plz
Google yolo
xD
I don't get this
Can someone walk me through the setup of webhooks from start to finished? xD
const express = require('express');
const app = express();
var server = require('http').createServer(app);
app.get("/", (request, response) => {
console.log(Date.now() + " Ping Received");
response.sendStatus(200);
});
const listener = server.listen(5000, function() {
console.log('Your app is listening on port ' + listener.address().port);
});
setInterval(() => {
http.get(`http://${process.env.PROJECT_DOMAIN}.glitch.me/`);
}, 280000);```
In the console it logs:
Webhook running at http://0.0.0.0:0/dblwebhook```
is it supposed to be 0.0.0.0:0
so now I can enter that url in the Webhook URL section?
Replacing the zeros, yes
Wait, do I need to replace the zero's to an IP if it is a Glitch.com project?
Alright ty
NEVERMIND
If I don't handle the error event, will it be thrown? This is in reference to dblapi.js; I'd like to do away with dbl.on('error', func)
errors will still be thrown
wait for dbl
uh idk actually
I would assume
That's specifically for errors with posting stats with the autoposter
how do i set up webhooks for a user voting
what do i put for the 0.0.0.0:0?
your bot's website/ip and an open port for the webhook
it doesnt run on a website
then your bot's host's ip
what if we get the address already in use
acc let me host it on glitch
what if we get the address already in use
@restive otter then you can just switch the port to an open one
it doesnt have to be port 80
right
@restive otter how do i find the website ip
with glitch
i dont know, i dont use glitch
oh
It's http://your-project.glitch.me iirc
top.gg webhook send a post to my express server?
example how to receive who voted in my bot
You need a webserver with http handling
Aka express
Just configure a url for dbl webhook
And treat the POST request it'll send, the data will be in the body
const http = require('http');
const express = require('express');
const app = express();
const top = app
let server = require('http').createServer(top);
top.use(express.json())
top.post("/topgg", (request, response) => {
console.log(request.json)
response.sendStatus(200);
});
?
It would be something like this? @knotty garnet
You should use body-parser for body parsing, not express
And it parses and sets request.body, not request.json
what do i put for the 0.0.0.0:0? webhook
If it's on glitch, this:
It's
http://your-project.glitch.meiirc
oh ok
Don't remember whether it's http or https
how do I see what port I need to use for the webhook?
mine isn't doing anything when I test it and I think that's why
Are you self hosting?
yes
let me try
nope nothing...maybe it's my ip? which IP do I use? the IPv4? or Default Gateway?
here are my options https://prnt.sc/swxh2d
would anyone be able to help
How can I send the data that top.gg sends me to discord?
{ bot: '656966356037533713',
user: '412591106149187593',
type: 'upvote',
query: '',
isWeekend: false }
You can send it in an embed
@empty jay https://whatismyipaddress.com/
I just want the user ID to be sent, { user: '412591106149187593' }
Then only add an embed field for the user
Should I post my bot's server count manually if it never emits the "ready" event? Because it seems like the autopost function only works on ready.
Should I post my bot's server count manually if it never emits the "ready" event? Because it seems like the autopost function only works on ready.
@restive otter autopost should post every 30mins if you haven't specified a number smaller then that...Smallest possible time in between posts is 15 mins
If you have an event handler, it also doesn't matter where you put it...I suggest you put it in your entry file e.g. index.js or whatever it's called for you...If you have the dbl.on('ready' blabal) in your ready function, it will only emit on startup, because obviously the bot is only ready once...So put it in your index.js...and then just do smth like js dbl.on('ready', e => { console.log('Posted!'); });
i mean like dblapi.js only posts the stats of your bot when the ready event is emitted but mine never emits it
the bots ready event
Yes?
my bot wont emit the ready event no matter what so should i post manually instead of using dblapi's autopost
Gimme a sec
the source code clearly tells us that it autoposts in the client.on("ready") event
Where does it tell that?
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}`);
})```
Put the dbl events in your main file and see what happens
nothing
dbl only posts on the ready event
but my bot doesn't emit the ready event
i think i will just post it manually using dbl.postStats()
does the vote.user give id?
yes it gives a snowflake (id) @spark sphinx
i mean the discord user id?
yes
oki ty
would it be ok for me to use the api on my testing bot then once ive got everything set up push it to my actual bot? it would look like im sever count spoofing on DBL's end
We don't mind if you post server count below your actual one when testing
ok thanks
uhm dbl.webhook.on('vote', vote isnt responding for me
how can i add this api in my bot i am not understanding anything..?
hey
are there any ways to counter command spamm through the discord.py api? or i have to right my own spam filters
-api
THIS CHANNEL IS ONLY FOR SUGGESTIONS/HELP/BUGS TO DO WITH OFFICIAL TOP.GG API LIBRARIES AND API DOCS FOUND AT
https://top.gg/api/docs
mod only
guys, my bot froze on 32 servers is there anything wrong with the script?
and define "froze"
@knotty garnet is because my bot is on 40 servers but there are 32 servers on the site
what script?
@knotty garnet in my script
Iβm still not getting any results from my webhook...
Are you sending it to a discord webhook?
I'm not getting any voting requests from my webhook.
The tests are going through, though.
Also should it require the package
Idk then, I hope someone else can help you
Thanks for trying
have a great night or day
okay, now the webhook receives the data but the dbl.webhook.on('vote') is not working
again, no errors in the console
what did you put as your url in your bot's edit page?
what did you put?
@vapid cape
what kind of webserver do you have running on that?
do you use nginx or express? or both? or something else
do you have SSL?
Idk if that matters, but dbl sends a POST request
Maybe you're expecting a GET request
No the dashboard for the webhook receives it, but the code doesnβt get it
where is the dashboard hosted? what does it run on?
is it an express.js server?
oh...
Lol
i mean
you're not hosting your bot in that are you?
where is your bot hosted?
My bot is hosted on a vps
And the api server?
What api server
well, if you want to receive vote events in your bot, you need to put your bot's server in your url
your vps ip address and webhook port and path
also, your bot shouldnt be able to use port 443, its a reserved port for https
i am confused
lets say your bot is hosted in a vps
you add dblapi.js to your bot and you write new DBL("top.gg token", { webhookPort:5000, webhookAuth:"bla123" })
then you go to your top.gg edit page and under webhooks you would write http://YOURVPSIPADDRESS:5000/dblwebhook in url and bla123 in authorization
then you save it and press the test button and you should receive a vote event in your bot
if it still doesnt work, you might need to open/allow port 5000 (or whatever port you decide to use) in your vps firewall (in some hosts this must be done through their admin panel)
is the hostname supposed to be 0.0.0.0? http://i.love.zypher.xyz/yay/bc7dba449d.png
0.0.0.0 means "any url"
right
That's used internally
The IP you're supposed to use externally is your server's public ip
nginx
You gotta open a proxy if the port is within the listen range
π all working! thanks for your help
Yw, nginx can be a pain sometimes
Are you sending it to a discord webhook?
@median badger As far as I know yes
The tests are going through, though.
@cedar bison my tests aren't even going through and I'm not sure if it's my code or what...
i wasnt talking about that
you were talking about a webhook right?
yes
ok I can't even get my tests to go through...are you able to help me really quick?
@jaunty depot
Hey
the api does not work
Why is it not outputting anything
https://gyazo.com/f03c2a3e638e76415a3bd2998ed87108
I have put the login details and still is not working.
Gyazo
@empty jay
Did it work for you?
no
how can i get dbl token?
Spice up your Discord experience with our diverse range of Discord bots
@gusty elbow Click the link above your message and click your bot. Then if there is no token, generate one. Hopefully that helps you
^
TypeError: Cannot read property 'id' of undefined``` error in api
pls help me
anyone there ?
So I have a database
How do I set the voted option to false when the vote finishes (i mean, how do I make an action when the vote finishes after 12 hours)?
anyone know how to get items from an array mongodb discord.py
-api
THIS CHANNEL IS ONLY FOR SUGGESTIONS/HELP/BUGS TO DO WITH OFFICIAL TOP.GG API LIBRARIES AND API DOCS FOUND AT
https://top.gg/api/docs
-mongodb
Read the message please
ok
@restive otter you only put a word then delete again
@limpid vale what ?
@restive otter just do client.shard.id instead of client.shards.id.

client.shard.id
Good Morning
are u stupid?
nvm
seems no
You dont have eyes ?
nvm
Yes, i have
seems no
nvm
such a stupid
Don't imitation me, you dumb
This is #topgg-api
tm
how can I setup the post vote webhook stuff
@next pendant are you using js ?
const { body } = await get(
`https://top.gg/api/bots/692374798654898260/check`
)
.set("Authorization", process.env.DBL_TOKEN)
.query({ userId: message.author.id });```
why does `body.vote` return undefined?
for context, get is defined as const { get } = require('node-superfetch')
https://top.gg/api/bots/692374798654898260/check first check what this link returns
{"error":"No query userId, add ?userId= to your request"}
check if the user has voted, i console logged body: turns out my brain is in my stomach;
{ voteD: 0 }
if(voted){
} else {
}
});```
try this
@slow kraken
Can you try this too;
const { body } = await snekfetch.get(`https://top.gg/api/bots/${client.user.id}/check?userId=${message.author.id}`, { headers: { 'Authorization': dbltoken } })
Hey
the api does not work
Why is it not outputting anything
https://gyazo.com/f03c2a3e638e76415a3bd2998ed87108
I have put the login details and still is not working.
The port is not open?
@gusty elbow Click the link above your message and click your bot. Then if there is no token, generate one. Hopefully that helps you
@restive otter ok
@olive arrow I don't have a firewall
@left osprey show your constructor (without pass)
@olive arrow π
What is it set to in dbl
I mean, i got the token the web hook port and pass
what is the command to add a game activity to your bot
I mean what did you set the webhook too
what is the command to add a game activity to your bot
@steady minnow #development
Np
@olive arrow I set the webhook to get the votes
like when someone votes it console log
I know what the webhook is for lel
lol
My VPS public ip
-dotpost @restive otter
@restive otter
Please do not post dots to clear your messages/get attention. It adds absolutely nothing to the conversation and just causes spam.
If you need to get attention, then say hello everyone. If you need to clear your messages, then press the Esc key. If you do not follow these instructions you will be muted.
Then what port
Do this
http://your IP:5000
@olive arrow one thing tho, i did http://IP:5000 and pressed test and for me it did not work
Try restart your webserver
The test thing on top.gg requires you to save first
its kinda buggy
try pressing save and then test
-api
THIS CHANNEL IS ONLY FOR SUGGESTIONS/HELP/BUGS TO DO WITH OFFICIAL TOP.GG API LIBRARIES AND API DOCS FOUND AT
https://top.gg/api/docs
-notr
Δ°ngilizceden baΕka dillerde konuΕmak iΓ§in #memes-and-media kanalΔ±nΔ±, top.gg hakkΔ±nda destek almak iΓ§in #support kanalΔ±nΔ± kullanΔ±n.
not sure if you can check how many times a certain user has voted but you could store it in a database
once a user votes
How do i setup a webhook for the on_dbl_vote in discord.py? I have been looking in the API docs but im very confused on how to do it.
how can i do so everytime someone vote on my bot it get logged in my server?
Thanks, i'll have a look now
@warm oasis Our official libraries support webhooks that you can use
like im not good at js could you send me the right thing to run in my bot?
well that's against the rules
(discord.js) i added a webhook to my bot, and i know it works because i posted stats with it, but it's not receiving any vote events. i copied the vote event from the docs and it still won't work
no errors or anything
did you configure it on the website
configure?
if that's the endpoint that you've created, yes
depends on how your webserver is configured
if you have a reverse proxy forwarding http/https to port 4000, then you dont need port 4000 in the url
its weird
my route says it's loaded
I just voted and it didn't send the message to me
should it my url/votes/dbl
constructor(...args) {
super(...args, {
route: "votes/dbl"
});
console.log('I AM LOADED');
}
and I logged it, and it's loading properly
test the route with reqbin
tried that
it just says "not found"
if my route is: "votes/dbl" should it be myurl/api/votes/dbl or myurl/votes/dbl
https://api.sxbot.pw/api/votes/dbl
``` this is my webhook url on the site
Hi! Sorry I know this is a noob question but I'm using discord py and how can I send the server count over to top gg?
can't figure this out
it seems like everything connected
what should happen when i hit "Test"?
Your webserver will receive a http request with type being "test"
ok
[12/Jun/2020:01:30:43 +0000] "POST /api/votes/dbl HTTP/1.1" 404 9 "-" "DBL"
I see this in my nginx access file
how can I test that my route is working though
.
Errr.....cookie api?
There's imgur depending on what kind of images you want
Also, I don't think this is the right place for that topic
o
image generator api
i recently switched from vps to discloud host, now i don't know what i need for url
because I don't have the ip nor the port
and server stay N/A
You have to post it
Do you have the appropriate api package? Or are you making standard post requests
You need to send requests to somewhere that can receive the votes
If you go to edit bot, its somewhere near the bottom
Thanks a lot
where do i get the vote script/api or whatever
I did everything ,,, Still webhook isn't working
Do you have the appropriate api package? Or are you making standard post requests
@median badger yes
bruh
how can I require dbl if it is in the index.js, here is the code:
const DBL = require('dblapi.js');
const dbl = new DBL(process.env.DBL_TOKEN, { webhookServer: listener, webhookAuth: ... }, client);```
You can put dbl on the client instead
client.dbl = new DBL(...)
Then you can access it anywhere your client is with client.dbl
thanks π
What I did was make the bot read the vote log and if it is mentioned then it sends a message
What's wrong here
``const EventEmitter = require('events');
class MyEmitter extends EventEmitter {}
const myEmitter = new MyEmitter(nothing);
myEmitter.on('event', () => {
console.log('an event occurred!');
});
myEmitter.emit('event');
``
-api
THIS CHANNEL IS ONLY FOR SUGGESTIONS/HELP/BUGS TO DO WITH OFFICIAL TOP.GG API LIBRARIES AND API DOCS FOUND AT
https://top.gg/api/docs
00:00 UTC Friday up to 23:59 (11:59 PM) UTC Sunday
uh
I guess thats why my webhook gave double points right now
so besides vote count what else can I do
how do some bots, merge commands into votes, or whatever?
"merge"?
Hi can you help me to create a Webhook and how to send vote on channel ?
hi
why is the bot_id here https://github.com/DiscordBotList/DBL-Python-Library/blob/master/dbl/client.py#L69 always None?
A simple API wrapper for top.gg written in Python. Contribute to DiscordBotList/DBL-Python-Library development by creating an account on GitHub.
like no kwargs.get?
See _ensure_bot_user
so that is making it the bot
hmm i thought it was to give another bot id to use the api as that 
Essentially it's set to none so that your linter doesn't scream at you
You can have two dblclients running at once
It gets the ID from the client/bot object given to the constructor
aha
How do I merge votes with Currency or something like that
I meant rewarding them
For Voting
I recently switched from vps to discloud host, now i don't know what I need for url
because I don't have the ip nor the port
const dbl = new DBL(config.dblToken, bot);
@median badger ok
it isn't that hard
@balmy hamlet if it were easy I wouldn't be asking for help, and if you don't know the answer just ignore it
I found this for an automatic server count in discord py
import dbl
import discord
from discord.ext import commands
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'dbl_token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes
async def on_guild_post():
print("Server count posted successfully")
def setup(bot):
bot.add_cog(TopGG(bot))
Sorry I know this is a dumb question but where should I call the setup() function?
it's easy tho
automating with the API illegal?
Which file do I excatly put the API in?
Put api in index.js / server.js file
ok
..
cached
you need to gen a random number after a ? to not cache
np
discord caches images from the same url
to post stats, It's the method postStats(), I am right? When I use it
dbl.postStats(client.guilds.size);
I get Error: postStats requires 1 argument
So I don't understand
what is your djs version
12.2.0
Ok well I have found it's client.guilds.cache.size instead of client.guilds.size, thank's
When pasting the URL somewhere, replace 0.0.0.0 with your public IP address
if I'm use heroku to run bot what should i fix?
Your app's Heroku url then
How i check if webhook work then console.log("Work")?
I'm using Heroku too, but my laptop isn't responding
Hey Mods, could it be possible that you deactivate my bot for a moment? It appears that the top.gg server requests my bot really fast. Just to check, if this is true or not I'd ask you guys to deactivate my bot for like an half hour
This is the bot ID 559827216620322831
how do i make a log of people who upvote my bot with v11
@neon berry haha its funny because you dont have a bot
Okay, nvm. It appears that top.gg is requesting my Bot every second. I threw it now from the website and everything is back to normal. Weird
Is there api to do a bump command?
I didn't even know you could bump your servers, I just checked the API docs and there is nothing about it.
You cant
I want help
You cant
@spiral steeple then explain the bots you can use to bump servers
@empty jay there isnt an api to bump servers unless it is a listing website which includes its own api, bump bots use their own bumping algorithms
you have to do that yourself
looks like top.gg to me Steven lmao but ok thanks harry https://top.gg/servers
That hasn't got anything to do with top.ggs api + you cant bump servers on discord server list

holy shit
you just dont get it
you cannot bump servers on top.gg
https://oliy.is-just-a.dev/jb3d9t_4376.png this isn't possible
It is possible, but not at all worth it.
you cannot bump servers on top.gg
@spiral steeple you really don't get what I was asking do you?
I wasn't asking if I can go to that website and do it...I was asking if anyone knew of existing API
then why is it in here?
No existing API
I was asking if anyone knew of existing API
MY EXACT WORDS
yes, you cant
there is no bump api feature, command, button anywhere
it is, as I said, impossible, in any way, to bump a server on top.gg through its api or otherwise
that's not at all what you were saying earlier lmao
Why do I get this error when trying to post server count using the dblpy python api?
I dont get it, I am using the DBLPY library, what am I supposed to do?
yes
this is my code
Wdym?
@opaque jetty I got the same error and ended up reverse engineering? that method for PyDBL
I can send you thr code if you like
DM me and ill send it to you if your still getting the issue
It's not exactly an "issue" here
how works the vote api?
i have this:
const DBLL = require('dblapi.js');
const app = express();
const server = http.createServer(app);
const dbll = new DBLL('mytoken', { webhookAuth: 'myauth, webhookServer: server });
dbll.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbll.webhook.on('ready', hook => {
console.log(`Webhook running with path ${hook.path}`);
});
dbll.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
app.get('/', (req, res) => {
// ...
});
server.listen(5000, () => {
console.log('Listening');
});
dbll.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
on startup:
Webhook running with path /dblwebhook
Listening
but nothing happens, when someone votes.
yes
but now i get: Error: listen EADDRINUSE: address already in use :::5000
because express is running on 5000
but if i change the webserver to 3009, then i also have to change the webhookPort, and that will result in the same error.
you dont use webhookPort if you have an existing server
you use webhookServer like in the code you posted above
the code you posted above looks correct, hence why i asked about your top.gg settings
did you change anything?
well, changed it back to the code above, but this part is not running:
dbll.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbll.webhook.on('ready', hook => {
console.log(`Webhook running with path ${hook.path}`);
});```
well it was running before, you posted the logs
yes, but that was a different code
well what is the current code then?
This is what i currently have:
const DBLL = require('dblapi.js');
const app = express();
const server = http.createServer(app);
app.get('/webhook', function (req, res) {
res.send('webhook page');
});
app.get('/dblwebhook', function (req, res) {
res.send('webhook page 2');
});
// Change the 404 message modifing the middleware
app.use(function(req, res, next) {
res.status(404).send("Sorry, that route doesn't exist. Have a nice day :)");
});
// start the server in the port 5000 !
app.listen(5000, function () {
console.log('Example app listening on port 5000.');
});
const dbll = new DBLL('token', { webhookServer: server , webhookAuth: 'auth' });
dbll.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbll.webhook.on('ready', hook => {
console.log(`Webhook running with path ${hook.path}`);
});
dbll.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
and it get only this on start:
Example app listening on port 5000.
try const listener = app.listen(...)
and webhookServer: listener
i changed app.losten to server.listen and that seems to work for:
Webhook running at http://0.0.0.0:0/dblwebhook
Webhook running with path /dblwebhook
Example app listening on port 5000.
now i have to find someone, to vote, to see if it fully works. π
test button on your bot's Edit page
Thanks, still not working.
do i have to fix the http://0.0.0.0:0/dblwebhook? or is the url on the edit page wrong?
replace 0.0.0.0 with your public IP address when entering the URL somewhere
but where do i have to enter the url? i only have to above code.
Your bot's Edit page, scroll down to the very bottom
that's: http://myip:5000
even if it is portforwarded and so, another ip?
so what do you have in your bot's edit page, in the URL and Authorization fields?
URL should be http://YOUR.IP.ADDRESS.HERE:5000/dblwebhook
Authorization should be the same thing that you put in webhookAuth
Thanks, works. π
User with ID 356857570285191169 just voted!
User with ID 356857570285191169 just voted!```
i am getting error : 401 unauthorized, what do i do
Is this a good idea. ```ts
setInterval(() => {
this.cli.shards.forEach(shard => {
this.dbl.postStats(this.cli.guilds.filter(g => g.shard.id === shard.id).length, shard.id, this.cli.options.maxShards as number);
});
}, 1800000);
since the bot is clustered.
or would it be better to have a single microservice handle stats posting
@ me if u respond
@restive otter I let the main controller do the posting
tho ig you can post each set of shards and the count
and the api can join the dots up
what do you think message.author.has does
gives a 1 if you voted and 0 if not @sullen nymph
Have you properly read dblapi.js docs
ye
Where does it mention has and not hasVoted
OR using message.author instead of a DBL client provided by the library itself
Can you output what hasVoted returns
@green mantle alrighty thanks
i guess it will take few mins tho i use vps so i need to transer files @sullen nymph
Maybe make it send a message in a channel if that's easier for you
if (process.env.LOCK_KEY === 'captcha-prod' && this.masterCluster) {
setInterval(async () => {
this.dbl.postStats((await this.cli.getStats()).guilds);
}, 1800000);
}
``` mission success
hello
this picture it mean my api worked?
@sullen nymph ok so it said that author is not defined, witch dose not make sence, and i changed to this cause i miss read the docs
Well it does
You don't have any message to access in an event that just says "server count posted"
help ?
-api
THIS CHANNEL IS ONLY FOR SUGGESTIONS/HELP/BUGS TO DO WITH OFFICIAL TOP.GG API LIBRARIES AND API DOCS FOUND AT
https://top.gg/api/docs
i do
Well what is message in your case
Yes
the message that is sent with +getreward
@viscid forum
Is it in the scope of the function
how do i fix my code, the docs are useless
If I was to establish a rest api, can I use that as an endpoint for the vote webhooks?
Ok
How can I check if a user has voted for my bot in Python?
If you read the docs @merry zodiac you may find something
thx a lot
No worries.
This was working till i added a timer, i have looking at for a while and see nothing that i did wrong. But if you don't vote you still count as you voted(top.gg api) no clue what i did wrong, dose anyone know see to fix?
Is your webhook pointe to your IP address?
what does that mean
@viscid forum use await
@restive otter where?
@oblique sluice whatβs your code?
Thsi was working till i added a timer, i have looking at for a while and see nothing that i did wrong. But if you dont vote you still count as you voted(top.gg api) no clue what i did wrong, dose anyone know see to fix?
Do I have to open my ports on my internet box?
It's only on port 5000, because my host is on another port and it doesn't work ...???
I keep getting ```Unclosed client session
Do you have any idea what function you used to get that
I'll take a look when I'm free. You can open an issue on the Github repo if you want
Oh wait, I am running it by doing setup(client) in the on_ready() function. Is that right?
Let me try doing it without calling it.
You use bot.load_extension on the file if it's separate
Its the same file.
bot being an instance of commands.Bot
Oh you don't need the setup function
You can just bot.add_cog it but eh, there's no real difference anyway
3.5.3 up to 3.8 work just fine, haven't tested above that
Yeah I tried it without calling it and got this:
Does it appear if you don't load the cog?
Should bot be uppercase or lowercase, I am importing it as this:
Uppercase
bot should be your instance of the commands.Bot class
Yeah
Huh
@opaque jetty https://stackoverflow.com/questions/46112848/python-package-aiohttp-has-a-warning-message-unclosed-client-session
My code is as follows:
import asyncio
import aiohttp
urls = [
'http://www.163.com/',
'http://www.sina.com.cn/',
'https://www.hupu.com/',
'http://www.csdn.net/'
]
async def get_ur...
have you checked this out
not sure if it's the sure-fire solution, but it seems related
Its just that i'm not controlling the session, the library is
Can someone link me to a bot that has the top.gg api webhook working please?
I honestly think the problem is that I am not using cogs, and the discord.py session is interfering with the dbl session
I will try using a cog and report back
This was working till i added a timer, i have looking at for a while and see nothing that i did wrong. But if you don't vote you still count as you voted(top.gg api) no clue what i did wrong, dose anyone know see to fix?
Server count isn't posted
await axios.post(`https://top.gg/api/bots/${this.user!.id}/stats`, querystring.stringify({server_count: this.guilds.cache.size}), {headers: {"authorization": process.env.DBL_TOKEN, "Content-Type": "application/x-www-form-urlencoded"}})
Nvm, the Authorization needs to be capitalized, which is weird because the headers are not case sensitive
I wanna set the webhook url to my linux vps
How can i set the url
.
This was working till i added a timer, i have looking at for a while and see nothing that i did wrong. But if you don't vote you still count as you voted(top.gg api) no clue what i did wrong, dose anyone know see to fix?
it checks if you have a timer then it cheacks if you voted are not. the timer works. But when you have not voted it says you have
no clue why
well
@balmy hamlet what should be the webhook url??
http://my-ip/dblwebhook
wait
you're trying to delete their id and data from the database, once a minute has passed, but 86400000 is not a minute
but
it's 12 hrs right
which is correct
if the bot stops then the timeout will never complete
if the process stops*
when it restars it resets
yes
the timeout will never finish
hence they'll never get removed from the database
with is ok beacuse i do updates every couple days and the timer commands dont give much
ye
boom, I get added to the database
ye
then you restart the bot for maintenance
my id will never get removed from the database
bc you stopped the process
Umm should work with map??? 
it is
why does that affect if voting is true
you set the timer
it does not affect if voting is true
didn't you say the id never gets deleted from the database
their id will get removed once 24 hours have passed
yeah
but that just makes another problem
api
if for some reason the process gets killed
so will the timeout
I recommend using a cron job
which runs on the system
hence the only thing that can stop it is the system being off
@balmy hamlet help me out now

@balmy hamlet digitalocean ubuntu 
yeah that timer dose reset rn as we said but right now thats not huge deal for me, its the hasVoted is true even if they havent voted, are you saying the timer effects that?
@restive otter i use that
Raj, try to run this from the command line
$ dig +short myip.opendns.com @resolver1.opendns.com
sorry if i sound stupid new to this api
Should i just copy paste this?
yes
well the api itself has nothing to do with the timeout being killed
yeha i dont care that the timer gets reset not huge deal with me, its the voting being true even if author hasent voted
@restive otter yeah
if you havent voted it says you have and gives reward
ok that's weird
wdym
you only need your host url and the webhook path
and the port if necessary
so it would be
Okay
http://yourip:yourport/webhookpath
Kek
is the first part to me are raj

Hmm
and you also need a webserver
so do you know why the .hasvoted always comes as true?
even if they havent voted
it ok if you busy rn
I'm not that busy
but let's get back to work
hasVoted shouldn't always return true
unless you actually voted
yep
yep
if you actually voted for your bot then you'll need to wait 12 hours, and then check again
it if keeps returning true then there's something wrong
did you vote or did you use the test button
yeah, i have no clue whats wrong. i voted. but i had some ppl who did not vote help me test. and it said they had voted when they have not
can i console logged th etests and they camet rue
and the code worked before i added timer dont know if i screwd something up but when i compared code they lokoed the same
hmm
lemme check something
are you sure they didn't vote for the bot?
if they didn't and it returned true the that's a weird bug, and I can't do nothing to fix it
yes
wait
is it ok for the code to be in
if it s in dbl.on('getreward' () => {}) it dose not work
idk if that matters
other wise i gusse its bugged
3|dbl | Webhook running at http://0.0.0.0:8080/dblwebhook
3|dbl | Server count posted!```
^ Logs
```http://144.172.8'.'''/dblwebhook```
^ url
It didn't worked

@viscid forum @balmy hamlet
i dont anything aboout that
Okay
wait
what did you put inside your webhoot url in top.gg
and don't show your ip
censor it
do you already have a webserver setup?
you need a webserver for this to work
and you need to create a post route to that webserver
the route should be called something like /webhook/topgg
or something you like
is it ok for the code to be in
wait
f it s in dbl.on('getreward' () => {}) it dose not work(edited)
[12:37 AM]
idk if that matters
[12:37 AM]
other wise i gusse its bugged
dude
that's not how event listeners work
@restive otter okok, now, show your webserver's code
Dolphin
what do you mean
it can be in the message event callback
but you can't just make up events that don't exist
dbl doesn't emit a 'getreward' event
that's not how it works
that works with all my other code
should it be in dbl.on('getreward' () => {}) it dose not work instead
for example, in d.jsm everytime the websocket receives a message, the library emits a message event, and that's why <Bot>.on('message') works
dbl does not have a getreward event
@balmy hamlet its half np
lemme check something real quick raj
Kk
and it that whats causing my problem it being in ?
so what should i put in it instead
not really
show your entire code
and hide your tokens
Raj, did you pass in a client to it?
@zSnails#5755 ye
me? ok i will put in a haste bin real quick
o
k
@restive otter what are you trying to do
I actually have no clue
posting server count
getting votes from the webhook
how are you trying to get the votes
vote event
I mean, what I did was that I setup a standard webserver and handled post requests to it
show your code inside the vote event thingy
I mean, what I did was that I setup a standard webserver and handled post requests to it
@balmy hamlet idk how to do
@balmy hamlet client instance
yeah but you only need 1 dbl instance
@balmy hamlet haste bin was not working so this will do. this is the worst code you will ever see. the get reward is near the bottom https://hatebin.com/ufoykneobf
that 1 instance can do everything
your prolem may be that the post request is getting sent to the webserver on the 2nd instance
Uhh I don't have any prob with it btw
your prolem may be that the post request is getting sent to the webserver on the 2nd instance
@balmy hamlet ahhh how to fix
Kek
Did
what did you set your path and port to when creating the webhook instance
@balmy hamlet /dblwebhook and port 8080
Webhook running at http://0.0.0.0:8080/dblwebhook
@viscid forum ok you have worse things on that code than that thing not working, you have more than 3 message event handlers, you don't need that many
@restive otter ok, and what did you put on top.gg
@balmy hamlet
http://ip:8080/dblwebhook
yeah those where the different sections, i use to sort that way. but not anymore its become a mess but one only i know how to navigate
it's actually weird that it isn't working
i know i am so confused
@viscid forum well I couldn't find the command due to that mess
its at the bottem
@balmy hamlet okay worked thx
After deleting that 2nd nstance
but if dbl.hasVoted always returns true then that's a bug which I can't fix
@restive otter see
Thx
np
so it dose not to be in a dbl.on ?
ofc not
wait
you don't need that code in any of dbl's events
you need it where you're trying to use it
so i should put getreward in dbl.on or did i do that part right?
What are you trying to do
don't put it inside of anything that has to do with a dbl.on
I need to get some sleep
brb
@olive arrow scroll up
no
its not working
its always true
no matter what even if the person hasent voted
Have you configured dbl?
like that right?
Yeah and with your client as well?
I mean did you put the client inside the dbl constructor, and is everything else working in terms of server count posting and stuff?
yes ok so this is my get reward and this is whats its in
Your what now?
Ok
That should work
Hold on allow me to test something, I'll be just a second
kk
It's nothing to do with the API
Since I've just checked with myself
As I have not voted for my bot
then what did do wrong?
if you wanna see all my code his is the worst code you will ever see. the get reward is near the bottom https://hatebin.com/ufoykneobf
Is your bot online?
nope
ye
On what line is the get reward command?
thats not the bottem
what is wrong here?
Didn't install it
I instaled it
No module found 'dbl'
Looks like you may have not installed it fully as it says it is already satisified
import dblpy
ill try
@olive arrow thats the bottem
yes
Hmm
?
yes
It's await dbl.hasVoted()
Np
