#topgg-api

1 messages · Page 143 of 1

sullen nymph
#

Notice the double slash after api

marsh cedar
sullen nymph
#

Yeah your browser probably trimmed one of them

marsh cedar
chilly spire
#

Hey so the top.gg docs say I can find a webhook at my bot site. When I go to that site, though, I don't have a webhook

#

Can anyone help?

night ingot
chilly spire
#

The webhook URL isn't there

night ingot
#

What url are you looking for exactly?

#

Because the button I showed you leads to that exact url

chilly spire
night ingot
#

That's where you enter your own webhook address. You need to set up your own system for it

chilly spire
#

shit

#

alright

#

thanks

royal jacinth
#

Hello

chilly spire
#

When I set up my own system, does Top.gg give me the authorization or does the system I set up provide that as well

night ingot
#

You can set up your own authorization token in the webhook page for your bot. But it's not required to use one

chilly spire
#

Oh, alright

#

one last thing

#

can I use a discord webhook

night ingot
#

I don't think so, but I can't say for sure. Never tried it

chilly spire
#

Well it's not really working for me

#

=/

#

But thanks

tepid thunder
#

y my users are getting multiple rewards in 1 votes

sullen nymph
#

What library do you use

tepid thunder
sullen nymph
#

How are you using webhooks

#

If you are, in the first place

tepid thunder
#

means?

#

@sullen nymph this is my code

#

@sullen nymph see this i just voted before vote i was having 0 crate and after vote i have 6 crate

sullen nymph
#

Interesting

#

Are you sure the webhook actually responds with 200 and not 401

tepid thunder
#

yes

#

its responds 200

waxen iron
#

how can i do it do it

tepid thunder
#

here is the logs

waxen iron
#

?

#

how can i set up a webhook and use the api

sullen nymph
#

Interesting

chilly spire
#

Does the webhook have to be where your bot is being hosted?

#

Probably a dumb question if the answer is yes

tepid thunder
#

@sullen nymph dude see this its also spamming in dms the vote rewards and now it increase

#

please tell how should we fix

waxen iron
#

@sullen nymph ?

sullen nymph
#

@craggy sentinel have there been reports of webhooks firing multiple times for a vote from the same user?

#

Note: the webhook does respond with 200

craggy sentinel
#

needs to be a 204 iirc

sullen nymph
#

The announcement says 2xx

#

Does it have to be 204?

craggy sentinel
#

oh nvm docs say 2xx aswell

tepid thunder
#

itss 200

craggy sentinel
#

thats the first real report i've seen yet

tepid thunder
#

see this

craggy sentinel
#

there were several reports prior but those were always people who haven't read #site-status Thonk

#

are you sure it's actually responding?

#

like have you checked if the endpoint actually works with something like postman etc.

tepid thunder
#

its working but its giving multiple rewards and dms in 1 votes

craggy sentinel
#

not sure if you understood me

#

because that would actually make it a bug on your side

#

and top.gg wouldn't be involved at all

sullen nymph
#

It does respond

#

That's a 200 response code returned to a POST request to /dbl, so

tepid thunder
#

i have sended the code

#

of my webhook

stoic schooner
#

how do i setting my webhooks?

restive otter
#

i will like to know as well

#

i didn't realy understand the documentation

plucky lance
#

You guys gonna host a webhook service on your server which listens to the incoming dbl webhooks
You have to open the port you specified in your firewall INBOUND TCP
Take the public IP address of the machine and use it as your webhook path

restive otter
#

ya but i don't know how to do it

plucky lance
#

Do you even own (rent) an own server?

restive otter
#

i have my own server

plucky lance
#

OS?

restive otter
#

debian

plucky lance
#

Well than find out which firewall the system uses, maybe ufw or iptables

restive otter
#

ok

plucky lance
#

Both rules are simple to setup, e.g. sudo iptables -A INPUT -p tcp -m tcp --dport 9999 -j ACCEPT
Replace the destination port 9999 with out actual port

restive otter
#

ok i'll try

plucky lance
#

Two useful commands:
ufw status
systemctl status iptables.service

devout dock
sullen nymph
#

Within the past 12 hours

devout dock
#

thank you

hollow flax
#

Python Short Question...
When i use this Command...

await hook.get_user_vote(user_id=185449287356907520)

than it gives "TRUE" back....
Is TRUE = voted for the bot
and
FALSE = Not voted for the bot ?

sullen nymph
#

Correct

dull thicket
#

e

restive otter
#

where i can find out my token?

dawn kernel
barren kestrel
#

I’m simplistic terms. In discord.js how can I say, “once a user votes, do something.” I don’t really want to do it through webhooks. Ping me if you know

plucky lance
#

You can’t djs has nothing to do with topgg.
If somebody votes on topgg that has nothing to do with djs, too.
You can only send a request to the API of topgg and basically ask which user voted, take his user id and do something with it.

#

Similar to webhooks but for these you don’t need to ask the API who voted, they will send you a webhook or let’s say an information including the user (id).
You can work with that.

#

This whole process doesn’t require djs because it has nothing to do with it.

#

If you wanna use the user id you got to for example send a DM to the user djs will be library to use to actually send that message.

#

Let’s say you wanna promote an user who voted for your bot.

#

You will walk through the mentioned ways above, using the djs library your bot is probably running with, check the user id you got if the user actually exists on your Discord server and if so promote him.

#

Send a message, assign a role etc.

#

All this sounds more complex than it actually is.

#

Using a common lib to create a webhook service OR a lib to send cURL requests to the API of topgg

#

And using the response in your bot code or a several instance of it just to send a vote-thank message or assign a role etc.

#

At least just a few lines of code

marsh cedar
#

how to check who voted for my bot using dbpy?

prisma turtle
#

Yeah me too I need to know how 😅

#

I read the documentation and I try it bot, nothing happens

#

Yes

#
import discord
from discord.ext import commands, tasks
import asyncio
import datetime
import sqlite3
import os
import time
from collections import OrderedDict, deque, Counter
import math
import random
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
import io
from io import BytesIO
import requests
import aiohttp
import logging
import dbl



class BotList(commands.Cog, name='Ranks'):
    def __init__(self, bot):
        self.bot = bot
        self.token = 'The token of the api.' # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)

    @tasks.loop(minutes=30.0)
    async def update_stats(self):
        """This function runs every 30 minutes to automatically update your server count"""
        logger.info('Attempting to post server count')
        try:
            await self.dblpy.post_guild_count()
            logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
        except Exception as e:
            logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))

        # if you are not using the tasks extension, put the line below

        await asyncio.sleep(1800)

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        logger.info('Received an upvote')
        print(data)
        
    @commands.Cog.listener()
    async def on_ready(self):
        print("Dbl is loaded !")

def setup(bot):
    global logger
    logger = logging.getLogger('bot')
    bot.add_cog(BotList(bot))
