#topgg-api

1 messages Β· Page 133 of 1

restive otter
#

nvm i got it

#

:D

median tulip
#

I wanted to put the top in my bot, gg autoposter, where do I get the top.gg token of my bot?

brittle spoke
#

@median tulip go to your bots page, click edit then go to webhooks

hot island
#

Yo um

#

Im getting the unauthorized error

#

it says that i need a token for that endpoint

#

here's the code im using

#
const webhook = new Topgg.Webhook("password");
const api = new Topgg.Api('Api token')
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
  console.log(req.vote.user);
  let table = store.get(req.vote.user)
  if (store.get(req.vote.user).votecrate) {
    table.votecrate += 1;
    store.set(vote.user, table);
  }
  else {
   table.votecrate = 1;
    store.set(vote.user, table);
  }
});
raven slate
#
const dbl = new DBL(confige.dbd_token, { webhook Port: 5000, webhook Auth: config.AUTH_PASS });
dbl.webhook.on('vote', (vote) => {
console.log(`<@${vote.user}> has voted me ${vote.size}` );


const webhook = new Discord.webhookClient("804368399634399280", "p7bmUUrOB5DZJpjMZg6GnoKyLlLHiENOVcU4ehfeHme83gHFdVMedhehO6c6BtGlCX2P")
webhook.send(`<@${vote.user}> has voted me ${vote.size}`);
});;


