#topgg-api

1 messages Β· Page 75 of 1

true talon
#

Well gh

#

Gg

vapid cape
#

check the log, there were two votes with 2 different ids

#

in your glitch log

restive otter
#

No 1x bro

#

look

molten locust
#

no wait, if someone voted through the proper vote link on top.gg it will show their user id

vapid cape
restive otter
#

oh

#

thx lel

molten locust
#

what is glitch, some kinda cheapo vps?

#

im amused that you can just edit files directly on their site πŸ˜„

restive otter
#

free website

#

it's suck

vapid cape
#

yeah is a small pseudo-vps

restive otter
#

i will use soon repl.it

vapid cape
#

its not really a vps, its like a managed project

molten locust
#

ive been using digital ocean so far without issue. few people here recommend contabo too

vapid cape
#

like google's app engine

molten locust
#

ahhhh

#

so just a small container really

vapid cape
#

yeah

restive otter
#

@restive otter is gay

molten locust
#

#savage

restive otter
#

${vote.user} gives id

molten locust
restive otter
#

how to find the name of the voter

#

Tim

vapid cape
#

get it from the client

restive otter
#

client.users.get(vote.user).username

vapid cape
#

yes

restive otter
#

ty

molten locust
#

so im seeing this unhandled rejection error i hadnt previously

#

i suspect its from guilds kicking my bot then him trying to send a spawn to the server (that hes no longer in)

#

missing access - thats for sure my bot been kicked right?

vapid cape
#

can be invisible/deleted channel

molten locust
#

oohhh yea good call

#

have to add handlers for both situations πŸ˜„

pale fulcrum
#

how exactly does one do that?

molten locust
#

do?

vapid cape
#

do what?

pale fulcrum
#

Make the handler for invisible channels

rocky bough
#

catch

jolly solar
true talon
#

Missing access

#

Hmm

jolly solar
#

What do I have to do? @true talon

true talon
#

And idk, I don't know d.py

jolly solar
#

np

vapid cape
#

im pretty sure that is not your dbl token

jolly solar
#

GWliliumFacepalmSeola i'm stuppid

#

I have to wait 30 minutes for the server count to update, is that right?

sullen nymph
#

It posts when the code starts

#

and from then on every 30 seconds

jolly solar
#

tks

sullen nymph
#

What's your DBLClient looking like

#

I can't open pastebin

jolly solar
#

the script ?

sullen nymph
#

In the code yeah

jolly solar
sullen nymph
#

is that a separate extension you're loading in main file

jolly solar
#

yes

sullen nymph
#

I thought you had to add the cogs inside a setup method

jolly solar
#

same file

sullen nymph
#

Wha...

#

Could you hastebin all of your code

jolly solar
#

yes sure

sullen nymph
#

Try to use the on_guild_post event in the class

sullen fox
#
const dblTwo = new DBL("dbl token", { webhookPort: 5000, webhookAuth: 'password' });

dblTwo.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dblTwo.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});
#

this isnt logging anything

vapid cape
#

where is your bot hosted? what did you put in the top.gg edit page?

molten locust
#

wth is hastebin? πŸ˜„

#

just an online text editor?

#

so its not actually like pastebin then? πŸ˜„

vapid cape
#

they are all similar to each other

molten locust
#

oh, yea lol πŸ˜„

#

my bad πŸ˜„

sullen fox
molten locust
#

your bots in more servers than mine πŸ’”

#

but mines is 1 higher on the trending bots section of homepage ❀️

vapid cape
#

@sullen fox in the top.gg edit page, the URL and Authorization field, under webhooks

#

what did you put there?

sullen fox
#

Website URL? nothing

#

oh the webhook URL? yeah there's nothign there

#

same with Authorization

sullen nymph
#

hm yes, sending requests into the abyss

sullen fox
#
const dblTwo = new DBL(my token, { webhookPort: 5000, webhookAuth: 'password' });
molten locust
#

you need to fill those out to point to the location of your bot

sullen fox
#

is 'password' supposed to be whatever i put in authorization?

molten locust
#

which will mean your bot need to be hosted somewhere with a public facing ip

sullen fox
#

i host it on aws

sullen nymph
#

is 'password' supposed to be whatever i put in authorization?
@sullen fox yes

molten locust
#

and yea password is whatever you want for authorization

sullen fox
#

what do i put in URL?

molten locust
#

i googled for random authorrization token generator and just made a random alphanumerical string

#

do you havea url for you bot?

#

if not, get one

sullen fox
#

wdym

molten locust
#

well, in order for your bot to recieve a webhook notification, your going to need to have your bot setup on some host thats always online, with a means of contacting it

#

else how would top gg know where to send the hook notification to

sullen fox
#

aws

molten locust
#

ip:port should be fine

#

so like, 192.168.0.1:80

#

or w.e ~ as long as it matches where your bot is running

sullen fox
#
Public DNS (IPv4): -
IPv4 Public IP: -
#

this is on aws

molten locust
#

yea your ipv4 is fine

sullen fox
#

ok lets say im running my bot locally because im coding a new command or something and dont want 2 instances running

#

what would i change the ip to

molten locust
#

why would you want to send a webhook to your local machine?

#

you would need to configure port forwarding for you router

#

and supply your own public facing ipv4:port

#

but tbh, you shouldnt be processing web hooks in dev mode

sullen fox
#

ok i filled out the URL and Authorization

molten locust
#

i just do a simple check for a configuration variable that defines dev mode

sullen fox
#

url has my ipv4 f my host

molten locust
#

and then dont process webhooks unless in production

#

his save and test

sullen fox
#

and authorization has the password

molten locust
#

and check your aws logs to see if its processed

sullen fox
#

problem: i have to wait until i can vote for it

molten locust
#

test: avoids waiting

#

i voted 102 times earlier within around an hour of testing πŸ˜„

#

none of them count as actual votes ofc

sullen fox
#

how?

molten locust
sullen fox
#

thanks

molten locust
#

np. wasnt sure my arrow was big or red enough πŸ˜„

sullen fox
#

lol

#

wait my url is just an IP

#

yours is an actual URL

sullen nymph
#

An IP is still an URL

#

It's just that they have a domain