#

The python api wrapper for top.gg

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

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

    async def on_guild_post():
        print("Server count posted successfully")

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print(data)
        user = data['user']
        embed = discord.Embed(description="New Vote! Voter: {}".format(user))
        channel = self.bot.get_channel(int(chnl_id))
        await channel.send(embed=embed)

def setup(bot):
    bot.add_cog(TopGG(bot))

i tried this to check votes, but it doesnt seems to work

mild mulch
#

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

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

async def on_guild_post():
    print("Server count posted successfully")

@commands.Cog.listener()
async def on_dbl_vote(self, data):
    print(data)
    user = data['user']
    embed = discord.Embed(description="New Vote! Voter: {}".format(user))
    channel = self.bot.get_channel(int(chnl_id))
    await channel.send(embed=embed)

def setup(bot):
bot.add_cog(TopGG(bot))

dusky monolith
#
import dbl
import discord
from discord.ext import commands, tasks

import asyncio
import logging


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

    def __init__(self, bot):
        self.bot = bot
        self.token = 'dbl_token'
        self.dblpy = dbl.DBLClient(
            self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)

    @tasks.loop(minutes=30.0)
    async def update_stats(self):
        """This function runs every 30 minutes to automatically update your server count"""
        logger.info('Attempting to post server count')
        try:
            await self.dblpy.post_guild_count()
            logger.info('Posted server count ({})'.format(
                self.dblpy.guild_count()))
        except Exception as e:
            logger.exception(
                'Failed to post server count\n{}: {}'.format(type(e).__name__, e))

        # if you are not using the tasks extension, put the line below

        await asyncio.sleep(1800)

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        logger.info('Received an upvote')
        print(data)


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

I get undefined variable 'logger' should I replace import logging with import logger or from logging import logger

#

And I'm trying to know what the returned data is, however, I keep getting this

restive otter
blazing thicket
#

I am having trouble getting the top gg api working with updating the server count

#

The bot works and I am not getting any errors

#

it just doesn't update the server count

#

