#topgg-api

1 messages Β· Page 90 of 1

vapid cape
#

its not a physical path, its a virtual one

upper dune
#

okay

#

is there like a dbl.webhook.on('test') function so I can see if it works?

sullen nymph
#

vote event and check if vote.type === 'test'

upper dune
#

okay

#

why does the webhook on ready say it's running on 0.0.0.0 ? xD

#

Did I do something wrong? BlobFearSweat

#

And testing isn't working somehow...Guess it's because of that

sullen nymph
#

No, it says that on purpose

#

Replace it with your actual public IP when pasting the URL somewhere

upper dune
sullen nymph
#

I assume that's an actualy IP and your port 5000 is open and forwarded

#

so yes

upper dune
#

okay

empty jay
#

Hodd I was having the same issue

upper dune
#

oh okay

empty jay
#

yeah I can't figure it out so if you end up getting it will you ping me with the solution?

spark sphinx
#

o-k so it doesnt load when theres a vote for the bot

  console.log(`User with ID ${vote.user} just voted!`);
});```
vapid cape
#

show webhook configuration and top.gg configuration

upper dune
#

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

upper dune
#

send help plz

sullen nymph
#

Google yolo

upper dune
#

xD

#

I don't get this

#

Can someone walk me through the setup of webhooks from start to finished? xD

slow kraken
#
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

sullen nymph
#

Yes

#

Replace it with the actual public IP address when entering the URL somewhere

slow kraken
#

so now I can enter that url in the Webhook URL section?

sullen nymph
#

Replacing the zeros, yes

slow kraken
#

Wait, do I need to replace the zero's to an IP if it is a Glitch.com project?

sullen nymph
#

Port being 3000

#

And don't specify port in the URL

slow kraken
#

Alright ty

slow kraken
#

NEVERMIND

narrow coral
#

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)

spiral steeple
#

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

restive otter
#

how do i set up webhooks for a user voting

restive otter
#

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

knotty garnet
#

It's http://your-project.glitch.me iirc

faint dew
#

top.gg webhook send a post to my express server?

#

I just put my webhook in top.gg, now how can I get the data that top.gg sends to my server?

#

example how to receive who voted in my bot

knotty garnet
#

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

faint dew
#
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

gentle urchin
#

You should use body-parser for body parsing, not express

#

And it parses and sets request.body, not request.json

restive otter
#

what do i put for the 0.0.0.0:0? webhook

knotty garnet
#

If it's on glitch, this:

It's http://your-project.glitch.me iirc

restive otter
#

oh ok

knotty garnet
#

Don't remember whether it's http or https

restive otter
#

glitch is https

#

hmm

empty jay
#

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

restive otter
#

Are you self hosting?

empty jay
#

yes

restive otter
#

Hmm

#

2333 is a default port but I might be wrong

empty jay
#

let me try

#

nope nothing...maybe it's my ip? which IP do I use? the IPv4? or Default Gateway?

#

would anyone be able to help

faint dew
#

How can I send the data that top.gg sends me to discord?

#
{ bot: '656966356037533713',
  user: '412591106149187593',
  type: 'upvote',
  query: '',
  isWeekend: false }
gentle urchin
#

You can send it in an embed

faint dew
#

I just want the user ID to be sent, { user: '412591106149187593' }

gentle urchin
#

Then only add an embed field for the user

restive otter
#

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.

empty jay
#

still not working...

#

@gentle urchin any ideas?

upper dune
#

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!'); });

restive otter
#

i mean like dblapi.js only posts the stats of your bot when the ready event is emitted but mine never emits it

upper dune
#

Heh?

#

No

#

So for me it posts my server cpunt every 30 Minutes

restive otter
#

the bots ready event

upper dune
#

Yes?

restive otter
#

my bot wont emit the ready event no matter what so should i post manually instead of using dblapi's autopost

upper dune
#

Gimme a sec

restive otter
#

the source code clearly tells us that it autoposts in the client.on("ready") event

upper dune
#

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

restive otter
#

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()

spark sphinx
#

does the vote.user give id?

restive otter
#

yes it gives a snowflake (id) @spark sphinx

spark sphinx
#

i mean the discord user id?

restive otter
#

yes

spark sphinx
#

oki ty

zinc fossil
#

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

sullen nymph
#

We don't mind if you post server count below your actual one when testing

zinc fossil
#

ok thanks

spark sphinx
#

uhm dbl.webhook.on('vote', vote isnt responding for me

old lake
#

how can i add this api in my bot i am not understanding anything..?

lapis edge
#

hey

#

are there any ways to counter command spamm through the discord.py api? or i have to right my own spam filters

sullen nymph
#

-api

abstract mothBOT
median badger
#

mod only

silk echo
#

guys, my bot froze on 32 servers is there anything wrong with the script?

knotty garnet
#

what script?

#

and define "froze"

silk echo
#

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

knotty garnet
#

did you execute the code to post guild count to top.gg?

empty jay
#

I’m still not getting any results from my webhook...

median badger
#

Are you sending it to a discord webhook?

cedar bison
#

I'm not getting any voting requests from my webhook.

#

The tests are going through, though.

median badger
#

Where exactly are you sending it,

#

Because you need to program it

cedar bison
#

?

#

I need to program it?

#

It works if I manually send it.

median badger
#

Are you sending it to a discord webhook

#

Any errors in console

cedar bison
#

nope

#

and im not even receiving anything on my webhook dashboard

median badger
#

Also should it require the package

cedar bison
#

only the tests

#

yeah thats above

#

i only provided a snippet

median badger
#

Idk then, I hope someone else can help you

cedar bison
#

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

vapid cape
#

what did you put as your url in your bot's edit page?

cedar bison
#

https://my.webhook:443

#

except I didn’t put my.webhook

vapid cape
#

what did you put?

cedar bison
#

@vapid cape

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?

knotty garnet
#

Idk if that matters, but dbl sends a POST request

#

Maybe you're expecting a GET request

cedar bison
#

No the dashboard for the webhook receives it, but the code doesn’t get it

vapid cape
#

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?

knotty garnet
#

Ain't that a postman-esque site?

#

Like, for debugging?

cedar bison
#

My bot is hosted on a vps

knotty garnet
#

And the api server?

cedar bison
#

What api server

vapid cape
#

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

cedar bison
#

i am confused

vapid cape
#

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)

cedar bison
knotty garnet
#

0.0.0.0 means "any url"

cedar bison
#

right

knotty garnet
#

That's used internally

#

The IP you're supposed to use externally is your server's public ip

cedar bison
#

yes okay

#

well, nothing happened when i did what Tim said..

knotty garnet
#

Do you use tomcat or nginx?

#

Or none?

cedar bison
#

nginx

knotty garnet
#

You gotta open a proxy if the port is within the listen range

cedar bison
#

πŸ‘ all working! thanks for your help

knotty garnet
#

Yw, nginx can be a pain sometimes

empty jay
#

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...

cedar bison
#

i wasnt talking about that

empty jay
#

you were talking about a webhook right?

cedar bison
#

yes

empty jay
#

ok I can't even get my tests to go through...are you able to help me really quick?

silk echo
#

did you execute the code to post guild count to top.gg?
@knotty garnet yeah

bold holly
#

@jaunty depot

left osprey
#

@empty jay

#

Did it work for you?

empty jay
#

no

twin hedge
#

how can i get dbl token?

sullen nymph
gusty elbow
#

how do i do the api?

#

plz ping me if you know how

restive otter
#

@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 ?

olive arrow
slow kraken
#

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)?

rancid eagle
#

anyone know how to get items from an array mongodb discord.py

sullen nymph
#

-api

abstract mothBOT
rancid eagle
#

-mongodb

sullen nymph
#

Read the message please

rancid eagle
#

ok

limpid vale
#

@restive otter you only put a word then delete again

restive otter
#

@limpid vale what ?

#

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

sullen nymph
restive otter
#

tm

next pendant
#

how can I setup the post vote webhook stuff

restive otter
#

@next pendant are you using js ?

slow kraken
#
 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')

restive otter
#

https://top.gg/api/bots/692374798654898260/check first check what this link returns

slow kraken
#

{"error":"No query userId, add ?userId= to your request"}

restive otter
#

hm

#

@slow kraken what are you trying to do ?

slow kraken
#

check if the user has voted, i console logged body: turns out my brain is in my stomach;
{ voteD: 0 }

restive otter
#
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 } })

slow kraken
#

i fixed it T-T

#

thanks anyways

left osprey
olive arrow
#

The port is not open?

gusty elbow
#

@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

left osprey
#

@olive arrow I don't have a firewall

olive arrow
#

@left osprey show your constructor (without pass)

olive arrow
#

What is it set to in dbl

left osprey
#

I mean, i got the token the web hook port and pass

steady minnow
#

what is the command to add a game activity to your bot

olive arrow
#

I mean what did you set the webhook too

#

what is the command to add a game activity to your bot
@steady minnow #development

steady minnow
#

i dont speak english and i was creating a bot for fun

#

thank you

olive arrow
#

Np

left osprey
#

@olive arrow I set the webhook to get the votes

#

like when someone votes it console log

olive arrow
#

I know what the webhook is for lel

left osprey
#

lol

olive arrow
#

I have one myself

#

I mean what is the domain/IP and port that you set it to

left osprey
#

My VPS public ip

trail sigil
#

-dotpost @restive otter

abstract mothBOT
#

@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.

olive arrow
#

Then what port

left osprey
#

I didn't add a port to the ip

#

oh

olive arrow
#

Do this

left osprey
#

i need to do IP:5000

#

?

olive arrow
left osprey
#

alright

#

thanks alot man

olive arrow
#

No

#

*np

left osprey
#

@olive arrow one thing tho, i did http://IP:5000 and pressed test and for me it did not work

olive arrow
#

Try restart your webserver

light talon
#

The test thing on top.gg requires you to save first

#

its kinda buggy

#

try pressing save and then test

drowsy violet
#

selam

#

tΓΌrk mod var la

sullen nymph
#

-api

abstract mothBOT
sullen nymph
#

-notr

abstract mothBOT
#

İ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.

median badger
#

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

restive otter
#

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.

warm oasis
#

how can i do so everytime someone vote on my bot it get logged in my server?

sullen nymph
restive otter
#

Thanks, i'll have a look now

sullen nymph
#

@warm oasis Our official libraries support webhooks that you can use

warm oasis
#

like im not good at js could you send me the right thing to run in my bot?

spiral steeple
#

well that's against the rules

spiral steeple
dusty roost
#

(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

arctic arch
#

did you configure it on the website

dusty roost
#

configure?

next pendant
#
http://myip:4000/api/votes/dbl
#

is this correct format for the webhook?

stiff osprey
#

if that's the endpoint that you've created, yes

next pendant
#

should it be

vapid cape
#

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

next pendant
#

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

vapid cape
#

test the route with reqbin

next pendant
#

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
merry zodiac
#

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?

next pendant
#

can't figure this out

#

it seems like everything connected

#

what should happen when i hit "Test"?

knotty garnet
#

Your webserver will receive a http request with type being "test"

next pendant
#

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

next pendant
#

very odd

#

still cant get it to work

knotty garnet
#

That's a 404

#

Have you proxied that address?

restive otter
#

.

restive otter
#

anyone knows a cookie API

#

image or gif

knotty garnet
#

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

restive otter
#

dog api png

#

@knotty garnet

knotty garnet
viscid forum
#

how do i use the top.gg api to see how many servers i have on ther site?

sly violet
#

you want to query the current servers displayed on top.gg for your bot?

pure nymph
#

why config wrong

viral solar
#

you did not define "config"

#

const config = require("./config.js")

pure nymph
#

o

restive otter
#

image generator api

viral solar
#

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

pure nymph
#

Btw why server not display on dbl?

#

I have add dbl token to bot

pure nymph
#

and server stay N/A

median badger
#

You have to post it

#

Do you have the appropriate api package? Or are you making standard post requests

cursive geode
#

My bot shows server number in Top.gg ,,,, But I can't get vote info

median badger
#

You need to send requests to somewhere that can receive the votes

#

If you go to edit bot, its somewhere near the bottom

cursive geode
#

Thanks a lot

warm oasis
#

where do i get the vote script/api or whatever

knotty garnet
cursive geode
#

I did everything ,,, Still webhook isn't working

pure nymph
#

Do you have the appropriate api package? Or are you making standard post requests
@median badger yes

#

bruh

median badger
#

const dbl = new DBL(config.dblToken, bot);

#

try that

slow kraken
#

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);```
spiral steeple
#