sullen fox
#
dblTwo.webhook.on('vote', vote => {
    console.log('Someone voted.')

    const logGuild = client.guilds.get(`id`);
    const errorLog = logGuild.channels.get('id')
    const voteLogs = logGuild.channels.get('id')

    voteLogs.send(`${vote.user} just voted!`)

});
``` both the console and voteLogs.send arent working
fleet knoll
#

Umm don't you need to provide an actual ID?

#

I mean I could be wrong but πŸ€·πŸ»β€β™‚οΈ

sullen nymph
#

Placeholders

fleet knoll
#

Oh true lol πŸ€¦πŸ»β€β™‚οΈ

vapid cape
#

if it doesnt work either your url/authorization is wrong, or your server is not accessible (ie: firewall/closed ports)

molten locust
#

yea, ^ that

#

and my domain simply forwards to an ip address via a dns

#

like all urls do πŸ˜„

vapid cape
#

do you have a reverse proxy running?

#

if not, it should be xx.xx.xx.xx:3000/dblwebhook

vapid cape
#

did you put the port in the url?

#

either ip is wrong, or authentication is wrong, or contabo requires ports to be opened in their admin panel

night veldt
#

guys is this where u get the code

restive otter
#

lol

#

what code

limpid vector
#

Still can't get the voting to work

visual moss
#

can I get a notification from the API whenever votes reset?

#

is there a webhook.on() event for that?

spiral steeple
#

They reset on the first of every month at 12 AM UTC

#

It'd probably hurt the server to mass send requests to every running webhook at once to add a notification for them

balmy hamlet
#

@night veldt what code?

floral phoenix
#

Has anyone got any idea why im getthign this error

Exception in thread "main" java.lang.NullPointerException```
Im using this code
```java
        DiscordBotListAPI api = new DiscordBotListAPI.Builder()
        .token("MyToken")
        .botId("MyBOTID")
        .build();
        api.setStats(jda.getGuilds().size());```
hollow sandal
#

I do the following in my code to get when the bot is voted, do I need to set the webhook url also in the bot's page on DBL?

bot.dbl_client = dbl.DBLClient(bot, bot.dbl_token, webhook_port=5000)

@bot.event
async def on_dbl_vote(data):
    uid = data["user"]
    print("Vote received")
    await increment_ticket(bot, uid)
sullen nymph
#

Yes

harsh stream
#

@night veldt what code?

fallen basin
coarse haven
#

@fallen basin can u send a clearer pic

fallen basin
sullen nymph
#

Output body

fallen basin
#

Output body
@sullen nymph ?

sullen nymph
#

console.log the body

fallen basin
sullen nymph
#

So req.body.user can't be used

fallen basin
#

but the Funny is on @restive otter it is working

#

and what else do i need instead of req.body?

sullen nymph
#

Make sure your brackets, parentheses etc are in correct places

fallen basin
#

?

#

Help i dont undestand anything

hollow sandal
#

Yes
@sullen nymph then what url do I put on my discord bot's DBL page?

sullen nymph
#

http://<ip>:<port>/<webhookPath>

#

Since you are not overwriting the default value for webhook_path, it's /dblwebhook, so http://your_ip>:5000/dblwebhook

vapid cape
#

@fallen basin are you using express?

#

if so, you need to use the body-parser addon/middleware

fallen basin
#

okay thx i'll try it

#

@vapid cape

vapid cape
#

read the link i sent

restive otter
#

How do you have to install that?

#

in the code

#

@vapid cape πŸ‘†

coarse haven
#

@restive otter install what

fallen basin
#

use*

restive otter
#

body parser

fallen basin
#

How to use that

vapid cape
#

i literally posted the link that explains it?

#

and even has examples at the end?

coarse haven
#

Tim has a status which looks like a furry text

fallen basin
#

he Finshed it

floral phoenix
#

I have set this up in my JDA main class

