#topgg-api

1 messages · Page 92 of 1

onyx cipher
#
@commands.Cog.listener()
    async def on_dbl_vote(self, data):

        print("got vote")

        memberID = data["user"]

        print(f"got vote from {memberID}")

        member = self.bot.get_user(int(memberID))
        print(member.name)
        await member.send(f"""
Hey!Thanks for the vote :heart: :100:
You now have one extra token :moneybag: 
Please do this every now and then :heart:
Enjoy making commands using me!""")

        tokenmaker = TokenMaker(member)
        tokenmaker.add_token()
#

well uhm this wont work

#

i need help

onyx cipher
#

here is the whole cog

#
import dbl
import discord
from discord.ext import commands , tasks
from setup import dbltoken
import logging
from utils.tokenMaker import TokenMaker

class TopGG(commands.Cog):
    """Handles interactions with the top.gg API"""

    def __init__(self, bot):
        self.bot = bot
        self.token = dbltoken
        self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)


    @tasks.loop(seconds=3)
    async def update_stats(self):
        """This function runs every 30 minutes to automatically update your server count"""
        print("posting")
        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

    @commands.Cog.listener()
    async def on_dbl_test(self, data):
        print(data)


    @commands.Cog.listener()
    async def on_dbl_vote(self, data):

        print("got vote")

        memberID = data["user"]

        print(f"got vote from {memberID}")

        member = self.bot.get_user(int(memberID))
        print(member.name)
        await member.send(f"""
Hey!Thanks for the vote :heart: :100:
You now have one extra token :moneybag: 
Please do this every now and then :heart:
Enjoy making commands using me!""")

        tokenmaker = TokenMaker(member)
        tokenmaker.add_token()




def setup(bot):
    global logger
    logger = logging.getLogger('bot')
    bot.add_cog(TopGG(bot))
sullen nymph
#

you aren't setting webhook arguments

onyx cipher
#

what

#

what

#

@sullen nymph

#
    def __init__(self, bot):
        self.bot = bot
        self.token = dbltoken
        self.dblpy = dbl.DBLClient(self.bot,
                                   self.token,
                                   autopost=True,
                                   webhook_path='/dblwebhook',
                                   webhook_auth=self.token,
                                   webhook_port=5000)
#

do i need to do this>

sullen nymph
#

yes, except I don't recommend setting webhook_auth to your top.gg API token

onyx cipher
#

then what else @sullen nymph

sullen nymph
#

open port 5000 and go to your bot's Edit page

onyx cipher
#

well idk how to do that

#

i am a noob at networking

#

how do i open port 5000

sullen nymph
#

Google™️

#

there, scroll all the way down, set Authorization field to what you set webhook_auth to
in the URL field, set http://ip:5000/dblwebhook where ip is your public IP address

onyx cipher
#

but

#

i have set this bot up

#

@sullen nymph

#

can i have 2 webhooks

sullen nymph
#

that bot is unofficial, but the URL should still be available

#

same applies to the token that it sent

#

You can't really have 2 webhooks unless you make one that later sends a request to another webhook

onyx cipher
#

ok wait

#

do i really need to open port 5000

sullen nymph
#

not in this case

#

you don't need the webhook arguments then

green mantle
#

not that matters too much because and api is really rather borked rn

granite tendon
#

Is it just me or is the bot status not displaying properly on every bot listed?

orchid cargo
#

I voted my bot yesterday it was returning True

#

But now it's returning False

#

Even though I voted it

#

I'm using get_user_vote

#

To manually fetch it

#

(python)

#

Ok it worked now

#

It took 2 mins to update my vote

green mantle
restive otter
#

Why the votes wont work Tests work

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
            userid = data["user"]

            letter = "ASDFGHJKLQWERTYUIOPZXCVBNMasdfghjklzxcvbnmqwertyuiop12345678900987654321"
            code = ","
            for m in range(0, 6):
                code += random.choice(letter)
            db = await aiosqlite.connect("main.db")
            c = await db.execute("SELECT codes FROM minicodes")
            codes = await c.fetchall()
            codes = codes[0][0]
            codes += code
            await db.execute("UPDATE minicodes SET codes = ?", (codes,))
            await db.commit()
            await db.close()
            fcode = code.replace(",", "")
            msg = discord.Embed(
                colour=discord.Colour.green(),
                title=f"Your code is {fcode}",
                description = "Thanks for voting :) Claim the code with `?redeem_vote <code>`"
            )
            try:
                await self.bot.get_user(userid).send(embed=msg)
            except:
                pass
green mantle
#

are you doing it with the test button

restive otter
#

Wdym

#

this is the test code

#
    @commands.Cog.listener()
    async def on_dbl_test(self, data):
        logger.info('Received an upvote')
        print(data["user"])
#

It works

#

but voting doesnt work

marsh panther
#

Hi, I'm getting a ton of 429 errors when connecting to dbl with dblapi.js, even if it works fine but I don't really want to get banned

#

Errors aren't helpful at all. Is there any limit to . hasVoted()?

#

That's probably why I'm getting rate limited but not sure

orchid cargo
#

but voting doesnt work
same

restive otter
#

does the test work?

#

Test button

orchid cargo
#

opened port at 5000
put my public ip:port/mypath

nothing works

restive otter
#

For me test works

#

tho

orchid cargo
#

I haven't tried test yet

restive otter
#

Press test

#

Just

orchid cargo
#

ok

restive otter
#

but do you have a test code in your cog?

#

Like async def on_dbl_test(self, data):

orchid cargo
#

yeah I'm doing it now

restive otter
#

nvm got it

inland lake
#

anyone got a clue why i get this error:

it seems to happen randomly and sometimes the voting works sometimes it doesnt

arctic arch
#

your host likely has dns issues

inland lake
#

im not using the webhooks

#

could it be that top.gg has some dns issues then?

arctic arch
#

that has nothing to do with webhooks

#

