#topgg-api

1 messages ยท Page 82 of 1

wide sigil
#

Do I need to do anything to my server?

#

like make the port listening

sullen nymph
#

which events do you have in your top.gg cog

wide sigil
#

or something

sullen nymph
#

vote != test in dblpy

wide sigil
#

what?

#

oh

#

oof

#

how do I test vote then?

#

and what does test do?

sullen nymph
#

Use on_dbl_test

#

It's just a fake vote

wide sigil
#
@commands.Cog.listener()
    async def on_dbl_test(self, data):

        print("test vote")

did this, didnt work

#

wait now its unauthorized facepalm brb

#

okay still doesnt work

#

do I need to set my port to listening or something? @sullen nymph

sullen nymph
#

Well it needs to be open nekothinking

wide sigil
#

ooh maybe need to open my server or something

vapid cape
wide sigil
#

when I ping the URL on cmd, it doesnt work

#

Hi??

#

helpo

#

please

#

this no worko

last cedar
#

i thought i updated it....

green mantle
#

@wide sigil is your port open...

last cedar
#

@vapid cape i had to refresh the client so ye it worked thx

wide sigil
#

Yeah @green mantle I believe so

green mantle
#

check

wide sigil
#

Still doesn't work

#
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/upvote', webhook_port=5000)```
#

@green mantle any ideas?

finite hare
#

Would a VPN generate a problem with that? Or is that just based on the VPN's user policy?

vapid cape
#

@wide sigil test it with reqbin

wide sigil
#

With what

#

oh cool

vapid cape
#

try sending a POST request to yourself, no need for authorization or content

#

if you are accessible, it will show unauthorized

#

if it shows any other error, then you are not accessible in that address

wide sigil
#

Getting 1007

#

oh wait

#

im getting 404 when im running mu code

#

@sullen nymph what do you do when you get 401?

vapid cape
#

now its working

wide sigil
#

hmm

vapid cape
#

401 means the request has found its target and successfully delivered the request

wide sigil
#

but when I click on test, it doesnt print anything

vapid cape
#

add your Authorization in custom authorization

wide sigil
#

I have no auth

#

for this address

#

I mean, I didn't enable auth

vapid cape
#

there is some sort of auth enabled

#

else it wouldnt say unauthorized

wide sigil
sullen nymph
#

Oh

vapid cape
#

method not allowed means wrong request type

#

ie GET instead of POST

wide sigil
#

But on reqbin I get 401

sullen nymph
#

405 is wrong method

vapid cape
#

curl does GET by default i believe

sullen nymph
#

If you get a 401 response when sending a request to dblpy webhook

wide sigil
#

ah maybe because it's get

sullen nymph
#

Your auth isn't setup properly

vapid cape
#

try adding an auth do your webhook

wide sigil
#

But I don't know the auth code

vapid cape
#

you create one yourself

#

in your dbl constructor

wide sigil
#

Does AWS have default authorization?

vapid cape
#

it has nothing to do with aws

#

its only an authorization between top.gg and your webhook listener

sullen nymph
#

Auth is done in request headers

vapid cape
#

you define the auth where you create the dbl listener

wide sigil
#

so my auth should just be a string?

vapid cape
#

yes

wide sigil
#

okay one moment let me do this

vapid cape
#

for example

wide sigil
#

Does the order matter?

vapid cape
#

no

wide sigil
#
self.dblpy = dbl.DBLClient(
            self.bot,
            self.token,
            autopost=True,
            webhook_path='/upvote',
            webhook_port=5000,
            webhook_auth=self.bot.PASSWORD)
vapid cape
#

then in reqbin add it as a custom auth

#

you should now get a bad request instead of unauthorized, if it works

wide sigil
#

I'm getting a 500 now..

#

internal server error

vapid cape
#

then there is an issue in your code

#

or maybe py doesnt throw a bad request like js does

#

anyway add this

wide sigil
#

still a 500

#
500 Internal Server Error

Server got itself in trouble
vapid cape
#

then check your logs

wide sigil
#

Oh wait, I've got an error

#

JSONDecodeError

vapid cape
#

even with the content added?

wide sigil
#

lemme restart the code and try

#

hmm still a 500

#

with the content

vapid cape
#

still jsondecodeerror?

sullen nymph
#

Huh what

wide sigil
#

and more errors

#

caused by that

#

actually that may have been last toime

sullen nymph
#

That's fun

vapid cape
#

well idk what to do about that

#

what do you think shiv?

sullen nymph
#

It's... internal but

#

it shouldn't even appear in the first place

#

Ah

#

There's no type key in the received JSON

wide sigil
#

crap it worked

#

it worked when I tested with dbl

vapid cape
#

lmao

wide sigil
#

I think it was my event

vapid cape
#

i guess you did something wrong in reqbin then

#

or that

wide sigil
#

gotta try with a real vote now

sullen nymph
#

They didn't have type in the JSON when testing with reqbin

wide sigil
#

Probably

vapid cape
#

ah it also expects a type param?

#

js doesnt lul

wide sigil
#

But I remember seeing application/json

green mantle
#

iirc the lib is loading the json'd response

#

so when it doesnt get that

#

it raises a json decoding error

sullen nymph
#

I mean all I do is

type = request.headers.get('type')
if type == 'upvote':
    event_name = 'dbl_vote'
elif type == 'test':
    event_name = 'dbl_test``` which is why event_name can just not exist if there's no type or its something else
#

10/10 coeding skillz

vapid cape
#

so it expects a type parameter in the headers?

sullen nymph
#

Essentially

#

yeh

vapid cape
#

good to know

#

dblapi.js doesnt do any of this xd

sullen nymph
#

:^))

#

Might just throw everything into one event and make people check vote['type']

#

aka the way dblapi.js does it

vapid cape
#

dblapi doesnt even do that

#

it just gives you the content

#

doesnt check any header besides auth

#

i mean, the data apparently does contain type

#

but its in the data, not in the headers?

fast mirage
#

how do you add shards to the bot page?

sullen yoke
#

check api for posting guild count, shard stuff should be there

#

it is for python anyway

fast mirage
#

i use autopost

gaunt quail
#
$.ajax({
    method: 'POST',
    url: `https://top.gg/api/bots/${clientId}/stats`,
    data: {
        server_count: ''
    },
    headers: {
        authorization: token

    }
});
vapid cape
#

server_count must not be empty

#

also you probably need to add contentType application/json

#

contentType: "application/json; charset=utf-8"

gaunt quail
#

server_count must not be empty?

#

what should i write ?

spiral steeple
#

must be a number or null iirc

gaunt quail
#

i want the servers count ?

vapid cape
#

what are you trying to do?

gaunt quail
#

i want the servers count ?

spiral steeple
#

you want to set it or get it

vapid cape
#

you want to get it or to set it?

spiral steeple
#

lmao

vapid cape
#

damn, beat me to it

willow spindle
#

use official npm package

spiral steeple
#

Cant exactly use that in webdev tho

#

it looks like it's a website