DiscordBotListAPI api = new DiscordBotListAPI.Builder()
    .token("token")
    .botId("botId")
    .build();``` with my token and bot ID but it still says NA for the amount of servers
restive otter
#

what's with the API and being like 1 minute late after a vote?

#

hasVoted() returns false until like a minute after a user has voted

restive otter
#

How do I get the votes for my bot and then send it to a channel

hollow raptor
willow spindle
#

use dbl webhook

true talon
#

nothing in the console

#

dont tell me dbl.on things are useless

#

and that I have to do .then in the setInterval

vapid cape
#

did you try placing postStats outside of the interval?

visual moss
#

They reset on the first of every month at 12 AM UTC
@spiral steeple

Thanks. What would be the best way to code this in if I wanted to automate resetting the vote counter? Time calculations are always messy

#

Am familiar with momentjs

#

checking for if the date is 12am UTC every second would be pretty intensive...

spiral steeple
#

I would use a cronjob

vapid cape
#

setTimeout

visual moss
#

but I would have to specify the time each month for the cron job?

and re setTimeout, calculating the timeout is the messy part

#

taking into account leap days like for last month, how many days in a month to times 86000 by, etc

spiral steeple
#

You can set a cron job to run every month on the first at 12 am

visual moss
spiral steeple
visual moss
#

found a package for it

#

also that

#

thats better actually

#

Thanks

spiral steeple
#

That's just to check what it is

#

helps with scheduling cron jobs

visual moss
#

Gotcha

spiral steeple
vapid cape
#

time left for the next 1st day of the month midnight utc in milliseconds

visual moss
#

also thanks

#

will check out

dense compass
#

Don't think so?

#

I've never messed around with webhooks before so I'm not entirely the correct person to talk to about them

restive otter
#

my 3rd time asking here, how long does it usually take for votes to update for the api?

bleak ledge
#

Anyway to test the api before your bot is approved
like an in-place java spoof library?

restive otter
#

And you got a reply bash

bleak ledge
#

Is there a spoof lib?

#

for java

#

To test dbl api before submitting

restive otter
#

I don’t see it in the docs

#

So I doubt it

#

Unless I’m blind. I’m barely awake.

bleak ledge
#

Ok, thank you

#

I guess I'll write an implementation and cross my fingers

elfin maple
restive otter
#

@elfin maple my thing you code is broken re code

restive otter
#

Hi, can I get some help with the voting system?

#

Je suis franΓ§ais

tawny heron
#

is there support for discord.js?

willow spindle
#

no

tawny heron
#

oh nice

green mantle
#

There is @tawny heron

tawny heron
#

for v12?

green mantle
#

Look at the js docs

tawny heron
#

which was published yesterday?

green mantle
#

Pretty sure people who were using V12 before it was released have been using the Api

#

Tias

tawny heron
#

yeah like me

#

but im getting errors

#

that i asked about earlier and was told that v12/old master is not supported

#
    at IncomingMessage.<anonymous> (/root/Musix/node_modules/dblapi.js/src/index.js:118:25)
    at IncomingMessage.emit (events.js:323:22)
    at endReadableNT (_stream_readable.js:1204:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:26284) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 84)
willow spindle
#

I misunderstood you @tawny heron

vapid cape
#

tonk didnt update yet?

true talon
#

tonk didnt update yet?
@vapid cape no

#

@tawny heron u have to post stats manually

vapid cape
#

im gonna do a PR for tonk then lol

tawny heron
#

well no idea how im supposed to do it manually xd

#

im just gonna wait for an update

vapid cape
#

@arctic arch one question tho, does the api support combining internal sharding with external? like sending {shards:[345,235],shard_count:4} from one process and {shards:[324,345],shard_count:4} from another

#

or you can only do it one-by-one or all-at-once

arctic arch
#

hmm not sure if I implemented it so you can have null for shards that you don't want to update

vapid cape
#

ah interesting

#

also, are you gonna update dblapi.js anytime soon, or should i send you a PR?

arctic arch
#

still thinking I'll wait and see how it goes
I see a lot of devs arent happy about the change

vapid cape
#

well, not hard to make it compatible with both v11 and v12

arctic arch
#

obviously I have to support both

vapid cape
#

you think there's a chance they'll rollback the .cache thing even in v12?

elfin maple
#

@restive otter wtf

arctic arch
#

not sure if they'll revert but some big breaking changes around managers could still be happening

tawny heron
#

personally i dont like the .cache thing

vapid cape
#

well, i dont think it will happen, considering they officially released v12

arctic arch
#

oh I wasn't aware of that

#

that's weird

tawny heron
#

yesterday

vapid cape
#

oh lul, yeah they released it yesterday

arctic arch
#

so quick

vapid cape
#

hence why the pressure to update dblapi

tawny heron
#

it really came as a surprise for me too

arctic arch
#

shoulda just pinged me with "v12 is stable"

vapid cape
#

well, true, didnt think of pinging you lmao

elfin maple
vapid cape
#

the sharding system also changed

#

client.shard.ids = [array]

arctic arch
#

I'm aware

#

but it works

vapid cape
#

oh, alright then

arctic arch
#

the guilds from all shards exist in client.guilds

vapid cape
#

yeah true

arctic arch
#

so the server count is the total server count

#

client.shard.count includes shard count

#

so you get a request with total shard count and total guild count

restive otter
#

dblapi works on discord.js v12?

vapid cape
#

not yet, but should be released soon

restive otter
#

f

arctic arch
#

I don't have the time to test that rn, feel free to review the pr

restive otter
#

Ok

#

how

restive otter
#

@restive otter webhooks

#

ok

neat sierra
#

the api is unresponsive

#

after the Update

#

of discord.js

vapid cape
#

you mean dblapi.js?

neat sierra
#

yes

vapid cape
#

its not updated for v12 yet

neat sierra
#

it's not posting server count

#

oh

#

when it will be

vapid cape
#

probably today or tomorrow

neat sierra
#

ohk

#

did you like the new update?

#

mine is 25%

vapid cape
#

you mean v12?

neat sierra
#

yes

vapid cape
#

i've been using it for like 6 months already

neat sierra
#

oh nice

vapid cape
#

i have my own framework built on top of it

#

anyway, this is offtopic for this channel

neat sierra
#

yea

#

so they change RichEmbed to MessageEmbed

balmy abyss
#

I have a question about the api. I need to get webhooks to get a notification when someone votes for the bot. How can I get the Webhook port and Auth?

green mantle
#

you set it like that

#

you host a webserver essentially

balmy abyss
#

just invent the data

green mantle
#

wut?

balmy abyss
#

invent the port and password?

green mantle
#

you host a webserver essentially

balmy abyss
#

the port of the server where the bot is hosted?

green mantle
#

πŸ€·β€β™‚οΈ

balmy abyss
#

I don't understand

green mantle
#

what ever you are running a webserver on

#

to recieve the webhook

#

you would have the IP and port be for that server

#

the port you set

#

the IP is your public IP normally

#

unless it's being routed through a domain

#

http://theinnkeeper.online:12345/dblwebhook -> what a example url would look like
http://123.456.78.90:12345/dblwebhook -> Example of an IP url

balmy abyss
#

ok thx

#

but I don't think I have any of that

green mantle
#

You have to run a webserver, dbl has a set of libs already made for it

balmy abyss
#

ok

vapid cape
#

@arctic arch so internal sharding is treated as a single shard. but when using the shard manager, shard.id is undefined, so lets say you use the manager to launch 2 shards, and run dblapi on each shard. The bot would make two api requests both containing a server_count:123, shard_id:undefined and shard_total:2, does the api automatically increment a shard id by the order in which the requests come in, and then reset it when shard_total is reached?

#

or would it assume both requests are for shard 0 and overwrite one with the other?

arctic arch
#

it would assume the server_count is the total

#

the old sharding is still a thing with v12?

true talon
#

Some things changed, but most of the things are the same

arctic arch
#

that would make things tricky

true talon
arctic arch
#

would assuming a shard ids array having only one id as being from the manager work

vapid cape
#

yes, when using the manager, most likely shard.ids will always have only 1 value

#

but if you want to venture beyond that, you could do something like dividing total by ids.length and then checking the ids of the shards

arctic arch
#

that's what you think but servers don't evenly distribute between shards

vapid cape
#

no im saying something like this

#

fuck wait i need to think

worn kiln
#

hii, i've just a problem, i don't know what to put in "webhook url" on the website because of i'm using glitch and not a vps

willow spindle
#

your project url/dblwebhook

worn kiln
#

that what i put

willow spindle
vapid cape
#

nvm my method only works if all processes have an equal amount of shards

worn kiln
#

@willow spindle it just show me

#

"Cannot GET /dblwebhook"

willow spindle
#

yo do not need that

elfin maple
worn kiln
#

need what ?

arctic arch
#

I pushed a commit with my possible solution

elfin maple
#

create a server with https (?)

vapid cape
#

i was thinking about something like this

elfin maple
#

I had the same problem a few months ago

vapid cape
#

shard_id = client.shards.ids[0] / client.shards.ids.length

#

to support internal sharding combined with process sharding

worn kiln
#
const otherApp = express()
const server = http.createServer(otherApp)
const dbl = new DBL("dbl token",{ webhookPath:"/dbl",webhookPort:4387,webhookAuth:"psw" })

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 !");
});

otherApp.get('/', (req, res) => {
});

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

here my code to get vote

vapid cape
#

but it only works if all processes have an equal amount of internal shards

worn kiln
#

it doesn't work

willow spindle
#

"Cannot GET /dblwebhook"
@worn kiln this is normal because webhook is not GET, the webhook is POST

worn kiln
#

mmh yes but when I click test on the website, it's doesn't tell me everytihng

elfin maple
#

{ webhookServer: server }

worn kiln
#

lets try

#

when i click test, how do i know if the test work ?

willow spindle
#

check console

worn kiln
#

nothing

#

if i put webhookPort:4387

#

server.listen(5000 or 4837 ?

#

@willow spindle

vapid cape
#

@worn kiln if you have an existing server, you dont use a port

#

specially in glitch, that only gives you one port

#

you should do this instead

#
let listener = server.listen(process.env.PORT, ...)
let dbl = new DBL(token,{webhookServer:listener,webhookAuth:"password"},client) // optional client if you want to enable the auto poster
#

in glitch you should use process.env.PORT as your port

worn kiln
#

oke i try

#

oh my god

#

it work

#

i just take the listener of basic glitch

#

thx u so much 😭 ❀️

floral phoenix
#

I done exacly what it shows on the guthub for java

vapid cape
#

java or javascript?

#

show your code

knotty garnet
#

I done exacly what it shows on the guthub for java
@floral phoenix are you sending a get request to to right endpoint?

#

Also, there's an official DBL library for java

#

It's on their website

floral phoenix
#

And im using Maven

knotty garnet
#

Hm, weird

#

I use that exact library

#

Could you show us a snapshot of the part where you call the method?

floral phoenix
#

Sure

#

I just showed my token but ill reset it

knotty garnet
#

Yay, another intellij user

#

Ah, I see the issue

#

Just a sec, gonna take a print

#

Waitaminute

#

It's correct

#

Is that method being called?

#

Also, are there errors in your log?

floral phoenix
#

There is no errors no thats why im so confused

vapid cape
#

i dont know java, but does that code wait for a ready event? or only initializes stuff?

knotty garnet
#

It setups the proper bot environment

#

Aka an initiator

floral phoenix
#

So have i done it wrong

#

Or xD

knotty garnet
#

Not at all

#

But you might want to run it on debug mode to see why it's not updating

vapid cape
#

because you cant get the guilds before discord sends them to you

#

aka, you have to wait for the ready event before posting

knotty garnet
#

Ah, that could be it

#

Since I call that only during cronjobs i haven't thought about JDA not having enough time to cache the info

vapid cape
#

does jda have a ready event?

knotty garnet
#

Jda has it

#

onReadyEvent

#

However

#

JDA locks the thread until it finishes loading

#

So that a bit weird

#

It was supposed to work

floral phoenix
#

So should i make a onReadyEvent and put that in there ?

vapid cape
#

well, try it

knotty garnet
#

You could also try to put it inside a command

#

See if it works

#

Ah, and btw, you shouldn't create a DBL object each time

floral phoenix
#

Ye not working

knotty garnet
#

Put it on a static variable

#

Hm

#

Weird

#

Do you use slf4j?

floral phoenix
#
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-log4j12</artifactId>
        </exclusion>```
