#topgg-api

1 messages · Page 93 of 1

gentle pewter
#

is there a way i can save if the user has or has not voted to a variable?

#

I tried the suggestions such as making it into an atomic but that didn't work

#

java ^

spiral steeple
#

well java is a typed lang, I assume you're just missing the type

#

ah wait

#

I 'm an idiot

#

what's the error show?

#

You can try to cast it, afaik it returns a boolean and not an AtomicBoolean

#

but Idk for sure

restive otter
#

@spiral steeple sorry for ping

#

Did you know anything about 401 cloudflare rejection?

solar spoke
#

Unautherized should mean you don't have a correct token

spiral steeple
#

^

#

does this have to do with the top.gg api?

restive otter
#

Yes

solar spoke
#

Do you use the correct http method?

spiral steeple
#

Normally the 401 from top.gg for invalid tokens isnt a cloudflare rejection I dont think

restive otter
#

Yep

spiral steeple
#

can you show me what it says?

restive otter
#

It says cloudflare tho

#

0|projectb | server: 'cloudflare',
0|projectb | 'cf-ray': '5abb70c919671752-FRA'
0|projectb | },
0|projectb | ok: false,

solar spoke
#

Send code

restive otter
#

0|projectb | Error: 401 Unauthorized
0|projectb | at IncomingMessage.<anonymous> (/root/projectbump/node_modules/dblapi.js/src/index.js:118:25)
0|projectb | at IncomingMessage.emit (events.js:327:22)
0|projectb | at endReadableNT (_stream_readable.js:1221:12)
0|projectb | at processTicksAndRejections (internal/process/task_queues.js:84:21) {
0|projectb | raw: '{"error":"Unauthorized"}',
0|projectb | body: { error: 'Unauthorized' },
0|projectb | status: 401,

solar spoke
#

Exclude secret code tho

#

That's an error not code

spiral steeple
#

^ show the part where you made a new instance of dbl (usually like new DBL(x, {...}, client) dont show the token though

#

and if you're sure the token is correct, regen it and try again

restive otter
#

@spiral steeple everytime I press refresh on top gg it saying different token every time

solar spoke
#

ofc

restive otter
#

Why?

solar spoke
#

Same happens with a discord api token

#

So you can revoke older tokens

restive otter
#

Right so how do I know what to use

solar spoke
#

Generate new one

restive otter
#

If it changes everytime lol

solar spoke
#

paste it

#

You can use multiple

#

Don't bother the new token on refresh

restive otter
#

I clicked regen

#

And now I paste that right?

solar spoke
#

int he code yes

restive otter
#

I have to paste the token twice

#

One in bot.js and one in index.js

solar spoke
#

It needs to be placed in the header of the http request

restive otter
#

It is

#

I get unauthorized every time

solar spoke
#

Show your code, but exclude the token

restive otter
#

Which one bot js or index js?

solar spoke
#

idk where you do the request

restive otter
#

I might just be tempbanned from the api

#

Hence when I need a staff member

#

As it worked earlier on and now it's not at all

solar spoke
#

@spiral steeple This guy

restive otter
#

@solar spoke well you arent listening are you ......

solar spoke
#

You didn't send your code, we asked 3 times

restive otter
#

I've already said 50 times

#

Its nothing to do with my code..m

#

It was working earlier today

#

And then I regen and put it on my main bot and now It wont connect

jaunty plank
#

is the issue a different platform?
ie, you where on windows, moved to linux, and the issue came up?

gentle pewter
rancid cove
#

wtf is an atomic boolean

rapid kettle
#

ikr

gentle pewter
#

Bruh

plush ore
#

Atomic boolean lmao

jaunty plank
#

💥

tawdry ferry
#

It's like an atomic wedgie but backwards

ocean aspen
#

Someone api for NimoTV?

tawdry ferry
#

This channel is specifically for the DBL api

ocean aspen
#

ah

#

sorry

hollow flame
#

Can someone help me in dbl webhook please

#

Its showing me this

#
1|dbl  | 209.97.134.24 - - [30/Jun/2020 21:56:23] "POST /dbl HTTP/1.1" 404 -
1|dbl  | 209.97.134.24 - - [30/Jun/2020 21:57:23] "GET /dbl HTTP/1.1" 404 -
1|dbl  | 209.97.134.24 - - [30/Jun/2020 21:57:46] "POST /dblwebhook HTTP/1.1" 404 -
1|dbl  | 209.97.134.24 - - [30/Jun/2020 21:58:46] "GET /dblwebhook HTTP/1.1" 404 -```
sullen nymph
#

What's your webhook_path

molten galleon
#

Does the vote event trigger at exactly the same time someone votes?

#

Or it takes time?

green mantle
#

Normally only a couple secs delay

novel laurel
#

so I tried adding the API to my bot's main class

#

this happened

#
Exception in thread "main" java.lang.NoClassDefFoundError: org/discordbots/api/client/DiscordBotListAPI$Builder
        at com.Main.main(Main.java:23)
Caused by: java.lang.ClassNotFoundException: org.discordbots.api.client.DiscordBotListAPI$Builder
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        ... 1 more
crude plinth
#

dbl isn`t working

peak patrol
#

u trying to import dbl into dbl bruh

crude plinth
#

It was working before 😄

peak patrol
#

whats the error

#

exactly

crude plinth
#

idk

#

nothing?

peak patrol
#

than why u asking whats wrong in here

#

if thw code is running

crude plinth
#

The Bot dont tell me anything....

peak patrol
#

what it is supposed to tell u

crude plinth
#

ahhh 😄

novel laurel
#

gonna repost

crude plinth
#

ehmmm Create parameter

novel laurel
#

?

peak patrol
#

code pls

#

@novel laurel

novel laurel
#

hold on

#

my bot has officially ceased to respond to my commands

#

and will not turn off

peak patrol
#

@novel laurel it may be running in background

novel laurel
#

yes iti s

#

and it won't respond to my kill switch

crude plinth
#

@peak patrol ehmmm, is this normal that dbl isnt in the main extensions?

novel laurel
#

so I don't know how to turn it off

#

it's stuck in gulag rn

peak patrol
#

task manager boi

novel laurel
#

this isn't on my pc

crude plinth
#

i ! am stupid at the moment ...

novel laurel
#

it's on a vm

crude plinth
#

😄

peak patrol
#

oh

novel laurel
#

and it's running on tmux

peak patrol
#

@novel laurel which os

novel laurel
#

so I have no clue how to stop tmux

#

debian

peak patrol
#

su

#

terminate

#

i guess

novel laurel
#

searching up how to do that now

peak patrol
#

best

#

@crude plinth have u installed dbl library

crude plinth
#

should be

peak patrol
#

try pio install

#

pip*

#

or updating

novel laurel
#

ok

#

I can send code now

#

I found out how to kill tmux sessions

#

basically

#

@peak patrol which parts of the code should I send

#

the part where I'm initializing api or where I'm calling setStats()?

peak patrol
#

which is causing issue

novel laurel
#

no clue

#

on my computer it runs perfectly fine

#

but on my vm

#

it goes dookie nuts

peak patrol
#

maybe cause of os difference

novel laurel
#
Exception in thread "main" java.lang.NoClassDefFoundError: org/discordbots/api/client/DiscordBotListAPI$Builder
        at com.Main.main(Main.java:23)
Caused by: java.lang.ClassNotFoundException: org.discordbots.api.client.DiscordBotListAPI$Builder
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        ... 1 more
#

this doesn't seem like an OS issue

peak patrol
#

mhmm

#

send me code from where the tread started

#

thread*

novel laurel
#
new Thread(()->{
            while(true) {
                int servers = j.getGuilds().size();
                j.getPresence().setActivity(Activity.playing("!bwhelp | " + servers + " servers"));
                api.setStats(servers);
                try{
                    Thread.sleep(3000);
                }catch(InterruptedException e){
                    e.printStackTrace();
                }
            }
        }).start();
#

i.e. every 3 seconds update status

#

but that's clearly not it, it's probably the initialization

#

because it says it's missing Builder

#

could it be a missing import statement?

peak patrol
#

maybe

#

or something isnt defeind

#

properly

novel laurel
#

man that's bs

#

changing the operating system shouldn't do a damn thing

#

well nevermind

#

I can confirm it's not the operating system, just something goes wrong when I try to run the jar I build

#

@peak patrol

crude plinth
#

@peak patrol Normaly my friend make the stuff with the vps, server

#

I have no idear

novel laurel
#

neither do I

peak patrol
#

my online class started srry i wont be able to reply try searching google or ask for help at stackoverflow or r/codingzombie@crude plinth @novel laurel

novel laurel
#

ok

#

thanks anyway, mate

crude plinth
#

okay @peak patrol see yea

modern steeple
#

@restive otter

radiant fossil
#

api nasıl kurulur

restive otter
#

@radiant fossil Bu kanal sadece top.gg API'si ile alakalı.

radiant fossil
#

ok

potent dune
#

can i know from u the discord server name plz?

strange turtle
#

what

potent dune
#

server name i think i joines the wrong

sullen nymph
#

Maybe

potent dune
#

yes can u tell me the name

sullen nymph
#

-api

abstract mothBOT
abstract mothBOT
#

tickNo This user has no bots

full elk
#

-api

steel hawk
#

Is it just me or are vote webhooks taking a really long time

jaunty plank
#

They take a few minutes

#

Is that a long time?

steel hawk
#

yes

#

I have vote locked commands so users think that the bot is broken since the webhook hasnt arrived yet

knotty garnet
#

no it's not normal, webhooks normally take 1-2 seconds after vote

#

top.gg has been a bit sluggish regarding the api recently

viral jewel
#

-api

jaunty plank
#

Api is a mod only command

knotty garnet
#

and that was a very poor minimod attempt

gentle pewter
#

LOL

tepid harness
#

if i want to test my webhook with reqbin

#

how would i do that

#

is it a post request

#

using basic auth

sullen nymph
#

A POST request with Authorization header containing the value from Authorization field on the website

tepid harness
#

ok

#

i tested it on reqbin and it works

#

but the DBL test doesn't

sullen nymph
#

Same port and everything?

tepid harness
#

yes

#

copied the URL from DBL

vapid cape
#

where is your bot hosted?

#

also did you save before testing?

#

what url did you use?

tepid harness
#

it's hosted on a VPS

#

i saved before testing, yes

#

i copied the URL from the code into the DBL URL

green mantle
#

its not 0.0.0.0 is it

tepid harness
#

no

#

it's 172.something

green mantle
#

eh okay that fine

#

are your ports open on the FW

tepid harness
#

yeah

#

it works on reqbin

#

i copied the address, authentication, and made my own content which fit the DBL format

#

and it works

quasi mountain
#

i checked with Galaxygate and no firewall rules are needed

jaunty plank
#

yeah GG doesnt add that stuff for ya

quasi mountain
#

@jaunty plank so is there any rules that need to be added. do you know of any specifics

jaunty plank
#

it should be completly open on a fresh install for their VPS's on linux

#

Windows may be a different story

quasi mountain
#

k gotcha

#

@tepid harness you still there

#

is there anyway to log whats happening

tepid harness
#

i'm not getting anything

#

hell i don't even know if the webhooks are sending

quasi mountain
#

hmmm

vapid cape
#

@tepid harness add http:// to the url

tepid harness
#

already have it @vapid cape

vapid cape
#

so your full url is http://xxx.xxx.xxx.xxx:5000/dblwebhook right?

tepid harness
#

Yes

#

I changed the port to 3259 tho

quasi mountain
#

and you sure galaxygate doesnt block that specific port

#

why did you pick that port?

tepid harness
#

Long explanation

#

It doesnt block it

#

Because reqbin works

quasi mountain
#

did you ever try port 5000 to test?

tepid harness
#

Yes

quasi mountain
#

maybe someone might be willing to team view to you. You are going to have to do some more digging to get the help

#

anyone willing to work with Humanoid some more. He can provide code snippets or anything else that you need to help troubleshoot it

#

im just trying to help him find help LOL 🙂

vapid cape
#

galaxygate doesnt block ports, im on galaxygate too

quasi mountain
#

@tepid harness is there anymore information or code snippets you can provide

tepid harness
#

I mean i basically copied

#

From the examples

idle sparrow
#

? (node:389508) UnhandledPromiseRejectionWarning: Error: 401 Unauthorized
? at IncomingMessage.<anonymous> (C:\Users\ARDA\Desktop\Discord\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:389508) 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: 3)
?

#

check if member dbl voted error

median badger
#

Are you using a correct token

#

Which you cant access

#

As your bots not verified

hasty heath
#

very new here, how would I use discord.py and this api to get the votes and reward users when they vote?

restive otter
#

^^^ I’m with you on this was going to ask the same lmao

severe osprey
#

^^^^ Lol same

green mantle
#

@severe osprey @restive otter @hasty heath

Look at the dblpy section on the API page it shows how to use the dblpy module

molten galleon
#
[dblapi.js autopost] The provided client is not supported. Please add an issue or pull request to the github repo https://github.com/DiscordBotList/dblapi.js

charDerPP

#

I had just passed the Discord.Client instance

jaunty plank
#

Eris?

molten galleon
#

Discord.js

jaunty plank
#

Intresting

#

The logged in client?

#

I'm not sure if it needs to be logged in

#

🤔

#

If you can't figure out the auto posting, you can manually post stats too

molten galleon
#

Yeah I know, but the vote event doesn't even get triggered either

#

I want to use that event to activate daily reward :v

#

wait wait

#

no.. the construction is right djthink

vapid cape
#

@molten galleon you need to pass in the instantialized client

molten galleon
#

well it is

vapid cape
#

as second or third parameter

molten galleon
#

I'm passing it as third param

vapid cape
#

show code?

molten galleon
#
const dbl = new DBL(config.dbl, { webhookAuth: auth, webhookServer: server }, client);
vapid cape
#

and client is new Discord.Client() ?

molten galleon
#

yeah

#

does it have to be logged in?

vapid cape
#

yeah

#

but i mean, you dont need to login before passing it

#

as long as you login somewhere

#

what version of djs btw

molten galleon
#

12.1.1

#

yes I do login charDerPP

vapid cape
#

how about console.log(client) the line before?

molten galleon
#

I'm sure client is fine, but still I'll do

#

Just updated Discord.js version to 12.2.0, still :v

vapid cape
#

do you do some kind offloading or require discord.js any differently than normal?

molten galleon
#

nope

vapid cape
#

this is how dblapi checks for supported libs

#

whats your dblapi version btw

molten galleon
#

2.4.0

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

both are required normally 🤷‍♂️

vapid cape
#

wtf lol

#

@arctic arch any ideas?

jaunty plank
#

Just do manual posting

molten galleon
#

Okay..

#

And what about vote event? It doesn't trigger

vapid cape
#

try doing console.log(client instanceOf Discord.Client)

molten galleon
plush ore
#

I've had a similar kind of bug with a newer version of d.js, but it wasn't with dbl api

vapid cape
#

what about instanceOf Discord.exports.Client

#

wait no

#

client instanceof require.cache(require.resolve("discord.js")).exports.Client

molten galleon
#

Discord.exports is undefined

#

hmm

#

Does it matter if I do that in eval?

vapid cape
#

shouldnt matter

molten galleon
#

and any idea why do I not receive vote updates?

#
dbl.webhook.on('vote', vote => {
  db.client.set(`vote_${vote.user}`, true);
});

I tried logging, there's no log :v
And webhook.on ready event logs fine

vapid cape
#

did you setup your url and auth in top.gg?

molten galleon
#

uh, wait

arctic arch
#

so it's a d.js client but fails the check?

vapid cape
#

apparently yes

molten galleon
#

yea

vapid cape
#

although instanceof checks work fine

molten galleon
#

did you setup your url and auth in top.gg?
@vapid cape ops I hadn't done that, did it now, and does it affect the auto post thing? i guess no

vapid cape
#

no, webhooks are independent

molten galleon
vapid cape
#

when you did console.log(client) did you scroll up the log and check the object name?

#

did it say Client {

molten galleon
arctic arch
molten galleon
#

that above screenshot is a log from app.js just a line above DBL is insanciated

vapid cape
#

yeah but try logging that

molten galleon
#

I did log that, without eval

arctic arch
#

msg.client could be different

#

¯_(ツ)_/¯

vapid cape
#

what if you do ```js
let client;
let dbl = new DBL("token",{opts},client = new Discord.Client())

molten galleon
#

...

#
console.log(client);
const dbl = new DBL(config.dbl, { webhookAuth: auth, webhookServer: server }, client);
#

aaand that ss is the logged client

#
const client = new Discord.Client();

my client is declared like this charDerPP

#

config.dbl is the token, if it matters

vapid cape
#

the only thing i can think of is that somehow there are 2 versions of discord.js loaded, in two different paths, and each is being required from a different path

#

try console.log(Object.keys(require.cache)) after the new DBL line

#

see if somehow there are 2 paths for discord.js in the wall of text

molten galleon
#

alright

#

Ugh I cannot read through that fkin long array

vapid cape
#

lmao

#

if its formatted weirdly, try .join("\n")

molten galleon
#

and uhhh

#

I didn't get that error

vapid cape
#

LOl

molten galleon
#

wtf

jaunty plank
#

Magic

molten galleon
#

does that log fix it?

#

its super weird

#

logs have nothing to do with it

vapid cape
#

remove the log and check again

molten galleon
#

okay

#

LMFAO

#

no error

vapid cape
#

lmao

#

your node is drunk, tell it to go home

plush ore
#

Honestly this kind of weird shit happens all the time

#

as soon as you add debug code it fixes itself

vapid cape
#

developer hell

molten galleon
#

scarascared but how can it happen

plush ore
#

ask mr compiler

arctic arch
#

ask mr interpreter

plush ore
#

node should be a compiled language too 🙂

#

anyways off topic

arctic arch
#

well its not

#

and will not

molten galleon
#

is there some sort of event which triggers when I click "Test" on edit page? if so, which one is it?

arctic arch
#

the vote event

molten galleon
#

didn't trigger then

vapid cape
#

where is your bot hosted

molten galleon
#

digi ocean

vapid cape
#

how did you format your url

molten galleon
#

oh wait it was url

arctic arch
#

url on the site pointing to the correct ip?
port open on firewall?
auth thing correct on both ends?

molten galleon
#

got it

#

I used the domain, but without correct port, while webhook server was running on port 5000

#

and now its fine, I changed port

silk zenith
#

Did field titles and footers become bold?

vapid cape
#

yes (wrong channel btw)

jagged mantle
#

can i use a webhook to store votes or do i need to use console.log?

jaunty plank
#

Webhooks are used to push data, not pull it

#

Console.log is used to log data, not store it

steel hawk
#

This is actually stupid

#

The vote webhook took 10 minutes to arrive

austere notch
#

How long does it take for top.gg to post to my webhook when someone votes?

jagged mantle
#

pls help, vote isnt defined, hole embed code thing.

const VoteEmbed = new Discord.MessageEmbed()
  .setTitle(`e`)
  .setColor("#c75dc9")
  .addField(`Voter`, vote.user)
  .addField(`Time`, vote.time)
  .addField(`Weekend doubler`, dbl.isWeekend())
  .setFooter("**Dbl** voting system. ");

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

  webhookClient.send(`${VoteEmbed}`, {
    username: `Spider Vote`,
    avatarURL:
      "https://cdn.discordapp.com/icons/702134225528291368/66d4c03d4c8d064fc884ba70d32134f6.webp",
    embeds: [VoteEmbed],
  });
});```
restive otter
#

seriously?

knotty garnet
#

you've put the const in the wrong place

#

like, REALLY wrong

jagged mantle
#

how is it wrong?

#

I start embeds of like that every time I use one

knotty garnet
#

you can't use a variable outside of its scope

#

it doesn't work like that

#

{} are walls

#

what starts inside brackets die inside those brackets

restive otter
#

hmm

austere notch
#

What can cause a long delay on my webhook recieving the post request? (takes up to 10 mins)

knotty garnet
#

server-side issues

vapid cape
#

@slim smelt did you add your client?

#

new DBL("token",client)

#

is it the same client you login with?

#

ie ```js
client = new Discord.Client()
dbl = new DBL("top.gg token",client)
...
client.login("discord token")

#

all in your main file

#

@slim smelt can i see full code?

#

@slim smelt you're using the wrong client

#

you're doing bot = new Client() and using new DBL("token",client)

#

your client is bot not client

#

so you have to do new DBL("token",bot)

#

and remove all those extra client lines

restive otter
#

Who has the giveaway code lines?

jaunty plank
#

its against the rules for us to give you copy paste code @restive otter

#

ie spoonfeeding

restive otter
#

My corrector tells me that n against the rules for us to give you copy the paste code

#

I didn't understand what you said

jaunty plank
#

we are not allowed to give you an exact answer, we can point you in the correct direction however

restive otter
#

Ok

brisk hornet
#

i need help with this, the api is telling me that i have not voted

20:49:02.438 VoteCommand     ERROR  uid: 214829164253937674
20:49:02.439 VoteCommand     ERROR  hasVoted: false

When i have clearly voted

{"username":"fernandopal","discriminator":"8931","id":"214829164253937674","avatar":"c9a22e30ba58b379e273c735e4e06856"}

I'm using the java library and the code provided in the github site

api.hasVoted(member.getId()).whenComplete((hasVoted, e) -> {
    LOGGER.error("uid: " + member.getId());
    LOGGER.error("hasVoted: " + hasVoted);
});

Its so frustrating bc idk what's wrong with it

#

(im logging it as an error just for testing, ignore that xD)

jaunty plank
#

the api is quite slow recently

#

ive heard people talking about it taking 30 minutes.

#

for the webhook to send*

brisk hornet
#

(its 20:57 rn in my country)

brisk hornet
solar spoke
#

People use Discord.java? -Nice

knotty garnet
#

discord.java?

#

what kind of cursed thing is this?

solar spoke
#

Java Discord API

#

I call it discord.java xd

knotty garnet
#

is that JDA?

solar spoke
#

yes

knotty garnet
#

anyway, out of this channel's topic

#

and yes, I use

brisk hornet
#

im getting frustrated with that problem

#

i guess i can only wait

obsidian tide
#

i just got a 503 backend fetch error..

#

nvm that was one time

#

i feel like it was because cloudflare

restive otter
#

Top show the amount of servers I have on my discord bot, all I need is the constructor with it's options and the client added correct?

#

Or would I have to use the postStats method everytime the guildCreate event is sent. (discord.js)

willow spindle
#

If you add your client to constructor, it will automatically post

#

@restive otter

gentle pewter
#

Hold up, you can make it so people can vote through the bot?

hot hatch
#

yes

gentle pewter
#

Sick

sullen nymph
#

Huh?

bitter terrace
#

does dblapi.js work with sharding?

median badger
#

yes it does

bitter terrace
#

I need to update manually or I can do like, pass something in the constructor for auto server count posting?

vapid cape
#

if you give it your client, it should post automatically

bitter terrace
#

yeah but while sharding, do I give client to it in all the spawned processes? 🤔

vapid cape
#

thats one way of doing it

#

each process will send its own guild count with its shard id, and top.gg will reassemble it in their backend

#

another way of doing it is to use fetchClientValues or broadcastEval to fetch all guild counts and manually send a single request, either from the sharding manager or from a single shard

bitter terrace
#

I see. I'll try the first method lol

tender ingot
trail sigil
#

-ask2ask @tender ingot

abstract mothBOT
#

@tender ingot

Don't ask to ask.
Just ask your question, it wastes time if you say "i need help" or "can someone help me?" instead of just saying what the problem is. Save your time and other people's time and just ask the question.

Please read https://dontasktoask.com/ for an explanation on why this is an issue.

tender ingot
#

@trail sigil ok

#

its ok?

trail sigil
#

like this?

tender ingot
#

@trail sigil i need vote count not server count

trail sigil
#

honestly, i dont have a clue because i dont do python lol

#

just wait for someone who can answer your question ig

tender ingot
#

Thank you it's really important to me@trail sigil

bitter terrace
#

try self.dblpy.get_bot_upvotes()

tender ingot
#

@bitter terrace can u help me with this

bitter terrace
#
import dbl
import discord
from discord.ext import commands

class TopGG(commands.Cog):
    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)
        votes = self.dblpy.get_bot_upvotes() # this is the line you need
def setup(bot):
    bot.add_cog(TopGG(bot))
#

this should work. but I am not sure at all.

sullen nymph
#

get_bot_upvotes returns a coroutine, so you need to await it

jagged sky
#

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

#

whats the url?

sullen nymph
jagged sky
#

ty

bitter terrace
#

oh yeah, forgot it needs await

restive otter
#

hey guys does anyone know how to fix this at all thanks

0|projectb | Error: 400 Bad Request
0|projectb |     at IncomingMessage.<anonymous> (/root/projectbump/node_modules/dblapi.js/src/index.js:118:25)
0|projectb |     at IncomingMessage.emit (events.js:327:22)
0|projectb |     at endReadableNT (_stream_readable.js:1221:12)
0|projectb |     at processTicksAndRejections (internal/process/task_queues.js:84:21) {
0|projectb |   raw: '{"error":"Required parameter server_count or shards missing"}',
0|projectb |   body: { error: 'Required parameter server_count or shards missing' },
willow spindle
restive otter
#
dbl.postStats(client.guilds.cache.size, client.shard.ids, client.shard.count);
setInterval(() => dbl.postStats(client.guilds.cache.size, client.shard.ids, client.shard.count), 900000);```
#

but its not missing it

#

fixed it i think lol

jaunty plank
#

The library already automatically does poststats when you start it btw.

#

And does the loop and all that

jagged sky
#

clicking on test is supposed to send get or post request on a webhook is specified?

sullen nymph
#

POST request with type key with value test in request body

sonic forum
#

How can I add people who vote to a list I have no idea how to handle api requests

knotty garnet
#

the http request that top.gg sends to your webhook will contain an user ID

#

save that ID to the desired list or fetch that ID to get the user object

sonic forum
#

Yeah how do I handle that http request

ruby blaze
#

Hey I've never used webhooks before. How would one integrate api into their bot in order to allow a voting system with reward

#

And how to define and accept data from them

knotty garnet
#

Yeah how do I handle that http request
@sonic forum the http request will contain the data either in the body (POST) or in the url (GET)

#

so all you gotta do is get the body of the request, and parse it to json

#

And how to define and accept data from them
@ruby blaze same for you

jagged sky
#

And what should you specify webhook?

#

Vps ip will do?

knotty garnet
#

you need to setup a webserver

#

like express

jagged sky
#

Then

#

I guess I'll use Django

frozen jolt
#

dbl.getVotes().then(votes => {
console.log(votes);
});
this isn't working

#

no error but doesn't console.log anything

#

ping me please

bitter terrace
#

https://top.gg/api/bots/BOTID/votes doesn't seem to be accurate. On top.gg, it says 70. But this endpoint returns an array of 41 vote objects.
Is it delayed?

#

dbl.getVotes().then(votes => {
console.log(votes);
});
this isn't working
@frozen jolt this returns an empty array for me. So I'm using the API manually.

frozen jolt
#

same

#

how are you using it

bitter terrace
#

With node-fetch

#

But that's not accurate either 🤔

frozen jolt
hasty heath
#

is there a way to test the voting to see if it works without actually voting? I do not want to wait 12 hours to test my changes

#

and do I need to specify anything for the vote? Or can this be the only dblpy code I have?

async def on_dbl_vote(data):
    print(data)```
knotty garnet
#

is there a way to test the voting to see if it works without actually voting? I do not want to wait 12 hours to test my changes
@hasty heath use the test button near the save button

hasty heath
#

ok thanks

pastel raptor
#

(d.py)
i'm assuming there's a way to do like, a vote reward feature using the API

#

could anyone give me a lead on it

#

probably this actually, isn't it

#

poggers this is gonna be fun

jagged sky
#

so i am using this webhook tester service to see what it sends

#

but its not sending anything

#

am providing the tester webhook url and then clicking on test

jagged sky
#

what is webhook_auth="" for?

sullen nymph
#

the thing after ip:port in the URL

#

must start with /

jagged sky
#

oh is it app route?

vapid cape
#

webhook_path is the route

#

webhook_auth is the authorization header

jagged sky
#
You can use this value to verify the requests are coming from us.```
#

this right?

vapid cape
#

yes

jagged sky
#

any ideas why am i not getting any requests

#

i used a webhook tester service to test but didnt work

#

now i am using a flask ngrok based web server

#

still not getting any post request from api

#

@vapid cape u have any idea whats wrong?

sullen nymph
#

@jagged sky what does your code look like

#

Thanks for correcting me, Tim

jagged sky
#

ef init(self, bot):
self.bot = bot
self.token = 'blah blah' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True,webhook_path='ngrok link ',webhook_auth="authorisation password")

vapid cape
#

which side did you test? top.gg -> webhook tester or webhook tester -> your server?

jagged sky
#
@app.route('/')
def api_root():
    return "Welcome again"

@app.route('/discord',methods =['POST'])
def api_di_message():
    if request.headers['Content-type']=='application/json':
        idk = json.dumps(request.json)
        print(idk)


if __name__ == "__main__":
    app.run(debug=True)```
vapid cape
#

you copy pasted the webhook tester url into your top.gg url?

#

did you press save before pressing test?

jagged sky
#

just copy pasted and clikced on teset

#

no

vapid cape
#

you need to save first

jagged sky
#

wait do u have to press save

#

oof

#

lmao i have been gettin the error for 2 days

#

ty

#

lemme check

vapid cape
#

you can also test your server using reqbin or postman

jagged sky
#

working

#

ty

onyx cipher
#

hi

#

i want to set up a webhook inside of my bot

#

somebody help me before i die

#

what do i put in webhook url

sullen nymph
jagged sky
#

on my pc it works

#

but on my vps

#

-bash: ./ngrok: Permission denied

bitter terrace
#

chmod +x ngrok

#

then try ./ngrok again

onyx cipher
brisk hornet
#

@sullen nymph this should be fine right?
@onyx cipher remove the slash after the port, ip:port

bitter terrace
#

before*

brisk hornet
#

that xD

onyx cipher
#

does colon need to stay?

bitter terrace
#

yes

brisk hornet
#

before*
@bitter terrace when i dont think on it i usually put it wrong

bitter terrace
#

lol

onyx cipher
#

like that?

bitter terrace
#

yeah

onyx cipher
#
    @commands.Cog.listener()
    async def on_dbl_test(self, data):

        testing = self.bot.get_channel(712639566774796298)
        await testing.send("tested")
        print("TESTED")
        print(data)
#

here is how i set up the event

#

but it still isn't printing "Tested"

#

when i test the webhook

bitter terrace
#

hmm. is it running on your pc or a server?

onyx cipher
#

pc

#

for now

bitter terrace
#

I think you need to forward port 5000 then.
you can check if your http server is accessible from this site https://www.yougetsignal.com/tools/open-ports/
just put IP and port 5000

onyx cipher
#

says its closed

#

@bitter terrace

bitter terrace
#

that's why

restive otter
#

Why did my guild counter randomly stop updating but votes work

onyx cipher
restive otter
#

He gave you a link ...

bitter terrace
#

@onyx cipher if you want to know how to do port forwarding, you need to search on google. it depends on your router etc.

onyx cipher
#

so much for checking votes

#

im dying

bitter terrace
#

lol

onyx cipher
#

ok what if i had to do this on my VPS?

bitter terrace
#

then you'd just need to allow the port on your firewall

onyx cipher
#

i have no clue about these weird networking terms

bitter terrace
#

um

#

it's just allowing/denying connection to a port

onyx cipher
#

ok so my bot is on a debian machine

#

how do i perform that ritual

bitter terrace
#

I think there's ufw for that

#

ufw --version

onyx cipher
#

oh wait lmao

#

its ufw

bitter terrace
#

xD

onyx cipher
bitter terrace
#

apt-get install ufw

onyx cipher
#

i am weak @bitter terrace

bitter terrace
#

hm

onyx cipher
bitter terrace
#

oh

#

sudo ufw

#

sudo ufw --version

onyx cipher
#

ufw 0.36

#

alr what now

bitter terrace
#

ok

#

sudo ufw status

onyx cipher
#

inactive

bitter terrace
#

ok

#

sudo ufw enable

#

sudo ufw allow 5000

onyx cipher
#

done

#

what happens now

#

is it done?

bitter terrace
#

sudo service ufw restart

#

then it should work

onyx cipher
#

@bitter terrace wait

#

i can't ssh into my machine anymore

#

what the fuck

#

what do i do now

#

fuck

jaunty plank
#

Ufw even gives that warning

#

🤔

onyx cipher
#

so how do i fix this

#

its gone huh

jaunty plank
#

Was your only way into the vm via ssh?

onyx cipher
#

yes

jaunty plank
#

Try Google then

onyx cipher
#

do not tell me its all gone please

jaunty plank
#

Let's hope not

onyx cipher
#

holy fuck

#

why me

bitter terrace
#

hm that never happens to me. is it on GCP? @onyx cipher

onyx cipher
#

YES

#

my gcp died

#

@bitter terrace

bitter terrace
onyx cipher
#

@bitter terrace worked

#

now i can't setup webhook huh?

bitter terrace
#

webhook should work on that vps now

onyx cipher
#

wow

#

it wont

#

i mean why

#

@bitter terrace port 5000 us allowed right?

bitter terrace
#

yes it is

restive otter
#

Why doesnt my guild count work

trail sigil
#

-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.

trail sigil
#

ensure it is all setup properly, as show in the docs

#

if it is... then what errors are you getting?

onyx cipher
#
@commands.Cog.listener()
    async def on_dbl_test(self, data):

        testing = self.bot.get_channel(712639566774796298)
        await testing.send("tested")
        print("TESTED")
        print(data)
#

@bitter terrace this must print "Tested" when i test the webhook right

restive otter
#

No errors vote rewards are even working

bitter terrace
#

if everything else is right, yeah

onyx cipher
#

this is my url

#

does it look fine?

#

@bitter terrace (sorry for the ping , im in a hurry)

bitter terrace
#

np

onyx cipher
#

ok does the url look fine

bitter terrace
#

and yeah it looks good

onyx cipher
#

THEN WHAT IS BOTHERING

#

this webserver set up is murdering me

bitter terrace
#

lol

#

go back to the yougetsignal site

#

check if the port is open

onyx cipher
#

about to murder myself

#

what the fuck is going on

jaunty plank
#

Lol

bitter terrace
#

lol

#

your bot is on right?

onyx cipher
#

yes

#

i mean no

#

it is now , just turned it on

#

@bitter terrace

bitter terrace
#

ok check that when the bot is on

onyx cipher
#

should i restart my machine?

bitter terrace
#

nope. it should work

#

oh try this

#

netstat -tulpn

#

it should tell you which ports are open

distant plover
#

Sup

#

I have a question regarding the webhook

#

when creating the DBLClient, what value do I insert in the webhook_path section?

jaunty plank
#

Whatever you want the path to be

distant plover
#

It doesn't matter?

jaunty plank
#

Not really.
Something short and sweet helps

#

But it really doesn't matter

bitter terrace
#

doesn't matter what you choose. but you must use the same path on top.gg webhook url field

jaunty plank
#

^

onyx cipher
#

i really need to set up this webhook

jaunty plank
#

Its just the url path they push data to

onyx cipher
#

im literally dying rn

#

i been trying to do this for the past 4 hours

distant plover
#

?

jaunty plank
#

The path part is just the something

The entire thing is the whole url

onyx cipher
#

no / between ip and :port

distant plover
#

ohhh I got you

#

ty

onyx cipher
#

do i only have to use port 5000?

jaunty plank
#

You can use any port

#

Any available port

onyx cipher
#

22?

jaunty plank
#

22 is an ssh port

#

Its not available

#

Unless you move ssh

onyx cipher
distant plover
#

you should go for a port higher than 1024

jaunty plank
#

^ all the low ones are commonly used

distant plover
#

Yep

onyx cipher
#

port 5000 isn't opening

#

even tho

jaunty plank
#

Do you have multiple firewalls on?

onyx cipher
#
sudo ufw enable
sudo ufw allow 5000
#

i did all this

#

but port 5000 is still fucking with me

bitter terrace
#

@onyx cipher it only stays open when your bot script is running

onyx cipher
#

ok

#

so if i do python3 bot.py

#

it stays open?

bitter terrace
#

yeah

#

then when you close python, the port closes again

onyx cipher
#

umm let me see

#

will it still work if i run it using tmux?

bitter terrace
#

yes

#

just needs to stay on

onyx cipher
#

lets see

bitter terrace
#

k

onyx cipher
#

im dead

bitter terrace
#

hm

#

and if you do netstat -tulpn?

onyx cipher
bitter terrace
#

oh I remember now

#

GCP has its own extra firewall

onyx cipher
#

so what now?

bitter terrace
#

I always allow all on that. Let me get a screenshot of that

#

ok here

onyx cipher
#

what?

#

where the fuck is that

#

@bitter terrace

bitter terrace
#

gcp

#

wait

#

VM Instances

empty jay
#

Who is able to help with my webhook? Nothing is making it work for tests

#

or when I vote...

#

it won't console log with the example code from the api docs when I input my info in

bitter terrace
#

is it running on your pc? or a vps?

empty jay
#

pc

#

sorry about the slow response lol was distracted by my 3d printer

bitter terrace
#

you will need port forwarding if you're using your pc

empty jay
#

yeah idk how to do that 🙃

inner tapir
#

scuffed way - use google cloud functions as a webhook lul

empty jay
#

?

bitter terrace
#

or use ngrok

empty jay
#

I've never heard of that...is it free?

bitter terrace
#

yes

empty jay
#

awesome I'll look into it but I'll probably be back with questions

bitter terrace
#

ok

empty jay
#

@bitter terrace sorry for the ping...ok so I got it fired up and have this on my screen...what do I do now? https://prnt.sc/tbtsq8 there's more above but idk if it's secret so I'm not showing it lol

Lightshot

Captured with Lightshot

bitter terrace
#

lol

#

you're using the js library right?

#

@empty jay also, np for ping

empty jay
#

yes js

bitter terrace
#

ok, so you have a http server running right?

empty jay
#

I really appreciate this...I've been trying for like a month and just can't get it without using a host lol

#

whatever that picture is is what I have so far lol

#

do you mean a local webserver?

bitter terrace
#

yeah, like the express or http module

empty jay
#

i did ngrok http 80 and that stuff popped up

#

oh wait...where will it say someone voted?

bitter terrace
#

it will send a signal(webhook request) to your program

empty jay
#

yeah I'm lost lol

bitter terrace
#

um

jaunty plank
#

you know how an api, you send a request to get data?

a webhook is an api, but the opposite.
data gets pushed to you, rather than you pulling it

#

the official library will make the webserver(webhook) for you, if you configure it to

sullen nymph
#

-api

abstract mothBOT
sullen nymph
#

Also, no @cobalt canyon

cobalt canyon
#

ok

sullen nymph
#

Begging for boosts is not allowed

cobalt canyon
#

peymmane

#

vizqirt

#

gotes

austere notch
#

What can cause a long delay on my webhook recieving the post request? (takes up to 10 mins)

#
const server = createServer((req, res) => {
    if (req.url === '/dblwebhook' && req.method === 'POST') {
        if (config.dbl !== req.headers.authorization) return _returnResponse(res, 403)
        if (req.headers['content-type'] !== 'application/json') return _returnResponse(res, 400)

        let data = ''
        req.on('data', (chunk) => data += chunk)

        req.on('end', async () => {
            if (data) {
                try {
                    const value = JSON.parse(data);
                    if (value.query === '') value.query = undefined;
                    if (value.query) value.query = parse(value.query.substr(1))


                    return _returnResponse(res, 200, 'Webhook successfully received')
                } catch (e) {
                    return _returnResponse(res, 400)
                }
            } else {
                return _returnResponse(res, 400)
            }
        })
    }
})

server.listen(5000)

function _returnResponse(res: ServerResponse, statusCode: number, data?: string) {
    res.statusCode = statusCode
    res.end(data);
}``` my webhook
jaunty plank
#

the api has been kinda slow recently

#

heard reports of over 20 minutes

austere notch
#

yeah

#

It's taking me up to 10 minutes

restive otter
#

Was fine these few days

#

Last week it was too delayed

frail lynx
#

-api

little robin
#

I couldn't do the voting system. is there anyone he can help??

pastel raptor
#

lol same, im not even sure where to start

jaunty plank
#

What library are you using?

pastel raptor
jaunty plank
#

Covers how to use the webhook

pastel raptor
#

already have it up

jaunty plank
#

Looks like you just set the webhook path auth and port

sullen nymph
#

What does your DBLClient look like

pastel raptor
#

my DBLClient?

#

uhh nothing rn

#

:D

sullen nymph
#

Are you hosting any webhook rn

pastel raptor
#

nope

#

hence idk where to begin

sullen nymph
pastel raptor
#

yea

#

like i see that i need

self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)```
this
sullen nymph
#

Aye

#

Make sure port 5000 is open and enter http://ip:port<webhook_path> on yout bot's top.gg Edit page

#

so something like http://public_ip:5000/dblwebhook

pastel raptor
#

i uh

#

i dont get that part

#

;;

vapid cape
#

where is your bot hosted?

pastel raptor
#

on a vps

#

would i have to use that ip?

vapid cape
#

yes

grim dew
#

ehm is it more clever to post on guild join/leave

#

or in a loop?

sullen nymph
#

a loop

restive otter
#

What do I replace version with, in the dbl api

glossy ice
#

Sa

jagged sky
#

i am able to recieve webhook on my windows pc

#

but when i follow same procedure on ubuntu vps

#

its not recieving anything . do i have to provide any special permissions?

balmy hamlet
#

are you giving the correct ip

#

and path

tawny void
#

Hi just wondering about webhooks as well, I have set up a post route, and I can make a request to that myself but when I click test on the webhook on my bot it doesn't work Thanky

jagged sky
#

yes corect ip and port

#

just basically isnt recieving post request on ubuntu

#

on my pc windows i get post request but on my vps ubuntu it doesnt work

jagged sky
#

502 Bad Gateway

#

what could be causing this on ubuntu

restive otter
#

Hello

#

I need help pls

jagged sky
#

POST /discord 502 Bad Gateway

#

anything i could do to solve this?

restive otter
#

where is it occuring

jagged sky
#

on mine ofc

restive otter
sullen nymph
#

0 - not voted
1 - voted

restive otter
#

Thx

#

My code is```js
let fetched = await fetch("https://top.gg/api/bots/697318252744933406/votes").then(async res => await res.json())
return "Votes: "+fetched.length