(the 'token' part has my token in it when I'm using the bot)

dull thicket
#

Can someone help me with the python version of the lib?

#

It says that my bot is in 6 servers on the websife but it’s in 140

dull thicket
plucky lance
#

did you debug the code to see the result?

sullen nymph
#

How many of you fail to apply the cog listener decorator

dull thicket
sullen nymph
#

@commands.Cog.listener()

dull thicket
sullen nymph
#

Are you aware of how decorators work

dull thicket
#

Oops

#

I don’t have that thing at all

#

I only have the listeners for on vote and on test vote

dull thicket
#

All I have it in self.dbpy the Boolean auto post as true

#

Do u need anything more than that?

sullen nymph
#

Make sure you apply a bot object to DBLClient that's actually your public bot

dull thicket
# sullen nymph Make sure you apply a bot object to DBLClient that's actually your public bot
class TopGG(commands.Cog):
    """
    This example uses dblpy's webhook system.
    In order to run the webhook, at least webhook_port must be specified (number between 1024 and 49151).
    """

    def __init__(self, client):
        self.client = client
        self.token = token'
        self.dblpy = dbl.DBLClient(self.client, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port="PORT", autopost=True)```
#

Port, password, and token are my things I took them out

#

@sullen nymph it posted b4 idk why it’s not working anymore

wind wind
#

What does the API do?

rain heart
wind wind
rain heart
#

you can use it to also get information about other bots on top.gg and/or other users

restive otter
#

i'm having trouble with webhooks
i think ik what's wrong but
i can't seem to CURL my webhook link from my VPS
but I can from my PC where I'm running
it
Which screams networking issue but Idk how to fix it

#

VPS in Germany ^

#

Cmd (my computer ^)

#

looks like ppl outside my network just cant get thru but idk why

sullen nymph
#

192.168 is internal IP

#

aka not what you need

restive otter
#

bruh am i slow

sullen nymph
#

You need your external IP address

restive otter
sullen nymph
#

Probably best not to leak it here

restive otter
#

true

#

but i'm clicking refresh IP as soon as I'm done here so i don't mind

#

DDOSS away

sullen nymph
#

Make sure your machine doesn't have a firewall that blocks requests to port 5000

plucky lance
#

netsh advfirewall firewall add rule name="Webhooks" dir=in action=allow protocol=TCP localport=5000 enable=yes profile=any

#

Make sure to add a firewall rule for your Windows device if you host the webhook service on it.

restive otter
#

I'll be hosting it on my VPS but I just need to test on my device, but will do

#

Still no luck by the way

#

Ran that command & replied with "Ok."

plucky lance
#

Even tho you will have to setup an inboud rule for your specified port

#

Protocol TCP

plucky lance
#

Advanced firewall settings

#

Inbound rules, sort by name

plucky lance
#

did you run the command two times?

restive otter
#

yea

#

just deleted the 2nd

plucky lance
#

than delete one of it

restive otter
#

ye did

plucky lance
#

Last step now is your router to forward the port 5000 to your device

restive otter
#

oh gosh port forwarding

plucky lance
#

Atm the router blocks incoming ports

restive otter
#

not sure if there's anything else to do past this

plucky lance
#

TCP port 5000 to 5000, no range, no UDP

#

Make sure you actually forward the port to the DEVICE the code is running on

restive otter
#

oh

worthy kraken
#

Is there a way to show your bots status like dnd and online on the top.gg page?

rain heart
#

Not as of now

restive otter
worthy kraken
#

Oh since I saw like dyno and those bots have it so I was curious

plucky lance
#

If that's your device to webhook service is running on

#

Than it looks good

restive otter
#

Ayyy

#

It worked

#

I'm gonna go learn more about this now so I can do this in the future

restive otter
#

Thank you for the help my man

#

If I understand correctly, we opened up the port on my computer's firewall, then router's firewall, then directed it to my device

plucky lance
restive otter
#

:)

plucky lance
#

errr nvm

#

lmao

restive otter
#

🤨

hollow owl
#

hm

plucky lance
restive otter
#

yea

plucky lance
#

If a connection is "coming" to you aka. INBOUND the direction is vise versa

restive otter
#

That makes sense

plucky lance
#

any firewall needs to allow these inbound rules, they usually drop

#

Just for security reasons of course

#

Same thing for a server

#

But the provider firewall will not block your requests because you're responsible for what happens on your rented machine

restive otter
#

Yeah

plucky lance
#

This mostly requires only to open the port in the device firewall the code is running on aka. adding a new firewall rule for inbound rules

restive otter
#

Got a response from the webhook btw, so 🙂

plucky lance
#

Oh on thing more

restive otter
#

Yeah for sure

plucky lance
#

Response with a HTTP code 200

restive otter
#

Means successful

plucky lance
#

Correct

#

Or the same webhook will be send over and over again

sullen nymph
#

Could respond with 204 too

restive otter
#

oh i have no idea how to do that

#

lol

#

let me check some docs

plucky lance
#

doesn't matter.. 2xx

#

I wonder the webhook doesn't allow 3xx codes, too

restive otter
#

this might sound preposturous but is it possible the library i'm using handles it for me

plucky lance
#

doesn't make any sense when using proxies for example

#

but ok

restive otter
#

yeah i think the python-sdk lib for dbl does the response for you

plucky lance
#

maybe, dunno snakish-lang or the lib in general

restive otter
#

Fair enough

#

I'm excited to do this all over again but with ubuntu in a few hours

#

Meh i'll figure it out it's probably easier, last time I had to open a port it was just 1 command

plucky lance
#

Using ufw or iptables

restive otter
#

yeah ufw enable 5000 or something

plucky lance
#

sudo iptables -A INPUT -p tcp -m tcp --dport 5000 -j ACCEPT

#

for example

#

and for ufw:

restive otter
#

ufw allow 5000/tcp

plucky lance
#

/tcp

#

correct

dull thicket
#

Can someone help me? I have setup everything for the python lib correctly, and I did auto post= True in the self.dblpy thing.... a few weeks ago, it was running fine and all, but I may have ran my beta bot on it, and due to that on top.gg it says my bot has 6 servers. Now, it dosent post at all and it’s not doing anything. It’s stuck at 6 servers can someone please help?

open surge
#

I am using this in nodejs alongside discord.js

const express = require('express')
const Topgg = require('@top#2386-gg/sdk')

const app = express() // Your express app

const webhook = new Topgg.Webhook('topggauth123') // add your top.gg webhook authorization (not bot token)

app.post('/dblwebhook', webhook.middleware(), (req, res) => {
  // req.vote is your vote object e.g
  console.log(req.vote.user) // 221221226561929217
}) // attach the middleware

app.listen(3000)
#

I run the test and nothing happens. Still a user voted and did nothing on the console

#

I still have a question:
Webhook URL, what is it?
IF my bot is running locally. I have used the public IP, the local IP, and nothing

plucky lance
#

You will have to setup an inbound rule for your firewall for the port you specified.

#

Additionally hosting at home requires to open the port in your router and forward it to the device your code is actually running on.

#

You will of course have to use your public IP address as webhook path.

#

Even if all is setup correctly your provider could still be the last instance which may filters your incoming packages you can't do anything about.

open surge
#

thanks I did the steps, and it remains the same.
Although I highly doubt the provider will help me.

#

It is still somewhat difficult to understand the help in English.

plucky lance
#

Make sure you even have a public IPv4 address

#

DSLite is a common routing method today which can result to may don’t have a public accessible IPv4

unique ember
#

!ping

short ridge
#

!ping

fading knoll
#

where can i get the api

#

mk i got it

dusky monolith
#

how do i get my token again?

#

go to edit then what?

rain heart
#

read pins

sullen nymph
#

Webhooks

dusky monolith
#
class TopGG(commands.Cog):

    def __init__(self, client):
        print("loaded")
        self.client = client
        self.token = token  # set this to your DBL token
        # Autopost will post your guild count every 30 minutes

    async def on_guild_post(self):
        print("Server count posted successfully")

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        with open('bank.json', 'r') as f:
            load = json.load(f)

        print(data)
        user = data['user']

        try:
            load[str(user)]
        except KeyError:
            return

        load[str(user)]["Balance"] += 750
        load[str(user)]["Votes"] += 1
        load[str(user)]["Crates"] += 2
        voter = self.client.get_user(user)

        await voter.send("Thank you for voting on Top.gg! You got **750![scopes_money](https://cdn.discordapp.com/emojis/824242696150450177.webp?size=128 "scopes_money")** and **2![scopes_crates](https://cdn.discordapp.com/emojis/824251883680956467.webp?size=128 "scopes_crates")**.")

Why didn't the on_dbl_vote event get triggered?

rain heart
#

have you added your webhook url? have you added the webhook port on your constructor that activates your webhook?

dusky monolith
#

i dont want a webhook i only want it to dm the user and give them the rewards

#

look, i never made a webhook

sullen nymph
#

hello yes

#

without webhook there's no on_dbl_x events

dusky monolith
#

ah

sullen nymph
#

because magic

dusky monolith
#

makes sense.

sullen nymph
#

The webhook handles incoming requests from top.gg so yeah

dusky monolith
#

so is it self.webhook = webhook_url?

#

i have to wait 12 hours to test again lmao

sullen nymph
#

Where is your DBLClient instance even

#

use the Test button with on_dbl_test

dusky monolith
#

wait there is???

#

i want to test votes and when someone votes it will increase their balance and stuff

sullen nymph
#

You can test requests and see if your code works

dusky monolith
#

ok fair enough

#
    def __init__(self, client):
        print("loaded")
        self.client = client
        self.token = token  # set this to your DBL token
        # Autopost will post your guild count every 30 minutes
        self.dblpy = dbl.DBLClient(self.client, self.token)

So like that

sullen nymph
#

Don't forget the webhook arguments

dusky monolith
#

lemme find that

dusky monolith
#

oh ty

#

@sullen nymph how can i fin the webhook port and webhook path?

sullen nymph
#

You see which port and route is available on your machine and use them

dusky monolith
#

eh I can't seem to really understand

sullen nymph
#

The general idea is that the dblpy webhook is a wrapper for an aiohttp webserver, where you need a port to run the webserver. On top of that, there are handlers for specific routes like /dbl, /, etc.

dusky monolith
#

so webhook_path = "/"?

#

and the port is my host port?

sullen nymph
#

Let's take for example a random URL
http://0.0.0.0:port/path
port is the port to run the webhook on
/path is the path to run the request handler on

sullen nymph
#

For my examples I specify 5000 or 3000

dusky monolith
#

alright

#
self.client, self.token, webhook_auth="nope", webhook_port=5000, webhook_path="/")

@sullen nymph so that would work?

sullen nymph
#

Yeah, seems good

dusky monolith
sullen nymph
dusky monolith
#
class TopGG(commands.Cog):

    def __init__(self, client):
        print("loaded")
        self.client = client
        self.token = token
        self.dblpy = dbl.DBLClient(
            self.client, self.token, webhook_auth="no", webhook_port=5000, webhook_path="/")

    async def on_guild_post(self):
        print("Server count posted successfully")

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        channel = self.client.get_channel(781596060438233150)

        with open('bank.json', 'r') as f:
            load = json.load(f)

        print(data)
        user = data['user']
        await channel.send(f"{user} has upvoted!")

        try:
            load[str(user)]
        except KeyError:
            return

        load[str(user)]["Balance"] += 750
        load[str(user)]["Votes"] += 1
        load[str(user)]["Crates"] += 2
        voter = self.client.get_user(user)

        await voter.send("Thank you for voting on Top.gg! You got **750![scopes_money](https://cdn.discordapp.com/emojis/824242696150450177.webp?size=128 "scopes_money")** and **2![scopes_crates](https://cdn.discordapp.com/emojis/824251883680956467.webp?size=128 "scopes_crates")**.")

@sullen nymph sorry for bothering you but, this still does not work bunnyupset

sullen nymph
#

Did you vote or use the Test button?

dusky monolith
#

voted

#

asked one of my friends to vote

#

i have the dbl voting bot and it sent that my friend voted

#

but MY bot didnt send anything

sullen nymph
#

I suggest using the Test button in Webhooks section along with on_dbl_test event to actually test the webhook

#

What URL did you enter on top.gg?

dusky monolith
#

its not a webhook :/

#

im not using a webhook

#

the bot gets a channel and sends there

sullen nymph
#

webhook_auth="no", webhook_port=5000, webhook_path="/"

#

Do you know what a webhook is?

dusky monolith
dusky monolith
#

a message sent to a specific channel with it's webhook url

#

isnt that what it is?

sullen nymph
#

... no

#

A webhook in web development is a method of augmenting or altering the behavior of a web page or web application with custom callbacks. These callbacks may be maintained, modified, and managed by third-party users and developers who may not necessarily be affiliated with the originating website or application. The term "webhook" was coined by Je...

dusky monolith
#

O

sullen nymph
#

Well, you are correct under the context of Discord webhooks, but not the programming definition

dusky monolith
#

webhook

#

hooking a web to smth

#

yeah yeah

sullen nymph
#

pretty much

#

Make sure the port 5000 is accessible and that you are entering a proper URL on top.gg

dusky monolith
#

what url does it require? the channel's webhook one?

sullen nymph
#

The URL to your machine where your webhook runs

dusky monolith
#

what machine...

#

my pc/host?

sullen nymph
#

Well, wherever you run the bot

dusky monolith
#

on a hosting service

#

so i need my host's port?

sullen nymph
#

Then yeah, http://host.ip.address.here:5000/

dusky monolith
#

i have the server address not the host's ip address

sullen nymph
#

yeah use that ig

dusky monolith
sullen nymph
#

errrrr

dusky monolith
#

or should i keep the port 5000?

dusky monolith
#

so is that correct?

rain heart
#

http

#

not https

dusky monolith
#

alr

#

so it should work now yeah?

rain heart
#

if your code is correct, yes

sullen nymph
#

What does your browser show when you open that URL yourself?

dusky monolith
sullen nymph
#

Are there any designated ports for you to use by the hosting company?

dusky monolith
#

but it says sent an invalid response

plucky lance
#

Did he even open the port on his device?

sullen nymph
#

It's not hosted locally

plucky lance
#

Doesn’t matter by default the firewall should block this inbound rule anyway

sullen nymph
plucky lance
#

Depending on the policy it drops any inbound rules or accepts all.
Instead of guessing he could just check the firewall settings. okeh

sullen nymph
#

Do you know what Sweplox is

plucky lance
#

That’s a question for me or him?

sullen nymph
#

You

plucky lance
#

Never ever heard of that.

sullen nymph
sullen nymph
dusky monolith
plucky lance
sullen nymph
#

Seems so

plucky lance
#

Ah alright which probably means he has no control about firewall rules or ports...

#

Oh I see they also offer VPS

#

Hmm... could probably still be the issue KEKW

restive otter
#

Anyone here

pseudo ether
#

hi

restive otter
#

How are you

pseudo ether
#

I am new here so can anyone help

restive otter
pseudo ether
#

and how will it be online all the time?

restive otter
pseudo ether
#

ok

barren kestrel
#

@plucky lance

#

I need a diff port

#

I dont think 19555

#

Is right

#

is that a good port

#

or

#

Ok so I did all the steps on port 80

#

and it works

#

but when I test it doesnt work

#

it says its open

#

yes i am

#

hosting locally

#
const Topgg = require('@top-gg/sdk')

const api = new Topgg.Api(config.toptoken)

const express = require('express')
const app = express() // Your express app
const webhook = new Topgg.Webhook(config.topggwebhookauth)
const dwebhook = stuff for discord webhook

app.post('/dblwebhook', webhook.middleware(), (req, res) => {
  dwebhook.send(`<@${req.vote.user}> has voted for News Agent on top.gg!`)
})
app.listen(80)
#

My code

#

@shut flume

#

yes

#

and is token

#

and my webhook

#

Oh tru

#

When I go to it

#

it says that

#

but it all seems fine

#

its

#

ip:80/dblwebhook

#

so how do If ix

#

fix

#

Ok what do I fill in?

#

what sthe step name

#

and data

#

which...

#

i dont get that

#

idk what to do this is what I dont udbnerstand. What am I supposed to post

#

i know nothing about that

#

and where is it in the docs

#

ty tho

#

Im there

#

do I put my id

barren kestrel
#

like what to put in request line and data

#

Thats all I need

#

I dont get what else your saying

#

ok

#

so to do that I need those 2 boxes

#

im using djs

#

ok

#

so how cna I fix that

#

the header thing

#

ok im doing

#

@shut flume It did nothing

#

Ok. I dont think its code as its from the js code from the docs

#

But im not recieving data

#

yes

little matrix
#

hlw?

#

I have seen my webhook working

#

perfect

#

but

#

For a few days.

#

when someone votes once.

#

It counts 10 votes for the guy...

#

1 vote = 10 times a webhook returns.

#

pls ping me. why

plucky lance
#

Sorry, I’m busy today, no time left@barren kestrel

golden tinsel
#

I keep getting this error when I try to do a post request:

at=error code=H14 desc="No web processes running" method=POST path="/dblwebhook" host=benbot-2ndv.herokuapp.com request_id=6c773c69-503a-4135-bf2c-14bba3e5021c fwd="60.16.666.180" dyno= connect= service= status=503 bytes= protocol=https

I am hosting with Heroku, Ill send the code in my next msg

#
from discord.ext import commands, tasks

import dbl
import libs.database as db

import os
#host on repl now?
KEY = os.getenv('TOPGG_TOKEN')
PORT = os.getenv('PORT')
print(PORT)
if KEY == None:
    from dotenv import load_dotenv
    load_dotenv()
    KEY = 'nopedopedo'
class TopGG(commands.Cog):
    """
    This example uses tasks provided by discord.ext to create a task that posts guild count to top.gg every 30 minutes.
    """

    def __init__(self, bot):
        self.bot = bot
        self.token = KEY  # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='ryertyertyrt', webhook_port=PORT)
        self.update_stats.start()

    def cog_unload(self):
        self.update_stats.cancel()

    @tasks.loop(minutes=30)
    async def update_stats(self):
        """This function runs every 30 minutes to automatically update your server count."""
        await self.bot.wait_until_ready()
        try:
            server_count = len(self.bot.guilds)
            await self.dblpy.post_guild_count(server_count)
            print('Posted server count ({})'.format(server_count))
        except Exception as e:
            print('Failed to post server count\n{}: {}'.format(type(e).__name__, e))


    @commands.Cog.listener()
    async def on_dbl_vote(self,data):
        print(data)
        print(data.isWeekend)
        print(data.bot)
        print(data.user)
        await db.query(
            f'''
                UPDATE users
                SET votecount = votecount + 1
                WHERE id = {data.user}
            ''')
    @commands.Cog.listener()
    async def on_dbl_test(self,data):
        print(data)
        
        


def setup(bot):
    bot.add_cog(TopGG(bot))

#

ping me and also... hellloooo?

#

ok I am getting off for a sec, dm me please

dull thicket
#

Can someone help me with the python version of the library

rain heart
#

just ask and wait for someone who could answer your question

sullen nymph
#

Use keys not attributes

#

As for your error, turn on your web dyno

wet sun
#

Why does my bot say N/A in the servers box?
How do I make it show the number of servers my bot is in?

rain heart
mystic estuary
#

Is there a way I can test the voting API with my dev bot with a different ID?

plucky lance
#

As long as it’s not approved, no

#

Since users can only vote for existing (approved) bots on the website

heavy owl
#

I am using discord.py's library and I want to use the on_dbl_vote and on_dbl_test events. They do not seem to activate when someone votes though

#

I've read in the docs that for it to work, you need webhook_port and some others. What do I put there though?
self.dblclient = dbl.DBLClient(self.bot, self.dbltoken, webhook_path="https://discord.com/api/webhooks/772783784935686146/mywebhook :)", webhook_auth="12345", webhook_port=5000)

#

I tried that

#

But it did not change anything. What do I need to put in the webhook_port, webhook_path and webhook_auth?

#

Please ping on answer

violet viper
#

Hey! How would I post a variable with all the servers the bot is in instead of using dbl.on("posted")?

rain heart
sly pine
#

Hello. I can't connect automatic grading notifications. why?

restive otter
#

!join

restive otter
#

it has nothing to do with discord webhook

restive otter
heavy owl
#

I don't have my own website where I could do it

#

^^ On top.gg what do I put in URL and Authorization? And then what do I put in the webhook_port, webhook_path and webhook_auth?

cyan rune
#

is this normal don't get an response on webhook test in the console?

#

JS/discord.js

heavy owl
#

Python

#

And the module dbl

#

My server's URL? What do you mean by your server

#

Well on that IP my website is

#

With server IP you mean the IP of my VPS hosting my bot right?

#

So all bots having vote reminders and such need to have that?

cyan rune
#

I have an webserver using express.

console.log('[EXPRESS] STARTING SERVER');
const express = require('express');
const app = express();
const Topgg = require('@top-gg/sdk');
const webhook = new Topgg.Webhook('18S2l7h07Id894.A1n6r03O62k55o4k8.eo1nds8iwaf78');

app.post('/dblwebhook', webhook.middleware(), (req, res) => {
    console.log(req.vote)
});

app.listen(25569, () => console.log('SERVER READY'));
heavy owl
#

Hmm okay. So what do I put here

#

How do I set up my webhook? lol

cyan rune
#

yes. i host my bot on an Root-Server

heavy owl
#

Oh so I actually need to like add something to my website?

#

Is that what I want? I use django

#

What do I want to do with them

#

Oh but isn't the voter data supposed to end up in my bot?

#

So I can do something with it

#

Not much

cyan rune
heavy owl
#

Also, could I do the webhook stuff on another webserver than the one hosting my website? Because then I can run it on a different port than my website. Then I could even run that one with JS which you know I guess

cyan rune
#

No

heavy owl
#

How would you do it

#

But how

#

I don't use JS. I just want that to work lol

#

I still don't understand what I need to do on my server

#

What do you mean by handling them?

#

sadge I am clueless

#

There is no guide for that. If I don't even know what do handle

rain heart
#

If you have no clue what handling means in regards of requests, you're most likely not ready to approach that yet. Come back to it when you have more knowledge

wet sun
#
elf.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)```
#

Hey, I was wondering if the values webhook_path and auth were the same ones you can find on the website of your bot under webhooks?

sullen nymph
#

The path is related to the URL

#

As for the auth, it's a password you create

wet sun
sullen nymph
#

Well, yes and no. You create the webhook with certain parameters and then specify them on the website

wet sun
#

Hm

wet sun
sullen nymph
wet sun
#

Right, but I need to create one correct

sullen nymph
#

Which part are you confused about?

wet sun
#

Or something

sullen nymph
#

Passing webhook args to DBLClient makes it create one for you

wet sun
#

Oh

#

Uh

#

I just tried it with the default code on the docs, with the info under webhooks

#

So I assumed I did it wrong

#

Wait no

#

thats completley wrong sorry

#

its another bot that does that

#

Ok starting over

#

I need to create a link and a password

sullen nymph
#

Well, it works, it's just suggested that you adjust the args to your needs

sullen nymph
restive otter
#

I'm created a new bot

sullen nymph
#

As for the password, it's just anything you enter

#

since that's what it is, a password that dblpy will use to confirm that requests are actually coming from top.gg

wet sun
#

So

#

Let me see if I understood this

#

I can enter anything as a password

#

That much I got

#

Then the webhook url is the only thing I'm failing to understand

#

I need to create a webhook for the site to send data to

sullen nymph
#

Do you know what a webhook is?

#

As in, what it does

wet sun
#

I believe so

#

Its acts as a middle man right?

sullen nymph
#

Mmm, basically yeah

wet sun
#

Yeah

#

I just need to understand how to use them

#

and in this case its the url

sullen nymph
wet sun
#

I think?

#

I just dont get what that does

sullen nymph
#

It's a URL for you to enter on top.gg in the Webhooks section on your bot's Edit page

wet sun
#

Does that work for anybody?

sullen nymph
#

In some cases where you have SSL you'd use HTTPS instead of HTTP, and sometimes a domain instead of an IP

#

but generally yeah that works for most people

wet sun
#

So i can copy and paste exactly that

#

and it would work

sullen nymph
#

Replace 0.0.0.0 with your external IP though

#

and replace the stuff with your webhook settings like port and path

wet sun
#

How do I know what each of those things are

sullen nymph
#

Port is 5000, path is /dblwebhook

#

As for IP, do you use a VPS or host locally?

wet sun
#

I host locally atm

sullen nymph
#

Then first make sure your port is open in firewall settings and forwarded to your machine in router settings

sullen nymph
#

Google can help you here

wet sun
sullen nymph
#

Dangerous in what terms?

wet sun
#

Outside attacks

#

Also, does this port have to be open under the specific device the bot is being hosted on?

sullen nymph
#

Top.gg doesn't expose your URL to anyone but you, so I don't see any significant reasons to be exactly worried

wet sun
#

hm alright..

sullen nymph
#

Whatever you set as webhook_port. In your case, yeah, it's 5000

wet sun
#

I see

#

and is that what I need to open in my pc?

sullen nymph
#

In firewall settings, yeah. Inbound requests to that port

wet sun
#

Alright

#

So my ip doesnt matter then?

sullen nymph
#

What do you mean? k3llyhmm

wet sun
#

you asked about my ip earlier

#

But I dont see how that comes into play rn

sullen nymph
#

Right now it doesn't. You will need it later when you enter the webhook URL on top.gg

wet sun
#

alright

wet sun
sullen nymph
#

Correct

wet sun
#

Alright

#

and for the port what does it apply to

#

TCP or UDP?

sullen nymph
#

TCP

wet sun
#

k

#

Alright I think I did it

#

What now? @sullen nymph

sullen nymph
#

Did you forward the port to your device in router settings too?

wet sun
#

Uh

#

No I dont think so

#

How do i do that

sullen nymph
#

Google your router model 👀

wet sun
sullen nymph
#

Can't find much on that specific model

wet sun
#

Like

#

I dont have access to its account and stuff

sullen nymph
#

Oh, how come?

wet sun
#

I don't pay for it lol

#

Its under my residence's wifi

sullen nymph
#

Oh

wet sun
#

Yeah..

#

So....

#

Virtual host now..?XD

sullen nymph
#

I guess so

chilly spire
#

Could we use the on_dbl_vote function without a webhook?

rain heart
#

no

chilly spire
#

or is that not possible

#

damn

#

looks like I have to find a workaround

chilly spire
#

So how would I set up a webhook?

#

anyone?

austere swallow
#

there should be a webhook example

chilly spire
#

So, I need a webhook on my top.gg page for this to work, right?

#
webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000```
austere swallow
#

you will need to make a webhook server yes

rancid lotus
austere swallow
#

if you are using a VPS/server, open the port for the webhook port as stated, then put the url (http://<your-vps-ip>:<webhook-port/<webhook_path>) into the webhook area on top.gg

#

and test it

chilly spire
#

yeah that's the part I'm worried about
I have no clue how to set one up

austere swallow
#

are you running it on a VPS/server

chilly spire
#

I have a raspberry pi that I'm hosting my bot

austere swallow
#

ah at home, I see

#

then you will need to configure port forwarding to forward the port from your router to the rpi

#

then the IP will be your public ip of your router/internet

#

if you are using a dynamic IP provider, it is recommended to get a DDNS service to keep track of the current IP

chilly spire
#

dang
Alright thanks

austere swallow
#

np!

hazy tangle
#

Please Owo Cash

rain heart
#

-api

abstract mothBOT
#

This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.

If you need help with development about your bot or development in general, feel free to use #development.

glass cloak
#

is there a way to automatically detect server votes similar to bot votes with on_dbl_vote

rain heart
glass cloak
#

hmm, I'll look into it, ty

hidden brook
#

how do i approve it

faint knot
#

My bot is in 100+ servers but on website page it shows N/A??

#

Okay thanks

faint knot
#

Authentication is performed with the Authorization HTTP header as such

#

Whhat this means?

reef kiln
faint knot
#

I mean, where to put the Authorization token?

#

Where this code goes?

rain heart
#

That's your header

#

Read the pins

faint knot
#

Header of website page!!

#

Oh ok gotcha,

rain heart
#

Not of the website, header of your request

faint knot
#

U mean where we paste the auto-post code in main.js,??

#

There's no explanation about it in brief!!

cold root
#

how do I set up webhook

#

?

plucky lance
plucky lance
#

Why do think there’s a driving school instead of let anyone learn by doing?
Why do you think most jobs require to study?

cold root
#

My friend gave me this:

cold root
#
const DBL = require('dblapi.js');
const dbl = new DBL(apiToken, { webhookPort: 9008, webhookAuth: 'BTSsuckslikewtf' });// in webhookport: 9008, replace the "9008" with your host's port. 

dbl.webhook.on('vote', (vote) => {
console.log(`${vote.user} has voted me!`)
const webhook = new Discord.WebhookClient("ID","token")//replaces with ur webhook information
 webhook.send(`<@${vote.user}> (\`${vote.user}\`) has voted me!`) 
});

