#topgg-api

1 messages ยท Page 35 of 1

arctic arch
#

oh its a branch

worthy ferry
#

Yeah

arctic arch
#

isn't that a new feature in development kinda branch

worthy ferry
#

I'm modyfing the API rn

#

No

#

It's here from like 3 months

#

or something

#

So idk what to post as shard id

#

Cause I'm not able to get bot's shard as it's acting like normal non-sharded bot

#

(Easier to maintain)

#

:/

#

H... help ?

snow fiber
#

@worthy ferry You don't have to post shard ID's if you have the total available

worthy ferry
#

oH OK

snow fiber
#

You can just post server_count with the total value

#

You can also add shard_count with your amount of shards

#

But that's not really neccesary

worthy ferry
#

KK

#

Want me to send you modified version of API?

snow fiber
#

No, I don't use Javascript myself

#

I honestly have no need

worthy ferry
#

I mean for the team

snow fiber
#

Oh, you can make a PR I reckon

worthy ferry
#

PR I reckon? my brain doesn't work today

snow fiber
#

Pull Request

worthy ferry
#

ooooo

snow fiber
#

If you make a PR here the team can review your changes

restive otter
#

@snow fiber the dblapi, how can you display an extra footer on the vote webhook, when the double weekend is active?

plain timber
#

@restive otter just check if isWeekend is true

restive otter
#

so if(dbl.isWeekend()) {
// add footer
}

#

?

#

@plain timber

plain timber
#

No

restive otter
#

then wut

plain timber
#

You're using webhooks right

restive otter
#

yes

plain timber
#

isWeekend is a field sent in the webhook body

#

Just like user and bot

restive otter
#

yes but how do i use it

#

so it shows when the boost is on

plain timber
#

How are you getting the user id

restive otter
#

vote.user

plain timber
#

Then check vote.isWeekend

restive otter
#

okay

#

so if(vote.isWeekend()) {
// add footer

plain timber
#

Yeah I guess

#

Oh wait

#

No () after isWeekend

restive otter
#

ok

plain timber
#

Did you try it?

worthy ferry
#

PR submitted :3

gilded summit
#

....

#

isWeekend is a property

#

Why would you try to execute it as a function?

hoary timber
#

Did something in the API changed?
I get an error in maven, that it can't get the DBL-api

#

(tag me pls since I muted the guild)

hoary timber
#

I really need help.
I can't make a change to my bot, because it looks like that something in the API has changed... Altough the API-page shows still the same stuff that I currently use

arctic arch
#

what language?

hoary timber
#

I tested around and can confirm, that something isn't right with the dependency for the API, because after commenting all apearence of the API out, does ot work now

#

Java @arctic arch

arctic arch
#

a new version was released, docs arent up to date yet

hoary timber
#

So. What are the new methods then?

arctic arch
hoary timber
#

ok.

#

What's the reason behind using the botID too now?

#

Ahhh I see

#

To no longer have it in setStats

#

Is there any way, to get update-notifications for the API @arctic arch

#

Other than through GitHub, by watching it, because that could just spam my e-mail....

arctic arch
#

idk

restive otter
#
5|nsfw     |     at _response.transport.request.then (/home/tutorapide/nsfw/node_modules/snekfetch/src/index.js:182:21)
5|nsfw     |     at <anonymous>
5|nsfw     |     at process._tickDomainCallback (internal/process/next_tick.js:228:7)
5|nsfw     |   request: undefined,
5|nsfw     |   body: { error: 'Unauthorized' },
5|nsfw     |   raw: <Buffer 7b 22 65 72 72 6f 72 22 3a 22 55 6e 61 75 74 68 6f 72 69 7a 65 64 22 7d>,
5|nsfw     |   ok: false,
5|nsfw     |   headers:
5|nsfw     |    { date: 'Thu, 26 Jul 2018 19:14:52 GMT',
5|nsfw     |      'content-type': 'application/json; charset=utf-8',
5|nsfw     |      'content-length': '24',
5|nsfw     |      connection: 'close',
5|nsfw     |      'set-cookie':
5|nsfw     |       [ '__cfduid=d35020e1628e45d140a462cf72355fdc51532632492; expires=Fri, 26-Jul-19 19:14:52 GMT; path=/; domain=.discordbots.org; HttpOnly; Secure' ],
5|nsfw     |      'x-powered-by': 'Express',
5|nsfw     |      'access-control-allow-origin': '*',
5|nsfw     |      'access-control-allow-headers': 'Authorization',
5|nsfw     |      etag: 'W/"18-XPDV80vbMk4yY1/PADG4jYM4rSI"',
5|nsfw     |      'x-cacheable': 'NO',
5|nsfw     |      'x-varnish': '954990863',
5|nsfw     |      age: '0',
5|nsfw     |      via: '1.1 varnish-v4',
5|nsfw     |      'strict-transport-security': 'max-age=15552000; includeSubDomains; preload',
5|nsfw     |      'x-content-type-options': 'nosniff',
5|nsfw     |      'expect-ct': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
5|nsfw     |      server: 'cloudflare',
5|nsfw     |      'cf-ray': '440931160b2ea84b-CDG' },
5|nsfw     |   statusCode: 401,
5|nsfw     |   statusText: 'Unauthorized' }
``` Help me  .
#

My code post guild

 snekfetch.post(`https://discordbots.org/api/bots/stats`,{
      headers: { Authorization: 'token' }
    })
        .send({ server_count: client.guilds.size})
        .catch(err => console.log(`'[Discordbots.org] Impossible d\'Update!'`, err));```
sullen nymph
#

'token' is your actual DBL token, right?

restive otter
#

I put a token to hide my token sorry my english i am french

#

i can translate im french and english

#

does anyone here know anything about skyslik cloud?

#

i would like to know how to use the api to have a code who send a webhook message when i got an upvote
can someone help ?

steady charm
#

.hasVoted(id) in the docs says 24 hours but since the new update that people can vote every 12 hours, has it changed to just check in the last 12 hours now or is it still last 24 hours?

inner venture
#

@hoary timber you do bring up a good point

#

i dont think there is any way to do it, really

#

but that is def something that should be looekd into

hoary timber
#

@inner venture What point?

inner venture
#

there should be some way for lib users to get notified when new vers come out

hoary timber
#

New feature for @abstract moth ? ๐Ÿคท

inner venture
#

lmao

#

i dont really plan to be changing it besides for DBL updates

hoary timber
#

I personally wish, that Discord would change, that bots are also labeled in VC.... But that's nothing for here tho

sturdy scaffold
#
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(`User with ID ${vote.user} just voted!`);
});``` `const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });` what should i put in the port?
inner venture
#