You can put dbl on the client instead

#

client.dbl = new DBL(...)

#

Then you can access it anywhere your client is with client.dbl

slow kraken
#

thanks πŸ‘

charred reef
#

What I did was make the bot read the vote log and if it is mentioned then it sends a message

strong eagle
#

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');
``

sullen nymph
#

-api

abstract mothBOT
next pendant
#

is today considered weekend?

#

for the double votes

sullen nymph
#

00:00 UTC Friday up to 23:59 (11:59 PM) UTC Sunday

next pendant
#

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?

sullen nymph
#

"merge"?

faint phoenix
#

Hi can you help me to create a Webhook and how to send vote on channel ?

ornate abyss
#

hi

#

like no kwargs.get?

sullen nymph
#

See _ensure_bot_user

ornate abyss
#

so that is making it the bot

#

hmm i thought it was to give another bot id to use the api as that GWloopyBlobShrug

sullen nymph
#

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

ornate abyss
#

aha

cursive geode
#

How do I merge votes with Currency or something like that

#

I meant rewarding them

#

For Voting

viral solar
#

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

balmy hamlet
#

get the ip

#

it isn't that hard

pure nymph
#

const dbl = new DBL(config.dblToken, bot);
@median badger ok

viral solar
#

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

merry zodiac
#

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?