client.on('message' (message) => {
if(message.content.startsWith(prefix "myvote")) {
dbl.hasVoted(message.authot.id).then(c => { 
if(c) {
message.channel.send(`Yes , You voted me on top.gg `)
} else { 
message.channel.send(` You haven't voted me on top.gg `)
}
})
}
})```
#

what's the problem

rain heart
#

what's the issue?

#

errors?

#

@sullen nymph

sullen nymph
#

ok

rain heart
rapid kettle
#

@sullen nymph cunt

#

thanks bro

raven slate
#

config.AUTH_PASS

rain heart
#

did you define auth_pass?

#

in your config?

raven slate
#

Yeah

#

I put a random code in it

#

@rain heart

rain heart
#

also, still no clue what error you're getting

raven slate
#

Is there another code? @rain heart

rain heart
#

reading the docs should help you find examples for it

proven timber
#

upppp

hot island
#

Nono

#

I did already

#

I just put placeholders for the password and the token

#

to send you the code

fickle bear
#

How do I obtain my bot api to post my bot stats in the website?

rain heart
#

on your bot page settings under webhooks

fickle bear
#

Ahh I see it now thanks!

restive otter
#

is 300 seconds a good time?

rain heart
#

referring to what? posting stats?

#

I suggest posting stats every 15 minutes or so

#

or potentially 30

restive otter
#

oh oky

#

1800 it is

#

thanks

rain heart
#

also, top.gg instead of discordbots.org even if both work

restive otter
#

oh

#

done πŸ˜„

#

can I use webhooks to make a post to my website

#

or is it discord webhook bound or smth

rain heart
#

The vote webhooks?

restive otter
#

yes

#

I wanna send to my website to process it

rain heart
#

yeah sure, you just can't use discord webhooks

restive otter
#

oh I don't need

rain heart
#

If you want to only track it through your website and not your bot, that's fine

restive otter
#

anyway of fake sending a request to test?

rain heart
#

the test button on the webhook settings

restive otter
#

oh didn't see my bad

rain heart
#

it sends a request with the type value test

restive otter
#

thanks πŸ˜„

#

I have clicked test twice now, been waiting 1-2 minutes but nothing came up

rain heart
#

you need to save the webhook first before being able to use the test button

restive otter
#

oh ye now it was instant

zinc marsh
rain heart
#

Library field is deprecated, it does show up in widgets, but will be removed when widgets are being updated

zinc marsh
#

ok, thanks

restive otter
#

Authorization is a header right?

#

in webhooks

rain heart
#

Yes

restive otter
#

Weird I am getting GET request on that endpoint now Thonk

rain heart
#

It should only be a post request

rapid kettle
#

is it behind a proxy?

#

i was getting that when mine was behind a proxy

restive otter
#

no?

#

only thing I have is cloudflare

rain heart
#

is it behind a cloudflare proxy?

restive otter
#

no

#

I didn't setup anything like that

rain heart
#

also, accessing the webhook url through the browser makes a get request to it

restive otter
#

I didn't do that that's why I am confused

#

coz I just created it xD

#

must be nothing, it's 405 anyways

rain heart
#

As long as they're not authorized/dont have a valid authorization header, it's fine

restive otter
#

ye still had me wondering

#

thanks

rain heart
#

Just make sure to use a secure authorization key and not share the url to you wouldn't get any malicious requests to it

restive otter
#

ye that's what got me, coz this URL endpoint was just created...only place I pasted onto was top.gg

#

I was wondering if top.gg did GET too that's why I asked

rain heart
#

nah it only does post

#

as it sends the vote data aswell

restive otter
#

aight I filtered right way to only accept POST

restive otter
#

what data can I update besides guild count and shard count?

restive otter
#

oh I see

#

was making sure thanks

restive otter
#

whats the webhook url i am confused

rapid kettle
#

where is your webhook hosted

restive otter
#

uh still confused :P

rapid kettle
#

where's your web server that handles your webhook hosted?

restive otter
#

idk much about webhooks

rapid kettle
#

you have a webserver running listening for post requests, yes?

rapid kettle
#

well there is no url then

restive otter
#

so what do i do then

rapid kettle
#

leave it

#

ig?

restive otter
#

can do it without this webhook url thing?

rapid kettle
#

can do what

restive otter
#

post the server count

rapid kettle
#

yes

restive otter
#

alrighty then!

rapid kettle
restive otter
#
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 = '' # 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))
#

thats the cog i am usin

#

so i'll remove the ", webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000" ig

#

@rapid kettle lemme know if i am sayin something wrong lol

rapid kettle
#

idk much python

restive otter
#

ah alr

restive otter
restive otter
restive otter
#

lmfao

#

pip install dblpy

#

install that module

#

alr done and works! thanks!

#

np

astral kernel
#

having some issue saving the webhook, is that normal? (new bot)

rain heart
#

It cannot be a discord webhook

#

You need to host your own

astral kernel
#

its self hosted

#

the problem is saving it in the admin screen

rain heart
#

Screenshot what the url looks like

#

you can also dm it to me if you feel more comfortable with that

astral kernel
rain heart
#

I mean the webhook url you've entered

astral kernel
#

free advertising lol

rain heart
#

on the webhook url

astral kernel
#

oh ahaha

#

is it a get or a push hook, its a push right? should I test it first?

rain heart
#

Can you try reloading your page and re-enter

astral kernel
#

same result

#

the test button does nothing

#

the save button gives that message

#

google chrome

rain heart
#

open inspect-element console and show me what errors pop up when trying to save it

#

yeah test button doesn't work until you saved it

astral kernel
#

it says not approved, is that because its a new bot?

rain heart
#

Is your bot approved yet?

#

Is it @hollow inlet (barracuda) by any chance?

#

Or which bot is yours?

astral kernel
#

I own barracuda

#

but this is a new one

#

just registered it

#

should I just wait for some kind of approval?

rain heart
#

You don't seem to be added as a bot owner to that bot

#

is that bot in a team by any chance?

astral kernel
#

429000479331057675?

#

you mean barracuda?

rain heart
#

yeah

#

Because you dont show up as one of the owners

astral kernel
#

let me add me lol

rain heart
#

Though i see that it isn't in a team, just confused for a second

astral kernel
random harbor
rain heart
#

Like are you 100% sure you have access to your bot? or are you doing it through a different account?

astral kernel
#

mustknow is this user

random harbor
astral kernel
#

ok wait let me log in with lilypad

rain heart
#

so it should

#

make sure to replace dbl_token with your top.gg token found under your bot page settings -> webhooks

shadow sluice
#

hi

rain heart
#

aight

#

though how do you have access to that bot with your other account?

#

with the "your mom" account

shadow sluice
#

mustknow was the name of the other account htee first time I joined top.gg's server, its my old email addresses discord, I keep my access to important things in there cause discord is on 24/7

rain heart
#

aight anyways

#

try saving the webhook with this account

#

Because that one is mentioned as a owner

shadow sluice
#

I am logged in to this account

#

its the discord account thats logged into chrome

#

the app on the desktop is logged into the other account

#

links auto open in the app

random harbor
#

How can i get a token

shadow sluice
#

so the app took over the join into this discord

rain heart
astral kernel
#

so I just wait for verify?

rain heart
#

I mean your bot is approved, no?

shadow sluice
#

lets see

astral kernel
#

nope

#

726135294952341575

#

I mean I dont mind waiting πŸ™‚

rain heart
#

ah yeah i see it's still in queue

#

all good, you'll need to wait as you cant make any webhook changes until it is approved

astral kernel
#

that's cool

#

last time they told me they couldn't get a hold of me or something and I waited real long 🀣 I'll check in in a few days

random harbor
random harbor
rain heart
#

your bot client

#

your bot object

#

or whatever your bot is defined as

thorn sky
#

Hi how can i check the authorization value for webhooks? Im using sanic and python3.8.

pliant oak
thorn sky
#

does it not show up for test requests?

pliant oak
#

it might lemme check

thorn sky
pliant oak
#

hmm

#

apparently im not getting it either

#

oh there we go

thorn sky
#

does it need to be a real vote?

pliant oak
#

no

#

i tried a real vote

#

it returns the authorization key in the headers

random harbor
#

AttributeError: 'Client' object has no attribute 'add_cog'

pliant oak
random harbor
#

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

def __init__(self, bot):
    self.bot = client #discord.Client()
    self.token = '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))
setup(client)

random harbor
#

What can I do?

pliant oak
#

show me you defining the bot instance

random harbor
pliant oak
#

have you used a cog before?

random harbor
#

What I have to do for count the servers

random harbor
pliant oak
#

@random harbor show me the first part of your launcher file

random harbor
#

The what?

pliant oak
#

bot = commands.Bot(command_prefix=get_prefix, description='A Rewrite Cog Example')

#

that part

#

it might be client = commands.Bot

#

just show me that part

random harbor
#

Don't have

pliant oak
#

what

#

show me your main bot file

random harbor
#

I have only client = discord.Client()

pliant oak
#

ommitting token

random harbor
#

I have to show my bot's code or this is good??

pliant oak
#

i-

random harbor
#

?

pliant oak
#

try replacing in def setup(bot): with def setup(client):
and client.add_cog(TopGG(client))

random harbor
#

I am italian sorry for my bad english

random harbor
#

Don't print ('server. count...')

#

maybe I should change def _init (self, client) ??

#

@pliant oak

viscid wedge
#

hi πŸ˜„

#

I dont find the old docs anymore so I wanted to ask how the vote-event looks like because I dont want to change my live bot to see it πŸ˜„

rain heart
viscid wedge
#

ah thanks πŸ˜„

thorn sky
#

Hi I have a question regarding dblpy. When I set up dbl.DBLClinet what does it expect I put into webhook_path? does it assume i put in the webhook url I put into top.gg?

#

does the url need to accept get requests? Im asking this since i dont know how to get on_dbl_vote to work

dapper copper
#

cc @sullen nymph I don't really know the lib well enough to answer this, can you help ^^

sullen nymph
#

That route is passed in webhook_path

#

Route being the that comes after the domain/ip:port, must start with /

thorn sky
#

so if my webhook url is xyz.xyz.xy.xy:8000

#

i would put in /xyz.xyz.xy.xy

dapper copper
#

No

#

hold on

#

lemme explain

#

So you hostname is for example localhost:4200/webhook_path

#

/webhook_path is what you should set it to

thorn sky
#

ooh

#

so in my case

#

it would just be /

dapper copper
#

yes

thorn sky
#

ok thank you

dapper copper
#

No problem

thorn sky
#

and Im guessing it gets the webhook url from top.gg?

dapper copper
#

No it would need you to set the url

#

to your webhook

thorn sky
#

since I only see webhook_auth webhook_path and webhook_port as parameters

dapper copper
#

afaik it uses 0.0.0.0 so it'd be on whatevery_ip_your_host_gave_you:webhook_port/webhook_path

#

@sullen nymph this correct?

sullen nymph
#

Aye. Enter URL and Authorization key in your bot's Webhooks section on the Edit page

dapper copper
#

@sullen nymph I would also do people a favour as a testing thing, listen on get webhook_path and make it return Hello world or something as verification its working

#

i'll make it an issue on the repo if you want

sullen nymph
#

405 is returned

dapper copper
#

Oh

#

No content

#

ok

#

oh wait

#

Thats MNA

#

my bad

thorn sky
#

so nothing needs to be done on my server to get this to work right? I just accept post requests and I can see that I get it when I press the test button

sullen nymph
#

I mean, I can technically allow GET but I don't exactly see a point in that, considering you'll just get slapped with 405 if you try to access it in browser, which still kinda shows that the webserver is running

dapper copper
#

Yea

dapper copper
#

if it still doesnt work try accessing it on the browser

#

if it returns err_connection_refused make sure your firewall on the host isnt blocking the port

thorn sky
dapper copper
#

That means that the webserver is running

#

hmm

thorn sky
#
@app.route("/", methods =['POST']) 
async def on_post(request): 

    return response.json({"content": request.json}) 
    
dapper copper
#

try setting the webhook path to something other than /

thorn sky
#

this is my only function on my server

#

ok

#

will try

thorn sky
# dapper copper try setting the webhook path to something other than `/`

self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path="/webhook", webhook_auth=PASSWORD, webhook_port = 8000)

@commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print("test")
        logger.info('Received an upvote')
        print(data)
@app.route("/webhook", methods =['POST']) 
async def on_post(request): 

    return response.json({"content": request.json}) 
    

I can see the POST request on my server. I can read in the json file and confirm that it is from top.gg and connecting on a web browser gives a 405. But the on_dbl_vote function still doesnt print anything. They're both hosted on a vps from the same provider. (Although on a separate vps if that matters)

restive otter
#

If you're passing values to webhook kwargs, why would you setup the webserver yourself?

thorn sky
#

was i not supposed to do that?

thorn sky
restive otter
#

but anyway, you don't need it, the lib should handle it. What version are you on?

thorn sky
#

of dblpy or python

restive otter
#

dbl

#

I'm not sure if v1 is out yet, but webhook kwargs are ignored ig, as there's another interface for that

restive otter
sullen nymph
#

Github contains 1.0

#

pypi is still on 0.4

restive otter
#

why is __version__ value different with version_info

sullen nymph
#

Good question

#

Ask January me

restive otter
#

lol so, that means it's not out yet

sullen nymph
#

Ya it's not

#

1.0 isn't fully out yet

restive otter
#

0.4 doesn't ignore the webhook kwargs right? So that means, their webserver should be running.

sullen nymph
#

Mhm

#

Test webhook button will fire the on_dbl_test event @thorn sky

thorn sky
#

oooo

#

its not in the documentation

restive otter
#

it is? MegaThonk

thorn sky
#

this is what im reading

#

Ctrl+F on_dbl_test gives me nothing

restive otter
#

oh yeah it's not documented on 0.4.0 ig

thorn sky
#

is it the same as on_dbl_vote but its called on_dbl_test

thorn sky
#

or would there be other differences

restive otter
#

It'll be the same except the type field ig

thorn sky
#
@commands.Cog.listener()
async def on_dbl_test(self, data):
    print("test1")
    logger.info('Received a test upvote')
    print(data)

so this should work right? cause im still not getting anything

restive otter
#

I suppose, I'm still on 0.3, but I think there's no diff for that. Did the vote event get dispatched?

thorn sky
#

If you mean if I've ever seen the on_dbl_test event go off than no

restive otter
#

Yeah, you said the test event didn't fire, but did the vote?

thorn sky
#

I can see that I got the POST request on my server

restive otter
#

You sure the cog is loaded and the listener is one of the cog's methods?

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

    def __init__(self, bot):
        self.bot = bot
        self.token = #token would go here but i took it out so i dont show it here
        self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path="/dbl", webhook_auth=PASSWORD)
        self.claimable = []
        self.weekend = False
        self.update_stats.start()
    
    
    @tasks.loop(minutes=30.0)
    async def update_stats(self):
        """This function runs every 30 minutes to automatically update your server count"""
        self.weekend = await self.dblpy.get_weekend_status()
        logger.info('Attempting to post server count')
        try:
            await self.dblpy.post_guild_count()
            logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
        except Exception as e:
            logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
    
    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print("test")
        logger.info('Received an upvote')
        print(data)
        
    @commands.Cog.listener()
    async def on_dbl_test(self, data):
        print("test1")
        logger.info('Received a test upvote')
        print(data)
#

yes

#

I got the webserver you sent in chat that works as cog working so I'll just handle votes outside of the TopGG class I have

restive otter
#

If you don't pass the port, TCPSite (which what dbl uses) defaults the port to 8080, but your log says 8000

thorn sky
#

Ive tried it both with and without passing the port

#

neither worked

restive otter
#

You seemed to pass /webhook on the site while you set the webhook_path to /dbl.

thorn sky
#

i changed the webhook

#

i use a different ip and path now

#

its fine I've given up trying to use on_dbl_vote

restive otter
#

Oh welp, at least you got it working

thorn sky
#

still not working but trying a different approach

restive otter
#

I got the webserver you sent in chat that works as cog working
Didn't you say this

thorn sky
#

yeah but after i reloaded the cog it stoped working

#

i cant get the web server to go back up now

#

it worked at first

#

i tried restarting the vps and still nothing

restive otter
#

@thorn sky did you try and open the webhook path in your browser, and check if it gives you unauthorised, to check if the webhook is running.

thorn sky
#

nah i just gave up since it would sometimes work and just wouldn't other times. So I went back to my original idea of just running the webhook as a separate python file and writing to a text file and read that in my bot

restive otter
#

if only post route was set, it'll give you 405 doe

#

Can someone send me the api docs link i seem to always hit 404 when i try going on it i think i have the wrong link?

dapper copper
#

wait

#

what

#

the fuck

restive otter
#

i tried that link but it gives 404 wich means page not found

dapper copper
#

yea

#

just reported it now

restive otter
#

Ok, hope it gets fixed soon

dapper copper
#

Should be done fairly quick 🀞

restive otter
rain heart
#

Yup docs are no more again

restive otter
#

rip new docs 2021 - 2021

meager harness
#

if i replace webhook url of my bot will on vote on that link will be posted?

rain heart
#

if it is the correct one, yes

#

you cannot use discord webhooks

meager harness
#

ik

#

I have a website

#

So I can use that

rain heart
#

yeah you could

meager harness
#

Authorization is required?

rain heart
#

yes

meager harness
#

Or its just a verification from where the request is coming?

#

maybe multiple bot can use my webhook path and Authorization key is just to verify from where that request is coming or something else?

rain heart
#

just a verification, so malicious requests wouldn't come through

meager harness
rain heart
#

yes

meager harness
#

Seems when I do make a post request manually its working but pressing the test button doing nothing

rain heart
#

if you saved your webhook

meager harness
#

got it.

restive otter
#

tΓΌrk olan birisi server sayΔ±sΔ±nΔ± postlamama yardΔ±m edebilir mi

#

nasΔ±l yaparΔ±m

#

docs çalışmıyo

#

@restive otter if your asking about how to post guild count, may i know what programming language you are using for your bot, this will determine the way, each programming launguage have its way.

#

im using discord.js

#

how can i post server count ?

willow seal
#

Owoh

tacit marsh
#

hi where i can get my token acount ?

rain heart
#

you can get your top.gg token under bot page settings -> webhooks

tacit marsh
#

ok thanks

rain heart
#

yes

tacit marsh
rain heart
#

Not that link

#

go to bot page settings -> webhooks

#

the docs are kinda broken right now

tacit marsh
#

ok

#

and for that ? { webhookPort: 5000, webhookAuth: 'password' }

rain kestrel
#

I want my bot to have the servers on how many it is on this overview I did it on my one bot but forgot because I did it a year ago. Where can I find this in the API

restive otter
rain kestrel
#

I need the server_count

restive otter
#

You wanna get the server count? Why don't you rely on the cache?

random harbor
#

How can I show in how many server my bot is in python, I have already tried the docs but it don't show anything

restive otter
#

If you were asking how to show it on the site, you can use the python-sdk.

restive otter
#

how can i post stats

#

with dblapi.js module

#

in javascript

sinful knoll
#

This is the snippet from the site:

const client = new Discord.Client() // Your discord.js or eris client (or djs ShardingManager)
const AutoPoster = require('topgg-autoposter')

const ap = AutoPoster('Your Top.gg Token', client)

ap.on('posted', () => {
  console.log('Posted stats to Top.gg!')
})
restive otter
#

its for the 'topgg-autoposter' module

rapid kettle
#

move to topgg-autoposter or @waxen widget-gg/sdk depending on usage

haughty drum
#

Hello

#

Where can i find my authorization token so i could update stats

restive otter
hollow owl
#

hey,how can i get a bot desc to a json?

willow spindle
#

json?

haughty drum
#

string to json? just parse it

willow spindle
#

you can get bot's description in bot info endpoint

hollow owl
#

oh ok

#

thx

haughty drum
#

So uhm

#

Where I can i find auth token

willow spindle
haughty drum
#

ah didnt see it

#

am blind

#

alright ty

vapid wraith
#

What is the node package for getting upvote userids?

hot axle
#

@top-gg/sdk

worn sphinx
#

what do the webhooks even do

#

cuz idk

meager harness
rain heart
#

UTC

restive otter
#
import dbl
import discord
from discord.ext import commands
import asyncio
import logging

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

    def __init__(self, client):
        self.client = client
        self.token = '' # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.client, 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("Recieved a vote!")
        print(f"It was {user}")
        print(data)

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

the vote check isn't working for me

#

can anyone here help? :P

#

you need to specify the port and stuff

restive otter
#

port for the webserver to run on, that should match with what you pass on the site

#

uh oh

#

You can just pass the port alone, the path will default to /dblwebhook and the auth will default to an empty string.

inland widget
#

Yo

#

Yup this helped a ton

wary ember
#

You need to ask for help

inland widget
#

Yo can anyone help me set up auto rewards with my bot if people vote for my server? I don't want it to be roles I want my bot to give users a !claim command once they have voted.

upper spindle
#

What dose the dblby library do?

#

How do I get a dbl token?

#

What that

inland widget
#

Yo can anyone help me set up auto rewards with my bot if people vote for my server? I don't want it to be roles I want my bot to give users a !claim command once they have voted. I'll pay some 10$ to help me quick I know it can't be that hard.

glacial stag
restive otter
glacial stag
#

What to do

restive otter
inland widget
#

Would anyone like to help me with giving my users voting rewards that aren’t roles in my server?

balmy island
pliant oak
#

they have an example

balmy island
#

it's not what i am looking for

#

but i guess that i found it

#

thanks anyways

jolly solar
#

it's possible to know when a user vote for your bot without the webhook ?

#

but i have to connect with webhook ?

#

like that : self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000

#

?

#

not at all

#

it's the doc

#

You use the same extension like me for the emotes xD

#

i repost my question because it was hiden

#

πŸ€”

rain heart
#

That's python Bonk

jolly solar
#

The python server is too active, i'm ignored xD

restive otter
#

I've made a self-bot that I can chat and read messages through. Super fun stuff

#

All by myself too

#

Yeah but nothing "bad" like Discord would say

#

They allow clients like such anyway

#

If Discord really cared about me, they'd know. They're api says it all

jolly solar
#

how ? The available channel do not allow to write πŸ€”

restive otter
jolly solar
#

i'm just stupid xD

restive otter
#

@manic dune where's the TOS specifically for bots? I want to see it. It's been a while since I've looked at it

green mantle
# restive otter <@!350199484246130690> where's the TOS specifically for bots? I want to see it. ...

Finally, we ask that you respect Discord itself:

- You may not sell your account or your server.
- __**You may not use self-bots or user-bots to access Discord.**__
- You may not share content that violates anyone's intellectual property or other rights.
- You may not spam Discord, especially our Customer Support and Trust & Safety teams. Making false and malicious reports, sending multiple reports about the same issue, or asking a group of users to all report the same content may lead to action being taken on your account.

If you see any activity that violates these guidelines, you can report it to us by filling out this form.

sullen nymph
#

Off-topic

green mantle
sullen nymph
balmy island
sullen nymph
balmy island
#

nice

teal flume
#

apparently i've been exceeding my rate limits too frequently (429), what's going on?

balmy island
#

okay that on_dbl_vote in python lib doesn't get invoked for some reason
any idea what could be the reason ?

#
@commands.Cog.listener()
async def on_dbl_vote(self, data):
    user_id = data['user']```
