#topgg-api

1 messages · Page 172 of 1

restive otter
#

read that

half depot
#

im confused

#

i did read the docs

restive otter
#

@unborn sparrow

half depot
#

nvm somehow got it working

restive otter
wise violet
#

P!start

restive otter
#
@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."""
    data = int(data["monthlyPoints"])
    print(data)```

Is  that right to get the monthly vote count?
#

i dont understand the docs

restive otter
#

can anyone help me to understand? :/

rain heart
#

monthylPonumbers?

#

lol

#

actually says PoNumbers dafuq

#

Can assure you its monthlyPoints

willow sphinx
#

lol

rain heart
#

check the pr xetera kekw

#

Yeah was present since the init commit KEKW

#

Love how nobody noticed that

#

@restive otter try using monthlyPoints instead of monthlyPonumbers, was a typo in the docs

restive otter
#

ok

restive otter
#

Note that you shouldn't instantiate the client multiple times, so don't do it inside the command callback

#

ahhhh thanks

#

Op, the key is also converted to snake case, so it's data["monthly_points"] if you were to get it using that syntax

topaz mural
#

i still haven't understood

forest trench
#

Do you know what a webhook is?

topaz mural
#

nope

#

apart from the discord channel webhook (e.g. github)

#

is it that?

forest trench
#

Well, you need to know what that is first, unless you won't understand

topaz mural
#

well, what is it

#

i see this

#

but idk what to do with it

forest trench
#

A webhook in web development is a method of augmenting or altering the behavior of a web page or web application with custom callbacks.

topaz mural
#

a webhook is a url to which it sends a post request

#

i get that

#

but what do i do in this specific top.gg case

forest trench
#

So basically it sends stuff through internet from 1 place to another

topaz mural
#

i get that

forest trench
#

Now where are you hosting ur bot

topaz mural
#

just a python script

#

i mean, replit.com if it matters, but i don't think it does

#

and sometimes on my pc when i'm developing it

forest trench
#

does it have a custom ipv4 address for u app

topaz mural
#

it should do, yes

forest trench
#

Are u sure

topaz mural
#

yep

#

wouldn;t that require me to open a port though

forest trench
#

Ok, then use this example link, but replace the things inside with ur actual things

forest trench
topaz mural
#

where link

forest trench
#

You have to port forward whatsoever ever

topaz mural
#

where link tho

forest trench
#

Wdym link

forest trench
topaz mural
#

ok, so whats route

#

and is this automatically opened by the top.gg python library

forest trench
#

What

topaz mural
#

wdym

forest trench
#

Wdym by automatically opened

rain heart
#

route is the path of your webhook

topaz mural
#
import topgg
bot.topggpy = topgg.DBLClient(bot, dbl_token)

@bot.event
async def on_dbl_vote(data):
  print(data)```
rain heart
topaz mural
#

ok, thats all fine, but that is never mentioned in the topgg library docs anywhere

#

it says create bot.topggpy with an instance of DBLClient

#

and then simply use that event

#

it shouldn't require me to use a webhook, no? that would make me manually have to process events

sullen nymph
#

Which docs are you looking at?

topaz mural
sullen nymph
#

Link

forest trench
#

top.gg.DBLClient is exactly the same as commands.Bot in d.py, its not for getting data, webhooks are for getting data

sullen nymph
#

WebhookManager is what you need

forest trench
#

^

topaz mural
#

oh wow, i'm stupid

sullen nymph
#

I'm not sure where you got that outdated example from

topaz mural
#

i just used the bot.topggpy = DBLClient as shown under Examples on the Python page on docs.top.gg

#

under Manual server post count

#

without realising i needed something else for vote events

forest trench
#

Brb

sullen nymph
#

Ah

#

No worries then

topaz mural
#

:)

#

thank you

#

thank you so much you guys, it works!!

#

i am stupid

astral basin
#

How do I make the bot send a message when someone gives vote

#

i need a Code for NodeJS

slow sonnet
tidal idol
restive otter
astral basin
#

ok

jaunty plank
#

The url to the webhook listener. Depends on where the server is

#

Like vps/replit/heroku/home etc

#

http://yourvpsip:80/webhook

zealous blaze
#

My server doesnt show when i try to put it on top.gg what do i do?

#

it works now

jaunty plank
#

The authorization on the page you found the url

#

Like the url field, below that it says authorization

#

You are the one that decides it. It just needs to be the same on the site and your code

rain heart
#

try it and see

tidal idol
restive otter
high leaf
#

I set the correct http://ip here:port/dblwebhook but it seem to not be working

#

Ok i fixed, I was using my bot’s token/api key instead of the authorisation string.

loud gust
#

What do i type here if i want my bot to take the token from env file

#

Gives me error with that

#

Ah got it forgot it was "or empty string" with TS

plucky lance
#

🤦‍♂️

bleak condor
#

sorry for mention

rough crater
#

@bleak condor please dont ghost ping

#

and only ping one moderator ty

bleak condor
#

it was hacking link

#

sorry bro

rough crater
#

Yeah, one moderator can handle the issue

bleak condor
#

ok

restive otter
#

yo how can I get my top..gg token?

restive otter
tidal idol
restive otter
blissful belfry
#

Why I have this error?

#

aiohttp.http_exceptions.BadStatusLine: invalid HTTP method

#

I use http (not https)

#

code:

restive otter
blissful belfry
#
from discord.ext import commands
import discord
import asyncio
import topgg


class TOPGG(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "psw")
        bot.topgg_webhook.run(5000)

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

def setup(bot): 
    bot.add_cog(TOPGG(bot))```
tidal idol
blissful belfry
#

and the setting

blissful belfry
#

If I use curl, that work

#

but why with top.gg, that not work?

zinc moat
#

@rough crater

#

hello i am turkish i want to be turkey support team what should i do

tidal idol
#

for what

#

also i think you have the wrong channel - this is for the top.gg api

blissful belfry
#

pls help me lol
why when I do ```py
curl -d '{"user":"640518207257444374", "bot":"893494390142697493"}' -H "Authorization: token" -X POST http://ip:5000/dblwebhook

 it works but not with top.gg
#

token = password that I choose

#

ip = ip du vps (not localhost ip)

placid loom
#

I can't get the voting information

const webhook = new Topgg.Webhook('PASS')
router.post('/vote', webhook.listener(vote => {
    console.log(vote)
}));

Result :

{}

I would just like to get the id

placid loom
jaunty plank
#

using the top.gg vote button? or test? or postman/etc

jaunty plank
#

you may want to try without using the webhook listener middleware.

router.post('/vote', function (req, res) {
    console.log(req.body)
}));
potent prawn
#

anyone know how to show bot statistics in top.gg page python

blissful belfry
jaunty plank
placid loom
jaunty plank
#

trying to see if others have your same issue

blissful belfry
#

no, no event detected

placid loom
blissful belfry
#

oh

#

If I launch curl command with not data

#

He not detect

#

It is possible that we have the same problem

jaunty plank
blissful belfry
#

I launch that

jaunty plank
#

deleted because ip leak

blissful belfry
#

oh thanks^^

jaunty plank
#

using the js library too?

blissful belfry
#

if I remove the body directly, I get an internet error

blissful belfry
#
500 Internal Server Error

error

#

but

#
500 Internal Server Error
#

not error

#

but not detect

jaunty plank
#

just to double check, you are hosting on a vps right? @blissful belfry

blissful belfry
#

yes

jaunty plank
#

are you running your curls locally?

#

ie on the same server the webhooks on

#

or on your computer

blissful belfry
#

I launch curl on my computer, and send request to ip of my vps

#

not localhost

#

You can test if you want lol

#

(but mp)

jaunty plank
#

so curl isnt being used from ssh?

blissful belfry
#

yes

jaunty plank
blissful belfry
#

curl on my computer -> webhooks on my vps

#

not same network

#

so it's not in localhost

#

I can give you the order if you want (in mp) to prove you

jaunty plank
#

yeah, just needed to double check.

it does seem to be top.gg's side, but its weird its only you two.

#

We dont have this issue known anywhere, so I'm kinda stumped.

blissful belfry
#

I have send mp :p

jaunty plank
#

@placid loom hey, we may have found it.
does your authorization have any characters with accents in them?
such as é.

#

it seems accented characters mess with the request

placid loom
restive otter
#
@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."""
    user = client.get_user(int(data["user"]))
    guild = client.get_guild(811730903482761246)
    channel = guild.get_channel(840666055777058836)
    astra = client.get_user(int(data['bot']))
    embed = discord.Embed(title="Test Vote successfull ", description=f"![vote](https://cdn.discordapp.com/emojis/901962581760159744.webp?size=128 "vote") ``{user}({user.id})`` voted up for {astra}\n\nYou can vote **[here](https://top.gg/bot/811733599509544962/vote)** every 12 hours.", colour=discord.Colour.red(), timestamp=datetime.utcnow())
    embed.set_thumbnail(url="https://media.discordapp.net/attachments/813029623277158420/901963417223573524/Idee_2_blau.jpg")
    embed.set_footer(text="Thank you for your Support", icon_url="https://media.discordapp.net/attachments/813029623277158420/901963417223573524/Idee_2_blau.jpg")
    await channel.send(embed=embed)```

why is the member None?
#

on my other bot, it still works

#

is it because my bot was added today?

visual relic
#

syntax should be user , tho the () should have a link

restive otter
#

this is my other bot, where the same code works fine

visual relic
#

oh that

#

how did that no give any error then damn

#

cause if user is none then it should have given attr error when using .id

restive otter
#

uh wait not i get an error

#
Ignoring exception in on_dbl_test
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "/home/container/bot.py", line 114, in on_dbl_test
    embed = discord.Embed(title="Test Vote successfull ", description=f"![vote](https://cdn.discordapp.com/emojis/901962581760159744.webp?size=128 "vote") ``{member}({member.id})`` voted up for {astra}\n\nYou can vote **[here](https://top.gg/bot/811733599509544962/vote)** every 12 hours.", colour=discord.Colour.red(), timestamp=datetime.utcnow())
AttributeError: 'NoneType' object has no attribute 'id'````
#

which dont helps me

visual relic
#

that is indeed true

restive otter
#

i mean the same code is working fine on my other bot

#

thats why i dont understand why the bot cannot get the user

#

can it be because i dont have intents=discord.Intents.all in my client = commands.Bot?

#

or something else like that

visual relic
restive otter
#

idk it was just a idea

#

lul

visual relic
#

but u can go ahead and try

restive otter
#

but why? when you say that discord and top.gg are different things, intents can be the problem lol? that dont makes sense

visual relic
#

oh nice

#

tbh i have no clue too

#

but as long as it works

#

why care

restive otter
#

but thanks for your help haha

visual relic
#

wlcm

restive otter
#

have a nice day :)

visual relic
#

you too :D

restive otter
#

^^

potent prawn
iron viper
#

what should the webhook be? can it be discord webhook?

iron viper
sullen nymph
#

You don't use the members intent, hence no member objects are cached, meaning get_member will return None

tidal idol
white bison
#

why isn't my on_dbl_vote event getting called?

import topgg
from discord.ext import commands
import logging

logger = logging.getLogger('apollo')

class TopGGCog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.topgg_token = ""
        self.client = topgg.DBLClient(bot, 
                                        self.topgg_token, 
                                        autopost=True, 
                                        post_shard_count=True, 
                                        session=bot.session)
        self.webhook_manager = topgg.WebhookManager(bot)
        self.dbl_webhook = self.webhook_manager.dbl_webhook("/dblwebhook", "")
        self.dbl_webhook.run(5000)

    @commands.Cog.listener('on_autopost_success')
    async def on_autopost_success(self):
        logger.info("Autoposted guild and shard count.")
    
    @commands.Cog.listener('on_dbl_vote')
    async def on_vote(self, data):
        logger.info("Received vote: {data}")```