balmy hamlet
#

it's easy tho

alpine robin
#

automating with the API illegal?

restive otter
#

lmao what

#

only mods have -luca commands

cursive geode
#

How it works in Manual Count?

#

Is there any command

dire sand
#

Which file do I excatly put the API in?

restive otter
#

Put api in index.js / server.js file

dire sand
#

ok

restive stump
#

..

bold lake
#

Hi, how I use this ???

#

I want to get the votes of specific user

restive otter
#

@bold lake use an module

#

node-fetch,axios,snekfetch
... etc

median badger
#

cached

#

you need to gen a random number after a ? to not cache

#

np

#

discord caches images from the same url

feral crown
willow spindle
#

this channel is for top.gg api @feral crown

keen galleon
#

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

willow spindle
#

what is your djs version

keen galleon
#

12.2.0

restive otter
#

i have a question
why someone time

my bot show vote 0 or 14 or 16

keen galleon
#

Ok well I have found it's client.guilds.cache.size instead of client.guilds.size, thank's

restive otter
#

What should i fix?

sullen nymph
#

When pasting the URL somewhere, replace 0.0.0.0 with your public IP address

restive otter
#

if I'm use heroku to run bot what should i fix?

sullen nymph
#

Your app's Heroku url then

restive otter
#

is it can use?

