#topgg-api

1 messages · Page 135 of 1

little gorge
#

i put it in index.js?

knotty garnet
#

yes

steady delta
#

you have to make sure your ports are open

little gorge
#

ok

little gorge
steady delta
#

that should work for you then

knotty garnet
#

found it

#

again, you're not making a solution for kofi, you're going to make a solution for HTTP requests

#

webhooks are HTTP requests

little gorge
#

after i filled every information

knotty garnet
#

just keep that in mind, else you might get lost

little gorge
#

and put the code in index.js

#

what do i do now?

knotty garnet
#

well, you put what u wanna do when someone votes inside the webhook event

little gorge
#

how

#

like creating a command?

knotty garnet
#

like setting onReady event

steady delta
little gorge
#

can you show me some example

#

?

knotty garnet
#

else you might face some weird issues

little gorge
#

help?

knotty garnet
little gorge
#

send link

knotty garnet
#

same I sent before

steady delta
knotty garnet
#

but I clicked in "libraries -> javascript"

#

yes, exactly

steady delta
#

but im wondering how im going to handle events you know? @knotty garnet like how i would make a custom listener

#

I'm just gonna look it up

knotty garnet
#

the tutorial covers it

#

just search around if you need more references, http.client is not the only http handler

#

but it's the more widely used afaik

steady delta
#

@knotty garnet wait can i also use the flask one?

knotty garnet
#

I guess so

#

I'm not well versed in python, if you're already familiarized with another http handler feel free to use it

little gorge
#

hmmm

knotty garnet
#

basically anything that do X stuff when someone accesses Y url you're fine

steady delta
#

@knotty garnet thanks! gonna work on this later

knotty garnet
#

yw

little gorge
#

how

#

to

#

get the webhook's auth?

#

@knotty garnet can you help?

knotty garnet
#

dbl webhook's auth is anything you want it to be

little gorge
#

like d09wdfu9d0sugfv8dhascne9 acception?

knotty garnet
#

it's just a thing dbl will send u on every request so you can check if it's legit from dbl

little gorge
#

ok

knotty garnet
#

just make sure it's the same both on ur code and on the site

little gorge
#

ok

#

there some error

#

on my console

#

@knotty garnet can you help me fix?

knotty garnet
#

what kind of errors?

#

port?

steady delta
#

@knotty garnet do you think i need to ports for topgg and ko-fi?

#

or should i just separate them with two different paths

#

/kofi /topgg wdyt

knotty garnet
#

Single port, multiple endpoints

#

Opening one port for each service would be highly inefficient

steady delta
#

i won't need the token anymore if i don't use the api right? the dbl one

knotty garnet
#

The token is for dbl api (like server count poster)

#

You still need to use the api if you upload the server count

#

You'll just not need to use the webhook part of it

steady delta
# knotty garnet You'll just not need to use the webhook part of it
from discord.ext import commands

import dbl


class TopGG(commands.Cog):
    """
    This example uses dblpy's autopost feature to post guild count to top.gg every 30 minutes.
    """

    def __init__(self, bot):
        self.bot = bot
        self.token = 'dbl_token'  # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)  # Autopost will post your guild count every 30 minutes

    @commands.Cog.listener()
    async def on_guild_post(self):
        print("Server count posted successfully")


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

so im still okay with using this?

#

while having a webserver on the side?

dire imp
#

@steady delta you're fine with that

#

I also did the same when i used to host on replit

agile sequoia
agile sequoia
#

Thanks, I solved

cursive steppe
#

What endpoint can check if a guild is available in topgg?

restive otter
#

yes

rose yarrow
#

i am using a express webserver myself to see when someone votes, and the req.body comes out as empty for whatever reason

here is my code around the post route

https://sourceb.in/HtxeQUOvTt

#

how can i fix this?

#

like i need to get the user from the post request

#

but nothing in the request has that property

dire imp
#
...

self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_port=2727)