#

the on_autopost_success event is getting called tho

rain heart
#

have you set your webhook on top.gg?

white bison
#

yes

potent prawn
rain heart
#

test it using postman

rain heart
potent prawn
#

wait where

rain heart
potent prawn
#

ok lemme look

white bison
rain heart
#

try making a test vote

white bison
#

but I don't get the info from the logging module

potent prawn
raw raven
#

hi, guys , need help! Using webhooks I can receive event when click "test" button in dashbord on top.gg, but can not receive any callbacks when vote in bot page.

rain heart
#

both of you try using postman or reqbin to test the request

#

Have you setup your webhook listener correctly?
Do you have an active connection listening to requests?
Is the webhook somewhat hindered by a firewall?
You could test webhooks with one of the following tools to make sure they work:

  • reqbin
  • postman

if you're not sure about any of these, nor about what any of the tools mentioned above are useful for, I'd suggest reading over https://sendgrid.com/blog/whats-webhook/

raw raven
#

I can receive callback when click "test" button on top.gg dashbord, but I can't receive any callback when voted on botpage.

#

please help

rain heart
#

see above

raw raven
#

@rain heartI made test vote and it works, but real vote on bot page can not work

rain heart
#

try making a vote using reqbin or postman

white bison
#

this is a bearer token?