sullen nymph
#

Probably

#

Try it

restive otter
#

How i check if webhook work then console.log("Work")?

cursive geode
#

@restive otter It worked?

#

I am using heroku too

#

Idk how to configure Webhook

dire sand
#

I'm using Heroku too, but my laptop isn't responding

neon berry
#

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

restive otter
#

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

neon berry
#

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

empty jay
#

Is there api to do a bump command?

vernal adder
#

I didn't even know you could bump your servers, I just checked the API docs and there is nothing about it.

spiral steeple
#

You cant

elder violet
#

I want help

empty jay
#

You cant
@spiral steeple then explain the bots you can use to bump servers

spiral steeple
#

That's not for this list

#

it is impossible to bump servers on top.gg

ancient venture
#

@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

empty jay
ancient venture
#

That hasn't got anything to do with top.ggs api + you cant bump servers on discord server list

empty jay
#

I'm just letting @spiral steeple know that it is in face top.gg...

ancient venture
spiral steeple
#

holy shit

#

you just dont get it

#

you cannot bump servers on top.gg

spare mulch
#

It is possible, but not at all worth it.

empty jay
#

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

spiral steeple
#

then why is it in here?

spare mulch
#

No existing API

spiral steeple
#

this channel is strictly for the top.gg api

empty jay
#