dbl.webhook.on('ready', hook => {
 console.log(`Webhook up and running at http://${hook.hostname}:${hook.port}${hook.path}`);
});```
plucky lance
#

Yeah because it requires to have some knowledge about these things.
If you wanna do HTTP requests aka. cURL requests then it makes sense to learn about what it is, what methods are, what a header is etc.

These step by step guidelines you’re speaking about is nothing else than copying code without any kind of understanding and wonder why it doesn’t work after.

cold root
#

also, stupid qustion, how do u know host port?

plucky lance
# faint knot That's rude 👎

Yeah the truth can be rude.
People are providing help in here every day but it always require to know the basics of what you’re doing since nobody will write the code for you.

plucky lance
cold root
#

its 9008?

faint knot
#

You write 2 para of lecture, if you've stated how to do it.. it would be helpful. But it's okay keep it up.🙂

cold root
#

How do I know if my is 9008?

plucky lance
#

Or do you speak about the source port? Or destination port?

cold root
#

uhhh

faint knot
#

Thanks for help!

cold root
#

idk

#

what does it have to be?

plucky lance
#

You’re defining the port your webhook will listen to. You have to open that up in your firewall.

#

INBOUND TCP your port number

plucky lance
#

Where do you host the webhook service?

#

At home, on a server etc.?

cold root
#

home?

plucky lance
#

OS?

#

Question mark... what?

#

At home also requires to forward the port in your router to the actual device the code is running on.

#

If it’s on Windows then, yes you have an active firewall.

balmy island
#

Any idea why this could be happening ?
It's a loop which is supposed to check the users reacted to a specific message and check if they have voted, if not it sends a reminder

My code:

    @tasks.loop(hours = 1)
    async def reminder(self):
        await self.bot.wait_until_ready()
 
        channel = self.bot.get_channel(710341374188453898)
        message = channel.fetch_message(808091364196876288)
        reaction = message.reactions[0]
        print(reaction.users())
        users = await reaction.users().flatten()
        print(users)
        embed = discord.Embed(title = "Vote Reminder", description = "Thanks for voting I really apprreciate this <3\n__**[Click here!](https://top.gg/bot/747965125599821914)**__", colour = discord.Colour.dark_red())
        for user in users:
            voted = await self.dblpy.get_user_vote(int(user.id))
            if voted == False:
                await user.send(embed = embed)```
