#topgg-api

1 messages ยท Page 145 of 1

golden adder
#

I switched from dblapi.js to topgg-autoposter yesterday and it's so much better. Especially using it in the shard manager file ๐Ÿ‘Œ

calm agate
#

link pls?

#

this one ig

shy vortex
#

yes

#

this one

shy vortex
#

lol

golden adder
#

Yep that's why I switched

upper valley
#

how can i fix this

#

pls help

restive otter
#

read the error โ„ข๏ธ

upper valley
#

how can i authorize

#

@restive otter

restive otter
#

get your api token

#

1sec

upper valley
#

ok

sullen nymph
#

see last pin

restive otter
#

that ^

upper valley
#

so

restive otter
untold birch
#

What happend to dblapi.js?

restive otter
#

deprecated

untold birch
#

Soo, how can i check if a user has voted by now?

sullen nymph
#

@top-gg/sdk package

upper valley
#

someone who speaks turkish and approved for the bot top gg dm

swift adder
#

can i use a free website/code hosting site and make it so every time you'r API send request it sends it in a private discord channel (using a webhook) and then i make my bot to read whatever is in the channel and reward people according to that?
OR
is it a waste of time?
(please ping me then responding)

dusky plank
#

sa

restive otter
near remnant
#

What do I put on the webhook part of my bot on top.gg

restive otter
#

and the password is the password you choosed for the webhook

near remnant
#

I dont have a webhook

#

How do i get a webhook

restive otter
near remnant
#

Any tutorials with dblpy?

restive otter
#

you host it

#

o

#

its py

near remnant
#

Can someone pleaseeeeee help me with dblpy

#

Idk what to put on the webhook part

untold birch
#

Anyone knows how to make vote rewards?

trail sigil
#

you can use webhooks to see who voted, and do something from there e.g. change some value in a database to show if they've claimed their vote reward yet in the past 12 hours

dark fjord
swift adder
sullen nymph
restive otter
#

lol

rain heart
#

wtf

#

-b 818590030725382156

abstract mothBOT
#

dblMod Banned sadness?#1210 (@static harness)

kind obsidian
#

hey

#

how do i get servercount for top.gg

#

like for the small thing

rain heart
#

-servercount @kind obsidian

abstract mothBOT
#

@kind obsidian

To have your bot's server count displayed on Top.gg, please read the documentation on server/shard posting.

kind obsidian
#

ty

fluid condor
#

hey, so I sorta have a question

#

would something like ${api.getVotes[1].name} return the username of the most recent voter?

rain heart
#

getVotes[0], no?

fluid condor
#

or that, yeah

sullen nymph
#

getVotes()?

fluid condor
kind obsidian
fluid condor
#

I'm tryna make some sort of vote command that tells them the last 5 voters, the total vote count, and if they have voted in the past 12 hours

opal panther
#

where's the link for python?

rain heart
opal panther
#

thanks

fluid condor
#

I desperately need help

#

with using the .getVotes() thing

#

also how does the authorization work?

#

What I want to do is make a command that:
gives the total number of votes
says if the guy has voted in the past 12 hours
and gives the names & tags of the past 5 voters

#

so I'm wondering if like
api.getVotes().name[0] would work in getting the name of the most recent voter

#

or api.getVotes()[0].name or something

opal panther
#

why can i not get any vote info?

sullen nymph
#

api.getVotes()[0].username

opal panther
sullen nymph
#

get_bot_upvotes

untold birch
#

How to make a webhook :< Cus i wanted voting rewards :<

opal panther
#

shivaco, do you know where to get the voting info from the website?

sullen nymph
#

A webhook is just an HTTP listener running on a machine

#

JS and Python SDKs support those by default

sullen nymph
opal panther
sullen nymph
#

See pins

opal panther
#

my computer is different and doesn't have those

#

i have edit and refresh data there

restive otter
#

how to get logs who voted my bot ?!

sullen nymph
#

See the last pinned message

opal panther
#

it is

#

or at least the website

untold birch
#

Codejs const DBL = require("@top-gg/sdk"); const dbl = new DBL(process.env.TOPAPIKEY);ErrorDBL is not a constructorIs this going to work?

sullen nymph
#

no

opal panther
#

yes, i saw, my bot doesn't have those

sullen nymph
#

Well then you can't use those until your bot's approved

opal panther
#

๐Ÿ˜ก

sullen nymph
#

Are you looking at the Edit page currently

opal panther
#

yep

sullen nymph
#

You don't have a Webhooks section?

fluid condor
sullen nymph
#

It's in the request headers

opal panther
sullen nymph
#

Authorization: "YOUR_TOP.GG_TOKEN"

sullen nymph
opal panther
#

do they not realize that people want to test?!?!?!
๐Ÿ˜ก๐Ÿ˜ก๐Ÿ˜ก๐Ÿ˜ก๐Ÿ˜ก๐Ÿ˜ก๐Ÿ˜ก๐Ÿ˜ก๐Ÿ˜ก๐Ÿ˜ก๐Ÿ˜ก๐Ÿ˜ก๐Ÿ˜ก๐Ÿ˜ก

fluid condor
sullen nymph
#

What is there to test even

#

You wouldn't have any data to work with in the first place

opal panther
#

to test if my code receives votes correctly

fluid condor
#

I have no fucking clue how the authorization works; where am I meant to put it

sullen nymph
#

you can send test requests just fine yourself

rain heart
#

You can do that with Some dummy data you can make yourself with the schema on the docs

opal panther
sullen nymph
#

Are you using an official top.gg library?

fluid condor
#

topggjs?

sullen nymph
#

topggjs, so the node SDK

fluid condor
#

yeah

#

I just don't understand what I'm meant to do with the authorization thing

fluid condor
#

const api = new Topgg.Api('top.gg token')

#

is this the authorization?

rain heart
#

Yes, if you're referring to using the topgg api

untold birch
# sullen nymph https://discord.com/channels/264445053596991498/412006692125933568/7866331681605...
const express = require("express")
const app = express()
const port = 3000;
const DBL = require("@top-gg/sdk");

const webhook = new DBL.Webhook('topggauth123')

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

app.get('/', (req, res) => res.send("The bot is Jisoo and it's ok!"))