I was asking if anyone knew of existing API
MY EXACT WORDS

spiral steeple
#

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

empty jay
#

that's not at all what you were saying earlier lmao

spiral steeple
#

simply "You cant"

opaque jetty
#

Why do I get this error when trying to post server count using the dblpy python api?

opaque jetty
#

upgraded from 3.5 to 3.7 and got this

#

whats wrong?

opaque jetty
#

I dont get it, I am using the DBLPY library, what am I supposed to do?

#

yes

#

this is my code

#

Wdym?

spare mulch
#

@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

sullen nymph
#

It's not exactly an "issue" here

chilly rain
#

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.

vapid cape
#

did you configure it in your bot's edit page?

#

the URL and Authorization fields

chilly rain
#

yes

chilly rain
#

but now i get: Error: listen EADDRINUSE: address already in use :::5000

#

because express is running on 5000

fathom sluice
#

just change it

#

like 3009

chilly rain
#

but if i change the webserver to 3009, then i also have to change the webhookPort, and that will result in the same error.

vapid cape
#

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?

chilly rain
#

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}`);
});```
vapid cape
#

well it was running before, you posted the logs

chilly rain
#

yes, but that was a different code

vapid cape
#

well what is the current code then?

chilly rain
#

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.
vapid cape
#

try const listener = app.listen(...)
and webhookServer: listener

chilly rain
#

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. πŸ˜…

sullen nymph
#

test button on your bot's Edit page

chilly rain
#

Thanks, still not working.

sullen nymph
#

replace 0.0.0.0 with your public IP address when entering the URL somewhere

chilly rain
#

but where do i have to enter the url? i only have to above code.

sullen nymph
#

Your bot's Edit page, scroll down to the very bottom

chilly rain
restive otter
#

yh basically

#

usually localhost would work if i am not wrong

chilly rain
#

even if it is portforwarded and so, another ip?

vapid cape
#

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

chilly rain
#

Thanks, works. πŸ˜„

#
User with ID 356857570285191169 just voted!
User with ID 356857570285191169 just voted!```
craggy sentinel
#

nice

#

i love ghost pings

rapid kettle
viscid forum
restive otter
#

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

green mantle
#

@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

viscid forum
#

pl ping me

sullen nymph
#

what do you think message.author.has does

viscid forum
#

gives a 1 if you voted and 0 if not @sullen nymph

sullen nymph
#

Have you properly read dblapi.js docs

viscid forum
#

ye

sullen nymph
#

Where does it mention has and not hasVoted

#

OR using message.author instead of a DBL client provided by the library itself

viscid forum
#

oh @sullen nymph thats the wrong screen shot

#

lmao

#

there thats the right one

sullen nymph
#

Can you output what hasVoted returns

restive otter
#

@green mantle alrighty thanks

viscid forum
#

i guess it will take few mins tho i use vps so i need to transer files @sullen nymph

sullen nymph
#

Maybe make it send a message in a channel if that's easier for you

restive otter
#
        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
#

Yes but no

#

The 404 means 404 code was returned, and it means "not found"

viscid forum
#

@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

sullen nymph
#

Well it does

#

You don't have any message to access in an event that just says "server count posted"

restive otter
sullen nymph
#

-api

abstract mothBOT
viscid forum
#

i do

sullen nymph
#

Well what is message in your case

viscid forum
#

the message that is sent with +getreward

restive otter
#

now is it can?

sullen nymph
#

Yes

viscid forum
#

the message that is sent with +getreward
@viscid forum

sullen nymph
#

Is it in the scope of the function

restive otter
#

why in my cmd don't show

sullen nymph
#

dbl.on

#

Upvote in last 12 hours

viscid forum
#

how do i fix my code, the docs are useless

idle current
#

If I was to establish a rest api, can I use that as an endpoint for the vote webhooks?

sullen nymph
#

Is it in the scope of the function

#

@idle current yes

idle current
#

Ok

merry zodiac
#

How can I check if a user has voted for my bot in Python?

restive otter
#

shivaco

#

it don't console.log

idle current
#

If you read the docs @merry zodiac you may find something

merry zodiac
#

thx a lot

idle current
#

No worries.

viscid forum
#

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?

opaque jetty
#

Is your webhook pointe to your IP address?

viscid forum
#

what does that mean

restive otter
#

@viscid forum use await

viscid forum
#

@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?

faint phoenix
#

Do I have to open my ports on my internet box?

rapid kettle
#

no

#

@faint phoenix

#

unless its a different thing

faint phoenix
#

It's only on port 5000, because my host is on another port and it doesn't work ...???

opaque jetty
#

I keep getting ```Unclosed client session