rain heart
#

no

#

a simple authorization string

tawny blaze
#

but still it dont work in mine

#

and also m using repl

#
const webhook = new Votegg.Webhook('here my pass')
const app = express()

app.post('/dblwebhook', webhook.listener(vote => {
   console.log(vote.user)
}))```
raw raven
#

@tawny blazeI fixed the problem, we can only receive callback when user vote your bot or server, not rating

tawny blaze
#

as i tested with my webhook

#

nothing happened...

raw raven
#

@tawny blazedid you set Webhooks in your dashbord in top.gg?

tawny blaze
#

yep

#

as m on repl

#

so i have to add the webhook URL of my repl link na?

#

@raw raven

raw raven
#

yes, you have to

rain heart
#

I again suggest testing it with postman or reqbin

tawny blaze
#

but still...

raw raven
#

try this

#

the url should be accessable

rain heart
#

without the : 80

tawny blaze
#

http compulsory or any?

rain heart
#

because thats http basically

#

http is required

#

as the webhook is a "web" hook

tawny blaze
#

https

#

🙂

#

lemme try again..

rain heart
#

https wont work if you're using a basic webhook

#

unless it is proxied, which it is in repl's case iirc

tawny blaze
#

yea

#

m using repl

#

so will it work?

rain heart
#

You'll have to figure out your repl url

tawny blaze
#

and wht abt the :3000?

#

should i put it or not?

tawny blaze
rain heart
#

:3000 wont be needed

#

iirc repl provides a web-based port for you

#

You'll have to read the docs on their end for that

tawny blaze
#

uff

#

i have no idea now

#

how to make mine work now..

#

🥲

rain heart
tawny blaze
#

so the whole means

#

i have to use

#

0.0.0.0:8080

#

?

#

for repl

rain heart
#

there's no port definition on repl

#

it uses a proxy to force every 80 port on your repl url

tawny blaze
#

so it is somewhat impossible on repl?

#

to track votes?

rain heart
#

so you'd need to set your port to 80, define a endpoint, then your webhook url would be [yourrepl].[yourname].[repl].[co]

#

it is not, just you not being able to understand how repl works

tawny blaze
#

yea bcoz the hosting i was using

#

shutted due to some reason

#

so m not so experienced on repl

tawny blaze
#

its like u get it by creating a file

#

server.js

#
const server = express();
 
server.all('/', (req, res) => {
  res.send(`OK`)
})
 
function keepAlive() {
  server.listen(3000, () => { console.log("Server is Ready!!" + Date.now()) });
}
 
module.exports = keepAlive;```
#

so what now with the [yourrepl].[yourname].[repl].[co]?

tawdry shadow
#

hello how to make vote listener

#

?

tidal idol
restive otter
fluid violet
#

Hey, this is the topggpy support server?

plucky lance
#

There's nothing you can trigger or do by using a command at all.

#

So.. what are you actually trying to do then?

restive otter
#

i'm trying to make a special command for the one who voted

plucky lance
#

Well then you have to receive the requests if someone has voted and need to store this data (the user ID) in your environment, speaking about a database.