what it means is that the dns resolving fails on your host

olive arrow
#

If I am using dbl API, and it keeps saying 502

#

Is this because of the cloudflare cheek?

#

*checks

olive arrow
#

Is there anyway to stop autoposting?

#

(dblapi.js)

arctic arch
#

dont supply the client

olive arrow
#

ok

#

ty

onyx cipher
#

i need helping setting up the Webhook part

#
    def __init__(self, bot):
        self.bot = bot
        self.token = dbltoken
        self.dblpy = dbl.DBLClient(self.bot,
                                   self.token,
                                   autopost=True,
                                   webhook_path='/dbl',
                                   webhook_auth= hidden',
                                   webhook_port=5000)
#

i still can't understand the webhook_path and webhook_auth

#

how do i set a webhook up

#

i want to set it inside of my bot

#

like it says here

restive otter
#

yeah i need help i wont server count on my bot on top.gg

#

but dont know how

#

ok

#

so when you edit your bot you can get the api token there

#

uhh?

#

in top,gg

#

top.,gg

rancid cove
#

Edit bot on top.gg not in discord dev settings

restive otter
#

ok

#

yes

#
const DBL = require('dblapi.js');
const client = new Discord.Client({ disableEveryone: true });
const dbl = new DBL('api token here', client);

dbl.on('posted', () => {
    console.log('Server count posted!');
});

dbl.on('error', e => {
    console.log(`Oops! ${e}`);
});``` @restive otter
#

ok 1 sec

rancid cove
#

you might want to install dblapi.js 👀

restive otter
#

npm i dblapi.js

#

ok i put that in now what?

#

where do i get?

#

uwotm8

rancid cove
#

bro just read up

restive otter
#

ok

#

lol

#

YAY IT WORKED

#

now can i see if someone voted?

rancid cove
#

check the docs

restive otter
#

ok

#

where are the docs?

#

ok

rancid cove
restive otter
#

yh forgot the /docs

#

oh

#

ok

#

lol

#

umm

#

how to get DBLToken?

#

please

#

u wot m8

#

i told u already

restive otter
#

ok lol

#

im confused

#

i want to see who voted

#

nice

#

but like i need a token and pass

#

but like?

#

how

jaunty plank
#

i think thats all on the docs

restive otter
#

im reading and i dont understand it

#

Hi

#

I need help

#

im reading and i dont understand it
@restive otter docs are there to help u understand

#

In my bot there is showing server N/A

#

show the code

#

@restive otter docs are there to help u understand
@restive otter but its not

jaunty plank
#

?????

#

what dont you understand about exact examples of what to do

restive otter
#

it's literally there as Woo posted

#

i dont

#

yourDBLToken here i put it in and theres an error

jaunty plank
#

okay...

restive otter
#

and whats the password thing :;/

#

wtf I told u

#

In my bot there is showing server N/A
@restive otter show the code in a sourcebin

#

just please help ;-;

#

I already have tho???

#

and even Woo

#

bruh

#

i legit said

#

theres an error thing

#

u didn't

jaunty plank
#

you never said what the error is did ya?

restive otter
#

what's the error

jaunty plank
#

just because an error pops up, doesnt mean we know the error

restive otter
jaunty plank
#

you just said

restive otter
#

u didn't show the error

jaunty plank
#

theres an error

restive otter
#

@restive otter I am talking about bot ...

#

yes exactly

#

It's showing n/a there

#

yes have you used the api?

jaunty plank
#

you need to use the api to send your server count to top.gg

restive otter
#

@restive otter tell us the error then

#

don't expect us to magically know it

#

ok 1 sec

#

@jaunty plank thanks 😋

jaunty plank
#

np

restive otter
#

so whats webhook auth?

#

tell us the error

#

omg

#

stop changing topics

#

no im wondering cuz i need to do that

#

theres no error

#

yet

restive otter
#

what

#

the actual fuck

#

are u on about

jaunty plank
#

i dont know how you expect us to help when your lying about things

restive otter
#

i got a .env file nvm

#

ok

#

const dblWebhook = new DBL(process.env.DBLTOKEN, { webhookServer: 5000, webhookAuth: 'password' }, bot); what happens now?

#

idk what happens

#

has anyone voted?

#

no

#

could you vote to test?

#

@restive otter

pastel solar
#

there's a test button in the edit page

restive otter
#

oh ok

#

lol

#

the bottom one

pastel solar
#

const dblWebhook = new DBL(process.env.DBLTOKEN, { webhookServer: 5000, webhookAuth: 'password' }, bot); what happens now?

password

restive otter
#

ok

#

lol

#

bot list

#

nothing works :/

#

why do u keep saying ok lol

#

don't think it was funny

#

;-;

#

nothing works :/

pastel solar
#

the webhook placeholder should have your vps ip/dbwebhook

restive otter
#

dblWebhook.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dblWebhook.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});```
code
jaunty plank
#

did you make your password password? or did you remove that for us pikathink

restive otter
#

uhh

#

yeah

#

no

#

wait

#

what?

jaunty plank
#

did you use the link that was in your console

#

are you sure process.env.dbltoken is defined properly

restive otter
#

yes

#

im sure

#

it should be :/

#

let me check

jaunty plank
#

on all 3?

restive otter
#

wdym

jaunty plank
#

i asked 3 diffrent things you can check

#

are you sure all 3 are done properly?

restive otter
#

i used link

#

and the thing is defined

#

and pass is dif

#

im using glitch if thats a problem?

jaunty plank
#

i heard glitch doesnt allow port 5000

restive otter
#

oh ok

#

lol

jaunty plank
#

but i dont use glitch

pastel solar
#

uh yeah

restive otter
#

oh so uhh

#

what

#

then?

pastel solar
#

you gotta use port 80

jaunty plank
#

then use a port glitch allows

restive otter
#

ok

#

