#topgg-api

1 messages · Page 154 of 1

jaunty plank
desert fractal
#

umm???

desert fractal
jaunty plank
#

looks like your trying to use an api endpoint, not webhooks, but the same is true for using the api too. yes

desert fractal
#

xD

jaunty plank
river verge
#

Thanks Woo! It worked.

#

sorry for all that trouble btw

spice helm
#

Sorry, quick question, what header does the top.gg webhook use? (both webhook and server)

desert fractal
#

what need to go there?

#

and here

jaunty plank
jaunty plank
desert fractal
jaunty plank
#

you just type it, its like a password.
as long as its the same between your code, and the site its valid.

spice helm
#

Sorry but i already looked there, i don't see it

desert fractal
jaunty plank
#

discord webhooks and top.gg webhooks are not compatible with each other.

desert fractal
#

then witch webhook

#

i dont get it

spice helm
night ingot
#

It's an actual webhook, you need a webhook server to listen for it

spice helm
#

Oh sugar, i forgot i already sent that to you lol

night ingot
#

which you can set up using the libraries

jaunty plank
#

everything else is in the body.

spice helm
#

Sorry, i meant content header, is it application/json?

#

I just ran it on a webhook site, it is

modern lagoon
#

can anyone help me make vote logs?

spice helm
modern lagoon
modern lagoon
#

why not pin that link lol its super usefull

spice helm
#

When ever you run the standard flask server, it warns you that it's not tested for security issues and is only designed for testing, they mention this in the flask docs aswell

spice helm
modern lagoon
#

lol

spice helm
#

Research how to deploy it onto your webserver of choice

modern lagoon
#

ohk

#

ty

sullen nymph
spice helm
#

I don't think it's worth it, if a mod benefits from it, they're more than welcome to pin it but i don't think anyone should really go out of their way

brave gyro
#

hello

#

can someone help me with the webhook

jaunty plank
#

i might be able to, do you have a specific question?

brave gyro
#

yes

#

i made a webhook and put it into the box and saved when i click test nothing happens in the channel

jaunty plank
#

top.gg webhooks are not compatible with discord webhooks, you need to make your own webhook.

brave gyro
#

how can i do that?

jaunty plank
brave gyro
#

ty

spice helm
#

Can you get upvotes for the server without a bot?

rain heart
#

servers doesn't have an api

#

only by manually tracking it yourself using webhooks

spice helm
#

Oh right, thank you

pliant cobalt
#

Hi, i'm doing a Bot for a school project and trying to include a vote command, but im seeing people complaining about the approval delay, i'll like to know if i can do something on the code to get a test vote link, or i'll have to exclude the vote function for the presentation of the project

plucky lance
#

You can setup your webhook service and use the test function on the topgg website

#

I’m not aware of delays but it they’re caused by topgg there’s nothing you can do about other than waiting until it may be fixed

night ingot
#

There is no approval "delay". It's just the time it takes due to the amount of bots being submitted each day

plucky lance
#

Should wear glasses probably

pliant cobalt
#

Sorry, english isnt my main language, im aware the time it takes due to a lot of bots being submitted, i meant that saying delay, and thanks for the responses

calm mesa
#

How i create a webhook that is tiggered by someone vote?

plucky lance
#

Take a look at the pinned docs.
The contain examples how to use the API with or without libraries.

#

Keep in mind incoming connections from topgg to your webhook service do require to open your specified port in the firewall

stable magnet
#

so im self hosting my bot how do I setup my webhook settings page

#

like what ip should i add to port forward

willow spindle
#

your public ip:port/webhookpath

stable magnet
#

ok and do I need to port forward

plucky lance
#

Keep in mind incoming connections from topgg to your webhook service do require to open your specified port in the firewall

#

Yes you do

#

Port forwarding to the right device and setting up the firewall

stable magnet
#

where r u getting that info from

plucky lance
#

Hmm?

stable magnet
#

Keep in mind incoming connections from topgg to your webhook service do require to open your specified port in the firewall
that

plucky lance
#

Just scroll up a little bit

stable magnet
#

oh facepalm

plucky lance
plucky lance
winter tusk
#

Can u say how to ignore that?

willow spindle
#

compare error codes?

night ingot
#

You can just catch the error and ignore it with pass. Not related to the API though so move to #development if you have any further questions

modern lagoon
#

wht is a webhook path?

dire cairn
#

@modern lagoon it is like https://someaddress.com/path

#

The endpoint which will receive data

modern lagoon
dire cairn
#

What do you mean where you can get?

#

Purchase a vps or something

#

Make sure the pot is opened

#

Do it something like

#

22.343.2.42:2334/path

#

That will not work it's just a example

ripe wharf
#

how do i authorize it

dire cairn
#

Maybe because of //

#

Oh you need a token for it

ripe wharf
#

i known but how do i put it in the url

sullen nymph
#

Send an Authorization header

restive otter
#

How Do I Get A Username While User Is Voting On My Top.gg Server

#

What Should I Use vote.username or what

brittle spoke
#

try vote.user.username

restive otter
#

Ok

brittle spoke
#

cool

restive otter
#

Bro It Is Not Working

#

Undefined

brittle spoke
brittle spoke
restive otter
#

Not Working

#

This Way Also

brittle spoke
#

hmm

restive otter
#

Hmm

restive otter
#

Oo

#

Ok

dire cairn
#

It returns a snowflake

#

Not a user object

#

So fetch the user then get it

pseudo sierra
#

Hi, i just tried this webhook code ```py
from discord import *
from discord.ext import commands, tasks
from discord.utils import get
from datetime import datetime, timedelta
import random
import asyncio
import pyrebase
import os
import topgg
CONFIG = {
"secret config"

}
firebase = pyrebase.initialize_app(CONFIG)
db = firebase.database()
intents = Intents.all()
prefix = "."
client = commands.Bot(command_prefix=prefix, intents=intents)
random_color = 0x651DFF

#dbl_token = 'Top.gg token' # set this to your bot's Top.gg token

client.topgg_webhook = topgg.WebhookManager(client).dsl_webhook("/dblwebhook", "yamizero31")

client.loop.run_until_complete(client.topgg_webhook.run(5000))

@client.event
async def on_dsl_vote(data):
if data["type"] == "test":
return client.dispatch('dbl_test', data)

print(f"Received a vote:\n{data}")

@client.event
async def on_dsl_test(data):

print(f"Received a test vote:\n{data}")``` so i can get data when someone votes the server

it's not working and idk why

restive otter
#

Could someone give me a sample guild stats autoposter code for my bot? (JavaScript)
I have no errors in my logs but nothing is displayed
and the same for the top.gg webhook

sullen nymph
pseudo sierra
#

approved bot? in topgg or in discord in general ?

#

@sullen nymph^

#

it's a custom bot so i don't think it will get approved in both of them

sullen nymph
#

Why do you want a top.gg webhook if you're not gonna use it for top.gg is my questi- okay I admit I'm dumb

pseudo sierra
#

hmm? it's for the server

sullen nymph
#
@client.event
async def on_dsl_vote(data):
    if data["type"] == "test":
        return client.dispatch('dbl_test', data)

why are you dispatching dbl_test and not dsl_test instead?

pseudo sierra
#

the webhook is for the server

#

oh

sullen nymph
#

Yeah that clicked in my head halfway through my message