sullen nymph
#

Do you have any idea what function you used to get that

opaque jetty
sullen nymph
#

I'll take a look when I'm free. You can open an issue on the Github repo if you want

opaque jetty
#

Oh wait, I am running it by doing setup(client) in the on_ready() function. Is that right?

sullen nymph
#

Ehhh no

#

You don't call the function yourself

opaque jetty
#

Let me try doing it without calling it.

sullen nymph
#

You use bot.load_extension on the file if it's separate

opaque jetty
#

Its the same file.

sullen nymph
#

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

opaque jetty
#

So all I need to do is to have the class there

#

And it will work?

sullen nymph
#

It's an internal method that causes the unclosed session thing

#

Nothing you can do

opaque jetty
#

Is 3.7 ideal?

#

Or is another version better.

sullen nymph
#

3.5.3 up to 3.8 work just fine, haven't tested above that

opaque jetty
sullen nymph
#

Does it appear if you don't load the cog?

opaque jetty
sullen nymph
#

Uppercase

opaque jetty
#

so it should be Bot.add_cog(TopGG(Bot))

#

instead of bot.add_cog(TopGG(bot))

sullen nymph
#

bot should be your instance of the commands.Bot class

opaque jetty
#

oh I just named mine as client

#

so I guess client.add_cog(TopGG(client))

sullen nymph
#

Yeah

opaque jetty
#

After doing that, im getting this now

sullen nymph
#

Huh

opaque jetty
pastel raptor
#

have you checked this out

#

not sure if it's the sure-fire solution, but it seems related

opaque jetty
#

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?

opaque jetty
#

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

viscid forum
#

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?

hearty pagoda
#

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"}})
viscid forum
#

@hearty pagoda yes it

#

its up in my codde

#

that part works

hearty pagoda
#

Nvm, the Authorization needs to be capitalized, which is weird because the headers are not case sensitive

restive otter
#

I wanna set the webhook url to my linux vps
How can i set the url

balmy hamlet
#

k

#

what do you need help with

viscid forum
#

.

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?

balmy hamlet
#

ok so

#

what's happening

#

what should happen

#

and what doesn't happen

viscid forum
#

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

balmy hamlet
#

well

restive otter
balmy hamlet
#

wait

viscid forum
#

sorry wrong chat

#

did ot mean to put ?

#

not*

balmy hamlet
#

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*

viscid forum
#

when it restars it resets

balmy hamlet
#

yes

#

the timeout will never finish

#

hence they'll never get removed from the database

viscid forum
#

with is ok beacuse i do updates every couple days and the timer commands dont give much

balmy hamlet
#

but wait

#

that's the problem

#

let's say I voted for the bot now

viscid forum
#

ye

balmy hamlet
#

boom, I get added to the database

viscid forum
#

ye

balmy hamlet
#

then you restart the bot for maintenance

#

my id will never get removed from the database

#

bc you stopped the process

restive otter
#

Umm should work with map??? Z_wotta_phack

viscid forum
#

but dosent it pull that data from top.gg

balmy hamlet
#

no

#

it does pull the vote

#

but the timeout is a separate thing

viscid forum
#

yes the timer is not my prob

#

or

balmy hamlet
#

it is

viscid forum
#

why does that affect if voting is true

balmy hamlet
#

you set the timer

#

it does not affect if voting is true

#