#

If somebody is running your command, you gonna query your database and check if the user is in the list.

#

You could manually send a request to the API to check if a specific user ID has voted in the last 12 hours.

#

But that might result in spam if more and more people are using the command.

restive otter
#

So what method would you recommend

fluid violet
glad merlin
#

I cannot get post request even though I turned off my firewall. You have any idea why this happens?

plucky lance
glad merlin
jaunty plank
glad merlin
#

no

jaunty plank
#

You'll need to from home networks

#

http://portforward.com/
Has guides for most routers

Port Forward

A port forward is a way of making a computer on your home or business network accessible to computers on the internet even though they are behind a router. It is commonly used in gaming security camera setup voice over ip and downloading files.

plucky lance
#

Taking the webhook code as example to store vote.user in your database.

#

As well as a timestamp to make sure later, the user has voted within the last 12 hours.

glad merlin
#

😮‍💨

jaunty plank
#

If its on your home network and you want to recive votes from topgg yes

#

If you only want to recive tests from the same computer then no

glad merlin
#

It seems not working with port forwarding either

plucky lance
#

Well if you setup port forwarding properly and added a rule for your firewall and it's still not working, you may not have a public accessible IPv4 address.

glad merlin
plucky lance
#

Caused by ISPs nowadays using DS Lite to tunnel your IPv4 for internal identification

#

You better not use port 80 at all

glad merlin
#

I tried it with 3000 also

plucky lance
glad merlin
#

ipv6

#

here shows ipv4 also

plucky lance
#

You don't have a public accessible IPv4 address then.

glad merlin
#