#

That thing

knotty garnet
#

Yep

#

If you used it, I'd say to set it to debug level to get every event that happens on your code

harsh stream
#

@floral phoenix api.setStats(serverCount) returns a CompletionStage that needs to be executed

#

This is how I do it

api.setStats(serverCount).whenComplete((empty, error) -> {
    // log success or error
});

Maybe you could do it another way if you don't want to execute anything after the server count is send

knotty garnet
#

You don't need to continue it

#

The next step is called once it's complete

#

You could add a System.out there to see if it's completing tho

harsh stream
#

ok, I treated it kinda like a Mono/Flux reactor

knotty garnet
#

Cannot indent it properly on discord lol

#

Here's the way I've done it

#

It's basically what you've done

#

But on a cronjob

vapid cape
#

try posting a fixed number to test it

#

like api.setStats(123)

knotty garnet
#

^

restive otter
#

whats your code look like?

Im about to leave for work so i cant help much but thatll pry be needed for others to help πŸ™‚

#

sad

true talon
#

Wait some days til tonkku has published the new version of dblapi.js

neat sierra
#

@restive otter

#

i have the same problem

#

and i have solved it

#

i have change the version number

#

from 12.0.1 to 11.6.1 and it's working properly fine

#

just waiting for dbl to update

restive otter
#

i know

neat sierra
#

Guys i think

#

the discord.js is stable now

silk bluff
#

Yes it is

shy socket
#

JS:

Does this triggeres at every vote or only at a vote for my Bot?

#

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

sullen nymph
#

only a vote for your bot

shy socket
#

Ok thx

neat sierra
#

@arctic arch

#

when you are updating the api

#

?

#

i am waiting for it

#

the discord.js is stable now

green mantle
#

He is aware

neat sierra
#

hmmm

boreal totem
willow spindle
boreal totem
#

I took a look at that but that seems to only do server count and not that message above

true talon
#

Webhook

willow spindle
boreal totem
#

So I need a web hook?

green mantle
#

look at the example and read the docs

#
import discord
from discord.ext import commands, tasks

import asyncio
import logging


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

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

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

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

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

        await asyncio.sleep(1800)

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

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

imma steal this ty

willow spindle
#

lol

spiral steeple
#

And stealing it and not knowing what it does still won't help you.

restive otter
#

i know that. its not hard to see how it works

bleak ledge
#