events.js:173 throw er; // Unhandled 'error' event ^ Error: listen EACCES: permission denied 0.0.0.0:80 at Server.setupListenHandle [as _listen2] (net.js:1209:19) at listenInCluster (net.js:1274:12) at Server.listen (net.js:1362:7) at DBLWebhook._startWebhook (/rbd/pnpm-volume/c3a21c2b-7bf7-4bc0-b08e-07f5bbb7b34d/node_modules/dblapi.js/src/webhook.js:45:18) at new DBLWebhook (/rbd/pnpm-volume/c3a21c2b-7bf7-4bc0-b08e-07f5bbb7b34d/node_modules/dblapi.js/src/webhook.js:27:12) at new DBLAPI (/rbd/pnpm-volume/c3a21c2b-7bf7-4bc0-b08e-07f5bbb7b34d/node_modules/dblapi.js/src/index.js:69:22) at Object.<anonymous> (/app/Index.js:10:20) at Module._compile (internal/modules/cjs/loader.js:759:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10) at Module.load (internal/modules/cjs/loader.js:628:32) Emitted 'error' event at: at emitErrorNT (net.js:1253:8) at processTicksAndRejections (internal/process/task_queues.js:83:17) at process.runNextTicks [as _tickCallback] (internal/process/task_queues.js:58:3) at Function.Module.runMain (internal/modules/cjs/loader.js:828:11) at internal/main/run_main_module.js:17:11

jaunty plank
#

i think thats more of a glitch problem now

restive otter
#

ok

#

uhh

#

ok i got agood port but now its not doing anything :/

#

whats happening

jaunty plank
#

id start by considering the ways it might not be working

#

like, the url you use, needs to include the port, if you changed the port in the program, you need to change it for top.gg

marble sand
#

Hi, someone can help me make sure that when someone votes their send the data to a channel.

restive otter
#

like, the url you use, needs to include the port, if you changed the port in the program, you need to change it for top.gg
@jaunty plank i have

jaunty plank
#

@marble sand i think you mean something other than you said.

#

im not sure @restive otter, it may have something to do with glitch, it may be your not using the right password that you defined, or the token may be wrong.
everything must be right for it to work

restive otter
#

ok

marble sand
restive otter
#

you rpass

#

password

marble sand
#

oh thanks

restive otter
#

np

#

all the fucking ports are legit used

jaunty plank
#

@restive otter thats the life of glitch

#

im sure glitch has a way of finding available ports

marble sand
#

and URL should we put the url of our webhooks?

marble sand
#

?

placid peak
#

i know secret port what no one uses: ||69420||

vapid cape
#

lmao

jaunty plank
#

thats my password, how did you get that

placid citrus
#

Is there a rate limit on .hasVoted()?

vapid cape
#

60 per minute afaik

placid citrus
#

Okay, thanks

knotty garnet
#

And at most 100 votes iirc

full mesa
#

Does top.gg's webhook support raw IP addresses like 123.456.78?

hardy acorn
#

Try it and see

arctic arch
#

http://123.456.78.900:5000/webhook for example

willow spindle
#
  • /dblwebhook
onyx cipher
#

how do i get my ip

arctic arch
#

if they use the default from the js library

onyx cipher
#

do i need to get it from the my VPS?

#

i suck at networking but i want to setup a socket

willow spindle
#

curl ifconfig.co

#

@onyx cipher it shoud be a VPS ip

timber beacon
#

Hello

#

How can i create a webhooks could you please help and get vote in my own server

willow spindle
#

You cannot use api before your bot is approved

timber beacon
#

Ok

#

Suppose if i want to get another bot vote in my server

#

How can i use webhooks

#

Like dyno

#

Help

#

@willow spindle

willow spindle
#

top.gg vote webhooks or discord channel webhooks?

timber beacon
#

I have created webhook

#

But i am unable to receive vote

#

In my server

#

Bot name Member Count

willow spindle
#

you have to setup it

#

also

#

You cannot use api before your bot is approved
@NMW03#2110

timber beacon
#

How can i setup it

willow spindle
#

wait for approval first

timber beacon
#

How can i setup it

#

Please tell me

willow spindle
#

By creating a webserver

timber beacon
#

How can i create a webserver

willow spindle
#

For receiving webhook requests

#

did you actually coded your bot

timber beacon
#

Please 🙏 tell me

#

No i use app for coding

willow spindle
#

then you can't

timber beacon
#

Ok i will use microsoft visual code for serving

willow spindle
#

learn a programming language

timber beacon
#

I know

willow spindle
#

No i use app for coding
@timber beacon which app

timber beacon
#

Microsoft visual code

#

On my laptop

willow spindle
#

ok, also which language/library do you use

timber beacon
#

discord.js

willow spindle
#

but wait for approval first

timber beacon
#

Ok

willow spindle
#

Because you cannot use it now

timber beacon
#

What are the app that i can use for hosting my discord bot in mobile phone

#

Could you please tell me

#

@willow spindle

willow spindle
#

idk

patent cypress
#

@timber beacon I know

restive otter
#

what to write here

#

@left egret sir can you help me out pls

left egret
#

Your webhook server's URL

#

...where we'll send requests on vote

restive otter
#

umm

#

@left egretis there any way to get total votes of bot ! like i do command {prefix}vote it will show the votes of bot

left egret
#

Did you check our docs?

#

There is a bots/<id> endpoint that returns all info

#

including monthly and all time votes

restive otter
#

@placid peak can you tell me how to that

#

i need to get my bot votes

placid peak
restive otter
#

i am unable to do

#

i need help

velvet pond
#

Did the gateway go down? I got a bunch of 500 errors, but i don't know when they logged. I'm using the node sdk.

restive otter
#

sdome body help i have voting problem

#

people did vote but it is not showing

dense shale
#

did you got the webhook running?

restive otter
#

i am confised

#

which webhook i need

#

?

dense shale
#

the one for reciving the votes from top.gg

restive otter
#

where do i get it?