:(

plucky lance
#

There's actually no ISP I know supporting port forwarding for IPv6 yet, in 2021

glad merlin
#

I guess I will write the code hoping it works properly on actual bot KEKW

plucky lance
#

Yeah servers do have a (static) public address.

glad merlin
#

yep

plucky lance
#

No port forwarding but setting up firewall rules can still be a thing.,

#

If the default input policy is drop.

glad merlin
#

anyways, thanks for help

#

❤️

plucky lance
#

np

icy mulch
#

how do i make a server on top.gg and when they vote for the server it will send in a webhook?.

jaunty plank
true brook
#

thx so much

tidal idol
#

so what language @undone crane

undone crane
#

uh java, but why is this relevant

#

i'm only asking if there is an endpoint to get the users who voted on my bot

tidal idol
tidal idol
#

is the last 1k people ok?

undone crane
#

oh found it

tidal idol
undone crane
#

thanks

fossil mural
#

do I need to have webhook and thing to update joined server details?

jaunty plank
fossil mural
toxic temple
#

i

restive otter
#

@toxic temple

#

how u

#

have born date

#

in status

sullen nymph
#

how u

#

not read

#

channel topic

forest trench
opaque bison
#

heroku requires us to run a web dyno in order to listen to web hooks
right?

#

or can i just make do with worker

#

i tried a lot but it seems to not work without a web dyno if anyone knows a way around it hit me up

toxic temple
spiral matrix
#

@rain heart

rain heart
#

discord

#

dum

spiral matrix
#

And another

#

Damn

open coral
#

I'd like to include a counter of the servers the bot is in but I don't know how

woeful prairie
#

Api always returns status 401, I tried resetting the token also

reef fjord
#

I actually posted server count using top.gg API but it gives an error topgg.error.Unauthorized: Unauthorized (status code: 401)

tawny blaze
#

i hosted my bot by repl

#

and putted the webhook url as the url provided by the repl

#

and added in the code

#

but when i send a test

#

it doesnt do anything

ivory galleon
#

Im a little bit confused, when posting to the API, do I do it on one shard or on all of them?

#

I feel only one but idk

stray anvil
#

How does the guild count work with multiple shards? Each shard is posting the total number of guilds for the whole bot, but top.gg seems to be doubling the number I send.

devout musk
harsh terrace
#

can anyone help me out like please telll where i am missing

sullen nymph
#

Your class is named discordbotlists, but you try to refer to a class named TopGG

slow sonnet
# devout musk

this is because you need to have an authentication token.

#

your http header must have

{
  "Authorization": "your-topgg-token-here"
}
rain heart
tidal idol
#

@jagged nimbus here

jagged nimbus
#

Ok

tidal idol
jagged nimbus
#

Ohhhh

tidal idol
raw bough
jagged nimbus
#

I want to

raw bough
jagged nimbus
#

I will reward them with my economy system....it is a bit childish but... 😶

tidal idol
#

What language?

jagged nimbus
jagged nimbus
raw bough
jagged nimbus
tidal idol
jagged nimbus
tidal idol
#

@jaunty plank is great at API stuff, might be worth asking him

#

I’m not sure sorry

restive otter
#

is scraping the api for bot ids against tos on discord and top.gg?

tidal idol
#

IIRC it’s seen as abusing the API

#

Not 100% sure, @rain heart can you confirm?

rain heart
#

Not in particular, but not wanted either

reef fjord
#

Topgg API is throwing error 401

#

When I tried to post server count

plucky lance
#

You aren’t authorized then

restive otter
#

isnt that 403?

plucky lance
#

you need to send your topgg along with the header

plucky lance
restive otter
restive otter
plucky lance
#

A proper endpoint requiring an authorization will at first check if you’re authorized or not returning a 401 if not before restricting access to the resource returning a 403

#

According to the RFC

rain heart
jagged nimbus
light cosmos
tidal idol
light cosmos
tidal idol
#

replace botid with your bots id

light cosmos
tidal idol
light cosmos
#

When I click 404 come

tidal idol
#

what is your bot's user id

#

-bots 777146453201911808

#

nope

light cosmos
#

900997029197656085

#

@tidal idol

tidal idol
#

you can't access that until your bot is approved/declined i don't think

light cosmos
#

403

jaunty plank
#

Yeah webhooks cannot be accessed on unapproved bots

craggy grove
#

is dblapi.js not a thing anymore? my bot keeps logging the warning
[dblapi.js autopost] The provided client is not supported. Please add an issue or pull request to the github repo https://github.com/top-gg/dblapi.js

distant oak
#

I still use dblapi.js and everything works fine

craggy grove
#

hmmm

#

weird

jaunty plank
#

Dblapi.js is super out of date

#

It's been deprecated for atleast 8 months maybe a year

craggy grove
#

oh man lol

#

is there a new package i can use?

distant oak
#

Yes but it works MiaoussShrug

#

Yup

jaunty plank
craggy grove
#

thanks 🙏

jaunty plank
craggy grove
#

it does actually

jaunty plank
#

Hmm intresting

distant oak
#

It does work

craggy grove
jaunty plank
#

It's very diffrent in terms of code

craggy grove
#

gotcha

jaunty plank
#

It's a lot better though

#

Easier to use and debug in the event of an issue

craggy grove
#

oh nice that sounds useful

#

thanks for the help

devout musk
plucky lance
#

It needs to be added to the website and approved

craggy grove
#

when setting my webhook url, do i need to use the webhook url template provided in the docs? the one thats http://your.ip.here:port/dblwebhook

#

asking bc i cant really get it to work, so i want to use an existing ngrok subdomain i have instead

torpid lintel
#

i make a vote log but i also want to add total votes of voted member how i can ?

jaunty plank
versed junco
#

To update my bot I use the stats api. How does the api know I’m not doing a fraudulent number. Meaning if I do 10000 how does it know if it’s legit or not?

rain heart
#

the api doesn't know, though we see you doing that, kindly ask to set it to the correct number

#

otherwise your api access will be removed

reef fern
#

Excuse me, is there a way to remove the stats?, I'm using @top-gg/sdk

tawny blaze
#

i hosted my bot by repl
and putted the webhook url as the url provided by the repl
and added in the code
but when i send a test
it doesnt do anything

rain heart
# tawny blaze i hosted my bot by repl and putted the webhook url as the url provided by the re...

Have you setup your webhook listener correctly?
Do you have an active connection listening to requests?
Is the webhook somewhat hindered by a firewall?
You could test webhooks with one of the following tools to make sure they work:

  • reqbin
  • postman

if you're not sure about any of these, nor about what any of the tools mentioned above are useful for, I'd suggest reading over https://sendgrid.com/blog/whats-webhook/

rain heart
#

Wait for someone who can help

#

getting attention in different channels does not change

tawny blaze
#

as its a repl project

rain heart
#

Test your webhook using reqbin

#

or postman

tawny blaze
#

how to do that?

rain heart
#

visit these sites and enter your repl webhook url and make a test request

tawny blaze
#

kk

tawny blaze
#

as it said OK

rain heart
#

have you entered the correct url into top.gg?

tawny blaze
#

in the content when i putted by repl link and send it

rain heart
#

also try real voting instead of test

tawny blaze
#

like /dblwebhook

#

/voted

#

etc..

#

??

#

do i? @rain heart

rain heart
#

the path you set in your code

tawny blaze
#

ok..

#

can it be custom?

rain heart
#

of course

carmine fog
#

Webhook

rain heart
#

Updated for the new design: How to get your Top.gg token

  • Press the edit button on your bot page
  • Open the webhook section on the left menus
  • Press reveal (possibly required to first generate a token)
carmine fog
rain heart
#

What exactly do you need help with it

tawny blaze
#

@rain heart

#

it didnt work with real vote also..

#

😦

tawny blaze
#

is this the way to setup the listener?

#
   console.log(`Voted ${vote.user}`)
}))
rain heart
rain heart
#

reset your token please

carmine fog
rain heart
carmine fog
rain heart
#

There's everything provided on what exactly top.gg sends with your webhook, you can also use a library mentioned on the pinned messages

harsh terrace
#

please guide me where i am missin gout

rain heart
#

discordlists import doesn't exist

#

remove that

#

or you haven't installed it yet

harsh terrace
#

k

harsh terrace
rain heart
#

you'll also need to remove that line it is using

harsh terrace
#

its for server count on bot page

harsh terrace
#

so i hope it works

carmine fog
rain heart
#

Yeah you'll need to read the docs, making a webhook requires programming knowledge

rain heart
#

scroll up, already sent them

carmine fog
harsh terrace
#

is this the token of bot that i have putted in .env ?? so i need to replace its name instead of token i need to pu .env name right >?

#

or what i need to do

#

idk

#

@rain heart

rain heart
#

no clue about python, but I dont think set_auth is right

#

with the self.api

#

where's api coming from

harsh terrace
rain heart
#

wait nvm lemme check smth

#

remove self.api

harsh terrace
#

i took this thing from yt

harsh terrace
#

its in cogs

rain heart
harsh terrace
#

it

rain heart
restive otter
#

how do i get my api token?

tawny blaze
restive otter
#

im confused.

rain heart
#

read pins

tawny blaze
#

