#topgg-api

1 messages ยท Page 25 of 1

inner venture
#

i dont think you understand webhooks

snow fiber
#

A web hook is like a text message

#

You don't just check every time it there is a new message

#

Your phone will just tell you that there is a new one the moment it arrives

#

So dbl is the equivalent of that text message, all you need is a cell phone and a number to receive it on

vagrant kayak
#

Good analogy +1

clever flame
#

lol

steady sundial
#

@sudden rampart 60/minute man.

#

And yes I do one for my guildsize but not more

#

@arctic arch why not? I do a request every 3 seconds for my checkforvotes function

#

It checks if a user that uses the bot has voted up

elfin solstice
#

...........

#

its not like they added webhook support for a reason

steady sundial
#

I know I could use a webhook but i am to dump for it

elfin solstice
#

well spamming api will only get you api banned

steady sundial
#

Thats no spamming lol

elfin solstice
#

every 3 seconds is spam

steady sundial
#

No over 60 in a minute is spam

#

Can you just read the docs, thx.

elfin solstice
#

why am i even discussing lmao have fun getting banned by Tonkku

#

idc about you tbh

steady sundial
#

Why should I get banned lol

arctic arch
#

even if it's not blocked it's still technically spam

elfin solstice
#

cya ๐Ÿ‘‹

tidal burrow
#

I thought it's 60/min ๐Ÿ‘€

steady sundial
#

When you dont care about me why are you even answering

arctic arch
#

let's not start a fight here okay

#

calm down dude

tidal burrow
#

I have a while loop with 60 seconds cooldown, is that ok?

steady sundial
#

@arctic arch why you dont update your api to a function that allows you to give you an array of all ids that have votet up the bot

elfin solstice
#

.................................................................

steady sundial
#

Sorry but i have not the time to set up a webhook nodejs server

#

No the mod says no @tidal burrow

arctic arch
#

isn't that what the api is

elfin solstice
tidal burrow
#

I was first recommended to do a while loop, and now they aren't allowed? ๐Ÿ‘€

steady sundial
#

What function does that?

elfin solstice
#

@tidal burrow i would recommend using an webhook there it doesn't loop request at all and is more precisios

steady sundial
#

No its technical spam ^^

elfin solstice
#

says to me read the docs
doesn't know how to read them

#

yea

tidal burrow
#

I mean it's just a background task, that sends the server count every minute, I think I'll stick to it

steady sundial
#

You made a good webhook but it would ve much simplier if you would host it

arctic arch
#

request every 60 seconds is better than every 3 seconds

elfin solstice
#

Hosting a webhook WaitWhat

arctic arch
#

...

elfin solstice
#

i remember why i stopped helping now

arctic arch
#

hosting a webhook lol wut

tidal burrow
#

xD

steady sundial
#

I mean you could host the webhook on one of ur servers

tidal burrow
#

do you know what webhooks are?

steady sundial
#

That this server sends a callback to the webhook of the bot

arctic arch
#

so you don't understand webhooks

steady sundial
#

Okay so I read again about it, thx

#

Is there a js function that allows you to get a list of all ids that upvoted the bot?

robust olive
arctic arch
#

how are you doing it now if not a js function?

elfin solstice
steady sundial
#

I am doing a loop for every user.id and check if this guy has voted up

robust olive
#

ohmy facepalm

steady sundial
#

Oh but I see there is a function for that

#

I didnt see that one

elfin solstice
steady sundial
#

Okay so my loop is really really dump cd

tidal burrow
#

for every user.id? lol you'd be checking millions of users xD

elfin solstice
#

and for the future know your facts before saying someone should read the docs kthxbye

steady sundial
#

No for every user id that the bot has fetched......

robust olive
#

Do you use the library?

#

dblapi.js

sudden rampart
#

@steady sundial and if you have more than 60 you're ratelimited

#

on the first execution

sullen nymph
tidal burrow
#

I've set a while loop to send to API the number of servers every 5 minutes, and every time it does it, it prints/spams this into the console, here's the code if necessary:

import aiohttp

@bot.event
async def on_ready():
    dbltoken = 'CENSORED'
    url = 'https://discordbots.org/api/bots/' + str(bot.user.id) + '/stats'
    headers = {'Authorization' : dbltoken}

    while True:
        payload = {'server_count': len(bot.guilds)}
        async with aiohttp.ClientSession() as aioclient:
            await aioclient.post(url, data = payload, headers = headers)
        await asyncio.sleep(300)

I'll be gone for the next ~30 minutes so please mention me with the reply, thanks

sudden rampart
#

you never close anything

primal lark
#

@tidal burrow You have to close it

#

(The session)

tidal burrow
#

I've never worked with APIs before, how do you close a session?

primal lark
#

google ๐Ÿ˜œ

snow fiber
#

If I remember correctly it's better to do

async with aiohttp.post() as r:
    log status code here or type pass or whatever
sudden rampart
#

also why create a new session every time instead of reusing a single one?

snow fiber
#

@tidal burrow obligatory mention

primal lark
#

@snow fiber I think thats deprecated

snow fiber
#

That's literally how I got it from the docs if I remember

#

Yeah

#

That's what she the docs said

primal lark
#

nm lol

snow fiber
#

Nah I think they say that making the request directly is deprecated

#

Not making a session and using that for your web requests

primal lark
#

Yeah just realized mmLol

tidal burrow
#

I think I finally made it close it, await aioclient.close() I think it is, at least it stopped spamming my console

#

nope, it's still spamming...

restive otter
#

@olive krakenWinter#7894

#

oof

#

xd

primal lark
#

@tidal burrow Than use the example of Queen of Banne

snow fiber
#
async with aiohttp.ClientSession() as session:
    async with session.post(dastuff) as r:
        print(r.status)
tidal burrow
#

hm

snow fiber
#

And then you could also do like

async with aiohttp.ClientSession() as session:
    async with session.post(dastuff) as dbl:
        print(dbl.status + 'DBL POSTED')
    async with session.post(daotherstuff) as botspw:
        print(botspw.status + 'bots.pw POSTED')
#

Say you are posting to multiple lists or anything or doing some custom stats with your site whatevs

#

Which will reuse the session and use less resources

tidal burrow
#

well it's been 5 minutes without the spam, I think it worked, thanks

#

I need to learn about API, cause I have no idea how to use them lol

restive otter
#

hola

shy vessel
#

wrong channel for greetings

flint harness
#

my bot was declined for api abuse and I'm just wondering what classes as abusing the API?

Bot Description:
My bot is used to cleanup messages that being with the most common command prefixes... Useful for cleaning up chats full of commands.

Workflow:
Command Sent with common symbol as first letter !help, ]help, .help, etc... > > > Message with command deleted automatically after 2 seconds.

vagrant kayak
#

I don't think this has anything to do with the DBL API. Also would recommend talking the moderator who declined you

flint harness
#

that's what I'm wondering... If it's something to do with the DBL API then I'm confused since I don't even have DBL API setup for this bot...

inner venture
#

I believe the mod is referring to abuse of the Discord API

#

But please, lets take this discussion elsewhere

restive otter
#

Is there a way to like make the bot do something on_upvote (py)

short forge
#

webhooks can do that, i guess

steady hedge
#

If I'm not using any sharding, what should I be using for the 2nd and 3rd arguments?

#