@sturdy scaffold Any port that isnt in use

sturdy scaffold
#

i dont have a port

inner venture
#

Uh

#

are you hosting the server at your house

sturdy scaffold
#

wdym server?

#

like my WIFI?

inner venture
#

no no no

#

I meant the web server that the api will create

sturdy scaffold
#

dont have one

inner venture
#

If you dont know which one to use mate, just use 5000 or something

#

i dunno man

sturdy scaffold
#

doesnt work tho

inner venture
#

why

#

why doesnt it work

sturdy scaffold
#

wait

#

ill try again

inner venture
#

Look at that

#

:p

sturdy scaffold
#

ok thanks

#

that didnt work const DBL = require('dblapi.js'); const dbl = new DBL('token', { webhookPort: 5000 }); 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!`); });

#

didnt consolelog

inner venture
#

did you read the page I sent you

sturdy scaffold
#

yep

inner venture
#

I dont think you did

#

at all

sturdy scaffold
#

its 3000

#

for the port

inner venture
#

You have it set to 5000 in that code

sturdy scaffold
#

does the token go in strings?

brittle iron
#

Yes

sturdy scaffold
#

      throw er; // Unhandled 'error' event

      ^


Error: listen EADDRINUSE :::3000

    at Object._errnoException (util.js:1041:11)

    at _exceptionWithHostPort (util.js:1064:20)

    at Server.setupListenHandle [as _listen2] (net.js:1322:14)

    at listenInCluster (net.js:1370:12)

    at Server.listen (net.js:1466:7)

    at DBLWebhook._startWebhook (/rbd/pnpm-volume/f8110243-3aa1-4889-82fb-766dc6afd160/node_modules/.registry.npmjs.org/dblapi.js/2.2.0/node_modules/dblapi.js/src/webhook.js:45:18)

    at new DBLWebhook (/rbd/pnpm-volume/f8110243-3aa1-4889-82fb-766dc6afd160/node_modules/.registry.npmjs.org/dblapi.js/2.2.0/node_modules/dblapi.js/src/webhook.js:27:12)

at DBLAPI (/rbd/pnpm-volume/f8110243-3aa1-4889-82fb-766dc6afd160/node_modules/.registry.npmjs.org/dblapi.js/2.2.0/node_modules/dblapi.js/src/index.js:69:22)

at Object.<anonymous> (/app/index.js:42:13)

    at Module._compile (module.js:573:30)```
#

@inner venture i set the port to 3000 and this happened

inner venture
#

find out whats using port 3000 then man

sturdy scaffold
#

wtf is a 'port'

brittle iron
#

Its a door

inner venture
#

This is the API help channel, not the basic networking terminology help channel

sturdy scaffold
#

just need to send a message when a user votes

#

why is it so hard

inner venture
#

because youre using a garbage host

sturdy scaffold
#

do i have to fill that box in for it to work?

nimble steeple
#

no you dont

inner venture
#

Yes, you do

sturdy scaffold
#
    console.log(votes)
});``` will this send all the voters?
inner venture
#

It will send the last 1000 votes

sturdy scaffold
#

ok

#
const dbl = new DBL('token', bot);

dbl.getVotes().then(votes => {
    console.log(votes)
});``` why does this not send my bots voters?
sullen nymph
#

Did you replace the 'token' and bot with your actual token and Client instance or whatever it is?

sturdy scaffold
#

my bots token

#

like the DBL one

sullen nymph
#

Yep GWchadThink

sturdy scaffold
#

yh

sullen nymph
#

And is bot not non-existent?

sturdy scaffold
#

wdym?

sullen nymph
#

Do you have bot declared/defined?

sturdy scaffold
#

yes