didn't you say the id never gets deleted from the database

viscid forum
#

i dont think so

#

maybe tho

balmy hamlet
#

86400000

#

dude

#

86400000 is 24 hours

#

not 12 hours

#

that's the problem

viscid forum
#

ye i forgot to change

#

it updated now

balmy hamlet
#

their id will get removed once 24 hours have passed

#

yeah

#

but that just makes another problem

worn forge
#

api

balmy hamlet
#

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

restive otter
#

@balmy hamlet help me out now teddy_what teddy_what teddy_what

balmy hamlet
#

wait

#

what's your host Raj

restive otter
#

@balmy hamlet digitalocean ubuntu teddy_what

viscid forum
#

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

balmy hamlet
#

Raj, try to run this from the command line

$ dig +short myip.opendns.com @resolver1.opendns.com
viscid forum
#

sorry if i sound stupid new to this api

restive otter
#

Should i just copy paste this?

viscid forum
#

yes

balmy hamlet
#

well the api itself has nothing to do with the timeout being killed

restive otter
#

@balmy hamlet it returned my ip address

viscid forum
#

yeha i dont care that the timer gets reset not huge deal with me, its the voting being true even if author hasent voted

balmy hamlet
#

@restive otter yeah

viscid forum
#

if you havent voted it says you have and gives reward

balmy hamlet
#

that's what you need

#

back to Dolphin

restive otter
#

@balmy hamlet uh what do i set in the url???

balmy hamlet
#

ok that's weird

#

wdym

#

you only need your host url and the webhook path

#

and the port if necessary

#

so it would be

restive otter
#

Okay

balmy hamlet
restive otter
#

Kek

viscid forum
#

is the first part to me are raj

balmy hamlet
#

wait

#

what

#

why the fuck does it add a / after the yourip

#

I didn't add that

restive otter
balmy hamlet
#

don't add the / after the yourip

#

just https://yourip:yourport/webhookpath

#

there

restive otter
#

Hmm

balmy hamlet
#

and you also need a webserver

viscid forum
#

so do you know why the .hasvoted always comes as true?

#

even if they havent voted

#

it ok if you busy rn

balmy hamlet
#

I'm not that busy

#

but let's get back to work

#

hasVoted shouldn't always return true

#

unless you actually voted

viscid forum
#

yep

balmy hamlet
#

in which case you'll need to wait 12 hours

#

before it returns false

viscid forum
#

yep

balmy hamlet
#

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

viscid forum
#

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

balmy hamlet
#

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

viscid forum
#

yes

#

wait

#

if it s in dbl.on('getreward' () => {}) it dose not work

#

idk if that matters

#

other wise i gusse its bugged

restive otter
#
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

viscid forum
#

i dont anything aboout that

restive otter
#

Okay

balmy hamlet
#

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

viscid forum
balmy hamlet
#

wait

viscid forum
#

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

balmy hamlet
#

dude

restive otter
balmy hamlet
#

that's not how event listeners work

#

@restive otter okok, now, show your webserver's code

#

Dolphin

viscid forum
#

what do you mean

balmy hamlet
#

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

viscid forum
#

that works with all my other code

restive otter
#

Uhhh

viscid forum
#

should it be in dbl.on('getreward' () => {}) it dose not work instead

balmy hamlet
#

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

viscid forum
#

oh

#

so what should i put in it instead

balmy hamlet
#

@restive otter you just showed your top.gg token

restive otter
#

@balmy hamlet its half np

balmy hamlet
#

lemme check something real quick raj

restive otter
#

Kk

viscid forum
#

so what should i put in it instead

balmy hamlet
#

not really

#

show your entire code

#

and hide your tokens

#

Raj, did you pass in a client to it?

restive otter
#

@zSnails#5755 ye

viscid forum
#

me? ok i will put in a haste bin real quick

balmy hamlet
#

o

#

k

#

@restive otter what are you trying to do

#

I actually have no clue

#

posting server count

#

getting votes from the webhook

restive otter
#

@balmy hamlet its posting server count but not getting the votes

balmy hamlet
#

how are you trying to get the votes

restive otter
#

vote event

balmy hamlet
#

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