...

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

    @commands.Cog.listener()
    async def on_dbl_test(self, data):
        print("Received a test upvote:", "\n", data, sep="")```
#

I've set the Webhook url on the website to http://12.3.45.678:2727/dblwebhook and am still unable to receive a test update response in my console. Idk whats the thing i am doing wrong

spiral musk
#

,

deep cape
#

I'm trying to make my bot console logs when someone votes but when I use the test button on top.gg Webhook page it doesn't log anything is it because I put the wrong url? but I tested it using an api tester website and it worked or is my code

const express = require('express');
const app = express();
const bodyParser = require("body-parser") 
app.use(bodyParser.json());

app.post("/votes", function (request, response) {
  response.sendStatus(200) // tells the website that sent the POST request that everything was OK
  console.log(request.body) // log the actual data being received
  console.log(request.headers)
  let user = client.users.cache.get(request.body.user)
  console.log(`${user} has voted`)
  let auth = request.headers.authorization
 if (auth === "my auth") {

 } else return;
});

app.get('/', (req, res) => {
  res.send('Cats cute!')
})
app.listen(2000, () => {
  console.log(`running`)
})
restive otter
#

try post

#

app.post instead of app.get

#

nvm my bad

deep cape
#

port 2000 the website says "Error: I could not see your service on my ip on port (2000)"

deep cape
#

hmm ok I tested the Webhook using api tester website (https://reqbin.com) and it was working fine or it doesn't have anything to do with this?

#

oh okay I'll try to port forward it

#

I'm using hosting something.host will I still need port forwarding?

graceful merlin
#

Hello, doesn't the top.gg/sdk API have a way to see the ping?

#

a way to see the ping of the api with the client

sullen nymph
#

You can't

#

Feel free to just straight up ignore that error altogether

knotty garnet
knotty garnet
sullen nymph
#

Make sure your port is forwarded and open

#

Apart from that, make sure your URL follows the format of http://ip:port/path

graceful merlin
knotty garnet
#

store current millis -> make a request to top.gg -> compare with the new current millis

#
long before = System.currentTimeMillis();
//Make some request to the api
long ping = System.currentTimeMillis() - before;
#

some java example

graceful merlin
#

Ok

#

Thank

knotty garnet
#

rarely ip:port format can use https

#

normally you setup ssl after you own a domain

dire imp
#

Not sure about that i use ubuntu 20.04

dire imp
versed python
#

how can i get dbl api key can someone help me dm or here

rain heart
#

bot page settings -> webhooks

versed python
#

thank you

knotty garnet
dire imp
#

Keeping ip secret?

knotty garnet
#

yeah, else you might face ddos

dire imp
#

Yeah ok

#

My server has a public and private ipv4 ip

knotty garnet
#

that public one is the issue

dire imp
#

I've not shared it with anyone so I'm fine

knotty garnet
#

yep

dire imp
knotty garnet
#

is your port open?

#

or postman whatever

dire imp
#

Okay thanks

#

I guess if it's not open I'll have to specifically add that port to my server settings then.

knotty garnet
#

if using ubuntu, check udp

misty blade
#

whats the data return from a non test vote?

rain heart
#

same values, just with type being upvote

#

instead of test

misty blade
#

oh ok ty

violet panther
#
const AutoPoster = require('topgg-autoposter')

const ap = AutoPoster('topggtoken', client) // your discord.js or eris client

// optional
ap.on('posted', () => { // ran when succesfully posted
  console.log('Posted stats to top.gg')
})
#

What should I put at the client part?

restive otter
#

the comment says it think

violet panther
#

Oops, sry

vital forge
#

الو

#

شفيكم

restive otter
#

i want to have a voting system which tells who voted in a particular channel.

so how to use the webhooks things ? (i have vsc and 0 experience of coding)

pastel raptor
#

if you have 0 experience in coding, this'll be pretty difficult to implement

#

also you'd need an approved bot to access it's API

normal nest
pastel raptor
#

yeah, bot needs to be approved afaik

#

among other things, yes

normal nest
pastel raptor
#

haven't really messed around with the api myself

#

but have you coded it properly hmm

normal nest
#

404

#

yes..get method

#

ok it seems there is issue in docs

pastel raptor
#

@normal nest if you put it in the github as an issue, im sure it'll be looked at

real python
#

.networth {DerpyTelly}

pastel raptor
real python
#

how can I look to my networth

nocturne quarry
#

How I can make a voting reward :D

willow spindle
#

use webhooks

nocturne quarry
#

I make my bot set user value with it?

willow spindle
#

huh?

nocturne quarry
#

uhh

#

Okay thanks

wise silo
#

The bot's server count is currently 800 but why does it appear here to be 510

#

-botinfo 763772564962148402

rain heart
brittle spoke
#

Im late af as well

wise silo
#

I use google translation pandasad

#

oh discord.js

brittle spoke
hoary nexus
#

server count

graceful merlin
#

-botinfo 795323591850983425

sullen nymph
#

-botcommands @graceful merlin

abstract mothBOT
#

@graceful merlin

Hey! Bots aren't given permissions to send responses in this channel. Please use #commands to run commands.

sullen nymph
#

Next person to use Luca's commands in this channel gets muted

hoary nexus
#

i did it! thank you!

pallid aspen
#

How do I get my bot's topgg token

restive otter
#

Your Bots Edit Page > Webhooks > Get Token

pallid aspen
#

thanks

polar star
#

plz write

rain heart
#

What?

graceful merlin
#

how many api and top.gg packages do you have? can you quote for me?

rain heart
#

1 official, see pins

graceful merlin
#

ok

#

where are the pins?

#

top-gg/sdk?

jaunty plank
#

Yep, and the auto poster(also in the same pin)

graceful merlin
#

I have a question while I'm on top-gg / sdk, I'm calling him by express using the API name for req. Can I just call vote and add some value to the user who voted for my bot?

jaunty plank
#

You'll want to store that in a database of your own.

graceful merlin
#

yes

#

mongodb

#

I'm trying out of storage first, using just my savings box to add coins to a user

#

and can I pull other functions from this dependency / api? I am trying hasvoted

jaunty plank
#

Any methods listed on the docs can be used yeah

graceful merlin
restive otter
#

ok how do i make it so if someone votes multiple times they can get the role for how many times they voted (for example voted 2 times gets the 2x voted role)

jaunty plank
#

youll need a database to keep track of how many times each user voted

#

Youll also need a discord bot, which gives the correct role

restive otter
#

ive alr got the vote tracker bot so thats 1 but do you have any recomendations for bots that give roles automatically

wide ginkgo
#

I'm trying to setup a webhook for votes and I get the following error every time I try to save There was a problem saving the webhook :Thonk:

rain heart
#

Bot?

wide ginkgo
#

Yeah it's a bot.

rain heart
#

you cannot use webhooks when it is not approved

#

your bot needs to be approved first

wide ginkgo
#

It is approved

rain heart
#

You do not have the developer role though

wide ginkgo
#

How can I be given the developer role

#

We had an issue with this before as I'm not listed as a developer, even though I'm listed as an admin

hot axle
rain heart
#

What webhook are you trying to add?

#

it cannot be a discord webhook

#

you have to make one yourself

wide ginkgo
rain heart
#

DM the url, I'll tell you if it is valid

#

can you check what the inspect element console says when you try to save it?

wide ginkgo
#

dm'd you the error

#

Can try to get the owner to set it

vestal jackal
#

So, I am trying to do the webhooks for voting detection, and I am trying to use dblapi for it because that is what I have seen on how to get vote detection, and on the top.gg document it says I have to put the code in index.js. Which index.js would I put the code in since in dblapi there are 2 index.js in the module, and there is the index.js that isn't in the module that just runs the bot.

halcyon warren
#

Anyone know how to add a bot to an sever

jaunty plank
#

click invite on their top.gg page

restive otter
#

bot

#

quick question

#

why do we need to create a webhook for the bot votes

#

why not events

jaunty plank
#

webhooks are a form of events.

restive otter
#

thats not what i mean

#

you see if im using the top.gg sdk it doesn't allow me to receive the events like client.topgg.on("voted")

#

i have to create a http server

#

something like that

hot axle
#

that gives you more control over the server

jaunty plank
#

sure, most http servers have events

#

the one listed on the sdk uses an http server event

#

its also more lightweight for top.gg, and increases reliability.

restive otter
#

hmm

jaunty plank
#

its overall a very clean and powerful way of handling it.

restive otter
#

hmm ok

restive otter
#

@everyone

jaunty plank
#

ah pong

restive otter
#

I want to have the command used by voting How Do I?

jaunty plank
#

I dont understand, what do you mean?

restive otter
#

For example, what did you not understand?

jaunty plank
#

what are you trying to do

#

get a vote event?

restive otter
#

For example, I want voters to use the help command. You understand?

tardy nimbus
#

ah, a man of culture

#

yessir, use the API to check whether someone has voted in the last 12 hours or not and lock the help command if not

sullen nymph
#

Why the fuck would you votelock the help command

#

Do you think that's a good idea

#

Do you think it's allowed

#

cc @restive otter

restive otter
#

bruh, locking the help command

#

Not moneywhore but votewhore

steady delta
#

any alternatives to fetch_user? it takes long to fetch multiple users

summer kernel
#

How can I show the total number of votes for my bot?

sullen nymph
#

get_user(x) or fetch_user(x) or x

#

x being the user ID in int

summer kernel
#

sHIW dude, can u help me

steady delta
#

also get_user doesn't work for me

#

fetch user takes long

#

i just need to take username

sullen nymph
summer kernel
sullen nymph
#

Fetching a user shouldn't take too long

steady delta
#

not if im taking multiple T_T

#

im using it for leaderboards

sullen nymph
#

because

#

-api

abstract mothBOT
#

TOP.GG API ONLY!!!
ANY OFF-TOPIC CONVERSATION WILL BE DELETED AND MUTED
This channel is only for SUGGESTIONS/HELP/BUGS to do with OFFICIAL API LIBRARIES and API DOCS found at: https://top.gg/api/docs

steady delta
#

yes i was using it to sort who has the highest votes on topgg

#

but ill go there

summer kernel
#

Hey dude, sHIV. I read this link but i don't understand cause i have bad English so sorry for this can u help me for my question?

restive otter
#

Make a request to the API

#

Read the outputted JSON

#

Get the first element in the results array

#

Read the value in points for total votes and read monthlyPoints for votes in current month.

narrow plover
#

/poll "Кто за перенос базы?" "Алькатрас" "Тисы"

sullen nymph
#

fucking idiot

graceful merlin
#

Hi

stone dawn
restive otter
#

yes

rancid lotus
#
events.js:173
      throw er; // Unhandled 'error' event
      ^
Error: listen EADDRINUSE: address already in use :::3000
    at Server.setupListenHandle [as _listen2] (net.js:1226:14)
    at listenInCluster (net.js:1274:12)
    at Server.listen (net.js:1362:7)
    at Function.listen (/rbd/pnpm-volume/e34fee2b-1bee-48e8-b280-5dfbc30c3da0/node_modules/.registry.npmjs.org/express/4.17.1/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/app/bot.js:124:22)
    at Module._compile (internal/modules/cjs/loader.js:759:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
    at Module.load (internal/modules/cjs/loader.js:628:32)
    at Function.Module._load (internal/modules/cjs/loader.js:555:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:826:10)
Emitted 'error' event at:
    at emitErrorNT (net.js:1253:8)
    at processTicksAndRejections (internal/process/task_queues.js:83:17)
    at process.runNextTicks [as _tickCallback] (internal/process/task_queues.js:58:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:828:11)
    at internal/main/run_main_module.js:17:11```
