#topgg-api

1 messages ยท Page 91 of 1

viscid forum
#

let me test it

#

this in the so if(await dbl.has right?

olive arrow
#

Yes should work

onyx quest
viscid forum
#

@olive arrow now i have the oppisite problem ๐Ÿ˜†

olive arrow
#

Are you sure that the person just hasn't voted

#

Try this

viscid forum
#

i did it when i did not vote it worked, then i voted and it said i still havent voted

olive arrow
#
const voted = await dbl.hasVoted(message.author.id)
if(voted) {//continue old code from here```
viscid forum
#

under first if on at ippy top

#

tippy*

#

or very id better word

#

ok i think it works now not sure tho

strong eagle
#

Who using BDFD

olive arrow
#

What

topaz verge
#

token undefined??

crimson oriole
#

i did voted my bot

#

but it says havent

#

about 4 hours ago

pure nymph
#

@topaz verge regen token

topaz verge
#

@pure nymph oke fixed

#

thanks

pure nymph
#

urwel

restive otter
#

How bot get user vote
suchas
if have someone vote then sent message to channel (voteusername)

#

javascript

olive arrow
#

Webhook

faint phoenix
#

Is it possible to have the username of the person when they vote? To avoid that when it is not on my server it writes "invalid-user" sorry my english is not very good

past flume
#

@faint phoenix code it to only work with your server id

twin hedge
#

How can i get user vote info?

restive otter
#

wdym?

twin hedge
#

upvote info?
Is there any method..

restive otter
#

How bot get user vote
suchas
if have someone vote then sent message to channel (voteusername)
javascript

#

what host are you use ?

twin hedge
#

galaxy gate..

twin hedge
#

I used this and voted

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

It won't get invoked..

frigid basin
#

I tried that too, I ended up using a separate bot for it

true talon
#

i have a question with shard&server post & kurasuta (a custom cluster & sharding manager for discord.js). where should i invoke the dbl webhook? I currently invoke it here in my main.js file, but idk if its the good place, because only thr server count is posted this way...

sullen nymph
#

@twin hedge Show me your full code related to top.gg

twin hedge
#
class DailyRewards(commands.Cog):
    """Handles interactions with the top.gg API"""

    def __init__(self, bot):
        self.bot = bot
        self.token = 'TOken' # set this to your DBL token
        self.dbl = dbl.DBLClient(self.bot, self.token)


    @commands.command()
    async def daily(self, ctx):
        check_users_votes = await self.bot.Users_Upvotes.find_one({"UserID" : ctx.author.id})
        if check_users_votes == None:
            check_vote = await self.dbl.get_user_vote(ctx.author.id)
            print(check_vote)
            if check_vote == True:
                await self.bot.Users_Upvotes.insert_one({"UserID" : ctx.author.id, "Streak" : 1, "Last Voted At" : datetime.datetime.utcnow()})
                check_users_votes = await self.bot.Users.find_one({"UserID" : ctx.author.id})
        embed = await get_upvote_embed(check_users_votes)
        await ctx.send(embed = embed)

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

def setup(bot):
    bot.add_cog(DailyRewards(bot))

Other not related to top.gg

#

This event is not working,
on_dbl_vote..

sullen nymph
#

wellll

#

You're not using webhook_x kwargs in DBLClient

twin hedge
#

Let me check

faint phoenix
#
(node:13) UnhandledPromiseRejectionWarning: Error: postStats requires 1 argument
at DBLAPI.postStats (/home/container/node_modules/dblapi.js/src/index.js:142:45)
``` Why i have that ?
tranquil fox
#

Hi, I would like to put a more than simple voting system on my bot. The person votes and the bot stores in a .json the number of times they voted and sends him a pm.
I just have this error that I can't resolve.
Thank you !
TypeError: Cannot read property 'on' of undefined

dbl.webhook.on('ready', hook => {
    console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
  dbl.webhook.on('vote', vote => {
    console.log(`Cette personne viens de votรฉ pour le serveur !
    Son ID est : ${vote.user}
    Son pseudo : ${vote.user.tag}`);
    if (!votes[member.id]) {
        votes[member.id] = []
    }
    votes[member.id].unshift({
        reason: reason,
        date: Date.now(),
        mod: message.author.id
    })
    fs.writeFileSync('./votes.json', JSON.stringify(votes))
    vote.user(`J'ai bien pris en compte votre vote et je vous en remercie !`);
});
#

I specify that I have installed all the npm modules*

#

?

restive otter
#

@tranquil fox did u set URL and Auth?

tranquil fox
#

yes

languid wigeon
#

how can I get the bot to accpet an input

#

like !coinflip [input]

#

never works

jolly hornet
#

-api

abstract mothBOT
arctic oriole
#

is there a way to use API to update member count of a server that I own and have my own bot in

sullen nymph
#

DSL doesn't have an API

#

You'll have to invite the bot to the server and edit the server page

arctic oriole
#

the discord server list bot? cause its already there, you said I have to take steps on the top.gg website as well?

sullen nymph
#

Yeah, on your server page basically press Edit and Submit

arctic oriole
#

oh hey, that was easy, thanks

alpine gull
#

With this api, I can add money or something to a user if they upvote the bot?

median badger
#

Yes

alpine gull
#

Thought so, thank you

twin hedge
#

Can Someone Reply?

tired wagon
#

Reply

twin hedge
tired wagon
#

You tell me to reply

#

I do it

twin hedge
#

Please Ping, if someone can Answer...

loud dust
#

hello I have troubles with my autovote code..

#

can anyone help me?
(Please ping me if you can help)

twin hedge
#

Same, happening with me, but in python.. This thing not seems to be working

loud dust
#

@mighty shuttle So sorry to bother you. but do you know how to fix this problem ^

twin hedge
#

@loud dust It is not invoking when vote is added right...?

loud dust
#

correct. whenever I- or anyone else for that matter votes for my bot..

#

he doesnt even log it

twin hedge
#

Same problem with me, did u used webhook thing in top.gg edit section?

loud dust
#

yes under webhook events

twin hedge
#

API channel must be active, and they should answer

#

I have been waiting here since yesterday...

#

But No Answers at all.

loud dust
#

I mean

#

I would dm Oliy

#

bc he said to

#

but im not sure

#

if it is the right thiung to do

twin hedge
#

@loud dust You can get some examples from web.. I think

loud dust
#

I tried ngl

twin hedge
#

Me too, but got nothing

loud dust
#

screw it

#

ima do the dm

twin hedge
#

Docs are also not proper

loud dust
#

I went for the dm

twin hedge
#

What should be url, for in-build webhook?

hollow flame
#

@twin hedge vc auuva re

cursive geode
#

@twin hedge
Localhost

twin hedge
#

@cursive geode Not seems to be working

loud dust
arctic arch
#

you haven't configured your webhook properly

#

you need to set a webhookPort or supply a webhookServer to hook to

twin hedge
#

I have python 3.8.2, will the api work??

sullen nymph
#

Yes

twin hedge
#

I tried many times not seems to work, can you help me..

sullen nymph
#

What does your code look like

restive otter
#

yes shoe cude

twin hedge
#

@sullen nymph I am just trying to give coins to users, when they vote our bot..

sullen nymph
#

Please refrain from posting any unnecessary comments in this channel

#

@twin hedge Show me your top.gg cog