plucky lance
#

It the library you’re using outdated?

balmy island
#

no i don't think so

plucky lance
#

Well invalid HTTP method is a weird error if you didn’t change the library.
It doesn’t follow there actual method which is needed for the request.
For example GET or POST

balmy island
#

what should i check ?

plucky lance
#

In the first place check which version that package is and if it’s up to date and when its last update was.

#

I can’t remember if the methods for requests to the topgg API have ever changed.

#

If the issue is a py related issue I can’t help u with unfortunately.
I don’t speak snakish notlikenoot

loud jewel
#

Where can i find my Ip adress

gray stratus
#

How do I track the votes for a server (not a bot) using the api

loud jewel
gray stratus
loud jewel
#

u can repurpose it

restive otter
restive otter
loud jewel
#

Where do i find my webhook port>

#

actually nvm time to upgrade to the new 1

cyan wyvern
#

hi how to setup dblwebhook in python

brittle spoke
restive otter
#

y this dont work

const express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express()
const webhook = new Topgg.Webhook('...')
app.post('/web', webhook.middleware(), (req, res) => {
  console.log(req.vote.user)
  bot.channels.cache.get("795394146143043584").send(`<@${req.vote.user}> has voted for me on top.gg!`)
});

app.listen(1251)```
brittle spoke
#

did you try the 80 that the docs provide...

rain heart
#

80 isn't something you should use for the webhooks

restive otter
junior patio
#

sa

rain heart
#

-api

abstract mothBOT
#

This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.

If you need help with development about your bot or development in general, feel free to use #development.

restive otter
rain heart
#

you're trying to access an endpoint with a token that can't access it

restive otter
rain heart
#

what are you trying to do exactly

restive otter
rain heart
#

are you checking on your own bot?

#

and not another?

restive otter
rain heart
#

post your code here and wait for someone who can help

restive otter
#

same bot btw

#

just another index.js

dull thicket
#

My bot's server count isn't updating as it should. I have the code 100% set up correctly and it has worked B4, but now for somereason it's not workibg

restive otter
#

for some reason, my projects on replit cannot access it but if i host the bot and the api locally, it works

dull thicket
#

No

#

I have my own host

#

It has worked B4 like I said

#

but all of a sudden nope

untold vortex
#

Where can I get a bot token?

rain heart
#

see pins

untold vortex
#

sorry!

fast meteor
#

whats the api url for posting server count?

#

the python library isnt working for me so im going to do it manually

rain heart
#

mentioned on the docs

fast meteor
#

where

#

i cant find

#

wait

#

no

#

sorry

#

can someone tell me if i am doing this right? this is python

headers = {"Authorization": "secret"}
data = {"number": len(bot.guilds)}
async with aiohttp.ClientSession() as session:
  await session.post('https://top.gg/api/bots/671801771345182782/stats', data=data, headers=headers)
#

its not updating the server count on my bots page

rain heart
#

wrong data you're sending

#

re-read the docs

fast meteor
#

oh

#

oop

#

lol

#

my bad

#

thx

sullen nymph
#

json= not data=

fast meteor
#

oh

#

ok

#

also

sullen nymph
#

Yes

fast meteor
#

do i type the ?

sullen nymph
#

No

fast meteor
#

ok thx

#

thx that worked

restive otter
#

got that fixed, some lag from top.gg apparently, those that recieve the 403 error should be fine now

uncut lintel
#

Is it possible to have the server post code work on v11? If so could someone send the code or help...
Thx :)

willow spindle
#

you should use v12

uncut lintel
#

so much to change ._.

#

too lazy

#

thx though

tired pollen
#

is the isWeekend field of the bot webhook schema always true? other than today being saturday, this entire week the isWeekend field was true.

restive otter
#

whats this dbl api?

rain heart
#

-api

abstract mothBOT
#

This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.

If you need help with development about your bot or development in general, feel free to use #development.

rain heart
#

our api

restive otter
#

is dbl api yours?

rain heart
rain heart
restive otter
#

how may iget that?

rain heart
#

read pins

restive otter
#

my mind is in pain 😅

tired pollen
#

ty

restive otter
#

and whats the ame api

rain heart
restive otter
#

k thx

slender quail
#

{"error":"Unauthorized"}

#

why do i get this

rain heart
#

No token given or token invalid

slender quail
#

whats wrong?

rain heart
#

remove the :

slender quail
#

ok

rain heart
#

https://top.gg/api/bots/805537268349665290/check?userId=503603261471719444

#

this

slender quail
#

still same error

#

@rain heart i get the same error

#

┬─┬ ノ( ゜-゜ノ)

plucky lance
#

Did you add your API token to the header?

#

damn annoying embeds

rain heart
#

ikr stinky embeds

#

and yeah authorization missing

plucky lance
#

Can’t they be turned off for specific roles?

#

Maybe worth a community vote to disable embeds for anything < mods

rain heart
#

some users use screenshot urls for demonstrating things, which would make it not worth it

plucky lance
#

Oh yeah forgot about these

#

@slender quail
You got it fixed?

restive otter
#

-help

rain heart
#

-api

abstract mothBOT
#

This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.

If you need help with development about your bot or development in general, feel free to use #development.

plucky lance
slender quail
plucky lance
#

From the site by editing your bot.

twin whale
#

Is showing the amount of servers your bot is in the api or is that something to do with the amount of servers it’s in

plucky lance
#

Nope you’re basically reporting the current server count to topgg

twin whale
#

Oh because some bots have the amount of servers on how do I do it?

plucky lance
#

It’s not being reported automatically.
You have to do it manually just by sending a cURL request (HTTP request) to topgg or a library which does the job automatically.

#

Both being explained in the docs pinned at this channel.

twin whale
#

Ok

#

I’ll look at them when I get to my pc

#

Thanks!

plucky lance
#

👍

slender quail
#

i get: error code: 1015

#

@plucky lance

rain heart
#

doesn't help much

slender quail
#

whats error code 1015

rain heart
#

cloudflare stuff

#

ratelimit i think

slender quail
#

to fix it

rain heart
#

wait 1 hour, if nothing happens, full 24 hours

#

you made too many requests

slender quail
#

i was testing

#

for the first ever time

#

OH I KNOW WHY

#

I DID alwaysReply for messages, and it requests every time

rain heart
#

there's the issue then

slender quail
#

shit

slender quail
rain heart
#

an hour up to 24 hours

cold root
#

how do I setup the api in bot?

#

I got this from friend

#
const dbl = new DBL(apiToken, { webhookPort: 9008, webhookAuth: 'BTSsucksLikeWtf' });// in webhookport: 9008, replace the "9008" with your host's port. in "AnyPassword" u can choose a random password.

dbl.webhook.on('vote', (vote) => {
console.log(`${vote.user} has voted me!`)
const webhook = new Discord.WebhookClient("id","token")//replaces with ur webhook information
 webhook.send(`<@${vote.user}> (\`${vote.user}\`) has voted me!`) 
});

