#topgg-api

1 messages ยท Page 36 of 1

misty geode
#

now do to your edit page

#

and add your url

loud gulch
#

what if someone (the user) isnt in the server

misty geode
#

it will show @austere blade

loud gulch
#

then it would fail to give them the role

misty geode
#

^

#

that also

restive otter
#

wym edit page?

misty geode
#

your bot edit page

restive otter
#

im there

#

what do i need to do

misty geode
#

go to webhook

restive otter
#

yes

misty geode
#

bottom of the page

restive otter
#

im there

misty geode
#

enter your url

#

of the site

#

where its listing

restive otter
#

so glitch

misty geode
#

yes

#

send your url

restive otter
#

this

misty geode
#

what is the port

#

that you set

#

is it listening on port 3000?

restive otter
#

kk

misty geode
#

then that

#

then hit test

#

in your log panel of glitch

#

you should see it

restive otter
#

done

misty geode
#

hit save

#

and test

restive otter
#

did

#

k

misty geode
#

check console

restive otter
#

how to test

misty geode
#

on glitch

restive otter
#

no friends are online

misty geode
#

thats why there is test

#

hit test

#

and see console

#

on glitch

restive otter
#

Webhook running with path /dblwebhook

Listening

misty geode
#

send the url of the page you in

#

where you coding

restive otter
#

on glitch

misty geode
#

yes send that url

#

so i can see your code

#

also

#

take off your token

#

b4 you do it

restive otter
#

kk

loud gulch
#

or put it in .env xd

misty geode
#

unless you dont care and gona reset it

loud gulch
#

or if its not private put it in env

#

no one besides you can see content of env file

misty geode
#

what is the file

#

?

loud gulch
#

its literally

#

.env

misty geode
#

oh not you lol

#

ik that

#

โค

loud gulch
#

ok lol

restive otter
#

index.js

misty geode
#

k penguin delete that link

#

after this

#

reset bot token

#

and dbl token

restive otter
#

kk

misty geode
#

k your server is on 5000

#

its listing on port 5000

#

change the url port to 3000

#

on the edit page

fast tapir
#

Should I remove that message from my bot's cache?

restive otter
#

done

misty geode
#

hit test now

restive otter
#

test on?

misty geode
#

the edit page

restive otter
#

tested

misty geode
#

hit save and test

#

what you see in console?

restive otter
#

i did

#

wait a few seconds

misty geode
#

oh you reset token

#

put your new one

#

just reset it after i leave

#

delete this link

restive otter
#

yea

#

now?

misty geode
#

hit test

#

you should see someone voted in your console

restive otter
#

what console

misty geode
#

click logs

#

now hit test

restive otter
#

nothing

#

again

#

i invited you

misty geode
#

yea i can see the code

#

your listener is looping for some reason

restive otter
#