#

this is a part of my event

restive otter
#

Ok ok

balmy island
restive otter
#

So I'm confused: why would Discord even allow the connection of self-bots if they don't like their existence at all?

brazen abyss
#

I was just gonna ask

cedar arch
#
@bot.event
async def on_dbl_vote(data):
    print(data)

Why my bot is not responding when I vote for it?????

cedar arch
#

Anyone here???????

#
@bot.event
async def on_dbl_vote(data):
    print(data)β€Š

Why my bot is not responding when I vote for it?????

jaunty plank
#

did you fill the url on the website?

restive otter
#

yo ok

#

does the

#

AutoPoster api for node error

#

if your bot isn't verified yet

cedar arch
jaunty plank
#

the website needs a url and auth to know where to send the votes to

#

your bot/servers edit page, webhooks, URL and auth sections

cedar arch
#

Ooo

little harbor
#

@cedar arch why did you ping me here earlier?

cedar arch
#

I don't pinged

little harbor
#

you did, and deleted it

#

I'm guessing it was a mistake πŸ‘

cedar arch
#

Yes

#

That's why i deleted

velvet abyss
#

where can I found a webhook and how and what?

#

where can i found webhook url

jaunty plank
#

the url will be something like
http://ip:port/path
ip, port and path need to be filled in