twin hedge
#
class DailyRewards(commands.Cog):
    """Handles interactions with the top.gg API"""

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


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

I am just confused with webhooks

sullen nymph
#

What is the URL you entered on top.gg

twin hedge
#

IP:5000/dblwebhook

sullen nymph
#

Add http:// before

twin hedge
#

It is there..

sullen nymph
#

make sure your port is open and forwarded to the correct machine

#

send me the full URL, I'll get back to you after I'm done with my personal stuff

twin hedge
#

Ohkk,
Which url, that local host?

sullen nymph
#

the URL you entered on top.gg without editing anything out

#

DM it to me

timber fjord
#

can someone pass me an API for creating bots?

sullen nymph
#

-api

abstract mothBOT
frigid basin
#

any way to check if a user has voted for the bot at any point? (discord.py btw) for like vote locked commands

knotty garnet
#

database

restive otter
knotty garnet
#

port 11?

#

u sure that's right?

#

anyway, is the port fowarded?

#

also, if you're using nginx, is the port proxied?

restive otter
#

I'm not using nginx

knotty garnet
#

what about the other 2 questions?

restive otter
#

i tested other ports but still did not work

#

wdym with forwarded?

knotty garnet
#

ok, so I guess it's not fowarded

#

fowarding a port is allowing external connections to it (aka exposing it)

#

without that dbl won't be able to send http requests to it

restive otter
#

well

vapid cape
#

where is your bot hosted?

restive otter
#

i currently have it open on my computer but i host it on heroku or other hosting services

#

or dashflo

vapid cape
#

heroku uses port 3000 and links it with the default http/https ports via reverse proxy, and also provides you a public url for that

#

so when hosting in heroku, the correct webhook url is https://PROJECTNAME.herokuapp.com/dblwebhook

#

and you have to use port 3000 or process.env.PORT in your code

restive otter
#

Okay, lemme try it out.

#

Ah doesn't work.

vapid cape
#

you need to enable a web dyno

#

somewhere in your heroku configuration

restive otter
#

okay did it

#

ahhh heck

alpine gull
#

do i need to use webhook?

vapid cape
#

depends what you want to do

knotty garnet
#

only if you want "on vote" events

alpine gull
#

Just for upvoting

restive otter
#

Tim, isn't there other way to do it than web dyno?

knotty garnet
#

no

#

are you worried about the time limit on free dynos?

alpine gull
#
const { Client, MessageEmbed } = require("discord.js");
const DBL = require("dblapi.js");
const dbl = new DBL('x', Client);
var db = require('quick.db')
let cooldown = new Set();
let cdseconds = 43200;

module.exports = {
    name: "upvote",
    catergory: "misc",
    description: "Vote once a day",
    usage: "Upvote",
    async run(client, message, args) {

        if(cooldown.has(message.author.id)) {
            let noembed = new MessageEmbed()
            .setAuthor(message.author.username)
            .setDescription("You may only vote every 12 hours!")
            .setColor("#ff0005");
    
            return message.channel.send(noembed);
        };

        let userBank = db.fetch(`bank_${message.guild.id}_${message.author.id}`)

        dbl.hasVoted(message.author.id).then(voted => {
            if (voted) message.reply("thanks for the upvote! here's $5000!")
            db.add(`bank_${message.guild.id}_${message.author.id}`, 5000);

            });
    }
}``` Never used this before, nor used Javascript in a while, is this how i would do it?
vapid cape
#

no

#

if you just want to use dbl.hasVoted, you dont need client

#

just dbl = new DBL("top.gg token")

alpine gull
#

otherwise, it's all fine?

vapid cape
#

if you want your bot to show how many guilds its in in top.gg when you need to pass client, but your original bot client, not a new uninitialized copy of client

alpine gull
#

ah okay, that makes sense, thanks

little robin
vapid cape
#

yes

little robin
#

thanks

vast geyser
#

BDScript are not important for peoples...

sullen nymph
#

-api

abstract mothBOT
signal tiger
#

-api

restive otter
#

hey so cna som,eone explain how do you just get the server ocunt working

#

do you haev to put a chink of code in main.py to make it work

#

im usng python btw

rough crater
#

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

restive otter
#

yeah but like what do i do with it

#

i dont know how to implement in my code

#

@rough crater

#

i did this and ran it

#

nothing happened

#

server count doesnt display on the website

#

please @ me back

median badger
#

Just give it some time

warped quiver
#

time

#

you gotta be specific

#

like 5.319231209 seconds

sullen nymph
#

Whenever CF cache changes

warped quiver
#

yeah maybe just wait a bit

#

like 15 mins

sullen nymph
#

Or straight up use the /api/bots endpoint and fetch the server count from there

viscid forum
#

My code works fine, but after like half or day or more it just stops working. If i reset my bot it srtats working again. what didi i do wrong or how can i fix

viscid forum
#

pls ping me

frosty quarry
#

Hello,
Do that python code supposed to show me the votes ?

@commands.Cog.listener()
    async def on_dbl_vote(self, data):
        logger.info('Received an upvote')
        print(f' > DBL Upvote !\n{data}')
median badger
#

It will show when you got a vote

frosty quarry
#

But it doesn't work even if the server count works

simple cedar
#

Does anyone know how to use a space after the prefix?

#

I've tried adding it like (prefix ) but it won't work

twin hedge
#

It should work

#

Hello,
Do that python code supposed to show me the votes ?

@commands.Cog.listener()
    async def on_dbl_vote(self, data):
        logger.info('Received an upvote')
        print(f' > DBL Upvote !\n{data}')

@frosty quarry Not working for me, is this working for you.
If Yes. Please let me know

frosty quarry
#

@twin hedge Nah, nothing on my terminal when I reveive an upvote

twin hedge
#

@frosty quarry Same, do u implemented webhook thing?

frosty quarry
#

Nop, I did nothing except this code from the docs:

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

    async def on_guild_post():
        print("Server count posted successfully")
    
    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        logger.info('Received an upvote')
        print(f' > DBL Upvote !\n{data}')
faint phoenix
#

Can you help me ? ```js
(node:13) UnhandledPromiseRejectionWarning: Error: postStats requires 1 argument
at DBLAPI.postStats (/home/container/node_modules/dblapi.js/src/index.js:142:45)

sullen nymph
#

Apparently the docs aren't clear enough to say "use webhook_x kwargs in DBLClient"

frosty quarry
#
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/dblwebhook', webhook_auth='Pass?', webhook_port=5000)
sullen nymph
#

webhook_auth is a password you create yourself and enter on your bot's Edit page

#

Other than that, the snippet you sent seems alright

frosty quarry
#

Yea thanks, I did it and typed it on my webhook bot page with the URL http://IP:5000/dblwebhook

#

And I'm receiving the test webhooks

#

Where can I find the "Logger" ?

sullen nymph
#

Hm? What do you mean by logger?

frosty quarry
#

logger.info('Received an upvote')
These lines, where are they wrote ?

sullen nymph
#

logger is defined as a global variable in the setup function

frosty quarry
#

So I need to make a command that print the Logger content ?

sullen nymph
#

Not really, the logger just prints stuff. You can remove anything related to it and make the on_dbl_vote function send a message in a channel if you want to

frosty quarry
#

Ok thanks, I'll remove that Logger. But the on_dbl_vote doesn't work yet for me, I'm tryng to figure out how to do