I gotta find an alternative to pagekite for forwarding for webhooks

small swallow
#

multi threading serenity is hell

topaz verge
#

how can i make if user vote for my bot send to room
user ${message.author.username} vot for me

true talon
#

Webhook

topaz verge
#

and ?

true talon
#

U can read docs

topaz verge
#

okey

true talon
#

There is examples of how to do it

topaz verge
#

okey thanks

#

const dbl = new DBL(yourDBLTokenHere, { webhookAuth: 'password', webhookServer: server });
what's password ?

true talon
#

First, setup the webhook

#

Second, use the webhook password

#

I can't rly help, idk how webhooks works

topaz verge
#

okey np

green mantle
#

You need a webhook set up to get the vote events

#

You then need a system for sending discord webhooks if you want it to display a message

topaz verge
#

okey

silk bluff
#

Hello

#

I wanted to know in which format does the top.gg webhook send data

#

I tried to recive the posted data using multiple ways
I am using express for this purpose
I tried:
express.json()
express.text()
express.urlencoded()
But none of them seem to work for me

#

Sorry I got it.
It works on express.json();
I was not saving my file!

knotty garnet
#

it's always json, really few sites actually use xml for responses, and even those offer a json version of it

spiral steeple
#

Not always. A site I wrote an api handler for a site that only uses xml

vapid cape
#

urlencoded is widely used as well

spiral steeple
#

I wouldnt call it a popular site, but it still is updated regularly.

vapid cape
#

also multi-part data for file uploads

gaunt umbra
#

Hey, the API mentions a "test" vote Button, where can I find it ?

restive otter
#

@gaunt umbra

#

there

gaunt umbra
#

@restive otter thank you

#

😘

spiral steeple
#

Make sure to save before you test

blissful lake
#

Hello there! I was thinking about using DBL's webhook vote feature but for some reason, when I test it from the website, it doesn't send anything in the console.
https://discourse-cloud-file-uploads.s3.dualstack.us-west-2.amazonaws.com/business6/uploads/glitch/original/2X/9/9bbdd0211784ec33c74dde7c67d3d30e28763491.png

const DBL = require("dblapi.js")
const http = require("http")
const express = require("express");
const app = express();
const server = require('http').createServer(app);
const listener = server.listen(process.env.PORT, function() {
  console.log('Deployed successfully!');
});
setInterval(() => {
  http.get(`http://${process.env.PROJECT_DOMAIN}.glitch.me/`);
}, 280000);
  const dbl = new DBL(process.env.DBL, { webhookServer: listener, webhookAuth: process.env.PASS }, bot);
  
  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 ID ${vote.user} has voted!`)
  });

console says: Webhook running at http://0.0.0.0:0/dblwebhook

Also, here's a demo version that I made, that it doesn't include the tokens for security reasons. (for the users who use Glitch.com)
Project: https://glitch.com/edit/#!/dbl-testing

Thanks in advance,
TehPig_YT

#

Everything on the bot's DBL page is set up properly.

blissful lake
#

Notice: Problem has been solved

restive otter
true talon
#

what is ur djs version@blissful lake

blissful lake
#

Please read above before pinging me

restive otter
#

u dont have to be like that he or she just ask a simple question even if the problem is solved

true talon
#

k

restive otter
#

How do I fix 400 Bad Request errors?

#

this is my code

dbl.postStats(client.guilds.cache.size, client.shard.id, client.shard.count);
true talon
#

Discordjs Version?

restive otter
#

12.0.0

#

i mean 12.0.1

true talon
#

How do u define dbl

#

const dbl = new DBL(...)

#

Whats inside the ()

arctic arch
#

but is your bot even sharded

true talon
#

And that tonkku still haven't update dblapi

#

I think

arctic arch
#

I have it's just not released lul

#

you can npm i DiscordBotList/dblapi.js#djs-v12

#

to test it out

restive otter
#

yes my bot is sharded with 2 shards

true talon
#

Well try to update dblapi.js

restive otter
#

alr

arctic arch
#

an update is not needed if you don't add the client in the constructor

#

but if you have added the client in the constructor, why are you posting stats manually?

restive otter
#

wait you can add the client into the constructor?

#

i think i have to blame myself for not reading the docs

arctic arch
#

you can but the version in npm does not support d.js v12 yet

restive otter
#

so it automatically post it if the client is added?

arctic arch
#

yes

restive otter
#

alr then i guess i just have to wait for the new api to be released to npm

arctic arch
#

or you can load up the github version with the command above and test it now

restive otter
#

because npm i DiscordBotList/dblapi.js#djs-v12 β€”save returns an error

arctic arch
#

oh

#

whats the error

restive otter
#

wait lemme retry it to get the error

#

wait it worked this time Β―_(ツ)_/Β―

arctic arch
#

just dont forget to install the npm release when that's out or you'll get errors later lol

restive otter
#

ok thx

willow spindle
#

?

#

your bot didnt approved yet @restive otter

restive otter
#

yes

#

i want to be approved

#

When is it approved

willow spindle
#

wait 2 weeks

#

also this is not api related

restive otter
#

ok

arctic arch
#

dblapi.js v2.4.0 released with discord.js v12 support

willow spindle
#

finally

true talon
willow spindle
true talon
#

one of the twos

restive otter
true talon
#

no

spiral steeple
#

Or people can read commit messages

restive otter
#

Does the webhook test button actually work?

#

Yes!

harsh stream
#

make sure to save before trying to test it

dusty roost
#

Hey how do I create an on vote event with shards (discord.js)? I've looked through a couple pages of messages in this channel but nothing has worked for me.

vapid cape
#

vote events have nothing to do with shards

#

you will receive them in a webserver

dusty roost
#

yes but you can't login to your dbl token on the same port multiple times

vapid cape
#

just place the webserver in the shardingManager

dusty roost
#

i have

#

but it still isn't working

vapid cape
#

show code

dusty roost
#
const Discord = require('discord.js');
const client = new Discord.Client();
const Manager = new Discord.ShardingManager('./minecord.js');
Manager.spawn(2);

const DBL = require("dblapi.js");
const dbl = new DBL('token',
                    { webhookPort: 5000, webhookAuth: 'pass' });


dbl.webhook.on('ready', hook => {
  console.log(`${new Date()} Connected to DBL Webhook at http://${hook.hostname}:${hook.port}${hook.path}.`)
});