#

if using repl or heroku or something non standard you will need to use their URLs and ports.
if using a home server you will need to port forward

wraith skiff
#

It's possible to use a Flask webhook for receiving, right?

restive otter
#

it is

#

/psc

restive otter
#

how do i use the Api?

rain heart
willow spindle
#

@left egret this guy ghostpinging this guy in every channel (this is second time)

#

deleted lol

rain heart
#

saw it myself

left egret
#

let me check

carmine drum
#

how do u get your dbl token

rain heart
#

from your bot page settings -> webhooks

carmine drum
#

thanks

#

also what should the webhook url be

#

i want to make a reward mechanism for voting

#

so i need to use dblpy

#

and im just very confused

restive otter
#

Hey can some one guide me how to use api

pallid forge
restive otter
#

I kown

#

But it can't help me

pallid forge
#

What issues are you having?

restive otter
#

Can u come in dms

#

@pallid forge

pallid forge
#

Probably best if you ask here as I am not the most experienced with the api

restive otter
#

Ok

brittle spoke
#

what language do you use?

restive otter
#

Python

#

@brittle spoke

brittle spoke
#

are you looking to post server count?

restive otter
#

@pallid forge I am trying the webhook method and when I try the test button it shows nothing

brittle spoke
#

oh webhook

restive otter
#