gaunt quail
#

i want it in webpage

spiral steeple
#

considering they're using ajax

vapid cape
#

so you want to get it?

#

then you use a GET request, not a POST

gaunt quail
#

give me example pls

vapid cape
#
$.ajax({
    method: 'GET',
    url: `https://top.gg/api/bots/${clientId}/stats`
});```
#

i dont even know if the GET request requires authorization

spiral steeple
#

it does

vapid cape
#

then add js headers: { authorization: token } again

gaunt quail
willow spindle
#

๐Ÿค”

vapid cape
#

then you're doing something wrong

#

with your jquery lol

gaunt quail
#
$.ajax({
    method: 'GET',
    url: `https://top.gg/api/bots/${clientId}/stats`,
    headers: {
        authorization: token,
        contentType: "application/json; charset=utf-8"
    }
});
#
    <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.4.1.min.js"></script>
vapid cape
#

make sure you use $.ajax only AFTER you load jquery

gaunt quail
#

@vapid cape

#
     <script>
         $(function(){
            $.ajax({
        method: 'GET',
        url: `https://top.gg/api/bots/${clientId}/stats`,
        headers: {
            authorization: token,
            contentType: "application/json; charset=utf-8"
        }
    });
         })
     </script>
vapid cape
winged topaz
#

Hi, is there any way I can embed gifs from either imgur or gfycat and send them via a bot message? I'm working with the discord.py rewrite branch (v 1.4). I tried pasting the link into the url attribute of the Embed.set_image method but all it gives is the default discord poop sign after failing to load

spiral steeple
winged topaz
#

Do I post this there as well?

spiral steeple
winged topaz
#

Oh okay, apologies

spiral steeple
#

all good

noble iron
#

most websites don't allow requests from other websites

unborn oyster
#

Well, I use discord.py. What data comes from the data parameter in on_dbl_vote?

#

I wanna get it right instead of having to test with friends voting for the bot.

sullen nymph
#

Autopost in dblpy doesn't post shard stats ๐Ÿ‘€

unborn oyster
#

I am confused, where do I put the API key?

sullen nymph
#

Refer to examples

#

To get top.gg token, you scroll to the bottom of your bot's Edit page

wary zealot
#

if your bot isn't approved, can you still use the api?

spiral steeple
#

no, you need a token

wary zealot
#

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

pure dune
#

I didn't even know there was an unapproved status

restive otter
#
Ignoring exception in on_guild_join
Traceback (most recent call last):
  File "/home/trackrunny/.local/lib/python3.7/site-packages/discord/client.py", line 312, in _run_event
    await coro(*args, **kwargs)
  File "/home/trackrunny/LinuxBoi/cogs/TopGG.py", line 45, in on_guild_join
    await self.bot.dblpy.post_guild_count()
AttributeError: 'LinuxBoi' object has no attribute 'dblpy'
Ignoring exception in on_guild_join
Traceback (most recent call last):
  File "/home/trackrunny/.local/lib/python3.7/site-packages/discord/client.py", line 312, in _run_event
    await coro(*args, **kwargs)
  File "/home/trackrunny/LinuxBoi/cogs/TopGG.py", line 45, in on_guild_join
    await self.bot.dblpy.post_guild_count()
AttributeError: 'LinuxBoi' object has no attribute 'dblpy'
[NODE-us-127.0.0.1:2333] Unknown event received: TrackStartEvent
Ignoring exception in on_guild_join
Traceback (most recent call last):
  File "/home/trackrunny/.local/lib/python3.7/site-packages/discord/client.py", line 312, in _run_event
    await coro(*args, **kwargs)
  File "/home/trackrunny/LinuxBoi/cogs/TopGG.py", line 45, in on_guild_join
    await self.bot.dblpy.post_guild_count()
AttributeError: 'LinuxBoi' object has no attribute 'dblpy'

Why do I get this when trying to update my guild count?

#
import os

import dbl
from discord.ext import commands

from logging_files.top_gg_logging import logger


class TopGG(commands.Cog):

    def __init__(self, bot):
        self.bot = bot
        self.token = os.environ.get("top_gg_token")
        self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)

    @commands.Cog.listener()
    async def on_dbl_test(self, data):
        print(data)

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        user = await self.bot.fetch_user(int(data['user']))
        logger.info(f"TopGG | Vote From: {str(user)}")

    @commands.Cog.listener()
    async def on_guild_join(self, guild):
        await self.bot.dblpy.post_guild_count()

    @commands.Cog.listener()
    async def on_guild_remove(self, guild):
        await self.bot.dblpy.post_guild_count()

    @commands.Cog.listener()
    async def on_guild_post(self):
        logger.info(f"TopGG | Posted Updated Guild Count")


def setup(bot):
    bot.add_cog(TopGG(bot))
green mantle
#

cuz thats not how oop works?

#

youre doing self.bot.dblpy

#

which isnt a thing

#

also dont post guild count on every join and leave

#

thatll just spam the api

restive otter
#

My bot server number isn't showing up its saying 0 I know its in more then that but idk what to do, its supposed to show up in presence

green mantle
#

nah that looks right in terms of getting guild count

restive otter
#

Its saying 0

green mantle
#

tho youre using an f-string yet not using any of its functionality

#

are you by any chance setting that activity before on ready is called...

restive otter
#

no

#

its set on_ready

green mantle
#

whats your full code

restive otter
#
async def on_ready(**kwargs):
    print("Bot Online!")
    print("Name: {}".format(client.user.name))
    print("ID: {}".format(client.user.id))
    print("------------------------------------")
    client.remove_command("help")
    print(discord.__version__)
    activity = discord.Game(name=",cmds for commands! | Currently defining words on"  + (str(len(bot.guilds))) +  "Servers!")
    await client.change_presence(status=discord.Status.online, activity=activity)
    print(str(len(bot.guilds)))```
green mantle
#

oh then that makes life easier lmao

#

notice how youre using client not bot

#

as your var names

restive otter
#

I defined both

#

It changes its presence

#

its just not displaying the number

green mantle
#

why do you define both

#

do not define both, pick one or the other

restive otter
#

Does that really mess everything up

green mantle
#

yes

#

because you then have two bot objects and only one logging in to discord and getting guild count

restive otter
#

wow

#

I fucking hate myseldf

#

Thanks for that

green mantle
#

๐Ÿ‘

tulip lily
#

(node:32309) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token u in JSON at position 012:17 PM

at JSON.parse (<anonymous>)12:17 PM

Jump Toat dbl.hasVoted.then.voted (/app/komutlar/country.js:24:21)12:17 PM

at <anonymous>12:17 PM

at process._tickCallback (internal/process/next_tick.js:189:7)12:17 PM

#

what ?

green mantle
#

you appear to have a syntax error

tulip lily
#

there is an error on the site

#

@left egret

#

hata nedir ?

left egret
#

This channel is english only

tulip lily
#

yes

left egret
#

You have a syntax error

#

this mean, you probably have a typo somewhere

tulip lily
#

hmm ok

gloomy tide
#

Hello! I have a little problem using the webhook system: I don't receive any post request

green mantle
#
  1. What lib
  2. what language
#
  1. whats your code
thorny horizon
#

I got the problem too, I use dblpy, so python

self.bot = bot
self.token = 'token'
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)

Just did this on Cog init^

@commands.Cog.listener()
async def on_dbl_vote(self, data):
    print(data)
``` then I have this for the webhook
sullen nymph
#