dbl.webhook.on('ready', hook => {
 console.log(`Webhook up and running at http://${hook.hostname}:${hook.port}${hook.path}`);
});

#

but...

#

it doesnt respond.

jaunty siren
#

Where are you from?

untold vortex
#

Will there ever be a member count endpoint?

rain heart
#

probably not

untold vortex
#

Damn

#

Would be cool if we had a "custom" field

steady delta
#
TypeError: object Lock can't be used in 'await' expression 
restive otter
#

What does genious api works for?

livid blade
#

how do you add @abstract moth and @wild lantern to servers ?

rain heart
#

-api

abstract mothBOT
#

This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.

If you need help with development about your bot or development in general, feel free to use #development.

livid blade
#

k

real grail
sullen nymph
restive otter
#

ew

compact crow
#

@everyone

restive otter
#

i seriously need a help in getting a dbl api 😦

restive otter
#

-api

#

-api

restive otter
#

why this dont work

const express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express()
const webhook = new Topgg.Webhook('...')
app.post('/web', webhook.middleware(), (req, res) => {
  console.log(req.vote.user)
  bot.channels.cache.get("795394146143043584").send(`<@${req.vote.user}> has voted for me on top.gg!`)
});

app.listen(1251)```
plucky lance
#

Port 1251 opened up?

#

You need to add a new firewall rule.
INBOUND TCP 1251

#

On the device the code is running.

#

Running at home makes it even more difficult.

steady delta
sullen nymph
#

You'll have to wait until I actually get everything done and release it

restive otter
brittle spoke
dull thicket
#

Can someone help me?

#
@tasks.loop(seconds=1800)
async def server_count_post():
    headers = {"Authorization": "TOKEN"}
    data = {"server_count": len(client.guilds)}
    async with aiohttp.ClientSession() as session:
        await session.post('https://top.gg/api/bots/762361400903204925/stats', json=data, headers=headers)
        await session.close()```