dense shale
restive otter
#

bro

#

i readed it

#

but i am confused

#

tooooooooooooooo

dense shale
#

what language did you use?

restive otter
#

.js

#

@_@

dense shale
#

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!`);
});``` this is the Example from the docs. If the webhook is running you will see Webhook running at http://127.0.0.1:5000/dblwebhook
#

copy the URL and replace 127.0.0.1 or 0.0.0.0 with the IP of your Server. this URL you set in the page of your Bot on Top.gg

#

and if someone votes you will see in your console User with ID ${vote.user} just voted!

#

you can extend this to store the userid of the user that voted into a database to see the total votes per user as a example

restive otter
#

i will try it

#

port will be 5000?

dense shale
#

yes

restive otter
#

thank you very much

#

dude

dense shale
#

you can also mention the user without pinging them if you set <@normal ginkgoid> in the message (only in embeds)

#

whytf did this pinged someone

#

sorry

restive otter
#

lol

#

@dense shale last thing can i show total votes

#

of my bot

#

in message

dense shale
#

you can store the votes in a database.

#

if someone votes set the database +1 during the week and +2 on weekends

restive otter
#

but i have 176 votes now

#

what about them

dense shale
#

if you have a Proper database you could manually set it as a base value

restive otter
#

@dense shale hi can we send any message to user that voted

#

the bot

#

like

dense shale
#

you can

restive otter
#

vote.send(any message)

dense shale
#

you get the Discord Userid from the vote. then search for the user and then send a message to him

restive otter
#

how

#

@_@

dense shale
#

you get the userid from votes.user i think

#

then client.users.fetch(votes.user) will return the user that voted

#

if you then set the client.users.fetch(votes.user) as a value you can make user.send("text")

sullen nymph
#

-api

abstract mothBOT
burnt plume
#

sry wrong channel

restive otter
#

@dense shalethat not working

#

i should maybe use

#

get

dense shale
#

did you get an error?

restive otter
#

client.user.get(vote.user)

#

i got nothing

dense shale
#

why did you know id doesnt work?

restive otter
#

umm

#

becuse i tested it lol

dense shale
#

ohh i think its vote.user.id

restive otter
#

na

#

vote.user

#

actually

#

resturns id

dense shale
#

ye

#

i would use fetch bcs get is cached and can miss offline users

restive otter
#

i use v11

dense shale
#

but i guess we should take further discussions into #development

#

rip

#

would update soon

restive otter
#

i dont use v12 due to that cache thing

dense shale
#

well you bot will go offline in october

restive otter
#

@_@

#

why

dense shale
#

bcs V11 will get shut down

restive otter
#

umm

#

then i have to upadte

sullen nymph
#

-api

abstract mothBOT
frank mulch
#

hm

placid citrus
#

If we get rate limited (429) and API banned for an hour (sorry!), once we've fixed the issues, will the bot need restarting to reconnect for it to work, or should it be functional straight after the hour?

vapid cape
#

in any case, you should try manually starting your bot again after an hour just in case it doesnt for some reason

placid citrus
#

Tim, top.gg not discord!
No worries.

vapid cape
#

in that case it should automatically function again

snow scroll
#

(4 shards)

vapid cape
#

if you post with shard id then you have to send only guilds for that shard

dense grail
#

is top.gg webhook events coming in late

open bone
#

What does the webhookPort and webhookAuth do?

sullen nymph
#

Port - port to run the webhook on
Auth - a combination of characters to use as a password to make sure a request is coming from top.gg

open bone
#

What do I put in webhook URL on the top.gg website?

knotty garnet
#

the url to your webserver

#

if you have one

open bone
#

localhost?

#

idk

untold vortex
#

if

willow spindle
#

@open bone https://your-server-ip:port/dblwebhook

jaunty plank
#

What are the odds, my server is also localhost

austere pecan
#

Guys I used the api to show my server count. I got this error
Error: 429 Too Many Requests

#

            dbl.postStats(client.guilds.cache.size)
        }, 45000);```
#

This is my code

#

Can someone help?

#

I guess I got rate limited. Is it due to 45 seconds

#

smh yeah its probably that

jaunty plank
#

they suggest 1800 seconds on the docs for poststats

austere pecan
#

yeah my bad

restive otter
#

Lol

golden adder
#

is top.gg webhook events coming in late
@dense grail mine seem to be coming in late. Got vote confirmation notification from my bot about 10 or 15 minutes after actually voting for it

placid citrus
#

Is there a way to fire the “vote” event without someone voting in order to dev test?

green mantle
#

if you actually notice the bottom of the webhook pannel there is this button called test which exists for a reason :P

restive otter
#

sa

#

I want to take a dbl api but how do we do it?

knotty garnet
#

"take a dbl api"?

restive otter
#

how do i see from my api?

knotty garnet
#

sorry, I didn't understand. Do you want to make a dbl api?

restive otter
#

sorry, I didn't understand. Do you want to make a dbl api?
@knotty garnet Yes want this

knotty garnet
restive otter
#

How?

knotty garnet
#

if you want to make an api you'll need to use raw http requests

#

unless you meant "use the api", which in this case there are a myriad of pre-made libraries ready for use

restive otter
#

aaa need my new website owner? @knotty garnet

knotty garnet
#

what?

restive otter
#

-apispam

#

;-;

restive otter
#

-apispam

tawdry ferry
#

can i not use a .env variable for my api token, i got a 401 untill i stopped using the .env variable?

knotty garnet
#

Unauthorized error?

tawdry ferry
#

yeah

knotty garnet
#

You're probably getting the var wrongly

tawdry ferry
#

const ggtoken = process.env.GGTOKEN

knotty garnet
#

Have you tried doing console.log(ggtoken)?

#

To see what is its value

tawdry ferry
#

no, ill try that

#

i was being stupid, forgot to remove the `

knotty garnet
#

Lol

keen tartan
#

how to check if someone voted and reward them