or are the latter two optional?

inner venture
#

not sure about that, but if there isnt a way to post w/o sharding, you could always just use 0 for the shardId and 1 for the shardCount

steady hedge
#

The example on npm suggests that only the guild count is required

inner venture
#

shrug

#

have you tried that

steady hedge
#

I'm doing it right now, trying to make sure everything's correct since I have to put it on the live bot (test bot isn't on the DBL :P)

#

Looks like it worked with just the first param ๐Ÿ˜ƒ

inner venture
#

๐Ÿ˜ƒ

arctic arch
#

@steady hedge only the server count is required yeah

#

nice avatar btw lol

exotic gyro
#
if(dbl.hasVoted(message.author.id)) return message.channel.send(`**ERROR**: You must vote at https://discordbots.org/bot/409538753997307915 to use this command.`);```
#

will that work @arctic arch

arctic arch
#

nope

exotic gyro
#

hmm

#
dbl.hasVoted(message.author.id) return message.channel.send(`**ERROR**: You must vote at https://discordbots.org/bot/409538753997307915 to use this command.`);```
#

will that? @arctic arch

inner venture
#

what

exotic gyro
#

will that code work

#

im catching before one command if the person voted

#

how do u return with this api

arctic arch
#

it's a promise

#

you either await it in an async function or use .then

vast junco
#

is this correct?

restive otter
#
client.on('ready', () => {
    setInterval(() => {
        dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
    }, 1800000);
});

Found that in the API Docs.
Well, client.shards.id is undefined. What should you replace this parameter with?

#

client.shard.id ?

robust olive
#

mhm

restive otter
#

I'm just wondering why you would post a single shard id ๐Ÿค”

robust olive
#

if your bot isn't sharded just sent the guild count

restive otter
#

My bot is sharded.

#

But, what's the point in posting a shard id?

robust olive
#

if you sent the guild count for individual shards dbl adds them together
it's got to know the shard id to know which to update
or you can total the guild count for all shards yourself and just send that

restive otter
#

awesome.

#

Thanks, that's what I'll do.

astral ingot
#

IDk much about API

#

How can i set up clash ip to a self hosed bot

#

I wanna add a donation logger

shut ibex
#

Erm

inner venture
#

Um

cloud timber
#

Anyone Here Can Help Me With Checking Over My Discord.py Code
Need An Experienced Discord.py User To Check It Over tickYes

inner venture
cloud timber
#

Oh

golden wind
#

@vast junco you want the sleep function outside the exception

tough stream
steady hedge
#

Is that valid JSON?

#

I don't see a {"key": "value"} pair

sudden rampart
#

that's not the error

tough stream
#

I havn't even started coding anything, just trying to import it into my code

#

import dbl

#

is where it dies

sudden rampart
#

try python 3.6

tough stream
#

yeah ok im on python 3.5.2

golden wind
#

@tough stream i have no idea whats causing that error

#

i have tried finding it, someone else had it above

#

did you say you were on py3.5?

tough stream
#

yeah...

#

im going to install 3.6 and see if that fixes it

golden wind
#

ye its a 3.5 issue

#

shit

tough stream
#

lol yeet time to install all my tensorflow libraries again yaaaaaaaaaaaay

golden wind
#

rip sorry ๐Ÿ˜ฆ

primal lark
#

๐Ÿ˜•

prisma delta
#

Nos amamos EUA

short forge
#

@vast junco i'm not too sure about that

#

in the try exception block

#

the indentation for your sleep is in the exception part

#

so it'll only sleep when something goes wrong

#

@golden wind maybe consider not using fstrings and instead use .format for this

#

bc yknow fstrings are 3.6

#

or use the future-fstring thing

golden wind
#

ye

prisma delta
#

@Francis#2517 @Francis#2517

violet crane
#

How do I get my bot to print the uids that have voted for it as mentions?

inner venture
#

I'm assuming that you already have the user IDs, but the format for mentions in discord is <@userId>

#

@inner venture

#

You dont really have to include the !

vagrant kayak
#

You don't have to include ! at all. That's just something Discord does for nicknames.. idk why

violet crane
#

so i figured out how to do it

#

but i want it to list all of them

vagrant kayak
#

So for loop it?

violet crane
#

dbl.getVotes(true).then(vote => {dio.sendMessage({to:channelID,message:'<@' + vote[+1] + '>'})})

#

yeah

#

but i dont relly know how to use a 'for' loop

vagrant kayak
#

oh dear that's going to send a new message for EVERY voter

violet crane
#

yeah

vagrant kayak
#

You need to concat them into a string

violet crane
#

thats my problem though

#

i dont know how to do that

unique flax
#

I'm trying to use the DBL API to check if a user has voted for my bot, then give him or her access to a command.

#

This is the code I'm using, and it isn't working.

#
if (dbl.hasVoted(message.author.id) || message.author.id === '250811963334983683')
arctic arch
#

it's a promise

unique flax
#

I'm not familiar with those.

vagrant kayak
#

as in you have to await for a result

#

It doesn't return right away

arctic arch
#
dbl.hasVoted(message.author.id).then(voted => {
  if (voted)
})

or

// In an async function
const voted = await dbl.hasVoted(message.author.id)
unique flax
#

Ohh, ok.

#

I've used those before, I just never knew they were called promises, sorry!

violet crane
#

This should work to post a message for each use who has upvoted my bot as a mention right? ```js
for (i = 0; i < 5; i++) {
dbl.getVotes(true).then(vote => {dio.sendMessage({to:channelID,message:dio.fixMessage('<@'+ vote[i] + '>')})})}

arctic arch
#

I believe your loop is placed wrong

#

it's also fixed to 5 people

inner venture
#

๐Ÿ˜‚

violet crane
#

theres only five people

#

and where should i place the loop?

#

oh wait a minute

#

yeah where should I put it then?

tidal burrow
#

would it be too spammy if my bot will be checking if a user has upvoted it after each, limited by votes, command?

inner venture
#

@tidal burrow yes

tidal burrow
#

what do you recommend as a workaround?

#

๐Ÿค”

inner venture
#

Either keep a global list of the users who have voted

#

And update it like

#

Every 30 seconds or something (?)

#

Or use the webhook

#

Which sends you a post req everytime someone votes / unvotes

tidal burrow
#

it's limited to 60 requests per minute, right?

inner venture
#

the entire api, yeah

tidal burrow
#

sounds like a good idea, thanks

violet crane
#

hmmm

#

so im trying to retrieve info on a bot using the id and i keep getting an error json unexpected token u in position 0

violet crane
#

huh

short forge
#

pls

unique flax
#

How long does it take for a vote to register?

#

Because a friend of mine voted for my bot and I had to manually add him.

inner venture
#

how are you getting the vote data?

#

through a webhook?

#

or are you periodically callaing the votes endpoint

#

@unique flax

unique flax
#
dbl.hasVoted(message.author.id).then(voted => {
    if (voted) {}
});
#

This was written up by Tonkku.

inner venture
#

um

#

it should be instant

#

im not enitrely sure tho

unique flax
#

That's what I thought, but it isn't working.

tidal burrow
#

how will I be going around getting a list of all upvoters with discord.py with only one request? I was thinking of calling the GET on users instead of users/{user.id}, but idk if it's the correct way, or will it even work

sudden rampart
#

GET /bots/:bot-id/votes

tidal burrow
#

oh, I guess I was on a bit of wrong track lol

#

so that will basically return a list of all upvoters?

inner venture
#

upvoters..? @sudden rampart

sudden rampart
#

oops

#

votes

inner venture
#

:p

sudden rampart
inner venture
#

Isnt there a py dbl lib?

sudden rampart
#

i wrote the code to handle that months ago lul

tidal burrow
#

so to clarify, onlyids will return the discord user ids, right?

sudden rampart
#

yes

tidal burrow
#

hm

#

ok, I'll return here again if I'll have any more questions

steady hedge
#

@violet crane I don't know if you're still having the unexpected token u in position 0 error, but whenever I get that same error, it's because something is trying to use JSON.parse on undefined

arctic arch
#

yup

#

was the undefined something from the api?

restive otter
#

@uncut crystal Why did you delete my bot?

uncut crystal
#

also, #topgg-api is not the appropriate channel for this

restive otter
#

Leaked token?

#

I don't get that..

#

Where?

uncut crystal
#

again, #topgg-api isn't the appropriate channel for this, DM me

tidal burrow
#

I'm pretty bad at APIs, so can someone tell me if I'm doing this right? ๐Ÿ‘€

headers = {'Authorization' : dbltoken}
urlvoters = 'https://discordbots.org/api/bots/' + str(bot.user.id) + '/votes'
voters = []
payload_2 = {'onlyids': True, 'days': 7}
async with aiohttp.ClientSession() as session:
    async with session.get(urlvoters, data = payload_2, headers = headers) as r:
        for x in r:
            voters.append(x)
    await session.close()
inner venture
#

@tidal burrow kinda unrelated, but why arent you using the dbl py lib? ๐Ÿค”

tidal burrow
#

it pretty much works without it, yet I'm still learning how APIs work, so maybe later I'll consider taking a look into it

plush minnow
#

hm

light crag
terse flame
#

any way to retrive information like on reddit using discord.py

sudden rampart
#

wrong channel

tidal burrow
#

cough cough I still kinda need help with my code above haha ๐Ÿ˜„

candid escarp
#

hey guys, my bots growing pretty quick so, will i get in trouble if i update my guild count too much? right now it does it on ready and when it joins/leaves a guild, but its starting to join/leave a lot of guilds and quite fast

tidal burrow
#

you should turn it into a background task

#

make it update on it's own with some interval

candid escarp
#

so like update it every 15 minutes or something instead?

tidal burrow
#

well, the actual limit is 60 API requests per minute, but I personally have it set to 30 seconds

#

just don't go close to the ratelimit and you'll be fine

sudden rampart
#

i run mine each 30m

tidal burrow
#

yeah... and I still need help as well... ๐Ÿ‘€

candid escarp
#

okay

trim bluff
#

Is the JS library still bad?

#

Should I migrate to it from my own snekfetch implementation?

#

I can make 1 request per second?

#

That seems high.

inner venture
#

you can make 60 req per minute

#

theres a diff

open minnow
#

How I Use DBLDAPI?

#

DISCORD BOTS LIST API?

#

PLS

#

??

#

PLS

#

How To I Run With Discordbot-api?

#

@open minnow

lofty root
#

GROOVY????

inner venture
#

GROOVY

calm torrent
#

@open minnow have you read the docs?

golden wind
#

@tidal burrow why are you copying r to voters when r is everyone who voted?

calm torrent
#

might want to create a static session

golden wind
#

^

restive otter
#

What's wrong withif(dbl.hasVoted(String(sender.id)))?

#

I have js const DBL = require("dblapi.js"); const dbl = new DBL(`TOKEN`); to initiate

arctic arch
#

It's a promise, so

dbl.hasVoted(message.author.id).then(voted => {
  if (voted)
})

or

// In an async function
const voted = await dbl.hasVoted(message.author.id)
if (voted)
restive otter
#

Oh ok

#

didn't realise it was a promise

#

cant make a bot....

#

wrong channel

#

......

#

ok

restive otter
#

@restive otter henlo awaveBOYE

sacred horizon
#

no

restive otter
#

does DBLPoster do that?

sacred horizon
#

no this does too

#

hold on

restive otter
#

kk

sacred horizon
#

so run this in a guild joined or leave event

#
global.dbl = new DBL(auth.dbltoken, bot);
dbl.postStats(bot.guilds.size).catch(err => {console.log(`Error ${err.code}: Error uploading guild count to DBL`)});
restive otter
#

thank you!

sacred horizon
#

np

arctic arch
#

autoposter posts every 30 minutes

tidal burrow
#

@golden wind that was basically my idea, I intentionally want to get a list of all user ids who voted on the bot, I just need to know if I'm doing it right

golden wind
#

@tidal burrow ye but the api returns that list as r, so why copy it when it already exists?

#

and you should probably use the client session that you should have already created when starting the bot

#

as 4jr said

tidal burrow
#

well I did mention that I'm new to API stuff, idk what or how would be a better way of doing it ๐Ÿค”

restive otter
#

can i do can i do if(!dbl.voted(id))?

calm torrent
#

@golden wind you should create a start_vote_post() function in the wrapper

#

that just does what's in the example

zealous dagger
#

anyone knows how to set config vars in heroku with python and github

#

bot.run(BOT_TOKEN) doesnt seem to work

restive otter
#

&he

#

&help

#

&shoot @odd garden

zealous dagger
#

pls help

inner venture
#

wrong channel

open minnow
#

how i use Dbl api?! And How I Run?! I Run Node bot.js Is Not Work

#

@zealous dagger bot.run(process.env.BOT_TOKEN)

zealous dagger
#

doesnt work too xD

tidal burrow
#

still wrong channel

calm torrent
#

os.environ.get('BOT_TOKEN')

#

ofc u need to import os

#

and wrong channel

barren laurel
#

my discord server isn't on the "select a server" whenever i add a bot D:

#

how to fix?

tardy crater
#

wrong channel to ask in hmmm

barren laurel
#

oh rip

#

i saw it said "help" in the

#

top

#

;|

#

its says this channel is only for suggestions/HELP/bugs....

#

i guess i post in general?

tardy crater
#

this channel is only for the api libraries

barren laurel
#

oh

#

whoops

tardy crater
#

its okay!

candid escarp
#

hey guys, dunno really how webhooks or the api works, but is there a way to post to a channel in my bots server when someone votes, with their username and id?

vagrant kayak
#

You need to have a webserver catch the webhook first to do that

candid escarp
#

oh

karmic talon
#

you could always point the web hook to a web hook on discord

inner venture
#

no

#

that doesnt work

short forge
#

^

#

dbl's webhooks are a different format than discord's

karmic talon
#

oh rip

#

they should really change that or at least make it an option

inner venture
#

um

uncut crystal
#

yeah no

restive otter
#

I use dbl.hasVoted(message.author.id)

#

but how do i check when the upvote was?

#

so have they upvoted in the last 24 hourse?

#

*hours

arctic arch
#

you'd have to use getVotes(onlyids, days)

#

but now that I think of it, I should include the days part

restive otter
#

oh ok...

arctic arch
#

in hasvoted

restive otter
#

yeah...

#

so would it be:

#
dbl.getVotes(true, 1).then(result => {
    if (result.includes(message.author.id)) {/*DO STUFF*/}
})```
#

?

#

@arctic arch ?

arctic arch
#

yea but I gotta push an update

#

I'll ping you

restive otter
#

ok

arctic arch
#

@restive otter released 1.2.0

restive otter
#

ok

open minnow
#

how xD I Run DBLapi?

#

Discord.js

#

??

#

t!uptime

#

OPS

hazy coral
#

ok im having an issue with the dbl api where it wont let me make an api key

inner venture
#

what

hazy coral
#

my bot is on the list and everything but each time i click generate token it doesnt

inner venture
#

are you clicking

#

regenerate token

hazy coral
#

i never made the token

#

it wont let me

inner venture
#

csan you screenshot what it looks like for you ๐Ÿค”

hazy coral
#

it doesnt let me click generate token

inner venture
#

huh!

#

perhaps try a different browser

hazy coral
#

ok

#

thanks

restive otter
#

if(dbl.hasVoted(message.author.id) === false)

#

can someone tell me why

#

this isn't working bc i thought it would

#

nvm we good

sacred horizon
#

ur welcome

#

:3

brave pond
#

On the latest version of the dblpy lib get_upvote_info() returns NotFound: Not Found (status code: 404): {"error":"Not Found"} I looked through the previous messages here and saw others also having this problem but no solution

golden wind
#

@brave pond what version is your dblpy lib?

brave pond
#

0.1.5

golden wind
#

hmm

brave pond
#

I'm using
self.dblpy = dbl.Client(self.bot, self.token)
and
await self.dblpy.get_upvote_info()

golden wind
#

can you send me the full traceback?

brave pond
#

1 sec

#
Traceback (most recent call last):
  File "C:\Users\Giraffe\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 62, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "C:\BotsLock&Key\cogs\ServerCount.py", line 90, in votedhere
    voted = await self.dblpy.get_upvote_info()
  File "C:\Users\Giraffe\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dbl\client.py", line 150, in get_upvote_info
    return await self.http.get_upvote_info(bot_id, onlyids, days)
  File "C:\Users\Giraffe\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dbl\http.py", line 255, in get_upvote_info
    return await self.request('GET', f'{self.BASE}/bots/{bot_id}/votes' + urlencode(params))
  File "C:\Users\Giraffe\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dbl\http.py", line 207, in request
    raise NotFound(resp, data)
dbl.errors.NotFound: Not Found (status code: 404): {"error":"Not Found"}
golden wind
#

and your code being used?

brave pond
#

This was a test to see if it worked

@commands.command()
async def voted(self, ctx):
    voted = await self.dblpy.get_upvote_info()
    print(voted)
#

I set self.dblpy = dbl.Client(self.bot, self.token) in the init function

golden wind
#

try passing the bot id in the function

#

ie

#

get_upvote_info(12537282)

brave pond
#

1 second

#
Traceback (most recent call last):
  File "C:\Users\Giraffe\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 62, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "C:\Users\Giraffe\Desktop\GiraffeBot2\Lock&KeyTest\cogs\ServerCount.py", line 90, in voted
    voted = await self.dblpy.get_upvote_info(self.bot.user.id)
TypeError: get_upvote_info() takes 1 positional argument but 2 were given

golden wind
#

what python version are you using?

brave pond
#

3.6.4

golden wind
#

hm

brave pond
#

wait 3.6.2 apparently

opal zealot
#

I am on the latest version of the dblpy lib and I am using Python 3.6.4.post_server_count() returns a Forbidden: Forbidden (status code: 403): {"error":"Forbidden"} error.

edgy nexus
#

@opal zealot I wouldn't use the lib and just use aiohttp

arctic arch
#

check your token

edgy nexus
#

You could be ratelimited

sudden rampart
#

ratelimited is 429

edgy nexus
#

o

opal zealot
#

token is correct, still getting forbidden error

arctic arch
opal zealot
#

so its not my discord bot token

tidal burrow
#

iirc there's a different token you can take from a different place of dbl

#

oh no wait, that's the one I'm talking about lol

opal zealot
#

xd

#

so i dunno whats wrong

cobalt ruin
#

Are you sure it's a string and not a number or something

opal zealot
#

it cant be in '' can it -.-

tidal burrow
#

lol ofc it must be a string

edgy nexus
#

put it inside quotes

snow fiber
#

Python can use either ' or " doesn't matter

#

Aslong as it is enclosed with same chars

#

It's recommend to stick to one style tho

sudden rampart
#

" > '

opal zealot
#

Still have a forbidden error

tidal burrow
#

another question, are you sure you copied the whole token? for example, my monitor is small enough to hide the last bit of the token, so you know...

#

I had to zoom out to get the rest of it ๐Ÿ‘€

opal zealot
#

I got the whole token

tidal burrow
#

I like the way you hide your token xd

opal zealot
#

yes xd

#

I'm not exactly sure what the issue is tho

#

@arctic arch you probably dont want to be pinged but do you have an idea of the issue?

arctic arch
#

I can't really tell

#

try asking the lib dev

#

or someone with more python knowledge

opal zealot
arctic arch
opal zealot
#

owat

arctic arch
#

the api lib

opal zealot
#

xd

arctic arch
#

@golden wind

open minnow
#

Hey

#

How I Run DBLAPI?! node bot.js is Not Work!

opal zealot
#

@golden wind i need help ;-;

open minnow
opal zealot
#

deleted channel

#

k

open minnow
#

LoL

#

414039704514592770

#

@verbal meadow

#

<414039704514592770>

#

NOTHING

shy vessel
#

can you not post whatever this is here >_<

open minnow
#

How I Use DBLapi When I Run node bot.js or node . Is Not Woring

inner venture
#

cancer please

open minnow
#

?

#

How I Use DBLapi When I Run node bot.js or node . Is Not Woring

#

PLS

cinder heron
#

๐Ÿ‘€

#

add the code to your bot

#

it has nothing to do with the run script

open minnow
#

?

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

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

I Add This

cinder heron
#

yeah and whats the error it produces?

open minnow
#

Nothing

cinder heron
#

also did you install dblapi.js

open minnow
#

yep

cinder heron
#

wait so you type node whatever

#

and it does nothing?

open minnow
#

yep

cinder heron
#

show? it should do something ๐Ÿ‘€

open minnow
#

wait

cinder heron
#

my bot says started successfully

open minnow
#

Token Discordbot?

cinder heron
#

?

open minnow
cinder heron
#

hm hold on

const DBL = require("dblapi.js");
const dbl = new DBL(` YOUR TOKEN FOR DISCORDBOTS.ORG HERE `);

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

see ^

#

you set it up like that and add the interval into ready

open minnow
#

Where I GOt Token?

sudden rampart
#

on your bot's edit page

open minnow
#

K

#

api options?

cinder heron
#

just put your token in and thats it

open minnow
#
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('o');

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

CANT xD

#

HELP

cinder heron
#

you might wanna blank out ur token

open minnow
#

?

cinder heron
#

well that or reset it

#

you just literally gave everyone your bots site token

open minnow
#

How?

cinder heron
#

go to edit

#

and hit reset i think

open minnow
#

DONE

#

K

#

K

#

(node:6964) UnhandledPromiseRejectionWarning: Error: postStats requires 1 argument at DBLAPI.postStats (C:\Users\user\Documents\ZTzHex\node_modules\dblapi.js\index.js:49:45) at Timeout.setInterval [as _onTimeout] (C:\Users\user\Documents\ZTzHex\bot.js:7:13) at ontimeout (timers.js:458:11) at tryOnTimeout (timers.js:296:5) at Timer.listOnTimeout (timers.js:259:5) (node:6964) 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)