this isn't sending the total votes of the bot it just says ``"undefined"`` when i just done length it says ``"[Object object]"``
sullen nymph
#

eee are you sending top.gg token in headers?

restive otter
#

no

#

Should i sent it too?

sullen nymph
#

yes

restive otter
#

okay thx

#

how to add my token at body?

fetch("https://top.gg/api/"+client.user.id+"/votes", {
        headers: { 'Content-Type': 'application/json' }
    }).then(res => res.json())

i mean what header key i need to add for my token
"What is here?": "my token :)"

sullen nymph
#

Authorization

willow spindle
#

cache

restive otter
#

Oof

#

Wdym

spiral steeple
#

doubt cache would be 200 off

jaunty plank
#

they can be

restive otter
#

;-;

jaunty plank
#

discord can cache things for months

spiral steeple
#

It's not a discord cache though...

jaunty plank
#

ye, but caches can last very long periods of time

#

🤔

#

its been 5 days since voting reset

#

those 200 votes, coulda happened today

spiral steeple
#

And what does that have anything to do with top.gg and a value in the embed description

jaunty plank
#

no idea

#

🤔

#

how are you getting your values pika

spiral steeple
#

my point exactly, it isnt a discord cache thing. It could be top.gg cache though

jaunty plank
#

for the command