dbl.webhook.on("vote", vote => {
  console.log(`User with ID ${vote.user} just voted!`);
  client.channels.get(`683795130079379501`).send(`<@${vote.user}> just voted!`)
});
vapid cape
#

you cant use client in the shardingManager

dusty roost
#

i figured

vapid cape
#

you have to send it via broadcastEval

#

or however the shardingManager communicates with the shards

#

ie: Manager.broadcastEval("if(client.guilds.cache.has(CHANNELID)) { client.channels.cache.get(CHANNELID).send(DATA) }")

#

assuming discord.js v12

willow spindle
#

@dense compass ^

spiral steeple
#

Can 2 servers have the same channel id?

#

It'd be really really low chances

#

but is that possible?

restive otter
#

I want to say no simply because if it would somehow initiate at the same time, they'd simply go one after the other in terms of when they're processed, overall, maybe, but if it's handled correctly, it wouldn't

#

Though I wouldn't be concerned about it at all, it's next to impossible to do that

inner venture
#

@spiral steeple no, channels are unique

#

Channels as a resource arent even guaranteed to be attached to a guild

#

you can tell this by the paths for interacting with them

#

This is creating a message within a guild channel

#

Because theres no reference of a guild, one can only conclude that they are globally unique

#

even across DM channels

ocean rain
#

@inner venture where is that screenshot from?

inner venture
#

@ocean rain err, my computer

knotty garnet
#

you guys could also use a webhook for getting whenever your bot receives a vote

#

no need for dbl authentication

#

just create an endpoint and pass it to the webhook field in the bot's configs

#

since almost everybody here is using d.js you should have no problem setting up a webserver

harsh stream
#

You think too high of the average skill here

knotty garnet
#

'-'

#

node is basically made for setting up webservers

restive otter
#

@ocean rain if you want to know the program he's using, in the screenshot, it's Postman peepoWeird

ocean rain
#

oh

restive otter
#

I am having trouble setting up my DBL Api again

#

What should the webhook url be?

restive otter
#

nvm i think i got it

#

but feel free to help me

sullen nymph
restive otter
#

yep

#

ok thanks

#

well

#

actually no

#

hmmm

sullen nymph
#

We can't edit bots we're not owners of

restive otter
#

ik.

#

so wait

#

what do i insert in the URL for webhook?

sullen nymph
#

http://ip:port/dblwebhook by default

restive otter
#

mkay

sullen nymph
#

Edit ip and port per your configuration

restive otter
#

Ehm, what?

#

ig im putting localhost:port/dblwebhook

sullen nymph
#

http

#

Not https

#

Unless you've got an SSL

fair herald
#

What is 401 Unauthorized?

green mantle
#

means youre not allowed todo what ever your doing

sullen nymph
#

Token was not valid or specified

fair herald
#

Oof..

#

Then I didnt take the whole token..

#

Cant really see it.. on phone.

knotty garnet
#

@restive otter it's not good showing your server's ip lol

#

Someone might dddos it

balmy hamlet
#

^

rocky bough
#

lol

harsh stream
#

That isn't even a valid IP address

#

it only has 3 groups of numbers instead of 4 and 678>255

knotty garnet
#

Ah

#

You're right

balmy hamlet
#

I didn't read the ip

#

so idrk

true talon
#

lol

#

not even true or false

willow spindle
true talon
runic grove
true talon
#

hasVoted !== getStats

runic grove
#

ok im blind

runic grove
#

hasVoted takes time

true talon
#

like 10 mins?

#

wait

#

9pm

willow spindle
#

Depending on your eval command i think

true talon
#

should have update

#

nope

runic grove
#

no

true talon
#

I've voted my bot 10 mins ago

#

so...

#

hl

#

hmm

runic grove
#

yeah and one thing dbl has taught is that its shit with caching

true talon
#

oof

#

apparently it doesnt even return true or false

spiral steeple
#

That's why you use a webhook

true talon
#

hm

spiral steeple
#

Well did you await it

vapid cape
#

you didnt resolve the promise lol

true talon
#

I did lol

vapid cape
#

show code

spiral steeple
#

Nah that must be wrong, it is never the programmer's fault

#

always the library

vapid cape
#

no need for the weird async function

#

just do js pichu eval dbl.hasVoted('635383782576357407').then(voted => { message.channel.send(voted); })

#

and you'll see the true/false

true talon
#

false

#

I fucking voted

spiral steeple
#

Then it's a cache issue

#

which is why webhooks are suggested

true talon
#

I basocally have to... wait?

#

well I have to create a webhook

#

but idfk how they work

spiral steeple
#

the dbl library does it for you

true talon
#

no. I mean webhooks in general

#

release?

vapid cape
#

wat

spiral steeple
#

you dont need any other opptions

vapid cape
#

you just need a webdyno or whatever

spiral steeple
#

heroku was made for webservers

true talon
#

I have one

vapid cape
#

webhooks have nothing to do with notifications?

true talon
#

idfk

fierce furnace
#

@green mantle ?

green mantle
fierce furnace
#
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client);

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

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

that?

shy socket
vapid cape
#

did you set the webhook options?

shy socket
vapid cape
#

webhook options

radiant basin
#

the webhook isn't defined so the webhook isn't running.

vapid cape
radiant basin
#

^

shy socket
#

Where to set the Webhook options?

#

Oh found it

radiant basin
#

read the api docs.

#

oh and also set the webhook url and password on the site via editing your bot @shy socket

gritty panther
#

😦

thorn magnet
#

@fierce furnace this code main?

#
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client);

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

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

You don't have an approved bot yet

#

You won't have the top.gg token

true talon
#

^

true talon
#

so if you vote for a bot and then the bot restarts the bot dont see that u have voted for him

#

interesting

vapid cape
#

If you only store your votes in memory, yeah

harsh stream
#

The bot might also miss a webhook call during the restart

true talon
#

15 restarts later, the bot finally detects that I've voted for it

plucky swift
#

I keep getting Error: 400 Bad Request request when trying to use postStats (discord.js)

#

Was ever since I updated to v12

vapid cape
#

You dont need to use postStats

#

But if you want to, make sure youre getting the correct server count, which in v12 is client.guilds.cache.size