Do y'all read docs btw

thorny horizon
#

Nah I just copy the examples because I should think examples work

vapid cape
#

there are more than one example listed

thorny horizon
#

aha

#

Oh shit now I see

#

My bad

thorny horizon
#

Does that autmatically bind to public IP

#

Because I still dont get a reaction

green mantle
#

is the port open...

thorny horizon
#

Does the thing automatically host a webhook when I configure it like dis:

self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000, autopost=True)
vapid cape
#

yes

#

did you configure your webhook settings in your top.gg bot page?

thorny horizon
#

Yes

vapid cape
#

your bot is hosted in a vps?

thorny horizon
#

Yes

vapid cape
#

check if your vps provider requires ports to be opened in their firewall

#

for example, GCP/GCE does

thorny horizon
#

I have a database hosted

#

On public IP

#

So everything should be accesible

vapid cape
#

did you restart the bot?

thorny horizon
#

Yes

vapid cape
#

try sending a test request on reqbin

#

send a POST request to your url

thorny horizon
#

Mhm

restive otter
#

@vapid cape remember me asking about api and webhook and stuff and how it works?

#

I still haven't figured out how to use it properly... I did everything you said and when i test the url it just says could not connect in that reqbin.com

thorny horizon
#

How do i pass the password @vapid cape

vapid cape
#

paste it into custom Authorization

thorny horizon
#

wdym

vapid cape
#

but you dont need the password to test if the IP works

#

it will show unauthorized if it works, or connection error if it doesnt

restive otter
#

Hmm

vapid cape
#

@restive otter where is your bot hosted?

thorny horizon
restive otter
#

@vapid cape i self-host it remember?

vapid cape
#

@thorny horizon that means the IP is working

thorny horizon
#

Yes

vapid cape
#

put your password here

restive otter
#

Wait we need to provide the password when we are testing the POST in that website?

thorny horizon
restive otter
#

(The password we created in the Authorization)

sullen nymph
#

Might use logging module for webhook requests tbh...
what's that now?

vapid cape
#

@restive otter if you get connection error, then the problem is not the authorization

sullen nymph
#

Time to open issues on own repo

thorny horizon
vapid cape
#

check your logs

thorny horizon
#

Nothing

vapid cape
#

there should be a json parsing error or something

#

unless you ignore webhook errors?

restive otter
#

Hmm so the url is like this?:
https://MYPUBLICIPADRESS:MYPORT/dblwebhook
@vapid cape

vapid cape
#

@restive otter http, not https

#

unless you have SSL

restive otter
#

Oh

#

K lemme test

thorny horizon
#
    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print(data)
vapid cape
#

anyway, the IP is working, so double check your URL and Authorization in top.gg

#

add the test listener: ```py
@commands.Cog.listener()
async def on_dbl_test(self, data):
print(data)

#

press save in top.gg and press test

thorny horizon
#

Ohhhh

restive otter
#

@vapid cape hmm what can i do when the error i always get is could not connect?

vapid cape
#

then your ip address/port is wrong or blocked

thorny horizon
#

Still nothing on_dbl_test doesn't work too

vapid cape
#

you need to unblock it in your firewall/router

restive otter
#

Hmm I have unblocked it

#

But still

vapid cape
#

well, its still blocked

#

@thorny horizon try adding this to your headers

thorny horizon
#

Yeah got a weird error

#

An error occurred while processing your request. Error code: 10035

restive otter
#

hi

#

@restive otter

thorny horizon
#

@vapid cape Got it working ๐Ÿ˜„ I made a https req instead of http LMAO

#

And putty froze

#

so I couldnt see logging

craggy sphinx
#

here you can make requests if anyone knows of any API?

trail sigil
grave sundial
#

@sick stag

trail sigil
#

so what do you need to do?

sick stag
#

you ask, he wants to check current votes, and votes per month

grave sundial
#

yes

#

right now there have been numbers that seem very off and random

trail sigil
#

are you using dblapi.js?

grave sundial
#

yes

#

would you like the code via dm?

trail sigil
#

yeah sure

#

show me what you have done so far

restive otter
#

im unable to return whether a user has voted for my bot or not - im using the .net lib for this as i cant find the url endpoint for voting

the userid parameter is currently set to a discord userid - and im thinking that may be incorrect

regardless, its returning false for a user that has voted.

finite hare
#

The voted function only works asynchronously. @restive otter

#

I believe.

#

Can we see some of the relative code?

restive otter
#

i believe ive fixed it - just testing it out currently, but i was using the bot's id from discord and not from the site

regardless, its stopped throwing a nullref exception and is allowing me access things

i also am running it as an async operation lol^^

#

example:

bool UserHasVoted = await Program.topggBot.HasVotedAsync(arg.Author.Id);

topggBot is of type "IDblSelfBot", and "arg" refers to a SocketMessage

finite hare
#

I think you might need to catch the callback via a function

restive otter
#

okay, thank you

#

ill try some stuff out

finite hare
#

I don't know your alternative for JavaScript's ".then" function, but .then works

#

My explanations suck because I don't know a lot of terminology, sorry for the little help

restive otter
#

it would declare correctly, it just wouldnt log in with the userid and token for some reason .. but like i said, i was using the bot's discord id and not the topgg id

#

but no its okay, thank you for the help lol

finite hare
#

You're saying you can't login with your top.gg bot token?

restive otter
#

i wasnt able to, but ive resolved it

finite hare
#

Do you have the error event listener available?

restive otter
#

login function required two parameters

AuthDiscordBotListApi(bot_id, topgg_token);
#

i just misplaced "bot_id" for discord's id

#

but ye, like i said - ive fixed it, ty though

finite hare
#

Alright.

#

Thanks

restive otter
#

yup! and thank you

wispy lynx
#

webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000
Using the python library, what is the significance of each of these webhook arguments?

vapid cape
#

webhook_path = the endpoint of your webhook server, for example /dblwebhook means your URL field will be mywebsite.com/dblwebhook or myIPaddress:PORT/dblwebhook

#

webhook_auth = authentication for the webhook, must be the same as what you put in the Authorization field in top.gg

#

webhook_port = port to run your webhook server on

wispy lynx
#

So it hosts a webserver?

vapid cape
#

yes

#

top.gg webhooks are sent directly to you

wispy lynx
#

Very cool

vapid cape
#

they have nothing to do with discord webhooks

wispy lynx
#

ty

knotty garnet
#

Remember to set a auth field

#

To prevent unauthorized requests being processed by u

wispy lynx
#

๐Ÿ‘

wispy lynx
#

Does the DBL python lib include functions for donatebot api?

sullen nymph
#

dblpy is for top.gg, not DonateBot nekothinking

hallow knot
#

Hey can you customize the page on top.gg

green mantle
#

Html and CSS in the long description, if you need help ask in #development

hallow knot
#

K

jade kayak
#

I need help with api. I'm lost what I need to paste into URL and Authorization into bot's edit page (basically webhooks). Not sure if it matters, but bot is hosted on windows

wet sequoia
#

In URL you need to type the URL of your webserver where your webhook runs

#

Authorization can be anything. Its like a password which you can use to check if the webhook request is from top.gg
Top.gg will send webhook requests with the Authorization header and the value you typed in there

jade kayak
#

So if it's localhost I'd need to type in myip:port/dblwebhook?

sullen nymph
#

Don't forget http/https before

jade kayak
#

Oh well I guess I just won't log votes, cause it doesn't work.. Thanks

sullen nymph
#

nekothinking And you're not going to try and actually fix it?

vapid cape
#

when self-hosting you need to portforward in your router

#

because ports are blocked by default in most modems/routers

jade kayak
#

:nekothinking: And you're not going to try and actually fix it?
I've been trying that for 3 days already, maybe somewhen in the future I'll re-try

#

because ports are blocked by default in most modems/routers
wouldn't I get error, that connection was blocked?

vapid cape
#

no

#

because the connection never arrives

#

top.gg will receive an error that your connection was refused or did not respond, when they try to send it to you

#

but top.gg internal errors and logs are not public of course

jade kayak
#

how do I portforward then

vapid cape
#

you can however use a service like reqbin to test webhooks yourself, there you will see all errors

#

you need to access your router's configuration panel, usually at 192.168.1.1 (varies depending on router model)

#

an look for port forwarding or virtual servers

#

and set your webhook port to be sent to your internal/local ip address

jade kayak
#

192.168.0.1 it was, unfortunately idk the password, and the passwords internet provides are incorrect. So I guess I'll need to test webhooks myself

vapid cape
#

check the router's box or the router itself, sometimes the password is written in the labels

jade kayak
#

unfortunately it's not

vapid cape
#

then you'd need to contact whoever configured it

#

(or push the reset button, but it will likely break your internet connection until reconfigured)

jade kayak
#

I'll just do it whenever I'll receive new router, thanks GWcmeisterPeepoLove

teal lava
#

have you tried admin?

valid ravine
#

hey guy I am new

#

where can i find webhookAuth?

restive otter
#

You can set it

hoary nebula
#

ANYONE WANT TO BE my dou I have a mic and have 2fa and in diviosion 5 only because I don't play that much

#

arena

#

i play every day

sullen nymph
#

Read this channel's topic.

delicate rover
#

it is for webhooks

hearty lintel
#

you can put whatever you want, it's just a secret key that has to be the same on dbl and on the webhook backend

jagged pine
#

Hi guys, I'm not quite understaning how this API works, does the top.gg website update everything by himself or do I have to send him datas like server count and he will then update the bot page with that data?

willow spindle
#

you have to post server count

jagged pine
#

uhm ok I'll look that up

jagged bridge
#

Ignore everything, was a silly mistake lol

tawdry tree
#

is there a way to use the api in discord.py without cogs?

sullen nymph
#

There is, you just attach the created DBLClient to your bot variable and use it blobshrug

worn quail
#

yea

tawdry tree
#

oh thanks

jagged pine
#

I need to put this in my code so that the bot page get's updated right?

client.on('ready', () => {
    setInterval(() => {
        dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
    }, 1800000);
});
```Nothing else?
vapid cape
#