#
const server = http.createServer(app);
const dbl = new DBL('token', {  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('/', (req, res) => {
  // ...
});

server.listen(5000, () => {
  console.log('Listening');
});``` i have this but when i vote it doesnt console.log
restive otter
#

@plain timber yea it worked

#

@gilded summit because checking isWeekend manually it needs () according to the api docs

light crag
#

You were using webhooks. IsWeekend is a property in that context.

sturdy scaffold
#
const server = http.createServer(app);
const dbl = new DBL('token', { webhookAuth: 'password', 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('/', (req, res) => {
  // ...
});

server.listen(5000, () => {
  console.log('Listening');
});``` why when i vote does it not do anything?
humble bison
#

You need to put the URL and port of your Express server running.

sturdy scaffold
#

where do i put the port?

humble bison
#

Literally in the box you've screenshotted. So, if my webhook is running on 1.0.00.11 with the port 3000, I'd set it as http://1.0.00.11:3000 exactly.

sturdy scaffold
#

whats 1.0.00.11?

inner venture
#

an ip

sturdy scaffold
#

so i put my ip?

humble bison
#

You put the IP or URL of your Express server.

sturdy scaffold
#

how do i get them?

humble bison
#

Well, the IP would be the IP address of the machine your using, and the port would be 5000 for you.

sturdy scaffold
#

ok

#

my IPv4?

fast tapir
#

Yes

sturdy scaffold
#

kk

#

so this

gilded summit
#

@restive otter ... What?

#

That makes no sense

#

What language?

sturdy scaffold
humble bison
#

uh

#

I think so.

sturdy scaffold
#

its so hard to do

#

very confusing

#

can someone show me an example using express please

#

ive been trying all night

humble bison
#

There's an example on the API documentation.

sturdy scaffold
#

that doesnt work

#
const DBL = require('dblapi.js');
const express = require('express');
const http = require('http');

const app = express();
const server = http.createServer(app);
const dbl = new DBL(yourDBLTokenHere, { webhookAuth: 'password', 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('/', (req, res) => {
  // ...
});

server.listen(5000, () => {
  console.log('Listening');
});``` what do i put in ```js
app.get('/', (req, res) => {
  // ...
});```?
gilded summit
#

Ew

#

No syntax highlighting

sturdy scaffold
#

cba

humble bison
#

We aren't going to spoonfeed you.

sturdy scaffold
#

then make it more clear

humble bison
#

The API is pretty simple, just experiment with it for a bit and work it out.

sturdy scaffold
#

i have for 3 hours

#

then i have to wait 12 hours to test

light crag
#

There is a test button under the webhook section of your bot.

sturdy scaffold
#

doesnt do anything

summer oracle
#

You don't even need to use that. You can curl it just as well.

sturdy scaffold
#
const DBL = require('dblapi.js');
const dbl = new DBL('token', { webhookPort: 3000, webhookAuth: 'password' }, bot);

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!`);
});``` so this should work?
#

@humble bison

humble bison
#

Try it?

sturdy scaffold
#

how?

#

cant vote

#

didnt work ๐Ÿ˜ฆ

humble bison
#

Use the test webhook button.

sturdy scaffold
#

doesnt work

loud gulch
#

you put http

#

it should be https

sturdy scaffold
#

ok

#

still doesnt work @loud gulch

loud gulch
#

maybe remove the /dblwebhook

sturdy scaffold
#

nope

loud gulch
#

wait a sec

sturdy scaffold
#

k

loud gulch
#

try going to you glitch site

sturdy scaffold
#

ok

#

im at it

loud gulch
#

what u see

sturdy scaffold
#
events.js:182

      throw er; // Unhandled 'error' event

      ^


Error: listen EADDRINUSE :::3000

    at Object._errnoException (util.js:1041:11)

    at _exceptionWithHostPort (util.js:1064:20)

    at Server.setupListenHandle [as _listen2] (net.js:1322:14)

    at listenInCluster (net.js:1370:12)

    at Server.listen (net.js:1466:7)

    at DBLWebhook._startWebhook (/rbd/pnpm-volume/f8110243-3aa1-4889-82fb-766dc6afd160/node_modules/.registry.npmjs.org/dblapi.js/2.2.0/node_modules/dblapi.js/src/webhook.js:45:18)

    at new DBLWebhook (/rbd/pnpm-volume/f8110243-3aa1-4889-82fb-766dc6afd160/node_modules/.registry.npmjs.org/dblapi.js/2.2.0/node_modules/dblapi.js/src/webhook.js:27:12)

at DBLAPI (/rbd/pnpm-volume/f8110243-3aa1-4889-82fb-766dc6afd160/node_modules/.registry.npmjs.org/dblapi.js/2.2.0/node_modules/dblapi.js/src/index.js:69:22)

at Client.<anonymous> (/app/index.js:72:13)

    at emitNone (events.js:110:20)``` im gettings this error @loud gulch
loud gulch
#

uhh

sturdy scaffold
#

it stopped

loud gulch
#

you are already using port 3000

sturdy scaffold
#

i get this

loud gulch
#

that means its ok

#

try it now

sturdy scaffold
#

what should i put in the URL box?

loud gulch
#

what do you have now

sturdy scaffold
#

https://anchor.glitch.me:3000/dblwebhook

#

doesnt work

loud gulch
#

remove /dblwebhook

#

also whats the port of the webhook itself, not the express server

sturdy scaffold
#

how do i check?

loud gulch
#

look at your code

sturdy scaffold
#

3000

loud gulch
#

and the one for express server

sturdy scaffold
#

3000

loud gulch
#

meh try it

sturdy scaffold
#

i have

#

doesnt work

loud gulch
#

well all i can say is try changing the webhook port

#

and in the url box change 3000 to what port you put

sturdy scaffold
#

i dont have a port

loud gulch
#

heh

#

ok

sturdy scaffold
#

what should i put the port as?

#

it said in the example i didnt need one

loud gulch
#

well if you dont put one im sure you use the port of the express server

sturdy scaffold
#

i really want this to work

#

OMFG

#

IT WORKED

#

โค @loud gulch

loud gulch
#

๐Ÿ‘Œ

novel cape
#

Can anyone tell me why this is just returning the voted part?

junior goblet
#

@novel cape you better renew that token

#

don't share that

novel cape
#

oh yea

#

im stupid

novel cape
#

Im getting 401 Unauthorized what does it mean ยฏ_(ใƒ„)_/ยฏ

sacred parcel
#

Your token is probably wrong

#

it means you didnt log in properly

novel cape
#

Well I got the token from the api page

#

sooo

reef apex
#

sure, but where did you put the token in the request? @novel cape

novel cape
#
const dbl = new DBL('Token', client);```
reef apex
#

hmm then you must have the wrong token mmLol

#

maybe try to regenerate the token and make sure that there aren't any trailing spaces

pearl mauve
#

How do I make so users have to have voted for the bot to use specific commands?

snow fiber
#

Check if the user has voted

#

You can use the /check endpoint

misty geode
#

@sturdy scaffold wana help me setup the webhook?

inner venture
#

@misty geode Are you also on glitch

misty geode
#

no

#

should i use glitch?

inner venture
#

no, it was just the main issue he was having

#

what lib are you using?

misty geode
#

discord.js

inner venture
#

It should be straight forward if you follow the example on here

misty geode
#

so i can use my own site?

inner venture
#

Yeah

misty geode
#

okay

#

this should be easy then

#

i just got confused on what url to use

misty geode
#

@inner venture Webhook running with path /dblwebhook SQL CONNECTED Bot has started, with 7 users, in 4 channels of 1 guilds.

#

so i need to add that path to the link?

inner venture
#

Yeah

#

so it'll be something like

misty geode
#

k im using glitch for testing then ill move on to my site

#

so like this

inner venture
#

maybe

#

im not familiar with glitch

#

just try it kek

misty geode
#

ye

plain timber
#

tbh, i couldnt get webhooks working with dblapi.js so i just set it up with express, it was easy

#

just check for a POST request

arctic arch
#

if you managed to get express working how did you not manage to set a few variables ๐Ÿ‘€

misty geode
#

lol now im getting same error as @sturdy scaffold

arctic arch
#

cannot get?

misty geode
#

events.js:183

      throw er; // Unhandled 'error' event

      ^


Error: listen EADDRINUSE :::3000

    at Object._errnoException (util.js:992:11)

    at _exceptionWithHostPort (util.js:1014:20)

    at Server.setupListenHandle [as _listen2] (net.js:1355:14)

    at listenInCluster (net.js:1396:12)

    at Server.listen (net.js:1480:7)

    at DBLWebhook._startWebhook (/rbd/pnpm-volume/9edfe881-972d-4120-a555-e4687147d290/node_modules/.registry.npmjs.org/dblapi.js/2.2.0/node_modules/dblapi.js/src/webhook.js:45:18)

    at new DBLWebhook (/rbd/pnpm-volume/9edfe881-972d-4120-a555-e4687147d290/node_modules/.registry.npmjs.org/dblapi.js/2.2.0/node_modules/dblapi.js/src/webhook.js:27:12)

    at new DBLAPI (/rbd/pnpm-volume/9edfe881-972d-4120-a555-e4687147d290/node_modules/.registry.npmjs.org/dblapi.js/2.2.0/node_modules/dblapi.js/src/index.js:69:22)

at Object.<anonymous> (/app/server.js:24:13)

    at Module._compile (module.js:652:30)```
arctic arch
#

yeah something's already using the port

misty geode
#

ye

#

ima try 5000

inner venture
#

i think glitch only opens 80 and 3000

#

maybe

loud gulch
#

nah

misty geode
#

i hit test

#

and nothing shows

#

๐Ÿค”

inner venture
#

Did you set the port in the URL to 3000?

#

or is it still at 80 lol

misty geode
#

5000

#

cause its listening on 5000

inner venture
#

but

#

the screenshot you just sent says its listening on port 3000

loud gulch
#

the express server is 3000

#

the webhook is 5000

#

probably

misty geode
inner venture
#

Just read into the glitch docs a bit

#

@misty geode

#

can you try removing the port from the webhook url you set in DBL

#

and then setting the port in your program to 3000

misty geode
#

okay

#

events.js:183

      throw er; // Unhandled 'error' event

      ^


Error: listen EADDRINUSE :::3000

    at Object._errnoException (util.js:992:11)

    at _exceptionWithHostPort (util.js:1014:20)

    at Server.setupListenHandle [as _listen2] (net.js:1355:14)

    at listenInCluster (net.js:1396:12)

    at Server.listen (net.js:1480:7)

    at DBLWebhook._startWebhook (/rbd/pnpm-volume/9edfe881-972d-4120-a555-e4687147d290/node_modules/.registry.npmjs.org/dblapi.js/2.2.0/node_modules/dblapi.js/src/webhook.js:45:18)

    at new DBLWebhook (/rbd/pnpm-volume/9edfe881-972d-4120-a555-e4687147d290/node_modules/.registry.npmjs.org/dblapi.js/2.2.0/node_modules/dblapi.js/src/webhook.js:27:12)

    at new DBLAPI (/rbd/pnpm-volume/9edfe881-972d-4120-a555-e4687147d290/node_modules/.registry.npmjs.org/dblapi.js/2.2.0/node_modules/dblapi.js/src/index.js:69:22)

at Object.<anonymous> (/app/server.js:24:13)

    at Module._compile (module.js:652:30)```
#

same error

inner venture
#

what's using port 3000 then

misty geode
#

the express server

inner venture
#

well obviously not

#

because it just said it was in use

#

no?

misty geode
#

yes

#

glitch is weird

#

k so i made the server listen on 5000

#

when i hit test nothing shows on the page

#

btw token is there

inner venture
#

on what page

#

the bot page?

#

or the console

misty geode
#

bot page

inner venture
#

a little popup window is suppoed to appear

#

wouldnt be surprised if its getting lbocked

misty geode
#

iblocked? you mean ipblocked?

inner venture
#

blocked

#

as in

#

the popup was getting blocked

misty geode
#

o

inner venture
#

but seriously man

#

glitch routes port 80 to whatever port is in the PORT environment variable

#

that value should be 3000

misty geode
#

port environment is 3000

#

i changed it too 5000

inner venture
#

Changing it doesnt do anything

#

It's just glitch letting you knwo what port you should be listening on

misty geode
#

so i should try 80?

inner venture
#

No

misty geode
#

anyways i might just use my shit

inner venture
#

glitch takes incoming requests on port 80 and routes them to port 3000

misty geode
#

ye

inner venture
#

So youd need to listen on port 3000 but glitch is dumb anyways

misty geode
#

yea

#

what you use?

inner venture
#

For webhooks?

misty geode
#

yes

inner venture
#

Since I use firebase for my bot, I use firebase functions

#

but thats a bit complex

misty geode
#

ah i can use localhost to no?

inner venture
#

huh?

misty geode
#

host my app on my server

inner venture
#

well yeah

misty geode
#

@sturdy scaffold probly could help me

#

on what he did

sturdy scaffold
#

wok

misty geode
#

can you send what you used

#

trying the same stuff you doing

#

and also using glitch

sturdy scaffold
#

i changed my bots token now it doesnt work

steady pilot
#

Rip

#

What's ur bot 7uh

sturdy scaffold
#
const DBL = require('dblapi.js');
const server = http.createServer(app);
const dbl = new DBL('token', { webhookServer: server });

dbl.webhook.on('ready', async hook => {
    console.log(`on`)
})

dbl.webhook.on('vote', async vote => {
  console.log('test')
    const user = bot.users.get(vote.user)

    const votes = await db.fetch(`votes_${user.id}`)
    if (votes === null) db.set(`votes_${user.id}`, 0)
    db.add(`votes_${user.id}`, 1)
    const voters = await db.fetch(`votes_${user.id}`)
    
    const voted = new Discord.RichEmbed()
        .setColor(color)
        .setAuthor(user.tag, user.avatarURL)
        .setFooter(`User has voted ${voters} time(s)`)
    bot.channels.get('472190839477633034').send(voted);

});

app.get('/', async (req, res) => {
    res.sendStatus(200);
});

server.listen(5000, async () => {
    console.log('Listening');
});``` 
i changed my bots token now it doesnt work
help pls ty
misty geode
loud gulch
#

@sturdy scaffold use the new token..?

sturdy scaffold
#

i have

loud gulch
sturdy scaffold
#

this api is ๐Ÿ’ฉ

loud gulch
#

sometimes

sturdy scaffold
#

all the time

loud gulch
#

did you put a auth

sturdy scaffold
#

no

loud gulch
#

do so

sturdy scaffold
#

k

#

still doesnt work

loud gulch
#

did you put auth just on the website

sturdy scaffold
#

no

misty geode
#

i think its api

#

its works sometime

#

k i got it working

#

i used the same code as you

#

your token is wrong

sturdy scaffold
#

@misty geode could you send your code?

misty geode
#

i used your

#

lol

#

but api is fucked

#

work here and there

inner venture
#

Why does it seem to work for everyone except you two

misty geode
#

it works

#

but

#

like

#

idk

#

it work here and there

sturdy scaffold
#

^

misty geode
#

if i do test it works on glitch but then it wont work on my server

#

localhost:5000

sturdy scaffold
#

@inner venture fix it for me pls

loud gulch
#

@misty geode did you put the port

misty geode
#

yes

loud gulch
#

on the edit page

#

for your bot

misty geode
#

no

loud gulch
#

well put it GWqlabsSweats

misty geode
#

but why does it work without it on glitch

#

??

#

anyways ill do it

inner venture
#

because glitch is garbage man

#

we've been over this

sturdy scaffold
#

API is garbage

#

whats this?

#

how do i do it?

inner venture
#

Just because you dont understand it doesnt mean its garbage

loud gulch
#

your saying the api is trash because you dont understand it GWqlabsSigh

inner venture
#

what you screenshotted is standard stuff

sturdy scaffold
#

what do i do?

inner venture
#

Use one of the API libs man

loud gulch
#

dblapi.js

sturdy scaffold
#

i am

misty geode
#

can i use localhost as url?

sturdy scaffold
#

how do i authorise my bot?

#

/ me

misty geode
#

??

inner venture
#

no thats not how that works rev

misty geode
#

kk

#

i will need to port forward then

inner venture
#

localhost would make it call DBL's own servers

loud gulch
#

ok look

misty geode
#

yea ill port forward it

loud gulch
#

yes

#

also mask your ip

misty geode
#

yup

loud gulch
#

or something like that

misty geode
#

ill test it right now

sturdy scaffold
#

'Authentication is performed with the Authorization HTTP header in the format Authorization: TOKEN'

#

how do i authorise?

uncut crystal
#

with the Authorization HTTP header in the format Authorization: TOKEN

sturdy scaffold
#

helpful

uncut crystal
#

well that literally tells you how to authorize

sturdy scaffold
#

dont use big words

surreal junco
#

Use google to understand big words

loud gulch
#

big words?

uncut crystal
#

which word is too big for you, literally?

steady pilot
#

literally

sturdy scaffold
#

Authorization HTTP header whats this?

uncut crystal
#

getting offtopic, anyhow, just google what http headers are

inner venture
#

An HTTP header with the name Authorization

uncut crystal
#

the library you're making the request with lets you set headers

sturdy scaffold
#

do i have to authorise ?

uncut crystal
#

Yes

sturdy scaffold
misty geode
#

k i successfully port forwarded

sturdy scaffold
#

?

misty geode
#

its a header

sturdy scaffold
#

whats a header?

uncut crystal
#

a fairly googleable term

sturdy scaffold
#

doesnt say an example

#

can i have an example?

misty geode
#

understand it like what it means

inner venture
#

we're not here to teach you basic http concepts

nimble steeple
#

oof

#

you should know this no offense

sturdy scaffold
#

sorry im not on my computer 24/7

nimble steeple
#

Neither am I

sturdy scaffold
#

thats what they all say

nimble steeple
#

In information technology, header refers to supplemental data placed at the beginning of a block of data being stored or transmitted. In data transmission, the data following the header are sometimes called the payload or body.
It is vital that header composition follows a cl...

#

there

#

Listen I learned this when I was 11 yrs old

#

It is ok

#

i can hel

#

p

#

help

#

dm me

sturdy scaffold
steady charm
#

He said search a header, it will tell you

sturdy scaffold
#

where do i put this 'header'

#

in my code?

steady charm
#

obviously

sturdy scaffold
#
    webhookAuth: 'anchor',
    webhookServer: server
});``` is it this?
#

where in my code?

inner venture
#

I don't know why you'r even worried about this, considering that the library youre using handles this for you

sturdy scaffold
#

then why isnt my thing working?

#

changed my token now it doesnt work ๐Ÿ‘

#

sick

misty geode
#

i used same code as yours

#

it works

#

ss your site edit page

#

and code

#

ill help u

#

also send ur token for testing then change it

#

i can try to run ur token to see if it works

sturdy scaffold
#

ok

misty geode
#

send request

sturdy scaffold
#

kk

#

done

misty geode
#

remove anchor

#

from site

sturdy scaffold
#

ok

#

wait

#

wdym request?

#

friend request?

misty geode
#

k send the url you using

#

on the edit page

sturdy scaffold
#

ok

misty geode
#

k now remove the auth

#

keep it blank

sturdy scaffold
#

i have

misty geode
#

and hit test

#

k hit the test

sturdy scaffold
#

done

misty geode
#

k your token is fucked

#

regen and send

sturdy scaffold
#

ok

misty geode
#

hit test

sturdy scaffold
#

k

#

done

misty geode
#

nothing

#

k idk

#

no idea why its not working

#

works for me

sturdy scaffold
#

defo the API

inner venture
#

You guys realize the token isn't related to the webhook auth right?

misty geode
#

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

sturdy scaffold
#

what?

inner venture
#

The tokens you were pasting in chat before

sturdy scaffold
#

yh

#

is my bot token

inner venture
#

Those arent related to webhooks

sturdy scaffold
#

const dbl = new DBL('i put the token here', { webhookServer: server });

inner venture
#

Did you set anything for webhookAuth?

sturdy scaffold
#

no

inner venture
#

Did you set something for the webhook auth on the site?

sturdy scaffold
#

no

inner venture
#

Can you try doing that?

sturdy scaffold
#

i dont know how to do it for the webhook

#

i can do the site

inner venture
#

in this box

#

put something

#

anything

#

and then put that EXACT same thing

#

under the webhookAuth field

sturdy scaffold
#

k

inner venture
misty geode
inner venture
#

like shown here

misty geode
#

would this work?

sturdy scaffold
#

done

#
    webhookServer: server,
    webhookAuth: 'password'
});```
#