:(

#

i can see

misty geode
#

restart the bot

restive otter
#

and test

#

nothing

#

keeps looping

#

still

misty geode
#

restart

restive otter
#

done

#

restarted

misty geode
#

hit test

restive otter
#

done

#

it loops

misty geode
#

hum

restive otter
#

still

misty geode
#

whats your Auth on the edit page?

#

'password;

restive otter
#

upvote

misty geode
#

ohhh

#

okay one sec

#

restart

#

yup idk why its looping

restive otter
#

loops

misty geode
#

maybe its your code

restive otter
#

hm

misty geode
#

it should not loop like that

restive otter
#

fixed

#

lol

#

nothing when i hit test

misty geode
#

its not listing

restive otter
#

though

misty geode
#

k take a screenshot

#

of your edit

#

page

#

for webhook

restive otter
misty geode
#

hit save

restive otter
#

i did

#

nothing

misty geode
#

k restart

#

and try

restive otter
#

nothing

misty geode
#

๐Ÿ˜ฆ

restive otter
#

:(

misty geode
#

it works for me

#

maybe the webhook is down

restive otter
#

how did u do it

misty geode
#

i used same code

restive otter
#

:(

misty geode
#

restart

#

and hit test

restive otter
#

i did

misty geode
#

one more time

restive otter
#

nothing

#

still

misty geode
#

???

#

lol

#

restart again

#

it should be port 3000

#

why is it 5000

#

i changed it too 3000

restive otter
#

nothing

light crag
#

@restive otter Do you understand POST requests?

restive otter
#

no

light crag
#

Read up on it. That is basically what a webhook is.

misty geode
#

i have no idea why its not working for you

#

sadly

restive otter
#

:(

misty geode
#

but @light crag why is the real vote not showing?

#

the test button works

#

it send the message

#

but if say my friend does it

#

it does not show

light crag
#

Show code.

misty geode
#

k

#
    dbl_web.on('ready', hook => {
        console.log(`Webhook running with path ${hook.path}`);
    });
    dbl_web.webhook.on('vote', vote => {    
        console.log(`User with ID ${vote.user} just voted!`);
    });
    app.get("/", (request, response) => {
        response.sendStatus(200);
    });
    server.listen(5000, () => {
        console.log('Listening');
    });
light crag
#

Interesting. If the test button works then the real vote should.

misty geode
#
const express = require('express');
const http = require('http');
const app = express();
const server = http.createServer(app);
const dbl_web = new DBL('', { webhookAuth: 'upvote', webhookServer: server });
#

yea no idea why the real one not working

restive otter
#

mine does not work

#

at all

misty geode
#

test works perfect

#

@restive otter

#

use that

#

the owner build it

#

try to copy and paste it

#

and see if it helps

restive otter
#

Error: listen EADDRINUSE :::3000

elfin solstice
#

seems like that port is already in use

restive otter
#

oh

#

so i cant use it :(

elfin solstice
#

or you just use another port

restive otter
#
dbl.webhook.on('ready', hook => {
  console.log(`Webhook running with path ${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});

app.get("/", (request, response) => {
  response.sendStatus(200);
});

setInterval(() => {
  http.get(`http://${process.env.PROJECT_DOMAIN}.glitch.me/`);
}, 280000);

 server.listen(5000, () => {
        console.log('Listening');
    });
inner venture
#

@elfin solstice glitch is stupid though

elfin solstice
#

i never said its good

inner venture
#

lmao

#

and you can only use 3000

elfin solstice
#

oh what

inner venture
#

because thats where the requests get sent to

#

it redirects incoming requests on port 80 to port 3000 on your server

misty geode
#

no you can use 5000

#

i been using 5000

restive otter
#

events.js:182

  throw er; // Unhandled 'error' event

  ^

Error: listen EADDRINUSE :::3000

misty geode
#

also my rela votes working now

#

โค

#

put the port to 5000

restive otter
#

where

#

server.listen(3000, () => {
console.log('Listening');
});

#

that

misty geode
#

yes

#

change 3000

#

to 5000

restive otter
#

yea

#

done

misty geode
#

then also on the edit page of the bot site

restive otter
#

yea

misty geode
#

try hitting test now

#

after you restart \

restive otter
#

nothing

misty geode
#

your servers says its ok

restive otter
#

yea

#

?

#

i pressed test

#

so much times

misty geode
#

no clue

#

try

#

restart one more time

#

and hit test

#

k hit test

restive otter
#

nothing

misty geode
#

how u restart ur bot

restive otter
#

watch.json

#

tyo=pe and cancel

#

type

#

u restarted

misty geode
#

hit test

#

and put your port on 3000

#

on url

#

if that dont work i have no clue

restive otter
#

k

#

nope

#

nothing

misty geode
#

rip

#

try a new porject

restive otter
#

oof

misty geode
#

and see if the code i sent you works

#

if that works

#

its your bot

restive otter
#

ima go to bed

#

ty anyways

misty geode
#

np

#

change the link

#

to your glitch

#

edit link

#

and change token

#

โค

restive otter
#

yee

bronze wraith
split haven
#

Hi what are the ratelimits based on?

#

Is it by each token

proud sphinx
#

Probably

split haven
#

@arctic arch can you help

arctic arch
#

depends

split haven
#

@arctic arch my question is before, what are the ratelimits done by

arctic arch
#

its by ip

split haven
#

do you look for the forwarded for header

arctic arch
#

its done in cloudflare rn

split haven
#

ah

arctic arch
#

are you reaching the ratelimit?

split haven
#

i feel i will if it doesnt listen to x-forwarded-for

arctic arch
#

what do you mean ๐Ÿค”

split haven
#

im writing a centralised api for all bot lists

#

so im passing the source ip i get as x-forwarded-for

#

but obviously my ip will be then making far more requests than the average user

arctic arch
#

so kinda like a proxy thing

split haven
#

yes

#

bot dev makes a single post request to post stats to all bot lists

#

i'll email cf to ask

restive otter
#

events.js:182

  throw er; // Unhandled 'error' event

  ^

Error: listen EADDRINUSE :::3000

#

i got this error while using vote api

#

using glitch

arctic arch
#

something is using the port 3000 already

#

you likely have the thing that keeps glitch running forever?

restive otter
#

yea

arctic arch
#

what does that look like

restive otter
#

Im using uptime robot

#

whoops

#

Webhook running with path /dblwebhook

Listening

#

it gets the webhook

#

but when i hit test nothing comes up

#

i changed port to 5000

#

still does not work

arctic arch
#

glitch only allows port 3000

restive otter
#

that doesnot work

arctic arch
#

try without :3000

restive otter
#

k

arctic arch
#

glitch forwards that to the correct port

restive otter
#
const express = require('express');
const http = require('http');

const app = express();
const server = http.createServer(app);
const dbl = new DBL('', { webhookAuth: 'test', webhookServer: server });

dbl.webhook.on('ready', hook => {
  console.log(`Webhook running with path ${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});

app.get("/", (request, response) => {
  response.sendStatus(200);
});

setInterval(() => {
  http.get(`http://${process.env.PROJECT_DOMAIN}.glitch.me/`);
}, 280000);

server.listen(3000, () => {
  console.log('Listening');
});```
#

i used that

#

still does not work

#

test

#

no errors

#

just does not vote

#

nvm

#

it worked

#

thank yyou

formal sparrow
#
if(dbl.isWeekend) {
message.channel.send(`hi`)
} else {
message.channel.send(`bye`)
}
#

I tried that and it says hi even now in weekdays

sudden depot
#

i do not think that dbl.isWeekend is a property

#

u can try
console.log(dbl.isWeekend)
i am sure it will say [Function]

formal sparrow
#

Yea it's function

#

Didn't think in that way

#

Saw this from docs

#
dbl.isWeekend(weekend => {
    if (weekend) {
 console.log("Woo! Multiplier time!")
} else {
console.log(`hi`)
}
});
#

That didn't work nothing was logged and in docs, it was with syntax error

#
dbl.isWeekend(.then(weekend => {
    if (weekend) console.log("Woo! Multiplier time!")
});
arctic arch
#

oh my thats a bad mistake

#
dbl.isWeekend().then(weekend => {
    if (weekend) console.log("Woo! Multiplier time!")
});
formal sparrow
#

Thanks this works

#

Btw fix in docs else everyone will make mistakes in that

misty geode
#

Ooofers

native olive
plain timber
#

wrong token

#

double check it

native olive
#

i did

#

it's correct

plain timber
#

afaik, thats the only reason you would get a 403

inner venture
#

403 is forbidden tho

#

401 is unauthorized

arctic arch
#

is it the token for the right bot?

native olive
#

Yes it is

restive otter
#

hmmm

fast tapir
#

I'm attempting to get information on my bot, but I keep getting this exception:
java.io.IOException: Server returned HTTP response code: 403 for URL: https://discordbots.org/bots/461938818627665940
Code:

    public String getVotes() throws IOException{
        URL url = new URL("https://discordbots.org/bots/461938818627665940");
        URLConnection conn = url.openConnection();
        conn.connect();
        BufferedReader buff = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String out = "";
        String line = null;
        while ((line = buff.readLine()) != null) {
            out = out + line;
        }
        System.out.println(out);
        String votes = out.split("\"points\":")[1].split("\n")[0]; //Because I'm too lazy to get/use a JSON lib
        if(votes.charAt(0) == ' ') {
            votes = votes.substring(1);
        }
        System.out.println(votes);
        return votes;
    }
violet ingot
#

are you sure the url is correct

#

I get error 404 not found if I go to that URL

sullen nymph
#

Isn't it bot/bot.id?

clever rock
#

is it possible that I'll do the counting of my server counts and just send the total shards and the total server count?

sullen nymph
#

iirc you can send shards count as well

clever rock
#
client.on('ready', () => {
    setInterval(() => {
        dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
    }, 1800000);
});

since this code if ran, will send 12 requests since 12 shards will run the code so what I thought is

client.on('ready', () => {
    setInterval(() => {
        dbl.postStats(myServerCount, client.shards.total);
    }, 1800000);
});

this

#

then just have a process that sends that instead of shards sending it one by one

arctic arch
#

almost it, but you need to pass undefined to the ID spot dbl.postStats(myServerCount, undefined, client.shards.total);

clever rock
#

got it, thanks

plain timber
#

@fast tapir it looks like you're trying to access the bot page for users instead of the api

fast tapir
#

my bad XD

#

ty ๐Ÿ‘Œ

lucid osprey
#

DBL(token, [options], [client])
if I pass client from 'discord.io' library will it still work?

arctic arch
#

discord.io is not a supported library so it won't post stats automatically

lucid osprey
#

so I can't use DBL basically?

arctic arch
#

you can

#

the [] means optional

lucid osprey
#

okay I see
webhook is done in different way

#

so the amount of server is what I supposed to post myself, right?

arctic arch
#

yea

lucid osprey
#

okay it all seems pretty clear
thank you

sudden depot
lucid osprey
#

so I need to set up a server to listen to incoming webhooks on certain port, right?

lucid osprey
#

nvm figured out

crisp leaf
#

What is https://discordbots.org/api/bots/votes meant to return when you provide no ID and an Authorization header?

loud gulch
#

votes for the bot

#

with the token

crisp leaf
#

Yeah but I got a response containing 700 users when my bot has 25/2 upvotes

loud gulch
#

happens to me too

#

i get a response with users who didnt vote for my bot

crisp leaf
#

Some of the users were duplicates so I assumed that it was just every upvote of every bot ๐Ÿค”

inner venture
#

the endpoint is broken rn @crisp leaf @loud gulch

loud gulch
#

whats the reason of it being broken

#

also that means gonna have to use webhooks instead right?

inner venture
#

I think the preferred one is

#

the individual vote check

#

Or you can just use the /bots/{bot.id}/votes endpoint

#

i dont think that one isb roken

#

or if theyre technically the same

#

but yeah, individual vote checking is still on the table

amber dune
#

Any eta on when it will be fixed?

inner venture
#

No idea

amber dune
#

Rip

tardy mauve
#

Do i need to use API key to GET Weekender True /False? Or is it Public?

inner venture
#

public

honest root
#

you can check if it's Fri, sat or sun by UTC now

cobalt ruin
#

but what if we turn double voting off one weekend Thonk

dawn fjord
#

no turn it half way off for one weekend

#

1.75 voting

lavish valve
plain timber
#

there are 2 counts, total and monthly

lavish valve
#

oh right

plain timber
#

you can access both through the API, with points and monthlyPoints

#

monthly shows everywhere in the website but the profile page is rly outdated

lavish valve
#

alright thanks for the info GWfroggyPepoThumb

hoary timber
smoky trench
#

I haven't used the java library, nor am i great at java

#

i can take a look for you but i wont be of much help.

#

eh i dont think that library actually has webhooks premade.

hoary timber
#

obviously...

smoky trench
#

it's really not that difficult

#

just need to listen for requests through your app

hoary timber
#

mhm.... tells me nothing

#

<-- Noob right here

arctic arch
smoky trench
#

i was just about to do that

inner venture
#

@hoary timber easiest one to use is Spark

hoary timber
#

Spark?

smoky trench
#

again

#

google it

inner venture
#

Here

hoary timber
#

@smoky trench Thank you. But remember, that google doesn't just show THE ONE result I need... It shows hundreds

smoky trench
#

eh it was the first result when i googled "spark java"

hoary timber
#

I googled "spark"

smoky trench
#

using common sense, you'd append the language to the end or you would of course end up with unrelated search results

#

the computer isnt smart enough to know what you're thinking

#

but anyway, it's there and theres a lot of tutorials so you should be able to setup webhooks pretty easily.

hoary timber
#

So... If I understand it correctly, do I need to setup a get on startup, that f.e. listens to /votes on the VPS (which also hosts the site) and then peform actions, if that happens.
But what would I have to use, to get the values from the POST in the spark-api?

proud sphinx
#

What

#

You want to post or get

hoary timber
#

The webhook for votes gets send as POST.
I want to listen to those votes with the Spark-API. My question is now: Do I need to use get and what do I have to use, to get the values from that POST?

proud sphinx
#

You can listen to POST

#

Am confused

#

How can you get as post

hoary timber
proud sphinx
#

Please say what do you want to do

#

No code involved

hoary timber
#

I want to listen for votes

#

according to the API-page are they performed as POST request

proud sphinx
#

you need to only listen to post requests then

#

Yes

arctic arch
#

if its a post request, why are you talking about get

proud sphinx
#

Spark is overkill

hoary timber
#

๐Ÿคท

proud sphinx
#

Use OkHttp

arctic arch
#

...

proud sphinx
#

Oh wait

#

Springboot

#

I am stupid

hoary timber
#

*sigh*

#

That helps a noob like me absolutly nothing

arctic arch
#

instead of get, use post
ez

hoary timber
#

post "creates" something, according to the page (I still look at spark)

proud sphinx
#

@arctic arch but he needs to set up a server in Java

arctic arch
#

and they're using spark for that

#

and you dont have to create something

hoary timber
arctic arch
#

it's just this kind of standard what those would be used for on a website

proud sphinx
#

Whoops ok I am confused

#

@hoary timber yeah

hoary timber
#

You're not the only one @proud sphinx

proud sphinx
#

You can implement it how ever you want

#

You need to gather the request body

arctic arch
#

we're sending a post request, listen to that

proud sphinx
#

post("/votes", (req, res) -> {});

hoary timber
#

And I could put code there, to perform an action, right?
Just want to be sure...

arctic arch
#

yes

proud sphinx
#

req.queryParams() will give you the parameters

arctic arch
#

wrong

#

they're not query params, it's a json request body

#

req.body()

proud sphinx
#

Oh really

#

Then just params()

hoary timber
#

Looks like that post requires a return...

#

nvm. it was just the {}

arctic arch
#

I think you can just res.status(200) so it responds to the request with OK

hoary timber
#

Doesn't fix it

#

I always have "missing return statement", when using lambda with {}

arctic arch
#

just add a return

hoary timber
#

Doesn't work either

#

I hope return null; won't make issues

#

And I'm not 100% sure, how to get the different valiues.....

#

from the body... Never worked with such stuff

#

Wait. I did something like that before... with the API I use (it also returns JSON....)

#

I really lose my mind now on how annoying that is...

inner venture
#

@hoary timber do you still need help?

next zodiac
#

@restive otter cool ur here :)

hoary timber
#

@inner venture Yes.... I'm so confused right now

sharp quarry
#

How does one create a bot on mobile?

inner venture
#

Wrong channel

next zodiac
#

xD

restive otter
#

How would I post the server count with JS?

light crag
#

Either use the official library or POST the data yourself

final vortex
#

is there any way we can get an event that fires every time someone votes or will we have to check periodically?

fast tapir
#

webhooks are a thing

light crag
#

@final vortex use the official js lib

prisma mural
#

1|mb       | /home/ignis/node_modules/dblapi.js/src/index.js:138
1|mb       |   async postStats(serverCount, shardId, shardCount) {
1|mb       |         ^^^^^^^^^
1|mb       | SyntaxError: Unexpected identifier
1|mb       |     at createScript (vm.js:56:10)
1|mb       |     at Object.runInThisContext (vm.js:97:10)
1|mb       |     at Module._compile (module.js:549:28)
1|mb       |     at Object.Module._extensions..js (module.js:586:10)
1|mb       |     at Module.load (module.js:494:32)
1|mb       |     at tryModuleLoad (module.js:453:12)
1|mb       |     at Function.Module._load (module.js:445:3)
1|mb       |     at Module.require (module.js:504:17)
1|mb       |     at require (internal/module.js:20:19)
1|mb       |     at Object.<anonymous> (/home/ignis/node_modules/dblapi.js/index.js:1:80)
light crag
#

Are you using an old version of node?

prisma mural
#

6.14.3

raven zinc
#

Update to 8 or higher, as far as i know the async/await syntax isn't supported below 8

light crag
#

I thought it was 7.6 and above?

raven zinc
#

hmm, perhaps, anyway you need to update node ZoomEyes

light crag
#

^

prisma mural
#

Node.js updated

#

and another error

#
1|mb       | FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal.
1|mb       |  1: 0x8b8210 node::Abort() [node /home/ignis/mb/index.js]
1|mb       |  2: 0x8b825c  [node /home/ignis/mb/index.js]
1|mb       |  3: 0xac1afa v8::Utils::ReportApiFailure(char const*, char const*) [node /home/ignis/mb/index.js]
1|mb       |  4: 0x7fe56cf64839 Require(v8::Local<v8::Object>, char const*) [/home/ignis/node_modules/better-sqlite3/build/Release/better_sqlite3.node]
1|mb       |  5: 0x7fe56cf650de Integer::Init(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::Object>) [/home/ignis/node_modules/better-sqlite3/build/Release/better_sqlite3.node]
1|mb       |  6: 0x7fe56cf6cd37 RegisterModule(v8::Local<v8::Object>, v8::Local<v8::Object>) [/home/ignis/node_modules/better-sqlite3/build/Release/better_sqlite3.node]
1|mb       |  7: 0x8b9729  [node /home/ignis/mb/index.js]
1|mb       |  8: 0xb4ee49  [node /home/ignis/mb/index.js]
1|mb       |  9: 0xb4f9b9 v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [node /home/ignis/mb/index.js]
1|mb       | 10: 0xe47787841bd
tardy mauve
#

Anyone fancy giving me a hand setting up the Webhook API so i can have a Webhook message Posted to X Channel when USER Votes

plain timber
#

@tardy mauve just receive the post request at the url you set in the edit page

tardy mauve
#
const DBL = require('dblapi.js');
const dbl = new DBL(yourDBLTokenHere, { 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(vote);
  // Do what you need to do
});```

could you fill this in with EXAMPLEs so i know what goes where. Rubbish at webhooks
plain timber
#

i never got webhooks working with dblapi.js so i just set up a route in express

restive otter
#

ok cool but he's asking help about the webhook with the lib

formal sparrow
#

It always to go 3 when it isn't

#

Like it says the real count sometimes and 3 many times

#

My code was ```js
dbl.on('posted', () => {
})

#

Can someone help?

arctic arch
#

have you been using it on a test bot?

formal sparrow
#

Um sorry for disturbing you

#

That's the issue

restive otter
#

.

inner venture
#

@arctic arch honestly ive done that same thing an embarassingly large amount of times

uncut crystal
#

using production api keys in development wesmart

snow fiber
#

I have it using the bot.user.id property so I can't do it on accident

#

The only thing I forgot was that it would still set the count in DB

#

So my site would show that

lean wave
#

i once forgot about my test bot, shut down my bot to apply an update and then restarted it. the test bot was the only bot on for about 10 or so hours because i went to bed after that

restive otter
#

c

restive otter
#

hi

#

whats the client of discord.js

#

in dbl.token and client

dawn nymph
#

helo

static glen
#

what

#

I'm new to this.

#

I need help.

#

Mental help too.

plain timber
#

@restive otter the client is when you do something like const client = new Discord.Client(), usually it would be client but some people name it bot. its just whatever is before = new Discord.Client()

woeful grove
restive otter
#

nice thx @woeful grove

humble bison
#

@woeful grove good job at self promotion there ๐Ÿ‘€ cool thing though

jade cloak
#

Haha

woeful grove
#

i think the self promotion was ok because he actually looked for smth like that ThonkerGunsUp

humble bison
#

it's fine, yeah

inner venture
#

I don't thnk that's really relevant to thsi channel

livid moss
#

Oh oops wrong channel ๐Ÿ˜…

restive otter
#

Am I able to link my bot after its been approved? if it does

dawn fjord
#

Wrong channel @restive otter

digital narwhal
#

what is api?

#

but what is api

jaunty depot
digital narwhal
#

can you help? Thonk

jaunty depot
#

It's something kinda their coding system for bots and stuff.

#

I guess.

arctic arch
knotty grail
#

Fellas what do I enter for the webhook url on the dbl website

#

server ip or?

#

Im really struggling with making the webhook thing work

#

I assume since my hostname log is 0.0.0.0, I'd just need to enter the ip + port into the url

#

but that doesn't work

arctic arch
#

is the port open

jaunty depot
#

default port is 80

#

you don't have to type a port if it's default

arctic arch
#

by default you cant use port 80 so

gritty axle
#

I having a problem making the dblapi.js sending how many servers my bot is in my code:

const DBL = require("dblapi.js");
const dbl = new DBL(process.env.DBL, bot);
dbl.on("posted", () => {
    console.log(`Posted ${bot.guilds.size} servers to the DBL api!`)
  });

I've put the token in the env and it won't post and its displaying no error

shut ibex
#

did you wait 30 mins

#

the dblapi.js module posts every 30 mins

gritty axle
#

Its been a whole day ๐Ÿค”

shut ibex
gritty axle
#

same

jaunty depot
#

just take the example code instead of this?

#

in the dbl documentation

gritty axle
#

Ill try that in a min just testing smthn

#

Alright testing it

jaunty depot
#

okay

gritty axle
#

Ok i did it there is not error and nothing being put in the console but ill wait 30mins to see ๐Ÿ˜›

jaunty depot
#

you can make the time lower for now?

#

just for test

gritty axle
#

Ahh never saw that on the docs ok i will

jaunty depot
#

๐Ÿ‘Œ๐Ÿป

#

that should work

gritty axle
#

Nope nothing we set it to 10000 (10 secs)

#

Wait

#

I think i know why brb

jaunty depot
#

lel okay

gritty axle
#

Fixed Tysm

jaunty depot
#

np ๐Ÿ‘Œ๐Ÿป

restive otter
#

is there any bots on here i can add

jaunty depot
#

there is a lot of them but i don't think it the place where you ask

restive otter
#

where do i find them

jaunty depot
tardy crater
#

This isn't the channel to be discussing this.

digital narwhal
#

Is there an API for cleverbot

restive otter
#

yes but that's not what this channel is for

digital narwhal
#

Oh

jaunty depot
#

you can just remove the parts that you already have in your bot's main file

#

and add others

eager bronze
#

wym?

wet crow
#

I'm having problems trying to authorize my token

#

I got the format and the token but if I put in in the search bar on google it just searches up random stuff

#

Ping me if anybody responds I'm going to sleep

severe iron
#

why are you trying to Google it?

inner venture
#

which language are you using?

grand blade
#

@wet crow

trim shuttle
#

vote.user.addRole('Voter Role').catch(e => {

#

why does this not work

jade cloak
#

Error, code

trim shuttle
#

whats the correct way then

arctic arch
#

is vote the vote object you get from a webhook

trim shuttle
#

dbl.webhook.on('vote', vote => {
console.log(vote)
return vote.user.addRole('Voter [11]')
client.channels.get("476158627791634433").send(The text)

});

#

thats what i have

arctic arch
#

vote.user is only the id of the user

trim shuttle
#

oh

restive otter
#

how

#

would i do it

#

im trying to the same

wet crow
#

@inner venture JavaScript

loud gulch
#

why are you googling your token Thonk

wet crow
#

Irdk

#

I don't even know where to put the Authorization: Token

proud sphinx
#

In a heaser

#

header

#

Called Authorization

wet crow
#

Let me find it

#

Can't find it

#

I'm on my phone right now

wet crow
#

Can someone help me?

jaunty depot
#

Yes?

knotty grail
plain timber
#

Starts 12am Friday and ends 12am Monday iirc

wet crow
#

Where do we put Authorization: TOKEN

jaunty depot
#

you mean your bot's dbl token?

dawn fjord
#

As a header I believe

inner venture
#

@wet crow just use the dblapi.js lib

wet crow
#

OK

jade cloak
#

What is the best way to send a User a message when after he voted? Using Java

inner venture
#

@jade cloak the java lib doesn't have support for webhooks atm, but I'd love to help you implement it if you'd like

jade cloak
#

Would be very nice since I've never done anything with webhooks :3

inner venture
#

Let's move to dms so I get notifications ^^

wet crow
#

Once i install dblapi.js where do i put Authorization: TOKEN?

humble bison
#

@wet crow read the docs for the lib

#

it clearly shows where to put it

wet crow
#

In the Http header I don't even know where the Http header is

restive otter
#

Hi

plain timber
#

@wet crow you don't use a http header if ur using dblapi.js

#

Just read the docs please

#

You put it in the new DBL()

willow ruin
#

What is the best way to close dbl client connections? When interrupt py script with Ctrl-C connections stay unclosed.

willow ruin
#

Can I use raw requests to API base url instead of using library?

brittle iron
#

yes of course, just don't forget the Authorization part

gilded summit
#

Why specify the shardID and shardCount in .postStats?

restive otter
#

What to do with the Auth Part

gilded summit
#

What auth part?

#

@restive otter What auth part?

restive otter
#

At they website

gilded summit
#

What?

restive otter
#

If U edit Ur bot

gilded summit
#

What tf are you talking about?

#

Anyway

#

What's the point?

#

And does this mean I have to run the function on every shard connect?

restive otter
#

Token and Webhook

#

I mean

gilded summit
#

Bruh

#

If you don't know how the API works, don't answer

#

Clearly you have 0 idea of what you're talking about

restive otter
#

I โ€ฆ

#

No comment

brave pond
#

shard id is for multiple processes, shardcount is for single process sharding

gilded summit
#

Uhh

brave pond
#

if your bot is split into multiple processes each instance cant see all servers so the site adds them up basically

#

so I think that you would have to run it on each shard

gilded summit
#

Ah

brittle iron
#

Also, someone knows how to listen webhook in java?

inner venture
#

@brittle iron The lib doesnt support webhooks atm but its pretty easy to set one up

#

Have you worked with webservers before?

brittle iron
#

Not really, only once with sockets

inner venture
#

Alright, Id reccomend spark

#

is pretty hecking easy to use

brittle iron
#

Ok thx

inner venture
#

this is the website

brittle iron
#

Perfect thank you

restive otter
#

I was stuck on getting the Voting system working when I was running a bot on my PI. I have now upgraded to a Skysilk VPS. Already open ports. How would I configure this code to make it fit?

const DBL = require('dblapi.js');
const dbl = new DBL(yourDBLTokenHere, { 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(vote);
  // Do what you need to do
});
jaunty depot
#

Mine doesn't has port and password set, it just has dbl token

prime shard
#

I have more than 1000 votes a month, and to check if a user has voted I do https://discordbots.org/api/bots/467944868963024896/check?userId={user.id}"

#

should I have any problems with that?

jaunty depot
#

i don't do like that but maybe i'd work

restive otter
#

In the "API Options" section on bot edit page, when you edit the webhook URL and click "test", it sends to the original URL. To test the new URL you have to enter the new URL, save, edit again and then click test. Is this intended behaviour?

gray root
full socket
#

Anyone got a code snippet for a webhook implementation in C#?

full socket
#

Anyone? ๐Ÿ˜…

willow ruin
#

@prime shard Have you ever read API docs?

Individual User Id Voting Check for the past 24 hours.

Requires authentication.

Use this endpoint to see who have upvoted your bot in the past 24 hours. It is safe to use this even if you have over 1k votes.

GET/bots/{bot.id?}/check
Query String Params
Field     Type     Description
userId     Number     User id of the discord user
returns{voted: 1} or {voted: 0}
hoary timber
#

Quick API-question about webhooks:
No API-token is required for a bot to listen to webhooks, right? Or is it?

#

Because I'm thinking about a VoteListener-bot that listens for DBL-votes, so that people can give vote-rewards on their discord without the headache of setting up a votelistener in their bot...

inner venture
#

No token is required because you dont actually make any requests

#

However, DBL does allow you to provide a password/authorization token

#

separate from your normal one

#

that you can use to verify that the requests are coming from dbl and not some other sketchy person

hoary timber
#

kk

restive otter
#

groovy, any feedback about my question above about webhook test button?

inner venture
#

@restive otter Yeah, that seems pretty normal

karmic veldt
#
    let tde = bot.guilds.get("429995294542004225");
    let ch = tde.channels.get("471779437164101652");
    ch.send(`User <@${vote.user}> has just voted for Automator! Thanks for voting :smile:`)

})
#

Getting an error with that

#

._.

#

@arctic arch You helped me last time (sorry for ping) is there anyway you can help me with this?

arctic arch
#

whats the error

karmic veldt
#

TypeError: Cannot read property 'on' of undefined

#

const data = new DBL('TOKEN', {webPort: 5000, webAuth: 'accesstobot'});

#

Port 5000 is port forwarded

#

dblapi.js is installed

arctic arch
#

it's webhookPort and webhookAuth

karmic veldt
#

Oh

arctic arch
#

you forgot the hook ๐Ÿ˜›

karmic veldt
#

๐Ÿ˜‚

#

Thanks

#

When I press test on the webhook page it does nothing

#

._.

#

Idk if I did something wrong

#

Orrrrr

#

How I am meant to test it

#

and what test does

#

๐Ÿ˜‚

#

@arctic arch Sorry for double ping, can you see anything wrong?

#

Got no errors now but test doesnt do anything

inner venture
#

did you correctly set your webhook url on dbl

karmic veldt
#

Yeah

#

Like I made a webhook

#

Copied the URL

#

and put it onto there

#

Yeah

inner venture
#

are you running the bot at your house

karmic veldt
#

Nope Ubuntu

inner venture
#

or some other place where you would need to port foward

karmic veldt
#

Port Forwarded port 5000

inner venture
#

hm

karmic veldt
#

Yeah idk

arctic arch
#

have you saved

restive otter
#

You need to add /dblwebhook on the end of it

karmic veldt
#

Yup

#

The end of what?

#

The code?

restive otter
#

Your URL

karmic veldt
#

On DBL? I need to add that in

restive otter
#

Yes

karmic veldt
#

Where it says URL

#

add in /dblwebhook

restive otter
#

Yes

karmic veldt
#

Ok

restive otter
#

Then hopefully it will work

karmic veldt
#

What does "Test" do?

#

Send a test vote?

loud gulch
#

yea

karmic veldt
#

Still nothing then

#

:/

restive otter
#

What you hosting on?

karmic veldt
#

OVH

#

VPS

restive otter
#

Okay

karmic veldt
#

I used UFW to port forward 5000/TCP

arctic arch
#

got http:// in there?

karmic veldt
#

Where?

arctic arch
#

http:// ip:port/dblwebhook

karmic veldt
#

Where do you mean?

#

on the DBL website?

arctic arch
#

ye

karmic veldt
#

For URL I have

restive otter
#

oh lord

karmic veldt
#

._.

#

It said

#

Webhook URL

#

๐Ÿ˜‚

#

OH WAIT

restive otter
#

๐Ÿ˜‚

karmic veldt
#

I AM AN IDIOT

#

Omg

#

Thats so embarassing

#

UGH

#

PRETEND THAT DIDNT HAPPEN

loud gulch
#

is that what you put on the website

karmic veldt
#

Uh

#

So

#

URL looks like this

#

!!.!!.!!.!!:5000/dblwebhook

#

Except !! is the IP

#

@restive otter Is that right?

restive otter
#

Think so yeah

karmic veldt
#

Still not working

#

._.

restive otter
#

Idk lmfao, I used glitch for my vote thing anyway ๐Ÿ˜‚

#

Then my main bot is run on Skysilk

karmic veldt
#

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

#

@arctic arch This is right tho ._. right?

inner venture
#

that ip is definitely readable lmao

karmic veldt
#

Uh

#

Woops

#

๐Ÿ˜‚

inner venture
#

lmao

karmic veldt
#

Is that right?

#

๐Ÿ˜‚

#

Because I am really confused
๐Ÿ˜‚

#

And "Test" still isnt working

jaunty depot
#

mine has /vote at the end instead of that

karmic veldt
#

Ok

#

Let me try that

#

Still

#

Nothing

#

๐Ÿคฆ

#

I am so confuseddd

arctic arch
#

it doesn't look like it has http:// on it to me

karmic veldt
#

Omg

#

It didnt

#

Okay

#

That works

#

Ty

#

๐Ÿ˜‚

slim plaza
#

How can I check if a user can vote

inner venture
#

Like, if its been 12 hours since their last vote?

slim plaza
#

Yes

inner venture
#

You could just called individual vote checking endpoint and then see if it says they've voted

#

if says they havent, they can vote

#

Which lang are you using?

slim plaza
#

Python

#

@inner venture And what can I do with the /check?userId=.. endpoint?

thick marsh
#

how to unban api ?

uncut crystal
#

Could you elaborate?

thick marsh
#

elaborate what ?

uncut crystal
#

your question

thick marsh
#

my VPS get ban on API and any bot here cant start bc have problem with connect to gateway

#

like get ban

#

but when i host it from my pc it work normal

#

now is elaborate ?

brittle iron
#

Maybe a problem of firewall

thick marsh
#

bot work half year without any error

#

one day stop respond and second one got down

#

and i cant run it

#

bc on start have gateway problem

karmic veldt
#

Ok well

#

It worked

#

for about 2 votes

#

and now

#

It won't work when my friend voted

#

._.

brittle iron
#

Seems that cloudflare has banned your ip

inner venture
#

That sounds like an issue with discord, no?

eager bronze
#
const Discord = require("discord.js");
const DBL = require("dblapi.js");

const bot = new Discord.Client({disableEveryone: true});
const dbl = new DBL(process.argv[2] || config.token);

bot.on("ready", async () => {
  console.log(`${bot.user.username} is online on ${bot.guilds.size} servers!`);
  bot.user.setActivity(`for ${bot.guilds.size} servers | ${config.prefix}help`);
  bot.user.setStatus("online");
  setInterval(() => {
    dbl.postStats(bot.guilds.size);
  }, 1800000);
});

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

dbl.on("error", err => {
 console.log(err);
 raven.captureException(err);
})
``` have I set it up correctly for posting my server count to DBL?
arctic arch
#

const dbl = new DBL(process.argv[2] || config.token); is that your bot token? It should be a DBL token

thick marsh
#

@brittle iron waht

#

how it can ban my host

#

and why

arctic arch
#

and those events are never going to do because you're posting manually, you'd get completion status using promises

brittle iron
#

how, as far as i know the gateway is protected by cloudflare. why idk

thick marsh
#

so only way is get new ip there ?

#

bc change host is not on my walet

#

i need wait 3 weeks 4 that

brittle iron
#

idk, but you should send a ticket to discord

thick marsh
#

and wait 2 days for bot respond

eager bronze
#

wait, how do I get my dbl token? @arctic arch

brittle iron
#

on the tbl website

#

clicking in the right corner on your name

#

then on your bot you click "edit"

eager bronze
#

mhm

brittle iron
#

last box is the API option where you can get the token

eager bronze
#

ahh

#

thanks man!

#

other than that, does the code look fine?

brittle iron
#

which code? ๐Ÿ‘€

eager bronze
#
const Discord = require("discord.js");
const DBL = require("dblapi.js");

const bot = new Discord.Client({disableEveryone: true});
const dbl = new DBL(process.argv[2] || config.token);

bot.on("ready", async () => {
  console.log(`${bot.user.username} is online on ${bot.guilds.size} servers!`);
  bot.user.setActivity(`for ${bot.guilds.size} servers | ${config.prefix}help`);
  bot.user.setStatus("online");
  setInterval(() => {
    dbl.postStats(bot.guilds.size);
  }, 1800000);
});

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

dbl.on("error", err => {
 console.log(err);
 raven.captureException(err);
})
#

forget about the process.argv[2] || config.token

brittle iron
#

idk, i'm not a js guy ๐Ÿ˜”

eager bronze
#

๐Ÿ˜ฆ

#

alright well, thanks so much for helping me get my token

karmic veldt
#

I'm a JS dudeeee

#

What's up

shut ibex
#

Code looks fine to me

eager bronze
#

hi Sam, hi Jonas

karmic veldt
#

Hey

eager bronze
#

right uh, everything looks fine?

karmic veldt
#

Yeah

eager bronze
#

Awesome! Thanks man

karmic veldt
#

Try it and if anything is wrong get back to me

brittle iron
#

I personnaly update the server count when the bot enter/leave a server ๐Ÿ‘€

eager bronze
#

You're right

#

I have yet to even get the server count up first,

#

So putting it inside the ready event would put it up

brittle iron
#

yeah, also I have a little command to put em up whenever I want

eager bronze
#

nice

#

i'll see what I can do ๐Ÿ˜ƒ

brittle iron
#

everything, you're a coder ๐Ÿ˜Ž

eager bronze
#

๐Ÿ˜

#

its not supposed to update right away, right? @karmic veldt

karmic veldt
#

It updates after the setTimeout runs out

#

So it will wait the full time

#

Before doing it

eager bronze
#

right, figured

karmic veldt
#

It'll wait 30m like you specified first

#

Yup

eager bronze
#

mhm

karmic veldt
#

np

eager bronze
#

alright, I think I got it to work, lets just hope it updates once it finishes the timer

#

Thanks so much man!

karmic veldt
#

No problem! ๐Ÿ˜„ I had the same issues with this API for days

eager bronze
#

haha

karmic veldt
#

I put an actual webhook into the webhook part of the bot on the website

#

So

#

Haha

eager bronze
#

haha, rip

karmic veldt
#

Ikr

#

Its all good now tho haha

eager bronze
#

haha, thats good

#

welp, good luck to you sir!

arctic arch
#

cute

thick marsh
hot karma
heavy owl
#

hello new here ;p.. im looking in the website a robot for music, who dont leave the chat voice later the song finish... any can have suggestion?.. i use fredboat but sometimes that broken.. so i was looking for another.

sterile scroll
#

Rhythm not bad @heavy owl

humble bison
#

@heavy owl wrong channel, use #general. but tbh just use rhythm

gilded summit
#

Why send votes to a webhook instead of just from DBL itself?

full socket
#

I'm guessing because for big bots the payload would be massive

plain timber
#

Also you can instantly know when a user votes

#

And you can reward them

kindred radish
#

/bots/{bot.id?}/check is there a NON 24 check method?

#

or are you supposed to save it locally

loud gulch
#

you would need a webhook iirc

kindred radish
#

yep, Implemented it already

#

๐Ÿ˜„

tawdry pine
#

What response am I supposed to get from POST /bots/{id}/stats?

#

That's What I am getting rnjson {"shards":[]}

arctic arch
#

if everything's successful it should be {}

#

that looks like a GET request

tawdry pine
#

axios.post() ๐Ÿ‘€

#

hol up

#

what the heck

#

it's sending GET lol

tawdry pine
#

oh wow

#

I was sending the request to http:// instead of https://

misty geode
lofty bluff
#

Can I get help with JS?

loud gulch
restive otter
#

Would someone mind explaining to me how to call the member function within in the on command function?

#

Heres an example of what I am doing

#
@client.command(pass_context=True)
async def login(ctx, email="None", member: discord.Member = None):
    author = ctx.message.author.id

    print(discord.Member.roles)
inner venture
restive otter
#

xd

#

JK lol! Thx

#

what.

#

Should I copy and paste my question to devolpment?

inner venture
#

yeah

restive otter
#

Okay thank u

uncut crystal
#

wrong channel, read the topic

summer oracle
#

does the response code matter, or does dbl absolutely not care about it?
as in, im thinking of just always returning a 403 or 404 (even when the request was legit) just to avoid of the endpoint/path getting crawled and indexed on some weird place

OR

is there a list of IPs / IP ranges that we can expect the dbl webhooks to come from so that we can whitelist the webhook endpoint for them?

and if the answer is no to both, are there any plans to change that? possible example: currently response codes are ignored, but there are plans for in the future to redeliver webhooks upon a non-2xx response.
I want to avoid breaking the api more than necessary for such cases ๐Ÿ™ƒ

jade cloak
#

I dont think it matters :|

arctic arch
#

rn the response code doesn't matter

#

but we might introduce redelivery and error logging later

#

you should use the authorization to verify the request

summer oracle
#

true

#

i can return 2xx upon successful auth and not care about the rest

restive otter
#

How do you shard a bot?

inner venture
restive otter
#

oops

torpid iris
#

Just a question I'm gonna look dumb but just wondering, I'm getting a 401 error Just like wondering how do I autorize it? I used the correct token and such for linking the bot to the api to show the bot list or whatever but what else do I need to do LOL

#

p.s. mention me if you reply I don't have this unmuted and I'm a little busy lul

inner venture
#

@torpid iris How are you using the token? 401 is usually returned if there's no token iirc

torpid iris
#

the way the website tells me sorry for the late reply

#

I have the attention span of a 4 year old

#

Got distracted

inner venture
#

Which language are you using, btw? @torpid iris

#

๐Ÿค”

torpid iris
#

js

inner venture
#

Could I see a sample of how youre trying to use the api

#

@torpid iris

torpid iris
#

sures

#
(other stuffs)
const DBL = require("dblapi.js");
const dbl = new DBL('-web token-', client);

(event handler but no need for this)

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

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

@inner venture ^ just in case if you're like me and get distracted easily

inner venture
#

You're not doing something like using your discord token right @torpid iris hahah

torpid iris
#

????

torpid iris
#

@inner venture explain ๐Ÿ˜‚

inner venture
#

i was just making sure you werent using your discord bot token in place of your dbl token @torpid iris

torpid iris
#

Nope

torpid iris
#

that was helpful

restive otter
#

@ThaBot

humble bison
rich crow
#

I am not able to use the votes API in my commands

lunar tide
#

on the webhook when the bot start and you go to the site ip thats showen in console from it would the site show anything or just this

this is whats in console: Webhook running at http://0.0.0.0:5657/dblwebhook but does not do anything on site or when you test it in the dbl edit

inner venture
#

0.0.0.0 just means that it will accept any requests that reach it

#

You should replace it with your machines actual ip

#

Loading it in browser shouldnt show naything, either

lunar tide
#

hmm ok makes more sence

inner venture
#

Because when you load it in browser, that would execute a GET request when the endpoint is only configured to receive POST requests

lunar tide
#

ahh yah i see it worked now!

inner venture
#

awesome ๐Ÿ˜Š

#

glad it was an easy fix haha

lunar tide
#

one more question sir

inner venture
#

sure