you dont even need to do that

#

dbl has an autoposter

#

you just need to give it your client

#

ie: new DBL(dbltoken, client)

#

you only need to use postStats if you use DBL(dbltoken) without client

unborn oyster
#

Alright in discord.py

I am trying to get when ever on_dbl_vote triggers it prints the vote data in a specific channel But it never works I think it is because i don't know how to connect the token in that event.

vapid cape
#

wdym connect the token?

#

top.gg webhooks dont require tokens

gray root
#

If the user role has changed, would it be under PRESENCE_UPDATE?

vapid cape
#

GUILD_MEMBER_UPDATE i believe (offtopic)

ocean bridge
#

so I'm trying to make a lower cooldown for people that have voted, Im using

dbl.hasVoted(id).then(v => {
  if (v) {
    // voter cooldown stuff
  } else {
    // nonvoter cooldown stuff
  }
})

I'm not really sure what I've done wrong, if the person HAS voted, then it just skips everything and has no cooldown, but if they haven't voted then they have the normal cooldown for nonvoters. If it helps at all, I used the djs guide for the cooldown functionality

#

^^ and thats all in my message.js event

subtle matrix
#

How do you tell top.gg how many servers ur bot is in?

vapid cape
subtle matrix
#

thanks

narrow geyser
#

How long (usually) does it take for server count to update?

ocean bridge
#

Pretty sure the default is 30 minutes, but I might be wrong

subtle matrix
#

idk

#

30 minutes

#

1800000 (30 minutes) I think if I'm reading the right section

sullen nymph
#

Instant usually, cache might get in way it viewing from browser

narrow geyser
#

Ive cleared my cache, regenerated my token, im not getting any errors from dblpy, but it hasn't updated

sullen nymph
#

nekothinking you sure it's actually posting? Might wanna fetch the data from API

ocean bridge
narrow geyser
#

@sullen nymph im getting a empty dict as the response.

sullen nymph
#

What does your code look like

narrow geyser
#
import dbl
import discord
from discord.ext import commands, tasks
from basebot import Guardian
import logging


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

    def __init__(self, client: Guardian):
        self.client = client
        self.logger = logging.getLogger("guardian.topgg")
        self.client.task_manager.create_loop(self.post_stats(), 60*60*30, "top.gg-stat-poster")

    async def post_stats(self):
        self.logger.debug("Posting stats to top.gg")
        headers = {"authorization": self.client.config.dbl_token}
        data = {"server_count": len(self.client.guilds)}
        r = await self.client.session.post("https://top.gg/api/bots/676448082556354583/stats", headers=headers, data=data)
        self.logger.debug(await r.text())


def setup(client):
    client.add_cog(TopGG(client))
sullen nymph
#

Shouldn't the auth header be starting with capital A

narrow geyser
#

Well, not giving a error so

#

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

restive otter
#

api hakkฤฑnda yardฤฑm edebilecek bir tรผrk arkadaลŸ arฤฑyorum

narrow geyser
#

@sullen nymph Changed it, still no difference

#

Im getting statuscode 200 aswell

sullen nymph
#

Try to post 1 or 2 as test

green mantle
#

it should be A

#

also does the api not take the Bearer param for the auth string?

narrow geyser
#

@sullen nymph im posting 1 as a test

#

Nothing is updating