#

WHY?

#

help

#
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL(`? `,  client);

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

HOW?

#

When I Run Node . Nothing Happend

inner venture
#

oh my god

proud sequoia
#

hi

open minnow
#

HOW?

#

PLS

short forge
#

@open minnow question: are you even starting your bot

#

are you even connecting it

open minnow
#

Ye

edgy nexus
#

@open minnow DM me your entire bot's code

#

every single bit

#

don't take out anything

golden wind
#

@opal zealot server count is giving you a 403? ๐Ÿ‘€

sacred saddle
#

your token too

opal zealot
#

@golden wind yes ;-;

verbal path
#

Dont really know if this should go here, it seems like Github cached my widget. It's not updating on my readme and is now stuck at offline.
Anyone else that has had this issue?

sudden rampart
#

browser cache

verbal path
#

Oh really? K i'll try that out

#

No, not a fix

#

K sorry, fixed it by removing the cookie from discordbots, not by clearing cache. Thanks

arctic arch
#

github likes caching images

verbal path
#

@arctic arch Ye, but with the right headers you can force it not to cache badges. It was actually when I found a cookie in the headers from discordbots that I found out how to fix it

arctic arch
#

I thought we did do that header stuff

#

which cookie

verbal path
#

set-cookie: __cfduid=d4619aac4b1ac607f6f8177baa49dd1471520890074; expires=Tue, 1