pseudo sierra
#

no worries

#

@sullen nymph so i made a friend who has his ports open test it but it didn't work with voting or testing webhook

#

i wonder if this will work

from discord.ext import commands

import dbl


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, bot):
        self.bot = bot
        self.token = 'dbl_token'  # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        """An event that is called whenever someone votes for the bot on top.gg."""
        print("Received an upvote:", "\n", data, sep="")

    @commands.Cog.listener()
    async def on_dbl_test(self, data):
        """An event that is called whenever someone tests the webhook system for your bot on top.gg."""
        print("Received a test upvote:", "\n", data, sep="")


def setup(bot):
    bot.add_cog(TopGG(bot))```
sullen nymph
#

What happens when you slap the URL in your browser and open it?

pseudo sierra
#

hmm it's not my IP so lemme tell them to do it

pseudo sierra
sullen nymph
#

Port isn't open then 👀

restive otter
#

Could someone give me a sample guild stats autoposter code for my bot? (JavaScript)
and the same for the top.gg webhook plz zoomeyes

sullen nymph
restive otter
#

but it doesn't work for me

sullen nymph
#

Show your code and explain how it doesn't work

restive otter
#

in the logs I have no error or operating message

#

it's been 1 hour and nothing changes

sullen nymph
#

Well no shit

#

Not running the client, letting it initiate the user object

restive otter
#

that is to say ?

sullen nymph
#

That is to say that you're not running the client object

restive otter
#

Could you send me the line to run it?

pseudo sierra
#

@sullen nymph we tried to enable port forward in the router but it's still closed

pseudo sierra
#

nvm i tried it with a hosting website and it worked

sullen nymph
restive otter
#

I want to put a webhook when a user votes my bot. But when I click on "Send test" via the site, its not working ...
For the webhook URL I put the given URL on my discord server (webhook management)

And for authorization, I put the code after the last "/" on the webhook link: https://discord.com/api/webhooks/identifer/authorization_here

#

I've been told I can't use discord webhooks, why?

sullen nymph
#

Because Discord could block top.gg's IP addresses for sending too many webhook requests

night ingot
#

Discord webhooks aren't compatible with Top.gg's webhooks. You need an actual webhook server to listen for votes

sullen nymph
#

Plus it encourages you to do stuff manually instead of expecting support for everything

restive otter
#

type IFTTT ?

sullen nymph
#

You don't even need IFTTT for this tbh

restive otter
#

How should I do it? Is there a tutorial?

sullen nymph
#

You can host a webserver on your machine

willow sphinx
#

someone should make a one click serverless deployment that forwards topgg webhooks to discord

#

on aws lambda

sullen nymph
#

Repl KEKW

willow sphinx
#

it's free for the first 1 million votes a month

restive otter
wanton beacon
#

i've worked with api in the past but i can't understand these can anyone help me?

dire cairn
#

Bees?

wanton beacon
acoustic tree
#

what i need to write into repl.it because I am sure I don t need all this lines

sullen nymph
#

Just install the topggpy package

acoustic tree
#

because I don t using visual studio code so I don t need to istall pip

#

or?

sullen nymph
#

Enter topggpy here

acoustic tree
#

thx my boi

restive otter
#

how do i get my bots stats with api using curl

#

i get this

lunar vessel
#

So i'm a little confused on this api here.

#

I have used it at all granted - but can the bots endpoint grab info for any bot?

#

Or just bots i've submitted?

rain heart
#

you can only interact with the api when you have an approved bot on top.gg

lunar vessel
#

That's fine, but when you do have an approved bot, does that /bots endpoint allow querying of all top.gg submitted bots, or just bots i myself have submitted?

rain heart
#

first 500 afaik

lunar vessel
#

Gotcha

rain heart
#

and depending on limit/offset/query etc

#

more on the docs

hushed reef
#

curl is an outdated method of pulling information

restive otter
#

i am unable to authorize myself for the api idk why

#

is this the correct way to authorize?

loud token
#

just put the blurred value, don't put the {"Authorization": part

restive otter
#

o

misty meteor
#

I'm not receiving the POST request on webhook when I hit the test button?

plucky lance
#

If you want to set one, it’s not necessary needed

misty meteor
#

Oh

#

Ok

#

Nope

#

Still didn't receive the request

plucky lance
#

Make sure to open your specific webhook service port in the firewall

solid crest
#

how does the voting of a server exactly work, does anyone have an example of it?

dull plaza
#

How do I get who voted for my bot?

solid crest
#

it's literally in the docs

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

const api = new Topgg.Api(process.env.TOPTOKEN)

setInterval(() => {
  api.postStats({
    serverCount: client.guilds.cache.size,
  })
}, 1800000)

const webhook = new Topgg.Webhook(process.env.TOPGGAUTH)

app.post('/diamond_bot_wh', webhook.listener(vote => {
 
  console.log(`Someone just voted ( ${vote.user} )`)
  vote.user.send("**Thank You** so much for voting **DiamOnd_bOt [ db! ]** .\nI really do appreciate it!")
  
}))

app.listen(5000)

I did the things required in the webhook section of top.gg and saved it also.
No errors , no nothing.

#

And it doesn’t show the number of guild in top.gg

#

and also did
const app = express();
Installed the package express and @top-gg/sdk

late badge
#

Hello

jaunty plank
#

@tawny smelt whats your code look like(please include the line you log req.body)

tawny smelt
#
const express = require('express');
const app = express();
app.use(express.static('public'));

app.get('/', (req, res) => {
  res.send('Online')
})

const voteWeb = new Discord.WebhookClient('841765098121199686', process.env.voteWebTOKEN)

app.post('/new/vote', (req, res) => {
  console.clear()
  console.log('new vote')
  console.log(req.body)
  /*if (req.header('Authorization') == process.env.voteTOKEN) {
    res.send('Good!')
    var user = req.body.user
    const voteWebEmbed = new Discord.MessageEmbed()
      .setTitle('Aha another vote!')
      .setDescription(`<@!${user}> has voted!\nBe like them and vote [here](https://top.gg/servers/768927312178577449)`)

    voteWeb.send(voteWebEmbed)
  } else {
    res.send('YOU THOUGHT')
  }*/
})

app.listen(3000, () => console.log('Running'));

this code was used when i realized voting was broken

#

this is what console returns when i press test webhook ```txt
new vote
undefined

#

@jaunty plank?

jaunty plank
#

not sure why it wouldnt work here

tawny smelt
#

i think something is wrong on top.gg's end

jaunty plank
#

if it was, there would be others having this issue.

sullen nymph
#

Yee yee ass undefined

#

Are you sure that that's how the body is received

jaunty plank
#

oop, are you using a parser for json?

restive otter
#

They're not

restive otter
#

how to set up dbl server webhooks?

mortal crow
#

how to set up dbl server webhooks?

#

it's literally in the docs

restive otter
#

k

river hull
sullen nymph
spice helm
#

Oh they left

topaz snow
#

me too

sullen nymph
#

@restive otter Do you think topggpy should store IDs as int?

restive otter
#

If you'd like to make some models, I guess

sullen nymph
#

Yeah, thinking about them models

restive otter
#

I can see they'll subclass DataDict dboatsMmlol

sullen nymph
#

Yup KEKW

#

I wasn't being stubborn for nothing

restive otter
#

Hey. Is there any examples for python with top.gg api

#

so when a user votes my bot it logs to console

sullen nymph
restive otter
#

Ok Thanks Ill Be Able to work with that, Thanks 👍

#

How do i get my dbl token?

sullen nymph
#

Do you need it?

restive otter
#

Yeah for the apis

restive otter
#

Hey when i run the script it gives this error:

Traceback (most recent call last):
  File "C:\Users\vxi\Desktop\Top.gg Noti System\main.py", line 7, in <module>
    bot.topggpy = topgg.DBLClient(bot, dbl_token)
NameError: name 'bot' is not defined```
#