app.listen(port, () => 
  console.log(`Jisoo is listening at http://localhost:${port}`)
);```Will this work? Because there isn't any errors
#

and the webhook is like topggauth123

fluid condor
sullen nymph
#

console.log getVotes()

rain heart
#

That's somewhere in your code

untold birch
sullen nymph
#

Use port 8080

untold birch
#

hmm

fluid condor
#

its from this api.getVotes()[0].username

sullen nymph
#

Just output api.getVotes()

sullen nymph
#

with /dblwebhook appended to it

untold birch
# sullen nymph Your URL will be your repl's `repl.co` URL

This is code```js
const express = require("express")
const app = express()
const port = 8080;
const DBL = require("@top-gg/sdk");

const webhook = new DBL.Webhook('topggauth123')

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

app.get('/', (req, res) => res.send("The bot is Jisoo and it's ok!"))

app.listen(port, () =>
console.log(Jisoo is listening at http://localhost:${port})
);
```But it says Cannot GET /dblwebhook

fluid condor
#

but it didnt throw an error

sullen nymph
#

await it

#

or idk how you JS guys resolve promises

sullen nymph
#

but

#

If / route works, so should /dblwebhook with POST requests

untold birch
#

but get worked

sullen nymph
#

How did you send it

untold birch
#
const express = require("express")
const app = express()
const port = 8080;
const DBL = require("@top-gg/sdk");

const webhook = new DBL.Webhook('topggauth123')

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

app.get('/', (req, res) => res.send("The bot is Jisoo and it's ok!"))

app.listen(port, () => 
  console.log(`Jisoo is listening at http://localhost:${port}`)
);```
#

here the code

#

:/

sullen nymph
#

send not create

untold birch
#

where?

sullen nymph
#

How did you send the POST request

untold birch
#

Wdym :/

sullen nymph
#

Okay

untold birch
sullen nymph
untold birch
#

But

sullen nymph
#

Correct

untold birch
#

Yeah...

sullen nymph
#

Make sure the auth matches too and press Test on the bot's Edit page in Webhooks section

untold birch
#

ok

#

i did

#

nothing happend

sullen nymph
#

Did you save?

untold birch
#

yes

#

Lemme try again

#

OK FINALLY WORKED!

#

@sullen nymph Ty!

sullen nymph
untold birch
#
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
  let voteperson = bot.users.get(req.vote.user)
  console.log(req.vote.user)
  voteperson.send("Thank you for voting!")
})
```@sullen nymph
#

will this work

#

sry for ping

sullen nymph
#

TIAS

#

Try it and see

#

๐Ÿ˜›

opal panther
#

could someone show me an example code for top.gg votes with python?
it just needs to do print() when there's a vote in the example
the docs really aren't that good

sullen nymph
#

God damn it, need to rework that README

opal panther
#

i did not know that existed

opal panther
sullen nymph
#

Yeah, those examples only provide what's needed to just get it working

#

To adapt it to your use case is up to you

opal panther
#

no, it doesn't work

#

it runs, but i need to get it to wait for a vote then call the function

#

not just define the function

sullen nymph
#

Assign a function as an event to your bot object, make sure your port is open (and forwarded to your device if hosted locally). The function will be called when vote requests are received

#

You can only send mock votes manually currently since your bot hasn't been approved yet

opal panther
#

i can't do any votes

#

i'm using someone's verified bot to test

sullen nymph
#

P.S. you can send HTTP requests manually

opal panther
sullen nymph
sullen nymph
opal panther
#

no, that's what i have

sullen nymph
#

Yeah, you assigned those functions as events. dblpy will use the bot's event system to call them when votes are received

opal panther
#

it ends the program

#

what do i do to make it continue to run?

#

or just discord bot run?

sullen nymph
opal panther
#

yes

#

understand that much better

sullen nymph
#

Do you have bot.run in your code?

opal panther
#

no

sullen nymph
#

Well..?

opal panther
#

i thought something would be in this

sullen nymph
#

You assign events, etc etc, then use .run method on your client/bot object

opal panther
#

okay

sullen nymph
#

That's discord.py thing and goes off this channel topic

opal panther
#

yes

#

thanks

sullen nymph
opal panther
sullen nymph
#

Yes

opal panther
#

do i can not do this without a website to create a URL for?

#

so

#

this doesn't work

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

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

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

How does it not work?

frigid gorge
#

my TOP.GG-WEBHOOK is not working!

the first code I did worked but it keeps repeating the user ID that voted for my bot

the second one worked only once and does not answer but

opal panther
sullen nymph
opal panther
#

verification is "password"

frigid gorge
#

@sullen nymph yes

sullen nymph
#

update

frigid gorge
#

what?

sullen nymph
#

update the SDK

sullen nymph
frigid gorge
#

@sullen nymph using the top.gg test system

sullen nymph
#

What version is your @top-gg/sdk package at?

frigid gorge
#

the last version

sullen nymph
#

which version exactly

frigid gorge
#

3.0.7

sullen nymph
#

Update

frigid gorge
#

for which version?

sullen nymph
#

3.0.8 iirc

#

or 3.0.9

frigid gorge
#

ok

opal panther
#

this doesn't work (why?)

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

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

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

What URL did you set on top.gg?

calm reef
#

for voting, the docs said to do this
{ webhookPort: 5000, webhookAuth: 'password' });
what do i put for thsoe
im new to webhooks

opal panther
sullen nymph
#

http://ip:port/dblwebhook

calm reef
#

ty

restive otter
#

you can look at pins how to use them

calm reef
#

ok

opal panther
sullen nymph
#

a value

young escarp
#

Hi

sullen nymph
#

ip being the IP address of the machine where the webhook is hosted

#

port is 5000 because webhook_port

opal panther
#

i'm trying that now

sullen nymph
#

Better not leak the IP here

rain heart
#

dont mind if i do

sullen nymph
#

Make sure no firewall is blocking that port

opal panther
#

it is considered public

scarlet cobalt
#

One message removed from a suspended account.

#

One message removed from a suspended account.

rain heart
#

I still wouldn't share your ip

#

even if it is considered public to you

opal panther
scarlet cobalt
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

sullen nymph
scarlet cobalt
#

One message removed from a suspended account.

sullen nymph
#

yes

opal panther
#

okay

sullen nymph
#

good girl Faith

opal panther
#

connection timed out

#

and unable to complete the request