willow spindle
#

Which lib

keen tartan
#

discord.js

#

@willow spindle

willow spindle
#

hasVoted()

keen tartan
#

k

#

i'll check

molten quarry
lost merlin
#

which language?U use

molten quarry
#

python

lost merlin
#

yeah mee too

#

Can't figure that out till now

molten quarry
#

Same here

dense shale
#

install the py client. it should handle it

#

the docs are pretty good

short ember
#

Same

placid citrus
#

Any reason why this would be hitting a rate limit?

    let DBLUsers = await db.DBLUser.find();
    DBLUsers.map(g => g.ID).forEach((user, i) => {
        const member = client.guilds.get('627967081014624294').members.get(user);
        setTimeout(() => {
            if (dblClient.hasVoted(member.id) && !member.roles.includes('667451645180903428')) member.addRole('667451645180903428').catch();
            if (!dblClient.hasVoted(member.id) && member.roles.includes('667451645180903428')) member.removeRole('667451645180903428').catch();
        }, i * 2000);
    });```
vapid cape
#

it runs hasVoted twice on every timeout

placid citrus
#

Right, yes.
Sso lets assign that to a var above

vapid cape
#

and if that code runs more than once, you will have multiple concurrent timeouts all requesting data from top.gg

placid citrus
#

It's just in the ready event, so it runs once

vapid cape
#

the ready event may be fired more than once, make sure you set it to .once instead of .on

arctic arch
#

hasVoted returns a promise too, you're not awaiting

restive otter
#

@molten quarry do you mean giving top.gg the amount of servers or getting the amount of servers on your bot?

#

Late response also

molten quarry
#

giving them the amount of server

restive otter
#

Oh not sure

molten quarry
#

:/

restive otter
#

Not on your end it would be len(client/bot.guilds)

#

Client or bot depending on what you use

knotty garnet
#

giving them the amount of server
@molten quarry use the top.gg lib

abstract rapids
#

will my boat be approved?

jaunty plank
open bone
#

How do you get the amount of votes a bot has?

jaunty plank
#

depends on the programming language and library

devout hearth
#

So I got an error: getaddrinfo EAT_AGAIN top.gg

supple flicker
#

okay so, how do I make my bot say "User voted" in a channel with the api and stuff. could someone help me?

#

@sullen nymph could you please help me if you got some spare time?

jaunty plank
#

what library/language @supple flicker

supple flicker
#

discord.js

jaunty plank
#
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});

instead of console.log, channel.send()

you will have to get a channel.

supple flicker
#

hm okay.

ivory river
#

Using Windows Server 2016 I have added a TCP forward in my Windows Firewall for port 5000, when trying to visit it says that the server took too long to respond.

#

Any ideas?

#

Regarding webhooks.

sly gate
#

Hi
Nothing gets sent to my console when someone votes...

sly gate
hollow flame
#

Hey i just added the auto server count in my bot

#

Now its around 10 mins still not showing

#

So something i have done mistake??

#

I just create file called top.gg in my cogs

hollow flame
#

@sullen nymph can u please help sorry for the ping

restive otter
#

can we using voting api on github?

median badger
#

Huh

willow spindle
#

What

wooden dove
#

Any idea why?

dense shale
#

@sly gate did you added the Webhook URL to your Page at Top.gg?

#

@hollow flame is the authentification of the bot valid?

sly gate
#

It was the wrong url @dense shale

#

Its good for now

hollow flame
#

@dense shale yaa dbl bot token

#

Is correct

dense shale
#

does the bot validate that he connected to the DBL server?

hollow flame
#

How🤔

#

I check that

#

Bt i have created the folder top.gg in my cogs folder

#

In that i have paste the codes

dense shale
#

ohh you use py

hollow flame
#

Yes

dense shale
#

did you got this event?```
async def on_guild_post():
print("Server count posted successfully")

hollow flame
#

I didn't see the log

#

I need to restart my bot :/

dense shale
#

did you got self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) make sure autopost is true

hollow flame
dense shale
#

idk. i use d.js

#

if you follow the infos on the offical documentation it should work

olive arrow
dense shale
#

gg

#

im not even logged in

olive arrow
#

no your cloudflare token

lime wagon
#

I heard the bot was disapproved if we use animated emoji. is it correct

green mantle
sly gate
#

There is a little problem no ? x)

#