#

help

rain heart
#

Use a different port

rancid lotus
#

Can you help me?

#

I do not know

restive otter
#

can anyone say how to get crowdin api?

sullen nymph
#

-api

abstract mothBOT
#

TOP.GG API ONLY!!!
ANY OFF-TOPIC CONVERSATION WILL BE DELETED AND MUTED
This channel is only for SUGGESTIONS/HELP/BUGS to do with OFFICIAL API LIBRARIES and API DOCS found at: https://top.gg/api/docs

restive otter
#

ohk

nocturne quarry
#

Can someone tell me why its not sending the test webhook?

#

And I really didnt understand what value I put in Auth

sullen nymph
#

Are you sure the port you specified is open?
Are you sure the webhook URL you entered is correct?
Are you sure the Authorization key you entered matches the key in your webhook code?

nocturne quarry
#

Oh

#

Where I get the key in webhook code?

sullen nymph
#

You create it yourself

#

A piece of text that acts as a password in this case

nocturne quarry
#

Okay thanks

#

Oh you mean token?

sullen nymph
#

Not exactly

nocturne quarry
#

Okay

sullen nymph
#

It's a piece of text that you come up with and use

#

like a password

#

set it in webhook settings if you're using an official library and make sure the same text is entered in the Authorization key

nocturne quarry
#