#

what is wrong with this?

sullen nymph
#

No need to close the session since the context manager does that automatically

#

That looks alright. Can you print the response?

dull thicket
sullen nymph
#

Assign the .post to a variable

dull thicket
#

ye

#

I made it response

#

do I print that?

sullen nymph
#

Then you can print response.status

dull thicket
sullen nymph
#

That's interesting

dull thicket
#

so its finally not 6 anymore

sullen nymph
#

🤣 as long as it works

dull thicket
#

Lmao

#

what happened to the lib

plucky lance
#

Make sure to add the content type to the header

dull thicket
plucky lance
#

Same way you added your token to the header lol

sullen nymph
#

aiohttp should do that automatically

plucky lance
#

It chooses json automatically

#

?

sullen nymph
#

If you pass the json parameter, it should set Content-Type accordingly

plucky lance
#

Hmm ... 400 as response is weird

left mesa
#
const Command = require("../../base/Command.js");
const { MessageEmbed } = require('discord.js');
const DBL = require('dblapi.js');
const Resolvers = require("../../helpers/resolvers");

class DJ extends Command {

    constructor (client) {
        super(client, {
            name: "dj",
            dirname: __dirname,
            enabled: true,
            guildOnly: true,
            aliases: [  ],
            memberPermissions: [ "MANAGE_GUILD" ],
            botPermissions: [ "SEND_MESSAGES", "EMBED_LINKS" ],
            nsfw: false,
            ownerOnly: false,
            cooldown: 5000
        });
    }