saw it?

rain heart
#

yeah that should work

#

if the authorization and the path is correct

restive otter
tawny blaze
#

yea it is

rain heart
#

and is the authorization correct aswell?

tawny blaze
#

yea

rain heart
#

and it is still not sending anything?

tawny blaze
#

const webhook = new Votegg.Webhook('here my auth') @rain heart

tawny blaze
rain heart
#

and testing the request yourself including the authorization works too?

tawny blaze
#

wait..

#

i jst filled the url

#

not the auth

#

in which section should i fill the auth?

#

Bearer Token
or
Basic Auth
or
Custom

rain heart
#

custom is the one you need to test with

tawny blaze
#

yea

#

it worked

rain heart
#

Send the url and the authorization

tawny blaze
#

dm?

rain heart
#

sure

tawny blaze
rain heart
#

Did you receive anything with top.gg data?

#

also, try having a simple "Hello" instead of already trying to fetch the data in it

tawny blaze
#

by testing?

rain heart
tawny blaze
#

k wait

rain heart
#

with the vote data included

tawny blaze
#

restarting after editing

#

testing again

rain heart
#

do you get anything

tawny blaze
#

no..

rain heart
#

not sure then

tawny blaze
#

😦

#

i tried it with a test

#

lemme find someone to vote..

tawny blaze
#

@rain heart ok it is working now..

rain heart
#

what was the issue

tawny blaze
#

its like repl users have a file name server.js

#

that shows the url and says OK

#

so i was putting the listener thing in index.js instead of putting it in server.js

#

and it worked when i putted listener in server.js

#

@rain heart

#

when i put console.log(vote.user)

#

it gives id

#

how can i make my bot dm that person?

rain heart
#

You can fetch the user from the provided id and then use that user object to DM them

#

Refer to the docs of the discord Library

tawny blaze
#

kk

restive otter
#

where do i find my webhook auth?

tidal idol
restive otter
#

is it this?

tidal idol
#

Webhook URL - the URL which top.gg automatically sends post requests to on vote

Webhook Auth - kinda like a password. Set it on top.gg and it will only send that as an authorisation header

tidal idol
restive otter
#

oh ty

tidal idol
#

No problemo

fast stratus
#

server count instantly show on top.gg after adding api to bot ? or it takes time..

rain heart
#

Should be added instantly

#

If not, caching

violet sun
#

What must be in here?

blazing harbor
#

im getting an http 400 error when i try to post my bot's stats to topgg

#
    return await got.post(API_URL, {
      headers: { Authorization: TOPGG_TOKEN },
      json: { server_count: guilds, shard_count: shards }
    }).catch(err => {
      console.error(`Unable to post stats to Top.gg: ${err}`);
    });
#

nvm

plucky lance
#

Not sure if you can only post the shard count without the other shard parameters

plucky lance
reef pecan
blazing harbor
#

The url that topgg will send an http request to

blazing harbor
#

The place that your web server is listening on

#

It’ll recirve the http request and do what it wants to do with it

reef pecan
#

But I don't have a web

blazing harbor
#

U need one

reef pecan
#

And how I create a web?

#

And what I do with the web

blazing harbor
#

U can make one with nodejs or python

reef pecan
#

??

blazing harbor
#

Any language, really

reef pecan
blazing harbor
#

Oh

#

Ru running it locally?

reef pecan
#

? Whattt

rain heart
#

You seem to be entirely confused about the concept of webhooks

#

read this

brazen sparrow
#

is it possible to track top.gg votes entirely through a bot, or do i still need a webhook?

brazen sparrow
#

python

tidal idol
modest fjord
#

Hey

#

Hello?

#

Anyone here?

#

I need a help in python like when user votes my bot it should give some reward to the voter just teach me anyone

sleek dune
modest fjord
#

But I have trouble

frank turtle
#

what maybe the cause of this?

#

pretty sure i got the token right

#

i'll try getting a new one

#

nope

#

do i have to import tasks from top.gg for this?

#

it's the auto posting server count part

#

something's prob wrong here but yeah

restive otter
frank turtle
#

yeah mb

#

just trying to pick up anything i may have missed

modest fjord
restive otter
#

You're already using the autopost, no need to worry making your owk task

frank turtle
modest fjord
frank turtle
#

lmao

#

cool

modest fjord
frank turtle
#

oh that's not what im doing

modest fjord
#

Hmm then?

frank turtle
#

will do something like in the future but now my bots in its infancy

#

just server count in the site thing

modest fjord
#

Hmm

#

Okok

#

Good luck

#

I need some help with making vote rewards when user is voted

#

@restive otter can u help me with making vote rewards when user is voted?

#

Sry to ping

restive otter
#

Not really no, I'm at school now

#

Nah it's fine, I'll be back in a couple hours

modest fjord
#

Hmm after school can u help me?

modest fjord
rain heart
#

@modest fjord read the docs in the meantime

modest fjord
#

Hmm yes I read it

tidal idol
#

Wai

#

Wrong ping

modest fjord
#

Oh

tidal idol
#

@frank turtle from discord.ext import tasks

modest fjord
#

@tidal idol can u help me how to do vote rewards when user is voted

tidal idol
#

There is literally a tutorial/template there

modest fjord
#

Umm.. I read it but I have some doubts and problems

tidal idol
modest fjord
#

Then

tidal idol
#

You need webhooks

#

You need to look at the code given on the documentation

modest fjord
#

Ok can u explain how to do it in detail?