Should've added more comments in the example blobweary, but isn't that pretty self-explanatory?

#

bot is supposed to be any object that subclasses discord.Client

sullen nymph
restive otter
#

lmao

#

just realized that I haven't deleted the dbl_token in the webhook example, it's pretty much redundant mmulu

sullen nymph
sullen nymph
#

@restive otter on to add all of these as fields!

hushed reef
#

python has structs?

restive otter
#

nah mmulu

sullen nymph
#

That's just typing annotations

#

Oh you know what

#

I cba to do all this manually

hushed reef
#

a data class sorry

#

never knew python had them, i haven't written anything yet in the language requiring me to use one

sullen nymph
#

Oh wait

#

I forgot about the dataclasses module

restive otter
#

Are you gonna decorate DataDict then?

sullen nymph
#

What do I decorate here? KEKW

restive otter
#

Not sure if it'll override dict methods

#

the class?

sullen nymph
#

Well, how will type hinting behave though?

restive otter
sullen nymph
#

Superclass methods take priority?

restive otter
#

But, won't it duplicate the data? Cuz it'll have them as attributes while we also have it as key-value pairs

sullen nymph
#

Duplicate...

#

Maybe?

#

Will I be able to modify specific fields for typehinting with dataclass though?

restive otter
#

Modify as in type casting them?

sullen nymph
#

Yeah

restive otter
#

Can't you do it in parse_dict?

sullen nymph
#

Oh yeah

#

So technically at that point

restive otter
#

lmao

#

you can do ClassType.__annotations__

#

Wait, what are you trying to do xd

coarse rune
#

Hi

#

How to add server count on the top.gg bot page?

brittle spoke
#

by going to the library you use?

coarse rune
#

Ok i use javascript

brittle spoke
#

the go to the javascript one

coarse rune
#

Ok.....

coarse rune
tawny smelt
#

umm
When top.gg is sending request (because someone voted for the server) its sending without anything in the body (or am i just not receiving it?)
can some1 check if its just me or some1 else as well is having same problems?

jaunty plank
tawny smelt
#

whoops

tawny smelt
random zenith
#

hello, I have a hard time understanding how to set up vote rewards with Java, I've looked into the docs, but I'm not sure if I need to set up a webserver or not for this API. So far I've implemented the API into the bot which works with JDA, but to create a new API object every time a message is sent gives me eventually an out of memory error while I got 48GB RAM.

jaunty plank
tawny smelt
#

lemme try

jaunty plank
tawny smelt
#

JSON.parse(req.body) thats correct right?

jaunty plank
tawny smelt
#

how-?

random zenith
jaunty plank
jaunty plank
#

👀 doesnt seem the java lib supports webhooks anyway, so youll need to make your own from scratch

tawny smelt
#

@jaunty plank umm why is top.gg sending two requests?

jaunty plank
random zenith
jaunty plank
#

you would need to make a webhook with java to receive the webhooks.

scarlet cobalt
#

One message removed from a suspended account.

tawny smelt
jaunty plank
scarlet cobalt
#

One message removed from a suspended account.

sullen nymph
#

So yeah I can do what I want just fine with dataclass

rain heart
#

maybe

jaunty plank
random zenith
#

I know, just use TomEE in this case and it'll be fine, but I'm still not sure how to deploy this on a VPS

sullen nymph
#

since they support default values

random zenith
#

I'll have to figure it out as I go I guess, thanks for the info

random zenith
# rain heart *maybe*

if you do rewrite it and if it's possible, it would be great to know when a user has voted

rain heart
#

if you're referring to webhooks

random zenith
jaunty plank
#

even if the main library adds it, it will be in the form of webhooks.

random zenith
#

I was referring to the API of Java, would be great if I could get the date time of when a user voted

rain heart
#

yeah that's not possible with the api at all, best approach is using webhooks for that

random zenith
#

Yeah I came to that conclusion as well with what Woo told me haha, thanks though ASthumbsup

restive otter
sullen nymph
#

Oh dear

#

I mean, it looks compact. Is it better than the one I already implemented?

restive otter
#

It raises the proper AttributeError instance

sullen nymph
#

Ah

restive otter
#

But IDK, I haven't found someone does this, so I don't really know the drawbacks

sullen nymph
#

As once said by a wise man

#

Prod is the best environment for testing

buoyant laurel
#

Hey I need help

import dbl

# This example uses dblpy's webhook system.
# In order to run the webhook, at least webhook_port argument must be specified (number between 1024 and 49151).

dbl_token = 'top.gg token'  # set this to your bot's top.gg token
bot.dblpy = dbl.DBLClient(bot, dbl_token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)

@bot.event
async def on_dbl_vote(data):
    """An event that is called whenever someone votes for the bot on top.gg."""
    print(f"Received an upvote:\n{data}")

@bot.event
async def on_dbl_test(data):
    """An event that is called whenever someone tests the webhook system for your bot on top.gg."""
    print(f"Received a test upvote:\n{data}")