I use this to know the vote count : ```js
await dbl.getBot(Pikacord.user.id).then(stats => {
bot = stats.points;
});

restive otter
#

:D?

ashen rover
#

is there any way to post guild count without using dblapi.js? :o

sullen nymph
#

A direct HTTP request to /bots/{id}/stats

ashen rover
#

thanks

sullen nymph
#

You can view dblapi.js source code to see how it's done internally for reference

arctic trench
#

-botinfo 716533909818572850

abstract mothBOT
#
Bot info
ID

716533909818572850

Username

Pokécord 2.0

Discriminator

0608

Short Description

Pokecord 2.0 is mainly made on public interest. This bot is based on Pokemons catching, trading etc.

Library

discord.js

Prefix

. (Customizable)

Total Upvotes

1

Monthly Upvotes

0

Server Count

No server count

Owner(s)

@quartz heron
@tawny pelican
@latent moon
@arctic trench

green mantle
#

🤔

#

that isnt gonna get approved lol

#

also not the right channel

abstract mothBOT
#

tickNo That bot wasn't found

wooden dove
#

to have my server count show, i need to send post requests to /bots/{bot.id?}/stats, yes?

#

with the authorisation header

past mortar
#

You could or you can just do this if you have the api module.
const dbl = new DBL(Your Token, Your Client);

golden adder
#

I don't think so @tidal star but you could just set up a webhook event that updates a counter per user id in a database every time they vote 🤷‍♂️ just remember to check if it's a weekend vote because they count double

spiral steeple
#

You can

#

it's called points

#

it's a GET request to /bots to get the bot object

#

The libs also cover it

arctic arch
#

they asked per user

#

not total

golden adder
#

Points returns just a number not an array of user ids

spiral steeple
#

Ah, then I didnt see that. Per user you'd probably need to use webhooks

golden adder
#

No problem! 😊

swift dove
#

Any girls?

spiral steeple
#

Not the place to ask.

jaunty plank
desert inlet
#

how i can put the shards on top.gg?

#

the send was this but not found the shards

#
      .send({ server_count: servers.reduce((previous, count) => previous + count, 0), shardId: client.shard.id, shardCount: client.shard.count } )
vapid cape
#

if you're using discord.js v12 and using the Sharding Manager

#

then it should be client.shard.ids[0] for shardId

desert inlet
#

@vapid cape Nope

#

i used the discord js v11

#

In the web don't put shards or something like this 😦

vapid cape
desert inlet
#
      .send({ server_count: servers.reduce((previous, count) => previous + count, 0), shardId: client.shard.id, shardCount: client.shard.count } )

.

vapid cape
#

you're doing shardId and shardCount

#

should be shard_id and shard_count

desert inlet
#

ok

rapid kettle
#

@gloomy fractal above
he wants us to invite with admin perms

hollow flame
#

How i add servercount in my bot

#

Its in python i have created the topgg.py folder in cogs and added the automatic post

#

Bt still its now show yet in the top.gg

sly gate
#

End I won't be allowed... but why...

#

The link worked perfectly before and the password matches and the port...

restive otter
full mesa
#
            async with client_session.get("https://top.gg/api/bots/657776310491545620/check", headers={"Authorization" : "MyTokenHere"}, json={"?userId=" : str(users)}) as response:

But DBL's API responds with:

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

I already have the query, right?

proper cedar
restive otter
#

Yo how can I get admin in this server

willow spindle
#

you can't

hollow flame
#

Help me

old lake
#

what to put in webhook path and auth??

#

ping me

restive otter
#

@old lake

#

there i pinged you

old lake
#

np 👍

jagged prawn
#

how to fix n/a

true talon
jagged prawn
#

i checked but

#

i need help

#

how to install i nheroku

#

package

true talon
#

Learn how heroku works please

jagged prawn
#

-_-

sullen nymph
jagged prawn
#

whats the dblapi.js version

sullen nymph
#

2.4.0

jagged prawn
#

thanks

restive otter
#

@jagged prawn Yay!

jagged prawn
#

❤️

restive otter
#

Have fun with your bot @jagged prawn

jagged prawn
#

thanks u too 🙂

hollow flame
#

@sullen nymph sorry for the ping

rapid kettle
#

How do I use my top.gg api widget

#

Do I just copy-paste the link as an embed image

true talon
#

Yes

whole wind
#

hmm

rapid kettle
#

My bots widget returns 1 server?

jaunty plank
#

whats the webpage for your bot say server count wise @rapid kettle

rapid kettle
#

25

#

but I fixed it

jaunty plank
#

did it previously say 1 before?

rapid kettle
#

Yes

jaunty plank
#

is the image just cached?

rapid kettle
#

it turned out to be an issue with discord cache

jaunty plank
#

discord likes caching stuff pikathink

rugged minnow
#

lol, considering that discord js v11 -> v12 just added a buncha of cache to all of the stuff

full mesa
#

json={"userId" : str(users)}

#

How can I fix it?

sullen nymph
#

What's users

full mesa
#

A list of IDs

#

Its in a for loop so it goes through them one by one.

#

@sullen nymph

restive otter
#

hi

#

I need help to add the api to my bot, does anyone help?

vapid sapphire
#

You cannot use the API until you have a bot approved on top.gg

restive otter
#

okay

dull plank
#

💯

restive otter
#

I need help when a user votes for my bot, the bot give them a role in my server
i also dont know how to

devout hearth
#

Hey I get an error from your api sometimes. Any reason why?
Error: getaddrinfo EAT_AGAIN top.gg

frigid basin
#

@restive otter
what language?

restive otter
#

js

#

i dont get the Getting Started part..

frigid basin
restive otter
#

i read it

frigid basin
#

did you try the example?

restive otter
#

yeah

frigid basin
#

did it work?

#

if not, any errors?

restive otter
#

nope it does nothing

#

what do i put for the 0.0.0.0:?

frigid basin
#

You need to port forward Your IP

#

or your VPS

#

I think

#

not 100%

jaunty plank
#

vps's typically dont need port forwarding

restive otter
#

how do i port forward

#

sorry im new to this ;-;

frigid basin
#

If you use a VPS you don't need to

#

if not i can get a guide

restive otter
#

i dont use a VPS

jaunty plank
#

port forwarding depends on your router, this page has most routers listed

#

and guides for each one

full mesa
#

Would anyone know what I'm doing wrong for it to send that error?

knotty garnet
#

You need to add userid param to the url

full mesa
#

Oh

#

That makes more sense

#

Thank you

balmy hamlet
#

dude

#

the error literally says "add ?userId= to your request"

#

how is that even hard

jagged prawn
restive otter
#

@jagged prawn make sure bot has perms manage server

#

so that bot can see invite links in that seeveer

#

if bot has 0 perms he cant fetch the invites link of the server

#

also this is not bot discusiion channel you have to discuss in #development

#

this channel is only for bot api of top..gg

jagged prawn
#

@restive otter ye this is the problem

#

bot is in 32 guild

#

i need skip but i dont know how

restive otter
#

come there

jagged prawn
#

ok come here pls

#

ok

golden adder
#

Quick question about the api. I have a voting streak counter on my bot like in the screenshot below. The way I currently do it is via webhooks in the bot's index.js file. The webhook vote event updates the info in the bot's database for the user who voted (new currency balance, vote UNIX timestamp, updates voting streak and gives them a voter role if they're in my bot's support server). This all works fine, however, if the bot is rebooting when a user votes then the webhook event fires into nowhere because the bot isn't online to receive it, thus causing users to miss out on their voting rewards and lose their voting streak. I was wondering if there's a more reliable way of going about this? My bot doesn't reboot often at all but sometimes it lines up with someone's vote and causes me trouble to go and fix it manually in the db. Right now the bot's in 1,200 servers and gets about 800 monthly votes so it happens about once a week. Any better solutions?

#

Sorry for the long ass message 😂

keen ermine
#

Can i get an api token before my bot got approved?

rapid kettle
#

Nope

vapid cape
#

@golden adder one solution would be to put the webhook endpoint in a separate process connected to the same database

golden adder
#

I was thinking that... How would I notify the user via DM though?

vapid cape
#

many ways to do that, you can make an api request to discord from there, you can send a message to the bot process via ipc or message brokers, you can use some middleman service to handle dbl votes...

#

you can use a pub/sub system with your database, if it supports it

golden adder
#

Ok. Thanks @vapid cape I'll look into that

austere pecan
#

I'm getting error 524 Origin Timeout and 503. Is this normal?

#

Will it just pass by?

golden adder
#

Probably just some DBL downtime 👀

#

I don't know

jaunty plank
#

That is the webhook part

#

The webhook is for your bot to receive data

strange turtle
vapid cape
#

it does do autoposting

#

if you give it your client

#

new DBL(token,options,client)

strange turtle
vapid cape
#

why are you doing vote.id == vote.user

#

that will never be true, so you will never find a vote

strange turtle
#

Ah okay, I'm new to the api.

vapid cape
#

you need to check if vote.id equals the user id that used the command

#

also, dbl.hasVoted() exists

strange turtle
#

so make a var to see if they equal to each other?

vapid cape
#

no, you just need to change vote.user to the user who used the commad

strange turtle
#

Alright, thanks.

vapid cape
#

you have to use the same api key as your main bot

#

if your test bot has the same id

strange turtle
#

If you got multiple shards and it counts them, it should count all the guild counts

vapid cape
sullen nymph
#

0 I believe

languid spoke
#

Yes, i am having the same Problem. Could anyone help us pls?

grizzled gulch
sullen nymph
#

Please read channel topics

grizzled gulch
dusty roost
#

does anyone know the right firewall rule to make on gcp to allow dbl to send votes

#

i tried an ingress rule that allows tcp:5000 but still nothing

vapid cape
#

thats correct

#

did you set the ip ranges to 0.0.0.0/0?

dusty roost
#

yeah

#

so i went to the bot page and it did update the server and shard count, but i'm still not getting vote events

#

on the topic of that, is there anyway to make it auto update the server count of all shards? because passing client in dbl just sends the server count of the shard that the dbl set up is on; is there a way to put it in an external file so it applies to everything?

jaunty plank
#

discordjs?

#

@dusty roost

dusty roost
#

yeah

jaunty plank
#

or, if you want to do it by the api, you can use postStats to set the shard id and count, along with the number of servers that shard is in.

dusty roost
#

i got Error: 400 Bad Request

jaunty plank
#

doing what

#

or, well whats your code look like

dusty roost
#

nvm i think i spotted it

#

if it doesn't work again i'll send it

#

TypeError: Cannot read property 'Id' of undefined

#
dbl.webhook.on(`ready`, hook => {
            console.log(
              `Webhook running at https://${hook.hostname}:${hook.port + hook.path}.`
            );
            setInterval(() => {
                client.shard.fetchClientValues("guilds.size")
                .then(results => {
                  dbl.postStats(results.reduce((prev, val) => prev + val, 0), client.shards.Id, client.shards.total);
                  console.log(results.reduce((prev, val) => prev + val, 0));
                })
                .catch(console.error);
            }, 10000);
        });