plucky swift
#

Yeah, am using that

#

So I can just remove it?

vapid cape
#

If you add your client to the DBL constructor, it will do it for you automatically

plucky swift
#

Awesome

vapid cape
#

Bht make sure you have the lastest version of dblapi.js

snow surge
#

Is there any way to check is user voted for bot and this return true only 1 time per vote, so user can't claim rewards multiple times?

restive otter
#

webhooks

snow surge
#

No API endpoint for this. Like during downtime?

shy socket
#
const Discord = require('discord.js'); 
const client = new Discord.Client(); 
const express = require('express');
const fs = require('fs')
const http = require('http');
var app = express()
client.login('Discord Token'); 
const DBL = require("dblapi.js"); 
const server = http.createServer(app);
const dbl = new DBL('Top.gg Token ', { webhookAuth: 'SecureWebSocketPost', webhookServer: server});
app.get('/', (req, res) => { 
	res.send("Aktiv!")
}); 
app.listen(6573, () => { 
	console.log('Running on port 6573');
});

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


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


#

Wont work

#

The Tokens are set. ..

#

And webhookAuth is set too

restive otter
#

is there a ratelimit for guild update time?

vapid cape
#

@shy socket did you configure it in your bot's top.gg settings?

restive otter
#

-ping

wild lanternBOT
#

dslWaddle I'm alive!!!

lament crescent
#

i created my bot and i created a script and it's not working someboody can help me?

#

this is something worng

#

wrong

vapid cape
lament crescent
#

thx

median badger
#

@lament crescent you leaked your token

lament crescent
#

Yeah i know i restart ham

uneven hawk
#

What does: Error: 400 Bad Request mean when trying to connect

echo lake
#

lol

craggy anchor
#

is there an example of a daily system being implemented with DBL

echo lake
#

@uneven hawk Discord Gateway or Top.gg?

uneven hawk
#

Im pretty sure Top.gg bc its coming from dblapi.js

    at IncomingMessage.<anonymous> (C:\Users\___\Desktop\Bot\node_modules\dblapi.js\src\index.js:118:25)
    at IncomingMessage.emit (events.js:323:22)
    at endReadableNT (_stream_readable.js:1204:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:1536) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1536) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
balmy hamlet
#

send the code

#

the one that's giving the error duh

#

uuh

#

I'll assume you're using your dbl token

#

first

#

did you just copy the code from the website

#

ik

#

I mean

#

idk why it's erroring

#

u sure that's where the error is coming from?

#

It means nothing

#

this is how I'm doing it

#

@stiff orbit kinda

#
dbl.on('posted', () => {
    logger.info(`GuildCount Updated`)
});
dbl.on('error', e => {
    logger.error(`DBL Had an error ${e.message}`)
})
#

I have the rest at the top of my file lmao

#

I don't think so

#

it's 11

#

pm

#

I got school tomorrow

#

yes

#

at the top of the file

#

I'm just showing that part

#

it doesn't matter lmao

restive otter
#

I can't use the API if my bot hasn't been approved yet, correct?

#

O,

true talon
mellow plinth
#

How can u change the n/a on ur bot on the website?

true talon
restive otter
#

is there any videos on how to get the server count on top.gg?

sullen nymph
#

dblapi.js supports server count posting

restive otter
#

yh but i need like a video so i know what im doing

sullen nymph
#

Documentation?

#

Those are outdated Sai

hollow raptor
#

examples

sullen nymph
#

Well I didn't ask what those are zoomeyes

arctic arch
#

@restive otter there are good text based examples, videos aren't needed

cold pendant
#

@arctic arch What do you mean by This channel is an archive of old examples? Kinda unclear.

#

Like how old are the examples?

arctic arch
#

channel closed down and was archived sept 2018

restive otter
#

I have a bot called @restive otter, and it carrys on giving multiple vote rewards whenever a user votes. It's down at the moment, but could someone check my code in a little bit please?

#

@sullen nymph would you be able to help please since you're one of the library developers?

sullen nymph
#

I don't exactly remember how top.gg handles the weekend vote data
If you need help with it in discord.py though, I might be able to help

restive otter
#

I don't mean weekend, I just mean it duplicates votes.

#

I'll send a screenshot

#

And the code

#
    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        logger.info('Received an upvote')
        voter = bot.get_user(int(data["user"]))
        if data["isWeekend"]==False:
            coinamount = random.randint(10,1250)
            try:
                await voter.send("Thanks for voting! As a reward, you've been given {} coins!".format(coinamount))
            except:
                pass
            await bot.get_channel(671795061150842891).send(embed=makeEmbed("", "{0} has voted, and won {1} coins!\nVote [here](https://top.gg/bot/627859943889960961/vote)!".format(voter, coinamount)))
            giveMoney(voter, coinamount)
        else:
            coinamount = random.randint(100,2100)
            try:
                await voter.send("Thanks for voting! As a reward, you've been given {} coins! Since it's the weekend, you get more coins than usual!".format(coinamount))
            except:
                pass
            await bot.get_channel(671795061150842891).send(embed=makeEmbed("", "{0} has voted, and won {1} coins!\nVote [here](https://top.gg/bot/627859943889960961/vote)!".format(voter, coinamount)))
            giveMoney(voter, coinamount)
        #print(data)```
#

@sullen nymph

#
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='************', webhook_port=33, autopost=True)```
I have that too
sullen nymph
#

Do you think there could be multiple instances running?

restive otter
#

No, I've checked it all and I don't see why it would duplicate itself

#

I only ever run screen -S gembot python3 bo4.py once, so I'm not sure why Linux would duplicate it.

#

And it doesn't ever duplicate any commands

#

So I have no idea what's happened

#
@bot.event
async def on_ready():
    print('----------------------------')
    print('CONFIG')
    dblsetup(bot)```
Could that be doing something?
sullen nymph
#

What's dblsetup?

restive otter
#
def dblsetup(bot):
    global logger
    logger = logging.getLogger('bot')
    bot.add_cog(TopGG(bot))```
green mantle
#

oh well there u go

restive otter
#

?

green mantle
#

on_ready fires multiple times

restive otter
#

Oh does it?

green mantle
#

on every reconnect

restive otter
#

Ohhhhhh

green mantle
#

every shard connect, every shard reconnect

restive otter
#

So if I do this would it be ok?

dblsetup(bot)
print('Started top.gg webhook')


bot.run("************************")```
green mantle
#