Okay thank you for helping

restive otter
#

Hello there I think I spotted a bug with the "force dark theme" option on a bot's page

Whenever this option is on, the bot's mini-description is displayed in a very similar color to the background making it almost invisible

This is outside of the detailed description field so I don't think I can change it's color myself

proper sapphire
restive otter
#

That's an error dude

proper sapphire
#

öy bot dont error log

#

if error code

rain heart
proper sapphire
#

im bot later error send

rancid lotus
#

poop @proper sapphire

#

lol

rain heart
wary plover
#

-bots @wary plover

abstract mothBOT
wary plover
#

-bots @rain heart

abstract mothBOT
rain heart
dire imp
#

In python top.gg sdk, await dblclient.get_user_vote() returns a boolean telling if that user has voted in the last 12 hours or not. Right? and does the function also has the same 60 requests/60 seconds ratelimit?

bronze axle
#

hey, is there some sort of way I can run code when a user votes? I'm using java

obsidian coral
#

Webhooks

bronze axle
#

any tutorial i can see?

obsidian coral
#

You’ll need to set up a webserver to receive them

bronze axle
#

how?

obsidian coral
#

I’m not good with Java so I wouldn’t know where to link you other than the top.gg docs

bronze axle
#

can the top.gg docs explain it?

obsidian coral
#

Find HTTP server Java

#

Docs explain how to set it up on top.gg, what you do on your bots end is up to you

bronze axle
#

ok, i just wanna give the user coins

obsidian coral
#

Then you set up a http server and when top.gg sends a post with the data, you parse it on your bot and do the code to give coins

bronze axle
#

aight cool

bronze axle
#

just wishing there was an onVote() method I could implement Sad_Pepe

obsidian coral
#

Uhh wait don’t the libraries have smth like that, haven’t used em

#

Dunno if there is a Java one

#

There is

#

Oh wait it might not have it?

bronze axle
#

I'm using JDA

#

Javacord has the webhooks

#

I saw it in @rain heart 's example

#

also wondering if he could help me

rain heart
#

hm?

#

ping

bronze axle
#

ah yes

#

could you help me with receiving vote data?

#

in java

rain heart
#

sure what's the issue

bronze axle
#

i looked at your Loggers bro thingy

#

and it was in Javacord, I am using JDA

#

so if there is a way to receive the vote data without javacord..

rain heart
#

You could do it the same way, just with different executing on the Vote class

#

You dont need javacord, one sec

rain heart
bronze axle
#

my users have been begging for vote-rewards for the longest time

knotty garnet
#

it's dirty easy to setup it

dire imp
#

Im not setting up a webhook because I keep failing at that

bronze axle
#

ok, any tuts?

dire imp
#

why I can't just use the get_user_vote()?

bronze axle
#

really i don't want anything too big, im just going to use it to receive vote data

knotty garnet
rain heart
#

@bronze axle you can technically just ignore the javacord stuff

#

or springboot yeah

knotty garnet
#

everything at the start is building spring from zero, the part where u need is that one I said

bronze axle
rain heart
#

nah its not

knotty garnet
#

oh, nvm

rain heart
#

could be

bronze axle
#

ooh what is it

#

@knotty garnet

#

im intrerested in Spring boot

rain heart
#

got a bit inspired from builders

knotty garnet
#

do u use maven or gradle?

bronze axle
#

maven

knotty garnet
#

ok, then the tutorial will be on-point to your case

bronze axle
knotty garnet
#

since it uses maven as example

bronze axle
#

aight cool, but how do i receive stuff once ive done all of that

knotty garnet
#

if u set it to /dbl then the url will be http://ip:port/dbl

#

ip:port are your VPS' ip and port

bronze axle
#

so is that what I should set it to receive the vote data?

knotty garnet
#

yep, once top.gg sends a vote request to http://ip:port/dbl, springboot will look for a mapping to /dbl then execute whatever is inside it

bronze axle
knotty garnet
#

then it's your public ip

#

access that site from ur rasp

#

I recommend those params

bronze axle
#

ooh ok, and the port?

knotty garnet
#

you need to open one

#

what's ur OS?

bronze axle
#

windows

knotty garnet
#

hm, idk how to setup ports there, but search online about it

#

there might be many tutos for that

#

also make sure to port-forward on your router

bronze axle
#
<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
#

these are the dependencies needed?

#

do i need that starter-test thing?

knotty garnet
#

starter-test is for junit iirc

bronze axle
#

ok cool

knotty garnet
#

also:

#

create an applications.properties file inside resources folder and put that text inside it

#

for the sake of your sanity

bronze axle
#

why

knotty garnet
#

Because springboot logs every transaction

#

Your console would be spammed really quick

#

The first three lines there limit how many threads springboot (lets call it sb) will use

#

The fourth line sets loglevel to ERROR

#

And the last line redirects all errors (404, 500, etc) to /error so you can create an error handler later on

bronze axle
#

ok kl

#

Should I put the thing I downloaded in .m2?

knotty garnet
#

Downloaded?

#

What u downloaded?

bronze axle
knotty garnet
#

Didn't u use maven?

bronze axle
#

yh

knotty garnet
#

Like, you were supposed to but those maven stuff inside ur pom file

bronze axle
#

it says "Plugin 'org.springframework.boot:spring-boot-maven-plugin: ' not found"

knotty garnet
#

Yes, that's not a lib but a plugin

#

You need to put those stuff in ur pom file

#