restive otter
#

Just that value see the code

jaunty plank
#

my point was caches can last long periods of time

#

not that discord and top.gg caches are related

sullen nymph
#

556 monthly votes and 1021 total votes returned from the API (/id)

restive otter
#

Hm

spiral steeple
#

You could just use a GET to the bot endpoint instead of using .length

#

because /votes is oddly delayed

sullen nymph
#

317 users voted in last 12 hours (/votes)

restive otter
#

Wont show monthly?

sullen nymph
#

You're sending a request to /:id/votes which returns votes for last 12 hours

spiral steeple
#

/votes doesnt do monthly that's user_id/check mb, but it's still weird :P

restive otter
#

Then other?

spiral steeple
#

/bots/bot_id and monthlyPoints

sullen nymph
#

/:id returns a JSON where monthlyPoints key returns monthly votes

restive otter
#

Thx

#

um

median badger
#

wrong endpoint

#

its api/bots/

restive otter
#

bot is giving error

#

/bot is error

{"error":"Not Found"}
median badger
#

its bots

restive otter
median badger
median badger
#

yes

#

thats it

sullen nymph
#

that's a JSON

restive otter
#

api/bots ?

sullen nymph
#

yes

median badger
restive otter
#

thx

#

but it doesnt show monthly users voted

median badger
#