#

It's not a big issue though, it has an expiredate

arctic arch
#

that's irrelevant to caching

verbal path
#

That's what I thought, but when I removed that cookie that's when I was able to see it being online again.

#

But now I think about it

arctic arch
#

probably a coincidence

verbal path
#

That shouldnt have worked so ye maybe a coincidence

cold finch
#

Do we have a way of inputting HTML code?

sudden rampart
#

wat

cold finch
#

If so, what function I've stared at the API for awile

#

awhile*

sudden rampart
#

also html isn't code

#

it's markup

cold finch
#

.... Anyways.... is there any way of inputting HTML tags.....

sudden rampart
#

where?

cold finch
#

I really need to use <br />

#

for bots

sudden rampart
#

in messages?

cold finch
#

yes

sudden rampart
#

\n

#

also wrong channel

cold finch
#

Thanks

opal zealot
#

@golden wind Do you know why im getting a 403? Thonk

inner venture
#

@opal zealot wrong token?

opal zealot
#

no

#

im getting a 403: Forbidden error

#

the token is correct

inner venture
#

what are you trying to do

opal zealot
#

Im trying to post server count

inner venture
#

how sure are you that you have the rigth token

opal zealot
#

i got it from here

#

and

#

my bots edit list

#

they are both same

#

discordbots edit list