Not download

rapid kettle
#

ngl i misread that

bronze axle
#

i added all the things the guide told me too

austere swallow
#

do you not have like a dependency manager (e.g. maven) for the bot?

bronze axle
#

yea i use maven

#

do how do i fix that error?

#

or can I just ignore it?

onyx forum
#

What is api

#

No reply sed

bronze axle
#

i think it is referring ot the top.gg api

onyx forum
#

Manny pls tell

bronze axle
#

basicallly

onyx forum
#

Ohh

jaunty plank
onyx forum
#

UwU

bronze axle
#

@knotty garnet so what do I put in my pom file?

knotty garnet
#

I'm back

#

did u reload maven?

#

actually, could u show me ur entire pom file?

#

@bronze axle

bronze axle
#

ok

#

the formatting is gonna flop

knotty garnet
#

no plz, use hatebin

#

don't paste the whole file here

bronze axle
#

ill just send a message file?

knotty garnet
bronze axle
knotty garnet
#

plugins should be after dependencies, but that shouldn't cause issues

#

try reloading maven

#

if using intellij, click the refresh button in maven tab

bronze axle
#

ok its reading the pom

knotty garnet
#

also, note that intellij sometimes doesn't load maven repos to the cache, so it might show error but the code still runs

bronze axle
#

so should i invalidate cache and restart?

#

yea cause i refreshed and its stil showing the error

knotty garnet
#

try that

#

nonetheless, try running the code, if it executes then it's right

bronze axle
#

yea the code runs fine

knotty garnet
#

now u need to create an app class

dire imp
knotty garnet
#

ignore the @fresh plover thing

#

wtf

#

sorry karin

#

ignore the @Bean thing

bronze axle
#

ok

knotty garnet
#

just create a class, and in its constructor put that line which is inside main

#

do not create a method called main there

bronze axle
#

should I call it like "App" or something

#

SpringApp?

knotty garnet
#

whatever u want

#

it'll be a simple class with a single constructor inside

#

remember to put that @SpringBootApplication annotation above the class

bronze axle
#

ok so ive done the annotation and created the class

#

what next

knotty garnet
#

did u put that line inside the constructor?

#

SpringApplication.blablabla

bronze axle
knotty garnet
#

is your class named Application?

bronze axle
#

nonj0

knotty garnet
#

actually, I made a mistake

#

it HAS to be a main method

#

not a constructor

bronze axle
#

oooo ok

knotty garnet
#

you don't need to put the main method inside it, you can call somewhere else

#

if you do put a main method there, you just do YourClassName.main(args);

bronze axle
#

so can it just be a normal method?

knotty garnet
#

yes, but gotta be static

bronze axle
#

cool

knotty garnet
#

and you gotta pass String[] args to it

bronze axle
knotty garnet
#

yep

#

now when u start ur bot just call SpringApp.init(args);

bronze axle
#

ok cool

restive otter
#

Hey

bronze axle
#

so now, how do I receive top.gg vote data?

knotty garnet
#

let's go one step at a time

#

do that then start ur bot

#

you'll see a giant "Spring" ascii art popup in ur console

#

if it does appear, then you did everything right

bronze axle
#

yup i saw the ascii

knotty garnet
#

then we can continue

#

create this

#

name the class however u want

bronze axle
#

inside the SpringApp?

knotty garnet
#

no

#

a new class

#

BUT

#

it gotta be in the same folder as SpringApp

#

or in subfolders

bronze axle
#

yup i made a new package called springboot

knotty garnet
#

my http handlers are in endpoint folder

#

and Application is springboot

bronze axle
#

so should I make a subfolder?

knotty garnet
#

up to u

#

but I recommend

bronze axle
#

ok, and what should i call this

knotty garnet
#

if u use many endpoints

bronze axle
#

ok so i should make a subfolder called endpoint

#

and put this new class in?

knotty garnet
#

yep

bronze axle
#

aight and should I call this class Controller ??

knotty garnet
#

call it something suggestive like DblHandler

#

I like to use Handler keyword to identify classes with endpoints

#

but again, up to you

bronze axle
#

I put in the annotations

#

so now what should I do with this method?

knotty garnet
#

lemme see how it is

#

?

bronze axle
#

should I copy it as is?

knotty garnet
#

no, I mean, just show a print of how you've done

bronze axle
#

ive improvised a little

knotty garnet
#

except for the class name and path

#

argument names are also up to you

bronze axle
#

ok

knotty garnet
#

done?

bronze axle
#

yup

knotty garnet
#

show me

bronze axle
knotty garnet
#

ok, nice

#

inside that method, put System.out.println(payload);

bronze axle
#

done

knotty garnet
#

ok, now we'll leave the code for now

#

did u setup the port?

bronze axle
#

no

knotty garnet
#

you'll need to port-forward in ur router

#

I can't say exactly how to because it depends on router model

bronze axle
#

I have BT

#

so i get the default gateway ip right?

knotty garnet
#

no

#

it has to be ur public ip

#

aka "how world sees u"

bronze axle
#

ok so my IPv6?

knotty garnet
#

ipv4

bronze axle
#

ok done that

#

i accessed the site thru the pi

knotty garnet
#

there should show ur public ip

#

save it somewhere for future reference

bronze axle
#

ok

knotty garnet
#

all u need to do now is open a port

bronze axle
#

so how do i do that?

knotty garnet
#

as I said, you'll need to search that urself since it's model/brand dependent

#

but for all cases, access 192.168.0.1

#

or whatever is ur router config url

bronze axle
#

ok

#

ok so i think i have it down

knotty garnet
#

try to send a blank request to ur ip