Yeah

#

Can someone help me

#

@pallid forge

pallid forge
#

I’ve never personally used the webhooks so I can’t sorry

restive otter
#

Ok

#

oof i should’nt delete

#

anyways

restive otter
#

so you have a bot and hosted?

#

Yep

#

may i know what is it, a vps, heroku, repl.it

#

so first you should know your ip and port,

#

Ip??

rapid kettle
#

No need for port

#

and IP is just repl URL

restive otter
#

oh welp forgot

#

Ok

carmine drum
#

what about heroky

#

heroku

rapid kettle
restive otter
#

I got it

restive otter
carmine drum
#

what do i need

#

to do

#

the documnetation is so confusing

restive otter
#

Same

#

just get the repl url like this https://PROJECT_NAME.YOUR_REPL_NAME.repl.co @restive otter

#

and

#

put

#

so you both want to post guild only right?

#

or voting function as well?

restive otter
carmine drum
#

i want to get voting function

restive otter
#

alr

carmine drum
#

but its like a redeem sort of thing

restive otter
carmine drum
#

yes

restive otter
#

dbl

#

its the same

#

Ohh ok

#

so there is an example in the docs for voting function and guild count

carmine drum
#

Yes

restive otter
#

Yeah

carmine drum
#

but i dont know how to get any of it to work

