#topgg-api

1 messages ยท Page 89 of 1

young onyx
#

4776024699

stiff osprey
#

@radiant peak no, because top.gg send the events to you

radiant peak
#

okay thats good

#

ty

rocky bough
#

have you tried the test button

#

it worked?

#

something might be wrong with your webhook

frigid basin
#

any way to show how many shards my bot has on it's page?

sullen nymph
#

shard_count in server posting

frigid basin
#

Ok thx

frigid basin
#
await self.dblpy.post_shard_count()``` doesn't seem to work
frigid basin
#

thx

restive otter
#

@stuck moon

cinder jackal
#

Hello. In the js library, do I have to call .postStats regularly?

#

Or is it automatically done?

sullen nymph
#

If you provide your client to the DBL constructor, you don't need to post stats manually

cinder jackal
#

Alright, thanks

mossy bay
#

was anyone having a problem with top.gg server count with python

#

I think i did everything but it doesn't seem to show the correct count

#

i have set a config var on heroku

dreamy storm
#

even widgets are showing undefined

viral solar
gentle pewter
#

^

split prawn
#

im so lost

#

regarding this api

vapid cape
#

your bot needs to be in this server to appear online
if your bot is not yet approved, you need to wait for approval
if your bot is already approved, it might have been kicked. check #mod-logs for your bot's id and see why it was kicked
@viral solar @gentle pewter

gentle pewter
#

ty

split prawn
#

does anyone here have experience integrating the webhook thing with nodejs?

vapid cape
#

yes, what are you having trouble with?

split prawn
#

okay great, so i'm trying to catch votes

#

i npm installed http, express and the dbl api

viral solar
#

it was approved a while ago, but never entered this server

split prawn
#

const http = require('http');
const express = require("express");
const app = express();
const port = 3000
const server = require('http').createServer(app);
const listener = app.listen(port, function () {
    console.log("Listening on port " + listener.address().port);
});
const DBL = require("dblapi.js");
const dbl = new DBL(config.dblToken, client, {  webhookServer: listener, webhookAuth: config.webhookauth });

dbl.webhook.on('vote', async vote => {
    console.log(`User with ID ${vote.user} just voted!`);
    let voter = await Player.findById(vote.user);
    if (!voter) {
        voter = new Player({ _id: id, joined: Date.now() })
    }
    if (!voter.inventory) {
        voter.inventory = {};
    }
    let inventory = voter.inventory;

    if (!inventory[`commoncrate`]) {
        inventory[`commoncrate`] = 2;
    } else {
        inventory[`commoncrate`] += 2;
    }
    await Player.updateOne({ _id: `${vote.user}` }, { $set: { inventory: inventory } })
});```
vapid cape
#

@viral solar what is its id?

split prawn
#

so, i'm trying to get this to work

viral solar
#

my id?

vapid cape
#

@split prawn are you using express and http for anything else? if not, you dont need them at all, dblapi has its own internal server

split prawn
#

oh really

vapid cape
#

@viral solar your bot's id

split prawn
#

i didn't know that

viral solar
#

is 573905687822860288

split prawn
#

okay tim I removed that

vapid cape
split prawn
#

so, how do I get it to work?

viral solar
#

hm

#

and how do I get him back to the server?

split prawn
#

sorry if I'm being too dumb, I never really used webhooks before

vapid cape
#

webhooks require either a webhookServer if you use an existing server, or webhookPort if you want it to create one

#

so go ahead and change it to webhookPort:3000

split prawn
#

yeah, done that change

vapid cape
#

@viral solar you fix the issue, or disable the feature that made it get kicked, then you contact the mod who kicked it

viral solar
#

ok thanks

split prawn
#

sorry tim, so how do I get it to work?

#
const DBL = require("dblapi.js");
const dbl = new DBL(config.dblToken, client, { webhookPort: 3000, webhookAuth: config.webhookauth });