#

http://ip:port

bronze axle
#

ok

#

let me finish up with the port rq

#

what port number is the best?

#

6969?

#

or 80

knotty garnet
#

never 80

#

it can be any port u want, as long as it's not used anywhere else

#

but below 1000 is a danger zone

bronze axle
#

what is the limit?

#

9999?

restive otter
#

max is 65535 iirc

bronze axle
#

ok ill name it something super obscure

knotty garnet
#

ngl, I never know

#

did u find a tuto on how to do it?

bronze axle
#

yea BT Smart Hub has one

knotty garnet
#

put everything the same then

bronze axle
#

which protocol

knotty garnet
knotty garnet
bronze axle
#

TCP, UDP, TCP/UDP

knotty garnet
#

tcp iirc

bronze axle
#

Its like all the ports are closed

knotty garnet
#

did u use portchecker?

bronze axle
#

yea

knotty garnet
#

you should set it to HTTP

bronze axle
#

it switches back to FTP

knotty garnet
#

oh, nvm nvm nvm

#

waitaminute

#

actually, open port 80

bronze axle
#

it says its closed

knotty garnet
#

I mean, on the port forward

bronze axle
#

ok i set it all to 80

knotty garnet
#

now try

bronze axle
#

i havent saved the port

knotty garnet
#

save it

#

if it still says its closed you need to also open on firewall

topaz axle
#

Anyone know why my bot could be appearing offline on top.gg? It's up 24/7

knotty garnet
bronze axle
knotty garnet
#

80 is HTTP

#

443 is HTTPS

#

unless you have SSL, you'll only be able to use HTTP

topaz axle
knotty garnet
#

because discord limits bot count to 50 per server

#

you see, top.gg has way more than 50 bots

topaz axle
#

that makes sense

bronze axle
#

oh ok

topaz axle
knotty garnet
#

more like a discord issue, but yeah

bronze axle
#

ok so the port is still saying closed

knotty garnet
#

did u open on firewall?

#

ignore the apache part btw

austere swallow
#

@topaz axle #site-status message
Also, only selected bots chosen and voted by the community will be added here

bronze axle
topaz axle
#

and you @knotty garnet

knotty garnet
#

don't disable ur firewall

bronze axle
#

ok i undisabled

knotty garnet
#

enabled then

bronze axle
#

yes i set to default

knotty garnet
#

see that guide I've sent

bronze axle
#

yh

knotty garnet
#

it has firewall config stuff

bronze axle
#

ok which section?

knotty garnet
#

yes

#

linux be like: udp allow http

bronze axle
#

hehe

knotty garnet
#

may I ask u, why are you running windows on rpi?

bronze axle
#

i am familiar with windows and i didnt originally buy the pi

knotty garnet
#

I see, but if you plan on using it as a dedi you should consider using ubuntu instead

#

windows is a memo hog

bronze axle
#

yh ive been told that

#

some people just say i may as well switch back to raspbian

#

do i only need to put in port 80?

knotty garnet
#

yep

#

you can also add 443 once u get a domain + ssl

#

but keep it closed for now

bronze axle
#

ok i did it

knotty garnet
#

see if it's open now

#

also, you could just ping ip on cmd

#

on another pc obviously

#

but try that site

bronze axle
#

still saying closed

knotty garnet
#

I'm a bit clueless then, it was supposed to be able to connect to that port

bronze axle
#

should i specify a port in Remote Port

knotty garnet
#

if you do netstat -a -n on cmd does it show 0.0.0.0:80?

bronze axle
#

i dont see 80

knotty garnet
#

on External address, not local

bronze axle
#

oh Foreign?

knotty garnet
#

yeah, looks like it's not open at all

#

btw, no, it should be listed under "Local Address"

#

which isnt

bronze axle
#

and i know for sure i saved the port

knotty garnet
#

did u restart the rpi?

austere swallow
#

make sure your java application is running first

knotty garnet
bronze axle
knotty garnet
#

like, it's closed

bronze axle
knotty garnet
#

hm

#

lemme check if there's no other way to refresh ports

bronze axle
#

i did tell my users before starting that the bot might go offline

knotty garnet
#

try restarting then

bronze axle
#

ok il save intelliJ first tho

knotty garnet
#

intellij saves on each time u change current app

#

ctrl + S does nothing at all there

bronze axle
#

oh

#

so whats the point of even having a save button?

knotty garnet
#

you can disable that auto-saving feature

bronze axle
#

yea i dont plan on doing that lol

knotty garnet
bronze axle
#

you can't save google docs right?

#

its only auto

knotty garnet
#

yeah, google docs is always auto-save

bronze axle
#

and btw i can use this spring boot thing for other stuff right?

austere swallow
#

pretty sure you can

#

its basically a web server

bronze axle
#

ok

#

and by dbl, i hope he means top.gg

knotty garnet
#

yep

#

springboot can be used for anything that can be served from calling ur server

bronze axle
#

ok

#

wel its still closed 😮

knotty garnet
#

maybe the issue is on the router side then

#

did u change it to port 80?

bronze axle
#

on what

knotty garnet
#

the router port forwarding

bronze axle
#

yea i set all the ports on the thing to 80

#

both start and end on both external and internal

knotty garnet
#

I'm clueless then, we'll need help from someone who know how to properly open a port on windows

#

idk why they make it so difficult

bronze axle
#

yh

#

ill go consult help on youtube

#

im going to delete the rule

#

and then rettry

bronze axle
#

the video says I should change to Allow Edge Traversal

knotty garnet
#

never heard that

bronze axle
#

ok, it didnt do anything

#

im going to ask on Ben Awads server