hushed kindle
#
import dbl
import discord
from discord.ext import commands, tasks
from basebot import Guardian
import logging


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

    def __init__(self, client: Guardian):
        self.client = client
        self.logger = logging.getLogger("guardian.topgg")
        self.client.task_manager.create_loop(self.post_stats(), 60*60*30, "top.gg-stat-poster")

    async def post_stats(self):
        self.logger.debug("Posting stats to top.gg")
        headers = {"authorization": self.client.config.dbl_token}
        data = {"server_count": len(self.client.guilds)}
        r = await self.client.session.post("https://top.gg/api/bots/676448082556354583/stats", headers=headers, data=data)
        self.logger.debug(await r.text())


def setup(client):
    client.add_cog(TopGG(client))

some python UwU

restive otter
#

heeelp

#

``const botconfig = require("./botconfig.json");
const Discord = require ("discord.js");

const bot = new Discord.Client({disableEveryone true});
bot.on("ready", async () => {
console.log('${bot.user.username} is online!');
});

bot.login(botconfig.token);``

ocean bridge
cosmic fog
#

hi

Guys.....

jolly hornet
scenic vigil
#

Hi I have just added Causym to my server. Can anyone tell me how to use it as translation bot? Thanks

burnt trellis
#

-wrongserver @scenic vigil

abstract mothBOT
#

@scenic vigil

Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Support Server" button on the bot's page, not the "Join Discord" button at the top of our website. If there isn't a button that says Join Support Server, then we can't help you. Sorry :(

burnt trellis
verbal sluice
#

Is it possible to make it where certain roles have access to certain emojis by using an api?

balmy hamlet
#

wdym, also, this channel isn't for that kind of questions

fiery sun
#

Hello, I have a problem with webhook. When I click in test buton on the site I don't have any logs... If someone can help please

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

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

dbl.webhook.on('vote', vote => {
  console.log("Tested")
  var user = client.users.get(vote.user)
  if (!user) return;
  if (vote.isWeekend) {
    client.channels.get("702531867617919006").send(`Thanks to **${user.username}** to have voted for me on https://top.gg/bot/BreakLink/vote ! `)
  } else {
    client.channels.get("702531867617919006").send(`Thanks to **${user.username}** to have voted for me on https://top.gg/bot/BreakLink/vote ! *(X2 Week-End Bonus !)*`)
  }
});```
ocean parcel
#

@fiery sun are you running it on your server?

fiery sun
#

Yes

ocean parcel
#

thonk

#

let me chck docs rly quick

#

@fiery sun you run linux right?

fiery sun
#

Yes unbuntu

ocean parcel
#

run sh sudo netstat -peanut | grep 5000 for me pls (in a different window than your bot)

fiery sun
#

Ok

ocean parcel
#
sudo apt install net-tools```
#

you can use this tool to see which ports are used on your system btw

#

I'm trying to see if your bot got bound to the port

fiery sun
#

Okay

ocean parcel
#

yup, that mounts

#

๐Ÿค” can you DM me the server IP to check if the outer world can accesss the webhook

fiery sun
#

I can dm you with server domain name if you want

ocean parcel
#

yeah, that works

#

but... I'll need you to add me as a friend

#

since my DMs are closed

fiery sun
#

Okay I send friends request to you

#

You add me

ocean parcel
#

yeahohboi

restive otter
#

i need discord api

#

how can i extract it

dense basalt
#

-api @restive otter

abstract mothBOT
#

@restive otter

THIS CHANNEL IS ONLY FOR SUGGESTIONS/HELP/BUGS TO DO WITH OFFICIAL TOP.GG API LIBRARIES AND API DOCS FOUND AT
https://top.gg/api/docs

restive otter
#

hello

#

help me

willow spindle
#

do not ask2ask

remote slate
#

Can I setup a webhook with my IP address or do I need a domain?

sullen nymph
#

Just an IP address is fine

remote slate
#

Thanks, it works perfectly chat_perfect

#

Can I post a suggestion here?

#

Add the request info from DBL when clicking on Test would be great

sullen nymph
#

request info? nekothinking

#

The data is almost the same, only the value of type key in returned JSON is different

plush ore
lone sun
#

Alr

#

Sry

spare solar
#

is there an api for voting?

smoky plover
spare solar
#

no I mean voting from a command

trail sigil
#

no, you cannot vote with a command

#

votes can only come from your bot page

spare solar
#

ah ok

blissful sinew
#

@trail sigil

#

Can u help me ?

#

I'm new in bit development

trail sigil
#

hey

#

wassup

verbal sluice
#

Anyone know how to do modified emojis

trail sigil
#

wdym?

verbal sluice
green mantle
#

not the channel for that

dusty fulcrum
#

is the server count on top.gg supposed to update immediately after posting a new count? for some reason my count seems to be stuck even though it's pretty surely posting new counts.

vapid cape
#

it usually updates within seconds

restive otter
#

heeey help

#

bot don't starting

jolly hornet
#

-api

abstract mothBOT
jolly hornet
restive otter
#

ok

dusty fulcrum
#

wait, is the old https://discordbots.org/api/bots/<id>/stats still valid? just realised that this bot is still using that url

sullen nymph
dusty fulcrum
#

still odd, for some reason it didn't work. i just changed it to the implementation with the dblpy package so it's working now

true talon
#

@dusty fulcrum u have almost the same pfp as me, I was thinking "oh im green" for a sec

#

๐Ÿ˜ฆ

dusty fulcrum
#

LOL. a friend of mine edited these angeryCry angeryBongo okayDoggo

sturdy fern
#

My bot shows on the website still the old Profilimage. How can I fix it?

#

sorry for my english

willow spindle
#

this is not related with API @sturdy fern

sturdy fern
#

where should I ask then?

willow spindle
restive otter
#

Is there any way to find how long until a user can vote again?

spare solar
#

whats the api so it shows the amount of server are using it on top.gg

solid wharf
willow spindle
#

Is there any way to find how long until a user can vote again?
@restive otter no

remote slate
#

request info?
@sullen nymph I mean, I would like to get the status code returned by DBL
either if it's a 404 or a 403 or if it didn't work at all

sullen nymph
#

Ah

#

I mean you can edit the internal code to return the request response

#

There's exceptions for 403 and 401, don't remember about 404 as it shouldn't ever happen with dblpy

remote slate
#

yea that's a good idea, I don't even know why I didn't think about it

#

i'll make a fork of the lib, thx

sullen nymph
#

Or you can just create your own lib from scratch for all you know

remote slate
#

true

restive otter
#

How do I actually POST to webhooks.
I'm trying this

    local url = "https://discordapp.com/api/webhooks/ID/TOKEN"
    local res, body = http.request("POST", url, {content = "test"})
willow spindle
#

this isn't related with top.gg API

restive otter
#

๐Ÿ‘

restive otter
#
if(dbl.hasVoted(message.author.id) === true) {
  message.author.send("You have already voted")
}

it skips through the if statement. Doesnt dbl.hasVoted(message.author.id) return a bool?

#