restive otter
#

But can't understand

carmine drum
#

like i have the function, but how do you call it

restive otter
#

get that code and put it in cogs folder or what ever you named it if you have cogs

#

I don't

carmine drum
#

when i try asyncio.run it decides that self isnt declared

restive otter
#

Yeah

carmine drum
#

yes but in my example

#

i have a discord eveny

#

event

restive otter
#

just a second

carmine drum
#

on message prefix+"redeem":
check vote

restive otter
#

Can u send me full code of event

#

Vote

#

Plz

carmine drum
#

or alternativley just on user vote is just as workable but i dont know how to test that

restive otter
#
from discord.ext import commands

import dbl


class TopGG(commands.Cog):
    """
    This example uses dblpy's webhook system.
    In order to run the webhook, at least webhook_port must be specified (number between 1024 and 49151).
    """

    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)

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        """An event that is called whenever someone votes for the bot on top.gg."""
        print("Received an upvote:", "\n", data, sep="")

    @commands.Cog.listener()
    async def on_dbl_test(self, data):
        """An event that is called whenever someone tests the webhook system for your bot on top.gg."""
        print("Received a test upvote:", "\n", data, sep="")


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

after putting this in your bot’s cog folder

restart your bot so it can load and host the webhook

after that go to your bot’s edit page and go to webhooks tap, put your webhook as https://PROJECT_NAME.YOUR_REPL_NAME.repl.co/dblwebhook < FOR REPL

after that put the authorization the field under webhook url as your secret the password in the code and the password in the top.gg page should match!.

test the webhook and see if it works.

@carmine drum
@restive otter

#

Ok

restive otter
#

are you using python with your bot?

carmine drum
#

thx

balmy island
rain heart
#

your aws ip

balmy island
#

what about the port ?

willow spindle
#

it is your choice

proud cloud
wraith skiff
#

But the url

proud cloud
#

after that go to your bot’s edit page and go to webhooks tap, put your webhook as https://project_name.your_repl_name.repl.co/dblwebhook < FOR REPL
this part is only for repl

wraith skiff
#

Yea..

proud cloud
#

you just need to find your heroku app url

wraith skiff
#

Maybe I can use a heroku webhook

wraith skiff
sullen nymph
#

on repl you run your webhook in port 8080, I think same applies to Heroku

restive otter
#

yes you can

#

idk what is the default port for heroku

proud cloud
wraith skiff
#

Yea that

#

But it shows options of what will trigger it

proud cloud
#

https://<application name>.herokuapp.com/ isn't this domain working for webhooks?

wraith skiff
#

yes

#

but

#

I gotta select what will trigger it

#

idk

proud cloud
#

the path is triggering it

balmy island
#
sh-4.2$ ip
Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }
       ip [ -force ] -batch filename
where  OBJECT := { link | address | addrlabel | route | rule | neigh | ntable |
                   tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm |
                   netns | l2tp | fou | macsec | tcp_metrics | token | netconf | ila |
                   vrf | sr }
       OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |
                    -h[uman-readable] | -iec |
                    -f[amily] { inet | inet6 | ipx | dnet | mpls | bridge | link } |
                    -4 | -6 | -I | -D | -B | -0 |
                    -l[oops] { maximum-addr-flush-attempts } | -br[ief] |
                    -o[neline] | -t[imestamp] | -ts[hort] | -b[atch] [filename] |
                    -rc[vbuf] [size] | -n[etns] name | -a[ll] | -c[olor]}```

So ... ?
proud cloud
#

so your domain should be like https://<application name>.herokuapp.com/dblwebhook

wraith skiff
#

yea it is like that

balmy island
#

which ip should i use ? address ?

wraith skiff
#

what

balmy island
wraith skiff
#

ok

#

can someone give me the link where I get my bots dbl token

wraith skiff
#

thanks

#

its the votetracker bot webhook

#

it also gave me the auth

willow spindle
#

yes

balmy island
#

why isn't it working..

willow spindle
#

are you serious

balmy island
#

about ?

willow spindle
#

127.0.0.1 is localhost

balmy island
#

oh

#

i am not able to find my ip

#

both on my windows laptop or on aws's linux

willow spindle
#

curl ifconfig.co

balmy island
#

okay and on windows ?

#

cause i am testing on it

willow spindle
#

same iirc

sour sequoia
#

bot.on('message', async (message)=>{
app.post("/dblwebhook", webhook.middleware(), (req, res) => {
// req.vote wil lbe your vote object, e.g
wc.send(req.vote.user); // 395526710101278721 < user who voted
wc.send(test)
});

app.listen(0);

wraith skiff
#
    bot.add_cog(TopGG(bot))```