eternal moth
#

@bronze axle you want to open port 80?

bronze axle
#

yea

eternal moth
#

search for Firewall on windows search
open it, then Advanced Settings
then you have access to everything the firewall has
click on New Rule in Entry Rules
choose Port > select the protocol you want > type on local ports what port you want

#

if you want pics, i can send them

bronze axle
#

pics please

eternal moth
#

my Windows is in another language, but I'll send you closed captions xD

#

search for Firewall on windows search

bronze axle
#

ok

eternal moth
bronze axle
#

ok

eternal moth
bronze axle
#

ok yh, this seems similar to what i did but go on pls

eternal moth
bronze axle
#

yup

eternal moth
#

not sure

bronze axle
#

@knotty garnet said i should use TCP

eternal moth
#

choose it so

bronze axle
#

ok

eternal moth
#

and insert 80 in the local ports

bronze axle
#

yes done that

knotty garnet
#

normally it's TCP ain't it?

eternal moth
#

@bronze axle who will access it?

bronze axle
eternal moth
#

your bot's online?

bronze axle
#

yes

eternal moth
#

probably is safe

bronze axle
#

ok i clicked the first one, Allow the connection

#

so this is different

eternal moth
#

if you select the 1st, EVERYTHING can enter through that port

bronze axle
#

oh ok

eternal moth
bronze axle
#

ok now its on Users

eternal moth
#

just a thing, do you share your PC with other Windows Users?

bronze axle
#

no

eternal moth
#

yeah, this option is useless so

#

go back and select the 1st

bronze axle
#

ok

eternal moth
#

on Profile let everything ticked and Next

#

on Name put 'Port 80' so u can know

#

after all that do the exact same in the Exit Rules

bronze axle
#

OH I DIDN'T DO EXIT RULES

eternal moth
#

probably u want to get info from your PC

#

and don't let any enter, if this concerns you, u can just delete the Entry Rule u just did

bronze axle
#

oof still does not work when i do netstat

eternal moth
#

show me the comand you used

#

full line

bronze axle
#

netstat -a -n

eternal moth
#

k

#

see it fast

#

too late

bronze axle
#

huh

eternal moth
#

2 secs

#
TCP    aaaaaaaa      aaaaaaaa:80       CLOSE_WAIT
TCP    aaaaaaaa      aaaaaaaa:80       CLOSE_WAIT
TCP    aaaaaaaa      aaaaaaaa:80       CLOSE_WAIT
TCP    aaaaaaaa      aaaaaaaa:80       CLOSE_WAIT
TCP    aaaaaaaa      aaaaaaaa:80       CLOSE_WAIT
TCP    aaaaaaaa      aaaaaaaa:80       CLOSE_WAIT
#

they're as CLOSE_WAIT, ain't them?

bronze axle
#

TIME_WAIT

eternal moth
#

oh

#

well, from this point forward, I don't know shit

#

has your router Port 80 open?

bronze axle
#

you mean for port forwarding?

eternal moth
#

yeah

bronze axle
#

uh huh its open

eternal moth
#

well, idk

knotty garnet
#

windows 3
developers 0

#

well, at least we know we should focus on the router

bronze axle
#

yh

green mantle
#

what's your router config

bronze axle
#

I have BT Smart Hub

#

oh u mean when i type ipconfig?

green mantle
#

no i mean your router config

#

e.g. take ss of your router firewall and port forwarding rules

bronze axle
#

ok

#

ill only share the port config

near remnant
#

You need member intents for that

restive otter
bronze axle
#

hey @knotty garnet

#

does this count?

rain heart
#

0.0.0.0 means being able to connect to anywhere

#

For you it is going to be your external ip

#

If you have portforwarded that is

bronze axle
#

i port forwarded port 80

rain heart
#

Do you use that port already?

bronze axle
#

no this is my first time port forwarding

rain heart
#

i actually suggest using a non-standard one such as 5000 or in your case above 8080

bronze axle
#

its free right?

rain heart
#

yes these should be free

#

remember you cannot use a port multiple times

bronze axle
#

wdym

rain heart
#

Ports cannot be used multiple times

#

as simple as that

bronze axle
#

so i can only use the port for one thing?

rain heart
#

because it cannot have multiple connections coming through it

#

correct

#

you have about 65535 ports to use

#

15% being used by your operating system

#

for things such as microsoft related stuff and applications you have installed already

bronze axle
#

why does it say the port is closed?

jaunty plank
#

if hosting from home you need to port forward, if you have a firewall youll need to let it through the firewall

restive otter
#

how do i set up the webhook?

jaunty plank
bronze axle
#

POGGERS!

rain heart
#

Yup good job

#

now try testing your webhook

bronze axle
#

oof KuuHaKu was guiding me

#

this is what i have so far except the onVote method just prints the payload

knotty garnet
#

ok, you're here again

austere swallow
#

according to the latest docs updates, must the webhook response only return http 200? what about the other http ok codes like 204? cc @willow sphinx

#

since there is usually no response that needs to be sent back by the server

jaunty plank
#

Honestly, I would suggest just trying a 204 and seeing if it repeats it after a minute or not.

austere swallow
#

well.. its better to get the official answer I guess

jaunty plank
#

it seems the only reason it requires a 200 is because it repeats the request if it doesn't.

kindred mountain
#

https://sourceb.in/HLTbl7J18k
look at this error
never seen like this before
even my bot not working
the cmds
only cc prefix working
default prefix not working

#

i am sure it is related to top.gg

restive otter
#

judging from what ThinkDeep

willow sphinx
#