#

list?

#

i mean edit the bot watever

#

u get the point xd

golden wind
#

@opal zealot triple check you haven't accidentally missed letter off the token

#

otherwise send me the full traceback

open minnow
#

Halp

#

dbl.getStats("378926376910192640 <-- What This? Client ID?!)

#

๐Ÿ˜ฆ

arctic arch
#

bot user id

#

(same as client id for some bots)

open minnow
#

k

scarlet cobalt
#

hey guys, im getting 404 error with the url https://discordbots.org/api/bots/{id} Got my header with params key Authorization and value the token from my edit page. Any idea what im doing wrong?>

#

also get this Could not get any response There was an error connecting to https://discordbots.org/api/bots/281874979191259136. Why this might have happened: The server couldn't send a response: Ensure that the backend is working properly Self-signed SSL certificates are being blocked: Fix this by turning off 'SSL certificate verification' in Settings > General Client certificates are required for this server: Fix this by adding client certificates in Settings > Certificates Proxy configured incorrectly Ensure that proxy is configured correctly in Settings > Proxy Request timeout: Change request timeout in Settings > General

inner venture
#

Are you using the right method? @scarlet cobalt

#

trying to use any other method besides GET will return a 404

robust olive
#

because that isn't a valid user id thankang

inner venture
#

on that endpoint, i mean

#

oh yeah, thatll also return a 404

#

Are you trying to do this in a browser? ๐Ÿค”

scarlet cobalt
#

here, @inner venture and @robust olive

inner venture
#

then the bot ID is invalid

scarlet cobalt
#

ohh blurp -,- i though it was discord snowflake, but discordbots has its own id

robust olive
scarlet cobalt
#

thx anyways ๐Ÿ˜„

sudden rampart
#

it is the discord id

inner venture
#

arent user ids snowflakes

uncut crystal
#

yeah, they are

calm torrent
#

So mass pinging or giving a pingable role (those anyone can mention) to those that didn't upvote are officially not allowed?

tardy crater
#

You can ping like say in an announcement channel or something asking people to vote, but don't abuse it ?

calm torrent
#

re: emote servers that spam the shit out of those that don't upvote

tardy crater
#

yea no those arent allowed

#

if anyone does, let us know

calm torrent
#

ok

restive otter
#

Hello, how Can my bot get accepted :D ?

severe mist
#

Submit it, and wait

calm torrent
#

not this channel anyway

tidal finch
#

It just send promise pending

#

With nothing

cunning forum
#

you need to learn how to use promises

#

promise is a special kind of object in javascript

#

which represents a value after some time

#

when the underlying method executes

#

you have 2 ways to get values out of promises

#
  1. Using async funtions/await
#
  1. Using Promise.then
tidal finch
#

ohk

#

thanks

cunning forum
#

so what you want to do

#

is

#

apicall(whatever).then(function(returnValue) {
// Do stuff with return Value
});

tidal finch
#

Ok

opal zealot
#

@cunning forum its time to change ur profile pic to the new scary android turtle

unborn jetty
#

Do vote webhooks fire on each daily vote, or just one time?

#

Also does it set the Content-Type header correctly?

snow fiber
#

Webhooks fire everytime

#

Not sure about the header but the body is JSON

unborn jetty
#

b/c some web frameworks are weird and will interpret a POST as application/x-www-form-urlencoded unless Content-Type is explicitly set to application/json

sudden rampart
#

afaik it has the correct content type

cobalt ruin
#

I can confirm

unborn jetty
#

Thank

dusky gust
#

How do I do the webhook thingy on the website?

vagrant kayak
#

Webhooks are a general term

#

Discord webhooks do not work

#

You must setup your own webserver of some kind to fetch the webhook they send

dusky gust
#

ohhh

#

Well, Is there a way to see who upvotes my bot?

inner venture
#

@dusky gust

dusky gust
#

How do I do that?

#

@inner venture

inner venture
#

do you know how to interact with rest apis

dusky gust
#

Nope

inner venture
#

perhaps you should read up on that ^^

dusky gust
#

Okay

calm torrent
#

what lang? @dusky gust

#

you could use a wrapper

dusky gust
#

discord.js

calm torrent
#

then use the js wrapper

#

discord.js isn't a lang btw

spare axle
#

Lol

restive otter
#

memes

edgy nexus
#

is there an easy way to get all upvotes for the month

#

or do I have to do ?days=numberofdayssincereset

loud harbor
#

whats the NuGet package called for the DBL API

#

nvm found it

ocean sky
#

Hello, i'm curious on how to post my server count to the DBL API, I have tried the example code, however, I get an error message stating: Forbidden: Forbidden (status code: 403): {"error":"Forbidden"} Traceback (most recent call last): File "C:\Users\jackg\Desktop\My Bot\Post.py", line 32, in update_stats await self.dblpy.post_server_count() File "C:\Users\jackg\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dbl\client.py", line 100, in post_server_count await self.http.post_server_count(self.bot_id, self.guild_count(), shard_count, shard_no) File "C:\Users\jackg\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dbl\http.py", line 189, in post_server_count await self.request('POST', '{}/bots/{}/stats'.format(self.BASE, bot_id), json=payload) File "C:\Users\jackg\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dbl\http.py", line 160, in request raise Forbidden(resp, data) dbl.errors.Forbidden: Forbidden (status code: 403): {"error":"Forbidden"} it might be useful for you to know that I am using async as a pose to rewrite

inner venture
#

@ocean sky are you using the right token

ocean sky
#

yes

#

the one provided by DBL API, am I correct?

inner venture
#

yeah

ocean sky
#

ok

inner venture
#

with the correct bot, right?

ocean sky
#

yes

inner venture
#

youre 200% sure?

ocean sky
#

201% sure

brave pond
#

wait one time some of my token was hidden offscreen

ocean sky
#

hmmmm

inner venture
#

thats all i got ๐Ÿคท

ocean sky
#

I just checked the token in my code and the token on the API, and they are both identical....

golden wind
#

can i see the code you're using to call the client?

ocean sky
#
    """Handles interactions with the discordbots.org API"""

    def __init__(self, bot):
        self.bot = bot
        self.token = 'Tis a secret'  #  set this to your DBL token
        self.dblpy = dbl.Client(self.bot, self.token)
        self.bot.loop.create_task(self.update_stats())

    async def update_stats(self):
        """This function runs every 30 minutes to automatically update your server count"""

        while True:
            logger.info('attempting to post server count')
            try:
                await self.dblpy.post_server_count()
                logger.info('posted server count ({})'.format(len(self.bot.guilds)))
            except Exception as e:
                logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
            await asyncio.sleep(1800)


def setup(bot):
    global logger
    logger = logging.getLogger('bot')
    bot.add_cog(DiscordBotsOrgAPI(bot))``` is anything wrong with my code?
#

there it is lol ๐Ÿ˜„

#

That is within a cog BTW

golden wind
#

hmmm

brave pond
#

๐Ÿ‘€ change len(self.bot.guilds) to len(self.bot.servers)

ocean sky
#

oh yea....

golden wind
#

ooohh

ocean sky
#

nope, same error message

golden wind
#

really?

ocean sky
#

yes

brave pond
#

I know in the lib it tries servers then guilds

golden wind
#

what version of dblpy are you using?

ocean sky
#

latest

#

but my code is async

golden wind
#

0.1.6?

ocean sky
#

I believe so

golden wind
#

and py?

ocean sky
#

0.16.12

brave pond
ocean sky
#

oh

#

hold on

#

3.6

golden wind
ocean sky
#

I think so

#

when I typed the install command all I did was pip install dblpy

brave pond
#

Oh hey Francis 0.1.6 fixed getting votes

golden wind
#

ye i know

#

lol

#

i missed a ? in a url

brave pond
#

rip

golden wind
#

working on getting webhooks built in

#

but been quite busy lately

brave pond
#

ooh that'd be awesome, I was looking into web servers today to handle them myself

ocean sky
#

I'm still confused at why it says i'm forbidden to post the server count

golden wind
#

same tbh

#

it should work

ocean sky
#

should

golden wind
#

are you triply sure its the correct token?

brave pond
#

I still think your token is wrong but you just didn't notice

#

Maybe try regenerating it

ocean sky
#

yep, I even regened and replaced it

brave pond
#

no secret spaces or anything?

ocean sky
#

nope

brave pond
#

trailing whitespace?

ocean sky
#

what?

brave pond
#

spaces at the beginning or end

golden wind
#

eg

#

'token '

ocean sky
#

nope...not like that

golden wind
#

hmm

brave pond
#

Got the right bot token right

ocean sky
#

yep

golden wind
#

what bot id is it?

ocean sky
#

otherwise my bot would fail to startup....

#

423889279630966787

brave pond
#

no I meant on dbl, you picked the right bot from the list right

ocean sky
#

yes

brave pond
#

idk how many bots you have so might as well cover all ground

ocean sky
#

I have 2....there both very much distinguishable between each other

golden wind
#

the only reason that a 403 would be sent back is that your token is incorrect

ocean sky
#

hmmm

#

I'll try it again....and possibly agin....

#

I've regened and replaced it once...still doesn't work...

golden wind
#

hmmmf

ocean sky
#

quick check, the token is found under the My bots section correct?

edgy nexus
#

yes

ocean sky
#

ok, I was just making sure I got it from the right place lol

ocean sky
#

Does anyone else know why I get a 403 error when I try to post my server count to the DBL API?? (I must have regened and replaced my DBL 50 times now BTW)

loud harbor
#

what can the Webhooks do?

#

can it like, for example, send a message into a guild when I edit the bot's page

snow fiber
#

No

inner venture
loud harbor
#

just saw that

#

lol

#

thanks

inner venture
#

wrong chat

restive otter
#

Guys for webhooks

#

You must define a password?

inner venture
#

no?

restive otter
#

Ok

vagrant kayak
#

I would though

restive otter
#

How do I start the bot

calm torrent
sleek sinew
severe mist
#

onlyids=true

sleek sinew
#

Do I add that as a header or? Sorry Im not very familiar with http xd

severe mist
#

add it on to the end of your url

sleek sinew
#

Oh I see, thanks!

restive otter
#

I've never actually used a webhook before and i'm trying to figure this out, how do I just make a simple thing where it prints the id of a user that votes? (python)

inner venture
#

@restive otter You have to setup a webserver to receive the post request that DBL sends to your url

restive otter
#

aand how do I make a webserver? I don't have my own website.

light crag
#

Tutorials. Just don't copy and actually change some things.

restive otter
#

hm ok I'll keep looking then

#

oh so you do need to make a website guess i'm not doing this then

inner venture
#

@restive otter no, you dont

restive otter
#

hi

primal lark
#

@golden wind The api is working just fine on windows, but Im still getting this error on Debian 9: ```Python
Traceback (most recent call last):
File "run.py", line 9, in <module>
from stats import dbl_stats
File "../stats/dbl_stats.py", line 1, in <module>
import dbl
File "/usr/local/lib/python3.5/dist-packages/dbl/init.py", line 19, in <module>
from .client import Client
File "/usr/local/lib/python3.5/dist-packages/dbl/client.py", line 31, in <module>
from .http import HTTPClient
File "/usr/local/lib/python3.5/dist-packages/dbl/http.py", line 234
await self.request('POST', f'{self.BASE}/bots/{bot_id}/stats', json=payload)
^
SyntaxError: invalid syntax

#

Python 3.5.3

tranquil rose
#

@primal lark update to python 3.6; that type of string formatting is only supported in 3.6

primal lark
#

Oh ok ๐Ÿ˜•

#

I hate to update Python ๐Ÿ˜„

tranquil rose
#

Lol

ocean sky
#
INFO:discord.client:logging in using static token
ERROR:bot:Failed to post server count
Unauthorized: Unauthorized (status code: 401): {"error":"Unauthorized"}
Traceback (most recent call last):
  File "C:\Users\jackg\Desktop\My Bot\post.py", line 33, in update_stats
    await self.dblpy.post_server_count()
  File "C:\Users\jackg\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dbl\client.py", line 100, in post_server_count
    await self.http.post_server_count(self.bot_id, self.guild_count(), shard_count, shard_no)
  File "C:\Users\jackg\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dbl\http.py", line 189, in post_server_count
    await self.request('POST', '{}/bots/{}/stats'.format(self.BASE, bot_id), json=payload)
  File "C:\Users\jackg\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dbl\http.py", line 158, in request
    raise Unauthorized(resp, data)
dbl.errors.Unauthorized: Unauthorized (status code: 401): {"error":"Unauthorized"}``` Does anyone know why I get this error message when I attempt to post my server count to the DBL API?
restive otter
#

I don't even get an error message xd ```py
class DiscordBotsOrgAPI:
"""Handles interactions with the discordbots.org API"""

def __init__(self, bot):
    self.bot = bot
    self.token = 'asdf'  #  set this to your DBL token
    self.dblpy = dbl.Client(self.bot, self.token)
    self.bot.loop.create_task(self.update_stats())

async def update_stats(self):
    """This function runs every 30 minutes to automatically update your server count"""

    while True:
        logger.info('attempting to post server count')
        try:
            await self.dblpy.post_server_count()
            logger.info('posted server count ({})'.format(len(self.bot.servers)))
        except Exception as e:
            logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
        await asyncio.sleep(1800)

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

#

just nothing happens

ocean sky
#

hmmm

restive otter
#

yeah this api thing is broken i'm just gonna give up on it

ocean sky
#

it's broken???

#

If so then i'm fine as long as they fix it

restive otter
#

nothing is working for me

ocean sky
#

nor me

#

but it works for everyone who tried to post it ages ago

restive otter
#

yeah...

golden wind
#

@primal lark update the library i fixed that

#

@restive otter its not broken, it just wont post anything to your console if you haven't set up logging correctly

primal lark
#

Thanks man ๐Ÿ–ค

light crag
#

@ocean sky it isn't broken. you just don't send authorization

ocean sky
#

don't I?

#

How do I authorize it?

snow fiber
#

it's also not really that hard to do it manually

light crag
#

In the header you have to set authorization with your discordbotsapi token

ocean sky
#

oh ok ๐Ÿ˜ƒ

#

I have @shy vessel

snow fiber
#

recommend that you look for scripts that use aiohttp if you're going for manually because using requests or urllib will make your bot slower

ocean sky
#

oh ok

shy vessel
#

why u ping me GWnanaREEEEEEEEEE

ocean sky
#

ohhhhhh, I pinged the worng user.....i'm really sorry...I meant to ping someone else

#

When I run: dbltoken = "Tis a secret" url = "https://discordbots.org/api/bots/" + bot.user.id + "/stats" headers = {"Authorization" : dbltoken} I get the error message url = "https://discordbots.org/api/bots/" + bot.user.id + "/stats" AttributeError: 'NoneType' object has no attribute 'id'

light crag
#

Is your client named bot?

ocean sky
#

yes

light crag
#

hmm

snow fiber
#

(also make it a string)

light crag
#

Well there is something wrong with your client. I think. User should not be none

ocean sky
#

so should I just replace bot.user.id with a string that is my bots id?

light crag
#

If you want.

ocean sky
#

ok

#
client_response: <ClientResponse(https://discordbots.org/api/bots/423889279630966787/stats) [401 Unauthorized]>
<CIMultiDictProxy('Date': 'Sat, 17 Mar 2018 16:35:12 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '24', 'Connection': 'keep-alive', 'Set-Cookie': '__cfduid=d96b13d2d772f5ea230dc624995631db41521304512; expires=Sun, 17-Mar-19 16:35:12 GMT; path=/; domain=.discordbots.org; HttpOnly; Secure', 'X-Powered-By': 'Express', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Headers': 'Authorization', 'Etag': 'W/"18-XPDV80vbMk4yY1/PADG4jYM4rSI"', 'X-Cacheable': 'NO', 'X-Varnish': '890733437', 'Age': '0', 'Via': '1.1 varnish-v4', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains; preload', 'X-Content-Type-Options': 'nosniff', 'Expect-Ct': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', 'Server': 'cloudflare', 'Cf-Ray': '3fd0df100ea4353c-LHR')>``` WTF???
snow fiber
#

Have you entered your token

ocean sky
#

yes

snow fiber
#

May I see the full script without tokens?

ocean sky
#
url = "https://discordbots.org/api/bots/" + '423889279630966787' + "/stats"
headers = {"Authorization" : dbltoken}``` It goes where `tis a secret` is right?
snow fiber
#

Yes

#

And it has to stay a string ofc

ocean sky
#

well, then it should be right

#

yes

snow fiber
#

But show me the actual aiohttp code you're using

ocean sky
#

dbltoken = "token"
url = "https://discordbots.org/api/bots/" + bot.user.id + "/stats"
headers = {"Authorization" : dbltoken}

async def on_ready():
    payload = {"server_count"  : len(bot.servers)}
    requests.post(url, data=payload, headers=headers)

async def on_server_join(server):
    payload = {"server_count"  : len(bot.servers)}
    requests.post(url, data=payload, headers=headers)

async def on_server_remove(server):
    payload = {"server_count"  : len(bot.servers)}
    requests.post(url, data=payload, headers=headers)``` That's the example that I copied
snow fiber
#

Ah

light crag
#

Wouldn't recommend for every server join and remove

snow fiber
#

Yeah but it's fine for now

ocean sky
#

hmmm

snow fiber
#
import requests
import json

dbltoken = "token"
url = "https://discordbots.org/api/bots/" + bot.user.id + "/stats"
headers = {"Authorization" : dbltoken, "Content-Type" : "application/json"}

async def on_ready():
    payload = {"server_count"  : len(bot.servers)}
    requests.post(url, data=json.dumps(payload), headers=headers)

async def on_server_join(server):
    payload = {"server_count"  : len(bot.servers)}
    requests.post(url, data=json.dumps(payload) headers=headers)

async def on_server_remove(server):
    payload = {"server_count"  : len(bot.servers)}
    requests.post(url, data=json.dumps(payload), headers=headers)
ocean sky
#

should I try that instead?

snow fiber
#

Yeah just try it

ocean sky
#

ok

snow fiber
#

It's similiar to what I use

#

Also while I'm at it I want to recommend looking into discord.py rewrite

light crag
#

LOL

snow fiber
#

pip3 install discord-rewrite

light crag
#

oo

snow fiber
#

But that's getting a bit offtopic

ocean sky
#
    requests.post(url, data=json.dumps(payload) headers=headers)
                                                      ^
SyntaxError: invalid syntax``` doesn't work...
light crag
#

shouldn't there be a comma after data?

ocean sky
#

idk

snow fiber
#

Yea

ocean sky
#

i'll just try another example

#

oh

snow fiber
#

Sorry my bad

ocean sky
#

so, where does the comma go?

light crag
#

after data=json.dumps(payload)

ocean sky
#

ok

#
    import requests
ModuleNotFoundError: No module named 'requests'```
light crag
#

u need to install it

ocean sky
#

oh ok

#

so pip install requests?

light crag
#

i think

ocean sky
#

yea, just tried it lol

#

ok...my bot actually loaded this time...

#

no error has been logged

snow fiber
#

Is your count getting posted

ocean sky
#

I don't think it is

#

nope...

light crag
#

how many servers do you have?

inner venture
#

-bots @ocean sky

abstract mothBOT
#
JackTEK05#0851
Bots

@vivid moth
@keen flume

light crag
#

cause it says 4

ocean sky
#

ik

#

when I checked this morning it magically said 4

#

I recently added the ot to another server tho

light crag
#

oh

#

hmm?

ocean sky
#

ik...

#

And theres no info..error or warning message relevant to it...

snow fiber
#
r = requests.post(url, data=json.dumps(payload), headers=headers)
print(r.status_code)
print(r.text)
ocean sky
#

where do I put that?

snow fiber
#

Replace requests.post with that

ocean sky
#

under on_ready & on_server_join etc?

snow fiber
#

It'll show you the HTTP status code

ocean sky
#

oh ok

snow fiber
#

Just on_ready for now

ocean sky
#

ok

snow fiber
#

You'll only need it to show you if it's being send

#

If it's 200 it's ok

#

If it's 404 or 401 or something there is a mistake

ocean sky
#

It shows nothing what so ever...

light crag
#

hmm

snow fiber
#

hmm

light crag
#

really weird

ocean sky
#

never mind, i placed it in on_server_join

snow fiber
#

lole

light crag
#

lol

ocean sky
#

my bad..lemme fix that

#
{"error":"Unauthorized"}```....am I banned from posting the server count or something?
light crag
#

ahh ok

ocean sky
#

it's a 401 BTW

snow fiber
#

No, are you sure you have copied your token in full?

ocean sky
#

yes

#

a million times

light crag
#

Are you using the DiscordBotsAPI token?

ocean sky
#

YES!

light crag
#

wtf

ocean sky
#

hmmmm? ๐Ÿค”

snow fiber
#

Are you sure you are using the correct bot ID and not the ID of your other bot?

ocean sky
#

i'm sure

#

It has to be a str in async correct??? As a pose to an int in rewrite

snow fiber
#

yes

#

but for the url it always has to be a string

ocean sky
#

Do I need to change "Authorization"????

snow fiber
#

No that is correct

ocean sky
#

ok

light crag
#

if you are using the right token it should work

#

idk what is wrong

ocean sky
#

ik...

#

nor does anyone that i've asked...

snow fiber
ocean sky
#

what about it?

snow fiber
#

That's how it should work

ocean sky
#

ok...

snow fiber
#

but afaik your code has that correctly

ocean sky
#

"Content-Type" : "application/json" what about this?

snow fiber
#

You post your stats as a json object

inner venture
#

How did you post it before

snow fiber
#

This tells DBL that you are actually sending JSON

ocean sky
#

I didn't @inner venture ...idk how I did

inner venture
#

i mean

#

you clearly did

#

๐Ÿค”

ocean sky
#

Well, everything that I tried didn't work

#

unless the other bot owner did it...

inner venture
#

Can you try dm'ing me your token? ๐Ÿค”

#

ill try posting it

ocean sky
#

OK

inner venture
#

maybe something is borked on dbl's side

#

It's not working for me either

#

Im guessing cos that token is incorrect tho

ocean sky
#

hmmm....

#

i'll regen the token, send it to you again (and try myself) if not then dbl is broen

light crag
ocean sky
#

ik where my dbtoken is

sudden rampart
#

user tokens anyone? lul

light crag
#

then maybe dbl really is broken

#

idk

ocean sky
#

hmmm

#

yea, @sudden rampart i'm sending my token in DM as a last desperate attempt....i'll regen my token if it doesn't work anyway

#

OK, it worked

#

I got a 200 message

light crag
#

nice

ocean sky
#

ik

#

YES!

#

My bot actually has a chance to get certified...it just depends on how popular it becomes...

#

Only problem now is that my bot responds to commands twice per command....

inner venture
#

you have two instances of the bot running

#

probably

ocean sky
#

....I do actually...come to think of it

#

yea, I did

#

ty for all of your help everyone ๐Ÿ˜ƒ

#

did someone here invite my bot into their server....cos in my dev server I just got a mod log stating that the bot joined it's 6th server?

little harbor
#

well it's on the list so someone probably added it from there Thonk

#

unless you have the bot role from another bot in which case idk lol

ocean sky
#

you were probably right the first time...I was just curious that was all ๐Ÿ˜ƒ

opal zealot
#

I need some help. I have been trying to figure out the problem and i dont know what is wrong.
I am using Python 3.6.4 and the discord.py rewrite. Here is my code:

import discord
from discord.ext import commands
import aiohttp

class zdblapi:
    def __init__(self, bot):
        self.bot = bot
        
import aiohttp

dbltoken = "no token for you"
url = "https://discordbots.org/api/bots/no id for you/stats"
headers = {"Authorization" : dbltoken}

async def on_ready(self, guild):
    payload = {"server_count"  : len(self.bot.guilds)}
    async with aiohttp.ClientSession() as aioclient:
            await aioclient.post(url, data=payload, headers=headers)

async def on_server_join(self, guild):
    payload = {"server_count"  : len(self.bot.guilds)}
    async with aiohttp.ClientSession() as aioclient:
            await aioclient.post(url, data=payload, headers=headers)

async def on_guild_remove(self, guild):
    payload = {"server_count"  : len(self.bot.guilds)}
    async with aiohttp.ClientSession() as aioclient:
            await aioclient.post(url, data=payload, headers=headers)

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

The server count just doesn't update. So, I made a little server count updater in discord.js
and it worked, it updated the server count. To test if the python one worked, I set the discord.js counter to 3, started and ended the process. My bot is in 13 servers, and the server count didnt update.

snow fiber
#

Add a 'Content-Type': 'application/json' header

#

Try import json
and do data=json.dumps(payload)

opal zealot
#
import discord
from discord.ext import commands
import json
import aiohttp

class zdblapi:
    def __init__(self, bot):
        self.bot = bot
        
import aiohttp

dbltoken = "no token for you"
url = "https://discordbots.org/api/bots/422019359603556362/stats"
headers = {'Content-Type': 'application/json', "Authorization" : dbltoken}

async def on_ready(self, guild):
    payload = {"server_count"  : len(self.bot.guilds)}
    async with aiohttp.ClientSession() as aioclient:
            await aioclient.post(url, data=payload, headers=headers)

async def on_server_join(self, guild):
    payload = {"server_count"  : len(self.bot.guilds)}
    async with aiohttp.ClientSession() as aioclient:
            await aioclient.post(url, data=payload, headers=headers)

async def on_guild_remove(self, guild):
    payload = {"server_count"  : len(self.bot.guilds)}
    async with aiohttp.ClientSession() as aioclient:
            await aioclient.post(url, data=payload, headers=headers)

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

i probably did something wrong, because it still doesnt work