tidal idol
#

That gets the person who voted and from there you could give them X rewards

tidal idol
modest fjord
tidal idol
modest fjord
modest fjord
tidal idol
#

Don’t code outside of your comfort/knowledge zone

modest fjord
rain heart
#

just ask

modest fjord
rain heart
#

state what you're having troubles with

modest fjord
#

Oh

modest fjord
rain heart
#

the print function gives you an example on how to use the user id from the vote.

You can for example use that id to then change certain values in stuff like a database etc

modest fjord
#

Yes

#

But I'm new to vote rewards that's y I need help

rain heart
#

and no I'm not going to help through direct messages as I'm at work right now

modest fjord
#

Okok

rain heart
#

read through that, it explains what you need to check if a specific user has voted

modest fjord
#

Hmm kk

rain heart
modest fjord
#

Umm I need python

rain heart
#

select python on the libraries then

modest fjord
#

Hmm

torpid lintel
#

i want to fetch all total votes amount of voted members how to get ?

modest fjord
# rain heart select python on the libraries then

My intention is to make that in my bot I have urban dictionary command but I want the command to be used by users who voted my bot, and if user is not voted it should send a msg like this "you need to vote if u want to use this command"

#

Aurel u there?

tidal idol
#

The documentation gives all the details you need

#

the vote response gives you user id's

#

or you could do an API lookup to see if a user voted but then it will be slower

tidal idol
#

ghost ping??

modest fjord
#

Nono I deleted the reply

#

I'm sry

tidal idol
#

ah

jagged nimbus
#

Am I doing it in the right way?

#

I have made it in the main file

#

(v12 stuff)

restive otter
#

@jagged nimbus remove your token

restive otter
#
const Topgg = require("@top-gg/sdk");
const webhook = new Topgg.Webhook("test")

app.post("/voted", webhook.listener(vote => {
  let channel = client.channels.cache.get("907041749845811271")
  let user = client.users.cache.get(vote.user)
if(!channel)return console.log("channel was not found")
  if(!user)return console.log("user was not found")
  channel.send(`${user} voted for us, thank you`)
}))
#

where is the error

#

im replit

tidal idol
#

you're replit?

restive otter
restive otter
#

tias

restive otter
#

tias

#

try it and see

#

what i put in here?

#

@tidal idol@restive otterany one know?

stoic gale
#

bro ask for discord bot script

restive otter
#

wtf?

restive otter
restive otter
stoic gale
stoic gale
jaunty plank
restive otter
jagged nimbus
#

regenerated*

restive otter
jaunty plank
restive otter
#

It will be useful,?

jagged nimbus
#

I am also not able to work with top.gg api

#

it is not showing any error

#

nor it is working

#

I think I'm running out of luck

restive otter
#

@modest fjord Have you got it working?

modest fjord
restive otter
#

Other way?

modest fjord
#

Yep

modest fjord
#

I'm not asking code

#

Just teach me

restive otter
#

I'd personally do DB calls rather than REST calls. So setup a webhook and store the timestamp and the user ID and just have a check for the command. The other way is to make a request to the API each command invocation which I don't think is ideal

modest fjord
jaunty plank
#

Restrict

modest fjord
#

Hnm

restive otter
#

It's not that different. If you wanna restrict it, then store the user ID and the timestamp in the DB. If you wanna reward users, then just give them something once you got requests from Top.gg. Both are doable with webhooks

modest fjord
#

For vote rewards I'm gonna try some other way

restive otter
#

What? Parsing Discord webhook messages you redirect the requests to? Sounds hacky

modest fjord
#

Wha?

#

Not hacking

#

Lol

restive otter
#

It's another "way" I know, dunno what you really meant

#

I said hacky doe

modest fjord
#

Hmm

#

I will tell how I'm going to do after the vote rewards gets success

modest fjord
#

@restive otter my bot is not showing up in top.gg

violet sun
#
self.topgg_webhook = topgg.WebhookManager(self.bot).dbl_webhook(WHAT MUST BE IN HERE???))```
#

What must be in the ()

jaunty plank
#

The auth to your webhook

#

It's like a password, you are the one who decides it

restive otter
#

And the route, I'd suggest you see the example or read the docs

tidal idol
violet sun
#

thanks

tidal idol
#

That is what the form asks you for on top.gg

restive otter
#

Not the whole URL lawl

atomic burrow
true brook
#
let author = context.params.event.author.id
const Topgg = require(`@top-gg/sdk`)
const api = new Topgg.Api('blah blah')
let userVote = await api.hasVoted(`${author}`)
#

it says it cannot find the module @top.gg/sdk

restive otter
true brook
#

i did

main bane
#

TypeError: AutoPoster is not a function

#

const poster = AutoPoster(process.env.TOKENTOPGG, client)```

My code is this
#

why is not wokring

rain heart
#

not working isn't a helpful statement

#

any error logs?

main bane
rain heart
main bane
#

yes

#

i copied the exact same code

#

then npm i topgg-autoposter

#

but no effect

rain heart
#

const { AutoPoster } = require('topgg-autoposter')

main bane
#

thx lol

#

im dumb

spice frigate
#

??

#

oh

#

got it to work

#

tho my token doesnt work

#

and token is added

tidal idol
spice frigate
#

nope didnt work

#

added the new token in

#

nvm im retarded

#

XD

prisma stream
#

#play klay bbj

rain heart
fossil epoch
#

What the command for the link

rain heart
#

the what?