ig yh

sullen nymph
#

Sounds reasonable

restive otter
#

Thanks!

woeful fulcrum
#

When I use ```js
dbl.getVotes().then(votes => {
votes.forEach(vote => {


`vote.id` is the ID of the user who has voted or the ID of the vote ?
willow spindle
#

user

true talon
#

I switched to a real vps (contabo). I took my bot files, replace some values with tokens and tried to run it, but I get this error :

lumap@vmi329048:~/PichuRewrite$ node index.js 
/home/lumap/PichuRewrite/index.js:46
dbl.webhook.on('posted', () => {
            ^

TypeError: Cannot read property 'on' of undefined
    at Object.<anonymous> (/home/lumap/PichuRewrite/index.js:46:13)
    at Module._compile (internal/modules/cjs/loader.js:1147:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Module.load (internal/modules/cjs/loader.js:996:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47```
#

Was working fine with heroku

#

Literally the same code

spiral steeple
#

Show the code

true talon
#

K

arctic arch
#

looks like you haven't configured your webhook

cold marlin
#

;-;

true talon
#

Nvm, fixed itself

bleak ledge
#

How is the voting multiplier useful? Is there any advantage to supporting it?

#

(in the Java lib for dbl)

#

I'm not going to use it I don't think

knotty garnet
#

well, at weekends your vote count as 2

#

it's nice to try to give people reasons to always vote at those days

bleak ledge
#

Oh ok
That's cool
So I either double my prize or otherwise make it slightly better
Neato

bleak ledge
#

Why does vote count as 2 on weekdays? Wouldn't it discourage users who work on weekdays?

green mantle
#

Counts as 2 on weekends

#

1 on weekdays

#

Doubled I'm assuming because that's when most people are active on discord as a whole

bleak ledge
#

Ok, makes sense

restive otter
#

I was wondering why I woke up with +100 votes yesterday

#

Or like 90

balmy hamlet
exotic gyro
#
dbl.getVotes().then(votes => {
        if (!votes.find(vote => vote.id == message.author.id)) {
            message.reply(`You must vote for Helper to gain access to this command.  To use this command vote for me [here](https://discordbots.org/bot/409538753997307915)`)
            
        }return;
    });```
#

is there something wrong with that

#

because i have voted

#

and it wont recognize that i voted

restive otter
#

when i do npm install dblapi.js i get those and it wont show server count how can i fix this?

tawdry spindle
#

have you tried running your code?

restive otter
#

yup

#

not showing server count

tawdry spindle
#

you sure it's posted? can you show us the code and how you send it

#

so someone can help, igtg good luck

restive otter
pale fulcrum
#

It doesn’t look like you actually posted it anywhere in that code

tawdry spindle
#

Yeah well I don't remember how long were DBL tokens but you just leaked a big part of it... Not a big deal but be careful about those next time.

#

Also yes, you did not send any data to DBL, you've just set up a webhook server which will not also work since I guess it requires Express to work BUT you don't have to worry about all that if you just want to send server count.

#

Send it with an interval of at least 2 minutes, you can do it every hour or whatever you want but try to keep request limits in your mind.

#

@restive otter

restive otter
#

@tawdry spindle i did all of that but its not showing servercount in consolelog

tawdry spindle
#

Uh? If you want to display your bot's server count why are you even looking up to DBL docs?

#

Well I'm pretty sure you tried console.log(dbl.postStats(... but that'll not return something I believe

restive otter
#

nope

#

the code i show is what i put in the bot and install the other thing

#

someone was helping me with it works for them but wont work for me

tawdry spindle
#

The code in the screenshot?

#

And who's this "someone" since that screenshot is completely not relevant to your request

restive otter
#

ok then if thats not the right way of doing it can u show me how to do

tawdry spindle
#

Scroll down a bit

restive otter
#

k ill check it out

restive otter
#

@tawdry spindle it didnt work

hollow raptor
#

it not updating count in page or not showing in ur console server count?

restive otter
#

its not showing in console server count

hollow raptor
#

ye beacue you haven't added any count in log to show

restive otter
hollow raptor
#

ur logging a simple string with normal text...

restive otter
#

ok so what do i need to add to get the server count to log?

hollow raptor
#
console.log(`posted ${serverCount} Count.`)
#

you should make interval> check ratelimits in docs

restive otter
#

i have that but still not console logging anything

#

its like my bot is not seeing the code

#

i even installed npm install dblapi.js

hollow raptor
#

...

maybe u created other file and not requied it ...

restive otter
#

i put the code in my events ready.js

hollow raptor
#

then it would log
maybe did something wrong
does bot started and
logging anything in ready event?

#

you added anything to log when ready event started?

restive otter
#

yea thats where my logs use to be

hollow raptor
#

?

restive otter
#

const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('', client);

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

dbl.on('error', e => {
    console.log(`Oops! ${e}`);
})
client.on('ready', () => {
    setInterval(() => {
        dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
    }, 1800000);
});
dbl.getStats("651003099636301834").then(stats => {
    console.log(stats).postStats(serverCount, [shardId], [shardCount])

    console.log(`posted ${serverCount} Count.`)
});

}

#

thats what i have and my api key in there

hollow raptor
#

1st is event it will post your server count
setinterval to dbl posted event

arctic arch
#

what

restive otter
#

idk

#

this is so confusing

hollow raptor
arctic arch
#

in the new DBL line do you have your client

restive otter
#

yes i have my client

arctic arch
#

okay so the module will handle posting for you

#

and the posted event will fire when it has done so

#

you don't need to set your own interval

restive otter
#

what am i doing wrong in the code?

hollow raptor
#

everything

#

...

arctic arch
#

no, Sai

restive otter
#

omg

arctic arch
#

is that your whole file

restive otter
#

this is giving me a headache

#

thats my events ready.js

arctic arch
#

okay

#

so

#

you're creating a new client in your ready event

#

you're supposed to use the client of your running bot

#

and you should initialize dbl before the ready event

#

so it should go in your main index.js or whatever it is you start your bot with

restive otter
#

oh

#

ill try that right now