jaunty plank
#

are you on djs 11 or 12?

dusty roost
#

11

jaunty plank
dusty roost
#

ok i'll try that

#

hey it works

#

thanks a lot

jaunty plank
#

np

dusty roost
#

do you know how to fix my voting issue?

jaunty plank
#

Ive never used the api yet(i don't have access yet), so i probably wont have an answer the docs doesn't have.

dusty roost
#

oh i see

dusty roost
#

uh to anyone else who may see this: i'm not getting voting events even though it's connected to the webhook

jaunty plank
#

is it hosted on a home network?

#

if its hosted on a home network, it needs to be port forwarded

#

also, if you have ufw or iptables you may need to let it through

willow spindle
#

just use official library

#

it has hasVoted() function

#

because it is useful and you don't need to send http request

#

i mean you don't need to send a http request manually

sullen nymph
#

I suggest you set top.gg as the URL

restive otter
#

so i need to update user data who voted for that i need webhook server? or i can do without that, im using python

old glacier
#

@sullen nymph ^^^^^^

sullen nymph
#

It's easier to use webhooks to store data locally

#

which will be more efficient but you will need to handle cases when someone voted for your bot while the webhook/bot is down

strange turtle
#

Just have patience

vocal cove
#

sa

#

bot eklemek istiyom nasıl klicem

#

şimşek

jagged prawn
vapid cape
#

which library? discord.js? which version? v12?

jagged prawn
#

discord.js

#

nodejs

jaunty plank
jagged prawn
#

ok

vapid cape
#

which version tho

#

v11 is guilds.size, v12 is guilds.cache.size

jagged prawn
#

im using

#

v12.18

rapid kettle
#

how do i use my widget again

#

i forgot

sullen nymph
#

setembedimage(<widget link>)

rapid kettle
#

yea, but discord caches it

sullen nymph
#

?somerandomquery=somerandomvaluethatchangesoneachrequest

rapid kettle
#

ah

#

so i can just put a timestamp

sullen nymph
#

that works too

rapid kettle
#

oh god

#

something spoopy happened

#

why

sullen nymph
#

What's the URL

rapid kettle
#

I'll just get that

sullen nymph
#

Apparently there's a limit of 6 characters in query value

rapid kettle
#

god damn

#

I'll just clip a few chars

sullen nymph
#

Could also slap more params in

vapid cape
#

@jagged prawn discord.js version, not node.js version

jagged prawn
#

ye

#

i type node

frozen jolt
#

how to set up so it does something when a user votes your bot

#

please ping me

jaunty plank
#

What library are you using?

frozen jolt
#

discord.js

jaunty plank
#

I was meaning the api library

#

Theres an example of receiving vote updates on that page for the official library

young haven
#

how do i get the bot to thank a user on the channel after voting top.gg?

jaunty plank
#

In a specific channel in your main server it's pretty easy

#

Just get the channel(once at startup) and send the message there

young haven
#

adding this?

dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});
jaunty plank
#