psure its monthly points

restive otter
#

wait

#

Thx

sullen nymph
#

monthlyPoints

restive otter
#

Thx

median badger
#

i like how firefox shows json

sullen nymph
#

ikr

jaunty plank
#

all the browsers do, dont they?

sullen nymph
#

Not really, Firefox has a special way of processing JSON

#

there's also JSONs in arrays

tawny void
#

sorry still got a problem with webhooks, does the test feature actually work? I cant seem to get the request

median badger
#

it does work

tawny void
#

does anyone here use express for their route? that could have a quick check of my code :P

#

I can post to it and access the route but when i hit the big ol' test button it doesnt work :/

hasty heath
#

can I use my domain as a webhook? If so how?

#

or does top.gg provide a webhook link?

sullen nymph
#

your domain

#

as long as there's code to handle the requests coming from top.gg, you can use your machine's IP directly

hasty heath
#

okay

#

how would I do that? Is there example code in the api website?

sullen nymph
#

There's official libraries with examples that you can use

#

you can dig around with the source code if you don't want to use them

hasty heath
#

does dblpy support rewrite? It looks like the code is for non rewrite discord.py

sullen nymph
#

Latest dblpy supports 1.0.0+ only :^)

hasty heath
#

okey dokey

#

sorry for so many questions, what would my webhook url be if it is on my vps? Just the ip of the system?

jaunty plank
#

yeah

#

the public ip

hasty heath
#

so ipv6?

#

wait nvm

#

I don't have a private ip on it so

jaunty plank
#

you dont have an internal ip?

hasty heath
#

no I do, it is the same as public

jaunty plank
#

o weird

#

i didnt even know that was possible

hasty heath
#

I guess I must have made my code wrong, nothing happened :P

#

then again it is just the default code but with my token

jaunty plank
#

you need to tell it to make the webhook by setting the parameters iirc

#

const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
for example with js

hasty heath
#

yeah, it does that

#

self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='PASSWORD', webhook_port=5000)

jaunty plank
#

then the url will be
pubip:port/dblwebhook