#topgg-api

1 messages · Page 63 of 1

deep bay
#

api requests

#

dbl.webhook.on('vote', vote => {})

junior cloud
#

.webhook

azure pollen
#

can

#

you show all code lmfao

dense basalt
deep bay
junior cloud
#
dbl.webhook.on("ready", hook => {
    console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on("vote", async (vote) => {
    console.log("ff");
//some unnecessary stuff...
})
const dbl = new DBL(token, { webhookPort: 5000, webhookAuth: "woahthislookscool" }, bot);
dbl.on("posted", () => {
    console.log("Server count posted!");
});

dbl.on("error", e => {
    console.log(`Oops! ${e}`);
});```
azure pollen
#

are you both having the same issue?

junior cloud
#

yes

azure pollen
#

okay hold

deep bay
#

yes

azure pollen
#

CC @arctic arch are we having issues with webhooks?

jolly hornet
#

also you missed a semicolon on line 37 @deep bay

deep bay
#

that's needed?

junior cloud
#

no

jolly hornet
#

No

junior cloud
#

but it makes it prettier

deep bay
#

i'll add that, just for you

jolly hornet
#

And consistent

azure pollen
#

why does it matter, that's not even the issue

#

stop

dense basalt
#

I'm using a webserver to process votes. But it works for me.

azure pollen
#

the most pointless chatter

chrome canyon
#

I would confirm webhooks working or nah but that'd require to get a second bot approved mmLol

arctic arch
#

webhooks work

junior cloud
#

hm

dense basalt
deep bay
#

yes

junior cloud
#

@deep bay what did you write in your URL

#

If you even got anything there

chrome canyon
#

localhost:8080

dense basalt
#

And that you are using the same in your code

deep bay
#

i wrote the webhook url that i created

dense basalt
#

@chrome canyon shush

junior cloud
#

wait wait

#

are you using a discord webhook?

deep bay
#

yes...

junior cloud
#

00f

dense basalt
#

Do you have a webserver for it

deep bay
#

unsure if thats what i was suppsoed to do..

#

no Timo

dense basalt
#

Because DBL is self does not send that in Discord webhooks format

deep bay
#

what am i supposed to put in the webhook url box then

azure pollen
deep bay
#

ah

junior cloud
#

b

deep bay
azure pollen
#

test the webhook

deep bay
#

yeah but define test

junior cloud
#

brainpower 100

deep bay
#

does it run the stuff in the vote event?

junior cloud
#

its sending a post request Ig

deep bay
#

it's still not emitting the vote event

#

@azure pollen do you have any idea why?

#

apologies for the ping

azure pollen
#

im busy now ask a mod ¯_(ツ)_/¯

deep bay
#

okay np

chrome canyon
#

@azure pollen if you make me a mod I'll reply as a mod

nimble heart
#

Lol

#

Is that the highest role in the server?

chrome canyon
#

no

nimble heart
#

Web admin?

#

What is

chrome canyon
#

the highest role is tonkku above all else

#

the highest actual useful role is Web Admin

#

the most op role is op af

#

but that's not fitting for this channel

deep bay
#

i'll just disband vote rewards for now, thanks for all the previous help

#

have a great day

restive otter
#

@deep bay what site is that

spiral steeple
#

the url cant be a discord webhook

deep bay
spiral steeple
#

it doesnt work like that

deep bay
#

its not a discord webhook anymore

worn quail
#

@restive otter it has to be a webhook made not using discord

#

eg googling "free webhook" should work

restive otter
deep bay
#

i searched that and went on the first one, and its accepting requests when i use the test button

worn quail
#

^

deep bay
#

but i dont get what to do next

restive otter
#

lmao

chrome canyon
#

Okay so

#

A normal webserver works the following

#

You send it a GET request and it returns usually html

#

if you submit a form, you send a POST with the form data, and the web server handles that data

#

A webhook only accepts the second type

#

So basically you hook up a webserver like express

#

And process all requests

deep bay
#

damn, didnt know vote rewards was so complex

chrome canyon
#

It really isn't

deep bay
#

i think ill just not have vote rewards

chrome canyon
#

What're you currently using?

#

Node.js?

deep bay
#

d.js

chrome canyon
#

Yeah well

#

express is the way

#

iirc dblapi.js

#

Has it inbuilt

restive otter
chrome canyon
#

Yes

restive otter
#

weird, says invalid

#

nvm works

chrome canyon
#

Should I write a dependencyless webhook module for dbl

dense basalt
#

yes

chrome canyon
#

@dense basalt do you have a node bot with eval

dense basalt
#

yes

#

but my VPS is doing maintenance

chrome canyon
#

Can you eval require('os').networkInterfaces().eth0[0].address

dense basalt
#

so it's down for some hours

chrome canyon
#

No worries

#

But can you eval that

#

And see if it gives you your public ip

dense basalt
#

I can just host it on my pc, brb

hearty dagger
#

I got you

chrome canyon
#

Meh won't work on pc

#

It uses eth0

dense basalt
#

I can use my other VPS then

#

with like 1 GB RAM

#

one sec

chrome canyon
#

It works on GalaxyGate

#

I just need some more coverage before putting it into a module

dense basalt
#

Yeah it gives my actual VPS's IP

chrome canyon
#

Host?

dense basalt
#

the IP of my server

chrome canyon
#

nono

dense basalt
#

oh

#

Contabo

chrome canyon
#

On which host

#

Neat

#

That's two down

restive otter
dense basalt
#

and 800 to go

chrome canyon
#

nah I need like 5 working hosts

dense basalt
#

A password you come up with to verify it's you

chrome canyon
#

then I'm convinced

#

just generate a 32 bit token

dense basalt
#

which one do you currently have

#

64 bit smh

chrome canyon
#

I use 512 to sign my reqs

#

on aether

dense basalt
#

talking about security

#

I will use 4096-bit from now on

chrome canyon
#

nice

dense basalt
chrome canyon
#

same

hearty dagger
#

Infinity years

chrome canyon
#

but yeah so

hearty dagger
#

Nice

chrome canyon
#

probably on all kvm servers

#

require('os').networkInterfaces().eth0[0].address gives ext ip

#

good enough ig

dense basalt
#

have fun

#

I'm going out for dinner, ping me if you need anything else qtie

chrome canyon
deep bay
#

ravy that gives an ip address lol

chrome canyon
#

very helpful

#

can you check if that's your server's ip

#

if yes, it's correct

deep bay
#

my server's ip?

#

how i check that

chrome canyon
#

hostname -I

#

usually

#

@dense basalt do you use windows

deep bay
#

yeh its the same

chrome canyon
#

perfect

#

anyone who uses node on windows?

hearty dagger
#

I have it installed

chrome canyon
#

can ya run require('os').networkInterfaces() and tell me which of those could give a possible external IPv4 (not 192.x)

#

for me it's called 'vEthernet (Default Switch)'

hearty dagger
#

Lemme just boot up

chrome canyon
#

ty because uh

#

I'm tryna auto-generate the webhook url

#

and that requires ext ip usually

dense basalt
#

@chrome canyon Linux for vps, macos for pc

chrome canyon
#

ok can you run the same thing on mac

#

require('os').networkInterfaces()

#

and see which one is an ext ip

dense basalt
#

I'm out for dinner now meowblep

chrome canyon
#

yeah doesn't matter when :p

#

just ping me

dense basalt
#

Probably in 3 hours imo

chrome canyon
#

because I'd love to not need to make an external request to get the public ip

hearty dagger
#

I don't get an external ipv4

chrome canyon
#

what interfaces do you get?

hearty dagger
#

Ethernet and "Loopback Pseudo-Interface 1"

chrome canyon
#

are you sure Ethernet doesn't have a public ip in any of the address fields?

hearty dagger
#

I get 1 ipv4 and 5 ipv6 fields

#

And idk what an external ipv6 looks like

chrome canyon
#

ok thanks

#

so it won't work with IPv6 probs

dense basalt
#

Do you want me to run anything on Linux since I can do that from my phone

chrome canyon
#

but yeah it should be able to autodetect some stuff

#

same procedure :p

#

require('os').networkInterfaces()

dense basalt
#

Aight, one sec

chrome canyon
#

and see which ones could potentially give ipv4

dense basalt
#

On console or what

chrome canyon
#

ye

#

android architecture might be close to an rpi or stg

dense basalt
runic grove
#

enter a node repl first, assuming tahts node

dense basalt
#

I'm on Mobile so this shit is gay to do

shut ibex
#

@chrome canyon do you still need it

chrome canyon
#

What?

shut ibex
#

the require('os') shit

chrome canyon
#

yes

#

As much testing as possible

#

Because that can be used to auto generate the webhook url

dense basalt
#

@chrome canyon Linux:
Running require('os').networkInterfaces() gives me 2 IPv4s

#

MacOs:
Running require('os').networkInterfaces() gives me 2 IPv4s and 4 IPv6s

#

And you're qt

chrome canyon
#

@dense basalt which interfaces give you the external ips?

#

like

#

the actual ones

#

not 192.x

dense basalt
#

What do you mean, I only get address, netmask, family, mac, internal and cidr

arctic arch
#

you dont get your public ip that way

chrome canyon
#

yes you do

dense basalt
arctic arch
#

you'll only get a private internal ip

chrome canyon
#

on linux it's eth0

#

on both my VPS' it's set in eth0

#

@dense basalt can you check eth0/address against your public ip

dense basalt
#

Linux: eth0 gives my VPS's IP and lo gives me public Ip I guess

chrome canyon
#

lo is loopback

arctic arch
#

fine keep going if you want to waste your time

chrome canyon
#

why tho tonkku

#

it works on literally every VPS it's been ran on

dense basalt
#

Not sure what my mac's IP is

chrome canyon
#

os.networkInterfaces().eth0[0].address is 99% your external IP on a VPS

dense basalt
#

TypeError: Cannot read property '0' of undefined

#

On Mac^

chrome canyon
#

well yeah

#

because mac

#

which interfaces you got there?

#

also your device does know it's public IP otherwise hostname -I would be bork

#

so you're able to get it in node

dense basalt
#

lo0, en0, awdl0 and utun0

arctic arch
#

all I get is internal ip

chrome canyon
#

on?

arctic arch
#

literally any machine I've ever used lmao

chrome canyon
#

heh

#

well if I eval it, I get my public IP

#

on wsl, ubuntu, and arch.

#

and across two different virtualization thingies so far

#

so I'm pretty confident

arctic arch
#

both GCP and DO VPSes give internal IPs as well

chrome canyon
#

also this is just to simplify people's webhook stuff

#

if it doesn't get the ip then /shrug

#

but if it does then bonus point

arctic arch
#

I would've implemented that in the library if it was possible but it isn't

#

at least on most machines

#

except yours

chrome canyon
#

and like three other people's

#

out of five I asked

dense basalt
#

Nice clicking on General

chrome canyon
#

but my personal goal is to get it without sending a request

#

and a machine knows its public IP so there has to be a way 😔

arctic arch
#

yeah I was going to do that but left it out from the initial release of webhooks

#

I wanted to at least have it as an api request on DBL api instead of any random site but still doing a request is a bit meh

chrome canyon
sudden rampart
#

curl 216.239.34.21 -H "Host: ifconfig.me" :^)

chrome canyon
#

yes but curl in js would require a child_process call

#

and if I call child_process, I can also just do hostname -I

arctic arch
#

is that uppercase i

dense basalt
#

Yes it is

arctic arch
#

not a valid option for me

dense basalt
arctic arch
dense basalt
#

They are using one dash though

#

Wait, nvm

#

It works for me

sudden rampart
#

doesn't work for me either

#

hostname (GNU inetutils) 1.9.4

dense basalt
#

I get my IP twice when doing a lowercase i

sudden rampart
chrome canyon
#

what a scam

#

btw

sudden rampart
#

also, just executing that won't work on eg windows

#

it's more reliable to just have an api endpoint that returns the public ip

dense basalt
chrome canyon
#

webhooks don't work on Windows anyway

#

because noone has a static IP

sudden rampart
#

there's windows server

#

and there are also people with static ips

chrome canyon
#

well but windows server is not my fault

arctic arch
#

hostname (GNU inetutils) 1.9.4
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Debarshi Ray.

chrome canyon
#

try hostname --all-ip-addresses

#

-I is a shortcut

sudden rampart
#

hostname: unrecognized option '--all-ip-addresses'

chrome canyon
#

yeet

arctic arch
dense basalt
#

hostname --all-ip-addresses just gives me my VPS's IP

chrome canyon
#

weird as heck

sudden rampart
#

different distros can have different commands

chrome canyon
#

yes

#

but well that's unrelated to node

#

so

#

do you have node installed Natan?

sudden rampart
#

yes

chrome canyon
#

can you try require('os').networkInterfaces()

dense basalt
chrome canyon
#

and see if any of the address fields match your ext ip

dense basalt
#

Oh my god this hotel wifi

sudden rampart
#

none

chrome canyon
#

that's weird as heck

#

what distro?

sudden rampart
#

manjaro

chrome canyon
#

it works on my arch boot

sudden rampart
arctic arch
#

3/6

#

your success rate is getting lower 😛

chrome canyon
#

2804:431:b700:dac3:8ab5:63bc:79a8:4647

#

might be public

#

fe80:: is internal for ipv6

#

fc00 and fd00 are local

#

might just have IPv6 as ext IP

sudden rampart
#

¯_(ツ)_/¯

#

anyway parsing that data would be a pain

chrome canyon
#

because I'm like completely confused

#

and no it wouldn't tbh

sudden rampart
#

2804

arctic arch
#

I dont have ipv6 rn

sudden rampart
#

well, give me a function that can parse that data from any format and get an accurate external ip

arctic arch
#

also a problem with your solution

chrome canyon
#

it's not that hard

arctic arch
#

it's not always eth0

sudden rampart
#

thing.wlp3s0[2].address

chrome canyon
#

just iterate over all the interfaces

sudden rampart
#

mine's that

arctic arch
#

are you on wifi?

sudden rampart
#

and i have half a dozen different addresses

#

yes

chrome canyon
#

and excluse 192.x

#

and fe80::

arctic arch
#

yeah I think thats the same as my laptop

chrome canyon
#

and you're gtg

sudden rampart
#

and 172.*

chrome canyon
#

¯_(ツ)_/¯

#

yeah and 172/169

sudden rampart
#

and 10.*

#

and etc

arctic arch
#

my lan is enp0s31f6

chrome canyon
#

yeah but like uh

#

it's not impossible

sudden rampart
#

i have one that's fd37:267c:7d7a:1:84dc:19ea:89da:3d83

#

and it's not my public ip

chrome canyon
#

it's def not the easiest

arctic arch
#

my gcp is ens4

sudden rampart
#

and shows on the array before my public ip

chrome canyon
#

no fd and fc are internal

#

for ipv6

sudden rampart
#

¯_(ツ)_/¯

chrome canyon
#

it's the 192.168.0 and .1

sudden rampart
#

easier to just hit an api endpoint than relying on that

chrome canyon
#

of IPv6

#

yes bUT

#

api is always a possible external failure

sudden rampart
#

if api fails then the webhook won't work anyway

chrome canyon
#

I personally would rather have a complicated solution

#

than an external one

sudden rampart
#

schedule a retry and keep doing

#

also an api endpoint would allow libs for other langs to be able to just hit it instead of having to figure out the ip themselves

#

¯_(ツ)_/¯

chrome canyon
#

well that'd then require an api endpoint at dbl

#

which I'm sure is possible

#

but doesn't currently exist

pearl ibex
#

Can someone help me out? I fetch the vote from webhook on event but its not working

dbl.webhook.on('vote' , vote => {
   const user = bot.users.get(vote.user)
   user.send("Thanks for voting!")
   bot.channels.get('the channel id im 100% sure true").send(user.username + " voted for the bot!")
})
#

I tried testing and actual voting both arent working

#

Whats the issue

pearl ibex
#

Can you help me with it

#

@NeverMinD#1451

#

@restive otter

restive otter
#

@pearl ibexu need to set webhook server and put webhook auth. And token in your bot's page

pearl ibex
#

I can post the server count and stuff @restive otter

restive otter
#

Servercount and webhook thinga different

pearl ibex
#

How i can set the webhook? Im using heroku

thick flint
#

how do i get a webhook URL?

#

and is it neccasary for me to get the votes on the code end?

#

ping me pls

spiral steeple
#

@thick flint you need to make a server that accepts post requests

amber dune
#

@hearty dagger please dont just say stuff like "heroku bad" it ads nothing to the conversation and causes arguments..

hearty dagger
#

understandable

#

consider it done

cerulean monolith
#

i cant get hold of bots api for discord servers
anyone guide me

#

anyone help me how to add this

#

this servers thingy

dense basalt
#

There literally is an example on the docs

cerulean monolith
#

thanks

wintry kernel
#

@plush oar what library are you

plush oar
#

js

wintry kernel
plush oar
#

// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})

dbl.on('error', e => {
console.log(Oops! ${e});
})

#

do i use that to display my server count ?

wintry kernel
#

I have no clue, I don’t use js

plush oar
#

oh lol

wintry kernel
#

You can get your server count using this and your bots id

plush oar
#

thank you so mucj

#

and that puts the server cound on the website or my ternimal log ?

wintry kernel
#

No

plush oar
#

what

wintry kernel
#

I have no clue what part posts it, just read the whole page

plush oar
#

ok sorry

hearty lintel
#

@plush oar show the full error

#

Here please

plush oar
#

at Module._compile (internal/modules/cjs/loader.js:774:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
at Module.load (internal/modules/cjs/loader.js:641:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)
at internal/main/run_main_module.js:17:11

hearty lintel
#

The full thing

#

Not just the stack

plush oar
#

it has my API key in the error tho

hearty lintel
#

Then censor it

#

Or remove it and replace it with “token”

plush oar
#

const dbl = new DBL(TOKEN', client);
^

ReferenceError: client is not defined
at Object.<anonymous> (index.js:5:180)
at Module._compile (internal/modules/cjs/loader.js:774:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
at Module.load (internal/modules/cjs/loader.js:641:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)
at internal/main/run_main_module.js:17:11

hearty lintel
#

You need to make client before u submit client too it

runic grove
#

how do you define your Discord.Client()

plush oar
#

const Client = new Discord.Client();

hearty lintel
#

Then make the client uppercase?

runic grove
#

then use Client instead of client

plush oar
#

omg

#

if this works

#

i love you all so much

runic grove
#

then you will stop copy pasting examples?

plush oar
#

yes lol

#

Thanks so much for your help lol

#

im so dumb

brisk scroll
#

we only get our token after approval right

sullen nymph
#

Yep

onyx vale
#

I need help

#

Why my bot always rejected

brisk scroll
#

Fix those problems

onyx vale
#

If new prob comes

#

Then fix again

#

Should i remove *google command

restive otter
#

Just check if the channel is nsfw and if not reject the command

onyx vale
#

What??

dense basalt
#

With the google command you can search NSFW sites like porn. Make sure this command is only available in NSFW channels else this breaks Discord ToS.

brisk scroll
#

in the d.js the dbl.hasVoted isn't a function?

spiral steeple
#

Show code

#

what you said doesnt help us

brisk scroll
#

Nvm fixed it

#

Tried attaching client to a constructor

fleet pebble
#

I tried running my bot and i received this error in the console:

{ Error: 429 Too Many Requests
    at IncomingMessage.res.on (C:\Users\spenc\Discord Bots\GRiM Project\node_modules\dblapi.js\src\index.js:118:25)
    at IncomingMessage.emit (events.js:202:15)
    at endReadableNT (_stream_readable.js:1129:12)
    at processTicksAndRejections (internal/process/next_tick.js:76:17)
  raw:
#

So I have my bot send server count to DBL and then it will refresh the server count every hour after that.

#

So im not even near being rate-limited

spiral steeple
#

well, if you're getting that error, you're being rate limited somewhere

ornate abyss
#

Pof

fleet pebble
#

well no shit

worn quail
#

@onyx vale what lang you use.

#

If its python async, I have a github repo with things to check for NSFW channels

#

and nitro things

worn quail
#

@brisk scroll I believe so

brisk scroll
#

Figured it out

calm zealot
#

Hello,
when i have my bot running on multiple vps, how do i best send the servcount? can i send the shardid+servercount from each individual vps to discordbots.org, and it will be added up there? or do i have to take care of the "collection" myself, and then send the final values in once?

timber orbit
#

using the javascript library, does on('test') work as a callback for running a webhook test on the edit page?

spiral steeple
#

No

#

It's still on vote

timber orbit
#

so vote will be triggered?

#

if so, that's great, thank you

spiral steeple
#

.on('vote') will be emitted, yes

timber orbit
#

nice

#

one more thing, is it normal for the hostname to show as 0.0.0.0 when logged? I looked at the source and it seems hardcoded in but that seems like a strange choice

spiral steeple
#

Yep

#

0.0.0.0 is basically just all ips (ipv4) on your machine

timber orbit
#

alright

spiral steeple
#

Idk why it sent two

#

Oh well

timber orbit
#

it's weird that things still arent working but i guess i'll just keep trying

spiral steeple
#

I would help, but it's 2AM

#

And I need sleep, so good luck

timber orbit
#

yeah no big deal, i appreciate the info youve given already

#

i sent a request to the URL through Postman and .on('vote') triggered, but when I do it through the Test button or get one of my friends to vote as a test, no response

#

is there any reason for that? are certain URLs not accepted?

restive otter
#

What's this error I keep on getting?

Error: 504 Gateway Time-out
    at IncomingMessage.res.on (/app/node_modules/dblapi.js/src/index.js:118:25)
    at IncomingMessage.emit (events.js:203:15)
    at IncomingMessage.EventEmitter.emit (domain.js:448:20)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
spiral steeple
#

because dbl is having issues

#

if there error is 5xx it's server side

jaunty steppe
#

wasnt there an event that was like

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

? cause it never seemed to get dispatched and now i cant even find it on the gh

restive otter
#

requires webhooks and stuff

#

idk ¯_(ツ)_/¯

restive otter
#

what does the api do?

spiral steeple
#

An API is an application programming interface, it allows parties to access some form of data, or post their own via HTTP/s (or internal) calls. It allows applications to communicate. Of course this is extremely basic but google does exist

umbral maple
#

someone has/can explain me how to use API for a discord bot

spiral steeple
#

well most people use an api wrapper

#

the most popular are discord.js, discord.py, and JDA. But if you were talking about discordbots.org api, you can use dblapi.js, dblpy, there is multiple others too

#

I believe

#

If you want to make calls yourself, for whatever reason, consult the discord api docs or the dbl docs

hearty dagger
#

I'm having some trouble getting the event that someone has voted for my bot

#

I'm using the python api wrapper and the event doesn't seem to be firing

void quest
#

Question

#

Do you have to be certified for your bot to have the cert icon in the widget?

worn quail
#

Yes

void quest
#

Aight

#

So me no get lel

#

Also, in my "my bots" page, what's the N/A for?

#

That cert?

halcyon valve
#

server count

tepid temple
#

Help me, speak spanish???

dawn fjord
void quest
#

how the shit fuck

#

i know widgets aren't this difficult

#

I've done them before

gilded pecan
#

how do i post my server count using js

void quest
#

self.discord.guilds.size

sullen nymph
#

dbalpi.js automatically posts server count every 30 minutes if you provide your Client to it

void quest
#

I have mine update every 5 mins

sullen nymph
#

@hearty dagger Make sure you have webhook_port that you specify in dblpy Client open and forwarded
@jaunty steppe Are you sure you are using the dblpy webhook system?

hearty dagger
#

I don't quite follow. Do I need a webhook link or anything and do I need a specific port? The docs on dblpy aren't terribly informative on this.

hearty dagger
#

@sullen nymph Sorry for tag but I'm still having a bit of trouble

sullen nymph
hearty dagger
#

Ah thanks

#

what url do I need to set in the bot's edit page

sullen nymph
#

http://yourpublicip:yourport/yourwebhookpath

hearty dagger
#

gotcha

jaunty steppe
#

Can webhoobpath be anything? @sullen nymph

#

Sorry I'm not really one with webhooks and website stuff

sullen nymph
#

Sure

#

Just make sure you specify it properly on DBL :p

restive otter
#

Oof

restive otter
#

Who can tell me how I do in discord.py that gives a role on support server to a voter and sende a message?

hearty dagger
#

Use the on_dbl_vote event

restive otter
#

Ok

frank laurel
#

im bad at wehooks lol and when ever i put a webhook it says "This webhook cannot send messages and only used for your bot"

#

ping me when respond xd

worn quail
#

@frank laurel that's fine..

frank laurel
#

wdym. i mean the webhook would act like its invalid

hearty dagger
#

My on_dbl_vote event still doesn't work

#

I opened a port and forwarded it to the correct device

#

So idk what to do now

sullen nymph
#

Are you using webhook_port that dblpy provides

hearty dagger
#

yes

rugged sierra
#

Can the dbl API wrapper for js add error handling?
The backend errors are annoying in my logs and error tracking

limpid sorrel
#

^submit a pull request

arctic arch
#

catch the errors...

#

and do what you must with them

hearty dagger
#

Neither the actual vote event nor the test event is firing for me so I'm a bit lost. Maybe I'm just dumb, maybe it literally doesn't work

spiral steeple
#

@hearty dagger did you make a webhook?

hearty dagger
#

yes

spiral steeple
#

Did you put the url into the edit page on dbl?

hearty dagger
#

yup

spiral steeple
#

Does your console log somethingg like "Webhook running at http://0.0.0.0:port/path"

arctic arch
#

did you save

spiral steeple
#

And that mmulu

hearty dagger
#

I did save

#

I got the test event working

#

Now to check the vote event

rugged sierra
#

@arctic arch I don't understand what you mean with catch, I mean it's not some promise rejection.
Do you mean listening on the error event like dblclient.on('error', ()=>null)?

arctic arch
#

read up on promises

rugged sierra
#

I'm pretty sure I know how promises work.
But how am I supposed to catch errors from postStats running in an interval

#

Just gonna write my own request and do nothing with failing requests. akkoShrug
dbl had 5 Errors in 6 Hours.
using .catch won't help me because it's literally the package running it in an interval, dunno how I should catch that.

spiral steeple
#

@rugged sierra you can always edit the code yourself, it isnt very hard to get to

rugged sierra
#

You are telling me to edit the files in node_modules?
@spiral steeple

spiral steeple
#

Yes

#

It isnt a sin

rugged sierra
#

Yes it is

spiral steeple
#

Or you can clone the github repo and do it yourself

#

It is open source after all

rugged sierra
#

That would make sense, but editing the files in node_modules hahaha sounds very dumb

#

But I will just write the simple request myself

#

Easier thank forking it akkoShrug

spiral steeple
rugged sierra
#

Okay I got it buddy

#

Just saying, if your backend regularly failes your wrapper at least should be able to handle it

spiral steeple
#

I dont use dblapi.js so I wouldnt even know what it does with errors

rugged sierra
#

Well obviously not handling it like you would with a failing backend, because I have it in my logs everyday.

#

Just trying to post stats, idc for server errors

tough flume
#

Hey

manic kayak
#

How long does it take for a vote to update?

hearty dagger
#

Few seconds max

manic kayak
#

Huh, cause with aiohttp it takes multiple minutes for it to update

#
            async with aiohttp.ClientSession() as session:
                async with session.get(f'https://discordbots.org/api/bots/606698583076372480/check?userId={ctx.author.id}', headers=headers) as result:
                    HasVoted = await result.json()
hearty dagger
#

strange

#

And now my on_dbl_vote and on_dbl_test events aren't firing again

#

I'm so confused

manic kayak
#

Ima try using requests on this

hearty dagger
#

oh god

#

requests is blocking

manic kayak
#

@hearty dagger Yeah it is, but aiohttp does not work basically
If you have a non blocking other suggestion for me to fix this then tell me 😂

hearty dagger
#

see if requests responds faster

manic kayak
#

Yeah

hearty dagger
#

It shouldn't but who knows

manic kayak
#

Ima tell a friend to upvote my bot

#

So i can check it

hearty dagger
#

lmao

#

My vote and test events were working perfectly yesterday

#

And now they have stopped working

#

And I don't know what changed

manic kayak
#

Yep

#

It literally worked instantly

hearty dagger
#

How strange

manic kayak
#

I don't mind that its blocking as long as it works, but i would rather use something non blocking

hearty dagger
#

I may have to resort to hitting the api myself if I can't get these damn events to work again

arctic arch
#

the interval part does handle errors tho

#

and sends them to the error event

worn quail
#

@manic kayak dbl has a delay for updating votes using http GET

restive otter
#

guy how to get dbl api ?

worn quail
#

what lang

manic kayak
#

@worn quail Ohh, so what should i use instead?

spiral steeple
#

@manic kayak a webhook

manic kayak
#

Wait so how should i go about hooking that up then

spiral steeple
#

Well it's extremely easy if you use dblapi.js

#

Wait

manic kayak
spiral steeple
#

You're in py

#

Arent you

manic kayak
#

Yea

spiral steeple
#

dblapi.py exists, but I'm not a py dev so you'd have to get help from someone else or figure it out by yourself

manic kayak
#

Ah

spiral steeple
#

If it's as easy as js, it's right in the docs

manic kayak
#

Cool

#

Ok ima figure it out then

spiral steeple
#

I actually dont know what it does, or if it makes a webhook for you

#

I havent looked at it, but tbh, it should, or I would guess it would

hearty dagger
#

py is ez

#

I can help with py

#

@manic kayak ping me if you need anything

manic kayak
#

Ah

#
self.dblpy = dbl.Client(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)

Do i need to fill out any of this? @hearty dagger
Im using the webhook example from the github

hearty dagger
#

you need your api token

manic kayak
#

Yeah

#

I put it in to self.token

hearty dagger
#

if you want to get vote events you need the webhook stuff otherwise you don't

manic kayak
#
class DiscordBotsOrgAPI(commands.Cog):
    """Handles interactions with the discordbots.org API"""

    def __init__(self, bot):
        self.bot = bot
        self.token = "Not Showing U"# set this to your DBL token
        self.dblpy = dbl.Client(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)

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

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

So i basically just gotta put in this?

hearty dagger
#

have you set up an open port through your firewall

manic kayak
#

Um, no i am a Mac

#

For hosting atm

hearty dagger
#

then the vote listener is pointless

manic kayak
#

Going to move it to a Server in the next few days

#

That can be firewalled n stuff

#

That i run a server network on

hearty dagger
#

it can't listen if you don't give it anything to listen to

manic kayak
#

Ok, welp then todays goal is for me to move this to my SoYouStart host

manic kayak
#

@hearty dagger Ok migrated the bot and voted, but it doesn't seem to be doing anything?

#
import dbl
import discord
from discord.ext import commands

import asyncio
import logging

class DiscordBotsOrgAPI(commands.Cog):
    """Handles interactions with the discordbots.org API"""

    def __init__(self, bot):
        self.bot = bot
        self.token = "Not showing u" # set this to your DBL token
        self.dblpy = dbl.Client(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)

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

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

I opened the port with ufw

#

ufw allow 5000

hearty dagger
#

are you forwarding the port to the machine the bot is hosted on

#

And did you set up the webhook in your bot edit page

manic kayak
#

Wait i have to set up the webhook on the bot page?

#

Ohhhhh

#

@hearty dagger So how would i hook up the webhook to the bot then?

restive otter
#

how to im get dbl api ?

runic grove
restive otter
#

im dont know what am wating for :l

manic kayak
#

@hearty dagger Ok found the docs on it, it says i have to put in a url that i want the info to be sent to? What url should i make it send it to

past finch
#

You make webhook

#

ideally a script on your server / website that handles the incoming data

manic kayak
#

How would i go on making a webhook then

past finch
#

Do you have a website?

manic kayak
#

Uh, i own a domain

past finch
#

Cool, so you can access that in your browser yes?

manic kayak
#

Its not for a website its for a server

#

So it would not be accessible from browser from my understanding

past finch
#

Okay you need to basically have a URL that DBL can post to, so you'd need that

manic kayak
#

Ok

#

So with my Domain what do i do with it

#

Do i just put the domain into the thing?

past finch
#

When you say domain, you mean a URL right, like example.org

manic kayak
#

Yes

#

Got it off of namecheap

past finch
#

Cool so you need to attach that to your server cos right now that isn't resolving

manic kayak
#

To my server that is hosting the bot?

past finch
#

Yeah, where is the server? Is it shared hosting or a R PI or something?

manic kayak
#

It is a SoYouStart host

past finch
#

Okay, so on that host, you have an account right, can you setup a website on that

manic kayak
#

Uh how would i set up a website?

#

Oh yeah btw

#

The domain is hooked to my host

#

Does that help

past finch
#

Holy crap SoYouStart is so expensive 😮

manic kayak
#

Its for gaming servers

past finch
#

Yeah I gathered lol, damn

manic kayak
#

Yea

#

Its fine

#

I host multiple server networks on it

#

And the bot now that i migrated it is running godly

past finch
#

Lol I bet

manic kayak
#

Anyways

#

So, how would i create a website

#

The Domain is Currently hooked up to my Host

past finch
#

Yeah so I have no idea what there web panel looks like

manic kayak
#

Well what would i need to do on it

past finch
#

I'm not too sure but basically you need to setup a basic apache web server

manic kayak
#

These are my options on the CP

past finch
#

Wanna priv chat?

manic kayak
#

Yeah

graceful oar
#

You purchased a dedicated machine not web hosting.

past finch
#

3 hours later and we're nearly done lol

manic kayak
muted oar
#

How would i prevent rate limiting when using the hasVoted method

onyx vale
#

Why my bot get kicked

#

Help

#

Help

#

@CTK BOT

muted oar
#

@onyx vale Ask the moderator that kicked it?

onyx vale
#

Ok

#

@grand blade

#

Why did you kicked my bot

grand blade
#

read modlog

onyx vale
#

@grand bladewhen my bot sent link messages

#

And what shoulf i do to add my bot here again

full socket
#

Fix the issue and dm a mod

#

Also this is not really the channel to discuss this 🤷

onyx vale
#

I dont know what is the issue

full socket
#

Your bot responds to links lol

#

Don't make it do that here

onyx vale
#

Should i blackliste

#

The bot herr

#

Ok

#

Thx

full socket
#

Idk ask a mod

muted oar
#

How would i prevent rate limiting when using the hasVoted method

full socket
#

By storing the last time you called the endpoint

#

I think libraries handle ratelimits

#

Not sure though. Check with the devs

muted oar
#

I am rn

#

I'm talking about the dblapi

#

Lol

#

Wouldn't be here talking about a different api

full socket
#

I know

#

There are libraries for dbl api already, and I do believe they handle ratelimits

restive otter
#

hello

near sparrow
#

Well @muted oar You don't prevent rate limiting, you just make sure the code doesn't hit it. There really isn't a way to prevent it besides making sure the code calls it at the right timews

#

times*

chrome canyon
#

i mean doesn't JDA have a queue of some sort?

sudden rampart
#

but JDA doesn't deal with DBL's api

tawny dawn
#

wow

#

this server is too beautiful

dawn fjord
tawny dawn
#

oh sorry me

muted oar
#

@near sparrow Wait I can't add a cooldown or something? Cause if multiple people use the command within the rate limit time it'd rate limit correct

mild oyster
#

Isn't the authorization password for webhooks that I set on the website the one I set in my bot at webhook_auth? I just set both to different values and used the test button, but the request still seems to go through. I feel like I'm missing something Thinky

polar mirage
#

Did you save

mild oyster
#

yes

#

more often than I probably need to

spiral steeple
#

take a look at the code yourself.

mild oyster
#

Using python, but I don‘t suppose that the issue is inside the library

#

aaaaaa

spiral steeple
#

ah, python

#

I believe it's still open source

hearty dagger
#

The python lib is working fine for me

restive otter
#

Using the JavaScript DBL API, I can't get the vanity url at all, it just responds with undefined.

#
bot.vanity.length? bot.vanity : "Unavailable"
spiral steeple
#

A lot of bots dont have a vanity url

#

https://discordbots.org/bot/memes is an example of a vanity url

#

Basically, it's not the discord bot id for the url, but an actual name

karmic hound
#

general practise in docs is if you see ? on a parameter it means optional

muted oar
muted oar
#

What is dblapi has voted time limit before it becomes a rate limiting problem

timber orbit
#

To whoever runs the docs, it might be worth adding somewhere that if the webhook URL has a port on it, like 0.0.0.0:5000, it won’t work

#

I was running into brick walls that I didn’t know existed until I pointed port 80 to port 5000

#

A preventable headache with a little note in the docs

spiral steeple
#

@muted oar there is a global hard rate limit of 60 requests/minute

#

@timber orbit It logs in console where it's running tho for example htttp://0.0.0.0:6969/dblwebhook

timber orbit
#

It does, but when I tested requests it didn’t work until I pointed the port I was using, 5000, to 80

#

Despite working when I used software to post to it manually

spiral steeple
#

uh

#

80 shouldnt even work

#

Port 80 is reserved

timber orbit
#

It’s reserved for web traffic but I can point a port towards it

spiral steeple
#

How are you hosting?

timber orbit
#

AWS

spiral steeple
#

closed port perhaps?

timber orbit
#

What do you mean?

spiral steeple
#

A closed port just blocks all incoming and outgoing traffic

timber orbit
#

It’s definitely not closed

#

Like I said, a manual post worked perfectly

spiral steeple
#

well

timber orbit
#

But actually voting and the test button didn’t do a thing

spiral steeple
#

yeah... it's from the same machine Thonk

timber orbit
#

It’s not, it’s external through postman or whatever it’s called

#

Yeah, Postman

spiral steeple
#

Either way, I dont have this issue so idk what happened with yours

timber orbit
#

Doesn’t make a whole lot of sense

viral ledge
#

How do i setup the server count in DBL?

#

I'm still confused about that part

muted oar
#

You are gonna have your bot post it to DBL

viral ledge
#

hmm

muted oar
#

Either by using .postStats or dblapi built in posting server count

#

Actually what Lang you using

viral ledge
#

discord.js

muted oar
#

Okay ye

#

Docs @viral ledge

viral ledge
#

I know but I'm still confused

#

That's why I asked

forest summit
#

is dbl.hasVoted() is only for the past 24 hours only?

#

how can it detect for the past 12 hours?

restive otter
chrome canyon
#

unrelated to the api

rugged sierra
#

@forest summit can't afaik, you will need to store the votes yourself

#

but you could fetch the last 1k votes

#

but kinda cancer

spiral steeple
#

the docs are just outdated.

shy vortex
#

is it just me or why does my vote command say I voted even tho I dind't

worn quail
#

how did you do yours

shy vortex
#

it checks if you voted and if true it gives you a value named gold and says thanks for voting

#

if false it says you dind't voted for the bot you can vote here link to page

worn quail
#

what url did you get that from

shy vortex
#

get from what

worn quail
#

The voting

#

/api/bots/botid/check?voted something like that

#

That?

shy vortex
#

Yes

worn quail
#

Odd

#

It shouldnt show that it voted

shy vortex
#

but it does

worn quail
#

what lang do you use?

shy vortex
#

when I do the vote command here

#

its normal

#

when I use it in other servers

#

It always says I voted

worn quail
#

How

#

that makes zero sense

shy vortex
#

Ik

worn quail
#

Might wanna ping tonkku about this

shy vortex
#

Im not gonna do it

worn quail
#

Or kyoyou

shy vortex
#

im afraid I get a punish

worn quail
#

seriously

shy vortex
worn quail
#

eeeeee

shy vortex
#

ffffffff

#

Ok I'll just do it

worn quail
#

don

#

I already dmmed

#

:p

shy vortex
#

thank you

worn quail
azure pollen
#

cc @arctic arch

#

i dont do DBL /api stuff

shy vortex
#

ok

#

then who does

worn quail
#

Ah

#

tonkku apparently

#

lol

shy vortex
#

ok

#

Should I pong him okeh

azure pollen
#

no, i already did

shy vortex
#

thanks

cedar crown
#

J

shy vortex
#

I

arctic arch
#

that makes no sense if it's different per server

#

must be a problem with your code

shy vortex
#

ok

lofty leaf
#

I need link for server

full socket
lofty leaf
#

Thanksemoji_51

#

Xliel

rose elk
worn quail
#

I use that method aha

#

its fine

violet smelt
#

oof

humble bison
#

it's best to use the new api examples

restive otter
#

I'm attempting to send webhook responses on every vote, however it won't seem to come through, the endpoint won't even get triggered...

#
app.post('/upvote/discordbots.org', function(req, res) {
if(req.headers.authorization !== config.credentials.discordBotsDotOrgAPIKEY) return 
  console.log(result.body)
});
#

This is the URL i'm sending it to

#

http://64.52.85.218:3001/upvote/discordbots.org

restive otter
#

Please ping me when you respond

rugged sierra
#

@restive otter

  1. is the port blocked by a firewall?
  2. dbl doesnt send the token as auth, so your code will always return
    || use semicolons animatedree ||
restive otter
#

No and I've tried a different auth value

#

@rugged sierra

#

I do use semi colons, but i'm testing first

rugged sierra
#

but currently you are comparing it to the api token, which is wrong

restive otter
#

That's already been changed

rugged sierra
restive otter
#

lemme try a different port

#

still nothing

#

Anyone else able to help please?

#

Scroll up to see the issue

spice cypress
#

On the webhook part of the page, you specific your own, custom, key

#

don't use your api key

elfin flint
#

Where i can get webhookAuth password?

shut ibex
#

You set it on the bot edit page

#

all the way at the bottom

elfin flint
#

ok

#

thx

restive otter
#

How do i make it show how many servers my bot is in on the website?

junior canopy
muted oar
#

How can I get extend/get more votes using .getVotes()

#

Or is there another way to get the bot vote count

humble quail
#

hello .... I'm looking for some tournament bot

rotund magnet
#

Just have a small question regarding the Java api:

DiscordBotListAPI api = new DiscordBotListAPI.Builder()
    .token("token")
    .botId("botId")
    .build();

token is the api key while botId is the token from Discord to start the bot?

sullen nymph
#

token - your DBL token
ID - your bot's ID

rotund magnet
#

Ah, id in the web link?

sullen nymph
#

Should be

rotund magnet
#

Is there a way to check how much time does it need to pass for someone to vote again with the api?

#

can't manage to find if it exists

muted oar
#

The time is 12h so when they vote make a cool down for that user of 12h

rotund magnet
#

I'd need to add a webhook for that I guess

#

I mean create a webhook on the bot, intercept the event, store it and etc. etc.

#

I thought about that but I wanted to see if the api does have that

tropic hill
#

is there a way to send the bot's onoine status pr dpes it have to be in this server

#

^using the python library btw

hearty dagger
#

has to be in this server

hot portal
worn quail
#

no...

#

why would we?

azure plover
#

^

hot portal
#

To update the server count on multiple bot listing

spiral steeple
#

Dbl doesnt endorse other bot lists, so why, from a business perspective, would they ever support that

worn quail
#

^^

restive otter
#

bot block isn't a bot list?

dawn fjord
#

BotBlock doesn't work with dbl anyway

grand blade
#

what's the point of botblock

azure plover
#

Over complicate everything and collect data

#

I would trust it more if it was an npm module that made HTTP requests directly to the bot lists that it posts to, but botblock makes us send our data to its own server, so

restive otter
#

oh so when i post server count it goes to botblock then goes to the bot list?

dawn fjord
#

Yes but it's bad

#

Because you give them your data and tokens for the bot lists

spice cypress
#

here's a server if you're looking for something like that

azure plover
#

That's not what we're talking about

gilded lake
#

Is there a way to automaticly reward people for voting for our BOT ?

hearty dagger
#

Yes

muted oar
#

Check if they voted and if so give them the reward

gilded lake
#

slonk I can't make it auto?

muted oar
#

There’s an event iirc for checking when votes happen

sullen nymph
#

That would require a webhook

restive otter
#

I put the following code in the main-class, but the serversize is still on N/A - could someone help me?

DiscordBotListAPI api = new DiscordBotListAPI.Builder()
                .token("TOKEN")
                .botId("USERID")
                .build();

int serverCount = jda.getGuilds().size();

        api.setStats(serverCount);
#

Oh I got the wrong token.

narrow geyser
restive otter
#
const DBL = require('dblapi.js');
const dbl = new DBL(Token, { webhookPort: 5000, webhookAuth: 'password' });

dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  
  console.log(`User with ID ${vote.user} just voted!`);
  
  const voteembed = new Discord.RichEmbed()
//Random Stuff 
  client.channels.get(``).send(voteembed);
  
});

Is this how to post upvotes to a channel in your server?

hearty dagger
#

Look at the dblpy docs

worn quail
gilded lake
#
const dbl = new DBL('My token that I found at DBL.org in API', client);

dbl.on('vote', vote => {
    let embed = new Discord.RichEmbed()
        .setTitle(emoji ("609307502093533214") + ' Récompenses de vote')
        .setColor("PURPLE")
        .setDescription(emoji ("609307501833486336") + `Le joueur** ${vote.user} **a voté pour Gato et gagne ainsi **1500` + emoji("609307501594411048") + "**")
        .setColor("PURPLE")
    client.channels.get("611122034474483715").send(embed)
});```

When I voted, no embed were sent, the channel ID is right, what did I make wrong please ?
restive otter
#

doesn't this have to be with webhook ?

slate cradle
#

Discord is not set as a variable

#

that's what i think is causing the problem, since you said no embed was sent

spiral steeple
#

B r u h, he doesnt even have a webhook

slate cradle
#

well the fact that he doesn't even have a webhook is not the only problem

spiral steeple
#

He probably just didnt show the whole code

#

This is most likely in his main file

slate cradle
#

still could be a possibility

muted oar
#

What does that have to do with Dbl api @supple flicker

spiral steeple
#

He's just showing us his client mods

muted oar
#

Lol

spiral steeple
muted oar
#

That belongs in offtopic though right

#

Honestly though I can see how that can be useful but also annoying @spiral steeple

spiral steeple
#

It was a joke. Just pointing it out.

teal lava
#

question, what is stopping me from doing postStats(999999999), just curious

narrow geyser
#

Your bot being removed

rugged sierra
#

Nothing, but if they notice (very likely) your bot will be removed

spiral steeple
#

And with marco's stats website, it will be detected really quickly

amber dune
#

@teal lava we monitor what stats people post, so dont try and fool the system mmLol

teal lava
#

not going to

#

but I see that the DBL constructor requires a "client" object, why not pull the guild size from there instead of lettings people enter whatever they want?

amber dune
#

make a pr i guess

#

¯_(ツ)_/¯

hoary timber
spiral steeple
#

@hoary timber retry-after is usually in seconds

#

But not sure how dbl handles it

hoary timber
#

which is why I ask

spiral steeple
#

This isnt a support server for a specific bot

#

Use their support server

hoary timber
spiral steeple
sullen nymph
#

@hoary timber seconds