sullen nymph
#

Well if on_dbl_test works, vote event should too thinkW

frosty quarry
#

Hm.. I'll retry..

#

Is this line supposed to be shown every 30min ? python async def on_guild_post(): print("Server count posted successfully")

sullen nymph
#

My suggestion is to test your code with the test event and once you are sure it works perfectly, put it in the vote event

#

Does the guild_post event have listener decorator?

frosty quarry
#

Ok my bad thanks.. @commands.Cog.listener()

sullen nymph
#

mhm

frosty quarry
#
{
  "bot": "705373559299637278",
  "user": "326508798753636363",
  "type": "upvote",
  "query": "",
  "isWeekend": false
}

Receiving it!

sullen nymph
#

Splendid

frosty quarry
#

Unclosed client session

#

How do I close client session ?

#

I have some long errors with that

sullen nymph
#

oh dear God

frosty quarry
#

Because I was in auto_post and I turned it into a manual server count post

sullen nymph
#

I really need to get to it sooner

#

I'll try to fix it in next update

#

Thanks for the report

frosty quarry
#

Strenght to you!
So I can't really do anything for that

sullen nymph
#

Well, aside from editing the source code

frosty quarry
#

topgg is down, hope i did nothing ๐Ÿ˜ญ

sullen nymph
#

... stop DDoSing our servers by testing your webhooks. facepalm

#

Nah, you didn't do anything

frosty quarry
#

๐Ÿ™ˆ

#

Can I let the auto_post and add the webhook after ?
Like ```python
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/dblwebhook', ...)

sullen nymph
#

I don't see why not?

#

They don't conflict with each other

frosty quarry
#

It seemed like I don't receive webhooks anymore when I turn on autopost

#

It's ok thanks, I'll continue to manage my code

faint phoenix
#

@sullen nymph How i can patch that ?

sullen nymph
#

What are your discord.js version and code?

faint phoenix
#

discord.js (v12) and: ```js
bot.on('ready', () => {
setInterval(() => {
dbl.postStats(bot.guilds.size);
}, 360000);
});

restive otter
#

guilds.cache.size

faint phoenix
#

Ah, yes I just forgot the .cache ๐Ÿคฆ

hazy forum
#

hello, can anyone help me with discord.py?

I want to make a task loop to send message to specific channel every 30 minutes. I have set the channel_id I need on database. To access it, I need guild id to find the channel_id. The query looks like this:
select channel_id from configs where guild_id = ?

But @discord.ext.tasks.loop has no arguments. How can I get current guild_id to run query above without any arguments on @discord.ext.tasks.loop function? Thanks! problem solved

frigid basin
frigid basin
#
    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        user = self.bot.get_channel(721883157804220507)
        await user.send(data)``` anyone have any ideas on why this doesn't work?
green mantle
#

you mean other than those god awful var names?

frigid basin
#

yes lol

green mantle
#

no idea you havent given an error or enough code soooooo

frigid basin
#

there is no error

sullen nymph
#

What does your DBLClient look like

frigid basin
#

Gimme 2 secs

#

is that this line? py self.dblpy = dbl.DBLClient(self.bot, self.token)

sullen nymph
#

You're not running the webhook at all

restive otter
#

please i want game for my bot (discord.py) Give my idea

frigid basin
restive otter
#

yes i do

rich perch
#

Whats the difference between

#

dbl-api

#

vs dblapi.js

restive otter
#

๐Ÿคฆ

rich perch
#

welp

#

@jaunty depot sorry for ping but its giving me an error for dblapi.js so maybe I need to use dbl-api, but im confused why there are two

jaunty depot
#

its dblapi.js

rich perch
#

Oh

#

whats the dbl-api then

sullen nymph
#

unofficial package made by someone

rich perch
#

ah ok

frigid basin
#

self.webhook_path = kwargs.get('webhook_path')
is the webhook_path the webhook url?

sullen nymph
#

Why the self.webhook_path

#

Oh I see what you did

#

No, it's the endpoint thing after ip:port

rich perch
#

Whats stopping someone to postStats with a random number

sullen nymph
#

The fact that they could be banned from top.gg

rich perch
#

ah ok

#

I c

next pendant
#

how do people command lock stuff to the votes endpoint?

knotty garnet
#

Simple database boolean

viscid forum
#

not sure what my problem even is, did not edit code just started happing in middleof day

restive otter
#

@viscid forum oof that's not python

#

I only know python

viscid forum
#

f

#

yeah i did not even change my code that just started happing no clue lmao

proud flare
#

How to make guild count visible for my bot in top gg?

proud flare
#

thanks

restive otter
#

Oh God JavaScript

viscid forum
#

@proud flare javascrpit?

willow spindle
#

can you show full error

restive otter
#

Gotta hate that syntax tho. All the unnecessary brackets

viscid forum
#

me? @willow spindle

proud flare
#

Yes js

willow spindle
#

yes

restive otter
#

Curlies

willow spindle
#

@proud flare post server count using top.gg api

viscid forum
#
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26)
(node:990) 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: 845)
proud flare
#

kk thx

viscid forum
#

just making sure @proud flare

willow spindle
#

no idea

viscid forum
#

Gotta hate that syntax tho. All the unnecessary brackets
@restive otter help you stay oginized. good for newbies like me

#

f

#

i am so confused

#

dose it want me to put .catch() somewhere?

#

@willow spindle figured it out

#

its caused by low connectivety

willow spindle
#

maybe

viscid forum
#

my vps must be craping out

restive otter
#

How would one make a bot stats command?

#

ooh yeah

#

organization is key

proud flare
#

ReferenceError: Cannot access 'client' before initialization

#

whats wrong?

#
const Discord = require('discord.js');
const DBL = require("dblapi.js");
const dbl = new DBL('MY API TOKEN', client);
dbl.on('posted', () => {
  console.log('Server count posted!');
})

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

thats my code

restive otter
#

It throws me an error when trying to download the discord.js libraries in glitch: /

proud flare
willow spindle
#

yes

proud flare
#

but then

ReferenceError: Cannot access 'client' before initialization
@proud flare

#
const Discord = require('discord.js');
const DBL = require("dblapi.js");
const dbl = new DBL('MY API TOKEN', client);
dbl.on('posted', () => {
  console.log('Server count posted!');
})

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

@proud flare and thats the code

willow spindle
proud flare
#

k sure

shut heath
#

Can anybody help me with getting a message everytime someone upvotes my bot?

#

Tag me please

tame marten
next pendant
#

I'm confused about the command locked stuff

#

so you can make it so certain commands will vote?

shut heath
#

What version are you on? @tame marten

restive otter
#

@tame marten v12?

tame marten
#

yea its 12

restive otter
#

use cache then

twin hedge
#

there is a windows problem as i know, localhosts won't work on external devices

vapid cape
#

wat

limpid vale
#

how to get dbl token?

sullen nymph
#

Unapproved bots can't use the top.gg API

limpid vale
#

oo

sullen nymph
limpid vale
true talon
#

Ok

shut heath
#

Can anybody help me with getting to know when someone upvotes my bot

wide nimbus
#

ฤฐ tried this server-count-example and paste my dbl token to 'AUTH' but not worked and send me that error
Error: ```j
Error: getaddrinfo ENOTFOUND https://discordbots.org
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:64:26) {
errno: 'ENOTFOUND',
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'https://discordbots.org'
}