restive otter
#

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
#

oh wait

#

why do you have 2 dbl instances

restive otter
balmy hamlet
#

you only ned one

#

you don't need dbl2

restive otter
#

@balmy hamlet client instance

balmy hamlet
#

yeah but you only need 1 dbl instance

viscid forum
#

@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

balmy hamlet
#

that 1 instance can do everything

#

your prolem may be that the post request is getting sent to the webserver on the 2nd instance

restive otter
#

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

balmy hamlet
#

remove the second instance

#

it always creates a webserver

#

so you have 2

restive otter
#

Btw na not possible its getbot is working

balmy hamlet
#

just delete it

#

one instance can handle everything

restive otter
#

Kek

balmy hamlet
#

and

#

what did you set your path and port to when creating the webhook instance

restive otter
#

Did

#

what did you set your path and port to when creating the webhook instance
@balmy hamlet /dblwebhook and port 8080

balmy hamlet
#

@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

restive otter
balmy hamlet
#

hmm

#

weird

viscid forum
#

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

balmy hamlet
#

it's actually weird that it isn't working

viscid forum
#

i know i am so confused

balmy hamlet
#

@viscid forum well I couldn't find the command due to that mess

viscid forum
#

its at the bottem

restive otter
#

@balmy hamlet okay worked thx

viscid forum
#

like all the way down

#

last thing

restive otter
#

After deleting that 2nd nstance

balmy hamlet
#

but if dbl.hasVoted always returns true then that's a bug which I can't fix

#

@restive otter see

restive otter
#

Thx

balmy hamlet
#

np

viscid forum
#

so it dose not to be in a dbl.on ?

balmy hamlet
#

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

viscid forum
#

so i should put getreward in dbl.on or did i do that part right?

olive arrow
#

What are you trying to do

balmy hamlet
#

don't put it inside of anything that has to do with a dbl.on

#

I need to get some sleep

#

brb

viscid forum
#

@olive arrow scroll up

olive arrow
#

Ok

#

So dbl.hasVoted is working?

viscid forum
#

no

#

its not working

#

its always true

#

no matter what even if the person hasent voted

olive arrow
#

Have you configured dbl?

viscid forum
olive arrow
#

Yeah and with your client as well?

viscid forum
olive arrow
#

I mean did you put the client inside the dbl constructor, and is everything else working in terms of server count posting and stuff?

viscid forum
#

yes ok so this is my get reward and this is whats its in

olive arrow
#

Your what now?

viscid forum
olive arrow
#

Ok

viscid forum
olive arrow
#

That should work

viscid forum
#

yep

#

thats the problem

olive arrow
#

Hold on allow me to test something, I'll be just a second

viscid forum
#

kk

olive arrow
#

It's nothing to do with the API

#

Since I've just checked with myself

#

As I have not voted for my bot

viscid forum
#

then what did do wrong?

olive arrow
#

Is your bot online?

viscid forum
#

nope

olive arrow
#

Like on dbl

#

I mean

viscid forum
#

its on top.gg and server posted works want me to invite to its support server or top.gg?

olive arrow
#

No that's fine

#

So the server posting works, correct?

viscid forum
#

ye

olive arrow
#

On what line is the get reward command?

viscid forum
#

last command

#

if you go top bottem youll see

olive arrow
#

That seems to be the work command

viscid forum
#

thats not the bottem

onyx quest
viscid forum
olive arrow
#

Didn't install it

onyx quest
#

I instaled it

olive arrow
#

No module found 'dbl'

onyx quest
olive arrow
#

It's called dblpy

#

Not dbl

olive arrow
#

Looks like you may have not installed it fully as it says it is already satisified

balmy hamlet
#

import dblpy

onyx quest
viscid forum
olive arrow
#

Ohhhh

#

So it gives them the money?

viscid forum
#

yes

olive arrow
#

Hmm

viscid forum
#

?

olive arrow
#

Weird

#

Oh yep I see

viscid forum
#

yes

olive arrow
#

It's await dbl.hasVoted()

viscid forum
#

what do you see?

#

YES

#

thank you so fucking much

olive arrow
#

Np