I just updated the docs to reflect the current state, yukine said he's gonna rewrite the webhook codebase this weekend so it should work as intended soon

austere swallow
#

ah ok, thank

kindred mountain
#

how to fix it?

kindred mountain
#

no

#

i did not

#

um..

#

ooof

torpid coral
#

where can i found api docs ?

restive otter
#

anyone has the code for python on how to track a vote ?

restive otter
#
@commands.Cog.listener()
async def on_dbl_vote(self, data):
      channel = self.bot.get_channel(811870894954905632)
      logger.info('Received an upvote')
      print(data)
      await channel.send(f"recived a bot : {data}")

#

this doesn't work

rain heart
#

Did you add a valid webhook url to your bot page settings?

rain heart
#

Did you test it with a request client?

restive otter
#

not yet

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

import asyncio
import logging


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

    def __init__(self, bot):
        self.bot = bot
        self.token = 'dbl_token' # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)

    # The decorator below will work only on discord.py 1.1.0+
    # In case your discord.py version is below that, you can use self.bot.loop.create_task(self.update_stats())

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

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

        await asyncio.sleep(1800)

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

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

this is everything I could find

#

what do I add to path @rain heart

rain heart
#

Can't help I don't know python

restive otter
#

nvm I found

#

but when I press test what should happen ?

dire imp
#

It should send you a message on the channel you want it to send as per your code. It's like dummy data@restive otter

#

Also if you make that work could you please share what did you do to make it successful? I'm also trying to add webhook in python but no success.

restive otter
#

ok sad it doesn't send anything

dire imp
#

Oh rip

restive otter
#

the documentation is hard to understand

#

like how am I suppose to make it send a message what should I do

#

I will delete it after

#

what should I do with this I put it in path and in webhocks on the website

#

@dire imp

dire imp
#

Is that what ur putting in webhook path?

#

But I think your webhook path should be something like this http://12.34.56.78:port/dblwebhook

restive otter
#

is it wrong

dire imp
#

I think it is

restive otter
#

than what should I put

dire imp
#

Which server r u hosting?

restive otter
#

hacker plan

dire imp
#

Then the server should have an ip address and a port. Put it in a format like this http://yourip:port/dblwebhook on topgg website.

#

I'm not sure where u can find your ip since i m not using repl.it anymore

restive otter
#

sad

#

found it

dire imp
#

i do agree that the documentation in official topgg website isn't very helpful

#

Ohh okay let me know if that works?

restive otter
#

ok thanks

#

@dire imp should it be like that

dire imp
#

Yes exactly

restive otter
#

@dire imp well didn't work

#

@empty gazelle help

dire imp
#

Yep same here.

empty gazelle
#

?

dire imp
#

I also followed to the same exact procedure

restive otter
#

for webhocks

#

I tried for 2h to use something and failed

#

@empty gazelle

#

I tired my anme and project

#

than port

#

I tired everything

#
//Server
const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => {
  res.send('voting system being hosted for 24/7')
})

app.listen(port, () => {
  console.log(`Server is Online`)
})
// Code
const Discord = require('discord.js')
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL(
  "TOKEN",{ webhookPort: 5000, webhookAuth: "PASSWORD HERE" },client);

dbl.on("error", e => {
  console.log(`Oops! ${e}`);
});
dbl.webhook.on("ready", hook => {
  console.log(
    `Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`
  );
});
dbl.webhook.on("vote", async (vote) => {
client.users.fetch(vote.user).then(user => {
const thanks = new Discord.MessageEmbed()
.setColor("RANDOM")
.setTitle("Thanks For Voting! :)")
.setDescription(`Thanks you so much for voting ,  it helps us grow a lot !`)
user.send(thanks)})
})

#

I used this

#

still NOTHING

#

stop using dblapi.js

dire imp
#

When i tried to put the first link and tried sending a test webhook it gave me a 404 not found error on the webpage

restive otter
#

I tried in py too

#

Use @top-gg/sdk

gloomy fractal
#

Btw I’d strongly recommend not leaking your VPS IP or discord webhooks :)

restive otter
#

@restive otter use @top-gg/sdk

#

how

#

than

#

read the pins

#

but I don't know how to make the webhock not code

#

what pins

#

what is this const app = express() // Your express app

#

I don't code in js

#

then cant help you

gloomy fractal
#

You need to have at least a little bit of experience

restive otter
#

bruh I made a full bot in py but because the py documentation is so shit I had to make in js

gloomy fractal
#

There’s a python library

restive otter
#

is shit

#

like literally

sullen nymph
#

P.S. you could just contact me for help with it

dire imp
#

Can i dm you shiv?

sullen nymph
#

Aye feel free to

graceful merlin
#

Does dblapi.js connect to top.gg?

rain heart
#

yes

graceful merlin
#

Ok

#

Thank

#

^^

covert lark
graceful merlin
#

Ok

graceful merlin
covert lark
#

why lmfao

#

its official

crystal ocean
#

did the api change?

wheat copper
#

waitWhat is this normal or?

restive otter
#

it's just down ig

wheat copper
#

ok lol

restive otter
#

should be fixed soon

wheat copper
#

i need to handle that error better - its typing tons of html in my console

plucky ruin
#

!play

rain heart
astral salmon
#

Is there is a trouble in Top.gg Api?

#

@rain heart

restive otter
#

yes

potent bramble
#

Ah ok was just about to ask if I was the only one with a gateway timout lol

restive otter
#

guys

#

i have created a check command since a whale ago

#

and now it doesnt work

#

nothing wrong

ruby tangle
#

is that a normal error?

restive otter
#

this was a 3h ago

wheat copper
restive otter
#

and this now