scarlet cobalt
sullen nymph
opal panther
#

tried multiple different numbers

opal panther
scarlet cobalt
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

sullen nymph
#

Not necessarily

opal panther
#

ISP?

sullen nymph
#

You can open ports via router settings

#

Internet Service Provider

opal panther
#

oh

sullen nymph
#

You will need to forward port 5000 to your device in router settings and open it in firewall settings on your PC

opal panther
#

i'm not really good at this, how?

scarlet cobalt
#

One message removed from a suspended account.

sullen nymph
#

Google time!

opal panther
scarlet cobalt
#

One message removed from a suspended account.

opal panther
#

i don't know

sullen nymph
#

Do you not have physical access to the router?

opal panther
#

not right now

#

is it not just on the computer?

scarlet cobalt
#

One message removed from a suspended account.

sullen nymph
#

Are you familiar with how an internet connection is performed?

scarlet cobalt
#

One message removed from a suspended account.

opal panther
#

nope

scarlet cobalt
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

opal panther
#

about ||13|| (over minimum discord age)

scarlet cobalt
#

One message removed from a suspended account.

opal panther
#

so, don't really understand this stuff

#

i've gotten it to work on my other computer

scarlet cobalt
#

One message removed from a suspended account.

restive otter
opal panther
#

i will try my other computer, which is set up for this stuff first, then try to get other stuff to work if not

scarlet cobalt
#

One message removed from a suspended account.

opal panther
#

okay

#

i will google this stuff

scarlet cobalt
#

One message removed from a suspended account.

calm reef
#

ok so i have this