If not, how should I be checking if the author has voted in the last 12 hours?

remote slate
#

I think hasVoted method is async?

#

so I think it's probably if (await dbl.hasVoted(id))?

sullen nymph
#

Or .then

restive otter
#

ok thanks

tribal gate
#

@rustic raptor

#

hmm

#

downtime

hallow mist
#

Does the webhook for voting arrive on port 80/443?

green mantle
#

it arrives on what ever port your run the webserver on

half olive
#

You can define the port on options with webhookPort: 300 (for example)

tardy nimbus
#

does .hasVoted return if they've voted in the past 12 hours or if they've ever voted?

sullen nymph
#

The former

tardy nimbus
#

just past 12 hours?

#

odd

willow spindle
#

12 hours

ebon merlin
#

that's literally stupid > the api for an nsfw command im using isn't meant to provide loli but it does. imma have to remove it

olive arrow
#

How do I stop the API contsantly reposting the stats

hollow raptor
#

setinterval

restive otter
#

hello

#
const { request } = require('https');

const update = () => {
  const data = stringify({ server_count: client.guilds.size });
  const req = request({
    host: 'top.gg',
    path: `/api/bots/${client.user.id}/stats`,
    method: 'POST',
    headers: {
      'Authorization': 'API TOKEN',
      'Content-Type': 'application/x-www-form-urlencoded',
      'Content-Length': Buffer.byteLength(data)
    }
  });
  req.write(data);
  req.end();
};

client.on('ready', update);
client.on('guildCreate', update);
client.on('guildRemove', update);```
#

help me

#

what does this do?

hollow raptor
#

updates bot stats server count

restive otter
#

ha okey thanks @hollow raptor

#

const postData = JSON.stringify({
    server_count: client.guilds.size
});

const options = {
    hostname: 'https://discordbots.org',
    path: `/api/bots/${client.user.id}/stats`,
    method: 'POST',
    headers: {
        'User-Agent': 'DiscordBot (https://moustacheminer.com/) Discord Guild Counter',
        'Content-Type': 'application/json',
        'Content-Length': postData.length,
        Authorization: 'AUTHTOKEN'
    }
};

const req = https.request(options, (res) => {
    res.on('data', (data) => {
        console.log(data.toString('utf8'));
    });
});

req.on('error', (error) => {
    console.error(error);
});

req.write(postData);
req.end();```
#

what does this do?

#

Same thing but this is old version

#

hmm ok

dry sinew
#

s

restive otter
#

Hi, i want to register vote of members but when i make
if await get_user_vote(ctx.author.id): in my command,
I get the error : discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'get_user_vote' is not defined
I don't understand, can you help me? (Python python )

green mantle
#

because that makes no sense...

#

i highly doubt you've imported the py lib and extracted just that function

restive otter
#

... Yes, ok x)

#

So I have to do dbl.client.get_user_vote()

#

?

green mantle
#

tias

restive otter
#

But module 'dbl.client' has no attribute 'get_user_vote' Thinking

#

Oh it's ok

#

Ty

sullen nymph
#

Did you read any examples or the docs

restive otter
#

Yes, but I don't understand because, the get_user_vote requires one argument; so await dbl.DBLClient.get_user_vote(user_id) (user_id = ctx.author.id)
And i get the error TypeError: get_user_vote() missing 1 required positional argument: 'user_id' Thinking

green mantle
#

๐Ÿ‘ Because you havent init the object

#

Classes exist and because its not a static method you have init the client object and pass bot and token

midnight garden
#

How i create a vote system ? ( the guy vote un my bot and automatically receive a prize) ...
ping me if you answer me

green mantle
#

@midnight garden you'll need to use the vote webhook and then go from their

midnight garden
#

hmm

#

ok

#

i'll test it

#

you have the link for docs ?

#

i found the docs

restive otter
#

@green mantle But I have init '-'

green mantle
#

send your code

restive otter
#
[...]
import dbl
class TopGG(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.token = "TheToken"
        self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)
        print('Cog "TopGG" ready.')

    @commands.command()
    async def vote(self, ctx):
        user_id = ctx.author.id
        if await dbl.DBLClient.get_user_vote(user_id):
            await ctx.send('You have arleady vote.')
        else:
            await ctx.send('You can vote')
[...]
green mantle
#

thats....

#

not how objects work

#

self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)

restive otter
#

hm?

green mantle
#

you set the init client to a attribute there

#

you cant just call the lib again and expect it to remember

restive otter
#

Uh yes

green mantle
#

thats not how objects work

restive otter
#

So i have to do await self.dblpy.get_user_vote(ID)

midnight garden
#

how i fix it ?

#

@green mantle sorry ping :/

green mantle
#

@restive otter yes

#

@midnight garden you cant fix

#

thats just how it works

#

you have to handle interactions with discord yourself

#

the site wont do it for you

restive otter
#

Ok so, what i have the error Command raised an exception: Unauthorized: Unauthorized (status code: 401) ๐Ÿ˜•

midnight garden
#

and what i do , for the bot send message when someone vote ?

vapid cape
#

unauthorized

restive otter
#

Yes but why?

vapid cape
#

your token is wrong

#

@midnight garden language?

midnight garden
#

im from portugal

vapid cape
#

i mean, coding language

midnight garden
#

ow

vapid cape
#

tb sou tuga lol

midnight garden
#

ata

#

Javascript

#

can add ?

vapid cape
#

do you have dblapi.js?

midnight garden
#

i don't have installed yet

vapid cape
restive otter
vapid cape
#

@midnight garden check the webhook example

midnight garden
#

this right ?

vapid cape
#

@restive otter shouldnt you use the dbl instance you created?

#

ie self.dblpy.get_user_vote instead of dbl.DBLClient.get_user_vote

#

idk how python works

#

@midnight garden yes

midnight garden
#

@vapid cape thanks , can add ??

vapid cape
#

yes

sullen nymph
#

Yeah, Tim. That's how dblpy works. dbl.DBLClient stores no token in this case while self.dblpy does
also iirc no method in dblpy is a classmethod :^)

vapid cape
#

:^)

midnight garden
restive otter
#

@vapid cape I have regen token, it's ok

vapid cape
#

@midnight garden you dony have node.js installed? how do you run your bot?

#

where is your bot hosted?

midnight garden
#

i think i unistall the node.js lol

vapid cape
#

there is your bot hosted then? how does it run?

#

or did you delete your bot too? lol

midnight garden
#

i junt unistall the node.js

#

but appear this error

vapid cape
#

tokens are strings, not variables lol

midnight garden
#

yep i do it now

#

and it works

vapid cape
#

and you just leaked your top.gg token, reset it

midnight garden
#

but i need test the bot

#

oh ...

vapid cape
#

also, if your bot is self-hosted, you will need to port forward your modem/router

midnight garden
#

oh god

#

and if i host them in a heroku ?

vapid cape
#

then its easier to setup top.gg webhooks

midnight garden
#

hmm

#

i need host him in a heroku

#