median badger
restive otter
#

@wide nimbus Use "dblapi.js" module for post server count and other things

wide nimbus
#

gotta try

#

Tried this and i got a error
Error: serverCount is not a number but a undefined instead at Client.postStats (/home/runner/PersaKdcBotHost123/node_modules/discord-bot-list/index.js:92:26)

willow spindle
#

can you read the code

wide nimbus
#

lol my bad

#

need translate to read codes btw

restive otter
#

@wide nimbus why you trying this?

willow spindle
#

use official library

restive otter
#

^

willow spindle
wide nimbus
sullen nymph
#

Most of those are unofficial or outdated

wide nimbus
#

oh..

sullen nymph
#

I suggest just using the official library

willow spindle
#

official library has an autoposter. Use it

wide nimbus
#

thanks ill try

cobalt geyser
#

PersaK

wide nimbus
#

yea?

little robin
idle current
#

so I have a restful api running on ngrok, but when I sent a test payload to the api I get nothing, any help?

#

wait a sec

#

itโ€™s done it just not logged it

viscid forum
#

My error, just started in the middle of the day yesterdat, iread that it was connection error from my vps. but has not stopped. what do i do (what code do i provide)

restive otter
#

can someone tell me how to get started

#

i already read the docs

#

but like is there a batch of code i can just chuck in my main.py to make it start working

viscid forum
#

Thatsserver count

idle current
#

thatโ€™s node js

#

but like is there a batch of code i can just chuck in my main.py to make it start working
@restive otter What are you looking for? Server count posts?

restive otter
#

no

#

just want my server count to show up on the top.gg

viscid forum
#

i am getting this error, i think i am being rate limited by top.gg what do i do, i was getting this error a whole bunch before this startes (maked with red is the old error)

vapid cape
#

do you use postStats?

#

or just the autoposter?

viscid forum
vapid cape
#

thats just the event

#

it logs when the post happens, it doesnt do the post

viscid forum
#

oh

vapid cape
#

do you do dbl.postStats() anywhere?

viscid forum
#

no

vapid cape
#

you just do dbl = new DBL(token, client)?

viscid forum
vapid cape
#

do you put client/bot at the end?

viscid forum
#

ye

vapid cape
#

ok, how many times in how many files do you use this code?

#

and which files?

viscid forum
#

and thats the only file

vapid cape
#

show more code

viscid forum
#

where

vapid cape
#

its new DBL() in the beginning or the file? or inside client.on("ready")?

viscid forum
#

begining

vapid cape
#

also, is dbl.hasVoted directly inside client.on("message")? or inside something else?

viscid forum
vapid cape
#

but directly? or inside some if down the road?

#

show the full .on("message") block

viscid forum
#

ye directly. and by that you mean all the code inside it?

vapid cape
#

yes

#

including the on("message")

viscid forum
#

thats like 1500 lines soo b eprepared to see the worst code you ever have seen

vapid cape
#

put it in a hastebin or similar

viscid forum
vapid cape
#

you werent kidding lmao

viscid forum
#

nope i as not

vapid cape
#

but all jokes aside, the problem is that you're creating an API request to top.gg on EVERY SINGLE MESSAGE you ever receive from discord

#

so if your bot is in 50 servers, and in each server someone posts 1 message, you isntantly create 50 requests to top.gg

#

which is basically an instant ban from the top.gg api

viscid forum
#

so how do i fix that?

#

and do i get unbanned?

#

or am i perm banned

vapid cape
#

you get unbanned after 1 hour afaik

viscid forum
#

so how do i fix that

vapid cape
#

you fix it by always checking for the command before attempting any kind of action

#

the same thing applies to all your database calls

#

every heavy computing, disk access or network request should always be done only AFTER checking which command was used

#

otherwise you're performing those actions on every single message even if the message doesnt contain any actual command

#

which makes your bot extremely slow and resource-heavy

viscid forum
#

(i am new to this as you can most likly tell) so i how do "checking for the command before attempting any kind of action"

#

like cmd ===

vapid cape
#

you're already doing it

#

how to you check which command was used?

#

message.content.startsWith

viscid forum
#

ye

vapid cape
#

you have lots of those in your code

#

so put all your heavy code inside those

#

never outside

viscid forum
#

so i should put the voted var inside it?

vapid cape
#

yes

#

you should always check which command was used, ie if message starts with some command

#

before doing anything else

#

only after you verify that the message did indeed start with some voting command, only then will you create a hasVoted request

#

same thing will all your database code

#

and almost everything else

#

the order in which things are done are extremely important in this case, because your bot is processing potentially hundreds of messages per second. one thing in the wrong order can basically destroy your bot

viscid forum
#