client.on('ready', () => {
    console.log(`I'm ready! Logged in as ${client.user.tag}!`);
    client.user.setActivity(`${config.prefix}help`, { type: 'PLAYING' });
    prefix = config.prefix;

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

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

    dbl.webhook.on('ready', hook => {
        console.log(`[DBL] Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
    });
})
vapid cape
#

webhook options and client should be reversed

#

ie new DBL(token,options,client)

split prawn
#

oh alright

vapid cape
#

the dbl.on blocks dont need to be in the ready event

spiral steeple
#

dbl waits for your bots ready event iirc

vapid cape
#

the autoposter does, but the webhooks dont

#

but its much better to check if the client is ready inside the webhook vote logic

spiral steeple
#

lol

vapid cape
#

discord.js's ready event may fire multiple times

spiral steeple
#

use a .once mmLol

vapid cape
#

which would make it keep adding new listeners

#

yeah using .once would be better

#

but that would also make it lose its activity on a reconnect lul

split prawn
#

okay great thank you so much tim

#

here i just place the VM's IP right?

#

and open port 3000

#

correct?

vapid cape
#

yes

split prawn
#

okay tysm

vapid cape
#

the full url would be something like

#

http://IP:PORT/dblwebhook

split prawn
#

oh alright

#

perfect, ty

#

and is there some way i could change that?

spiral steeple
#

I thought all guilds were always cached

#

is that not the real server count?

split prawn
#

I don't know, but my bot isn't in 6 servers lol

#

No, it's at like 89 or something

#

Oh waitt

#

Nevermind, sorry

#

My bad

#

I was on the testing token

cursive geode
#

I can't use api for some reason

heady moat
#

hey

#

whats the wrong

sullen nymph
#

What are your webhook settings in code

heady moat
#
app.get("/", (request, response) => {
  response.sendStatus(200);
});
var server = http.createServer(app);
const listener = server.listen(process.env.PORT || 8000, function() {
  console.log("Your app is listening on port " + listener.address().port);
});
const webdbl = new DBL(client.config.dblToken, { 
webhookAuth: 'mypassaword',
webhookServer: listener
})

webdbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});```
#

@willow spindle

willow spindle
#

?

vapid cape
#

@heady moat add /dblwebhook to your glitch url

restive otter
#

๐Ÿ‘€

sturdy zephyr
#

Hallo Does anyone know How can i make a private room for voted
Example if the member vote the bot send in the channel
{user} You have voted the bot

willow spindle
#

you can use webhooks

sturdy zephyr
#

Then?

#

Can i have the code or Should I make it myself? @willow spindle

willow spindle
#

there is example on docs

#

Which prog. language do you use

sturdy zephyr
#

Discord.js

willow spindle
sturdy zephyr
willow spindle
#

??

sturdy zephyr
#

Nothing I found it

#

Thank you very much

willow spindle
#

:+1:

fast spruce
#

hey how to make a command, where yout type vote and u vote then check and it checks if u voted and gives user prize

spark mango
#

I've installed the dblpy library on my vps with "pip3 install dblpy" but when I integrate the example server count to try, it said "raised an error: ModuleNotFoundError: No module named 'dbl'"

#

I don't really understand because i imported the module

knotty garnet
#

try pip install dblpy

spark mango
#

pip is for python 2.X

#

and my bot is on python 3.X

knotty garnet
#

so idk

restive otter
#

@split prawn how i set that?

willow spindle
#

hey how to make a command, where yout type vote and u vote then check and it checks if u voted and gives user prize
@fast spruce which library

restive otter
#

can someone aproof my bot plz

rugged sierra
restive otter
#

i dont even know how to code it ๐Ÿ˜ถ

#

There is a queue.

sullen nymph
#

Why are you listing an undone bot on a public bot list website

restive otter
#

cuz idk

#

i just dont know how tooo cooodeee ittt

rugged sierra
#

wrong channel for this

restive otter
#

ok

fast spruce
#

@fast spruce which library
@willow spindle discord.py

willow spindle
#

(I am using JS so I can't help you, sorry)

sullen nymph
#

I suggest you use dblpy's webhook

restive otter
#

Hi

#

From your bot's edit page

#

Ooo

#

ok thx

median badger
#

no, its from the api docs

vapid cape
#

doesnt matter, you can get it from both of them

restive otter
#

My vote track code isnt working, i tried everything but, no any response...

#

(vps)

vapid cape
#

show code and show top.gg settings

restive otter
#
webhookServer:server,
webhookAuth: '--',
webhookPort: 8000
},client)```
vapid cape
#

server and port are mutually exclusive, use only one or the other

#

do you have an express.js server?

#

or an http.createServer?

restive otter
#

Yes, i have.

#

http.createServer(app)

#

@vapid cape ?

vapid cape
#

show your createserver code

restive otter
vapid cape
#

do you have dbl.webhook.on("ready")?

restive otter
#

yes?

vapid cape
#

also, what does the console.log say

#

what is listener.address().port

#

in your console

restive otter
#

8000

vapid cape
#

ok, so delete process.env.PORT || and leave only 8000. delete webhookPort from dbl, change webhookServer to listener instead of server

#

and change https to http in your top.gg url

restive otter
#

okey

#

not worked

#

same ..

vapid cape
#

where is your bot hosted?

#

which company?

restive otter
#

Azure

vapid cape
#

check if they have a firewall

#

maybe you need to allow port 8000 in their firewall

restive otter
#

what

vapid cape
#

@oblique sluice which language?

#

did you install dblapi.js?

#

did you setup the webhook settings?

#

it works on glitch too

#

did you configure it correctly tho?

#

anyway configure it again

#

then show it

#

this is glitch or vps?

#

you're using the express server for uptime right?

#

anyway remove webhookPort, since webhookServer disables the port anyway

#

what is lbd?

#

ldb is your project name right?

#

glitch uses a specific port defined in an evironment variable, and links it to port 80 (http), so change your port to process.env.PORT

#

the url should be ldb.glitch.me/dblwebhook

#

and your server should be .listen(process.env.PORT)

#

authorization in top.gg is the same as webhookAuth in dblapi, right?

#

they have to be exactly the same

#

ok

#

so save everything

#

and try the test button

#

(you have to press save in top.gg as well, before testing)

#

it does

#

your project is named ldb or lbd?

#

you wrote two different things

#

do you get the webhook running at http://... in your console?

fiery spear
#

Yo

vapid cape
#

@oblique sluice can you show what it logs?

#

show your current code

fiery spear
#

I ain't getting the vote event from the api

restive otter
#

Why it is showing "0.0.0.0:0"?

vapid cape
#

its normal to show that

#

@oblique sluice im testing on reqbin and your url is getting 404

#

like it doesnt exist

fiery spear
#

I get the webhook.on('ready') event with 0.0.0.0:5000 but not the vote event

vapid cape
#

show code and show top.gg webhook settings

#

@oblique sluice try manually setting a path

#

webhookPath: "/dblwebhook"

fiery spear
#

I don't any response for votes

vapid cape
#

@fiery spear do you have an existing server? are you hosting on glitch?

fiery spear
#

Glitch

vapid cape
#

@oblique sluice did you put it with or without a slash? i forgot to add the slash before

#

still nothing

#

do this instead

#
  response.sendStatus(200)
})```
#

and remove all dblapi.js code

#

@fiery spear show your server code

#

http.createServer and express if you have it

#

all of it

#

basically gonna try without using dblapi.js at all

#

did you add the app.post code?

#

still getting 404

fiery spear
#

@vapid cape

vapid cape
#

@fiery spear ok, remove webhookPort from new DBL

#

and show your top.gg webhook settings

fiery spear
#

200 means OK right?

#

Ahh wait it works now

restive otter
#

@oblique sluice, for example ; if (hook.type === "test"){ //... }

#

if you don't mean it, sorry . idk

fiery spear
#

It works for me @oblique sluice

#

I mean I followed the same steps as ya did

spring flicker
#

how to download dblapi.js for heroku

fiery spear
#

Isn't it the same?

#

npm i dblapi.js

spring flicker
#

He says that he cant find it

#

nope i cant do that

fiery spear
#

Eh

#

Never used heroku though

spring flicker
#

He says module not found

#

Can someone helpme? I want to use dblapi.js for herou but he says module not found

vapid cape
#

@oblique sluice yes

#

test it with reqbin

#

and check if your vps requires opening ports in their firewall

#

what error are you getting on reqbin?

#

that means no webserver is running on the destination

#

welp ig2g

latent stone
#

hi, i'm using ipv6 for the vote webhook thing but it doesn't seem to work, does the API support sending requests to IPv6 hosts?
(the server seems to be configured properly since it works in browser)
~~code (in case there's something wrong in it) : https://hastebin.com/zuqubapoju.js ~~

I got my answer, yes it does!

fiery spear
#

Twixgamer I guess its best to check google or ask support from heroku

median badger
#

did you include the token

#

401 means unauthorized

sand wraith
#

Hey how to use webhooks on top.gg for posting vote messages on discord

vivid tulip
#

How does this whole api thing work

#

How do I set it up

hidden nymph
#

@sand wraith get the payload url from discord and send it there

sand wraith
#

Sent

#

But showing

#

Error

#

@hidden nymph

young mist
hidden nymph
#

@sand wraith show code

sand wraith
#

Now done

#

My frnd helped me

#

And thanks to you

hidden nymph
#

Ahh alright enjoy lockdown 4.0 @sand wraith

sand wraith
#

Lockdown 5.0

#

Ooooo

#

Am from india

hidden nymph
#

Ik

#

same here

sand wraith
#

Ooiioooo

hidden nymph
#

lol

abstract breach
#

HAIIII

pure nymph
#

Help me with dbl api

#

Idk where to replace code :v

cinder talon
#

py?

restive otter
#

?

sullen nymph
#

What is your question?

#

I deleted it for a reason

#

Can you ask your question instead of just sending screenshot of your bot page?

restive otter
#

Bah infaite his me but his and I've been waiting for 3hours a red box

heavy drum
#

It takes 2-3 weeks >.>

restive otter
#

Ok

#

my pc must still be on?

sullen nymph
#

Your bot must be online during reviewing

restive otter
#

Ok

heavy storm
willow spindle
#

what

heavy storm
#

API opptiones in edit

#

asking me for URL and authorization

#

i got the authorization already

#

but idk what to tipe in URL

willow spindle
#

can you send screenshot

heavy storm
#

k sec

vapid cape
#

@heavy storm the url is where top.gg will send vote webhooks to

#

you want to receive vote webhooks?

heavy storm
#

its my first time to do a bot i just wanna know how many servers my bot get in like other bots

vapid cape
#

then you dont need that

heavy storm
#

ohh what i need then?

vapid cape
#

you need to post your server count using the top.gg api

heavy storm
#

i checked the link and still dont get it ๐Ÿ˜ฆ

vapid cape
#

which language are you using

heavy storm
#

arabic/english

vapid cape
#

programming language

heavy storm
#

english

vapid cape
#

programming language

willow spindle
#

javascript, python etc.

vapid cape
#

^

heavy storm
#

ohh sorry

#

javascript

vapid cape
#

check the tools section

#

there is a javascript library

willow spindle
heavy storm
#

oky ty alot for help โค๏ธ

sullen nymph
#

A webhook being a webserver running on a machine

#

not a Discord webhook

#

Yeah, that's what a "real" webhook is

#

Yup

heavy storm
#

sorry 1 more ask
do i need to edit this or leave it? ('Your top.gg token', client); its db1api.js

sullen nymph
#

Enter your top.gg token and remove client if you don't need dblapi.js to automatically post your server count

mossy bay
sullen nymph
#

Are you sure the cog is loaded properly

green mantle
#

does it actually post count or error?

mossy bay
#

it posts some weird count says 13 servers but my bot is on 39

#

@sullen nymph yes i'm pretty sure

crimson gazelle
#

Error: postStats requires 1 argument

restive otter
#

dbl.postStats(client.guilds.size)

lavish elm
#

Sorry for this stupid question, but what happens if someone do this dbl.postStats(9264)?

#

Would that be legal?

restive otter
#

Yes

lavish elm
#

huh, disappointing

#

so a lot of bot counts out there could be fake

lucid depot
#

What is?

vagrant scroll
#

Ah

vapid cape
#

@lavish elm its possible to fake it, yes, but if found out you will be banned

#

nobody does that

lavish elm
#

Oh ok, happy to hear that then ๐Ÿ˜„ @vapid cape

restive otter
#

My webhook doesn't work at all, can someone help?

frigid shore
#

hi

#

can i host webhook on hosting that doesnt respond to web requests?

restive otter
#

well, of course not

frigid shore
#

;(

idle current
#

How can I setup a webhook that can be used with the api?

restive otter
#

Does the shard count of the bot's shards gets sent to the website automatically or needs to be sent manually?

#

Hmm

lucid depot
vapid cape
#

show code

dreamy brook
#

what is postStats

restive otter
#

server count

fast rune
#

how to use dblapi.js? im new to it so

#

i dont know how to get the token, i have the code

knotty garnet
#

The token is in your bot's page

#

Go all the way to the bottom, the token is above the widget config

faint dew
#

How do I get my bot to send a message to the console every time a user votes on my bot?

knotty garnet
#

console.log("User xxx voted")

#

Put that inside the webhook handler

#

About the webhook part, give express.js a read

fast rune
#

thank you

spare mulch
#

@mossy bay The python api straight up doesnt even work for me, I had to remake it.... Ill send you the code I wrote if you like

pure nymph
#

im not use shard in bot

#

but can i use dbl api?

grim granite
#

come again?

#

Are you saying your bot isn't sharded?

vivid tulip
#

????

#

Help

exotic karma
#

where is client coming from?

arctic arch
mossy bay
#

@spare mulch ye sure that would awesome

spare mulch
#

Who changed me nick ๐Ÿ˜ 

#

And alright, ill send it over

green mantle
#

@sullen nymph Was the user key in the payload a int or str again?

sullen nymph
#

String

#

@green mantle

#

I've thought about converting it to integer

green mantle
#

Aight

#

well ive edited the source code anyway to make it and int now

tame trail
sullen nymph
#

-servercount

abstract mothBOT
#

To have your bot's server count displayed on DBL, please read the documentation on server/shard posting. Click here to see the docs.. You may also find #312614469819826177 useful; however it is strongly discouraged as most of the examples are extremely outdated.

green mantle
#

Is the api working ๐Ÿค”

#

Im getting 403's even tho i just regened the token and logged it

#

nvm

restive otter
#

Regen your token

cinder jackal
#

how do i

#

test the vote system?

#

do i have to wait 12 hrs every time i want to test?

willow spindle
#

no

#

just click "Test"

cinder jackal
#

where

knotty garnet
#

below the "save" button

restive otter
#

How to solve that N/A in my bot

sullen nymph
#

-servercount

abstract mothBOT
#

To have your bot's server count displayed on DBL, please read the documentation on server/shard posting. Click here to see the docs.. You may also find #312614469819826177 useful; however it is strongly discouraged as most of the examples are extremely outdated.

narrow coral
#

What is stopping someone from posting a fake server count to DBL? I hope there is some sort of verification in place?

knotty garnet
#

What is stopping someone from posting a fake server count to DBL? I hope there is some sort of verification in place?
@narrow coral fear

cinder jackal
#

omg thanks KuuHaKu and NMW03!!

jagged prawn
#

-servercount

#

-help

restive otter
#

mod only

silk echo
#

Hello I want to ask if you can send the bot to the user's DM saying: "Thanks for voting for me" in this api ...

obsidian tide
#

If you are using node.js, do you already know how to use a vote event?

#

If you are not using node.js, idk cant help you

silk echo
#

@obsidian tide I'm using nodejs

obsidian tide
#

Ok did you already npm install the dbl npm thing?

silk echo
#

yeah

obsidian tide
#

Did you define it and set the webhook?

silk echo
#

yeah

#

....

obsidian tide
#
[DBL variable].webhook.on('vote', vote => {
  [client variable].fetchUser(vote.user).send('message')
}
#

I think

#

Change [DBL variable] and [client variable] to the vars

silk echo
#

OK thank you

obsidian tide
#

F if im wrong

#

I typed that all on a phone lmao

silk echo
#

me too xD

obsidian tide
#

Lol

silk echo
#

thanks

obsidian tide
#

np

silk echo
#

@obsidian tide I forgot to tell you that the version of Discord I'm using is v11

obsidian tide
#

You should really upgrade to v12

#

Then you can implement vote.user

#

I think

silk echo
#

ok

#

I think
@obsidian tide think?

obsidian tide
#

Yah

#

I havent tested

silk echo
#

ok i will test

cobalt summit
#

ุงู„ุณู„ุงู… ุนู„ูŠูƒู…

#

ุงู„ุณู„ุงู… ุนู„ูŠูƒู… = hi

silk echo
#

@obsidian tide error in log: TypeError: client.fetchUser(...).send is not a function

obsidian tide
#

Hmm

#

Idk

#

I havent really used it before

#

Or google it

restive otter
#

@silk echo fetchuser returns a promise

#

so you have to do the following

#

client.fetchuser(etc).then(fetchedUser => {fetchedUser.send(contents)})

silk echo
#

thanks

pallid field
vapid cape
#

@pallid field the url is the server where your bot is hosted. for example http://IP:PORT/dblwebhook if you're using a vps, or YOURPROJECT.glitch.me/dblwebhook if you're using glitch, etc...

restive otter
willow spindle
#

by posting shard count with server count

restive otter
#

how to do it? @willow spindle

willow spindle
#

which lib

open garden
#

@restive otter

restive otter
#

but i dont undestand it

open garden
restive otter
#

yep

open garden
#

So what exactly don't you understand?

restive otter
#

i read this but i dont find answer for my question

umbral atlas
#

@silk echo

silk echo
#

@umbral atlas agora รฉ sรณ perguntar em inglรชs

umbral atlas
#

hm

jagged mantle
#

i put my webhook link in so when someone votes i get a notifcation in a channel

spiral steeple
#

dont put a discord webhook in the webhook url

#

it requires an actual webserver

jagged mantle
#

So I need to make a webserver and after that what do I do?

#

I didnt realise getting vote updates were complex

spiral steeple
#

then you can accept the requests and use the data to send messages (through a discord webhook if you want, I suppose), or do stuff on your bot like giving users rewards

jagged mantle
#

I made a webserver but how do i do the rest

median badger
#

learn js

storm surge
#

im trying to add the discord.py server count example to my code but it gives me errors saying bot is not defined
and do i replace 'token' with my dbl token?

median badger
#

yes, you do

#

and if bots not defined, define it

storm surge
#

k thanks

spare mulch
#

JS isnt your only option, you can make a website in just about every language

#

Java, C#, Rust, Python, PHP, exc

limber widget
#

webhook api is not working

restive otter
#

correct?

dreamy brook
#

arnt u suposed to make web site with html??

vernal adder
#

@dreamy brook backend

#

frontend is like html, css, js and stuff

dreamy brook
#

oh

#

i do the back end in rust

vernal adder
#

u know rust?

dreamy brook
#

@jagged mantle i believe it would be easier to use the official library for that

#

there's an example specifically for webhooks in the examples section

restive otter
#

they told me i should ask this here..
I have created a webhook and copied that url to the webhook setting for my bot on the website of top.gg, but when I press TEST I don't receive a message from the webhook in my defined channel. Does someone know why this is??

knotty garnet
#

Well

#

Are you talking about discord's webhook?

#

If so, that's not the webhook that you're meant to use

#

@restive otter

#

You're supposed to create a webserver for listening to http requests, which will be triggered one top.gg sends a "user has voted" request

restive otter
#

Oh really okay! I tought it was just a discord webhook I had to make!

knotty garnet
#

No lol, the idea of using a webhook to listen to top.gg votes is to be able to handle it somehow (ex: giving credits to said user for voting)

stuck wedge
#

how to get the webhook url

#

for me bot?

#

my*

knotty garnet
#

You need to create one

#

Normally it has this format:

stuck wedge
#

what's endpoint??

knotty garnet
#

Err...

#

Like

#

Idk how to explain

stuck wedge
#

lol

knotty garnet
#

But it's a path to some part of your webserver

mortal isle
#

Le poop

stuck wedge
#

wtf

#

i dont get a shit what's endpoint

knotty garnet
#

Give this a read

stuck wedge
#

node.js

knotty garnet
#

You'll understand how it works

stuck wedge
#

damn

#

ok

knotty garnet
#

Forget about the node.js part

#

Just focus on what is a webserver

olive arrow
#

Use the dblapi package

restive otter
#

user has voted or not is not working

#

pls ping me if you can help

olive arrow
#

@restive otter in what context

restive otter
#

even when i voted for bot it shows i havent voted

olive arrow
#

You are the owner?

restive otter
olive arrow
#

That happens sometimes, I have the same issue

restive otter
#

i use this

olive arrow
#

When I vote for my bot, it doesn't regisyer

restive otter
#

yes

#

ohh

restive otter
#

or, let voted = await dbl.hasVoted(message.author.id)

#

if (!voted){}//...

foggy yoke
#

How do I get an API key?

#

Or my Discord Bot List token

marsh orchid
#

you mean the ID?

foggy yoke
#

I guess so

marsh orchid
#

right click on ur bot and copy the id

foggy yoke
#

I'm trying to do these

#

It says my DBL token though

marsh orchid
#

DBL hmm

foggy yoke
marsh orchid
#

sorry i cant help :c

foggy yoke
#

ok

empty peak
knotty garnet
#

@foggy yoke @marsh orchid the dbl token is only available after your bot is approved

marsh orchid
#

huh then why does he need it

knotty garnet
#

Probably to setup voting rewards

marsh orchid
#

oh ok

inland forge
#

yesterday was my birthday but passed ๐Ÿ˜ญ

foggy yoke
#

@knotty garnet My bot is approved on my main that was disabled

knotty garnet
#

What?

#

Ah

#

I see

#

If your main was disabled I think you can ask the mods to remove the bot from the site then reapply with the current account

foggy yoke
#

Okay

#

Uhhhhh

#

What

sullen nymph
wet wing
#

i used the sample code for discord.py to display server count and it worked fine, but hasnโ€™t updated the server count since then? even though it should automatically do so every 30 mins apparently

#

is there smth more i need to do?

green mantle
#

code?

lost merlin
#

My bot just got verified today

#

Why and what is this api ?

#

I have absolutely 0 knowledge about it

#

Can anyone share a guide or documentation or ? Explain

#

I would be grateful

formal pond
#

Hi

#

Api in my language is fire

#

But that doesn't help anything

#

Sowwy

#

owo

wet wing
#

@green mantle ` class TopGG(commands.Cog):

def __init__(self, bot):
    self.bot = bot
    self.token = 'my dbl token'
    self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) 

async def on_guild_post(self):
    print("Server count posted successfully")`
restive otter
#

hi

opaque jetty
#

wait from the python library, is there anyway to get votes?

restive otter
#

If I want to make auto rewards giving for voting. Should I put the DBL API library thing in the shard file or the main file? I am using eris-sharder.

spice pebble
#

Hi

topaz verge
hard delta
#

!H

median badger
#

need help with anything @hard delta ?

#

nvm

jade shuttle
#

@wet wing there is a bug in that example. You need to mark on_guild_post as cog listener. That should make the listener fire

#

Also don't hard code your token as an attribute in a cog class

lost merlin
#

How do i dm notify the person who votes ?
D.python

#

I want to dm thank them

jade shuttle
#

Webhooks

#

There is an example for it in docs

lost merlin
#

Where i cant see a dm notification example

jade shuttle
#

You listen to webhooks

#

Whenever you get the vote

#

Get the user id from the payload

#

Get user from that id

#

And DM them

lost merlin
#

How to get the user id from payload

raven urchin
#

(Event: on_raw_reaction_add)

lost merlin
#

I have no Idea what u guys sayin

#

But thanks

#

Will this help ?

open agate
#

.

median badger
#

Don't dot post

tardy snow
#

Hey guys can someone help me with posting server count?
I basically just copy pasted the stuff from the python library
but im trying to run the command below

    bot.add_cog(TopGG(bot))```
and dont know what to put in for `bot` in `def setup(bot)`
#

i feel like im over thinking it

#

I replaced it with client, but that doesnt work

daring cove
#

How did you define commands.Bot?

#

@tardy snow

#

Cause if you did bot = comma... that's right

tardy snow
#

I used this from the website

import dbl
import discord
from discord.ext import commands


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, autopost=True) # Autopost will post your guild count every 30 minutes

    async def on_guild_post():
        print("Server count posted successfully")

def setup(bot):
    bot.add_cog(TopGG(bot))```
#

@daring cove

daring cove
#

In your main file

#

Btw did you replace dbl_token?

tardy snow
#

yeah i replcaed it

daring cove
#

Cause if you did bot = comma... that's right
So?

tardy snow
#

i dont get what you mean by bot = commands.Bot

daring cove
#

oof

tardy snow
#

;-;

daring cove
#

To use cogs you need to use commands

tardy snow
#

so ur saying to do

daring cove
#

To use commands you need to define commands.Bot or commands.AutoShardedBot

tardy snow
#

commands.client?

daring cove
#

No

#

How did you call commands.Bot?

#

commands.client?
It's discord.Client btw but no

tardy snow
#

i never called it

daring cove
#

So how are you loading the cog?

tardy snow
#

its defined in the class, why do we need to load it

daring cove
#

So how many files do you have?

tardy snow
#

1

#

that deals with the bot

daring cove
#

Learn d.py basics before using cogs

latent gulch
#

Does anyone use dbscript?

daring cove
#

A cog is an external file that you can add to load classes

#

You need to have a main file

tardy snow
#

i just want the server count to show GWpinkuNotLikeNico

#

tis fine ill do it another way

daring cove
#

You can always put a class inside the main file

#

No need to use a cog

tardy snow
#

thats what i did rn

#

i just put the code i put above in my main file

#

and then i did this when im trynna run it

#

setup(bot=client)

daring cove
#

Oh

#

It's an extension so

#

Not a cog

tardy snow
#

okay here

daring cove
#

Nvm it's not, my bad

#

This is an example of a cog in the main file

tardy snow
#
class TopGG(commands.Cog):

    def __init__(self, bot):
        bot = commands.Bot
        self.bot = bot
        self.token = 'Token'
        self.dblpy = dbl.DBLClient(self.bot, self.token,
                                   autopost=True)  # Autopost will post your guild count every 30 minutes

    async def on_guild_post(self):
        print("Server count posted successfully")


def setup(bot):
    TopGG(bot)

daring cove
#

You don't need to do setup

tardy snow
#

so get rid of that

#

ok

#

i saw ur example

#

and u did this bot.add_cog(Music(bot))

daring cove
#

Not mine but yeh

#

As it's in the main file you don't need the setup func

tardy snow
#

but when i do this

#

client.add_cog(TopGG(bot))

#

i get this AttributeError: 'Client' object has no attribute 'add_cog'

#

oh wait

#

hm

#

ok

green mantle
#

you do need setup wot

#

If its in a cog

#

you need to add cog

#

also

#

you cant use cogs

#

with discord.Client

tardy snow
#

yeah

green mantle
#

it can only be used with commands.Bot

tardy snow
#

i figured that out, so i got rid of the setup, and used bot = commands.Bot

#

and then did bot.add_cog(TopGG(bot))

#

but i keep getting an attribute error bot.add_cog(TopGG(bot))

restive otter
#

bcs its bot.load_extension

#

and u give a path as arg

daring cove
#

you do need setup wot
@green mantle it's not an external file

green mantle
#

he still needs to the cog

daring cove
#

What

green mantle
#

still needs to add the cog sorry

daring cove
#

Yes but no need to do def setup

#

just bot.add_cog

tardy snow
#

ok

#

how do i add the cog

sullen nymph
#

use add_cog anywhere in your code (probably after you create the class)

tardy snow
#

ok

#

ill deal with tthis later ig

#

assuming cogs is a file?

sullen nymph
#

The class

#

Extension would be a file

tardy snow
#

so cog is a class

#

which is this stuff

class TopGG(commands.Cog):

    def __init__(self, bot):
        bot = commands.Bot
        self.bot = bot
        self.token = 'Token'
        self.dblpy = dbl.DBLClient(self.bot, self.token,
                                   autopost=True)  # Autopost will post your guild count every 30 minutes```
#

which i have,,,

#

and then did
bot = commands.Bot
bot.add_cog(TopGG(bot))

tardy snow
#

im just having a hard time understanding the add cog part

sullen nymph
#

Can you show your full code

daring cove
#

(hastebin)

#

@sullen nymph and this is how people leak their token

tardy snow
#

@sullen nymph full code regarding this? or like my entire bot

#

lol

#

ive leaked it too much

sullen nymph
#

Your main file

tardy snow
#

i just have a sep folder tbh

#

lol my entire bot is in main ;-;

daring cove
#

so send it

sullen nymph
#

And yeah, make sure you don't post your token.

Eh, sure, send it

tardy snow
#

ok gimme a sec ill just push it on githhubb

daring cove
#

ok

tardy snow
#

omg

#

wait

#

this stupid

#

shit

#

ok ur good

#

it pushed

daring cove
#

Bruh

#

Those global

#

Use bot vars

tardy snow
#

:/

#

okay last time i used python was 4 years ago

daring cove
#

And replace discord.Client with commands.Bot(command_prefix ="p.")

restive otter
#

just a question, did you read the docs?

daring cove
#

Lel

tardy snow
#

oh ye i tried toing that @daring cove

restive otter
#

if message.content.lower() == 'p.servers'

tardy snow
#

sh

#

STOp it

#

dont bully my baby

daring cove
#

Poor man

tardy snow
#

oh like i was saying

#

i tried to do p.

daring cove
#

I suggest to use commands, not events

tardy snow
#

but it didnt work

#

i did

#

on_message_pins_update or somethin like that

daring cove
#

not*

tardy snow
#

oh

daring cove
#

Not that

#

For the on_message

#
@client.command()
async def your_cmd(ctx):
      await ctx.send("hello") 
```this will send hello when you type p.your_cmd
tardy snow
#

oh

#

yeah not i get what ur sayin

#

to not put it all in one thing

daring cove
#

Instead of ```py
if message.content == "p.your_cmd":
await message.channel.send("hello")

tardy snow
#

i can do that

daring cove
#

But it's just a tip

tardy snow
#

no i was thinking of doing it anyways

sullen nymph
#

I suggest you get a cog listener deco on on_guild_post

tardy snow
#

its messy otherwise

#

a what

daring cove
#

And you are using simple defs, but d.py is asyncso you should also write your functions in async.

tardy snow
#

.-.

#

im thinking in OOP so this makes 0 sense

#

oh those defs are for reading files

sullen nymph
#

Not everything has to be an async function

tardy snow
#

i store them in gdocs

#

and all i store is thhe server id, channel and mode, and blacklisted channels

#

okay

#

so back to the orginal problem

#

before yall started picking on my code

#

lol

sullen nymph
#

I'm uhh

#

Just to be a bit clear

tardy snow
#

ok

sullen nymph
#

You always should only use one object, client or bot

#

Not mix both

tardy snow
#

hmm ok

sullen nymph
#

What you're doing is creating a separate bot object right before loading it into a different bot instance

tardy snow
#

thats what i was orginally confused about cause in the dbl api it said bot is a client obj

#

so i tried just giving it client

sullen nymph
#

It's

#

right

tardy snow
#

like client.add_cog(TopGG(client))

sullen nymph
#

I'll need to get back to the docs soontm

tardy snow
#

i keep getting this AttributeError: 'Client' object has no attribute 'add_cog'

#

idk

sullen nymph
#

But yeah, what it actually meant is that it needs to be an object with property guilds

#

Yeah

#

Switch your client to commands.Bot

tardy snow
#

and then switch back?

sullen nymph
#

Remove bot = commands.Bot in the cog itself

tardy snow
#

ok done

sullen nymph
#

Use client once you change it

tardy snow
#
client.add_cog(TopGG(client))```
sullen nymph
#

Yeah

#

Don't forget the params and stuff

tardy snow
#

you mean these params

#

(command_prefix='p.', status='Online')

sullen nymph
#

Yup

tardy snow
#

i get this tho

#

AttributeError: type object 'Bot' has no attribute 'loop'

#

error

sullen nymph
#

E

#

Which line is it coming from

tardy snow
#

self.dblpy = dbl.DBLClient(self.bot, self.token,
autopost=True) # Autopost will post your guild count every 30 minutes

#

110

#

im confused tho when u change it to commands.Bot, how does that interact with the discord api?

#

ok nvm im the big dumb

#

it still dont work

#

ill get there

#

eventtually

young haven
#

how i do it for a while on the auto poster
options.statsInterval

sullen nymph
#

im confused tho when u change it to commands.Bot, how does that interact with the discord api?
@tardy snow the commands.Bot basically has more tools to simplify creating commands and other tasks

#

It doesn't send any different requests from discord.Client afaik

tardy snow
#

yeah

#

why is this so confusing

#

i swear

#

im doing something stupid

sullen nymph
#

Could you update the code on GH?

young haven
tardy snow
#

yeah

sullen nymph
#

@young haven You can provide your d.js Client to DBL constructor and set the interval

tardy snow
#

done

#

pushed

sullen nymph
#

whoop

#

Remove line 106

young haven
#

@young haven You can provide your d.js Client to DBL constructor and set the interval
@sullen nymph I didn't understand how to do this

sullen nymph
#

Refer to dblapi.js documentation for an example

young haven
#

yes i already consulted but i didn't find an example with posting interval dblapi.js

tardy snow
#

ohh

#

it works

#

.<

#

thank u @sullen nymph

sullen nymph
opaque jetty
#

Wait how do I send test-votes?

sullen nymph
#

Test button on bot's edit page

opaque jetty
#

Oh there it is. Thanks

#

Is it normal for me to get this error when exiting ^Csys:1: RuntimeWarning: coroutine 'Command.__call__' was never awaited Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x106b1f748>

sullen nymph
#

Probably something to do with d.py handling a command when you exit the file

opaque jetty
#

Oh ok

#

Idk, i'm using the example on the dbl.py's github to send the server count and receive votes. I seem to be sending the server count O.K., but I dont see to be able to receive votes. Is there something im not doing right? ```class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""

def __init__(self, bot):
    self.bot = bot
    self.token = '##########'
    self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
    self.update_stats.start() # Your linter may say this is wrong, but your linter is wrong

def cog_unload(self):
    self.update_stats.cancel() # Your linter may say this is wrong too, but again your linter is wrong

# 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))

@commands.Cog.listener()
async def on_dbl_vote(self, data):
    logger.warning('Received an upvote')
    print(data)```
empty jay
#

I'm going through the API for DBL and I am getting some thoughts...Where does this actually post the stats on DBL? js client.on('ready', () => { setInterval(() => { dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total); }, 1800000); });

full charm
sullen nymph
#

-servercount

abstract mothBOT
#

To have your bot's server count displayed on DBL, please read the documentation on server/shard posting. Click here to see the docs.. You may also find #312614469819826177 useful; however it is strongly discouraged as most of the examples are extremely outdated.

full charm
#

I do not understand if you read from there

empty jay
#

I'm having trouble understanding the webhook/vote updates part of the api...can someone walk me through getting the port and password for it?

#

actually just the port...

tired ivy
#

what is this

#

I check with the snekfetch whether the user has voted

empty jay
#

sooooooo

placid peak
#

snekfetch

#

ugh

empty jay
#

I'm having trouble understanding the webhook/vote updates part of the api...can someone walk me through getting the port for it?

placid peak
#

do you use dblapi.js?

empty jay
#

yes

#

i just don't know much about webhooks...plus it says I need a port but idk where I'd get the port from

placid peak
#

nowhere, you choose ot

empty jay
#

I put in 5000 like in the API docs but I'm getting this error when I start my bot with a dbl.webhook.on eventjs dbl.webhook.on('ready', hook => { ^ TypeError: Cannot read property 'on' of undefined

placid peak
#

is your variable name dbl.webhook?

empty jay
#

here's my code ```js
const DBL = require('dblapi.js');
const dbl = new DBL(process.env.DBL_TOKEN, { webhook: 3000, webhookAuth: notgivingmypassword });

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

dbl.webhook.on('ready', hook => {
console.log(Webhook running at http://${hook.hostname}:${hookport}${hook.path})
})```

placid peak
#

its only dbl.on('ready' () =>...)

#

i think

empty jay
#

I legit just copied it off the docs...

placid peak
#

well i havent used dblapi for ages so cant help sry

empty jay
#

but also when I clicked the test button on the top.gg page to test the webhook nothing happened...does that mean I set it up wrong?

placid peak
#

idk

empty jay
#

does anyone else know?

restive otter
#

Does dbl have vote event without webhook?

empty jay
#

Are you getting the same error as I am?

restive otter
#

idk

empty jay
#

have you tried with a webhook?

empty jay
#

@restive otter ?

restive otter
#

i need without webhook BRUH

empty jay
#

I know...but have you tried it with the webhook...I'm just asking because that's how I'm doing it and I'm getting an error BRUH

#

I'm getting this error with this code...any ideas?

const DBL = require('dblapi.js');
const dbl = new DBL(process.env.DBL_TOKEN, { webhook: 3000, webhookAuth: `notgivingmypassword` });

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

dbl.webhook.on('ready', hook => {
    console.log(`Webhook running at http://${hook.hostname}:${hookport}${hook.path}`)
})```
```js
dbl.webhook.on('ready', hook => {
            ^

TypeError: Cannot read property 'on' of undefined```
arctic arch
#

are you the person who made a github issue

empty jay
#

yep...did it get a reply? I haven't checked

#

oh yep it did lol one sec let me try

#

heeey it works...thanks

#

ok so when I test my webhook on the bot edit page nothing happens...the url I put into the URL field is the url that discord gives me when I make a webhook right?

#

ping me if anyone has any ideas so I can see when I wake up

arctic arch
#

its not a discord webhook

empty jay
#

oh?

arctic arch
#

the url is what your console says

#

webhook running at

empty jay
#

oooh gotcha

#

didn't know that lol

arctic arch
#

but replace the 0s with your public ip

empty jay
#

wait but what if I want the votes to be shown in a discord channel?

#

i figured that's what it did

arctic arch
#

you can take that vote event and send a message using your bot

empty jay
#

gotcha

restive otter
arctic arch
#

you can also give people rewards with it if you have something like that

restive otter
#

i done const app = require('express')()

arctic arch
#

check the example on the website

empty jay
#

so where does the test actually get sent to? like where am I looking to see if it's correct?

meager oar
#

hey guys, just trying to implement a postStats from whats in the documentation, but client.guilds.size and client.shards.Id are both undefined. Guessing discordjs was updated?

empty jay
#

works fine for me

#

oh wait no it doesn't...add .cache before .size

#

yep that worked

meager oar
#

ok sweet ty

empty jay
#

i don't even know what a shard is tbh...but it was giving me an error so I took that out of the code

meager oar
#

ok cool I'll remove shard too

empty jay
#

what even is a shard?

signal hawk
#

When your bot gets so big you have to shard it, which basically causes it to be split and run more than once

#

A guild is assigned a shard

empty jay
#

gotcha....it's the parent of a guild pretty much

signal hawk
#

Very basic but yes

empty jay
#

then multiple guilds are assigned to a shard

#

like kids lol

#

also...when I test the webhook where am I actually looking for it to tell me if it works or not?

sullen nymph
#

Your code, the vote event should fire

meager oar
#

is it ok to put postStats on guildCreate? or is it better to have it running in an interval

#

to avoid any limits

sullen nymph
#

Suggested to use an interval instead

empty jay
#

ok but when you test it on the website...where am I looking for it to tell me if it's working?

meager oar
#

thanks @sullen nymph will do

sullen nymph
#

Press test button, request comes, code handles the request

empty jay
#

you have no clue do you?

sullen nymph
#

Not exactly sure what you mean

signal hawk
#

Put a console log in your code lmao

#

If you get the log it works

empty jay
#

but what am I logging? and where? I am legit reading the docs and it just says push the test button

signal hawk
sullen nymph
#

Press test button, request comes, code handles the request
Output anything you want

#

Even the vote data

empty jay
#

ok the little pop up shows but nothing else happens...

#

I'm guessing you guys can't help since you aren't actually helping at all

#

Can someone help me get my webhook working correctly?

sullen nymph
#

What do you mean by "pop-up"

signal hawk
#

You need to have code in your bot that handles the webhook post

#

Inside that code, handle the post, and if you have code that tells you something when it posts, then you know its working

empty jay
#

when you press the test button...the little popup at the top of your screen that says the test may take a few seconds

sullen nymph
#

Yeah, a request was sent to the URL you entered. From there, your code will handle the sent request

#

And how you handle the request is up to you n to implement

empty jay
#

but you guys aren't explaining it so I can understand it

signal hawk
#

The docs explain it

empty jay
#

obviously not good enough

signal hawk
#

Your dbl.webhook.on('vote')

#

Or however you defined it in your code

sullen nymph
empty jay
#

here is my dbl code I have in my main bot file...```js
const DBL = require('dblapi.js');
const dbl = new DBL(process.env.DBL_TOKEN, { webhookPort: 3000, webhookAuth: process.env.PASSWORD }, client);
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
});
dbl.webhook.on('posted', () => {
console.log('Server count posted!');
});

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

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!);
});``` what do I need to change

sullen nymph
#

The vote event

empty jay
#

ok what about it?

sullen nymph
#

Use it to handle the votes

empty jay
#

I'm not even doing anything with votes right now dude.

#

I'm on the bot edit page trying to test it

sullen nymph
#

the vote event is fired for tests too iirc

empty jay
#

then how do I do it to work with tests then

sullen nymph
#

Read the webhooks section in the docs

empty jay
#

I did and it's not giving me anything I understand...is that not obvious

sullen nymph
#

It explains the difference between vote and test requests

empty jay
#

ok I see that...do I change it from 'vote' to 'test'?

sullen nymph
#

In the code you set conditions

#

if vote.type === 'test' etc

empty jay
#

ok. now It's making sense...thank you...finally

#

ok I get this error when I test it...js (node:39280) UnhandledPromiseRejectionWarning: Error: 401 Unauthorized

#

actually when my bot starts up

sullen nymph
#

Oh you're also posting your server count twice

#

Anyhow, do you set an env var DBL_TOKEN

empty jay
#

nope just onve

#

yes that is correct in my .env file...

sullen nymph
#

client provided to the DBL constructor and postStats

empty jay
#

yep

#

ok I regenned my token and now I'm not getting that...let's trying this again now I guess

#

so how long do I wait until I assume the test failed lol

#

ok well imma go to bed...please please pleaseeee ping me with ideas and solutions if anyone has them

upper dune
#

What should I use as the Webhook URL for the api? blobowointresting

vapid cape
#

your bot's hosting information

upper dune
#

ah like ip and port?

sullen nymph
#

http://<ip>:<port><webhook_path>
ip - IP of the machine the webhook is hosted on
port - open port
webhook_path - endpoint for DBL to send requests to (default is /dblwebhook)

upper dune
#

soo the path

#

If I leave it at default

#

Do I have to create a folder there first?

vapid cape
#

if hosting on services such as glitch/heroku/replit/etc replace IP:PORT with your project url

#

no, you dont need to create any folder

upper dune
#

okay