#topgg-api

1 messages · Page 152 of 1

spice helm
#

Go back to the HTTP module, and click on the request body, you should now have the pop up

hybrid crypt
#

ok

hybrid crypt
spice helm
#

You sure?

hybrid crypt
#

yes

spice helm
#

send a sceenstho

hybrid crypt
#

where it should be located?

spice helm
#

On the right

#

Of intergromat

hybrid crypt
#

;3

spice helm
#

Scroll down

hybrid crypt
#

yes

#

then?

spice helm
#

Click into it

hybrid crypt
#

:o

#

i don't see request body thing

spice helm
#

Request content then sorry

hybrid crypt
#

:>

#

okey

#

ah what do i do in the request content

#

Okey

spice helm
#

Idk, do you have the pop up

hybrid crypt
#

wherE?

#

Okey

hybrid crypt
spice helm
#

Wrong link

hybrid crypt
#

:o

#

i see

spice helm
#

These

hybrid crypt
#

i don't have the red lines

#

;/

#

wait

#

i do have

#

OH YES

#

i have da pop up

#

wot i do?

spice helm
#

Nice, click them to put them in

hybrid crypt
#

ok

spice helm
#

Remember to click ok to save

hybrid crypt
#

ish done?

spice helm
#

Yep

#

CLick ok

hybrid crypt
#

ok

#

done

#

wat now

#

;o

spice helm
#

Then click run once and test your webhook from top.gg to see if its what you want

hybrid crypt
#

Okey

spice helm
#

Yes, you have to test it on top.gg

hybrid crypt
#

:o

#

ok

hybrid crypt
#

but the message didn't come

#

:<

spice helm
#

not what you were supposed to do

#

Go back to the HTTP module

#

And reinsert the variables now, they'll be corrupted

#

I've got to go now

hybrid crypt
#

oh ok ;-;

#

Ughh i give up, its no use ;-;

upper valley
#

Why am I getting this error when using top.gg's voting module?

#