but what if i wanto use a idk = db.fetch(whatever_${blah blah}) in multiple if(message.content.startsWith

vapid cape
#

basically, you put a copy of it in each of them

#

for example

#
db.fetch(1)
if(message.content.starsWith(a)) {
  db.fetch(2)
}
if(message.content.starsWith(b)) {
  db.fetch(2)
}
#

lets examine this

#

if your bot receives 100 messages

#

db.fetch(1) will be executed 100 times

#

if one of those 100 messages contains "a", db.fetch(2) will be executed only 1 time

#

if the message contains "b", db.fetch(2) will still be executed only 1 time

#

but regardless of what the message contains, db.fetch(1) will still be executed 100 times

#

database operations tend to be slow, so you can imagine the performance difference that makes

viscid forum
#

oh so in every message. content starts with re featch in the same var?

#

that uses it

vapid cape
#

its never a refetch

#

because only one of them will be executed at any given time

#

unless you have multiple copies of the same startsWith for some reason

viscid forum
#

i mean like to it twice

vapid cape
#

yes you do it twice, once inside each

#

but that doesnt mean it will be executed twice

#

it will only be executed once, depending on which command it was

viscid forum
#

ok i will do that some time later cause i dont have that energy rn. but thank you for helping me. i am going to test the voted var in the if message.startsWith in a hour or so when im unbanned

vapid cape
#

alright

wanton nymph
#

If I set the webhook URL (for bot) as a website, will the index of my website be able to receive the requests?

vapid cape
#

your website needs to listen to a POST request to the index page

#

as opposed to a GET request, which is the default that websites use

#

other than that, yes

wanton nymph
#

Cool, would a if (request.method == 'POST') of sorts work, just listening for POST requests?

vapid cape
#

are you running express.js?

wanton nymph
#

Yup

vapid cape
#

then you can do app.post("/",(req,res) => {})

wanton nymph
#

I see, well thanks a lot!

vapid cape
wanton nymph
#
const DBL = require('dblapi.js');
const dbl = new DBL('auth', { webhookPort: 5000, webhookAuth: 'password'});
dbl.webhook.on('ready', hook => {
    console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
app.post("/",(req,res) => {
  console.log(`Received post request!`)
  dbl.webhook.on('vote', vote => {
    console.log(`User with ID ${vote.user} just voted!`);
  });
})

Received post request! triggers, but the user ID for the vote doesn't. Do I need to place the vote listener outside of the POST request? (Sorry, I'm a big newbie with how post/request works. After some research and reading docs, this was the best I could come up with.)

true talon
#

Youre not supposed to create a express server to handle post requests, because the dbl webhook do it itself

#

And in your bot settings on your dbl page you have to do the rest est to /dblwebhook instead of /

vapid cape
#

if you use the express method you dont need dblapi.js at all

hollow temple
#

How do I post the total number of servers to dbl when I have a shard in my bot

hollow temple
#

Pls help me

vapid cape
#

which library and language?

restive otter
#

ne yapmam gerek

hollow temple
#

@vapid cape Discord.js

spark gust
#

@restive otter, top10 komutunu sil.

twilit ingot
#

zd

restive otter
#

dรงs

vapid cape
#

@hollow temple if you're using the sharding manager, just put new DBL("top.gg token", bot/client) in your shard file, and it will do it for you

high hull
#

what is this language lol

toxic niche
#

Is there supposed to be a delay between a user voting and a bot being able to check that they did? My bot has to wait about 3-5 minutes to allow access to a vote-lock feature after voting

twin matrix
#

omg

#

i copied wrong thing

#

sorry wait

#

Error: 503 Backend fetch failed

#

yeah this

#

error

toxic niche
#

A common error with the website, usually fixed within 12 hours ยฏ_(ใƒ„)_/ยฏ

twin matrix
#

oksy

#

oKay

sullen nymph
#

@toxic niche The API endpoint has a delay, yeah. That's why we recommend using webhooks

toxic niche
#

I need to figure out how to do that with python

sullen nymph
#

dblpy has official webhook support

restive otter
#

What is webhook?

#

Im new at js

restive otter
#

you can own web hook

faint phoenix
#
(node:13) UnhandledPromiseRejectionWarning: Error: 503 Backend fetch failed
at IncomingMessage.<anonymous> (/home/container/node_modules/dblapi.js/src/index.js:118:25)
``` Wit ?
fickle zealot
#

hello

#

im trying to connect my python bot to DBLs api

#

but im a bit confused

#

i thought i would just start of with the example:

import dbl
import discord
from discord.ext import commands


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

    def __init__(self, bot):
        self.bot = bot
        self.token = 'dbl_token' # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes

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

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

but im not sure what value im supposed to provide for setup(bot)

#

i tried client and client.user and neither worked :/

sullen nymph
#

What

fickle zealot
#

um

#

lol

#

:/

#

um well if anyone could help me that would be great :))

sullen nymph
#

What do you even mean with client.user

#

The setup function is automatically called by d.py in external files

#

If you are adding the cog (class) to your main bot file, you don't really need it

weak dove
#

EDIT
The issue was that the firewall was blocking the port.
Thanks to Shiv, I fixed it by creating a new firewall rule:
TCP > Port 5000 > All Connections

~~The webhook doesn't seem to be working for me, I'm not getting any response when running the test in the bot's edit page.
Here's my code:

class MyCog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.token = "TOKEN"
        self.dbl = dbl.DBLClient(self.bot, self.token, webhook_port=5000, webhook_path="/dblwebhook", autopost=True, webhook_auth="test_auth")

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

And on the bot's edit page I have:~~

sullen nymph
#

DM me the IP you are entering on the top.gg page

#

Are you sure the port is open

little otter
#

does anyone here have an example of them implementing this into their bot?

restive otter
#

shivaco

#

are you here?

twin hedge
#

@sullen nymph The actual problem is dbl not working on Public Ips... (Maybe Windows Problem)

spiral steeple
#

is your ip static, is your firewall on? if so, does the port allow traffic?

heavy drum
#

Is there any quick way to check if any of the servers my bot is in is on the server list?

restive otter
#

no

errant pine
#

Hi guys. Any idea how could I check if user voted for my bot, using webhooks and .NET Core? Are there any examples?

jaunty plank
restive otter
#

File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.7/site-packages/discord/ext/commands/core.py", line 72, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ApiResponseError: {"error": "Rate limit exceeded.", "errorCode": 457}

How to fix this problem any one can help me

true talon
#

Rate limit

#

Just wait for rate limit to expire

little robin
#
const DBL = require('dblapi.js');
const dbl = new DBL('auth', { webhookPort: 5000, webhookAuth: 'password'});
dbl.webhook.on('ready', hook => {
    console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
app.post("/",(req,res) => {
  console.log(`Received post request!`)
  dbl.webhook.on('vote', vote => {
    console.log(`User with ID ${vote.user} just voted!`);
  });
})
restive otter
#

?

little robin
#

password and auth , where exactly do I set these parts?

restive otter
#

ooof

#

From your bot's edit page

little robin
#

I know, but I couldn't find a password.

sullen nymph
#

Anything you want

#

It's a password set by you

little robin
#

thank you. I'm trying

balmy hamlet
#

and btw

#

that code is still not going to work as expected i'd say

#

since the first post request you get from dbl won't be received by the vote handler

wanton nymph
#

When I post server counts to top.gg using dbots, it only displays the server counts of one shard. Is there a workaround for this while using dbots, or should I just use the top.gg API directly?

restive otter
vapid cape
#

there are options for sharding

wanton nymph
#

huh, I couldn't find that anywhere

#

awesome, thanks so much for the help both times ๐Ÿ‘€

frigid basin
#

Any ideas on how to get total/monthly bot votes with the API on discord.py?

spiral steeple
#

does dblpy not cover the get bot endpoint?

sullen nymph
#

It covers all endpoints

spiral steeple
#

then just use get bot

jaunty plank
dull rune
sullen nymph
#

-servercount @dull rune

abstract mothBOT
#

@dull rune

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.

dull rune
#

okay thanks

willow spindle
abstract cave
#

i realized lol

willow spindle
stuck fjord
#

#play lovely

#

#play lovely

restive otter
#

i just trying to test the auto count, but it keep outputing this:

Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x000001D0AACBE460>
#

python 3.8.3

twin matrix
#

how to get the id of the person who just voted?

shut belfry
#

I have dumb question. Can I use API before bot was approved?

balmy hamlet
#

tl;dr: no

shut belfry
#

as I see I can't get their API key. Ok

radiant peak
#
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/bot.py", line 608, in _load_from_module_spec
    setup(self)
  File "/home/narmy/cogs/topgg.py", line 69, in setup
    bot.add_cog(TopGG(bot))
  File "/home/narmy/cogs/topgg.py", line 11, in __init__
    self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/dblwebhook', webhook_auth='dblhook1234', webhook_port=1556) # Autopost will post your guild count every 30 minutes
  File "/usr/local/lib/python3.8/dist-packages/dbl/client.py", line 86, in __init__
    self.task2 = self.loop.create_task(self.webhook())
  File "/usr/lib/python3.8/asyncio/base_events.py", line 429, in create_task
    self._check_closed()
  File "/usr/lib/python3.8/asyncio/base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "main.py", line 90, in <module>
    bot.load_extension(extension)
  File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/bot.py", line 653, in load_extension
    self._load_from_module_spec(spec, name)
  File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/bot.py", line 613, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.topgg' raised an error: RuntimeError: Event loop is closed
main.py:93: RuntimeWarning: coroutine 'DBLClient.webhook' was never awaited
  traceback.print_exc()
```so I always get printing this
#

who can help me?

green mantle
#

whats you code

restive otter
#

g

tepid trench
#

What all info can we get from top.gg?

radiant peak
#

@green mantle i fixed it

#

i sadly imported main into a cog lmao

rich furnace
#

Hwa do I put in Authorization

jaunty depot
#

You put whatever you want there

#

And check that "whatever you want" in your code

#

To see if the request is coming from DBL or not

rich furnace
#

ok

#

what about the token @jaunty depot

#

wait

#

so is it like

#

https://LINKolink$(#3/dbl<token>

#

@jaunty depot

jaunty depot
#

what

#

For example, I was using the url part like http://myvpsip/vote

#

And had something in the auth key part

#

Which I used too confirm the requests coming from DBL

rich furnace
#

..

#

the thing I get is the DM from the bot

#

which gives me link and the token

#

the vps link

jaunty depot
#

I don't get what you mean

rich furnace
#

@jaunty depot

#

this

restive otter
#

I am using a vps for my bot, and I event is not getting invoked on_dbl_vote event invoked...
With the http://VPSIP:5000/

rich furnace
#

@jaunty depot here ^^^

#

I don't know what to do

#

in this step

jaunty depot
#

What is this bot

rich furnace
#

DBL Vote

restive otter
#

@rich furnace Thats just a random token, not connected with dbl

rich furnace
#

What do I do?

restive otter
#

this is for ur webhooks

rich furnace
#

isn't this the support server?

restive otter
#

paste that in webhook auth

#

no

rich furnace
#

hmm wym

jaunty depot
#

That bot is NOT an official bot made by DBL

restive otter
#

see authorization

#

paste that token here

rich furnace
#

That bot is NOT an official bot made by DBL
@jaunty depot lol

#

sorry for wasting your time

restive otter
#

and url too and thats not official bot of dbl

rich furnace
#

ok

jaunty depot
#

No you don't paste your token to auth btw

restive otter
#

I am using a vps for my bot, and I event is not getting invoked on_dbl_vote event invoked...
With the http://VPSIP:5000/
@jaunty depot Can u answer this please

jaunty depot
#

You can use express to get the request

#

And I suggest you to add something like /vote at the end

restive otter
#

btw python doesn't have express

jaunty depot
#

Instead of doing just the url

#

You open express as another project

#

On your vps

#

Not inside your bot

restive otter
#

ohkk, then

#

how to connect it with bot then?

sullen nymph
#

Python has Flask and Django

jaunty depot
#

There's something called votehook on github

#

that has a good example of it

restive otter
#

Server not reachable I tried Flask

jaunty depot
#

It is not made by us but it was working last time I checked

restive otter
#

2 yrs ago, will this work

jaunty depot
#

I mean, nothing has changed really

#

Thats just a normal express example

restive otter
#

Well, i tried samething with flask, it works with gunicorn

#

but not on self hosted IP

#

Note : Working with repl.it
But neither with vpsIP nor with mypublicIP

jaunty plank
#

are you putting the text vpsIP and mypublicIP
or the actual ip?

#

because you listed both, but both are just placeholders for an IP adress

graceful abyss
#

What URL should I put for the WebHook of my bot?

obsidian tide
#

would it be dbl.post(client.guilds.cache.size) to update server amount?

sullen nymph
#

postStats

obsidian tide
#

26 servers working thanks!

sullen nymph
open forum
#

I can't get this working

#

I have 5000 port open for tcp and udp

restive otter
#

I saw a Turk!

open forum
restive otter
#

What's the problem bro?

open forum
#

Trying to set webhooks for dbl to get notification when someone vote for the bot

#

I don't even know if I should set up webhook for this feature but still

#

Can't set webhook get server's IP

restive otter
#

Its normal bro

open forum
#

Also, getting 404 page on ip:5000/dblwebhook

restive otter
#

its normal , too.

#

Can you come to dm?

spiral steeple
#

Well it doesn't listen for GET requests

fair herald
#

I didnt understand the webhook thing.

#

Wait

#

Does top.gg send a post request?

#

In the webhook?

sullen nymph
#

to the webhook

fair herald
#

Yeah

idle current
#

For people asking about voting webhooks, I watched this video https://youtu.be/fgTGADljAeg and then hosted it with ngrok and it all works fine. You will have to code a bit to get it so it deletes after 12h etc

In this video you will be building a fully functional REST API in under 30 minutes. You will learn how to setup a Node.js server with Express, how to connect that server to MongoDB through Mongoose, and how to setup a REST API with MongoDB and Node.js. This video is for any sk...

โ–ถ Play video
#

I put the link ngrok gave me into the webhook box and the test payload works

#

And if you do NodeJS for your bot, you can use superagent and use a get request to the api

#

Hope this helps people who need it

graceful abyss
#

What URL should I put for the WebHook of my bot?

jaunty plank
#

the url your webhook server is on

open forum
#

What URL should I put for the WebHook of my bot?
@graceful abyss http://<yourserverip>:5000/dblwebhook

#

And forward TCP|UDP port on 5000 with your server

graceful abyss
#

Thanks

faint phoenix
#
(node:21) UnhandledPromiseRejectionWarning: Error: 522 Origin Connection Time-out
at IncomingMessage.<anonymous> (/home/container/node_modules/dblapi.js/src/index.js:118:25)
at IncomingMessage.emit (events.js:228:7)
at endReadableNT (_stream_readable.js:1185:12)
at processTicksAndRejections (internal/process/task_queues.js:81:21)
(node:21) 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(). (rejection id: 1)
(node:21) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:21) UnhandledPromiseRejectionWarning: Error: 520 Origin Error
at IncomingMessage.<anonymous> (/home/container/node_modules/dblapi.js/src/index.js:118:25)
at IncomingMessage.emit (events.js:228:7)
at endReadableNT (_stream_readable.js:1185:12)
at processTicksAndRejections (internal/process/task_queues.js:81:21)
(node:21) 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(). (rejection id: 2)
(node:21) UnhandledPromiseRejectionWarning: Error: 522 Origin Connection Time-out
at IncomingMessage.<anonymous> (/home/container/node_modules/dblapi.js/src/index.js:118:25)
at IncomingMessage.emit (events.js:228:7)
at endReadableNT (_stream_readable.js:1185:12)
at processTicksAndRejections (internal/process/task_queues.js:81:21)
(node:21) 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(). (rejection id: 3)

It's ok ?

restive otter
#

No

#

i'm having trouble with putting this command into my bot () ```py
import dbl
import discord
from discord.ext import commands, tasks
import asyncio
import logging

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

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

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

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

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

    await asyncio.sleep(1800)

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

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

snow scroll
#

Hi, i have a problem
after a "post" stats dblapi.js return's "400 Bad Request"
code:

const servers = await client.shard.fetchClientValues('guilds.cache.size').then(r => r.reduce((a,b) => a+b));
DBL.postStats(servers, client.shard.ids[0], client.shard.count);```
restive otter
#

wat is this

manic solar
#

patrick

faint phoenix
#
(node:21) UnhandledPromiseRejectionWarning: Error: 522 Origin Connection Time-out
at IncomingMessage.<anonymous> (/home/container/node_modules/dblapi.js/src/index.js:118:25)
at IncomingMessage.emit (events.js:228:7)
at endReadableNT (_stream_readable.js:1185:12)
at processTicksAndRejections (internal/process/task_queues.js:81:21)
``` Can you help me ,
graceful abyss
#

Why does the client give me null?

graceful abyss
#

Is it possible to use client inside dbl.webhook.on?

twin matrix
#

(node:36) UnhandledPromiseRejectionWarning: Error: 524 Origin Time-out

willow hawk
#

Is the vote webhook not working? Not sure if i'm tripping

maiden sierra
#

So I have this setup:

import dbl
import discord
from discord.ext import commands

import os

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

    def __init__(self, client):
        self.client = client
        self.token = os.getenv("DBL_TOKEN") # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.client, self.token)

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

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

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

but when I receive a vote, nothing happens. The data is not printed.

#

So I double checked API and it says it should be @bot.event but I get an error for ```swift
NameError: name 'bot' is not defined

#

I tried client as well

fallow tartan
#

HOW CONNECT uh

tender otter
#

That error isn't from that part of the script, as I don't see 'bot' anywhere

#

Anyway just define bot and done

restive otter
#

How can i check if someone has voted in python with webhooks

sullen nymph
#

@maiden sierra the decorator for events in cogs is commands.Cog.listener()

#

Make sure you actually set webhook kwargs in DBLClient (refer to dblpy.rtfd.io)

restive otter
#

why

#

oh

#

do i need to loop over

#

nvm

restive otter
#

Why doesnt this work?

#
    @commands.command()
    @commands.cooldown(1, 43200, commands.BucketType.user)
    async def claim_vote(self, ctx):
        x = self.dblpy.get_user_vote(ctx.author.id)
        if x == False:
            ctx.reset_cooldown
            e = discord.Embed(
                colour = discord.Colour.green(),
                title = "You haven't voted today!"
            )
            await ctx.send(embed=e)
        if x:
sullen nymph
#

Define doesn't work

restive otter
#

wdym

sullen nymph
#

Any errors you're getting?

restive otter
#

no

#

It returns

#

true

#

If not voted

sullen nymph
#

ThinkingBTTV well it checks if the user upvoted your bot in the last 12 hours

restive otter
#

Ye but my alt hasnt

sullen nymph
#

And the API doesn't seem reliable for that so I would recommend using webhooks

restive otter
#

How webhooks work?

sullen nymph
#

set up a webhook, make top.gg send requests to a URL once someone votes, store votes in database, see if last upvote was within past 12 hours

restive otter
#

Wdym by to a url

sullen nymph
#

A webhook is an application that listens to certain requests sent to the machine. In order to send the request, the sender must know where to send one. A URL containing your machine's IP and port address will be needed for top.gg to know that it needs to send the vote data.

restive otter
#

SEEMS hard

#

I have it on gcp

#

so

sullen nymph
#

Not really, if it can listen to requests, it will work

restive otter
#

Just idk how

sullen nymph
restive otter
#

async def on_dbl_vote(self, data)

#

is with webhook

sullen nymph
#

That's the event used to handle actual votes, yes

restive otter
#

its actually not that hard

#

Where can i find this data webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)

sullen nymph
#

You set it in DBLClient

restive otter
#

and

#

Then??

sullen nymph
#

Open port 5000, go to your bot's Edit page, see the webhook URL field. There, you enter a link like http://ip:port/dblwebhook where ip is your public IP and port is 5000

restive otter
#

open port?

#

Google cloud should have it

sullen nymph
#

There's probably a setting somewhere that allows- yeah

restive otter
#

Okay

#

Its not that hard

#

So the test sends a test vote or smth

sullen nymph
#

Mhm

restive otter
#

And no port in the link right

sullen nymph
#

You do set the port in the URL

restive otter
#

?

green mantle
#

Your port is in the wrong place

median badger
#

Lol

green mantle
#

Also nice ip you got there

restive otter
#

?

median badger
#

It would ip:port/dblwebhook

restive otter
#

ohk

median badger
#

Also would suggest deleting the message with the ip

restive otter
#

Its not my ip

#

i changed it a bit

#

How can i find the what data it sends ? dbl.on_dbl_vote(data)

#

Ok found it

#

Can i use any other port than 5000?

sullen nymph
#

Yeah as long as it's not used

restive otter
#

I still keep getting error

#
^C^CTraceback (most recent call last):
  File "main.py", line 710, in <module>
    client.run(token)
  File "/home/markustraus/.local/lib/python3.7/site-packages/discord/client.py", line 637, in run
    _cleanup_loop(loop)
  File "/home/markustraus/.local/lib/python3.7/site-packages/discord/client.py", line 92, in _cleanup_loop
    _cancel_tasks(loop)
  File "/home/markustraus/.local/lib/python3.7/site-packages/discord/client.py", line 77, in _cancel_tasks
    loop.run_until_complete(asyncio.gather(*tasks, return_exceptions=True))
  File "/usr/lib/python3.7/asyncio/base_events.py", line 582, in run_until_complete
    raise RuntimeError('Event loop stopped before Future completed.')
RuntimeError: Event loop stopped before Future completed.
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f49f9481518>
```'
green mantle
#

you didnt control + C so yes

#

that pretty normal when not shutting stuff down properly

restive otter
#

With tests it still doesnt work tho

short viper
#

can i get high five api

restive otter
#

Still cant get it to work

restive otter
#

hi

willow spindle
fair herald
#

So when I try to use dbl.webhook.on('posted', () => {}) it never updates

#

So it shows that my bot is always offline

true talon
#

your bot is offline coz its kicked out of here

#

the offline status is different from dbapi

fair herald
#

Oh

true talon
fair herald
#

I kicked it myself but ok

true talon
#

lol

fair herald
#

How would I add it back then? Lol

true talon
#

ask a mod

sullen nymph
#

the "posted" event is used on dbl, not the webhook

#

What's the bot's ID

fair herald
#

Wrong

#

And the ID is

#

660497347368845353

true talon
#

Wrong
@fair herald no

fair herald
#

Look in the docs

#

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

sullen nymph
fair herald
#

Go down

#

The auto poster Events

sullen nymph
#

The autoposter has nothing to do with webhooks

fair herald
#

Why does it say dbl.webhook then? Just a question

sullen nymph
#

Most likely a mistake

fair herald
#

Ah ok

#

Can you add my bot again?

#

I kicked it myself

sullen nymph
#

done

fair herald
#

โค๏ธ

restive otter
#

how do i change the background colour html <body style ="background-color:lightblue"> this doasnt seem to work

sullen nymph
#

-api

abstract mothBOT
restive otter
#

thanks

sullen nymph
restive otter
#

I still haven't got the webhooks to work

#

can someone help?

sick geode
#

I havent either

#

Got the server count posted

outer fractal
#

-api

spice glacier
#
{
    "recipients": [
        "Only iterables may be used in a ListType"
    ]
}```
willow hawk
#

copied from docs

vapid cape
#

did you configure it in your top.gg edit page?

willow hawk
vapid cape
#

where is your bot hosted?

willow hawk
#

AWS EC2

vapid cape
#

check if they require you to allow ports in some firewall

willow hawk
#

but i was testing just on my PC

vapid cape
#

in the admin panel

#

your pc needs port forwarding in the router

#

for it to work in your pc

willow hawk
#

oh let me read up on that, thanks

austere notch
#

How can I connect a Discord webhook to a top.gg webhook?

restive otter
#

What?

vapid cape
#

you cant

#

top.gg webhooks are not compatible with discord webhooks

#

you'd need a middleman to convert from one to another

little robin
#

A webhook in web development is a method of augmenting or altering the behavior of a web page or web application with custom callbacks. These callbacks may be maintained, modified, and managed by third-party users and developers who may not necessarily be affiliated with the ...

graceful abyss
#

How to send a message to a specific channel when voting for my bot?

spiral steeple
#

@left egret

#

this kid advertising his roblox clothing group in api lmao

#

hmmm. Maybe @craggy sentinel is here

craggy sentinel
#

lmao i already had the ban prompt open as you pinged me

spiral steeple
#

oh lmao just the slow phone typing

left egret
#

I'm slow

spiral steeple
#

it's ok, we still love you

twilit gyro
#

Slm

timber beacon
#

I want my bot to approval now please check it

cold marlin
#

Hum

green mantle
orchid cargo
#

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

#
    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print(data)
sullen nymph
#

You're not setting webhook arguments

orchid cargo
#

oh

#

is it necessary?

sullen nymph
#

Well yeah

#

Without knowing at least the port, the program doesn't know where to host the webhook

#

Unless it'll try to use the first available port in a certain range, which is... bad

orchid cargo
#

ohkk

#

thanks I'll try

orchid cargo
#
@commands.Cog.listener()
async def on_dbl_vote(self, data):
    print(data)
#

it is never calling this function

#

self.dblpy = dbl.DBLClient(self.client, self.token, webhook_path='/mypath', webhook_auth='mypass', webhook_port=5000)

#

anyone

sullen nymph
#

What have you entered on your bot's Edit page?

orchid cargo
#

what?

sullen nymph
#

You need to enter a URL on your bot's top.gg Edit page

#

Hence the port and path, http://ip:5000/mypath where ip is your public IP

#

scroll all the way down once you press Edit to see webhook options

orchid cargo
#

ohhh

#

my bad

#

ok I've entered

#

now it may call that method automatically when user vote

lost merlin
#

How u use the get_user_vote ?

plain dirge
#

how to make discord bot

trail sigil
#

-faq 3 -c

abstract mothBOT
timber beacon
#

!!!

#

!!! support

obsidian tide
#

does top.gg keep turning off? i keep getting 500 errors sometimes in my code

sullen nymph
#

it's currently down

obsidian tide
#

oof, i didnt check

#

what's keep on making top.gg down ๐Ÿค”

sullen nymph
#

/shrug

#

Admins are aware

restive otter
#

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

graceful abyss
#

How do I make a test vote?

sullen nymph
#

Test button on your bot's Edit page

graceful abyss
#

Thank you

restive otter
#

I'm getting 500 server errors too

#

oof

#

time to stop making my game and actually handle that error

vapid cape
#

the top.gg api is a rest api that allows you to interact with top.gg and exchange data such as server count, votes and more

narrow geyser
#

Is there a example code for dblapi.js with the kurasuta sharding manager?

spiral steeple
#

Doubt it, you could probably just set up an interval and manually post with postStats

narrow geyser
#

yeah, just have no idea where to put it

vapid cape
#

should be the same

#

you basically have 3 options:

  1. put it in the manager and postStats with broadcastEval/fetchClientValues
  2. put it in the shard, and make it run only in shard 0, then use postStats with broadastEval/fetchClientValues
  3. put it in all shards and use the autoposter (if you dont need webhooks or you run a separate webhook elsewhere)
narrow geyser
#

@vapid cape the webhook thing is the problem, although I think i solved it. Thanks :)

tardy elm
#

how do I check if the message author has voted for the bot? I can't figure it out

graceful abyss
#

Why does the Ready event work and the vote is not?

willow spindle
#

@tardy elm which lib

graceful abyss
#

Why does the Ready event work and the vote is not?

bold gulch
#

so i have to have my own webhook url?

#

to use webhook events

tardy elm
#

@tardy elm which lib
@willow spindle discord.js guess I should have said that

willow spindle
#

check hasVoted()

tardy elm
#

I looked and I canโ€™t figure it out

willow spindle
tardy elm
#

Yeah I donโ€™t know what to put after dbl.hasVoted

bold gulch
#

i need to have a web server to run a webhook?

vapid cape
#

@graceful abyss the vote event has other requirments

#

you need to input correct information in your top.gg edit page under the webhooks

bold gulch
#

what is "correct information"

vapid cape
#

a correct URL and Authrization

#

the URL depending where your bot is hosted
and Authorization being what you write in your webhookAuth password

bold gulch
#

ok but what URL do i use?

vapid cape
#

the URL that points towards a webserver you run

bold gulch
#

ok

#

so i need to setup a webserver

#

got it

vapid cape
#

or a service that you want to receive webhooks in

#

if you're using javascript and node.js, the dblapi.js module sets up a webserver for you

bold gulch
#

oh

#

how do i use that lol

graceful abyss
vapid cape
#

glitch does not accept port 5000

#

it needs to be 3000

bold gulch
#

glitch cant be used to host Discord bots anymore anyway

vapid cape
#

it can

bold gulch
#

no they released a thing saying that you cant have a pinging service ping your project

vapid cape
#

there are other ways to ping it and keep it alive, besides they said that restriction was only temporary

bold gulch
jaunty plank
#

Honestly, I wouldn't be surprised if all the free online hosting methods for bots go away in the next year.

vapid cape
#

ah so they changed it to permanent

#

nice

tardy elm
#

Glitch is gonna lose a ton of users

vapid cape
#

good riddance honestly

willow spindle
#

Yeah I donโ€™t know what to put after dbl.hasVoted
@tardy elm user ID

vapid cape
#

its a ton of users who basically waste tons of resources and pay no money

tardy elm
willow spindle
#

idk

#

if command.author.id is user ID, yes

bold gulch
vapid cape
#

where is your bot hosted?

bold gulch
#

im currently just testing on my pc

#

but i host on vultr

vapid cape
#

local networks usually require port forwarding in your router

bold gulch
#

so if i placed the bot on my host it will work?

vapid cape
#

possibly yes

#

as long as you change the url accordingly

bold gulch
#

what URL do i use if the webserver comes from dblapi.js?

restive otter
#

anyone know how to get the Api to send who Upvoted into the server? it's not working,

bold gulch
#

im trying to figure that out too

restive otter
#

yehhh lol i got server count working but-

vapid cape
#

@bold gulch your vps ip address and the port you define

#

@restive otter did you set your URL and Authorization in your top.gg edit page?

bold gulch
#

is there a path i set or no

vapid cape
#

the default path is /dblwebhook

bold gulch
#

it worked

#

yay

#

tysm

restive otter
#

@vapid cape yep it's as my ip and port 5000,

vapid cape
#

where is your bot hosted?

#

@restive otter

restive otter
#

R0taCry self

vapid cape
#

self hosting usually requires opening ports in your local modem/router/firewall

#

aka port forwarding

restive otter
#

PeepoHide i need to get @burnt aspen hosted -- she's breaking my laptop lmao

vapid cape
#

use intents

restive otter
#

hm?

vapid cape
#

discord intents

#

fixes most resource usage issues

#

unless your bot needs stupid stuff like presence updates

restive otter
#

nope, my bot's Presence is fixed,

vapid cape
#

apparently yes

stiff osprey
#

@restive otter intents are for inbound payloads

placid peak
#

nope, my bot's Presence is fixed,
he meant users presence updates

onyx cipher
#

hey i need help with DBLPY