When I run this, it shows 404 error. (P.S. I don't know much about APIs)

restive otter
sullen nymph
#

A 404 for webhook

#

Now how do you manage to get that 404 is my question

buoyant laurel
#

I am hosting on replit

restive otter
#

Also, consider using topggpy

buoyant laurel
#

It shows 404 error

buoyant laurel
restive otter
#

Well, I don't have right to say so when I'm literally still using dblpy

sullen nymph
#

LMAO

jaunty plank
buoyant laurel
restive otter
#

If you're accessing the / path, then your webhook is definitely running

jaunty plank
#

seems normal, as your not running anything on that endpoint

sullen nymph
#

Ah

restive otter
#

Try accessing /dblwebhook, it should return 405 if it's running

sullen nymph
#

That explains everything. Replit by default opens the root route

#

Root? Main? / you get it

buoyant laurel
restive otter
jaunty plank
#

yourRepliturl/dblwebhook

restive otter
#

But, it should be BASEURL/dblwebhook, yes ^^

buoyant laurel
#

I got 405

sullen nymph
#

Then it's running

jaunty plank
#

thats the url youll need to fill in on your bots page in the webhook section

buoyant laurel
#

Ohh, thank you

sullen nymph
#

I wonder if adding a GET listener for DBL and DSL endpoints as a confirmation could be a good idea

buoyant laurel
#

still when I send a test webhook, I still don't get the data

jaunty plank
buoyant laurel
jaunty plank
#

youll need to fill it in

restive otter
#

return web.Response(status=200, text="Webhook is running!1!1!1!1!1")

jaunty plank
#

whatever is here in the code
webhook_auth='password'

buoyant laurel
restive otter
#

In your case, it's password

jaunty plank
#

in the example you showed, just password probably should make it something more secure

buoyant laurel
#

ohh finally got it.

#

Thanks a lot

sullen nymph
# restive otter `return web.Response(status=200, text="Webhook is running!1!1!1!1!1")`

Pfft, why do it the easy way?

>>> l
[87, 101, 98, 104, 111, 111, 107, 32, 105, 115, 32, 114, 117, 110, 110, 105, 110, 103]
>>> el
[33, 49, 33, 49, 33, 49, 33, 49, 33, 49, 33, 49, 33, 49, 33, 49, 33, 49, 33, 49, 33, 49, 33, 49, 33, 49, 33, 49, 33, 49, 33, 49, 33, 49, 33, 49, 33, 49, 33, 49]
>>> f"{''.join(chr(e) for e in l)}{''.join(chr(e) for e in el)}"
'Webhook is running!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1'
jaunty plank
#

👀 wth am i looking at

sullen nymph
#

ASCII codes

restive otter
#

char* gang

jaunty plank
#

oh wth lmao

sullen nymph
#

Well, dataclass doesn't help with typehints

restive otter
#

Does type hinting it without the decorator work?

sullen nymph
#

I mean the init method doesn't have typehints

#

This is as ugly as it could ever get lmfao

restive otter
#

Oh, I think I know what to do, let me test it

sullen nymph
#

Guess who was using a different class

#

Sometimes I disappoint myself

#

Oh, so no, it doesn't help with type hints

#

Dataclasses were introduced in 3.7?

restive otter
#

Welp, I tried this but seems like it only updates the __init__ annotations at runtime, so won't really type hint it.

restive otter
restive otter
sullen nymph
#

I guess I'm going the painful way then

#
    def __init__(self, donatebotguildid: int, id: int = None, username: str = None, discriminator: str = None,
                 avatar: str = None, def_avatar: str = None, prefix: str = None, shortdesc: str = None,
                 longdesc: str = None, tags: List[str] = None, website: str = None, support: str = None,
                 github: str = None, owners: List[int] = None, guilds: List[int] = None, invite: str = None,
                 date: datetime = None, certified_bot: bool = None, vanity: str = None, points: int = None,
                 monthly_points: int = None, *args, **kwargs):
#

Actually, am I okay?

#

No one's gonna need the type hints in the init since it's gonna be a received dictionary

restive otter
#

That's why I asked you if you're gonna let the users instantiate the objects. Cuz they should be rest objects which shouldn't be instantiated manually xd

sullen nymph
#

Yeah, I'm not the smartest cookie

#

WidgetOptions is one thing, BotData is another

restive otter
#
dbl_token = 'dbl token'  # set this to your bot's top.gg token
client.dblpy = dbl.DBLClient(client, dbl_token, webhook_path='http://ip/dblwebhook', webhook_auth='password', webhook_port=5000)

@client.event
async def on_dbl_vote(data):
    """An event that is called whenever someone votes for the bot on top.gg."""
    print(f"Received an upvote:\n{data}")

@client.event
async def on_dbl_test(data):
    """An event that is called whenever someone tests the webhook system for your bot on top.gg."""
    print(f"Received a test upvote:\n{data}")```This isnt working plz help
#

how can i give test upvote?

restive otter
#

thanks

jaunty plank
restive otter
#

someone told me to put ip there

jaunty plank
#

nope, just the path.

#

for example /dblwebhook is a valid path

restive otter
#

should I replace it with /dblwebhook

#

?

jaunty plank
#

if thats the path you want, yes.

#

the actual url you use then will look something like this
http://yourpubliciphere:5000/dblwebhook

restive otter
#

Do u want me to put webhook_path = http://yourpubliciphere:5000/dblwebhook

#

it should be a string ?

#

I am not able to understand

jaunty plank
#

webhook_path = "/dblwebhook"
webhook_path is ONLY a path, not a url.

restive otter
#

got it

#

what is webhook url ?

jaunty plank
#

the url(http://yourpubliciphere:5000/dblwebhook) is the url for the webhook on top.gg, in your bots edit page.
this is the url top.gg sends webhooks to.

restive otter
#

oh

#

@jaunty plankit doesnt print anything

jaunty plank
#

did you fill in the webhook url and auth?

#

on the site

restive otter
#

ya

jaunty plank
#

did you replace yourpubliciphere with the proper ip

restive otter
#

ya

#

lemme check once again plz

night ingot
#

Is port 5000 open on the network you're hosting the bot on?

restive otter
#

I am just using my pc for testing

jaunty plank
#

youll need to port forward then

night ingot
#

Yeah This

restive otter
#

how I can do that ?

jaunty plank
night ingot
restive otter
#

ty

#

Error: I could not see your service on

night ingot
#

See the link Woo sent, you need to forward the port on your Router

restive otter
#

ok

sleek night
#

I got an unclosed client session error after removing a webhook that didn't work. How do I fix this? And how do I build a functioning webhook?

(I can't post the full traceback as it is 5069 characters long, and Discord has a 2k limit)

sullen nymph
#

5k characters long traceback what

#

Can you show what you're doing

sleek night
#

Trace:

client_session: <aiohttp.client.ClientSession object at 0x7fc2c44ef040>
Task exception was never retrieved
future: <Task finished name='Task-1' coro=<DBLClient._webhook() done, defined at /opt/virtualenvs/python3/lib/python3.8/site-packages/dbl/client.py:436> exception=OSError(98, "error while attempting to bind on address ('0.0.0.0', 8080): address already in use")>
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/dbl/client.py", line 457, in _webhook
    await self._webserver.start()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/aiohttp/web_runner.py", line 121, in start
    self._server = await loop.create_server(
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1463, in create_server
    raise OSError(err.errno, 'error while attempting '
OSError: [Errno 98] error while attempting to bind on address ('0.0.0.0', 8080): address already in use
Traceback (most recent call last):
  File "main.py", line 62, in <module>
    bot.run(token)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 718, in run
    return future.result()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 697, in runner
    await self.start(*args, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 660, in start
    await self.login(*args, bot=bot)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 509, in login
    await self.http.static_login(token.strip(), bot=bot)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 293, in static_login
    data = await self.request(Route('GET', '/users/@me'))
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 209, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: 429 Too Many Requests (error code: 0):
#html & css spam -->
jaunty plank
#

"error while attempting to bind on address ('0.0.0.0', 8080): address already in use")>

#

looks like your still opening a webserver, and opening it on a port which is already used

restive otter
#

ratelimited eyesCentered

jaunty plank
#

oh yeah, looks like discords ratelimiting your bot too

sleek night
#

I'm using Replit.com to host the bot, so whenever I reload the page I'm hosting the bot on, that should close the webserver and start a new one right? (I'm relatively new to webservers and have no idea how webhooks work. This happened after trying to add a webhook to read votes from Top.gg, but the error stayed after removing the non-functional webhook)

#

There's a lot going on in the trace, so I'm not sure where my initial issue is and how to fix it.

sullen nymph
#

Not exactly. Ideally, you only want to run the webhook once and let the repl keep alive keep your stuff running. Reloading pages on its own shouldn't re-run a webhook (or anything really)

sleek night
#

I removed the webhook which started the huge trace, but it didn't fix anything. I don't understand why

sullen nymph
#

Seems like the culprit isn't the webhook

#

Maybe it's just your bot failing to start that causes all this

#

@restive otter Does this even need any tests?

restive otter
#

DataDict may do

sullen nymph
#
def test_data_dict_fields(data_dict: types.DataDict):
    for attr in data_dict.copy():
        if 'id' in attr.lower():
            assert isinstance(bot_data[attr], int)
        assert data_dict.get(attr) == data_dict[attr] == getattr(data_dict, attr)
restive otter
#

btw why is there kwargs there?

sullen nymph
#

Because PyCharm decided to add it there 4Shrug

restive otter
#

You're setting the attributes btw, that'll be fine if you do self.__dict__ = self in the DataDict as it won't duplicate them.

#

Never seen someone doing that though, might be uncommon

sullen nymph
#

If it works, I don't see a problem 😛

restive otter
#

Micro-optimization™️

sullen nymph
restive otter
#

Will pycharm scream at you if you pass the parameters to the superclass init instead of setting them as attributes?

sullen nymph
#

Seems fine

#

Should test in runtime

restive otter
#

Oh, actually owoThink nevermind, I think both implementations should work lmao. They won't duplicate the data

sullen nymph
#
    def __init__(
        self,
        id: Optional[int] = None,
        format: str = None,
        type: str = None,
        noavatar: bool = False,
        colors: Colors = None,
        colours: Colors = None,
    ):
        super().__init__(
            id=id,
            format=format or "png",
            type=type or "",
            noavatar=noavatar or False,
            colors=colors or colours or {}
        )

this is what I have for WidgetOptions right now and PyCharm is fine with it

restive otter
#

yeah lmao, I might be sleepy, it won't duplicate the data

#

But this is so compact mmulu ```py
class Test(dict):
def init(self, *args, **kwargs):
super().init(*args, **kwargs)
self.dict = self

sullen nymph
#

It is KEKW

restive otter
#

Ah, but I think better stick with the former as it won't override built-in methods such as keys, items and whatnot. I mean, it's not like people are gonna assign it LUL but w/e

sullen nymph
#

Who knows ia_lul_haha

restive otter
#

Back to "I usually prefer to think that whoever uses dblpy is a newbie, so anything is possible" xd

sullen nymph
#

Yup 😂

#

Ehh

#

I'll blame whoever decides to override built-in methods since I prefer to have the attribute error show up properly

sleek dune
#

i can't find him

restive otter
sleek dune
#

thx

#

then how can i get my top.gg token?

restive otter
#

Webhook page of the bo

#

T

sleek night
#

How do I know what my webhook path is?

loud token
sleek night
#

I know I did somewhere, but idk where I stored that info. :/

loud token
#

lmao

#

go check your bot's page on top.gg

deft helm
#

how do i check if someone has voted for the bot in the last 12 hours using top.gg api?

rain heart
deft helm
#

didnt see the docs before 😅

restive otter
#

k

#

,

restive otter
#

!token

#

?

final fulcrum
#

Spotify

#

Pv

meager knot
#

how

#

to display

#

bot server

sullen nymph
#

What library do you use?

meager knot
#

python

meager knot
sullen nymph
#

You can use topggpy's autopost feature

meager knot
#

huh

#

so how do i do that

#

idk anything also

#

can u show

#

an expame

meager knot
sullen nymph
meager knot
#

kk\

#

but wont that take are toke

#

token which is private

#

@sullen nymph

sullen nymph
#

All tokens are private and you use them to authenticate your bot

#

For this you want your bot's top.gg token

meager knot
#

ye

sullen nymph
meager knot
#

can u pls say i am disturbing u so muhc

#

much

sullen nymph
#

See pinned messages in this channel

meager knot
#

ok

#

so

#

and over here bot means

bot = commands.Bot(command_prefix=prefix)

meager knot
meager knot
grizzled vapor
sullen nymph
#

What do you mean?

grizzled vapor
sullen nymph
#

Top.gg supports webhooks, which means you can receive votes (for your bots only) in real-time and process them as needed

kind path
#

hi i'm using dblpy to make a post req to top.gg to post guild count (using autopost = True thing), but that doesn't work

#

it don't post the guild count :/

#

also tried with manual post, same result

sullen nymph
#

Are you sure the client gets instantiated?

#

Are you sure the client you attach DBLClient to is listed on top.gg?

#

Are you sure the top.gg token you entered is valid?

#

Okay my fingers hurt from typing

kind path
#
class Top(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

        dbl_token = 'token'  # set this to your bot's Top.gg token
        bot.dblpy = dbl.DBLClient(bot, dbl_token, autopost=True, webhook_path='/dblwebhook', webhook_auth="my_auth", webhook_port=myport)

    @commands.Cog.listener()
    async def on_ready(self):
        print(f"TopGG Loaded")
#

that's my code

sullen nymph
#

interesting

#

Try posting manually

kind path
#

already tried, same result

sullen nymph
#

not poggers

kind path
# sullen nymph Try posting manually
    @commands.Cog.listener()
    async def on_guild_post(self):
        """This function runs every 5 minutes to automatically update your server count."""
        await self.bot.wait_until_ready()
        try:
            await self.bot.dblpy.post_guild_count()
            channel = 834212576061161472
            d = self.bot.get_channel(channel)
            a = "[**`top.gg`**](https://top.gg/bot/801742991185936384)"
            em = discord.Embed(description=f'![PepeSmart](https://cdn.discordapp.com/emojis/820747995095629866.webp?size=128 "PepeSmart") Server count (**`{len(self.bot.guilds)}`**) was succesfully posted on {a} with **`{round(self.bot.latency*1000, 2)}ms`**', color = 0xffcff1)
            await d.send(embed=em)
        except Exception as e:
            print('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
``` that's the listener i use for recive posted guild
kind path
#

neither, autopost and manual post broken f

#

@vital anvil there's an issue with the api or i'm unlucky? tried manual guild post and autopost, no one work, the token is the right one

vital anvil
#

We didn't do any changes on the API

kind path
#

well, so i'm unlucky, i can't post guild count anymore

scarlet cobalt
#

One message removed from a suspended account.

vital anvil
#

what response do you get

kind path
#

no response, my shell isn't logging anything

knotty trench
#

waow sexs

scarlet cobalt
#

One message removed from a suspended account.

vital anvil
#

do a manual request

knotty trench
sullen nymph
#

Try using topggpy ftw

kind path
#

well, lemme try

#

wait

#

topggpy is what i'm using

#

._.

#

why the docs are the same of dblpy

scarlet cobalt
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

kind path
#

well, so i'm using it already

#

how can i make a manual request to top.gg to post guild count?

vital anvil
#

postman, curl or something similar

#

@sullen nymph might be a good thing to add errors if something goes wrong in the autoposting then

kind path
#

lemme try make a post req with aiohttp

kind path
restive otter
#

Would be good if you spend some time reading the docs

vital anvil
#

squish we're trying to debug here

#

don't be mean

restive otter
#

Sorry, didn't mean to, I mean, the docs tell the URL

vital anvil
sullen nymph
#

Bro

#

They're using the deprecated module

vital anvil
#

oh lol

#

^ this confused me then

#

dblpy shouldn't break though, right?

sullen nymph
#

It shouldn't, idk what's going on

restive otter
#

I'm still using it and it works, so it shouldn't

vital anvil
#

let them do the request then so we can see what the issue is

#

most likely a 403

restive otter
sullen nymph
#

ReCuRSION????????

velvet osprey
#

Whre can i get a api token?

restive otter
#

not as bad lol

velvet osprey
#

I use js

restive otter
#

See pinned messages ig

sullen nymph
velvet osprey
#

Thank you ❤️

kind path
restive otter
#

Put your token in the authorization header

vital anvil
#

yea your token is wrong

#

check your bot dashboard

kind path
#

._.

#

the token is right, regenered and copied the new one rn

hasty owl
#

@gio

kind path
#

but why autopost doesn't work?

restive otter
#

Hmm, try migrating to topggpy if you were using dblpy

kind path
#

lemme try

hushed reef
#

Or is this something that will be addressed in API/1.1?

vital anvil
#

right now there isnt

hushed reef
#

ah, alright

calm wing
#

Where can i generate a Token and Auth?

rain heart
#

You cannot generate a token while your bot isn't approved

hushed reef
#

really?

#

neat

restive otter
#

did someone ping?

#

Ye

#

bruh

rain heart
#

@short isle don't ghostping people

#

thanks

short isle
#

Ok

fringe drift
#

hi

#

how to use the server api pls?

#

i need to get votes and create a webhook server (like for the bot api)

jaunty plank
fringe drift
#

ok thanks!

jaunty plank
tawdry flax
#

I want to know how can i check whether someone has voted for my bot or not? I saw some documents but i am not able to do the header : authorisation part

night ingot
#

In what way are you "not able to"? Do you just not know what to do, or are you running into errors?

pseudo sierra
#
import discord
import dbl
class TopGG(commands.Cog):
   

    def __init__(self, client):
        self.client = client
        self.token = 'dbl_token'
        self.dblpy = dbl.DBLClient(self.client, self.token, webhook_path='/dblwebhook', webhook_auth='yamizero31', webhook_port="somePortNum")

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
         print(data)```guys this event gets called twice
#

idk why

#

how should i fix it?

#

btw it's for server vote and not bot votes

sullen nymph
#

Use topggpy

pseudo sierra
#

it doesn't work

#

tried it many times, this one responds

sullen nymph
#

How...

pseudo sierra
#

idk, i putted the 2 packages
topggpy and dbl
one in each file and ran the bot
the one that responded was dbl

sullen nymph
#

My question is why would you combine both

pseudo sierra
#

topggpy wasn't working

#

i googled and found dbl

#

so i just added it and it worked

sullen nymph
#

Yeah well there are changes in topggpy

#

That's probably why it didn't work 🤷

#

Because it works just fine for me

pseudo sierra
#

hmmm

#

lemme try again

sullen nymph
#
widget_options = {'id': 264811613708746752, 'format': 'png', 'type': '', 'noavatar': False, 'colors': {'text': 0}}

    def test_widget_options_fields(widget_options: types.WidgetOptions):
        for attr in widget_options:
            if "id" in attr.lower():
                assert isinstance(widget_options[attr], int)
>           assert (
                widget_options.get(attr)
                == widget_options[attr]
                == getattr(widget_options, attr)
            )
E           AssertionError: assert '' == None

test_type.py:74: AssertionError

@restive otter Well, this sounds fun 😂

restive otter
#

Was it the get returning None

sullen nymph
#

I'm not sure which comparison it's complaining about honestly

#

Since it's showing '' == None

#

Let's divide them

restive otter
#

So, must be the last 2

sullen nymph
#

Yup

#
widget_options = {'id': 264811613708746752, 'format': 'png', 'type': '', 'noavatar': False, 'colors': {'text': 0}}

    def test_widget_options_fields(widget_options: types.WidgetOptions):
        for attr in widget_options:
            if "id" in attr.lower():
                assert isinstance(widget_options[attr], int)
            assert widget_options.get(attr) == widget_options[attr]
>           assert widget_options[attr] == getattr(widget_options, attr)
E           AssertionError: assert '' == None

test_type.py:75: AssertionError
pseudo sierra
#

@sullen nymphsorry but i remember you told me that i can await this using client.something
client.topgg_webhook.run(5000) i don't remember what was it so can u help me?

restive otter
#

Is that the repr of widget_options? If not, that should be a dict?

sullen nymph
pseudo sierra
#

oh alr

sullen nymph
pseudo sierra
#
/home/container/philosophia.py:69: RuntimeWarning: coroutine 'WebhookManager.run' was never awaited
client.topgg_webhook.run(5000) # this method can be awaited as well
RuntimeWarning: Enable tracemalloc to get the object allocation traceback```
restive otter
sullen nymph
#

Oh, it's not in 1.0.1?

restive otter
#

You haven't pushed it iirc

sullen nymph
#

Let me see

restive otter
#

Btw the attr raising the error was type, wasn't it? How can it be None lmao, it defaults to "", doesn't it?

sullen nymph
#

It's multiple attrs actually

restive otter
sullen nymph
#
id
True
False
False

format
True
True
True

type
True
False
False

noavatar
True
True
True

colors
True
False
False
#
>>> for attr in wo:
...     print(attr)
...     print(wo.get(attr) == wo[attr])
...     print(wo[attr] == getattr(wo, attr))
...     print(wo.get(attr) == getattr(wo, attr))
#

Yeah, give me a sec

pseudo sierra
#

i forgot it

restive otter
sullen nymph
#

Having an issue with colors and colours right now, that issue is fixed

restive otter
#

How did you alias it?

sullen nymph
#

Oh my dumb ass

#

.get returns None for colours

#

Okay, and property differs from key

restive otter
#

If you've overridden the __setitem__, __getitem__ and get, ig the setter and getter will be redundant

#

Wonder if get is synced with __getitem__

sullen nymph
#

We'll see

#

It's not?

#
>>> print(wo.get('colours'), wo.get('colors'))
None {'text': 0}
sullen nymph
#

Why would the property setter- yeah

restive otter
#

Cuz, __getattr__ is getting directly from __dict__ attr

sullen nymph
#
id
True
True
True


format
True
True
True


type
True
True
True


noavatar
True
True
True


colors
True
True
True

So why is my test failing lol

restive otter
#

lmao

sullen nymph
#

This literally doesn't make sense

#

Oh, interesting

#

... of course

pseudo sierra
#
f /home/container/requirements.txt ]]; then pip install -U --target /home/container/ -r requirements.txt; fi; /usr/local/bin/python /home/container/philosophia.py
Traceback (most recent call last):
File "/home/container/discord/ext/commands/bot.py", line 606, in _load_from_module_spec
spec.loader.exec_module(lib)
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/container/philosophia_Cogs/moderation.py", line 14, in <module>
from philosophia import AUTOACTIONS
File "/home/container/philosophia.py", line 70, in <module>
asyncio.get_event_loop().run_until_complete(client.topgg_webhook.run(5000))
File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/home/container/topgg/webhook.py", line 120, in run
await self._webserver.start()
File "/home/container/aiohttp/web_runner.py", line 121, in start
self._server = await loop.create_server(
File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1463, in create_server
raise OSError(err.errno, 'error while attempting '
OSError: [Errno 98] error while attempting to bind on address ('0.0.0.0', 5000): address already in use
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/container/philosophia.py", line 3225, in <module>
client.load_extension(f'philosophia_Cogs.{filename[:-3]}')
File "/home/container/discord/ext/commands/bot.py", line 678, in load_extension
self._load_from_module_spec(spec, name)
File "/home/container/discord/ext/commands/bot.py", line 609, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'philosophia_Cogs.moderation' raised an error: OSError: [Errno 98] error while attempting to bind on address ('0.0.0.0', 5000): address already in use``` i get this error when i try to await it
sullen nymph
#

My fields and keys aren't synced lmao

#
OSError: [Errno 98] error while attempting to bind on address ('0.0.0.0', 5000): address already in use
#

Port 5000 is already used by something

pseudo sierra
#

i am not even using that port

#

oh wait

#

lol

sullen nymph
pseudo sierra
#

still same issue

#

i changed it from 5000 to client.loop.run_until_complete(client.topgg_webhook.run(4484))

#

4484 is supposed to be the port of the server i am hosting the bot in

sullen nymph
#

Sounds like you're trying to run it twice

pseudo sierra
#

?

sullen nymph
#

Sounds like you're trying to call .run twice

pseudo sierra
#

i don't get it
where else would i run it?

sullen nymph
#

Can you show your code?

pseudo sierra
#

sure

restive otter
#

Seems like it runs because you imported your file again, try __main__ guard it

#
if __name__ == '__main__':
    # run the webhook
sullen nymph
#

Having a conf.py file for constants ftw

pseudo sierra
#

hmm?

pseudo sierra
restive otter
#

Wherever you run the webhook

#

or wherever you call the run method

pseudo sierra
#

like when i run the bot? cause that's the main file so

if __name__ == "__main__":
    client.run("token")``` ?
restive otter
pseudo sierra
#

what's that?

#

do u mean this?

client.loop.run_until_complete(client.topgg_webhook.run(4484))``` ?
restive otter
#

Yes, would be a good idea if you also __main__ guard the client.run

pseudo sierra
#

oh alr

#

lemme try

restive otter
pseudo sierra
#

wait that worked!!!!

#

true, i will consider it and thx

restive otter
pseudo sierra
#

it's still being called more than 1

#

this time it got called 4 times

#

now two times

restive otter
#

Not sure what you're doing

sullen nymph
#

inb4 it's a recursion

restive otter
sullen nymph
#

@restive otter What do you think?

#

The getattr seems redundant

#

I'll probably adjust the test and test field/key changes

loud token
#

is this your json decoder/encoder

restive otter
#

is colors present everywhere?

sullen nymph
#

Yeah, I've been playing around with WidgetOptions and colors key was always present

#
  • I create it in superinit so it's always present
restive otter
#

I mean, in every payload

sullen nymph
#

Oh I see what you mean

#

Think I should move the check to WidgetOptions methods and call supermethods?

sullen nymph
restive otter
#

These aren't necessary ig, since you already got the getter and setter

sullen nymph
#

Yeah, I removed the getattr method

#

I do seem to need the setitem in setattr to sync the data

restive otter
#

It already is?

sullen nymph
#

Give me a minute

sullen nymph
# restive otter It already is?
    def __setitem__(self, key, value):
        if key == 'colours':
            key = 'colors'
        dict.__setitem__(self, key, value)
        setattr(self, key, value)

    def __getitem__(self, item):
        if item == "colours":
            item = "colors"
        return dict.__getitem__(self, item)

    def get(self, key):
        if key == 'colours':
            key = 'colors'
        return super().get(key)

    def __setattr__(self, key, value):
        if key == 'colours':
            key = 'colors'
        object.__setattr__(self, key, value)
        dict.__setitem__(self, key, value)

Should I change anything here? These are WidgetOptions methods

#

Since I'm basically redirecting anything colours to colors

restive otter
#

setattr(self, key, value) is redundant imo

#

As well as object.__setattr__(self, key, value)

#

Why is the __setattr__ still there? Did something break when you removed it?

sullen nymph
#

Yeah, I want setattr to update the dict

#

The latter wouldn't update if I did WO().colours = y

restive otter
#

Ah, I think I see the problem

#

self.__dict__ = kwargs, it's referencing to kwargs dict, instead of the dict object itself

#

Try changing it to self and remove the setattr method

sullen nymph
#

But my parse_dict KEKW

restive otter
#

It's fine because it's already passed to the init

sullen nymph
#

Oh oh

restive otter
#

At that point, kwargs is equivalent to the dict instantiated, but they're not the same object

#

So, when you're modifying the attribute, you're modifying the kwargs, not the dict.

sullen nymph
#

Ahhhh

#

I see

#

Yeah, it's all working

#

I still should keep my .get though, right?

restive otter
#

Yeah, since apparently it's not synced with __getitem__

sullen nymph
#

I have a print in getitem and using .get does nothing, soooooooo

#

Actually hold on

#
>>> d['id']
id
123
>>> d.get('id')
123

yeah

restive otter
#

Python™️

sullen nymph
#

😂

#

Finally this should be usable

tawdry flax
#

Can i get a link to any document which explains the whole api?

restive otter
upper valley
#

what happened to @topgg/sdk module ?

#

I can't download it

#

hello

#

help me

sullen nymph
#

How come you can't

upper valley
#

npm i @topgg/sdk not working

sullen nymph
#

Any errors?

upper valley
#

no

#

When I try to start the bot I get the error module not found

indigo canopy
#

🖊️

upper valley
#

what can i do right now ?

#

@sullen nymph

#

will nobody help

blissful knoll
#

v

#

v

#

sorry

upper valley
#

pls help

upper valley
#

``C:\Users\Administrator\Desktop\SJ-Bot-main>npm i @topgg/sdk
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@topgg%2Fsdk - Not found

npm ERR! 404
npm ERR! 404 '@topgg/sdk@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)

npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache_logs\2021-05-14T1
0_14_57_252Z-debug.log
``

hollow temple
#

npm install @top-gg/sdk

upper valley
#

i try this

#

and give me error

#

what is going on

#

all my modules are gone

#

and i try to download it

#

error

#

i get

restive otter
#
import discord
from discord.ext import commands
import dbl

client = commands.Bot(command_prefix="a!")

dbl_token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjgxMTczMzU5OTUwOTU0NDk2MiIsImJvdCI6dHJ1ZSwiaWF0IjoxNjE4NTIyNjA1fQ.HZzo6josspmshNaOq41LrwBJSMiJLeGmbtsTynFKgAo'
client.dblpy = dbl.DBLClient(client, dbl_token, webhook_path='/Testvote', webhook_auth='Astradiscord', webhook_port=5000)

class topgg(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print(f"Received an upvote:\n{data}")

    @commands.Cog.listener()
    async def on_dbl_test(self, data):
        print(f"Received a test upvote:\n{data}")

def setup(bot):
    bot.add_cog(topgg(bot))```
#

why is this not working?

hollow temple
hollow temple
#

use @top-gg/sdk

upper valley
hollow temple
#

okay

hollow temple
#

i don't know py but your top.gg token appears

#

hide your dbl token and change it

restive otter
#

i changed it before

sullen nymph
#

What the fuck and why

#

Okay calm down me

#

Ok

sullen nymph
restive otter
#

idk a friend does that

sullen nymph
#

Create DBLClient in the cog's init method

#

Your friend is dumb then

#

Well, rather, dumb in terms of working with d.py cogs

restive otter
sullen nymph
#

How do you create an object

#

An instance of a class

#

Do you know what a method is

restive otter
#

a method is something like keep_alive() or?

sullen nymph
#

Egh

#

A function attached to a class

#

hence you have bot.add_cog

#

add_cog is a method

restive otter
#

ah yes

sullen nymph
#

of object bot, which is an instance of commands.Bot class

#

Do you see the init method

restive otter
#

yes

sullen nymph
restive otter
#

sry but i dont understand you right now i'm not good in english

#

can you give me any examples?😬

restive otter
sullen nymph
#

In the init method you attach some attribute to the cog (instance of one) with self.x = y where x is the attribute and y is the value

#

The attribute name is whatever you feel like using, value will be an instance of DBLClient

restive otter
#

and how this looks like?

#

yes okay. what must in the webhook path and wbhook auth, where can i find these variables from my bot

sullen nymph
#

Show me how an instance is created

restive otter
#

class topgg(commands.Cog):
def init(self, bot):
self.bot = bot

tawdry flax
#

Can anyone explain, what are http headers?

sullen nymph
#

Webhook path is a path that's used in the webhook URL that you will use on top.gg. For example, http://1.2.3.4:5000/path is a URL you could use hypothetically. /path here is the path (also known as route) that will be used specifically for the DBL webhook.

No, that's creating a class with an init method. Why not take your time learning the basics of Python OOP?

sullen nymph
tawdry flax
#

Not at all, i read the document and saw there headers, maybe i thought it was ok to ask here, sorry.

sullen nymph
#

It's generally a better idea to search up your question and try to find an answer yourself. That way you teach yourself to be more or less independent

#

Plus it's easier if you just search up what's already there. On top of that, you might learn something new apart from what you search

tawdry flax
#

okay, thank you

sullen nymph
boreal whale
#

hi.

worthy bane
#

Ello

nocturne quarry
#

What data types can I post to top.gg other than guilds?

restive otter
#

can someone give me or help me with the code of server count on top.gg

#

?

#

or tell me where should i put it?

unique basalt
#

what is the top.gg module name in npm

rain heart
unique basalt
#

@top-gg/sdk its?

#

okey i got it

rain heart
#

@restive otter any reason for spam reacting?

#

Stop it thanks

restive otter
#

sry im bored

#

::)))

tawdry flax
#

Can i have a voting in top.gg required command with bdfd? It has new updates, it now supports : httpGet, httpPost, httpPut, httpDelete, httpPatch and httpResult

worn mountain
#

: ( js FetchError: request to https://top.gg/api//bots/stats failed, reason: Client network socket disconnected before secure TLS connection was established at ClientRequest.<anonymous> (/home/runner/Pop-Cat-Official/node_modules/node-fetch/lib/index.js:1461:11) at ClientRequest.emit (events.js:314:20) at ClientRequest.EventEmitter.emit (domain.js:483:12) at TLSSocket.socketErrorListener (_http_client.js:427:9) at TLSSocket.emit (events.js:314:20) at TLSSocket.EventEmitter.emit (domain.js:483:12) at emitErrorNT (internal/streams/destroy.js:92:8) at emitErrorAndCloseNT (internal/streams/destroy.js:60:3) at processTicksAndRejections (internal/process/task_queues.js:84:21) { type: 'system', errno: 'ECONNRESET', code: 'ECONNRESET' }

restive otter
loud token
#

wdym

vapid ledge
#

How do I make a topgg stats command?

patent lintel
#

why is top.gg posting to my webhook 4 times when someone votes wtf

vapid ledge
#

Speak spanish?

chrome pawn
#

hi, how to find out the password from the level in gd?

muted pine
marsh thicket
#

Que bien

oblique lance
#

how can i make a command to see how much vote does user have

rain heart
#

you need to track that yourself, you cannot check how many votes a specific user has

crisp hound
#

is there a video or something of that sort for using the top.gg api with python?

sullen nymph
steady gulch
#

Hi, wanted to ask. If i didn't want to use the topgg/sdk npm, would that be possible (for vote webhooks)

and this would be the code right?

app.post("/dblwebhook", (req, res) => {
  if (req.headers.authorization == "thepassword") {
    console.log(req.body.user)
  }
})```
crisp hound
#

can i give webhook url of my discord server?

#

so i will need to create a new website?

#

that gets the post request?

spice helm
crisp hound
spice helm
#

It just uses discordbotlist as an example, it still works with other platforms

#

@crisp hound

crisp hound
#

@spice helm can u provide some?

spice helm
#

Provide what exactly? It just uses discordbotlist as an example, if you follow the same steps it works for top.gg

#

Yeah

crisp hound
#

There was a problem saving the webhook Thonk
I get this error @spice helm

spice helm
crisp hound
#

@spice helm dmed u if that's cool

spice helm
#

Yeah

maiden geyser
#

Hi

oblique lance
#

@rain heart sir i have seen a server from there there is vote count of their bot

rain heart
#

ok?

oblique lance
#

wait i will give you link of the server in dm

rain heart
#

Can you just ask here and wait for someone as I'm not able to help, nor can be

oblique lance
#

ok

rain heart
#

Have something more important to do

oblique lance
#

yes can you tell me why webbook is exactly used

restive otter
oblique lance
#

ok

restive otter
#

Gamer moment

jaunty plank
#

@restive otter hey, what programming language is your bot in?

restive otter
#

Javascript

#

Discord.js module

jaunty plank
#

youll need to fill out the webhook url and webhook auth on your bots edit page in the webhook section

restive otter
#

What should I do with webhook URL

jaunty plank
#

its going to be the url to your webhook. will look something like
http://PUBLICIPHERE:PORT/PATH

#

your port and path will be defined in your code(linked above)

restive otter
#

What is the limit to get voting information?

jaunty plank
#

60/minute

high topaz
#

could anyone send me the code to create an embed for discord.py that I can just paste in and fill in the way I want to?

sullen nymph
#

cough see channel topic

#

Also you have to be dumb to not be able to understand how to do that by reading the d.py docs

high topaz
#

oh

#

sry

#

nvm then

#

don't even

sullen nymph
#

I'd suggest giving d.py docs a read, specifically the discord.Embed methods

high topaz
#

k

vague zinc
#

im using discord.py for my bot and im not sure how to use the vote detection

#

I installed dbl and tried implementing the on_dbl_vote(data) bot event but it doesn't print anything when votes happen

#

I also tried implementing the on_dbl_test(data) but that also doesnt print when i try to test

vague zinc
#

Fixed it, i simply had the wrong IP in the webhook URL

jovial kiln
#

👍

foggy slate
#

do I have to host a website for webhooks?

rain heart
#

a webserver yes

foggy slate
#

Is there a doc or something to see how to create a webhook?

jaunty plank
wheat rock
#

Hi I am new here and looking for friends 😊

rain heart
#

not in this channel unfortunately

wheat rock
#

What do you mean not in this channel

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.

foggy slate
#

webhooks is new to me

jaunty plank
#

what programming language are you planning on making your webhook in?

foggy slate
#

python

sullen nymph
foggy slate
#

thanks

vast phoenix
#

guys is it possible to check vote users using the api? I don't like the webhooks

rain heart
vast phoenix
#

i have to delete their user name after they claimed their reward

rain heart
#

you cannot get live votes though, only when for example the user uses a command for you to then check if they voted

#

see above

vast phoenix
#

lol

restive otter
eternal turret
#

can u get the user id of a voter with the api?

smoky marten
plucky lance