app.post('/dblwebhook', webhok.listener(vote => {
^

TypeError: webhok.listener is not a function

#

?

#

pls help

jaunty plank
#

webhok?

upper valley
#

I wrote a webhok for a definition called webhook :D

#

how can i solve this problem?

#

nobody helps :(

jaunty plank
#

did you init webhook?

#

const webhok = new Topgg.Webhook("your webhook auth")

rain heart
#

very likely misspelled webhook

rain heart
#

post your full code please

#

otherwise we can't help at all

upper valley
rain heart
#

try it now

#

what's the new error

upper valley
#

same error

rain heart
#

send the error

upper valley
#

app.post('/dblwebhook', webhook.listener(vote => {
^

TypeError: webhook.listener is not a function

rain heart
#

are you on the newest version?

#

read pins

upper valley
#

I'm updating the module

#

ok the problem is gone but when i press the webhook part of top.gg it doesn't write to the console

rain heart
#

make sure the url is correct

upper valley
#

//myserverip:5000/dblwebhook

#

not working

#

what port i changed and it worked :D

#

thanks man

restive otter
#

How can I create a vote webhook?

rain heart
#

Read the pins aswell

runic night
#

So I am pretty sure I use the right api token, but when I try to update the server number, I get:

Failed to post server count
Unauthorized: Unauthorized (status code: 401) 

I use the same code that is on the Python page btw.

vast plinth
#

probably dumb, but is top gg token the big ass string it gives you, not your bots id right

#

this token

#

on the webhook page

rain heart
#

correct

vast plinth
#

kk

rain heart
#

I mean

#

still am thinking about asking veld to maintain it

#

literally hasn't been maintained since 2019

#

I'd volunteer

vast plinth
#

thats on the freaking readme

#

thats intended use

rain heart
#

Still don't understand the source code of it

vast plinth
#

hold on let me get link

rain heart
#

Nah I've seen the source code

#

yet it's so outdated, can't even understand it with my smol brain

vast plinth
#

Ik, I might make a pull request its really fucking annoying

#

I still use Java 8 baybee

rain heart
#

java 8 pog

#

lol

vast plinth
#

Only have Java 11 for intellicode

short glen
#

hello, can anyone help me? im trying to create a top.gg webhook using discord.js and heroku but im stuck with this problem

#
2021-05-01T01:04:42.536430+00:00 heroku[router]: at=info method=POST path="/dblwebhook" host=[app_name].herokuapp.com request_id=1103d16e-586f-4597-b3df-185e5bc9fd53 fwd="159.203.105.187" dyno=web.1 connect=0ms service=4ms status=403 bytes=238 protocol=https
#

this is my code

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

const app = express();
const webhook = new Topgg.Webhook(process.env.TOPGG);

app.post('/dblwebhook', webhook.listener((vote) => {
  console.log(`Vote from: ${vote.user}`);
}));

const port = process.env.PORT || 8080;
app.listen(port);
rain heart
#

Enable your web dyno afaik

short glen
rain heart
#

I think so

#

Never used heroku, just heard of that

short glen
#

ok, but i have them enabled Thonk

restive otter
#

I'm having a rate limiting issue on the top.gg API, every 30 minutes my bots will update their online stats to show on the "Overview" section of my bot's page. But recently my bot has spat out a bunch of errors and it says things like "No json provided" etc etc, someone told me to post this here, so does anyone maybe know why this happening, perhaps i should raise the duration of when it post stats? much appreciated

main venture
lean harbor
#

Why Its Spamming

modern lagoon
#

@lean harbor hi

#

remember me?

modern lagoon
jaunty plank
#

top.gg resends webhooks until you give respond with a 200 response.

#

or until 10(or so) failed attempts

modern lagoon
#

oh

restive otter
#

Any ideas how to fix this?

restive otter
lean harbor
lean harbor
modern lagoon
#

🙂

lean harbor
#
const express = require('express'), {post, get} = require('superagent'), app = express();
const fetch = require('node-fetch');
app.use(express.json()); 
app.use(express.urlencoded({ extended: true }));
app.get('/', (req, res) => {

  res.send(`Response`)
})
app.post('/dblwebhook', async (req, res) => {
    let auth = req.headers['authorization'];
    if(!auth) return res.json({status: "Failed", message: `You didn't provide a 'Authorization' header!`});
    if(auth !== process.env.Auth) return res.json({status: "Failed", message: `You didn't provide the correct authorization key!`});
    if(!req.body) return res.json({status: "Failed", message: `You didn't provide any data!`});
    if(!process.env.dbl) {
      console.log(`You didn't add your dbl api key in the .env file.. smh`)
      return res.status(401).json({status: false, message: `Unauthorized`})
    }
    let bot = req.body.bot;
  	let {body: user} = await get(`https://top.gg/api/users/${req.body.user}`).set("Authorization", process.env.dbl);
     post(process.env.Webhook)
      .send({embeds: [{
        title: `Click Here To Vote Ratio™`,
		    color: 0xbc00ff,
		    url: `https://top.gg/bot/${bot}/vote`,
        timestamp: new Date(),
		    author: {
			    name: `Ratio™ Voted By: ${user.username}#${user.discriminator}`,
          icon_url: `https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}${user.avatar.toString().startsWith("a_") ? ".gif" : ".png"}`
		    },
		    footer: {
			    text: `Powered By Discord Bot List`, 
			    icon_url: `https://i.imgur.com/78Hl85r.gif`
		    }
     
      }]})

  
});
app.listen(4000, () => console.log(`DBL Voting Log Is Running`)); 
#

Why Its Not Working

robust kettle
#

app.set('view engine', 'ejs');

app.get("/dblwebhook", (req,res) => {
res.render("Voting");
});

#

@lean harbor

restive otter
#

How get bot dev role is it after my bot gets into top.gg?

robust kettle
#

Upon Approval

#

@restive otter

restive otter
#

Ok

lean harbor
restive otter
#

So i voted my bot and then made a request to check if i voted. But it always returns 0. I tried on my alt and got the same result. Do we need to wait some time or?

restive otter
#

Nvm, found a different solution.

crystal cloak
#

How can I define my library?

willow spindle
#

you can't

#

its deprecated and will be removed from api

night ingot
#

@restive otter stop that

restive otter
#

ok

livid egret
#

@restive otter ?

topaz axle
#

Anyone know how to use the DBL webhook in JS to listen for when someone "unvotes" (listener for when someone's vote is ready) ?

rain heart
#

get their vote, start a timer for 12 hours, after 12 hours, tell that user they can re-vote

#

if you want a more command-based check, simply use hasVoted through the API to check if they have voted in the last 12 hours

#

but if you want a notification-based "your vote is ready", you need the timer approach

jovial kiln
#

How long does it take for server stats to update after sending the POST request?

rain heart
#

instant up to 2 hours or so

#

depends on caching

sullen nymph
#

since it's basically a pain in the ass to customize routes this way imo KEKW

#

Should probs expose self.__app instead

restive otter
#

xd, thing is, everything in Python is public lol

sullen nymph
#

Ya well

restive otter
#

What was the idea behind exposing it btw?

sullen nymph
#

As the PR#45 or something says

#

sec

#

This is useful to customise routes and request handling.

restive otter
#

Ah, so that you can add routes and middlewares eh

sullen nymph
#

Pretty much

restive otter
#

yeah ig, it should've been app

sullen nymph
#

inb4 dbl_webhook('/dbl', 'eee').webhook.router.add_post('/dbl', some_func)

restive otter
#

xd

#

one could access it with ._WebhookManager__app though

sullen nymph
#

At that point I'm sure the dev knows what they're doing

#

... or at the very least have a slight idea of what they are doing

#

And, let's be fair

#

That just gives me more reason to blame them if they break something

restive otter
#

But um, I think you can access the app through the TCPSite anyway

#

<WebhookManager>.webserver._runner.app is <WebhookManager>._WebhookManager__app returns True

#

So ig, by exposing the webserver, it also exposes AppRunner and the Application. But they're public in the first place anyway LUL

sullen nymph
#

Wait am I that dumb

#

Omg

#

You legitimately just lowered my self-esteem so bad

#

Oh well what's done is done

restive otter
#

I did wot sad

#

I think I'll try to add some tests for actual pytest tests

sullen nymph
#

I spent like 20 minutes on trying to get that attr via the source code

restive otter
#

the _WebhookManager__app attr?

sullen nymph
#

The ._runner.app one

#

XGWkekwlaugh I'm laughing at myself so hard

restive otter
#

lmao

rain heart
#

@fresh forum please don't advertise

#

thank you

wintry warren
#
const Topgg = require('@top-gg/sdk');
const api = new Topgg.Api('"you really thought you were going to see the token')

const app = express();
const webhook = new Topgg.Webhook("you really thought you were going to see the password");

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

app.post('/dblwebhook', webhook.listener((vote) => {
  console.log(`Vote from: ${vote.user}`)
client.channels.cache.get('833702889062662170').send(`${vote.user} just voted **Mitsu**!`)
}));

app.listen(3031);```
#

I got a error saying "Cannot get /"

#

Oh wait

rain heart
#

you're trying to access that webserver without a context

#

can very likely just be ignored

rain heart
#

well path

#

not context, wrong wording

#

you're trying to access http://yourip:port/ instead of http://yourip:port/dblwebhook

wintry warren
#

I read the docs of top-gg/sdk and they said to use /dblwebhook...

rain heart
#

No no, what you're doing is correct

#

you tried to access your webserver without a path, that's what the error is

#

just ignore it

#

your webhook url is http://ip:port/dblwebhook

#

replacing ip:port with your ip and port

wintry warren
#

Hmm..

#

But how do I actually fix this

#

No vote logs in console logs

restive otter
#

@sullen nymph shall I remove test_import.py?

sullen nymph
#

Up to you tbf. We could also keep it in one file but that seems cleaner

#

The import test is just that, a test that imports the module, so you could leave it in case it's needed at whatever point

restive otter
#

Yeah but another tests import it as well xd

sullen nymph
#

Yup

#

Which is pretty much just rendering it useless KEKW

restive otter
#

Ok, Imma leave it as it is, you can always delete it dboatsMmlol

sullen nymph
#

XGWkekwlaugh I'll leave it for tomorrow since it's 4 am and inner me just wants to have a peaceful night

#

Thanks btw

restive otter
#

Seems like we got 1 hour diff

sullen nymph
#

Resolve conflicts button time

restive otter
#

Ya np, I also made some minor changes

sullen nymph
#

Will take a look, thanks

restive otter
#

@sullen nymph mind if I format all the files with black and isort?

sullen nymph
#

You shall not touch my imports. ir_evil_devil_laugh

#

It's fine, you can change them

restive otter
#

okie

snow idol
#

Hey

#

Anyone

rain heart
#

hm?

snow idol
#

How to I find cwl clans info , I dont know how to use it

rain heart
#

-wrongserver

abstract mothBOT
#

Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Get Support" button on the bot's page of the bot you need support for, not the "Join Discord" button at the top of our website. If there isn't a button that says Support Server or you were banned from the bot's support server, then we can't help you. Sorry :(

restive otter
#

How to create a vote webhook

rain heart
#

By using either a Library or coding one from scratch

#

Read pins

runic night
#

I am trying to update the number of servers my bot is in but I consistently get a :

Unauthorized: Unauthorized (status code: 401)

I use the python code provided in the top.gg documentation and I have copy-pasted the token I generated for my bot. Does anyone know how to resolve this?

rain heart
#

Are you using the top.gg token from your bot page settings under webhooks?

runic night
#

Yes

#

Isn't it the one I need?

#

Even forcing the token to be a string doesn't do anything

#

Ok so I fixed it:

  • When you copy-paste the token from the site to the .env in replit, it adds a newline at the start and the end of the token. They need to be removed.
  • When getting the token (with os.genv('token')), it needs to be explicated that the type of the token is str.
opal panther
#

is there an http request to see total votes for the year (for a bot)?

#

or something like that

hushed reef
#

you may only see the last 1000 votes

#

the only way to do that currently is find a way to make the bot track votes for each day and then cumulatively add them all up for the end of the year

opal panther
#

oh

#

it doesn't keep track of total votes at the end of each month?

opal panther
hushed reef
#

what

#

that makes no sense

opal panther
#

i don't need any info about the votes

hushed reef
#

so write a function that determines the end of whatever month it currently is and at the last minute count all the votes

opal panther
#

the problem is that i'm using http requests

#

not the library

#

okay

hushed reef
#

yeah, you're right

#

it's just inserted into the main bot information

restive otter
#

How to create an vote webhook

#

Theres nothing about that in the docs

jaunty plank
wintry tulip
#

ive tried whats listed on the documentation but the test button still doesnt do anything for me. Is something wrong with my code?

client.dblpy = dbl.DBLClient(client, dbl_token, webhook_path='https://MY_IP:6593/dblwebhook', webhook_auth='password', webhook_port=6593)

@client.event
async def on_dbl_vote(data):
    print(f"Received an upvote:\n{data}")

@client.event
async def on_dbl_test(data):
    print(f"Received a test upvote:\n{data}")
restive otter
#

The webhook path should only be /dblwebhook

#

Also, topggpy is up E_Poggers it introduces a separate webhook manager

wintry tulip
#

Oh I didn’t know that

#

I’ll try it

#

It still isn’t working. Is there something I need to do elsewhere for this to function?

restive otter
#

Did you pass https://MY_IP:6593/dblwebhook to the site? Ig just use http scheme for this. Also, you passed /dblwebhook to the webhook_path parameter, didn't you? Make sure port 6593 is open

wintry tulip
#

Yeah I’ve done all of this

#

And I checked if the port was open and it is

#

Does the password thing need to have something? Or is the “password” fine? I couldn’t find anything in the documentation that mentioned that.

restive otter
#

It's fully up to you, so that's fine.

wintry tulip
#

Do you have any other ideas to why it may not be working?

restive otter
#

Did you migrate to v1?

wintry tulip
#

I believe so

restive otter
#

Can you show the code?

wintry warren
#

Can someone help me, I get a "Cannot get /" error

wintry tulip
#
client.dblpy = dbl.DBLClient(client, dbl_token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=6593)

@client.event
async def on_dbl_vote(data):
    print(f"Received an upvote:\n{data}")

@client.event
async def on_dbl_test(data):
    print(f"Received a test upvote:\n{data}")```
restive otter
#

Uh, you didn't migrate then

wintry tulip
#

Oh there is diff code?

#

The topggpy thing has this code so im not really sure what the migration is

ruby kiln
#

Does anyone know why I get this error ? ClientException: autopost must be activated if autopost_interval is passed. Unclosed client session

restive otter
#

Yeah, shiv hasn't update it ig

wintry tulip
#

So I should just wait for them to update it and try again?

ruby kiln
restive otter
restive otter
restive otter
#

when instantiating DBLClient

ruby kiln
restive otter
#

yes

#

the autopost_interval defaults to 1800

wintry warren
#
const Topgg = require('@top-gg/sdk');
const api = new Topgg.Api('"you really thought you were going to see the token')

const app = express();
const webhook = new Topgg.Webhook("you really thought you were going to see the password");

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

app.post('/dblwebhook', webhook.listener((vote) => {
  console.log(`Vote from: ${vote.user}`)
client.channels.cache.get('833702889062662170').send(`${vote.user} just voted **Mitsu**!`)
}));

app.listen(3031);```
Can someone help, I get a "Cannot get /" error
#

I don't know why is it happening

wintry tulip
#
@client.event
async def on_dbl_vote(data):
    print(data)```
Sorry im still confused but is this the v1 version of how the on vote needs to be done?
ruby kiln
#

got the error back... ```
Failed to post server count
Unauthorized: Unauthorized (status code: 401)
Ignoring exception in auto post loop:
Traceback (most recent call last):
File "C:\Users\fouk\AppData\Local\Programs\Python\Python37\lib\site-packages\topgg\client.py", line 131, in _auto_post
await self.post_guild_count(shard_count=self.bot.shard_count if self.post_shard_count else None)
File "C:\Users\fouk\AppData\Local\Programs\Python\Python37\lib\site-packages\topgg\client.py", line 186, in post_guild_count
await self.http.post_guild_count(guild_count, shard_count, shard_id)
File "C:\Users\fouk\AppData\Local\Programs\Python\Python37\lib\site-packages\topgg\http.py", line 166, in post_guild_count
await self.request('POST', '/bots/stats', json=payload)
File "C:\Users\fouk\AppData\Local\Programs\Python\Python37\lib\site-packages\topgg\http.py", line 142, in request
raise errors.Unauthorized(resp, data)
topgg.errors.Unauthorized: Unauthorized (status code: 401)

wintry tulip
#

same lol

wintry warren
#

:(

sullen nymph
#

@restive otter I broke something again, didn't I?

#

I'll get to laptop in about few hours

restive otter
#

What do you think? This makes the run method can be awaited, but not necessary

sullen nymph
#

Sounds convenient 👀

restive otter
ruby kiln
# restive otter This isn't on us, the old version doesn't break the loop on 401. Meanwhile, the ...

okay I solved this problem. But now, I got this error HTTPException: Bad Request (status code: 400)

Here is my code : ```py
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""

@commands.Cog.listener()
async def on_ready(self):
    print("TopGG Server cog ready !")


def __init__(self, client):
    self.client = client
    self.token = 'MY TOKEN'
    self.client.topggpy = topgg.DBLClient(self.client, self.token, autopost = True)
    self.update_stats.start()

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

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

restive otter
#

Ugh, you already got autopost enabled, you don't need to do another post loop

wintry warren
#

Does anyone here can help with @top-gg/sdk

restive otter
#

Pro tip: you can pass True to the post_shard_count parameter

wintry warren
restive otter
#

just ask your question

wintry warren
#

So basically

#

I've getting an "Cannot get /" error

#
const Topgg = require('@top-gg/sdk');
const api = new Topgg.Api('"you really thought you were going to see the token')

const app = express();
const webhook = new Topgg.Webhook("you really thought you were going to see the password");

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

app.post('/dblwebhook', webhook.listener((vote) => {
  console.log(`Vote from: ${vote.user}`)
client.channels.cache.get('833702889062662170').send(`${vote.user} just voted **Mitsu**!`)
}));

app.listen(3031);```
restive otter
wintry warren
#

Is it something to ignore

restive otter
#

yup

wintry warren
#

How can I log the webhook url

#

Like the ip:port/dblwebhook

restive otter
#

where do you host your bot

wintry warren
#

Repl rn

restive otter
#

then its

restive otter
#

you need to fetch the user with their id

sharp totem
#

Hey

#

Can I know if a user has voted for a server without access to API just by a get request?

#

or any other way to know if a user has voted for a server

wintry warren
#

in the docs it's stated vote.user for user id

restive otter
#

you just can do <@${vote.user}> if you want

wintry warren
#

Oh

restive otter
#

how make meme api

#

🥺

hasty grove
restive otter
#

ok

wintry warren
#

Hello,

#

How can I get vote user tag?

vast belfry
#

hello, for using on_dbl_vote in the python sdk, do I need to run a quart server or something and manually process the POST or is there some utility for that in dblpy?

restive otter
#

It's now topggpy, and yes, there's a helper class for this

sullen nymph
#

@restive otter Bro my single quote strings :( this is discrimination

restive otter
#

LMFAO

#

black be like

#

I felt the same way ages ago lol

sullen nymph
restive otter
#

Could you guys make a system to detect if users left a review and how many stars they added? It would be useful for many things!

night ingot
#

People would use that to reward people for leaving a review, which is against our rules.

royal rampart
#

Hey, I'm currenlty reading the documentation for the python sdk, where can I get my top.gg token?

rain heart
#

read pins

royal rampart
#

thx

#

Well, now I'm getting the error TypeError: object Lock can't be used in 'await' expression

#

What do I need to do here?

restive otter
#

Did you install dblpy? Install topggpy instead

royal rampart
#

Do I need to change the imports/code then?

restive otter
#

Yeah, it's a breaking change

#

Not that much though

royal rampart
#

can you show me the code for it?

restive otter
royal rampart
restive otter
#

It is topggpy

#

topggpy == dblpy v1

#

Shivaco hasn't updated the examples; therefore, take a look at it instead

royal rampart
#
client.topgg = topgg.DBLClient(client, DBL_TOKEN, autopost=True, autopost_interval=900)

Is that enough code to post all my stats, or do I need more code?

restive otter
#

That's enough, if you want to post shard count as well, you can pass True to post_shard_count parameter

royal rampart
#

tysm

royal rampart
#

I was looking into the readme, sorry

hushed reef
#

all good

restive otter
#

I mean mmulu

hushed reef
#

never trust READMEs

restive otter
hushed reef
#

also, the php lib is out

#

only 3 people are gonna use it though KEKW

restive otter
#

POG I only use php because it's in my school syllabus lol

hushed reef
#

i can feel the pain in that

sullen nymph
restive otter
#

lmao

hearty jasper
#

Wh

dense field
#

Is there a way to put your bot in testmode

#

Like test the /bot features

#

And that good stuff

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
dense field
#

This is for the api

rain heart
dense field
#

Yeah

night ingot
#

Why would you need your bot in some test mode for that?

rain heart
#

then no there's not

dense field
#

Oh

dense field
night ingot
#

Oh you meant like that

#

yeah no, you'll need to wait for an approved bot

dense field
#

Alr

sullen nymph
#

@restive otter What do you think about renaming post_shard_count to something like autopost_shard_count?

#

And autopost to something like autopost_toggle?

restive otter
#

Umm, I'm personally fine with it as it is now. What about making a class, do you think it's redundant to make an AutoPostConfig class?

sullen nymph
#

Eh probably at some point if it's needed

restive otter
#

It might implement __getitem__ method, so one could pass a dict as well

sullen nymph
#

It's fine the way it is now and I haven't seen anyone even suggest a class for it so

restive otter
#

The autopost_toggle is kinda idk, I'd prefer the former

sullen nymph
#

I'll see if I get any suggestions about it

restive otter
#

It's pretty identical, but nothing is wrong by testing it ig. I'll add it soon

sullen nymph
#

Eh tbf true

#

I'll merge it once I'm done eating

restive otter
#

Shall I add the dsl one?

sullen nymph
#

Full coverage, I guess

#

In case I happen to somehow break the authentication process

restive otter
#

Alright, done ig

drowsy yew
#

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.

dense field
#

How is guild inflation dealt with?

jaunty plank
#

guild inflation?

dense field
#

Like, you add 30 to the actual count

#

30 + (actual) = 92

jaunty plank
#

then when a user reports it we check it against the actual count.

dense field
#

How can you do that tho?

jaunty plank
#

invite links give server count

dense field
#

Oh true

#

But

#

Not over a certain amount right?

jaunty plank
#

it always does, it just gets less accurate when you get into the millions, which as long as its mostly correct it doesnt matter at that point.

slow ruin
#

How can I alert when someone upvotes my bot?

dense field
slow ruin
#

How can I get my bot to talk?

dense field
slow ruin
#

Hello, I needed your help to make the webhook system, because "Authorization" I don't know what to do, can someone help?

loud token
#

when you receive a web hook, there's a section in the header called "Authorization" compare it to ensure someone isn't spoofing your web hook

gray yew
#

TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["authorization"]

how i can fix it ?

rain heart
#

you probably have a newline in your token

gray yew
#

ok

#

@rain heart i haven't

rain heart
#

check for invalid characters in your header then

loud token
#

should be "Authorization" not "authorization" right?

rain heart
#

nah that doesn't make a difference

viscid cloud
#

How can I make vote Tracker?

rain heart
viscid cloud
loud token
#

what are the pros and cons btwn using on _dbl_vote() and a webhook?

rain heart
#

on dbl vote only works with a webhook

#

there's no difference

jaunty plank
#

it is a webhook, just in a premade library.

loud token
#

If you use on_dbl_vote() do you have to provide a webhook url?

rain heart
#

on_dbl_vote is useless without a webhook

loud token
#

huh, okay

#

I see how it works now

#

thanks

#

that's pretty cool

wintry tulip
#

Hey I was wondering if Shivaco has fixed the errors that were on the topggpy library

viscid cloud
wintry tulip
#

They mentioned that they broke something and that they would get on their laptop in a few hours and that was like a while ago

restive otter
wintry tulip
#

I dont follow

restive otter
#

anyone know how to do that like someone votes my bot and my bot msg that guy in dm sayin ty :/

#

ty

sullen nymph
#

@restive otter you are just bullying me with your experience and knowledge, admit it 😛

#

Why the install itself workflow tho? Not sure why that's used in this case but regardless merged the PR

restive otter
#

Cuz pytest ig, it refers to topgg module, so if it wasn't installed, it can't run the tests

restive otter
#

But hm pytest runs in the parent directory, haven't tried relative import though. Well this install itself can also validate in case I happen to break the setup.py dboatsMmlol

sullen nymph
restive otter
sullen nymph
#

Tsk tsk

#

I was already about to open PyCharm so this will take like a few minutes

#

inb4 custom func split_auto_type LMFAO

restive otter
#

inb4 [int(i) for i in __version__.split(".")] mmulu

sullen nymph
#

Just make it tuple ezpz

sharp totem
#

How to check if a user has voted for a server without my bot having access to dbl client

sullen nymph
#

Can you elaborate on your question? What library do you use?

sharp totem
#

Python

sullen nymph
#

How do you not have access to your DBLClient object is my question

sharp totem
#

I want to check if a user has voted for a server just by making a get request

sullen nymph
#

Oh boy, a server

restive otter
#

There's no endpoint for server, is there?

sullen nymph
#

DSL doesn't have an API

sharp totem
#

Yep so?

#

How to check if a user has voted?

sullen nymph
#

The only way you can achieve this is with webhooks

restive otter
#

Setup a webhook and store it in your own database

sharp totem
#

oops

#

Why no endpoint?

sullen nymph
#

aka receive votes in real time and- yeah what norizon said

#

I'm not exactly sure why DSL doesn't have an API tbf

sullen nymph
restive otter
#

I guess

#

you can add __all__ to not expose it ig

sullen nymph
#

Hm, probably

restive otter
#

Or actually, I think if it has a trailing underscore, it wouldn't get exposed

#

NVM, I think it'd only work for wildcard imports lmao

sullen nymph
#

Guess there's only one way to find out? 😛

loud token
#

I have some code for checking for server votes

sullen nymph
#

I mean, there's the option of literally just doing what I did before

#

Form __version__ from the version_info namedtuple

restive otter
#

the __version__ value is only known at runtime, so I reversed it xd

sullen nymph
#

Something like ".".join((version_info.major, version_info.minor, version_info.micro)) 😛

#

Oh

restive otter
#

I could've suppressed the imports error, but dunno if that's an elegant way to do it

sullen nymph
#

Probably not

#

inb4

VersionInfo = namedtuple("VersionInfo", "major minor micro releaselevel serial")
major, minor, micro = __version__.split(".")
version_info = VersionInfo(
    major=major, minor=minor, micro=micro, releaselevel="final", serial=0
)

del major, minor, micro
``` 🤣
restive otter
#

What about this lol

sullen nymph
#

Oh my lord

restive otter
#

Overcomplicating shit blobweary

sullen nymph
#

😂

#

Well, let's leave it for another day

#

I doubt someone will use any of those vars along with from topgg import *

restive otter
#

I'll leave it to you

sullen nymph
#

I doubt you ever want to do a star import with topggpy soooooooooooooooooooooooooooooooooooooooo mmulu

restive otter
#

xd, I'll leave casting the number as int to you lol

sullen nymph
#

Aye, we'll be ready to go in a few seconds

restive otter
#

noice

sullen nymph
#

Yeah, "a few" KEKW

restive otter
#

dw, I'm myself a procrastinator KEKW

sullen nymph
#

Oop, changelog

restive otter
#

btw it's not a tuple, it's a generator

#

ig del major, minor, micro is more readable than my shit

sullen nymph
#

HAHAHAHAHAHAHAHAHAHAHAHA

restive otter
#

joy

sullen nymph
#

We'll leave it as it is

#

Not worth the hassle if no one complained about it yet

restive otter
#

LMAO, true

sullen nymph
restive otter
#

What type checker does pycharm use?

#

Didn't I type hint it to _WidgetOptions

sullen nymph
#

You did

restive otter
#

uh oh

#

Does ```py
opts = _WidgetOptions(
format=options.get("format") or "png",
type=options.get("type") or "",
noavatar=options.get("noavatar") or False,
colors=options.get("colors") or options.get("colours") or {}
)

sullen nymph
#

Yes 😂

restive otter
#

weird, I never used pycharm xd

sullen nymph
#

Ah

#

Do you think this could be made class-based?

restive otter
#

Sure, I've been thinking of that. Working with raw data isn't newbie-friendly ig. And, also it'd be good if the intellisense tells you what fields it has.

sullen nymph
sullen nymph
#

Rename or abuse Python?

#
    def __init__(self, bot_id: int = None, widget_format: str = "png", widget_type: str = ""):
        super().__init__()
        self.id = bot_id
        self.format = widget_format
        self.widget_type = widget_type
``` 👀
restive otter
#

Ig it's fine as they're just attributes. You aren't shadowing the built-in functions

#

Does it still complain if it was a property instead?

#

ah nevermind lmao

#

It was pointing to the parameter lol

sullen nymph
#

KEKW ya

restive otter
sullen nymph
#

Ya, true

#

Oh well, why bother renaming them

restive otter
#

Hell yeah abzoomeyesse it KEKW

sullen nymph
#

KEKW Time to just silence warnings about shadowing built-in names

#

Now, I'm wondering if I should add both colours and colors as parameters and then check if either was specified with colors taking priority

#

Scrap colours because colors is superior

restive otter
#

What about ```py
def init(self, **kw):
self.colors = kw.get('colors', kw.get('colours', {}))

@property
def colours(self): return self.colors

sullen nymph
#

Intellisense is lost that way, isn't it?

#

Though I mean, it's literally a dictionary... 02derp

restive otter
#

But, intellisense does show the docstring, doesn't it?

#

lmao, it's flattened blobweary

loud token
#

also shivaco and norizon, with topggpy 1.0.1

bot.topgg = topgg.DBLClient(bot, DBL_TOKEN)

returns autopost must be activated if autopost_interval is passed

restive otter
#

That's fixed in the master branch

#

For now, if you want to autopost, then explicitly pass True to autopost parameter. Otherwise, pass 0 to autopost_interval

loud token
#

That's what I do, just letting you know

restive otter
#

Yeah, we're aware and it's fixed, thanks though

loud token
#

so ig it still has some bugs

sullen nymph
#

Oh it's not on pypi is it

loud token
#

nope

sullen nymph
#

New version will be released like today-tomorrow very likely

loud token
#

nice ty

restive otter
#

I wrote the examples by hand, you'd better check it, shiv lol

sullen nymph
#

LMFAO will do once I'm back on my laptop

restive otter
#

Didn't touch the manual posting though, as it's pretty much identical ig

sullen nymph
#

Will change them once I'm done with the WidgetOptions class

green mantle
#

space separated = when in conjunction with type hints

restive otter
green mantle
#

😌

sullen nymph
#

😂

restive otter
#

loop.create_task exists in earlier versions though

sullen nymph
#

Oh yeah

restive otter
#

I'm not sure but it's at least supported since 3.5

sullen nymph
#

Yeah, no worries then

sullen nymph
#

@restive otter Is there any better way of doing widgetoptions test you can think of?

restive otter
#

How is WidgetOptions written?

viscid cloud
#
const Topgg = require("@top-gg/sdk")
const express = require("express")

const app = express()

const webhook = new Topgg.Webhook("xxxxx")

app.post("/dblwebhook", webhook.listener(vote => {
    // vote will be your vote object, e.g
    console.log(vote.user) // 395526710101278721 < user who voted\

    // You can also throw an error to the listener callback in order to resend the webhook after a few seconds
}))
app.listen(80, function () {
    console.log("Server is running on localhost80");
});```
From where can i get Topgg.Webhook?
night ingot
#

First of all, you can't use port 80 for webhooks
And you set the webhook auth yourself on your bot's webhook page

serene dagger
#

guys how can i make a webhook i wanna make a vote rewards for my bot i use (python)

#

🙂 pls help me

restive otter
#

You might want to do bot.loop.create_task(bot.topgg_webhook.run(5000)) instead of bot.topgg_webhook.run(5000)

sullen nymph
# restive otter How is WidgetOptions written?
class WidgetOptions(dict):
    id: Optional[int]
    format: str
    type: str
    noavatar: bool
    colors: _Colors

    def __init__(
        self,
        id: int = None,
        format: str = None,
        type: str = None,
        noavatar: bool = False,
        **kwargs,
    ):
        self.id = id
        self.format = format or "png"
        self.type = type or ""
        self.noavatar = noavatar
        self.colors = kwargs.get("colors", kwargs.get("colours", {}))
        super().__init__(id=id, format=format, type=type, noavatar=noavatar, colors=self.colors)

    def __getitem__(self, item):
        return getattr(self, item)

    def __setitem__(self, key, value):
        setattr(self, key, value)

    @property
    def colours(self):
        return self.colors

    @colours.setter
    def colours(self, value):
        self.colors = value
#

Could've just sent the edited client.py rn instead of copy pasting that

restive otter
#

Is it necessary to implement __getitem__ and __setitem__? Doesn't the dict implement it already?

sullen nymph
#

I don't think it introduces items as attributes?

#

My tests pass at least 🤣

restive otter
#

Also, take a look at this, it'd have different values

sullen nymph
#

wtf

#

Oh

#

I'm dumb

restive otter
#

What about this ```py
class WidgetOptions:
id: Optional[int]
format: str
type: str
noavatar: bool
colors: _Colors

def __init__(
    self,
    id: int = None,
    format: str = None,
    type: str = None,
    noavatar: bool = False,
    **kwargs,
):
    self.id = id
    self.format = format or "png"
    self.type = type or ""
    self.noavatar = noavatar
    self.colors = kwargs.get("colors", kwargs.get("colours", {}))

def __getitem__(self, item):
    return getattr(self, item)

def __setitem__(self, key, value):
    setattr(self, key, value)

def items(self):
    return self.__dict__.items()

def values(self):
    return self.__dict__.values()

def keys(self):
    return self.__dict__.keys()

@property
def colours(self):
    return self.colors

@colours.setter
def colours(self, value):
    self.colors = value
sullen nymph
#

I'm calling super().init with the parameters instead of the fields

restive otter
sullen nymph
#

Why reimplement those? k3llyhmm

restive otter
restive otter
sullen nymph
#

There's the option of handling None in the generate_widget method

sullen nymph
#

Just curious

restive otter
sullen nymph
#

OH

restive otter
#

It doubles the data, and once you edit some attributes, the dict values won't get updated

#

If you want to subclass dict, you can instead implement a __getattr__ method

#

It'd get invoked if the attribute doesn't exist, so it can instead subscript itself with the attr name

sullen nymph
#

if the attribute doesn't exist
Hm

restive otter
#

dicts don't have id, format, etc. so that'll work just fine ig

sullen nymph
#

getattribute is invoked before looking at the actual attributes on the object, and so can be tricky to implement correctly. You can end up in infinite recursions very easily.

#

👀

restive otter
#

Yeah, that's why it should implement __getattr__ instead

sullen nymph
#

Why not use __getattribute__ with getattr?

restive otter
#

Something like this ```py
class WidgetOptions(dict):
def init(
self,
id: Optional[int] = None,
format: str = None,
type: str = None,
noavatar: bool = False,
**kwargs,
):
super().init(id=id, format=format or "png", type=type or "", noavatar=noavatar, colors=kwargs.get("colors", kwargs.get("colours", {})))

def __setattr__(self, key, value):
    self[key] = value

def __getattr__(self, key):
    return self[key]

@property
def colours(self):
    return self.colors

@colours.setter
def colours(self, value):
    self.colors = value
#

Not sure if this way the intellisense would work properly though

sullen nymph
#

It probably wouldn't

restive otter
#

Also, what's awkward is, it'd raise KeyError if you accessed non-existing attributes KEKW

sullen nymph
#

That's gonna be fun to debug

restive otter
sullen nymph
#

I'm thinking of something, sec

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

    def __getitem__(self, item):
        return getattr(self, item)

    def __setitem__(self, key, value):
        setattr(self, key, value)

    def __setattr__(self, key, value):
        self.__dict__[key] = value
        setattr(self, key, value)

    @property
    def colours(self):
        return self.colors

    @colours.setter
    def colours(self, value):
        self.colors = value
#

What do you think?

#

Oh, sec

#
    def __setattr__(self, key, value):
        if key == "colour":
            key = "color"
        self.__dict__[key] = value
        setattr(self, key, value)
#

Plural, yeah

restive otter
#

What's the superclass though?

sullen nymph
#

You get the idea

#

superclass is dict, isn't it?

restive otter
#

self.__dict__[key] would set it as the dict's attribute instead of putting it as key

sullen nymph
#

Oh, interesting

#

How come? k3llyhmm

#
RecursionError: maximum recursion depth exceeded
#

What do you know KEKW

restive otter
restive otter
sullen nymph
#

Yup

restive otter
#

These are identical though

sullen nymph
#

Give me like 30 minutes

restive otter
restive otter
sullen nymph
#

Ohhh

#

Now I get what you mean

#

Good fucking lord I feel so dumb KEKW

#

@restive otter

class WidgetOptions(object):
    id: Optional[int]
    format: str
    type: str
    noavatar: bool
    colors: _Colors

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

    def __getitem__(self, item):
        return getattr(self, item)

    def __setitem__(self, key, value):
        setattr(self, key, value)

    def items(self):
        return self.__dict__.items()

    def values(self):
        return self.__dict__.values()

    def keys(self):
        return self.__dict__.keys()

    def __setattr__(self, key, value):
        if key == "colours":
            key = "colors"
        super(__class__, self).__setattr__(key, value)

    @property
    def colours(self):
        return self.colors

    @colours.setter
    def colours(self, value):
        self.colors = value

So this should be good?

restive otter
#

um, the __setattr__ is redundant imho

sullen nymph
#

lmfao true

restive otter
#

Because colours got a setter, so it'll work just fine.

#

Btw, you can make a Base Class that implements these methods

sullen nymph
#

BaseWidget?

restive otter
#

So that if you're planning to make classes for the data returned from the API, it can inherit it instead

sullen nymph
#

At this point I should probably move it to a new file types.py imo

restive otter
#

Uh, not only for Widget. Like it can have a from_dict class method, and then calls obj.__dict__.update(data)

#

Yeah

sullen nymph
#

Hmm... I'm really unsure of what I can name it tbh

#

If not something like DBLDataDict or just DataDict

#

DataDict sounds better, I think

restive otter
#

Yeah up to you xd

sullen nymph
#

I'm bad with naming stuff lmao so DataDict is it

restive otter
#

If you do obj["non_existing_key"], it'd raise AttributeError instead of KeyError, would it be better for __getitem__ to do self.__dict__[key] instead?

sullen nymph
#

Yeah, might be a better idea lol

#

Actually, I'm curious about from_dict. Why not use __init__ to create it?

restive otter
#

Oh yeah sure, the __init__ can take the dict from the API. I forgot that the users are not supposed to instantiate it.

sullen nymph
#

@night ingot You mind? 😛

night ingot
#

Keep the channel on topic, please :)

restive otter
#

Hm, ig the __init__ isn't necessary, is it? I'd let the subclass implement its own __init__. Cuz you wanna cast some objects to a different type. For instance, the date to a datetime object, the id to int

#

That DataDict class is inherited so that the subclasses become dict-like objects. That way it won't be a breaking change as the users can access it as if it was a dict.

night ingot
#

Second warning, cut it out

#

This channel is for API support, not random emojis

sullen nymph
#

More like you are trying to start an unnecessary argument

sullen nymph
restive otter
#

Yeah, even though it can still be called

sullen nymph
#

How much of a good idea is this?

class DataDict:
    def __init__(self, object_dict: dict, **kwargs):
        self.__dict__ = object_dict
        self.__dict__.update(kwargs)

😂

restive otter
#

I'd parse the data first

#

Like convert camelCased keys to snake_cased ones. Cast snowflakes as int, the date string as datetime object

sullen nymph
#

Hm

#

I'll implement a from_dict method instead of overriding init and do that in the func instead

#

Changing the typehints is gonna be fun

restive otter
#

I think of this like most of discord.py's objects where they can only be instantiated with the raw data from the Discord API

sullen nymph
#

That's pretty much what it's gonna be, but it will provide me convenient way to initiate it without having to worry about super().__init__

restive otter
#

I'm curious how that'd end up, looking forward to it

sullen nymph
#

This is gonna be a fun change

sullen nymph
#

Oh my dear lord converting camel case to snake case is a headache

restive otter
#

my quick approach xd

#

(?<!^)(?=[A-Z]) replaced with _ and then lowered is better ig

sullen nymph
#

I prefer to avoid regex here

restive otter
#

Oh well, ''.join(f'{"_"*(char.isupper() and idx != 0)}{char}' for idx, char in enumerate('isWeekend')).lower() lol

sullen nymph
#

What the actual fuck

restive otter
#

exdee, this one worth to have a test

sullen nymph
#

I'll try out the one I have rn and then test that

restive otter
#

pytest.parametrize goes brr

sullen nymph
#

Hm

austere oyster
#

I modified my poststats so that it only posts my server count, and in the logs it says error 400, what is the issue?

#

I'm using dblapi.js

#

nvm

young frost
#

how to make bot without library

#

like how to start making

rain heart
#

your bot needs a library

#

also

#

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

young frost
young frost
rain heart
#

it does

#

how's your bot going to interact with discord's api nonetheless

young frost
jovial kiln
#

@elfin solstice, seems as if there are still API issues with the GET /bots API endpoint with 504 time outs every time we attempt to do anything with that endpoint. Is there a chance there are still problems occuring?

#

Attempted without search parameters and got the same response.

willow sphinx
#

was this working before?

#

because I don't think it's been working for many many months

elfin solstice
#

@jovial kiln nope works fine for me

#

i get results without search query

pale fulcrum
#

pain

hearty lintel
#

with a search query it fails

elfin solstice
#

yea search query was broken for like 3 months already

#

i think

jovial kiln
#

oh

elfin solstice
#

and for now we most likely won't fix that

jovial kiln
#

So is there not a way to get all the bots for a certain user?

pale fulcrum
#

rip

green mantle
elfin solstice
#

i don't think so at the moment

#

its a thing we fix in v1 for sure

jovial kiln
elfin solstice
#

and v1 will start very soon (with limited functionality for now) since i'm working on it for an upcomming feature

green mantle
#

Sad You missed the implication of that

jaunty plank
#

pog

jovial kiln
#

ah yes, scraping pog

elfin solstice
#

user pages are dynamically loaded now so that will be quite hard

green mantle
#

for script kiddies sure

elfin solstice
#

we should probably stop the off-topic conversation in here and move memes to #general

hushed reef
#

Works with PHP when doing search query

hearty lintel
#

x

snow ruin
#

how do u make it so that whenever someone votes the bot gets triggered? LIke i mean I know that top.gg sends a post request to some url, but can the url be like localhost? or...

loud token
#

yeah

sullen nymph
#

It has to be IP address of the machine the webserver is hosted on

serene dagger
#

how to make a webhook idk how

snow ruin
sullen nymph
#

2 instances on the same machine means same IP

snow ruin
#

no but how bout different ips?

sullen nymph
#

Top.gg doesn't support multiple URLs for a bot/server so you'd need a system to cover that

fresh token
#

How to check if someone voted

open gull
fresh token
#

No.... I mean

#

How to make a bot detect

#

When they have voted

plucky lance
#

By using webhooks. See the pines messages. They contain a link to the docs.

serene dagger
#

hmm

torpid coral
#

Hello Guys, am i using api correctly ?

#

where can i find webhook password ?

plucky lance
#

You can define a password on the topgg site but you don’t have to.

sullen nymph
#

See the topggpy webhook instead

hearty wasp
#
import topgg

# This example uses dblpy's autopost feature to post guild count to top.gg every 30 minutes.

dbl_token = 'token'  # set this to your bot's top.gg token
bot.dblpy = topgg.DBLClient(bot, dbl_token, autopost=True)

@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}")```
#

Is this the correct way ?

restive otter
#

that'll autopost yeah, but the on_dbl_vote event won't fire as you need a topgg.WebhookManager object

restive otter
#

with what exactly?

serene dagger
#

it dosent print anything

#

when i type test

#

but its shows here

restive otter
#

What was the response status code?

serene dagger
#

there is no print

restive otter
#

Uh, is that flask?

serene dagger
#

not

restive otter
#

If you have installed topggpy from the pypi, your webhook won't even run

#

You need to do bot.loop.create_task(bot.topgg_webhook.run(5000)) instead

serene dagger
#

see

restive otter
serene dagger
#

oh mb

#

my bad

restive otter
serene dagger
#

yes

restive otter
#

I can't really help with that, but if you accessed the / route and it shows 404, then the webhook might be running. Try accessing /dblwebhook and see if it shows something else

serene dagger
#

ok

restive otter
#

It should show 405 if you GET request it iirc

serene dagger
#

ok

cloud hull
#

    const webhook = new Topgg.Webhook(processe.env.VOTE_AUTH)

    app.post(process.env.VOTE_PATH, webhook.listener(async (vote) => {
        const user = vote.user // User ID of the user who voted
        const guildId = vote.guild // The guild the user voted for
        const type = vote.type

        if(!guildId == config.guild)
        {
            return
        }


        console.log(`User ${user} has voted for ByteCode Studios`)

        const guild = await client.guilds.cache.get(guildId)
        const channel = await guild.channels.cache.get(process.env.VOTE_CHANNEL_ID.toString())```
#

will this work?

burnt brook
#

Hello guys

#

Give it a casinobot??

zenith elm
#

I have a question,the following is my code,but it doesn't give any error or response

@client.event
async def on_dbl_vote(data):
    print(data)
burnt brook
#

what must i pay who much is it?

night ingot
night ingot
#

That's not the only code you need for vote webhooks

#

Read the full docs

zenith elm
night ingot
#

No, it doesn't

restive otter
#

You can refer to topggpy instead, it uses a separate WebhookManager class for this

mental pumice
#

So i never actually tried something with webhooks tfkHide how am i getting a URL for the webhook?

night ingot
#

http://<your public ip>:<port>/<webhook path>

mental pumice
#

port and path can be whatever it wants to be? (ok obv the port needs to be open)

#

or what exactly is the webhook path? FeelsSmartMan

night ingot
#

You specify the path and port in your code, yes

mental pumice
#

so like http://340.34.5.33.2:5555/votes e.g.

night ingot
#

Yes

mental pumice
#

Ah i see thanks AlpakaSweet

orchid zodiac
#

Lmao I was about to ask the same question too

#

Thanks for the answer ee

chilly nova
#

how do i do a system where it dont require a webhook using discord.js for vote messages

night ingot
#

You can't listen for votes without a webhook

chilly nova
#

nvm I am gonna just use a webhook

#

its not hard anyways thanks

orchid zodiac
#

Hey guys, the on_dbl_vote event isn't working for some reason

#

I did everything right

rain heart
#

you need to use webhooks for it to work

#

read the docs

orchid zodiac
#

mate

#

i did everything

#

made webhooks, clients etc

#
from discord.ext import commands
import os
import dbl

#CODE BY WOOZY NOBODY TOUCH
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
        try:
            self.token = os.getenv("TOPGG_TOKEN")  # set this to your DBL token
            self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='0.0.0.0', webhook_auth='password', webhook_port=8080)
        except Exception as e:
            print(e)

    @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))```
#

this is my code

#

I'm using repl.it to host the beta bot right now

#

It doesn't even return any errors

night ingot
#

First of all, the webhook path isn't supposed to be an IP

orchid zodiac
#

Oh?

#

So then what shall I do

#

like /votes?

night ingot
#

For instance, yes

restive otter
night ingot
#

Second of all, you need to make sure you entered the correct URL on your webhook page, as well as making sure the port you're using is open on the network

orchid zodiac
#

I'm using 0.0.0.0:8080 the default of repl.it

night ingot
#

Well 0.0.0.0 isn't the public IP

orchid zodiac
#

IT WORKED

#

LESSS GOOO

#

LESS GO LMAO

#

thanks for the help

#

really appreciate it

restive otter
#
 const app = express() // Your express app
  
  const webhook = new topgg.Webhook('password') 
  
  app.post('/dblwebhook', webhook.listener(vote => {
    
    console.log(vote.user)
  })) 
  
  app.listen(3000) 
#

no error nothing happening

jaunty plank
fiery wraith
night ingot
#

You can't use the API until your bot is approved

restive otter
#

i did auth @jaunty plank

jaunty plank
#

need the url too

restive otter
#

but not webhookurl

jaunty plank
#

otherwise where will it send the request to

fiery wraith
jaunty plank
fiery wraith
#

i still dont understand the syntax

jaunty plank
#

of what? theres nothing unique to top.gg going on with the webhooks.

#

just basic http requests

fiery wraith
#

ohh

restive otter
#

@jaunty plank i created webhook and pasted webhook URL still same

jaunty plank
restive otter
#

@jaunty plank so how to get URL then

jaunty plank
#

welp, its the url to your webhook receiver.
so probably something like this.
http://YOURPUBLICIP:3000/dblwebhook
YOURPUBLICIP should be replaced with the public ip your express webserver can use.

#

if your using a host which only gives a url and not a ip you must use the url they give, with the path added at the end.

wet wing
#

hi, is it possible to test vote a bot not on top.gg?

zenith elm
#

Hello, is there a way to track votes without using cogs?

jaunty plank
#

where are you hosting?

#

home/vps/other

restive otter
#

heroku

#

but for now

#

on my pc

jaunty plank
#

so its hosted on your pc?

restive otter
#

yea

jaunty plank
#

youll need to use your public ip for your computers network, and port forward then

wet wing
#

how do you test vote ?

#

its moved since i last saw the button

jaunty plank
#

your bots edit page, webhook section, test

wet wing
#

does that do a vote? im not sure what it did

#
    async def on_dbl_test(self, data):
        print("Received a test upvote:", "\n", data, sep="")```
is this correct for receiving test vote notices?
restive otter
#

is there something can we do with port?

zenith elm
#

Hello, is there a way to track votes without using cogs? I'm Asking this twice

jaunty plank
zenith elm
#

Sigh

loud token
jaunty plank
loud token
#

If you want to know how, I know how

jaunty plank
#

that is his question, yes

loud token
#

I mean he just asked if there was a way

restive otter
zenith elm
loud token
#

I can tell you anywhere doesn't matter to me

restive otter
#
 const DBL = require('top.gg');
  const dbl = new DBL('myapitoken', { webhookPort: 5000, webhookAuth: 'password' });
  dbl.webhook.on('vote', vote => {
    console.log(`User with ID ${vote.user} just voted!`);
  });
#

nothing hapening

jaunty plank
#

also note, the top.gg library is deprecated, and may not function correctly.

restive otter
jaunty plank
#

hmm. then im out of ideas

restive otter
#

i can port forward 1pv4 ip but cant do my ip address

jaunty plank
#

when you port forward you should forward the port to your local machine.
https://portforward.com/ may be able to help more than i can.

restive otter
#

agh i am tired thank you so much for helping

jaunty plank
#

@brittle sail please dont post ads

orchid zodiac
sullen nymph
orchid zodiac
#

Hey guys

#

get_user_vote isnt working

#

It just returns False

#

even though we have voted

#

I use dblpy

sullen nymph
#

Wait a few minutes then try again

orchid zodiac
#
@commands.command(brief="utils", description="Upvote Proteus")
    async def vote(self, ctx):
        try:
            g = await self.dblpy.get_user_vote(int(ctx.author.id))
        except Exception as e:
            print(e)
        print(g)
        if g:
            vote = "You have already voted for Proteus! Check back later to vote again."
        else:
            vote = "[top.gg](https://top.gg/bot/809077913080299535)"
        embed = discord.Embed(
            title="Vote for Proteus",
            description=vote,
            color=ctx.author.color
        )
        await ctx.send(embed=embed)```
#

No exceptions are returned

sullen nymph
orchid zodiac
#

we did wait for some minutes

sullen nymph
#

Wait more

orchid zodiac
#

bruh alright

sullen nymph
#

The API can be slow in terms of user votes

orchid zodiac
#

oh

#

ok

sand nebula
#

im trying to get the user from webhook post request in php via $_POST['user'] but not working..

steady delta
#

autopost still not working?

teal matrix
#

Hi anyone here who knows how to add the server count to your bot page?

sullen nymph
restive otter
#

Is it okay when I post every 5 minutes my server stats guild without getting ratelimited?

#

Or when should I update my stats?

sullen nymph
#

5 minutes is fine

restive otter
#

kk thanks

#

When someone is voting can I receive this information?
(Java)

#

And when Im sending stats when should they update?

#

(on the website)

sullen nymph
sullen nymph
restive otter
#

I pushed

#

But here stays N/A

#

Posting like this:

List<Guild> guilds = jda.getGuilds();

discordBotListAPI.setStats(guilds.size());
sullen nymph
#

Something tells me that library either doesn't work or your code isn't working

restive otter
#

Hmm any way to check if library does not work?

#

Seems like the code does not execute... Im confused but I hope now it works

spice helm
#

When i did this i think it took a few minutes to come through first time, but you could always proxy it through something like burp to see what it's doing when it sends the request

restive otter
#

Is setStats async because it stops my code

fading inlet
#

Vote messages are not working for me since end of April

const DBL = require("dblapi.js");
const dbl = new DBL(topggToken, { webhookPort: 5000, webhookAuth: webHookPassword }, client);

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

When voting I do not receive any message anymore.

brittle spoke
#

use the new one in pins

fading inlet
#

Thank you

restive otter
vestal quartz
#

is this for discord api or dbl api or both

restive otter
#

(This channel)

vestal quartz
#

ok ty

steady delta
slim hemlock
#

hi

#

my ```js
const Topgg = require("@top-gg/sdk");
const express = require("express");
const app = express()
const DBL = require('dblapi.js');
const AutoPoster = require('topgg-autoposter');
const ap = AutoPoster(config.DBL_TOKEN, client)

const dbl = new DBL(config.DBL_TOKEN, { webhookPort: 5555, webhookAuth: '11211' });
dbl.webhook.on('vote', (vote)=>{

const eco = ecoschema.findOne({userID: vote.user.id})
const webhook = new Discord.WebhookClient('839215460624891915', 'OZ7wMQqK-wlzBlA33Lh0bwFYJvSAeXCQE_V_tcxBx1GRQEck5kRmxxZl_7hy--Fmx5Bb');
const voteembed = new Discord.MessageEmbed()
.setAuthor(`Thanks for Voting!`, client.displayAvatarURL())
.setDescription(`Thanks **${vote.user.tag}** for voting for Cyte Bot! \n You can vote again in 12 hours!\n [Click here to vote again!](https://top.gg/bot/754765403489828946/vote)`)
.setFooter("I have provided you your vote rewards successfully!")
.setColor("#0afa08")
webhook.send(`${vote.user}`, voteembed)
eco.money += Number(2000000)
eco.save()
vote.user.send(new Discord.MessageEmbed().setAuthor("Thanks for voting for me!", vote.user.displayAvatarURL({dynamic: true}))
.setDescription("I have successfully provided you `2,000,000` coins as your vote rewards!")
.addField("Please consider voting for me in the next 12 hours again!", `[Click here to vote again in the next 12 hours!](https://top.gg/bot/754765403489828946/vote)`)
.setColor("RANDOM")
)

})``` is not working, pls help