because , the bot have too much users , and the host them i pay , can't turn on because the ram

vapid cape
#

which host is that?

midnight garden
#

DisCloud

vapid cape
#

gratuito or carbon?

midnight garden
#

carbon

#

i will buy the planitum , but i need the money

vapid cape
#

yes 128mb is not enough for a node.js bot

midnight garden
#

uhum

vapid cape
#

node.js by itself with 0 users, already wastes 50mb ram

midnight garden
#

oh

vapid cape
#

heroku and glitch both have 512mb ram i think

midnight garden
#

hmm

#

I will try host in heroku

#

and if i host in heroku i don't need change the port right ?

#

@vapid cape

vapid cape
#

in heroku the port needs to be webhookPort: process.env.PORT

#

then in the top.gg website, in URL you put MYPROJECT.herokuapp.com/dblwebhook

midnight garden
#

hm

#

ok

midnight garden
#

@vapid cape how Many is the limit time of heroku ?

vapid cape
#

@midnight garden unverified accounts have 550 hours per month

#

verified accounts have 1000 hours per month

vapid cape
limpid vector
#

my dblapi doesn't seem to be working properly, anyone else having an issue with theirs?

silent pilot
#

Is there a way to use the python api in repl.it?

fair prism
#

my dblapi doesn't seem to be working properly, anyone else having an issue with theirs?
@limpid vector me too pandasad

limpid vector
#

some votes just aren't being registered

#

getting complaints about it from my bot o.O

silent pilot
#

@vapid cape Iโ€™m assuming I can use the dbl.py library on repl.it. Am i wrong?

polar mirage
#

vote webhooks are delayed?

limpid vector
#

yeah it seems like it

vapid cape
#

@silent pilot if running your bot works, then dbl should also work

silent pilot
#

Ok ty. There isnt a library on repl.it do i install it onto my computer and just run from there?

vapid cape
#

idk how replit works

#

should be able to install packages from github or from pip, no?

silent pilot
#

I believe so

#

I have it

#

Ty for ur help

#

@vapid cape i put the code in. It runs but it still says N/A for a server count. How do i go around this?

#

Sorry. I mis read the command

polar mirage
#

my test vote took 28 minutes megu

limpid vector
#

yup same here

#

is there anyone that should know about this lol

sullen yoke
#

oh, so webhooks are having an issue

#

I couldn't see the traffic hitting my firewall

ocean dune
#

@arctic arch are you aware of the vote delays/outages on the vote webhook? I'm getting tons of DMs of users which doesn't receive their vote rewards.

honest fox
#

can confirm, looks like that some of the requests are not being sent ^

late crater
#

Yeah that's been happening to me too

#

although for the past couple days

midnight garden
#

what i need configure here to my webhook work? ( my host is the computer )

#

@vapid cape sorry ping

vapid cape
#

nothing

#

if your host is your computer, then in the top.gg website, in the webhook URL field, you need to put http://YOURIPADDRESS:YOURPORT/dblwebhook

#

and port forward the port in your router/modem

midnight garden
#

where i find the id adress and port ?

sullen yoke
#

google "what is my ip" and you can pick your own port

restive otter
#

hi what will i do webhook

midnight garden
#

oh

#

and the port @sullen yoke

sullen yoke
#

pick a port you wish to use, just make sure it's open on your router

#

just don't pick a port like 123 cos that's reserved for time

#

or port 666 cos thats reserved for Doom

#

I think the default for dbl is port 5000, you may aswell use that

midnight garden
#

i need help lol

#

what i put in these spaces

vapid cape
sullen yoke
#

URL...
http://"YOUR_EXTERNAL_IP_ADDRESS":"YOUR_CHOSEN_PORT_YOU_CONFIGURED_ON_YOUR_ROUTER/FIREWALL"/dblwebhook
Authorization...
"A SUPER SECRET SUPER PASSWORD YOU WISH TO USE"

vapid cape
sullen yoke
#

if you don't know what "port forwarding" is then you may want to google it

restive otter
#

where my external ip

#

@sullen yoke

sullen yoke
#

google "what is my ip"

#

it won't start with "192.168.x.x"

restive otter
#

thank you

restive otter
#

what should I do

hollow raptor
restive otter
#

okey

#

const dbl = new DBL('token') @hollow raptor ฤฑ delete this

#

??

hollow raptor
#

yes

restive otter
#

ฤฑ need help

#

error

#