do I have too call this function?
sour sequoia
#

on what i need to put the app.listen?

willow spindle
#

port number

sour sequoia
#

wdym

#

what is port number

willow spindle
#

google it

sour sequoia
#

k

#

is it

#

like

#

zip code?

#

@willow spindle

willow spindle
#

no?

#

zip code wtf

sour sequoia
#

nvm,

wraith skiff
#

lol

willow spindle
wraith skiff
#

self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='https://python-bot-69.herokuapp/dblwebhook', webhook_auth=auth, webhook_port=5000)
did I put the webhook_path right?

#

i mean

#

should it just be /dblwebhook

#

?

willow spindle
#

no

#

idk about dblpy but i think no

wraith skiff
#

ok

sour sequoia
#

@willow spindle i got my port number, so i just put it there?

willow spindle
#

yes

#

you have to open that port too

sour sequoia
#

it have dots in it, its giving me problems because of it

willow spindle
#

dots?

sour sequoia
#

it have . and :

upbeat imp
#

ah ty7

#

-7

sour sequoia
#

i did netstat -a, in CMD and it showed me 100 numbers

#

and to put it there? in the app.listen?

balmy island
#
def __init__(self, bot):
    self.bot = bot
    self.token = "my_token" 
    self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='https://my_hosting_ip:8080/dblwebhook', webhook_auth='nice', webhook_port=8080)```

Still now working... the path is the exact same as the link in the site
#

lol how ?

#

shit the meme in not working

#

bruh

#

i am using hosting

#

i can't go through web

sour sequoia
#

same

balmy island
#

if not.. how can i get my port forwarded ?

wraith skiff
#

heroku webhook dont work with this

upbeat imp
#

for this part i do the end of the webhook for the channel ?
const webhook = new Topgg.Webhook("your webhook auth");

balmy island
#

I am not working on my router.. it's AWS

wraith skiff
#

idk how

#

no Ill host a webhook on heroku

upbeat imp
#

wait im stupid the webhook auth is the bot token for top?

sullen nymph
#

set webhook_path to /dblwebhook

#

You know what

#

I'll just start raising errors if webhook_path doesn't start with /

restive otter
#

how can i post my library to top.gg ?

rain heart
#

you can't anymore

#

the library field is going to be removed eventually

#

Well it is, just can't use it anymore

restive otter
#

ty

sour sequoia
#

@shut flume is there away that i can do that the bot will send a message when someone voted with out doing that port thing?

balmy island
#

i cannot see that :^)

restive otter
wraith skiff
#

const webhook = new Topgg.Webhook("your webhook auth");
translated to python?

#

nevermind I give up

#

I should probably start using repl

#

I cant do that

#

nah

#

because they are free

#

yea but I lose money then

balmy island
#

priorities

#

what's the point of paying money when it doesn't get you some benefits

#

with a discord bot.. hmm it's not worth it
maybe with some other stuff

wraith skiff
balmy island
#
Traceback (most recent call last):
  File "/home/ssm-user/.local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 275, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 523, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: invalid HTTP method```

This is my `on_dbl_test` output.. any idea what it does mean ?
proud cloud
#

at least you'll get less ping KEKW