fossil epoch
#

Link for this site

rain heart
modest fjord
quartz parrot
#
const DBL = require('top.gg');
const dbl = new DBL('my token', { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});  
``` why isnt this logging anything on console even though i have voted?
quartz parrot
#

somebody?

rain heart
#

Have you also set your webhook url on top.gg

quartz parrot
#

yes

quartz parrot
rain heart
#

0.0.0.0 means being able to connect from anywhere

#

So replace 0.0.0.0 with your servers public ip

quartz parrot
#

but this should also work right?

rain heart
#

No

#

0.0.0.0 is not a proper usable IP

quartz parrot
#

so what if i am hosting on heroku.?

#

how do get the ip?

rain heart
#

It is a visualised IP to tell you that you could connect on localhost, within the network etc

#

Check your heroku docs for that

quartz parrot
#

so if i am hosting locally now.. and i put my public ip insted of 0.0.0.0 and it says Your form contained some validation errors , Invalid url

rain heart
#

Has to be a proper URL aswell

#

Also, using it locally requires you to portforward

spice frigate
#

It can be used to declare.

rain heart
#

you cannot use 0.0.0.0 as an ip to connect to

spice frigate
#

E.g. For minecraft servers, it’s often use to declare any IP of the server

#

Of course, you cannot reach 0.0.0.0

#

But it can be declared as any ip of the pc

rain heart
#

declare that there's no definition of where that server can be reached

#

In the context of servers, 0.0.0.0 can mean "all IPv4 addresses on the local machine". If a host has two IP addresses, 192.168.1.1 and 10.1.2.1, and a server running on the host is configured to listen on 0.0.0.0, it will be reachable at both of those IP addresses.

spice frigate
#

Yes i know its private

#

But if he is trying to listen to a IP or somethinr, 0.0.0.0 may work also

#

You can’t reach another server using 0.0.0.0 but another server can reach that computer

rain heart
#

But not using 0.0.0.0 to reach it, either through localhost, a network ip or a public ip

modest fjord
#

Hey guys now my bot sends a thank you msg in user's dm for voting

#

But still need help with vote rewards

rain heart
#

Now just simply change data with the same thing

modest fjord
zenith edge
#

I

modest fjord
#

Hey guys I'm new to webhooks so plssend me how to do vote rewards in discord.py pls Don't send me api docs coz I already read it and I understood the python code but some says webhooks should be implemented so pls help me

tidal idol
#

if you dont know how to impliment vote rewards then don't

#

only proceed with it if you know how to do it

#

also, what do you want the vote rewards to be?

bold socket
#

an example of a flask application in python

#

additionally to this, u wanna import requests from flask and inside ur app() u wanna print(requests.json)

modest fjord
bold socket
#

receiving webhooks?

#

requests is in flask module tho

tidal idol
#

@jaunty plank 1. iirc you can get vote status via api, is this truei and 2. s it advisible to make api requests every command to see if user voted?

#

tyia

jaunty plank
#

You can get vote statuses from the api using the has voted endpoint.
It's not advisable to go that route every time a command is run though.
Our api does have ratelimits and could result in no one being able to run these commands

#

It's advisable to store the vote data in a database and pull from that

tidal idol
#

alr ty woob

modest fjord
quartz parrot
#

hey @jaunty plank could you help me setup a vote tracker for my bot...i am using the code given in the docs and nothing is logged when i vote.?

jaunty plank
#

Did you fill in the url and auth on topgg?

quartz parrot
jaunty plank
#

What are you hosting with? Home/server/vps/replit etc

quartz parrot
jaunty plank
#

If you want to do it locally you'll need to port forward and allow the port on the system firewall

slow bear
#

there's doc available for the vote object definition using webhook? I'm a bit confused about guild, type and bot 🤔

#

can we let users vote directly from servers using the bot itself?

#

it sounds weird to me

tidal idol
#

Nope

#

You have to vote on the site

slow bear
#

ok, so what's guild string then ?

jaunty plank
#

its the id of the guild voted for

quartz parrot
slow bear
#

i never voted for any bot, then i'm a bit confused 😓

jaunty plank
#

they vote on the website

slow bear
#

so the guild id is always the support guild server specified on the website

#

not a guild which would be represented by the vote

jaunty plank
#

whatever guild they voted for

#

if they voted for a bot, guild wont exist

slow bear
#

ahhh ok

#

type is related to the kind of the target ? bot/guild or it's something else?

jaunty plank
#

if they voted for a bot, the bot parameter will be used. if they voted for a server the guild parameter will be used

slow bear
#

oh i finally found something

#

this should definitely be directly exposed on the readme

/**
 * If webhook is a bot: ID of the bot that received a vote
 */
bot?: Snowflake;
/**
 * If webhook is a server: ID of the server that received a vote
 */
guild?: Snowflake;
/**
 * ID of the user who voted
 */
user: Snowflake;
/**
 * The type of the vote (should always be "upvote" except when using the test button it's "test")
 */
type: string;
/**
 * Whether the weekend multiplier is in effect, meaning users votes count as two
 */
isWeekend?: boolean;
#

and then type must be explicitely typed as 'upvote' | 'test' on the node SDK

#

i'm making a quick PR

jaunty plank
#

its covered on the docs

molten ginkgo
#

whats the api that shows how many votes your bot has?

molten ginkgo
#

this is the votes im guessing?

jaunty plank
#

yeah, overall. monthly points is what you have this month(what shows on the counter on the site)