still doesnt work

#

my token doesnt work

loud gulch
#

remove /dblwebhook

sturdy scaffold
#

doesnt work

arctic arch
#

why remove the path which is a part of it

sturdy scaffold
#

do you know what you are doing @arctic arch ?

loud gulch
#

last time it wasnt

#

also yes

sturdy scaffold
#

like can you make my shit work?

arctic arch
sturdy scaffold
#

yes

arctic arch
#

thats a working setup

loud gulch
#

heh

sturdy scaffold
#

im using express

arctic arch
sturdy scaffold
#

what do i put here app.get('/', (req, res) => { // ... });

arctic arch
#

whatever you want

misty geode
#

res.whatever

sturdy scaffold
#

k

arctic arch
sturdy scaffold
#

holy fuck

#

ty sm

#

โค

#

it works

#
//     response.sendStatus(200);
// });
// app.listen(process.env.PORT);
// setInterval(() => {
//     http.get(`http://${process.env.PROJECT_DOMAIN}.glitch.me/`);
// }, 280000);``` had to remove this tho
arctic arch
#

your problem was EADDRINUSE?

sturdy scaffold
#

i didnt get an error

#
``` should i remove this line?
misty geode
#

yes

#

you have it defined

#

already at the bottom

#

5000

#

or what ever it was

sturdy scaffold
#

ok

#

ty all

#

โค

arctic arch
#

I updated plum-town with that code

sturdy scaffold
#

ok thanks

misty geode
#

Tonkku

#

is it possible to do it with my ip?

#

i portforward it

sturdy scaffold
#

cheers โค

arctic arch
#

yes

misty geode
#

im doing it somehow its not working but if i do glitch domain it works

#

๐Ÿค”

arctic arch
#

sounds like port being closed to me

misty geode
#

my friend can access the site tho

#

with my ip

#

and port

arctic arch
#

is your url correct

misty geode
arctic arch
#

/dblwebhook?

misty geode
#

yes

#

that included

#

i can send u my ip for testing

#

but not here

#

xD

#

OKAYYY

#

it took some time

#

but it worked

#

yess

#

idk what was wrong i used the same damn code

#

LOL

#

anyways thx

#

Uhm the getVotes() function gets your bot votes right?

loud gulch
#

yes

misty geode
#

hum

#

im doing it i get 100 results

sturdy scaffold
#

same

misty geode
#

but i have only 32 votes

#

i guess its 24h votes

#

yup its 1000 recent from all bots

#

not your bot

#

๐Ÿ˜ฆ

inner venture
#

what

misty geode
#

yup

inner venture
#

do you have any proof

misty geode
#
dbl.getVotes().then(votes => {
  console.log(votes)
});
#

gets all the bots hosted recent 1000

#

not my bot list

#

i thought that command gets "your" bot vote list

inner venture
#

it does

steady pilot
#

Wat

misty geode
#

So lost where is that

inner venture
misty geode
#

Not even gonna say anything

inner venture
#

๐Ÿค”

misty geode
#

Thya shit wasn't there for me

inner venture
#

That endpoint shouldnt even be used, really

#

there are way better options

arctic arch
#

id-less endpoint is broke rn

inner venture
#

oh?

#

id-less endpoint?

arctic arch
#

like

#

you know how the id is optional

inner venture
#

wait wtf

#

how are you supposed to make that optional hahha

arctic arch
#

token

inner venture
#

๐Ÿค”

arctic arch
#

:smartguypointingatbrain:

inner venture
#

uh

#

Im just confused at this point

misty geode
#

Same

#

Lol

inner venture
#

lmao

arctic arch
#

/api/bots/:id/votes
/api/bots/votes

#

id can be figured out from token

#

boom

inner venture
#

ohhh

#

right

misty geode
#

O

#

K makes sense

#

Token should be prioritized by default

inner venture
#

Honestly

#

i dunno

misty geode
#

Have to get kids gets confusing

#

Having*

#

Ids*

#

Lol

#

Hahahahah

#

What did I just say

#

Have to get kids gets confusing

#

Fucking phone auto correct these days

#

This is broken btw

#

It doesn't get your bot votes

#

Its get all of the recent votes people have done

arctic arch
#

the lib uses the id-less endpoint

#

which bork

misty geode
#

Ye

#

I'll try that later

#

I rage shutdown my pc

arctic arch
#

did you rage because it wasn't working

misty geode
#

That and cause I have to go to my university

inner venture
#

angrily presses power button

misty geode
#

Have the votes locally stored

#

Would be a good thing

#

Would extend the 1000 limit

inner venture
#

or just use

#

the hasVoted endpoint

misty geode
#

Hasvote is 24h only

#

Having lifetime would be better to save ids that have voted

#

Then load them for ref

#

But its useless tbh

#

So 1000 is good I guess

inner venture
#

personally, i just store it like this

misty geode
#

Yes that's what I mean

#

Locally store them or database

inner venture
#

through the webhook ^^

misty geode
#

Yup

#

Does the webhook provide time

#

Of the vote

inner venture
#

no

shut ibex
#

no

inner venture
#

I just use current time

misty geode
#

:(

#

Ye

inner venture
#

It cant be that far off

#

considering that the webhooks dont try

misty geode
#

Yea maybe 5sec

inner venture
#

(i dont think)

misty geode
#

Woahhh

inner venture
#

retry i meant

#

sorry

#

also

#

it doesnt really matter

shut ibex
#

its can take a couple seconds due to caching

misty geode
#

๐Ÿ‘€

inner venture
#

its not like super important that you get second accuracy

shut ibex
#

yeah

misty geode
#

Lol

inner venture
#

worst case scenario, someone gets their vote priveledges a second late

shut ibex
#

but i think there is a request on git for adding the timestamp

inner venture
#

the timestamp would dev be needed if dbl added retries

shut ibex
#

ye

misty geode
#

so i use that

#

?

#

right

loud gulch
#

read the api docs

misty geode
#

yea i understand it

#

just im not use to api

pearl mauve
#

how do i get votes from the api? I am new to bot making so im really confused

amber dune
#

@pearl mauve what language

pearl mauve
#

@amber dune java.

#

JavaScript*

amber dune
inner venture
toxic acorn
#

i got this

bot.on('ready', () => {
    setInterval(() => {
        dbl.postStats(bot.guilds.size);
    }, 1800000);
});
#

and when the timer is over it kills my bot

inner venture
#

If you supply your client to the builder of the dbl API, it'll handle posting it for you

ripe linden
#

how can i see how many votes my bot has through the API?

plain timber
#

@ripe linden https://discordbots.org/api/bots/ID then check the points (for all votes) or monthlyPoints (for votes in month) fields

#

@toxic acorn try catching the error

toxic acorn
#

i just removed the interval

#

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

ebon fog
steady pilot
#

And what's the problem

gray dove
#

Coz u know when I edit my bot it doesnt accept the discord channel webhooks. It wants bot's. So im oretty confiused

arctic arch
#

yeah you need to host a web server that can receive those webhooks in your bot

gray dove
#

I have a server where I can host anything np about that. But how do I use it?

arctic arch
#

what kind of server

gray dove
#

VPS

arctic arch
#

perfect

#

now, what language have you written your bot in?

gray dove
#

๐Ÿ˜ƒ

arctic arch
gray dove
#

Okay thanks man. Much appreciate. Alternatively is there a way I can get my total vote count through my bot.

#

Or or or fire an event when the bot is voted

arctic arch
gray dove
#

coz i try this DiscordBotListHandler.GetVotersAsync(30)).Count

arctic arch
#

and the webhooks are what you need for an event when someone votes

gray dove
#

But it gives the total ppl who voted count and not the total vote count (coz of double voting)

#

Also whats the difference "monthlyPoints":338,"points":347,. Sorry for question bombing

arctic arch
#

points = total
monthlyPoints = this month

gray dove
#

Oooooooo

#

Nice

#

ty very very very much

#

๐Ÿ‘

#

never knew they were different

#

Should GetVotersAsync(30) not give the monthlyPoints ๐Ÿค”

#

Why are they different?

arctic arch
#

is that 30 a days parameter

gray dove
#

I think yes

#

it wants int? days

arctic arch
#

that was removed

gray dove
#

Hmmm. Nuget updated? ๐Ÿ˜•

arctic arch
#

it's now the last 1000 votes

#

there should be an update

gray dove
#

Im on nuget version 1.1.0

#

So now I assume Points = GetVotersAsync().Count?

arctic arch
#

not necessarely

gray dove
#

๐Ÿ˜•

#

my bot has 400 votes

#

< 1000

rigid dagger
#

that has nothing to do with our api?

restive otter
#

I have a problem with the account signed in for discord bots. The other day I went on my alternate account, Dj Synths, to something for a server that my main account (this one) wasnt on. I never went on discord bots. I go on discord bots today and its signed in on Dj Synths instead of this account. How do you switch accounts for discord bots?
(Sorry for long paragraph. Hopefully I dont get in trouble for it)

arctic arch
#

also not api related

restive otter
#

O

#

Sorry

tardy mauve
uncut crystal
#

user profiles are due for a rewrite

tardy mauve
#

how would i get when a user has voted. What Date and Time till they can vote again

humble bison
#

idk if the api even gives that info

tardy mauve
#

it should

honest root
#

@tardy mauve API does not return when the user has voted. Only true or false. If you need this info you will have to use webhook

rotund pumice
#

hi can i know how to get a webhook url for DBL vote

rotund pumice
#

<@&304313580025544704> can i know how to get a webhook url for DBL vote

rigid dagger
#

jfc

#

you dont have to ping every mod

rotund pumice
#

well no one respond

rigid dagger
#

then wait some more?

surreal junco
#

Is it hard to be patient?

rotund pumice
#

๐Ÿ˜ข

#

yep

surreal junco
#

The ones that know will answer when they have time, mentioning the moderators is not only pointless but annoying

junior goblet
#

@rotund pumice its on your bot page

#

scroll down

#

oh muted JUSTLOL

misty geode
#

You can make your own timer count down from the time the user has voted

plain timber
#

are webhooks broken?

restive otter
#

How do you use the API to tell when someone has upvoted for your bot?

mystic wing
#

You can (assuming d.js) put the post link in your onguildcreate event

#

or you can just have an interval for every ~30 minutes (less api spammy)

plain timber
#

@restive otter with dblapi.js, dbl.hasVoted('userid')

#

read docs pls

restive otter
#

...

#

I had

#

i just don't understand what the webhook thing is

plain timber
#

you dont need to use the webhooks

light crag
#

Webhooks are POST requests to a website endpoint.

candid knot
#

Is there a event that happens every time a user upvotes?
Cause i would like to do something every time a user upvotes on discordbots.org on a specific bot
Python

inner venture
#

@candid knot You can accomplish that through webhooks ^^

candid knot
#

So that JSlib you told me to install would work on python?

#

And i use Aiohttp, can you give me a example on how to do something every time a user upvotes with Aiohttp?

#

@inner venture

inner venture
#

wha

#

a js lib wouldnt wokr with python friend

candid knot
#

You did ^^ so i assumed you were talking about that link

#

And yeah, i thought so. i got confused

inner venture
#

the JS lib has support for DBL's webhooks

#

but i was referring to DBL's webhook system in general

#

I dont believe the python lib has support for them rn

#

so you'd have to implement it on your side

candid knot
#

What do you mean by that, implementing it into DBL for python?

#

Or are you saying just doing it another way

inner venture
#

Im saying

#

the python dbl lib

#

doesnt have an easy function where you can just say

#

whenever i get a vote, do {this}

#

you have to manually handle setting up a webserver to receive the post requests that DBL will send yuo

candid knot
#

Ah

honest root
misty geode
misty geode
#

does the api when user votes. Does it return users pfp image, id, and so on?

#

using the webhook?

light crag
#

Returns the user id

misty geode
#

so im guessing i can prob check bots all votes then compare that id?

#

and get the data from there

light crag
#

Just check the guilds for a user with the id. If they aren't in any of the guilds then maybe do that. However using the bot votes endpoint isn't a good idea.

misty geode
#

but its in array

#

i can check recent array

#

eg array[0]

light crag
#

?

misty geode
#

like how is it bad?

#

to not check from the votes

light crag
#

Once you reach 1000 votes it doesn't work anymore.

misty geode
#

o

#

im trying to get the users, username and avatar

#

i only have user id

light crag
#

Yes. Loop through the guilds checking if the member property contains the user id. Then get that GuildMember object and the user property should have it.

misty geode
#

yes

#

how about the GET /users/{id}

#

will that also not work after 1000?

light crag
#

Could also do that.

misty geode
#

yea thats easy

#

LOl

#

aii thx

light crag
#

๐Ÿ‘

misty geode
#

so im guessing users who vote gets saved to the site db hence why i cant search random person not associated with the site?

light crag
#

Oh you are using DBL API. I recommend using Discord's user endpoint.

misty geode
#

Ah

#

kinda useless to do that. i only want users who voted id

#

then get there info

#

but yea

#

i might do it with discord api

light crag
misty geode
#

okay

#

how do i request it in json

#

๐Ÿค”

humble bison
#

It gives you JSON by default lol

misty geode
#

it takes me to profile

humble bison
#

@light crag, it's much better to just get the user from your bot so your not ratelimited by the API.

#

even the people in the DAPI server suggested that to me.

misty geode
#

https://discordapp.com/users/{id}

#

is this right?

humble bison
#

no lmao

misty geode
humble bison
#

GET https://discordapp.com/api/v6/users/296044953576931328

misty geode
#

thx

humble bison
#

as an example

#

np

#

This isn't the right channel for this anyways, so move to #development to continue.

misty geode
#

i assumed that as discordbots does that

#

xD

#

yea my bad it got side tracked to here

#

but it was originally api related

humble bison
#

All good :D

misty geode
#

lit

#

thx all

humble bison
#

np

#

wait did you need auth for that?

#

๐Ÿ‘€

light crag
#

@humble bison I suggested that before the endpoint.

restive otter
#
const DBL = require('dblapi.js');
const express = require('express');
const http = require('http');

const app = express();
const server = http.createServer(app);
const dbl = new DBL(yourDBLTokenHere, { webhookAuth: 'password', 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('/', (req, res) => {
  // ...
});

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

this code doesnt work for me

#

my friend voted and nothing came up on logs

light crag
#

Where are you hosting?

restive otter
#

glitch

restive otter
#

anyone

#

?

misty geode
#

screenshot your edit page

#

for webhook

#

k test button is working

#

but actual vote is not working

#

anyone can help?

restive otter
#

yea

#

i need help

#

too

misty geode
#

test works fine

#

just the real one dont work

restive otter
#

hm

#

instead

#

of console.log

#

u just made it into embed

#

?

misty geode
#

yes

restive otter
#

nice

#

vote.user

#

is id?

misty geode
#

yes

restive otter
#

aight

#

how u get username

#

then

#

vote.username

#

?

misty geode
#

i used discord api then search userid

restive otter
#

oh

misty geode
#

then used the data from there to build embed

restive otter
#

ah

misty geode
#

rip no one gona help

#

๐Ÿ˜ฆ

restive otter
#

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

client.channels.get("466595482425229322").send(`<@${vote.user}> Has Just Voted !")

#

that does not work

#

..

#

is there anything wrong with it?

misty geode
#

he user must me in your discord

#

not really but

#

it wont give a proper mention

#

also whats the error?

restive otter
#

no error

#

just does not send

#

anything

#

he is in

#

my friend

#

lol

misty geode
#
.send(`<@${vote.user}> Has Just Voted !")` should be `.send('<@' + `${vote.user}` + "> Has Just Voted !")
restive otter
#

ill try

#

```client.channels.get("466595482425229322").send('<@' + ${vote.user} + >Has Just Voted ! \n Rewards : Role : **Voter** \n Currency : **20,000** Coins!).then(() => message.guild.member(vote.user).addRole("Voter"))

#

i made that

misty geode
#

test the webhook

#

using there test function

restive otter
#

Webhook running with path /dblwebhook

Listening