Will I put it? (')

#

@hollow raptor

hollow raptor
#

error is clear
"dbl" is already declared

restive otter
#

ฤฑ fix this eroor

#

@hollow raptor

vapid cape
#

tokens are strings

#

not variables

hollow raptor
#

^

restive otter
#

@vapid cape ฤฑ use (')

#

??

vapid cape
#

bla this is a variable
"bla" this is a string
'bla' this is also a string

#

`bla` this is also a string

restive otter
vapid cape
#

pls learn programming

restive otter
#

:C

vapid cape
#

if you put new DBL(abc)

#

it will try to look for abc = something in your code

#

but if you do new DBL("abc") it will use the words "abc"

#

understand?

green mantle
#

why the webhook has just stopped working

#

when port is open and working with test

vapid cape
#

people were saying webhooks were delayed by up to 30min a while ago

#

idk hows the situation now

green mantle
#

hmmm

#

ig server sided then

vapid cape
#

im so glad i dont use vote rewards on any of my bots lmao

green mantle
#

People just want nsfw

restive otter
#

Hello, I want to throw those who vote for my bot into a channel.

willow spindle
restive otter
#

ordan baktฤฑm olmadฤฑ bulamadฤฑm yani @willow spindle

willow spindle
#

english only

oblique turret
#

Im using dblpy and i want to know what decides our webhook_path. Is it meant to be anything we want or does it have to be a specific thing??

restive otter
#

I looked at the site but I couldn't understand anything

willow spindle
#

check examples

#

@oblique turret webhook url?

#

that is http://server ip:port/dblwebhook

restive otter
#

I proceeded with examples but my ip address was always 0.0.0.0

oblique turret
#

oh thank you

sullen nymph
#

@restive otter Replace 0.0.0.0 with your machine's external IP and you get a URL to your webhook

restive otter
#

how

sullen nymph
#

Copy the URL, replace 0.0.0.0, use the edited URL? nekothinking

restive otter
#

??

sullen nymph
#

Yes. 0.0.0.0 there simply says "your IP"

restive otter
#

no my ip 172.blah blah blah

sullen nymph
#

Replace 0.0.0.0 with your IP and you get your needed URL

restive otter
#

How do I change the ip is impossible

sullen nymph
restive otter
#

have a video about it?

sullen nymph
#

http://<your-IP>:<port><webhookPath>

restive otter
#

this

sullen nymph
#

It will never change there

#

All it's supposed to do is tell you which port and path it's running on

echo salmon
#

just wondering what people use for webhooks on the .net side? MVC ? Or is there anything simpler

oblique turret
#

do the webhooks need port forwarding to work??

echo salmon
#

Yes

oblique turret
#

oh ok

#

thanks

echo salmon
#

Depends on your network setup but if youre behind a firewall its like any other server

oblique turret
#

Last question: since i have a dynamic IP instead of a static one wouldnt that cause a major problem since i'd have to manually change it every so often?

echo salmon
#

Uhh

#

On what end?

#

Locally?

#

You might be able to do it by MAC depends on your firewall

#

If you mean on the internet you can get some DNS setup to configure when you ip changes I guess?

oblique turret
#

the external ip is dynamic

#

oh ok

#

i'll look into it thanks

echo salmon
#

Not 100% how youd do that

#

No worries

distant trellis
#

How would I allow await to be used on DBL's vote listener?

willow spindle
distant trellis
#

Can't find an answer to my question

willow spindle
#

which programming language do you use

distant trellis
#

Node

#

Would dbl.webhook.on('vote', async vote => { simply work?

willow spindle
#

you have to create webhook server

sullen nymph
#

Shouldn't they actually be async? nekothinking

distant trellis
#

I already have all of that set up but I'm rather new to await's usage

#

When attempting to use await to get something from my database, it's telling me I can't do it in a non-async function / listener

nimble fossil
#

Yes that would work @distant trellis

#

If you put that into an async function make sure to await it.

distant trellis
#

I am

#

I can't test it at the moment due to only being able to vote every 12 hours and it calls for member data which the test vote can't really provide so I'll wait it out

nimble fossil
#

Ask a friend?

distant trellis
#

Tried as many as I could already NC_Hehe

#

I'll wait it out and hope for the best

nimble fossil
#

๐Ÿ‘๐Ÿป

distant trellis
#

Thank you

sullen yoke
#

can anyone tell me what changed in the api between version 0.3.3 and 0.3.4 as 0.3.4 isn't mentioned in the docs?

#

for python*

marble escarp
#

Hey @austere coyote

#

I donโ€™t have a mic

austere coyote
#

hi everyone

#

i just tried dashe bot but the tasks didnt work, can you help me plese???

worn quail
#

@austere coyote is that relevant to the DBL api

dense shale
#

did i need to run an additional webhook server on my server or does the dbl libary handle this?

sullen nymph
#

dblpy and dblapi.js host one for you if you provide at least a port when creating a client

#

@sullen yoke support for discord.py 1.3 was added in 0.3.4 since dependencies for it were changed

dense shale
#

i use node.js and set a port but i did not get any test ping from the website when making a test. (i use the code from the example page but added a console print for the type)

sullen nymph
#

What's the URL you entered on the website

#

Are you sure the webhook is running?

dense shale
#

port is open in the firewall

true talon
#

@dense shale What's the URL you entered on the website

dense shale
#

hmm now i think its working get now a 404 instead of a timeout

sullen nymph
#

The URL is fine

dense shale
#

ok its working now thanks for trying to help me

lucid cypress
#

Um.. Discord Bot List actually have its own API

#

That's pretty neat

green mantle
#

most sites have their own api

#

but thats more of an offtopic convo to have

lucid cypress
#

Oh

restive otter
#

n!istatistik

willow spindle
restive otter
#

@willow spindle soryy

vapid cape
#

show the function

true talon
#

its me or dbl.hasVoted is broken

vapid cape
#

try (await pm.getVotes(userID)) + 1

timid trout
#

it's okay ?

sullen nymph
#

You need to host a webserver yourself

timid trout
#

I've got

#

Where can i get the token for webook ?

sullen nymph
#

what token? nekothinking

timid trout
#

for the webook

sullen nymph
#

That doesn't help at all, please elaborate

spiral steeple
#

you set the authorization

#

It's a webhook running on a server, not a discord webhook

shrewd ginkgo
#

when doing dbl.webhook.on("ready", hook => {...}) i keep getting "cannot not read property 'on' of undefined"
any ideas why?

hard ridge
#

Hi, is it possible to test async def on_dbl_test(data): without have to wait for someone to vote?

#

I just want to make sure my code is working

#

But is hard to test cos i have to wait every 12hrs

shrewd ginkgo
#

on your bot page if you click edit and scroll down to API Options -> Webhook theres a place where you can test it

hard ridge
#

Oh ok thanks

shrewd ginkgo
#

yeah np!

tawny heron
#

alrigth so simply the api just went crazy with my server count and shards

#

am i supposed to give the total server count or the server count on the specific shard?

restive otter
#

ho to get Webhock password?
and connect bot votes for my channel

green mantle
#

you make the password yourself

restive otter
#

@green mantle where?

green mantle
#

on your bots edit page

restive otter
#

Authorization

green mantle
#

yes

restive otter
#

and URL section?

echo salmon
#

the url of your server listening for the post request

restive otter
#

@echo salmon support link?

#

๐Ÿคฆ

green mantle
#

like this

restive otter
#

put i want if anyone vote, get to my channel

green mantle
restive otter
#
dbl.webhook.on('vote', vote => {
let embed = new Discord.RichEmbed()
.setDescription(`User with ID ${vote.user} just voted!`)
client.guilds.get("ID").channels.get("ID").send(embed)
});```
green mantle
#

yes

restive otter
#

and can i connect it to my channel?

green mantle
#

but 0.0.0.0 being your public ip

restive otter
#

okay second?

#

URL was public?

green mantle
#

public ip

restive otter
#

okay now what can i do to connect when person vote, bot or webhock send to channel?

#
dbl.webhook.on('vote', vote => {
let embed = new Discord.RichEmbed()
.setDescription(`User with ID ${vote.user} just voted!`)
client.guilds.get("ID").channels.get("ID").send(embed)
});```
like that?
green mantle
#

tias

restive otter
#

i'll try it, wait.

#

@green mantle i tried it and don't send anything :(

#

seriously :D?

green mantle
#

is your url still 0.0.0.0

restive otter
#

What are you using for host @restive otter

#

@restive otter can i talk you in DM?

#

@restive otter why not here?

#

okay stay here.

#
const DBL = require('dblapi.js');
const dbl = new DBL('', { webhookPort: 5000, webhookAuth: 'password' }); dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});
dbl.webhook.on('vote', vote => {
let embed = new Discord.RichEmbed()
.setDescription(`User with ID ${vote.user} just voted!`)
client.guilds.get("701054225571905636").channels.get("703454462681022564").send(embed)
});```
#

that's my code correct? @restive otter

#

yes but your Auth can seenable

#

xD sry.

#

you need to just put correct url

#

in?

#

are you using glitch?

#

nope

#

windows host

#

Then i dont know D:,sorry...

#

:C

#

if i using glitch? @restive otter

hard ridge
#

Hi guys I got this error when try to setup the webhook upvote test:
raise Unauthorized(resp, data) dbl.errors.Unauthorized: Unauthorized (status code: 401)

#

Token and password looks good

sullen nymph
#

Reset your token

hard ridge
#

Ok let me try

#

What is the easiest way to get the webhook URL if self hosted bot?

green mantle