    async run (message, args, data) {

        const dbl = new DBL(this.client.config.apiKeys.dbl);
        let voted = dbl.hasvoted(message.author.id);
        if(!voted) {
            const vote = new MessageEmbed()
            .setTitle("Error!")
            .setFooter(this.client.config.embed.footer)
            .setColor("RED")
            .setTimestamp()
            .setDescription(`${this.client.customEmojis.error} you must vote me to use this command`)
            return message.channel.send(vote);
        }
        
    }

}

module.exports = DJ;```getting error```TypeError: dbl.hasvoted is not a function```
rain heart
#

hasVoted, not hasvoted

left mesa
raven pewter
#

how i can add server count thing on top.gg bot page?

rain heart
raven pewter
#

but i can't understand

#

how to add

rain heart
#

@sullen nymph now you can

raven pewter
#

can you send the code i should use it on my main.js?

sullen nymph
#

What's your library?

untold vortex
#

What does the shard_count endpoint even do?

raven pewter
#

d.js

#

can someone send example code?

sullen nymph
untold vortex
#

I don’t see any shard count on the page :/

sullen nymph
untold vortex
#

Like, the stats post endpoint, it has an option to post shard count, what does it even do?

sullen nymph
#

You can tell top.gg how many shards your bot has with that key in the request body

untold vortex
#

Yes, but what does that data go to? What does it do and what is the purpose?

#

I just don’t see a “shards” count on the page

#

I see server count but no shards

rain heart
#

that's in the setStats method

#

read the docs

untold vortex
#

I have...

sullen nymph
#

Similar to server count, it should be shown on the bot page

untold vortex
#

Am I doing something wrong here then?

#

I’m posting both, but it’s not showing?

#

Is there another key I need to send?

sullen nymph
#

Worked just fine with shard_count and server_count set

#

Try to press Refresh Data

untold vortex
#

Nope

sullen nymph
#

🤔

untold vortex
#

Are you using JS?

sullen nymph
#

Python

untold vortex
#

Are you stringifying the keys?

sullen nymph
#

Keys are strings and values are integers

untold vortex
#
{"error":"Unexpected token o in JSON at position 1"}```
#

the hell

sullen nymph
#

Seems like a broken JSON being sent

untold vortex
#

i also get json {} as a response with this:

sullen nymph
#

That means the request was successful

#

Suggest you print the status code along with the response text imo

untold vortex
#

uhhh

#

Nothing is being returned

#

its just json {}

#

wait

sullen nymph
#

The request was successful then

untold vortex
#

I get a 200 "ok" status

sullen nymph
#

Yup, then it's all good

untold vortex
#

then i wonder why the shards arnt posting

#

my guild works, not the shards though

sullen nymph
#

Send a GET request to the link and see if the API actually set the shard count

#

aka you can just open it in browser while logged in

untold vortex
#

null

sullen nymph
#

a?

untold vortex
#

Sick

#

I got it

raven pewter
#

how ı can get my webhook lınk?

untold vortex
#

I needed shard_id

sullen nymph
#

Interesting

#

I didn't set shard_id in my case

sullen nymph
#

port is the port you run the webserver on, path is, well, a route/path you set to handle top.gg requests

raven pewter
#

do glitch links work?

sullen nymph
#

do you use the top.gg sdk package for your webhook?