balmy island
#
@commands.Cog.listener()
async def on_dbl_test(self, data):
    print(data)```
just this
#

My mind has blown.. really

#

Yeah I did
is there somehing wrong with the code ?

#

yeah i suppose

#

yup

wraith skiff
#

does the webhook_port need to be given?

#

yea

#

ill just put 5000

#

idk

#

its not my webhook

#

its from the bot

#

vote tracker

#

and I will also put the webhook_path to ''

#

because its already in the url

#

the bot said it should be like this

#

and it worked for it

#

well nothing happened

balmy island
#

is it a problem from my port or what

sullen nymph
#

Ignore the error

#

Actually hold on

#

When do you happen to get it

balmy island
balmy island
sullen nymph
#

How are you sending them

balmy island
#

like this

sullen nymph
#

But I asked how you send the requests to your webhook

balmy island
#

What ? through voting or testing

#

both gets me the same error

sullen nymph
#

what's your aiohttp version

balmy island
rough pendant
#

dbl

sullen nymph
#

wtf

balmy island
#

what ,_,

balmy island
restive otter
#

hey i am trying to make on_dbl_vote so someone can help me

sullen nymph
balmy island
sullen nymph
#

Okay, didn't get what I needed. Can you DM me the URL and Authorization key you entered on top.gg?

sullen nymph
carmine drum
restive otter
#

Hey is there any method with using cogs to get the new votes

carmine drum
#

wym by "get the new votes"

#

there is get_user_vote

#

which tells you if a user has voted or not

restive otter
#

He probably meant the webhook, but outside of a cog.

carmine drum
#

hm

#

anyway what should i put as webhook url with heroku

restive otter
#

for heroku i don’t really know

#

but

#

you can try and put your application url + /dblwebhook

hot axle
restive otter
#

yes

carmine drum
#

cool thx

restive otter
carmine drum
#

also with all the "self" stuf it all goes wrong

#

it messes up my parameters in my discord.py commands

#

should i not have it in those

#

just the cog stuff

#

?

restive otter
#

can you show me the code you used?

carmine drum
#

no wait i think i got it myself

#

i havent tested the webhook yet tho

restive otter
#

because thats an on_message error not a webhook

worn sphinx
#

how do you make it so that when a user votes, it posts a message

restive otter
#

you need a webhook

#

You token

#

EDIT IT

carmine drum
#

whoopsie

restive otter
#

regenerate it

carmine drum
#

yup

worn sphinx
#

i have the webhook, but it doesnt post a mesage

#

when someone votes

restive otter
#

is there any errors?

worn sphinx
#

me

restive otter
#

yes

worn sphinx
#

no

restive otter
#

um python?

worn sphinx
#

no

restive otter
#

then sorry i can’t help, i can help with python or discord.py

worn sphinx
#

how to access top.gg token @restive otter

restive otter
#

go to your bot’s edit page >webhook tap, you will find it there

carmine drum
#

2021-02-09T15:31:02.766231+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/dblwebhook" host=hamoodcount.herokuapp.com request_id=0704f27b-ae4a-49d6-94de-776c7f124547 fwd="165.22.130.154" dyno= connect= service= status=503 bytes= protocol=https

#

This is what happens when i test webhook

#

but when i set the procfile to web

#

it says

#

Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

#

what do i do

restive otter
#

hm i never tested dbl webhook on heroku..

#

i see, are you sure you are loading the cog extension?

hot axle
#

well

#

you need to run the server on a web process

#

you can't run it on a worker

carmine drum
#

thing

hot axle
#

are you using the PORT enviroment variable?

carmine drum
#

what is that

#

sorry i noob at heroku

hot axle
#

heroku gives you an env variable called PORT

#

that's the port you should be using in your app

#

um no

#

process.env.PORT for js

carmine drum
#

python?

hot axle
#

um no idea

#

oh

#
import os

os.environ['PORT']
#

wait

#

its os.getenv('PORT')

carmine drum
#

ok so do i put 'PORT' or just any old port

hot axle
#

'PORT'

carmine drum
#

ok

#

thx

hot axle
#

that's the name of the enviroment variable

#

np

restive otter
#

@restive otter

#

:Uglycat:

#

Hi

restive otter
#

Nub

#
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 = 'dbl_token' # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token)

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

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

#

oh wait

#

WHY DID I COPY

#

Lol

#

I WAS MEANT TO GET FROM MY BOT

#

Is malware here

#
import dbl
from discord.ext import commands ,tasks
import discord
import asyncio
import logging


class TopGG(commands.Cog):
   
    def __init__(self, bot):
        self.bot = bot
        self.token = '{confidential so removed}' # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token)

   

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

       


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

i have the cog loaded

#

it still doesnt

#

show server numbers

#

i never could solve this either

#

i ended up using the webhook example for it to work

restive otter
#

You never started the loop

#

yes the loop should be called

restive otter
#

call that loop from on_ready event

#

???

restive otter
#

self.update_stats.start() could be in your __init__

restive otter
restive otter
#

in your main file, the update_stats is not even defined lol

#

yea

restive otter
#

I mean you can get the cog and start the update_stats method, but just call it directly in the cog init

#
try:
    client.load_extension("cogs.e")
    client.load_extension('cogs.modxd')
    client.load_extension('cogs.tickets')
    client.load_extension("cogs.purge")
    client.load_extension("cogs.tags")
    client.load_extension('jishaku')
    client.load_extension("cogs.utils")
except Exception:
    print("extensions cant be loaded the error")
    print(Exception)
    # Rest of the code

@client.event
async def on_ready():
  activity = discord.Game(name=f">help in {len(client.guilds)} guilds")
  print("Bot has logged in")
  await client.change_presence(status=discord.Status.do_not_disturb, activity=activity)
  update_stats.start()
restive otter
#

i am doing this

#

cogs.e is the file the api code is in

#

it doesn’t work because nothing is calling the task loop

restive otter
#

not gonna repeat what I've said kek

restive otter
#

also, you might want to cancel the loop on cog unload, otherwise the loop is gonna stack

sullen nymph
#

also you don't print your exceptions properly

balmy lantern
#

Hello i need help

sullen nymph
#

-ask2ask

abstract mothBOT
#

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

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

balmy lantern
#

How do i add my bot to Webnook i am on a Amazon fire tablet making my bot

#

-ask2ask

restive otter
#

Luca hates you blobweary

balmy lantern
#

Yes

#

Hd

#

No

#

Github

#

Js

restive otter
#

how does that answer the question

#

You need to make a post request

restive otter
restive otter
#

how to get user info

jaunty plank
carmine drum
# hot axle 'PORT'

I have all the env stuff but its still returning Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

sinful oasis
#

where can i regen my token i don't see it

rain heart
#

bot page settings -> webhooks

sinful oasis
#

ohh ojk

#

ok

safe pebble
#

id just like to clarify, .hasVoted is if the user has voted in the past 12hrs right?

rain heart
#

yes

safe pebble
#

awesome thats what i thought thank you

balmy hamlet
#
try:
    cogs = ['e', 'modxd', 'tickets', 'purge', 'tags', 'jishaku', 'utils']
    for cog in cogs:
        client.load_extension('cogs.' + cog)

except Exception:
    print("extensions cant be loaded the error")
    print(Exception)
    # Rest of the code
#

something like that

radiant peak
#

/bots/:bot_id/check also has stricter rate limits right?

rain heart
#

yes, 60 per minute

radiant peak
#

okay, thanks

sullen nymph
#

THAT EXCEPTION PRINTING WILL NOT WORK PROPERLYYYYYY

#

except SomeException as e: AND THEN USE e

restive otter
#

print(traceback.format_exc()) exdee

torpid anvil
#

does anyone know why this isnt working?

wise cairn
#

Yes

#

You Need ID=Channel_id

#

Not only the channel_id

#

@torpid anvil

restive otter
#

You can't get the channel before the bot is ready because the cache is empty

wise cairn
#

Thats true too

restive otter
wise cairn
#

Idk

torpid anvil
wise cairn
torpid anvil
#

hm

#

it still doesn't work