#
      if(message.content.startsWith('$claim')) {
        let voted = await topgg.hasVoted(message.author.id)
        if(!voted) {
          message.reply("You havent voted yet. Use $vote to vote on top.gg")
        } else {
          message.reply('Thanks for voting and supporting us as we grow! You have been awarded 25k bobux')
          this.economy.addBal(message.author.id, 25000)
        }
#

but people can keep spamming it after they vote

#

how would i make it work only once

opal panther
#

and have the library just call a function

#

why not?

#

?

scarlet cobalt
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

opal panther
#

i meant, connect through the library, not sort of set up an API

wind wind
rain heart
#

paste in here what you have entered

warm linden
#

samesies but I no nothing on coding TDaPomRun

rain heart
#

wdym

#

no 404

wind wind
night ingot
#

Are you logged in on the right account?

wind wind
night ingot
#

๐Ÿ‘Œ

warm linden
#

is mine just cursed FF_shinralurk

rain heart
#

@warm linden that's a server isn't it?

#

or what is that

#

that's not even a bot on our site or a server

warm linden
#

Oh it has to be up set up through the website, welp I'm dumb, I was trying to get the automated messages when somone votes for a server

#

That was a new discord application I made

#

Is it still possible to make that happen?

rain heart
#

You have to submit your bot to begin with

#

and get it approved

#

you can't just get started without having submitted it yet

warm linden
#

Oki dokes, I'll get on that, thank you for the help Shinra_Hey

near remnant
#

@sullen nymph can you please help

rain heart
#

your webhook you're hosting yourself

near remnant
#

I dont have a webhook

#

@rain heart how do i make one

rain heart
near remnant
#

@rain heart

#

I dont need webhook?

rain heart
#

If you want live-notifications of votes, you do

near remnant
#

I want it when someone votes

#

Will i need webhook?

rain heart
#

yes

#

for live-vote notifications

near remnant
#

Ok

#

@rain heart so i just need to put my host ip:and a port

rain heart
#

you need to actually host the webhook, simply entering the ip and post does not work

near remnant
#

Wait

#

How do i host

#

A webhook

#

How do i even make a webhook?

#

@rain heart

rain heart
near remnant
#

I did

#

All it said was to put a webhook

#

Ita so undescriptive

opal panther
#

i managed to get some help with opening the ports

#

yep

#

maybe the autorization "password"

#

i spelled it wrong

#

it has a h

#

you need to use a "password"

#
bot.dblpy = dbl.DBLClient(bot, dbl_token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
#

the password

#

you can make it what ever you want

timber orbit
#

are there any current issues with the voting being posted multiple times?

#

bc ive had that happen a ton lately out of no where

night ingot
#

It will re-send the webhook if you don't respond with a 2xx response due to some fairly recent changes.

#

so if the developer hasn't implemented a response, it'll happen multiple times

timber orbit
#

that's exactly what i needed to hear, thanks so much!

jolly hornet
#

@severe blade no ads

orchid stag
#

no one cares bout ur twitch

frank salmon
#

Is there a webhook to trigger when the bot is invited for a guild ?

rain heart
barren kestrel
#

How can I say in disocrd.js when a user voted, do somehting. I don't want to use a webhook.

rain heart
brittle grove
#

What package do I need for JavaScript to access the api

rain heart
#

read pins

barren kestrel
#

I want to make a lb soon. where every time a user votes, it adds them a point

rain heart
#

can't really help with that

barren kestrel
#

I can do the db stuff its just that part

#

to connect to the webhook

#

ok np

#

if anyone knows just ping me

rain heart
#

you need to authorize your webhook

#

are you sending the authorization along with the request?

rain heart
#

apparently not or the authorization is wrong

#

Yes, and what you have defined in your code

#

it is not your bot or top.gg token

#

yes

#

how are you testing it then? DM me the url

#

and the authorization

#

how is top.gg supposed to make requests to it when it is on localhost

pastel drift
#
import dbl
import discord
from discord.ext import commands

class TopGG(commands.Cog):
    def __init__(self, client):
        self.client = client
        self.token = 'token'
        self.dblpy = dbl.DBLClient(self.client, self.token)
    
    @commands.Cog.listener()
    async def on_ready(self):
        print(f"LOGGED IN AS: {self.client.user}")

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

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

Can anyone help, why doesn't it print any data on vote?

pastel drift
#

self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
What does webhook_path mean here?

pastel drift
#

Vote

pastel drift
opal panther
#

nope

pastel drift
#

I've been trying to get this right from a month

opal panther
#

well, you didn't define client

#

or use bot.run

pastel drift
#

client.run in the main file?

#

Yes I've done it

#

It prints logged in as

opal panther
#

or define client/bot object

pastel drift
#

But no data is being printed

opal panther
#

oh

#

you have the correct authorization set up?

#

and webhook?

pastel drift
#

Is webhook a requirement?

opal panther
#

yes

#

can be a port though

pastel drift
#

I have this

#

But I haven't specified it in python file

opal panther
#

not how webhook works

#

http://ip:port/dblwebhook

#

second one

pastel drift
#

ip will be my host ip, right?

opal panther
#

yes

#

with an open port

pastel drift
#

I'll give it a try

opal panther
#

@pastel drift did it work?

pastel drift
opal panther
#

you need to open it

pastel drift
#

I feel so dumb rn

opal panther
#

i didn't know either, you aren't

#

any verified bot dev isn't dumb (in most ways)

pastel drift
#

Yeah but this api and webhooks are so confusing

opal panther
#

yep

pastel drift
#

I'll check if it works

opal panther
pastel drift
#

Tried to open a port at 5000 but still it shows closed

#

Shall I share my screen?

opal panther
#

you must have the program running

opal panther
pastel drift
#

One sec

pastel drift
opal panther
#

not now

#

sorry

#

is the port open? (did you open it)

pastel drift
opal panther
#

don't share that

#

yep

#

and are you running your code?

pastel drift
#

I have the program running as well

opal panther
#

okay, give it a minute

#

then try again

#

are you 100% sure that it's open?

pastel drift
#
import dbl
import discord
from discord.ext import commands

class TopGG(commands.Cog):
    def __init__(self, client):
        self.client = client
        self.token = 'token'
        self.dblpy = dbl.DBLClient(self.client, self.token, webhook_path='/dblwebhook', webhook_auth='top.gg', webhook_port=5000)
    
    @commands.Cog.listener()
    async def on_ready(self):
        print(f"LOGGED IN AS: {self.client.user}")

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

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

This is the right way to define path, auth and port?

opal panther
#

webhook auth should be a password

#

other than that, yep

#

http://ip:port/dblwebhook is your link for webhook

pastel drift
#

auth can be any string that I have saved in the top.gg?

opal panther
#

no, any string that you enter to top.gg

pastel drift
opal panther
#

oh

#

is it now open?

pastel drift
#

Nope

opal panther
#

maybe re-open it to make sure

#

and do you use terminal?

pastel drift
#

I made 2 inbound rules tcp and udp

#

5000 port number

pastel drift
opal panther
#

is it connected to the router thing? (for internet, not a mill)

pastel drift
#

Connected via wifi

opal panther
#

is it public?

pastel drift
#

Is it anything related to my antivirus?

opal panther
#

maybe

pastel drift
opal panther
#

i don't know how to open port, someone did it for me

pastel drift
#

I just changed it

opal panther
#

is it now open?

pastel drift
#

I have the program running again

opal panther
#

after it's "open" i can help more

pastel drift
#

Still not open

opal panther
#

it takes a minute

pastel drift
#

This is gonna be painful for me

#

Now I am testing this on windows and later I have to upload it to AWS ubuntu

opal panther
#

i use linux+ubuntu, and know how that works (terminal)

pastel drift
#

Yeah I know

#

Still not open

opal panther
#

does the computer say it's locally open?

pastel drift
#

192.168.1.1

#

I should actually do this via terminal of my cloud

opal panther
#

i now know how to set up an API, but that's about it

pastel drift
#

I'll see how can I get it done and I'll contact you back if it's okay?

opal panther
#

no need

#

okay though

#

anyone else can help

pastel drift
#

Thanks for helping me

sharp totem
#
import requests

x = requests.get("https://top.gg/api//bots/:807170972801040394/check?userID=528898630074236928")
print(x)

But I am getting response 401 Unauthorized

#

what do to?

pastel drift
#

Thanks finally works now

sharp totem
#

Okay I have that token, where should that be added in the request?

sharp totem
#

Python

#

API token or webhook token?

left mesa
#
/* THIS POSTS STATS TO DISCORDBOTS.ORG */
const DBL = require('@top-gg/sdk');
const express = require('express')

module.exports = {
    
    /**
     * Starts to post stats to DBL
     * @param {object} client The Discord Client instance
     */
    init(client){
        const stats = new DBL.Api("token");
        setInterval(async function (){
            await stats.postStats({
                serverCount: client.guilds.cache.size
            })
        }, 60000*10); // every 10 minutes
        
        const webhookClient = new Discord.WebhookClient('id', 'token')

        const app = express()
        const webhook = new DBL.Webhook('topggauth123')

        app.post('/dblwebhook', webhook.middleware(), (req, res) => {
            console.log(req.vote.user) // 221221226561929217
            webhookClient.send(`${req.vote.user} Voted me`)
        })
        app.listen(3000)
    }

};```not receiving messages
restive otter
#

what do you mean not receiving messages?

left mesa
restive otter
#

where do you host your bot

left mesa
#

dan

sharp totem
#

which are u using and how do you pass Auth in that?

restive otter
#

i forgot it lol

left mesa
restive otter
#

yeah

sharp totem
#

Hey Reis which programming languages you know?

restive otter
#

js

left mesa
#

๐Ÿ˜ข

sharp totem
#

Okay

#

You know to send request? @restive otter

#
import requests

x = requests.get("https://top.gg/api//bots/:807170972801040394/check?userID=528898630074236928")
print(x)

But I am getting response 401 Unauthorized

#

How do you do this in js

restive otter
#

there are many tutorials how to make requests online lol

sharp totem
#

I got the response {"voted":0}
I was checking if the user has voted

#

Is that indicating Boolean value 0 , 1 ?

#

or how many votes the user has

#

@restive otter you know ?

frank salmon
#

What is botid/votes?

#

Why are endpoints hidden?
Also "widgets"
lol

sullen nymph
#

What do you mean hidden

frank salmon
#

That on the web I have not found anywhere to access those endpoints, I found them browsing outside top.gg

sullen nymph
frank salmon
sullen nymph
#

Widgets aren't described yet

frank salmon
#

What else is not yet described?
Because "votes" neither is it

#

Sorry if I ask a lot, I'm curious

sharp totem
#

Even though I am voted it is still showing 0

#

I asked my friend to check

#

He also voted

#

But 0

#

False

sullen nymph
#

/votes should be documented

sharp totem
#

Mhm.

sullen nymph
#

Remove the colon

sharp totem
#

oh end point

sullen nymph
#

api/ not api//

frank salmon
sullen nymph
#

None

sharp totem
#

why still I am getting {"voted":0} this json

frank salmon
#

F, okay thanks @sullen nymph ๐Ÿ˜„

sharp totem
#

It is wrong that request

sullen nymph
#

That endpoint can take up to an hour to update

#

Where are you sending the Authorization header btw

sullen nymph
sharp totem
#

this is more effecient?

sullen nymph
#

No

#

It gets last 1000 votes for current month

#

not last 12 hours

restive otter
#

huh

sharp totem
#

oof

sullen nymph
restive otter
#

yeah

sharp totem
#

P.S?

sullen nymph
#

A postscript (P.S.) is an afterthought, thought that's occurring after the letter has been written and signed. The term comes from the Latin post scriptum, an expression meaning "written after" (which may be interpreted in the sense of "that which comes after the writing").

#

just a hint that you should use async stuff with async stuff

#

and requests isn't async

sharp totem
#

okay are they the same way like requests?

sullen nymph
#

No, refer to aiohttp docs on how to send HTTP requests

restive otter
#

This isnt working```py

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

channel = client.get_channel(828203330752610335)

embed = discord.Embed(title="Vote log", description=data)

await channel.send(embed=embed)

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

channel = client.get_channel(828203330752610335)

embed = discord.Embed(title="Vote log", description=data)

await channel.send(embed=embed)```
#

idk doesnt print

#

anything

#

when I test it , it shows webhook tested but doesnt print in my console

sullen nymph
#

on_dbl_test doesn't get called?

frank salmon
restive otter
#

no errors

#

token needs to be a string ?

#

I set port to 80 now

#

no idea what is port

#

alright

tribal anvil
#

How can i get all the server my bot is in displayed on the website?

tribal anvil
tribal anvil
#

python?

golden adder
#

Ah...

#

Can't help you there. I use js

tribal anvil
#

ok nw :)

golden adder
tribal anvil
#

ok thanks!

#

@golden adder That works tysm!

golden adder
#

No problem! ๐Ÿ˜Š

tribal anvil
#

Have a good day!

golden adder
#

Thanks. You too

tribal anvil
#

Thanks :)

tribal anvil
golden adder
#

In terminal? I don't know I'm not familiar with py

tribal anvil
#

ok nw thank you though!

frail quartz
#

How can I make a notice when voting

#

Is there a video?

#

It will be easier

#

Well, thank you loveee

#

Javascript

#

Thank youloveee

sullen nymph
#

by default*

tribal anvil
#

Itโ€™s not showing up on the website though?

sullen nymph
#

Wait, fuck, info not debug

#

What does your code look like?

still girder
#

why wont dblpy work i read the docs and everything i even looked at examples but my bot doesnt pick up when someone votes or gets a test

sullen nymph
#

Show your code

still girder
#

ok one sec

#

import dbl
import discord
from discord.ext import commands
import asyncio

class TopGG(commands.Cog): 
    """Handles interactions with the top.gg API"""
    def __init__(self, bc): 
        self.bc = bc 
        self.token = self.bc.dbltoken # set this to your DBL token 
        self.dblpy = dbl.DBLClient(bot=self.bc, token=self.token)

    @commands.command()
    async def botvotes(self,ctx):
        votes = await self.dblpy.get_bot_upvotes()
        await ctx.send("BreadBot has {} votes on top.gg!".format(len(votes)))

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

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

def setup(bc):
    bc.add_cog(TopGG(bc))
sullen nymph
#

on_dbl_vote not upvote

still girder
#

i looked at the docs

sullen nymph
#

You didn't specify webhook parameters in DBLClient

still girder
#

i tried both

#

bruh thats not what the docs say

sullen nymph
#

Which docs did you use for that example?

#

The one for python-sdk repo?

still girder
#

it should automatically put the parameters into place though

sullen nymph
#

Which parameters kekw

still girder
#

the bot and the dbl token

sullen nymph
#

Those are fine

#

You need to specify more

still girder
#

bru-

#

like what

sullen nymph
sullen nymph
still girder
#

why do i need a webhook

sullen nymph
#

Because webhook means receive votes in real time

still girder
#

and how the heck do i get a webhook port

sullen nymph
#

and for the on_dbl_x events to work you need the webhook

#

You simply specify any port you have accessible

still girder
#

where do i find webhook auth

sullen nymph
#

It's just a password you create and enter both in your code and your bot's top.gg page

still girder
#

:p sorry for asking so many questions

sullen nymph
#

Nah it's fine

still girder
#

where is the path for the webhook

sullen nymph
#

Seeking knowledge is admirable

#

It's a route that comes after either the domain or ip:port in your URL

still girder
sullen nymph
#

For example,
https://yada.yeehee.repl.co/dblwebhook
path here would be /dblwebhook

still girder
#

ohhhhhhh

#

OHHHHHHHHHHHHHH

sullen nymph
#

Though keep in mind that you will need to set webhook_port to 8080

still girder
#

ok

ornate cloud
#

How to create api?

still girder
#

do i need to put anything into my keep_alive file tho

sullen nymph
#

Oh dear, keep_alive, right

ornate cloud
#

Nvm

sullen nymph
#

Eugh... you can redirect the requests from your keep_alive to a locally hosted webhook

#

on some other port

#

Say, keep_alive on port 8080, while your dblpy webhook runs on port 5000

still girder
#

mk

sullen nymph
#

And since you can't run two webservers on the same port

#

yeah, that's why I mentioned redirecting the requests

still girder
#

ahh

sullen nymph
#

Essentially from internal repl proxy to your proxy to your webhook ๐Ÿ˜›

still girder
#

so would the api put the data into the link

sullen nymph
#

Nope, request body

#

since it's a POST request

still girder
#

ohhh so i can do..

#

request.form

sullen nymph
#

request.body iirc

#

Haven't touched Flask in a while, sec

still girder
#

mmm

#

so i would do something like

sullen nymph
still girder
#

mmm

#

thx

sullen nymph
#

I think you'll get the gist easier with that

tribal anvil
#

@sullen nymph i have used the code from the docs but the bots servers isnt updating?

sullen nymph
#

Yeah well that doesn't tell me shit, let's be honest

#

Could you actually provide your code and show what you use?

tribal anvil
#

Sure! sorry

sullen nymph
#

xd no problem

tribal anvil
#

import dbl
import discord
from discord.ext import commands, tasks
from discord.ext.commands import Cog
import asyncio
import logging


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

    def __init__(self, bot):
        self.bot = bot
        self.token = '' # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token)

    # 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"""
        channel = self.bot.get_channel(828240894800560128)
        await channel.send('Attempting to post server count')
        try:
            await self.dblpy.post_guild_count()
            await channel.send('Posted server count ({})'.format(self.dblpy.guild_count()))
        except Exception as e:
            await channel.send('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)

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

ah yes

#

the good ol' forgotten task start

#

Though can't blame you, dumb me forgot to put that initially there

#

In the cog's init add self.update_stats.start()

tribal anvil
#

ok thanks!

sullen nymph
tribal anvil
sullen nymph
#

Oh fuck right

still girder
#

@sullen nymph do i put the repl.co link here

sullen nymph
#

Remove the await asyncio.sleep(1800)

tribal anvil
#

ok thanks!

still girder
#

k thx

sullen nymph
#

in case that doesn't happen, you can wait 30 minutes

tribal anvil
#

It worked tysm!

sullen nymph
still girder
#

@sullen nymph tysm the flask thing worked

sullen nymph
#

hell yeah

restive otter
#

Hey where are api key the page to generate does not exist anymore

#

How do we get the AUTH_PASS for our bot?

restive otter
sullen nymph
#

What do you mean by AUTH_PASS?

sullen nymph
quasi fjord
#

hey! i need help with logging votes when they happen. I have this code which runs while my bot runs.

// top.gg

const top = require('top.gg-core');

const topgg = new top.Client(dbltoken);
const webhook = new top.Webhook(webhookPW);

client.on("ready", () => 
{
    if (token == devtoken) console.log("MIZU (DEVELOPMENT) IS READY");
    else console.log("MIZU (PUBLIC) IS READY");

    topgg.post({
        servers: client.guilds.cache.size
    });

    setInterval(() => {
        topgg.post({
            servers: client.guilds.cache.size
        });
    }, 3600000); // posts stats every 1h
});

topgg.on('posted', data => {
    console.log(data);
});

webhook.login(`${webhookIP}/mizutopggVote`, '3000');

webhook.on('vote', vote => {
    console.log(`Voter id: ${vote.user}\nAll data: ${vote}`);
});

It console.logs the server info every hour:

{
  servers: 9,
  shard: { id: null, count: null },
  timestamp: 1617544395488
}

But when I vote, it does not detect it. Here is the webhooks page.

restive otter
sullen nymph
#

What the fuck is top.gg-core

sullen nymph
#

Why not use the official @top-gg/sdk package

restive otter
sullen nymph
#

It's a password that's simply used to confirm that requests are coming from top.gg

#

Make sure it matches the value in the Authorization field on top.gg

restive otter
sullen nymph
#

Yeah

restive otter
#

Ok tysm

quasi fjord
# sullen nymph Why not use the official `@top-gg/sdk` package

thanks! will this code do the job of logging when someone votes? (on the npm site of the sdk) :

app.post('/dblwebhook', webhook.middleware(), (req, res) => {
  // req.vote is your vote object e.g
  console.log(req.vote.user) // 221221226561929217
}) // attach the middleware
``` sorry im quite new to webhooks
sullen nymph
#

That's just the handler, which looks good to me. Make sure you run the webhook on an accessible port

quasi fjord
#

okay! so if the webhook url is all good, that, along with the rest of the code using express in the example, should log the user's id when they vote?

sullen nymph
#

Keyword: should

#

I'm only relying on common sense and intuition since I'm not exactly proficient in JS

#

It's better if you test it for yourself

quasi fjord
#

okay! thank you so much for the quick help ๐Ÿ™‚

sullen nymph
quasi fjord
sullen nymph
#

Well, do you want to use the API for stuff like posting your bot's server count?

quasi fjord
#

nope

sullen nymph
#

Ehhh then you can scrap that and just use the webhook

quasi fjord
#

oh nice! this is so convenient. thank you very much again!

sullen nymph
rain heart
#

-api

abstract mothBOT
#

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

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

grim solstice
#

Sry

#

Realized it

restive otter
#

Guys i wanted to know how can i get when a user vote for my bot then example give him some coins. i use discord.js

drifting gorge
#

How fo I setup upvote webhook?

quasi fjord
#
var path = require('path');
const { webhookPW } = require(path.resolve(path.normalize("./config.json")));

const init = async() =>
{
    console.log('[EXPRESS] STARTING SERVER')
    const express = require('express')
    const app = express()
    const Topgg = require('@top-gg/sdk')
    const webhook = new Topgg.Webhook(webhookPW) // add your top.gg webhook authorization (not bot token)
    
    app.post('/dblwebhook', webhook.middleware(), (req, res) => {
        // req.vote is your vote object e.g
        console.log(req.vote)
    }) // attach the middleware
    
    app.listen(25569, () => console.log('SERVER READY'))
}
module.exports.init = init

Hey! this is my webhook code, but my vps is not receiving the requests sent by topgg tests. I have used sudo ufw allow 25569 and sudo ufw allow http Any idea how to fix this?

restive otter
#

how do i make the bot give someone rewards when they vote top.gg

rich helm
quasi fjord
restive otter
#

whats webhook password

polar steeple
#
bot.on('ready', async () => {
    api.postStats({
        serverCount: bot.guilds.cache.size
      })
})

Anyone know why this is only coming up as 2 when the bot is in like 100 guilds?

rain heart
#

-api

abstract mothBOT
#

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

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

rain heart
polar steeple
#

that is topgg api?

rain heart
#

oh my bad

polar steeple
drifting gorge
#

Can someone help me make a webhook to travk upvotes? Im python

restive otter
#
gcount = len(bot.guilds)
url = "https://top.gg/api/bots/825063508806467664/stats"
data = {'server_count': int(gcount)}
headers = {'authorization':'top.gg auth token'}
requests.post(url, headers=headers, data=json.dumps(data))

what am I doing wrong here?

#

I get a response 400 when I send the request

sullen nymph
#

use json= not data=

#

What you are doing is simply sending a string without a Content-Type header

restive otter
#

ah ok

#

ill try that again

#

thanks, I got a response 200

#

not sure if it actually posted the guild count tho

#

nvm it did

#

thanks

sullen nymph
restive otter
#
dbl_token = os.environ.get("DBL_TOKEN")
webhook_password = os.environ.get("WEBHOOK_PASSWORD")
discord_webhook = os.environ.get("WEBHOOK_URL")
bot.dblpy = dbl.DBLClient(bot, dbl_token, webhook_path=discord_webhook, webhook_auth=webhook_password, webhook_port=5000)

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

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

dont work?

sullen nymph
#

webhook_path must be a route not a Discord webhook URL

restive otter
sullen nymph
#

Do you know how webservers operate

restive otter
#

do i put repl it

#

link

sullen nymph
#

Route and URL are different

#

route comes after domain

#

For replit you use port 8080 and use repl.co as the URL

#

webhook_path must be anything like /dblwebhook

restive otter
#

webhook_path='/dblwebhook'

#

this?

sullen nymph
#

so that your URL becomes https://xxx.yyy.repl.co/dblwebhook

restive otter
#

alr

#
dbl_token = os.environ.get("DBL_TOKEN")
webhook_password = os.environ.get("WEBHOOK_PASSWORD")
discord_webhook = os.environ.get("WEBHOOK_URL")
bot.dblpy = dbl.DBLClient(bot, dbl_token, webhook_path='/dblwebhook', webhook_auth=webhook_password, webhook_port=8080)
sullen nymph
#

Looks good

restive otter
#

so should i tes

sullen nymph
restive otter
#

on test it doesnt doa ntyhing

#

oh ok

sullen nymph
#

as well as Authorization

restive otter
#

auth is pwd

#

so for webhook url i put the actual webhook url

sullen nymph
restive otter
#

oh ok

sullen nymph
#

Discord webhooks aren't related to this at all

restive otter
#

so its

sullen nymph
restive otter
#

alr

#

doesnt do anything

#

do i put /dblwebhook after the repl.co part

sullen nymph
#

Yes

restive otter
#

hm

#

doesnt work still

#

on test

#

nothing hapepnes

#
import dbl

dbl_token = os.environ.get("DBL_TOKEN")
webhook_password = os.environ.get("WEBHOOK_PASSWORD")
discord_webhook = os.environ.get("WEBHOOK_URL")
bot.dblpy = dbl.DBLClient(bot, dbl_token, webhook_path='/dblwebhook', webhook_auth=webhook_password, webhook_port=8080)

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

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

Do you run that file anywhere

restive otter
#

oh right i didnt run it

#

it says bot is not defined

restive otter
#

wait lemme try making it one file

craggy rivet
#

One small question:
by running get_user_vote(user_id), does it return if the user has vote at least once in their life, or in the past 12 hours?

cursive finch
#

how do you make it send webhook to my channel when someone upvotes i cand understand documentation bc im not good at reading
what do i put in authorization

drifting gorge
#

How do I make a webhook send a message whenever someone uovote in python?

restive otter
cursive finch
#

same

restive otter
#

im still trying to post server count

#

too

rain flame
#

How can i check if a user has voted for my bot in code

night ingot
vague tangle
#


// Make sure to install this with 'npm install dblapi.js`
const DBL = require('dblapi.js');
// The webhookPort can be whatever you want but make sure you open that port in the firewall settings (for linux for example you can use `sudo ufw allow 8000`)
// The webhookAuth is set by you, make sure you keep it secure and don\'t leak it
const dbl = new DBL(config.API_TOKEN, { webhookPort: 8000, webhookAuth: 'password' });

// When the webhook is ready log it to the console, this will log `Webhook up and running at http://0.0.0.0:8000/dblwebhook`
dbl.webhook.on('ready', hook => {
   console.log(`Webhook up and running at http://${hook.hostname}:${hook.port}${hook.path}`);
});

// This will just log errors if there are any
dbl.on('error', e => {
   console.log(`Oops! ${e}`);
})

// When the webhook receives a vote
dbl.webhook.on('vote', async vote => {
   // This will log the whole vote object to the console
   console.log("debugging: someone voted lol")
   console.log(vote)
   // Get the Discord ID of the user who voted
   const userID = vote.user;
   // If the channel to send messages in exists, we send a message in it with the ID of the user who votes
   vote.user.send("Thanks for voting! $20 has been added to your balance.")
  //i give the money here
})
#

does anyone have any idea why this this isnt working

night ingot
#

Does it log any errors?

tribal anvil
#

@sullen nymph Sorry to bother you again but the bot doesn't seem to be refreshing every 30mins?

sullen nymph
#

It is 6 am

tribal anvil
#

oh shit, sorry

sullen nymph
#

So don't mind if I don't make sense sometimes

#

What's your code again

tribal anvil
#

CRAP

#

forgot to remove my token

#

ok regened it so we all good

#
import dbl
import discord
from discord.ext import commands, tasks
from discord.ext.commands import Cog
import asyncio
import logging


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

    def __init__(self, bot):
        self.bot = bot
        self.token = '' # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token)
        self.update_stats.start()

    # 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"""
        channel = self.bot.get_channel(828240894800560128)
        await channel.send('Attempting to post server count')
        try:
            await self.dblpy.post_guild_count()
            await channel.send('Posted server count ({})'.format(self.dblpy.guild_count()))
        except Exception as e:
            await channel.send('Failed to post server count\n{}: {}'.format(type(e).__name__, e))


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

Does it send the messages though?

restive otter
#

channel would be None if the bot wasn't ready yet

vague tangle
#

but nothing happens when i test

night ingot
vague tangle
#

yeah I'm sure

restive otter
tribal anvil
#

Yh i fixed it sorry for the inconvenience...

restive otter
#

ive been having trouble

tribal anvil
#

I just change the channel = to self.channel udner the innit

restive otter
#

ok thanks

#

still nothing hapepns

restive otter
tribal anvil
#

how are you running it

#

just the file?

restive otter
#

yeah

tribal anvil
#

you need to run your whole bot

#

i use cogs

restive otter
#

i have no cogs

#

in my bot

#

yet*

#

like its all one big file

tribal anvil
#

yh then it wornt work sorry

restive otter
#

oh ok

#

could i run seperate

#

?

#

like having to codes running on the same bot

tribal anvil
#

thats what cogs is

#

runs several files at once

#

Im not the best at this stuff

#

try speaking to one of the staff sorry

restive otter
#

im not either ;-;

tribal anvil
#

xd

restive otter
#

could i host a seperate code for it like on repl it or something

#

i use repl it for small codes

pine harbor
#

when

rain heart
#

when what

vague tangle
#

oh

#

thanks

#

how else should i do it then

smoky breach
#

Trying to setup a vote webhook for my bot but for some reason it's not working. In console - upon startup - it shows Top.gg API running at http://0.0.0.0:521/dblwebhook which is concerning because 0.0.0.0 as you may have guessed, is not the IP.

#
const dblapi = require("top.gg");
const express = require("express");
const dash = express();
const verify = express();
const http = require("http");
const server = http.createServer(dash);
const get = require("superagent");
const colors = require("colors");

module.exports = (client) => {
    // Discord Bot List (now top.gg) API, used for communicating server count and receiving vote hooks
    if (!process.env.DBL_TOKEN) return;
    const dbl = new dblapi(process.env.DBL_TOKEN, {
        webhookPort: 521, // Replace this with whatever port you want to run the webhook on
        webhookAuth: process.env.DBL_AUTH,
    });

    dbl.webhook.on("ready", hook => {
        console.log(colors.magenta(`Top.gg API running at `) + colors.white(`http://${hook.hostname}:${hook.port}${hook.path}`));
    });

    dbl.webhook.on("vote", vote => {
        const settings = client.getSettings(channel.guild.id);
        const logs = client.channels.cache.get(settings.modLogChannel);
        if (!logs) return;
        logs.send(`User with ID ${vote.user} just voted!`);
    });
};

I saw above that the dblapi.js package is deprecated, hence why I'm using top.gg now.

night ingot
smoky breach
#

Hm..

#

How come whenever I test the webhook from the site, it doesn't send anything?

night ingot
#

Is the port correct, and open?

smoky breach
#

Yep, I chose 521 instead of the usual 80 or 443 as those are already in use.

night ingot
smoky breach
#

Running on a VPS so can't use that website.

#

I did check to see if it was open though.

#

Ran sudo lsof -i -P -n | grep LISTEN in CLI.

restive otter
#

This code isnt working for me, it has no errors though(I have defined the tokens and auths earlier in the code)

app.post("/dblwebhook", topwebhook.middleware(), (req, res) => {
  console.log(req.vote.user); 
});
night ingot
#

@smoky breach could you try to send your own webhook to the server, just to make sure it's actually working?

smoky breach
#
dbl.webhook.on("vote", vote => {
        const settings = client.getSettings(channel.guild.id);
        const logs = client.channels.cache.get(settings.modLogChannel);
        console.log("foo")
        if (!logs) return;
        console.log("bar?")
        logs.send(`User with ID ${vote.user} just voted!`);
    });

Did the ol' foobar trick and it seems neither foo, nor bar is logged.

night ingot
#

Also, remember to hit "Save" after you change the webhook url on the page. It doesn't save automatically

smoky breach
#

So I assume it's an issue with the on vote event.

#

Regenerated credentials and saved, didn't seem to fix the issue though alas.

night ingot
#

I'm not sure how the js lib works, but could you try dbl.webhook.on("test"... instead?

smoky breach
#

Just to double-check, syntax is https://discordapp.com/api/webhooks/:ID-OF-BOT/:DBL-TOKEN, right?

#

Or am I still outdated?

#

Had this all setup perfectly a while ago but then with the deprecation of dblapi.js, everything seems to have been changed.

smoky breach
#

dbl.webhook.on("ready", hook => { }) Already got this so I know that it's working.

night ingot
#

actual votes and test votes are two different events afaik

smoky breach
#

Doesn't seem to have changed anything alas.

lusty current
#

how do i thank a user who voted for my bot via her dm?

sullen nymph
restive otter
#

Can you still use the top.gg package or is it a must to switch to top.gg/sdk?

restive otter
#

hmm

#

soo you might switch to @top-gg/sdk

restive otter
#

ยฏ_(ใƒ„)_/ยฏ

#

it is easy tho

restive otter
#

I triple checked everything

#

it works for me tho

#

hmm

sullen nymph
#

Did you run .listen

restive otter
#

yes

#

app.listen(3000)

sullen nymph
#

Are you sure the port is accessible

restive otter
#

I think so, havent checked

#

where do you host your bot?

#

I host the Canary(Test) bot on Visual Studio Code, but I publish the changes to my main bot which is hosted on repl

#

so the webhook is on replit?

#

No

#

Its on Visual Studio Code

#

well then cant help ya

sullen nymph
#

So locally

restive otter
#

cuz i am bad at local hosting things lol

#

but once its working, I insert the code in my main bot hosted on repl

sullen nymph
#

Use port 8080, make sure port is forwarded to your device and your device's firewall isn't blocking requests to it

restive otter
restive otter
#

any port

#

oh alright

#

So lemme try coding directly in the main bot which is hosted on repl

#

Thanks for the help

restive otter
astral schooner
#

hello

restive otter
#

Hi

sullen nymph
#

Oh, interesting

sullen nymph
golden adder
untold birch
#

How to Direct Message the user when they vote :?

#

How?

#

right now it only logs in the console

#

the use id

#

user*

#
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
  console.log(req.vote.user)
})``` and this si the code
#

is*

#

like bot.user.get?

#

i did

#

TypeError: bot.users.get is not a function

#

?

#

So... What can i doo?

#

:<

tribal anvil
#

Keep getting this Attempting to post server count Failed to post server count NameError: name 'channel' is not defined Attempting to post server count Attempting to post server count Posted server count (26) Posted server count (26)

#
import dbl
import discord
from discord.ext import commands, tasks
from discord.ext.commands import Cog
import asyncio
import logging


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

    def __init__(self, bot):
        self.bot = bot
        self.token = 'nono' # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token)
        self.update_stats.start()
        self.channel = self.bot.get_channel(828240894800560128)

    # 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"""
        
        await self.channel.send('Attempting to post server count')
        try:
            await self.dblpy.post_guild_count()
            await self.channel.send('Posted server count ({})'.format(self.dblpy.guild_count()))
        except Exception as e:
            await self.channel.send('Failed to post server count\n{}: {}'.format(type(e).__name__, e))


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