Yeah, instead of logging tho, send to the channel you want

young haven
#

TypeError: Cannot read property 'on' of undefined
dbl.webhook.on('vote', vote => {

jaunty plank
#

You need to initialize the webhook like the example shows

#

On the const dbl = new DBL
Line

young haven
#

I don't know how to do that, thanks for the help

vapid cape
#

did you check the examples?

young haven
#

Yes, but I don't understand

vapid cape
#

which part didnt you understand?

frozen jolt
sullen nymph
#

no it's your bot's ID

frozen jolt
#

ok ty

past warren
#

"how do i get the bot to thank a user on the channel after voting top.gg?"

#

can i do it

#

with C#

#

?

#

Because couldnt see

frozen jolt
past warren
#

using .net

frozen jolt
#

what is DBL Token ?

sullen nymph
past warren
#

y

frozen jolt
#

oh ok

past warren
#

"how do i get the bot to thank a user on the channel after voting top.gg?"
C# . net
Can i do it ?

sullen nymph
#

If the official DBL library for C# doesn't have a webhook, you can host one yourself using some library

frozen jolt
#

what would webhookAuth be?

sullen nymph
#

anything you want

frozen jolt
#

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

#

i am looking at this

#

and i do not userstand the hook.port or hook.path

past warren
#

k thank you

frozen jolt
#

is this something i am creating or something i get it from somewhere

sullen nymph
#

you create

#

ah the hook.port stuff

frozen jolt
#

is there an example because I am clearly new to this and I am trying to learn

jaunty plank
#

that is the example

sullen nymph
#

hook is the webhook "session" that is running currently

frozen jolt
jaunty plank
#

its the same as client.on('ready'
in this case, its an event for the webhook

frozen jolt
#

oh

young haven
#

which part didnt you understand?
@vapid cape I was trying to use
dbl.webhook.on('vote', vote => {vote.user.send("thanks for voting")});

but it doesn't work

jaunty plank
#

you need to tell top.gg to push data to your webhook

young haven
#

I have to put the webhook of discord on top.gg?

jaunty plank
#

no

#

the one your creating

frozen jolt
#

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!);
});
would i be changing the hook part or no?

#

like hook.hostname and hook.port

jaunty plank
#

hook.port is set here
webhookPort: 5000

frozen jolt
#

oh

jaunty plank
#

the hostname is likly just the ip to your server

#

the public ip

frozen jolt
#

but i don't change that right

#

it says Error: listen EADDRINUSE: address already in use :::5000

jaunty plank
#

the log part is just logging whatever its set to

#

do you have port 5000 in use already?

frozen jolt
#

i don't think so

jaunty plank
#

only one program per server can use port 5000

#

using glitch or something?

frozen jolt
#

yes

#

glitch

jaunty plank
#

glitch may not allow some ports

frozen jolt
jaunty plank
#

or you may have to request the ability to use a port

frozen jolt
jaunty plank
#

it would be a question for glitch

frozen jolt
#

I think I should just give up this is too complex for me

#

isn't there an alternate for 5000

jaunty plank
#

yeah, thats what i was saying

#

change the port to something glitch allows, or find an available port

frozen jolt
#

okay

sullen nymph
#

Glitch only allows 3000

frozen jolt
#

thx

#

same error for 3000

frozen jolt
#

what do u recommend i do? give up

jaunty plank
#

contact glitch support

frozen jolt
#

i look into it and they said you can setup a proxy

jaunty plank
#

You might need a second server to do that, at that point just get a VPS

frozen jolt
#

wait a min

#

isn't webhookPort optional

jaunty plank
#

ports are required

#

for webhooks

frozen jolt
#

oh f

jaunty plank
#

every web request has a port

frozen jolt
#

ok

frozen jolt
#

how would i use /bots/{bot.id?}/votes endpoint?

oblique turret
sullen nymph
#

-api

abstract mothBOT
frozen jolt
#

how would i use /bots/{bot.id?}/votes endpoint?
I believe this had to do with top gg

vapid cape
#

shivaco was responding to christian

#

to use the endpoints directly you can make http requests to them with any http library

#

alternatively you can use one of the official libraries, which support all endpoints

#

for example, you're already using dblapi.js, to access the /bots/:id/votes you can use dbl.getVotes()

restive otter
#

I keep getting cloudflare rejection with dbl api

#

anyone know how to fix

#

0|projectb | Error: 401 Unauthorized

#

0|projectb | server: 'cloudflare',
0|projectb | 'cf-ray': '5aba8533fab12fa5-FRA'
0|projectb | },
0|projectb | ok: false,
0|projectb | statusText: 'Unauthorized'
0|projectb | }

restive otter
frozen jolt
#

I am doing dbl.getVotes().then(votes => { console.log(votes); });

#

and it's only showing like couple votes and on the website it says 37 votes

#

all of the votes were in this month

vapid cape
#

its close to july, its possible the monthly reset already happened but the website didnt update yet

frozen jolt
#

okay ty

#

i had a friend vote for it just now and i tried it again it gave no new result

restive otter
#

Anyone?

frozen jolt
#

anyone?

gentle pewter