#topgg-api

1 messages Β· Page 77 of 1

topaz verge
#

oke

vapid cape
#

and your webhookPort should be webhookPort:process.env.PORT

topaz verge
#

oke

vapid cape
#

yes

topaz verge
#

i am aleardy

#

added

vapid cape
#

ok

#

and in authorization you put the same thing you put in webhookAuth

topaz verge
#

noting

#

empty

vapid cape
#

ie: webhookAuth:"blablabla"
Authorization - blablabla

topaz verge
#
      throw er; // Unhandled 'error' event
      ^
Error: listen EADDRINUSE: address already in use :::3000
    at Server.setupListenHandle [as _listen2] (net.js:1270:14)
    at listenInCluster (net.js:1318:12)
    at Server.listen (net.js:1405:7)
    at DBLWebhook._startWebhook (/rbd/pnpm-volume/abe93bf7-11f2-4401-b448-53ba2fc1f4f2/node_modules/.registry.npmjs.org/dblapi.js/2.4.0/node_modules/dblapi.js/src/webhook.js:45:18)
    at new DBLWebhook (/rbd/pnpm-volume/abe93bf7-11f2-4401-b448-53ba2fc1f4f2/node_modules/.registry.npmjs.org/dblapi.js/2.4.0/node_modules/dblapi.js/src/webhook.js:27:12)
    at new DBLAPI (/rbd/pnpm-volume/abe93bf7-11f2-4401-b448-53ba2fc1f4f2/node_modules/.registry.npmjs.org/dblapi.js/2.4.0/node_modules/dblapi.js/src/index.js:69:22)
at Object.<anonymous> (/app/server.js:82:13)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
Emitted 'error' event at:
    at emitErrorNT (net.js:1297:8)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:757:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
#

@vapid cape

vapid cape
#

youre already using that port somewhere else

#

do you have an express server?

topaz verge
#

no

#

tes

#

yes

#

i have

vapid cape
#

then instead of webhookPort you put webhookServer: listener

#

if you have a listener

topaz verge
#

look

#

i have exprres for the uptime

#

app.listen(process.env.PORT);
setInterval(() => {
http.get(http://.glitch.me/);
}, 1000 * 60 * 3);

vapid cape
#

let listener = app.listen(process.env.PORT)

#

webhookServer:listener

vapid cape
topaz verge
#

const dbl = new DBL(
  `${config.dbltoken}`,

  {
    webhookServer: listener,
    webhookPort: "listener",
    webhookAuth: "blablabla"
  },
  client
);```
vapid cape
#

remove webhookPort

vapid cape
#

then you're still using process.env.PORT somewhere else

#

or you didnt remove the old one

topaz verge
#

its work

#

when i remove the old

vapid cape
#

yes, i told you to remove the old

topaz verge
#

thanks

restive otter
#

@topaz verge working?

topaz verge
#

no

restive otter
#

why

topaz verge
restive otter
#

do u tried client.fetchUser ?

topaz verge
#

no

restive otter
#

any error?

topaz verge
#

no

#

@restive otter

restive otter
#

hmm

#

do u set dblpassword?

topaz verge
#

yes

restive otter
#

does anyone know possible reasons for counting servers on the top gg site not updating?

#

because it says that my bot is on 6k of servers but it is already with 8k and a half

knotty garnet
#

@restive otter up-to-date library? is your method being called?

restive otter
#

I think it was the version really, it was in 3.3 and now I put it in .4

distant oak
#

Hi ! I have a problem with your NPM package

dbl.webhook.on("vote", vote => { ^ TypeError: Cannot read property 'on' of undefined

vapid cape
#

@distant oak you need to add the webhook configuration, check the webhook example

distant oak
#

Ok thanks

#

It's ugly

#

We are in 2020 not in 1999

#

I can't search anything because the GUI is break

vapid cape
#

reload the page

#

or try a different browser

sullen nymph
#

It's the same on desktop

vapid cape
sullen nymph
#

@arctic arch? nekopeek

vapid cape
#

i found out why

#

cloudflare anti ddos thingy

#

the docs page bypasses it, but the css files do not

#

if you access the css file directly, it takes you to cloud flares 5 second check

#

after you pass that check, the docs page will load correctly

arctic arch
#

cannot reproduce

distant oak
#

I don't understand how webhook works

vapid cape
#

@arctic arch try opening the docs page in a new incognito tab, directly from the url

distant oak
#

What we have to write on URL and on Authorization

vapid cape
#

URL should be your bot's server address, such as vps ip address and port, or glitch/heroku project url

#

authorization is whatever you want, as long as you put the same thing in webhookAuth

sullen nymph
vapid cape
#

^ if you open the page directly

#

but then if you go to any other top.gg page

distant oak
#

Ok thanks

vapid cape
#

it will show the cloudflare anti ddos window

#

then the docs page works again

distant oak
#

There is no port and path on glitch ?

vapid cape
#

the default path when using dblapi.js is /dblwebhook

#

glitch's port is process.env.PORT

#

so your url should be MYPROJECTNAME.glitch.me/dblwebhook

#

and your webhookPort should be webhookPort:process.env.PORT

distant oak
#

Thanks again

#

That do anything (no message, no error, no logs)

vapid cape
#

show your code

grave sundial
#

im sure this is a stupid mistake but when i have

// using glitch
 const dbl = new DBL(blahblahtokenblahblah, { webhookPort: process.env.PORT, webhookAuth: 'password'});
#

it says my token is undefined

#

should it be in '' like it has in the other example on the api page

worn quail
#

why glitch

grave sundial
#

thats just what im using for my host

worn quail
#

your token wasn't set up correctly then

#

exactly what it says

#

regen it if needed

grave sundial
#

ill try a third time

#

nope

#

the code should be in my index.js towards the top right?

#

not inside anything else

worn quail
#

idk i dont do js

grave sundial
#

ah, well thanks anyways

silent orbit
#

Fyrlex

#

i'd recommend to choose a different port

#

because if you use the same for express and something else the app won't start

amber fjord
#

is there a way i can get the widget as png

#

nvm

distant oak
#

Hi ! Why webhooks do anything

#

I have a problem
Error: listen EADDRINUSE: address already in use :::3000

green mantle
#

read the error

#

port already in use

distant oak
#

But why ?

#

Ow express

#

Webhook running at http://0.0.0.0:3000/dblwebhook hmm that not normal

vapid cape
#

that is normal

distant oak
#

Oof

errant wasp
#

Is test webhook broken or something? I tested from my PC rather than using the test button on the settings page and it works, but when I try to test it there I get nothing logged.

vapid cape
#

how did you test?

errant wasp
#

I used a Chrome App to make a post request (only with type: test as JSON) and printing the result on my bot, which worked fine

hot stratus
#

Heya, I'm having an issue with my bot right now for a reason I can't understand. Suddenly it cannot log in (via client.login), it just hangs there without throwing an error or continuing with success.

#

The only error I got was this generic thing:

Error: Something took too long to do.

#

What's weird is that I have two versions of the bot made, one for development and one that is actually used (prod), and if I just switch the token to the dev-version it logs in fine

hot stratus
#

So after resetting the bot multiple times it did manage to log in, but I didn't change anything, so I still am wondering what went wrong...

blissful notch
#

@hot stratus what version of Discord.js are you using? (fuck I thought this was development)

hot stratus
#

Yeah, sorry about that. We can move this chat there.

wild blade
#

is there any way to update the bot description using the api?

knotty garnet
#

no afaik

wild blade
#

ok

craggy anchor
#

I still don't get anything printed or any errors showing.. I have no idea what I'm doing wrong to set up votes

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

import asyncio
import logging


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

    def __init__(self, bot):
        self.bot = bot
        self.token = token
        self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='DBL_PW', 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())

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print("voted")
        logger.info('Received an upvote')
        print(data['user'])
        user = self.bot.get_user(data['user'])
        try:
            await user.send("Thanks for voting!")
        except:
            pass

    @commands.Cog.listener()
    async def on_dbl_test(self, data):
        print("voted")
        logger.info('Received an upvote')
        print(data['user'])
        user = self.bot.get_user(data['user'])
        try:
            await user.send("Thanks for voting!")
        except:
            pass
    
def setup(bot):
    global logger
    logger = logging.getLogger('bot')
    bot.add_cog(TopGG(bot))
#

does this look fine?

#

I'm hosting it on a VPS

restive otter
#

have you checked if port 5000 is open @craggy anchor ?

#

and ur webhook auth is ur token etc.

craggy anchor
#

@restive otter wdym by that? port 5000 is open yes

restive otter
#

webhook_auth='DBL_PW',

craggy anchor
#

do I need to use my token as my webhook auth? the dbl token

restive otter
#

the dbl token ye

#

the api token for ur bot

green mantle
#

No?

restive otter
#

iirc

craggy anchor
#

i thought it could be anything

green mantle
#

The auth is not the same as the tokeen

restive otter
#

auth for the webhook should be ur api token right

craggy anchor
#

just a pw

restive otter
green mantle
#

The token is a specific thing you get generated by on the site

#

The auth password can be anything you set it to

restive otter
#

welp then idk

craggy anchor
#

besides from that, does anything else look wrong here?

restive otter
#

i dont speak any of that language

green mantle
#

Is it actually logging anything

#

I take it your token var is set

#

But you just haven't added in for security

#

If not

#

Then might be a good idea to add it

craggy anchor
#

no doesn't seem to log anything

#

wait actually it does

#

nvm

#

it would also be like this right?

vapid cape
#

yes, case sensitive

craggy anchor
#

still don't get any output when I try to use the test thing

spiral steeple
#

did you save?

craggy anchor
#
    @commands.Cog.listener()
    async def on_dbl_test(self, data):
        print("voted")
        logger.info('Received an upvote')
        print(data['user'])
        user = self.bot.get_user(data['user'])
        try:
            await user.send("Thanks for voting!")
        except:
            pass
``` yeah I saved,
#

I'm using print and checking if it shows anything but

#

it doesn't show up anything

#

just voted by myself too and didn't show up anything pensivesob

restive otter
loud gulch
#

turn ur bad request into a good request

restive otter
#

@loud gulch how ??

loud gulch
#

idk lmao im shittposting in the wrong channel

vapid cape
#

@restive otter if you're using discord.js v12, you need to update dblapi.js

restive otter
vapid cape
#

this error is not related to discord

#

whats the full path of the error?

restive otter
#

oh its opus error

#

@vapid cape yea its working now with 2.4.0
thanks brother

distant oak
#

Hi if I use discord.js@11.4.2, which version of dblapi.js I have to use ?

restive otter
#

try 2.3.0 or 2.4.0

jaunty fog
restive otter
#

Can anyone provide me a script of python to update servers in TopGG

#

U tried a lot but not worked

#

So

sullen nymph
#

What exactly have you tried

restive otter
#

Hello, it's possible to help me I want to use the API voting system ?

jaunty fog
#

I have a question. I have an express server for my bot. but can i use different port for my webhook?

vapid cape
#

nope

#

but you can use the existing server in dblapi.js

#

instead of webhookPort you use webhookServer: listener

jaunty fog
#

If i try to use listener it just gave me the EADDRINUSE error

true talon
#

Hi if I use discord.js@11.4.2, which version of dblapi.js I have to use ?
@distant oak any

distant oak
#

ok

restive otter
#

Do I need a different port for different webhooks on different shards?

#

(and yes i know there’s too many differents)

vapid cape
#

if you're sharding, you should ideally listen to the webhook in your sharding manager, not in individual shards

restive otter
#

@sullen nymph

#

Can anyone provide me a script of python to update servers in TopGG

restive otter
#

@vapid cape How should I get the user in a ShardingManager?

left egret
#

@restive otter check our docs

restive otter
#

import dbl import discord from discord.ext import commands class TopGG(commands.Cog): """Handles interactions with the top.gg API""" def __init__(self, bot): self.bot = bot self.token = 'dbl_token' # set this to your DBL token self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes async def on_guild_post(): print("Server count posted successfully") def setup(bot): bot.add_cog(TopGG(bot))

#

This is in working condition or no sir

#

@left egret

sullen nymph
#

If you set self.token to your bot's top.gg token, yes

restive otter
#

@sullen nymph

#

Sir

#

This is the token

#

Na

sullen nymph
#

Yes

restive otter
#

Wait I will

#

Host

jaunty fog
#
let dbl = new DBL(client.config.apiKeys.dbl, { webhookServer: app.listen(process.env.port), webhookAuth: client.config.votes.password });

can someone help with this code? Its giving me the eaddrinuse error

vapid cape
#

@restive otter depending what you want to do with it, most likely broadcastEval

restive otter
#

ok thanks

restive otter
#

Check from starting bro

sullen nymph
#

Your module is drunk πŸ‘€

green mantle
#

might be because hes trying to run it on a android python emulator

crisp river
#

Can i put anything on authorization?

#

on weehbook menu

vapid cape
#

yes

crisp river
#

K

jaunty fog
#
Webhook running at http://0.0.0.0:0/dblwebhook

Why does the port not working?

spiral steeple
#

did you pass a server?

jaunty fog
#

wdym?

spiral steeple
#

show me how you called the DBL constructor

#

it'd be like new DBL(...)

jaunty fog
#
let listener = app.listen(process.env.port);
let dbl = new DBL(client.config.apiKeys.dbl, { webhookServer: listener, webhookAuth: client.config.votes.password }); 
spiral steeple
#

Yeah when you pass an already made httpServer it defaults to 0

#

should be whatever port your listener uses

jaunty fog
#

ok but how do i fix the eadrinnuse error

spiral steeple
#

by passing the httpServer you already have, which is what you did.

#

Should work

#

Just the port shows 0

#

but it should be whatever your port for your listener is, it just doesn't log it

jaunty fog
spiral steeple
#

well it doesn't handle gets, it handles posts

#

go to your bots edit page and put http://ip:port/path and whatever your webhook auth is then save and test

jaunty fog
#

bruh but i already have an express server

#

so thats why im using webhookServer instead Port

spiral steeple
#

Yes I know

#

the server has a port

#

are you on glitch?

jaunty fog
#

y

#

yes

spiral steeple
#

Then it'd be listening on https://your-project-name.glitch.me/dblwebhook by default

jaunty fog
#

i mean

#

my express server handles my bot dashboard

spiral steeple
#

Ah

jaunty fog
#

should i use it on different project?

spiral steeple
#

It should work, I'm not sure if it doesn't. It does remove all request listeners though.

jaunty fog
#

i removed the listener on my dashboard file

#

If i dont its giving me the eaddrinuse error

#

or should i merge both of the files together?

jaunty fog
#

ok i moved it to another project and it works

hoary hill
#

Why would I receive a code 1006 when attempting to post server count?

spiral steeple
#

uh

#

what?

#

can you show the error?

hoary hill
#

it's literally an object returned with a message of code 1006

spiral steeple
#

You're missing something, that's not an HTTP Status

#

that sounds like a custom discord api error code

hoary hill
#

it's a http status used by cf

spiral steeple
#

Ah yeah cloudflare stuff

hoary hill
#

just looked at it, apparently my IP is banned?

spiral steeple
#

Weird, what do you host with?

hoary hill
#

a vps

spiral steeple
#

Maybe dbl got spam from the ip range of the provider

#

you'd have to ask though

hoary hill
#

who would I ask?

spiral steeple
#

I would dm oliy or tonk, but I've never seen it before

hoary hill
#

I'd like a mod to confirm that I can dm an admin though, don't want to annoy them

#

@craggy sentinel would that be ok to dm Oliy about my IP being banned from posting?

craggy sentinel
#

oliy is slow to respond occasionally, i'd recommend asking tonkku

hoary hill
#

alright

restive otter
#

hello, how i can do stats command with top.gg stats of my bot? i use node.js

lime rock
livid hound
#

Hello. Can someone give me a simple voting system where when someone votes it sends it to my guilds vote channel?

#

Such as if you seen Circle, it has that.

willow spindle
#

which lib do you use

livid hound
#

d.js

willow spindle
livid hound
#

Thanks my good sir.

livid hound
#

When it says to put your DBL token here, does it mean to put your bots api token there or ?

vapid cape
#

your dbl/top.gg token

#

you get it from your bot's edit page

livid hound
#

So for this line of code,

#

const dbl = new DBL(yourDBLTokenHere, { webhookAuth: 'password', webhookServer: server });

#

WOuld I put the dbl token where it says?

#

Because when I do it throws up a refrence error that it's undefined

#

.*

vapid cape
#

you put it as a string

livid hound
#

For this ```// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})

dbl.on('error', e => {
console.log(Oops! ${e});
})``` Where do I put to show the servercount?

fiery shadow
livid hound
#

I aint that smart

vapid cape
#

@livid hound those are optional. They are used to inform you if the count was posted correctly or not

livid hound
#

Oh.

frigid shore
#

hi

#

my webhook doesnt work :(

willow spindle
#

why

gray root
#

I am sending {"server_count": count, "shard_count": shard_count, "shard_no": shard_id}, from all my shards, however it's not updating on the bot page. It looks like it only picks up a single shard and the api doesnt add the rest all up.
shard_count would be 6
server_count varies between shards
shard_no would be 0 to 5

vapid cape
#

shard_id

#

not shard_no

gray root
#

Thanks

gray root
#

How long do they update? I believe that I resolved it, however they're still not updated on the bot page.

restive otter
#
dbl.webhook.on('upvote', vote => {
    const hook = new Discord.WebhookClient('690965417132425236', 'Te1mQMeYJJEmY2xyiSbhoFuiQLxtBxcrt9-kcSF3qUcYUizmAQ3GXLyiQ_3oIpaD7AJp');
    
    hook.send(`User with ID ${vote.user} just voted!`);
});

Would that work? for the webhook. Cause it doesn't

restive otter
#

Your module is drunk πŸ‘€
@sullen nymph what is the solution

#

Sor

#

Sir

silent orbit
#

you shouldn't leak the webhook token

#

anyone could send messages with it rn

#
dbl.webhook.on('upvote', vote => {
    const hook = new Discord.WebhookClient('690965417132425236', 'Te1mQMeYJJEmY2xyiSbhoFuiQLxtBxcrt9-kcSF3qUcYUizmAQ3GXLyiQ_3oIpaD7AJp');
    
    hook.send(`User with ID ${vote.user} just voted!`);
});

Would that work? for the webhook. Cause it doesn't
@restive otter isn't the event called upvote instead of vote

#

uh

#

i meant vote instead of upvote

shy vortex
#

yes

#

its vote

#

not upvote

#

also thanks for the webhook token

sullen nymph
#

@restive otter not use python on Android

true talon
#

dbl.hasVoted doesnt work, always return false (js)

craggy anchor
#

It has like

#

450 servers

#

@narrow geyser

#

but it only shows 20

true talon
#

dbl.getVotes() broken too

#

it shows a list of random people who have NEVER voted for my bot

restive otter
#

@sullen nymph

#

Done sir

#

I solved it

craggy anchor
#

what does this exactly mean

sullen nymph
#

Port is already used by something else

craggy anchor
#

ah hm

#

that only happens when I close it though

#

close the bot

sullen nymph
#

Is it trying to spawn another webhook

craggy anchor
#

idk.. I think it has something to do with the fact that I'm switching the bot usage between my pc and vps

#

might overlap or smth dunno

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

import asyncio
import logging


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

    def __init__(self, bot):
        self.bot = bot
        self.token = 'token_here'
        self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='DBL_PW', webhook_port=1337)
        
    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print("voted")
        logger.info('Received an upvote')
        print(data['user'])
        user = self.bot.get_user(data['user'])
        try:
            await user.send("Thanks for voting!")
        except:
            pass

    @commands.Cog.listener()
    async def on_dbl_test(self, data):
        print("voted")
        logger.info('Received an upvote')
        print(data['user'])
        user = self.bot.get_user(data['user'])
        try:
            await user.send("Thanks for voting!")
        except:
            pass
    
def setup(bot):
    global logger
    logger = logging.getLogger('bot')
    bot.add_cog(TopGG(bot))
``` is there something that looks wrong here? Nothing seems to work
sullen nymph
#

Why is it trying to use port 5000 when you're specifying the port as 1337 nekothinking

craggy anchor
#

i switched it for now

#

just to see if it did anything

sullen nymph
#

Is it starting just fine?

craggy anchor
#

here's the other part

#

idk how I can tell if it's starting fine tbh

narrow geyser
#

Did you try to load the extension multiple times?

craggy anchor
#

what do you mean by that? sorry

sullen nymph
#

Are you using load_extension multiple times on the file that runs the webhook?

narrow geyser
#

or reload_extension

craggy anchor
#

no.. don't think so

#
#Loading Cogs on Boot
path = ["cogs", "stagecogs"]
for i in path:
    for file in os.listdir(i):
        if file.endswith(".py"):
            name = file[:-3]
            bot.load_extension(f"{i}.{name}")
#

that's the only load

narrow geyser
#

and your not using reload_extension anywhere in your code?

craggy anchor
#

when it starts

#

oh I am yeah

#
   @commands.command(aliases=["r"])
    async def reloadall(self, ctx):
        """ Reloads all extensions. """
        path = ["cogs", "stagecogs"]
        for i in path:
            for file in os.listdir(i):
                if file.endswith(".py"):
                    name = file[:-3]
                    try:
                        self.bot.reload_extension(f"{i}.{name}")
                    except:
                        return await ctx.send(f"Failed to reloaded extension **{name}.py**")
        await ctx.send("Successfully reloaded all extensions")
narrow geyser
#

did you run that?

craggy anchor
#

no, I don't think it changes anything if I run it or not

#

I'm using the test thingy for the webhook

#

doesn't show up anything

sullen nymph
#

If you reload the extension, does it show the error

craggy anchor
#

nope

#

no errors shown

fallen sinew
#

hi

rocky bough
craggy anchor
#

yeah, this error only occurs once I close it

#

close bot

#

after I leave it on for like 10+ mins or smth, idk, but sometimes it doesn't show up if I start/close bot right away

#

when I close quickly

sullen nymph
#

Are you doing anything in teardown or really anything after your bot closes

craggy anchor
#

nope

#

nothing

#

I just force close it tbh

#

ctrl + c

#

in

#

the VPS

green mantle
#

whats your code

#

where you init client and bot class

craggy anchor
#

bot = commands.AutoShardedBot(command_prefix = get_prefix, case_insensitive=True)

green mantle
#

full code

craggy anchor
#

wdym by that? that's pretty much it I think..

green mantle
#

Your main file

craggy anchor
#
import os
import discord
from discord.ext import commands
from discord.ext.commands import AutoShardedBot
import asyncpg
import asyncio
from pathlib import Path
from collections import OrderedDict
import logging
from os.path import dirname, abspath
from utils import util

logging.basicConfig(level=logging.ERROR)

directory = Path(abspath(__file__)).parent
os.chdir(directory) #changes directory to be of file parent cwd
print(Path(abspath(__file__)))

#sends prefix to bot
async def get_prefix(bot, message):
    try:
        return bot.guildlist[message.guild.id]['prefix']
    except KeyError:
        await bot.pg_con.execute("INSERT INTO guild (guild_id, prefix) VALUES ($1, '.') ON CONFLICT (guild_id) DO NOTHING", message.guild.id)
        bot.guildlist[message.guild.id] = {}
        bot.guildlist[message.guild.id]['prefix'] = "."
        bot.guildlist[message.guild.id]['redirect'] = None
        return bot.guildlist[message.guild.id]['prefix']
    else:
        return (".")


bot = AutoShardedBot(command_prefix = get_prefix, case_insensitive=True)
token = open("token.txt", "r", encoding = 'utf-8-sig').read()
db_pw = open("db_pw.txt", "r", encoding = 'utf-8-sig').read()
bot.pg_con = asyncpg.create_pool(database="db", user="postgres", password=db_pw)
...
@bot.event
async def on_ready():
    print("Logged in as")
    print(bot.user.name)
    print("------------")
    await bot.change_presence(activity=discord.Game(type=1, name="Bot"),status=discord.Status.online)

#Creates database connection
async def create_db_pool(bot):
    bot.pg_con = await asyncpg.create_pool(host="..", database="db", user="postgres", password=db_pw)
...
#Loading Cogs on Boot
path = ["cogs", "stagecogs"]
for i in path:
    for file in os.listdir(i):
        if file.endswith(".py"):
            name = file[:-3]
            bot.load_extension(f"{i}.{name}")
bot.loop.run_until_complete(create_db_pool(bot))
bot.loop.async_caches
bot.run(token)
#

some things in between but all of them are just caching stuff when bot loads

green mantle
#

where r u importing the dbl module

craggy anchor
#

in a cog

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

import asyncio
import logging


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

    def __init__(self, bot):
        self.bot = bot
        self.token = 'token_here'
        self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='DBL_PW', webhook_port=1337)
        
    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print("voted")
        logger.info('Received an upvote')
        print(data['user'])
        user = self.bot.get_user(data['user'])
        try:
            await user.send("Thanks for voting!")
        except:
            pass

    @commands.Cog.listener()
    async def on_dbl_test(self, data):
        print("voted")
        logger.info('Received an upvote')
        print(data['user'])
        user = self.bot.get_user(data['user'])
        try:
            await user.send("Thanks for voting!")
        except:
            pass
    
def setup(bot):
    global logger
    logger = logging.getLogger('bot')
    bot.add_cog(TopGG(bot))
``` This is the only place where I import dbl
green mantle
#

have you tried changing the port

craggy anchor
#

yeah

#

I have

#

changed it from 5000 to 8080 to 1337

#

hosting it on VPS if that matters

#

(DigitalOcean)

little dew
#

how do i check if someone voted for my bot in top.gg ? (discord.js)

#

oh nevermind

restive otter
#

@silent orbit ye lol I was seeing what happened

silent orbit
#

alright

restive otter
#

but fr

#

can you help? it doesn't even console.log

willow spindle
little dew
#

i found out how to do it but it doesn't work

clever drift
#

I need help

#

But the data received goes to the console.log

#

But I want Json to go.

#

<@&405483030275424257>

true talon
restive otter
true talon
#

I need help

dbl.hasVoted('user ID' ) ALWAYS return false, even if the user HAS voted
Same thing with dbl.getVotes()...

How can I solve that?

#

My code is the same as the api templates

#

I've take a look at dbl.getVotes() output, and that's weird, it shows a list of ppl who has never voted for my bot

restive otter
#

@true talon If you input any type of id make sure its correct format, and if you’re using in a command (i.e. d.votes <user mention|user id> ) make sure you grab it correctly

#

And make sure you are using the correct bot id cause I believe you need that to, to search a bots votes

craggy anchor
#

hey can someone stay here and stick with me so I can figure out what's wrong with my code πŸ˜” I've probably asked the same question 5 times now here with people just disappearing and I have to ask the same thing all over again

restive otter
#

@craggy anchor #development and when I am home so not too long

craggy anchor
#

it's related to the API - I can't seem to figure out why my webhook isn't responding

restive otter
#

Me too

craggy anchor
#

ah.. alright πŸ˜” I'll wait for someone else then, thank you for offering though

restive otter
#

No prob

#

@arctic arch Can you help?

narrow geyser
#

Don't ping tonkku

livid hound
#

bruh

true talon
#

@true talon If you input any type of id make sure its correct format, and if you’re using in a command (i.e. d.votes <user mention|user id> ) make sure you grab it correctly
@restive otter I'm not stupid, I know how to grab id

restive otter
#

That's not what I was getting at, but okay

humble bison
#

@true talon the most accurate way is w/ webhooks

#

i tend not to use the api methods as they take a while to update

fast pond
#

my Bot was just approved, what does the webhook URL field make? Do I need it?

vapid cape
#

the webhook url is where vote events should be sent

fast pond
#

hmm ok, so what can I fill in it?

vapid cape
#

if you want to do something everytime someone votes for your bot, make a webserver or use a dbl library to make one, and put your machine's ip address in the url

#

or project url if using glitch/heroku

fast pond
#

And if I just want to send the user a message and reward him?

humble bison
#

literally what tim just said, make a webserver

fast pond
#

ok thanks

craggy anchor
#

hey can someone stay here and stick with me so I can figure out what's wrong with my code πŸ˜” I've probably asked the same question 5 times now here with people just disappearing and I have to ask the same thing all over again. It's with the webhook, I can't seem to find out what's wrong with my code; it doesn't seem to respond. If someone could just stick with me for 10 minutes while I post all relevant code, thank you so much.

sullen nymph
#

Try to print everywhere and see which part is being called twice

#

Also put one in the topgg cog's init

craggy anchor
#

it's not really calling twice I don't think, it just doesn't respond, but I'll print on cogs init and see if the cog is being called at least

#

oh nevermind it definitely is actually

craggy anchor
#

guess not then πŸ˜”

#

if anyones willing to pls ping me, just need 10-15 minutes and then im doneπŸ˜”

true talon
#

@Lumap the most accurate way is w/ webhooks
@humble bison I'm using webhooks

humble bison
#

well getVotes isn't part of the webhooks

#

it uses the normal api

craggy anchor
#
future: <Task finished coro=<DBLClient.webhook() done, defined at C:\Users\legoe\AppData\Local\Programs\Python\Python37\lib\site-packages\dbl\client.py:417> exception=OSError(10048, "error while attempting to bind on address ('0.0.0.0', 1337): only one usage of each socket address (protocol/network address/port) is normally permitted")>
Traceback (most recent call last):
  File "C:\Users\legoe\AppData\Local\Programs\Python\Python37\lib\site-packages\dbl\client.py", line 436, in webhook
    await self._webserver.start()
  File "C:\Users\legoe\AppData\Local\Programs\Python\Python37\lib\site-packages\aiohttp\web_runner.py", line 104, in start
    reuse_port=self._reuse_port)
  File "C:\Users\legoe\AppData\Local\Programs\Python\Python37\lib\asyncio\base_events.py", line 1361, in create_server
    % (sa, err.strerror.lower())) from None
OSError: [Errno 10048] error while attempting to bind on address ('0.0.0.0', 1337): only one usage of each socket address (protocol/network address/port) is normally permitted
#

this is the error I get when someone votes I think

humble bison
#

something else is running on that port/exact ip

#

so the webhook isn't ever able to run

gray root
true talon
humble bison
#

not a thing

#

you need to store users that voted in your db with the webhook

true talon
#

fuc

green mantle
#

its not that bad to sort out

#

just have a db where all votes are stored with a time stamp and just use a cron system

restive otter
#

Anyone is here

restive otter
#

What is a snowflake?

#

How do I use it to get a user using client.users.cache.get()?

green mantle
restive otter
#

wait so snowflake is outside on top.gg @green mantle ?

green mantle
#

yes

restive otter
#

lol i thought its a top.gg thing because i found it on the api section

green mantle
#

its just normal discord.js

candid root
sullen nymph
#

Post your server count

candid root
#

i really have trouble understanding

sullen nymph
#

Are you using dblapi.js?

candid root
#

Oops! Error: 401 Unauthorized

#

.d

candid root
#

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

webhookAuth: 'password' = webhookAuth where is?

vapid cape
#

webhookAuth = top.gg Authorization

candid root
#

done it

polar mirage
#

Seems like some votes aren't firing the webhooks?

empty yarrow
#

Hello, how can I make the weebhook work with shards?

vapid cape
#

if you're using the shard manager, put the webhook in the manager

empty yarrow
#

Okay ty ! But where i put the vote weebhook ? On main file ? @vapid cape

#

I just put the webhook vote in main file but i have a error : cannot read property "on" of undefined

vapid cape
#

show your code

empty yarrow
#

which part ?

#

I dont understand, the webhook connects well in shards.js but when I want to put the webhook to vote on my main file it blocks

vapid cape
#

wdym it blocks?

empty yarrow
#

It send a " cannot read property on of undefined"

vapid cape
#

show your webhook code

empty yarrow
#

Its resolved ty !

limpid oriole
#

Whats the optimal choice for java api?

prime shard
#

hello there, I have a problem, I post my bot guild count, the status is is 200 ok but it doesn't update on the site

rocky bough
#

could be because of caching

opal parcel
#

Hi dude I would love for help if you can I would love how you did it in the bot list

restive otter
#

did what?

#

that's the 2nd place you've said that @opal parcel wut are you talking abt

rocky bough
vapid cape
#

what language are you using?

magic oriole
#

im close to finishing my pinbot, a bot that reposts messages when theres a certain emote number reached, but I ran into a problem where it reposts a normal message but if its an image file it just leaves it blank

#

this is the code that reposts it

#

help?

willow spindle
rocky bough
pure snow
#

los!help

rocky bough
restive otter
#
dbl.webhook.on("vote", async vote => {
    manager.broadcastEval(`this.handleVote(${vote.user})`);
});
``` Can someone tell me why this doesn’t work?
#

discord.js v12

vapid cape
#

is handleVote attached to the client?

#

can you access it via client.handleVote?

restive otter
#

sorry for replying late

pale fulcrum
#

then you would probably change this to client, depending on the way you do commands, unless im mistaken

ionic field
#

is there a dbl api for bigger bots?

green mantle
#

its the same libs

ionic field
#

why would it be unreliable then?

green mantle
#

Depends on how you have it set up πŸ€·β€β™‚οΈ

#

if you're using fetch votes when you're getting over 1000 votes then you need to use webhooks

ionic field
#

it barely even works on the .on( vote method

green mantle
#

Might be dbl latency

ionic field
#

i waited 5 minutes before giving up

green mantle
#

you could always build your own webhook server and use that

craggy anchor
#

asking this again because it still hasn't been answered πŸ˜” :
hey can someone stay here and stick with me so I can figure out what's wrong with my code in regards to the webhook πŸ˜” I've probably asked the same question 8 times now here with people just disappearing and I have to ask the same thing all over again. It's with the webhook, I can't seem to find out what's wrong with my code; it doesn't seem to respond. If someone could just stick with me for 10 minutes while I post all relevant code, ping me, tyvm

green mantle
#

what is ur code atm

craggy anchor
#

@green mantle

import dbl
import discord
from discord.ext import commands, tasks

import asyncio
import logging


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

    def __init__(self, bot):
        self.bot = bot
        self.token = 'token'
        self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='pw', webhook_port=8080, autopost=True)
        
    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print("voted")
        logger.info('Received an upvote')
        print(data['user'])
        user = self.bot.get_user(data['user'])
        try:
            await user.send("Thanks for voting!")
        except:
            pass

    @commands.Cog.listener()
    async def on_dbl_test(self, data):
        print("voted")
        logger.info('Received an upvote')
        print(data['user'])
        user = self.bot.get_user(data['user'])
        try:
            await user.send("Thanks for voting!")
        except:
            pass
    
def setup(bot):
    global logger
    logger = logging.getLogger('bot')
    bot.add_cog(TopGG(bot))
#

From what I get at, the autopost seems to work

#

but that's not webhook related

#

but it's being initialized and recognized I guess

#

no errors are usually shown on the bottom

green mantle
#

can i see what you have on the site?

craggy anchor
#

sec

green mantle
craggy anchor
#

oh do I need to add http:// in the beginning?

green mantle
#

yes

craggy anchor
#

ahh okay hopefully that was the issue

#

lemme check

green mantle
#

🀞

craggy anchor
#

still doesn't seem to print anything when I vote.. hmm :/

#

on the test vote thing

#

lemme try a diff port

green mantle
#

is your port open on that port?

craggy anchor
#

is there a way I can tell?

green mantle
#

if your webhook server is running and the port is open it should say its open and be green

craggy anchor
#

I see, give me a second

#

was closed, and then opened when I started it

#

doesn't seem to work still, nothings printing

green mantle
#

just

#

should affect anything

#

but if you change the decos

craggy anchor
#

oh nevermind, I think its always open

green mantle
#

to @self.bot.event instead

#

that'll override anything if its going somwhere else

#

altho it shouldn't change anything

craggy anchor
#

replace listener to that?

#

it says self not defined

#

not when I init it, not when I vote, just sometimes appears when I close the script

#

it says address already in use but I've been using other addresses and

green mantle
#

oh wait yh

craggy anchor
#

same thing happens, I don't think it's a coincidence

green mantle
#

ngl i just moved my events out of the class

#

and moved to my main file

#

and just used @client.event (Im client not bot)

#

which just overrides any existing vote listener should you randomly have it there

craggy anchor
#

hm alright I'll try that

#

thanks for the help!

#

ohh actually I might know - is it because I'm switching from my comp to VPS for running it?

#

e.g. I sometimes run it on PC, sometimes on VPS

green mantle
#

depends

#

if your VPS' port isnt open then it wont work

craggy anchor
#
ERROR:asyncio:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x0000024EE65E52B0>
ERROR:asyncio:Task exception was never retrieved
future: <Task finished coro=<DBLClient.webhook() done, defined at C:\Users\legoe\AppData\Local\Programs\Python\Python37\lib\site-packages\dbl\client.py:417> exception=OSError(10048, "error while attempting to bind on address ('0.0.0.0', 1337): only one usage of each socket address (protocol/network address/port) is normally permitted")>
#

always gives me this error too I think

#

well, always randomly

green mantle
#

that vps?

craggy anchor
#

mm it's on PC but I think I've seen it on VPS too

green mantle
#

if thats the case then there is somthing else running on that port

craggy anchor
#

hmm okay I'll try things out tyvm

#

says its listening to python so im assuming thats my script ig

#

do I have to close the session or smth every time I close the script?

#

tried moving it to main file and didnt seem to work either :(

steady laurel
true talon
#

yes

#

assuming this ^ is index.js

rocky bough
#

yes because he defined client

steady laurel
#

i have a folder with al my modules this is in the index.js require("./modules/topgg.js")(bot, con) and the code is in the folder and then in the file

true talon
#

erm

#

you should put the code in your index.js

steady laurel
#

how long it normaly take to work on the site?

green mantle
#

have u set the lib up?

steady laurel
#

lib?

#

i have te code in the bot

vapid cape
#

that code is in topgg.js?

#

if so, its wrong

steady laurel
#

why

vapid cape
#

you are creating a new discord client

#

this new client is not connected, nor logged in, it has no information about anything

#

you need to use the client that your bot uses

#

and give it to dbl

steady laurel
#

ow i have bot

#

not client so i have to change client to bot

vapid cape
#

yes

#

thats why its recommended to just put the whole dbl thing in your main file

steady laurel
#

But what i have to put all in to get the server count on the site

vapid cape
#

you just need dblapi.js and new DBL(token, client/bot)

#

as long as the client you put in the DBL options is the correct client, it should work automatically

steady laurel
#

ow it works

#

noice but if somone invite the bot it update on it own or?

vapid cape
#

it autoupdates every 30 minutes

steady laurel
#

okey

#

thnx for the help

upper iris
#

Who knows where should learn js for api in discord or maybe python ?

green mantle
#

wut

upper iris
#

wut

balmy hamlet
#

fucking learn the lang before attempting such things

#

smh

tacit trout
#
const DBL = require("dblapi.js");
const dbl = new DBL(config.dbl_api, { webhookPort: 5000, webhookAuth: config.dbl_auth }, client)

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

When i use this, nothing happens when called...

restive otter
#

How i can conect a page with a webhook? Discord.js 11v

stiff lichen
#

Hello, how can I set up the dbl webhook to get vote and guild information?

restive otter
#

How i can conect a page with a webhook? Discord.js 11v
help?

manic basin
#

Hi guys I have a question. When I make a Streaming Status on my Bot on PC then theres Playing but on Mobile theres Streaming.

Can someone help me?

willow spindle
#

This is not related with top.gg api

arctic arch
cunning blade
#

I have a question can i have the url for the API Endpoint to send Guilds from my bot?

vapid cape
stiff lichen
#

hello

#

how can i set up the webhook?

#

i want to be able to log the votes.

vapid cape
#

what language?

stiff lichen
#

js

#

with djs library

vapid cape
#

are you using dblapi.js?

stiff lichen
#

no

#

i will need to install this?

vapid cape
#

you need a webserver to receive vote events, you can use something like express.js or similar, or you can use dblapi.js which includes a built in webserver

stiff lichen
#

alright

vapid cape
#

dblapi.js is top.gg's official javascript library

#

check the webhook example

stiff lichen
#

thanks

vapid cape
#

then you need to go into your bot's edit page and fill up the webhook URL and Authorization

#

URL should begin with either your machine/vps's ip address, or your glitch/heroku project url, or whatever public address your webserver will be running on

stiff lichen
#

i got the server count posted

stiff lichen
#

@vapid cape sorry, ive done what you said but i cant figure how to connect the votes

restive otter
#

I Know This A Dumb But How Do I Connect My Top.gg Api With My DiscordBot So When He Vote He Get Money Or Credits From Bot Economy

rocky bough
#

Read Docs

icy bay
#

is there somekinda error on Top.gg API? I am getting Error: 429 Too many requests :I

green mantle
#

you're being rate limited

icy bay
#

oh for some reason I placed postStats in client.on("message") ohgosh... that explains xd

true talon
#

Lol

mystic mural
#

is using the webhooks more effective performance wise than compared to direct API calls?

vapid cape
#

according to what people say, yes, by a large margin

thorn gate
#

is there a way to check if some1 voted in the last 12 hours?

#

and not if he voted

#

like in all times

sullen nymph
#

A specific endpoint to see if a user voted actually does that

#

Though it won't mention when exactly they voted

thorn gate
#

yes i know theres an option to check for votes but like i wanna gain votes quick when my bot will get approved so i was just wondering if its possible to check if they voted in the last 12 hors cuz you can vote once in every 12 hours

sullen nymph
#

/bot/<id>/votes is the needed endpoint for you
For dblapi.js, see getBot

craggy anchor
#

@green mantle sorry to bother, but when you moved everything outside of a cog into ur main file, you would put the functions as a listener event, and then run self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='DBL', webhook_port=5000, autopost=True) into an async function which u call on after with run.complete right?

restive otter
#

May I know who has the ID 312559122144821250 that is returned from webhook tests?

sullen nymph
#

Quite the wrong channel to ask ig

restive otter
#

?

candid root
#

dbl voted resend channel message example ?

craggy anchor
#

hey is this how u would do it if you were to drag the events out of the

#

cog and into the main file

#

@bot.event
async def on_dbl_vote(data):
    print("voted")
    logger = logging.getLogger('bot')
    logger.info('Received an upvote')
    print(data['user'])
    user = bot.get_user(data['user'])
    try:
        await user.send("Thanks for voting!")
    except:
        pass

@bot.event
async def on_dbl_test(data):
    logger = logging.getLogger('bot')
    print("voted")
    logger.info('Received an upvote')
    print(data['user'])
    user = bot.get_user(data['user'])
    try:
        await user.send("Thanks for voting!")
    except:
        pass
sullen nymph
#

No need to create another logger

craggy anchor
#

hm okay

#

everything else looks fine? I still don't understand why my code doesn't respond at all pensivesob

sullen nymph
#

Create an instance of DBLClient right after you create an instance of commands.Bot

craggy anchor
#

okay

#

do I have to call on it using run.till.complete or

sullen nymph
#

Nah, everything will run by itself

craggy anchor
#

okay, lemme try

#

still doesn't show up anything; I'm trying to use the print function and the testing thing on top.gg website and it doesn't print anything when i click on test

#

I'm using my PC to run the program that has the webhook using an IP on a remote VPS; not sure if that would affect anything but

craggy anchor
#

This always appears - is there a way to override whatever's in use?

sullen nymph
#

Restart the machine and try to run it again ig

craggy anchor
#

hm alright

#

oh u mean restart the vps?

#

hmm ok

#

BRUH

#

that was my problem

#

all along

#

all I needed to do was restart it

#

and it was causing me a headache

#

tyvm

sullen nymph
craggy anchor
#

also, is it possible to pass bot through the voting?

#
async def on_dbl_test(data):
    logger = logging.getLogger('bot')
    print("voted")
    logger.info('Received an upvote')
    print(data['user'])
    user = bot.get_user(data['user'])
    try:
        await user.send("Thanks for voting!")
    except:
        pass
``` e.g., I want to add bot here cuz I need bot to update my db
#

so I can reward them

sullen nymph
#

But bot is accessible there already

craggy anchor
#

oh is it?

#

LMAO

#

NVM

#

IM DUMB

sullen nymph
#

:p

craggy anchor
#

SORRY

#

I WAS LITERALLY USING IT ALREADY

sullen nymph
#

It's alright

craggy anchor
#

my brain

#

4 am

#

I still get this warning though; it might be why it's causing the error in the first place

sullen nymph
#

Ehh

#

You're force closing aiohttp sessions, that's not exactly an error

#

I suggest you keep d.py updated

molten locust
#

has the dblapi.js been updated to support discord.js v 12 yet?

#

i see there is an available update for it, wondering if its for that πŸ™‚

sullen nymph
#

Yeah

molten locust
#

❀️

#

guess im updating to v12 now then πŸ˜„

uneven brook
#

yeah it's really a nice version ^^

gritty panther
#

Aha

restive otter
#

hello, how can i'get votes of my bot

#
const DBL = require('dblapi.js');
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});
#

i'm using this but idk where add the webhook token

willow spindle
#

webhook token?

restive otter
#

maybe

#

anyone can help me

#

?

#

@willow spindle you just change yourDBLTokenHere to your token on line 2

#
dbl.webhook.on("vote", async vote => {
  console.log(vote.user);
});
``` Why does vote.user returns the ID 312559122144821250 no matter who voted the bot?
spiral steeple
#

only on tests

restive otter
#

its the same when i voted the bot myself

spiral steeple
#

that's your id btw 312559122144821248 but 2 off

#

tests are your id

#

your vote is your id

restive otter
#

why does it minus 2 the ID?

spiral steeple
#

you probably converted it to an int somewhere

#

Which is why in js the ids are strings

restive otter
#

but i didnt?

#

also - also effects strings

spiral steeple
#

That wouldnt be the reason

#

it would round an int because it's too big of a number for js

restive otter
#

but its not an Int

#

typeof vote.user returns String

willow spindle
#

@restive otter wrong ping bro..

restive otter
#

sorry

spiral steeple
#

I don't know then. It should return the correct id. I've never seen that problem before

restive otter
#

ok thx anyways

restive otter
#

can someone help me with dblapi?

#

im use discord.js

livid hound
#

i might be able to help a little bit

#

what do you need

restive otter
#

i use module export with my bot

#

and when i do this

#

hmm

#

um

#

when i run the command (prefix)dbl

#

it dont do nothing

#

cause you aren't runnin it by typing dbl

#
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('My token here xdd', client);

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

dbl.on('error', e => {
 console.log(`Oops! ${e}`);
})
module.exports.help = {
    name: 'dbl',
    aliases: []
};```
#

i put my token

#

im stupid

livid hound
#

okay so

restive otter
#

and how i do it?

livid hound
#

do

restive otter
#
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('My token here xdd', client);

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

dbl.on('error', e => {
 console.log(`Oops! ${e}`);
})
livid hound
#
    config: {
      name: "blbuuhb"```
#

something like that^

restive otter
#

this should be in index

livid hound
#

Example:

#
    config: {
        name: "website",
        description: "DogBots Website.",
        usage: "db!website",
        category: "miscellaneous",
        accessableby: "Members",
        aliases: ["dogbotwebsite", "thewebsite"]
    },```
restive otter
#

hm

livid hound
#

I don't believe that has to do with module.exports = {
config: {
name: "website",
description: "DogBots Website.",
usage: "db!website",
category: "miscellaneous",
accessableby: "Members",
aliases: ["dogbotwebsite", "thewebsite"]
},.

#

I thought you were fully talking about the api mainly, however for this go back to #development

restive otter
#

i use this

#

module.exports= {
config: {
name: "addrole",
description: "Adds a role to a member of the guild!",
usage: "!addrole",
category: "moderation",
accessableby: "Moderators",
aliases: ["ar", "roleadd"]
},

livid hound
#

Is it in the category named moderation?

#

Like this:

restive otter
#

what i do?

restive otter
#

??

plush ore
#

Is this even related to the api anymore

grim solstice
#

the command info is in module.exports.config, not in module.exports.help which is undefined

restive otter
#

-botinfo 672883668594720773

abstract mothBOT
#
Bot info
ID

672883668594720773

Username

BGBOT || V2

Discriminator

5897

Short Description

Thats an 24/7 bot very custom, it was the perfect bot!

Library

discord.js

Prefix

.z

Total Upvotes

55

Monthly Upvotes

54

Server Count

No server count

Owner(s)

@uneven quest

restive otter
#

it dont say the server count

true talon
restive otter
#

dont work

hexed glade
restive otter
#

ok

#

but the api dont work

#

idk why

#

    message: (bot, utils, config, discord) => {
        const Discord = require("discord.js");
        const DBL = require("dblapi.js");
        const client = new Discord.Client();
        const dbl = new DBL('MyPrivateTokenxdd', client);
        dbl.on('posted', () => {
            console.log('Server count posted!');
    })
        dbl.on('error', e => {
            console.log(`Oops! ${e}`);
        })
        bot.on('message', async message => {

            if (message.author.bot) return;
            if (message.channel.type === "dm") return;

            let prefix = config.prefix;
            let args = message.content.slice(prefix.length).trim().split(' ');
            let cmd = args.shift().toLowerCase();
            let command;

            utils.load(discord, bot, config, message, args, message.guild);
            if (!message.content.startsWith(config.prefix)) return;
            if (bot.commands.has(cmd)) {
                command = bot.commands.get(cmd);
            } else if (bot.aliases.has(cmd)) {
                command = bot.commands.get(bot.aliases.get(cmd));
            }

            if (config.commandNotFound == true) {
                try {
                    command.run(bot, message, args);
                } catch (err) {
                    if (err) utils.timed_msg(utils.cmd_fail(`Command \`${cmd}\` is not found! To see commands type .z help`, `${prefix}play <MUSIC/URL>`), 2500);
                }
            } else {
                try {
                    command.run(bot, message, args);
                } catch (err) {
                    if (err) return undefined;
                }
            }
        });
    }

}```
#

i need help with that code

#

it dont post the server count

#

idk why

pale fulcrum
#

is that your message event file?

#

oh wait I see

restive otter
#

ok

pale fulcrum
#

why do you have this as a module.exports?

restive otter
#

because i use a handler

pale fulcrum
#

yeah this is wrong I think

restive otter
#

how i fix it?

pale fulcrum
#

maybe it would work if you changed client to bot

#

but you should put this in your index.js

restive otter
#

:/

pale fulcrum
#

const dbl = new DBL('MyPrivateTokenxdd', client); => const dbl = new DBL('MyPrivateTokenxdd', bot);

#

because it seems to be like you use a message handler and just copy pasted it there

restive otter
#

thanks

pale fulcrum
#

you should move it to a different file though

storm sleet
#

@craggy sentinel
My bot is in 25servers, but on Top.gg says that it's in 0 servers πŸ€”

restive otter
#

Read the documentation on how to update your server stats

thorn gate
#

why would u ping a mod for that

storm sleet
#

Documentation?

thorn gate
storm sleet
#

owh thx

restive otter
#

@storm sleet memethiccboi

restive otter
#

How i use a webhooks to do Upvote Logs?

pale fulcrum
#

first, where do you host your bot?

stone sierra
#

@restive otter how do you do that 5 users in 12 channels of 1 guild?

restive otter
#

?

stone sierra
restive otter
green mantle
#

thats just logging stats

stone sierra
#

Yes but how?

#

I mean the users and channels

vapid cape
green mantle
#

^^

restive otter
#

how i can do a log of users when he do a upvote?

vapid cape
#

@restive otter are you using dblapi.js?

pale fulcrum
#

he is yes

restive otter
#

yep

vapid cape
#

did you setup the webhook options?

restive otter
#

idk how to use webhooks

vapid cape
#

did you look at the webhook example in dblapi.js?

restive otter
#

yep

vapid cape
#

so did you set it up like that?

restive otter
#

yep

vapid cape
#

where is your bot hosted?

restive otter
vapid cape
#

is it a full vps?

restive otter
#

yep

#

24/7

vapid cape
#

what did you put in the URL and Authorization options in your top.gg bot's edit page?

restive otter
green mantle
#

you need to fill that in

vapid cape
#

URL should be YOUR.VPS.IP.ADDRESS:WEBHOOKPORT/dblwebhook

#

Authorization should be the same thing you set up in webhookAuth:

restive otter
#

how i get all of this to do it?

green mantle
#

you got the API set up ye?

restive otter
#

yep

pale fulcrum
#

his api setup is strange

vapid cape
#

you need your vps's external/public IP address, which you should be able to get from your provider's control/admin panel

restive otter
#

ok

restive otter
vapid cape
#

yes

#

you just need the ip address

pale fulcrum
#

so it would be IP:port/dblwebhook

restive otter
#

ok

vapid cape
#

also, is your code what MILLION sent?

pale fulcrum
#

it is

restive otter
#

yep

pale fulcrum
#

the only difference is the client was changed to bot

vapid cape
#

thats utterly wrong

pale fulcrum
#

^

vapid cape
#

delete the entire code

restive otter
#

ok

#

done

pale fulcrum
#

its not in the message event, just the handler

#

so he wouldnt get rate-limited

vapid cape
#

the code shown in the dbl example should be placed in your main file, the same file where you declare you bot

restive otter
#

where is client.login?

vapid cape
#

and the client should be your bot client

#

yes

restive otter
pale fulcrum
#

no

#

well

#

I wouldnt

vapid cape
#

i mean, you can

pale fulcrum
#

where do you call the bot.login(token)?

vapid cape
#

but its easier if you put it in the same file where you declare your bot

restive otter
#

in a config file

pale fulcrum
#

wait

restive otter
#

.json

pale fulcrum
#

you declare the bot there

#

do you have a file named index.js

vapid cape
#

if you have let bot = new Discord.Client() then your dbl should be new DBL(token,bot)

restive otter
#

yes i have it

pale fulcrum
#

what is in it?

restive otter
#

?????????

#

this is the index file

pale fulcrum
#

you would put it there

vapid cape
#

yes, you can put it right under your bot

restive otter
#

ok

#

finished

pale fulcrum
restive otter
grim solstice
#

ah

#

I tought I am on that channel

restive otter
#

what i need to do ?

vapid cape
restive otter
#

i change client to bot?

pale fulcrum
#

yes

#

and delete const Client = new Discord.Client

vapid cape
#

delete the duplicated client and discord

restive otter
#

finished

vapid cape
#

now add in the webhook options

pale fulcrum
#

port being the port on the webpage for the VPS

restive otter
vapid cape
#

no...

#

why do you keep duplicating code

#

you already have DBL

#

dont duplicate it

#

add the webhook options on your first DBL

restive otter
#

now?

#

ok

vapid cape
#

yes, now add the webhook options

restive otter
#

im adding the webnock options

vapid cape
#

DBL(token,{options},bot)

#

do the options like in the example

restive otter
pale fulcrum
#

now change 5000 to the port you were shown on the webpage for the vps

vapid cape
#

^

#

also, dont forget the bot

restive otter
#

i put it

pale fulcrum
#

and changing password is optional but suggested

restive otter
#

changed webhook Port

vapid cape
#

did you put the bot back in?

restive otter
#

nope

#

i dont restart the bot

vapid cape
#

i mean

#

DBL(token,{options},bot)

#

bot

restive otter
vapid cape
#

yes

restive otter
#

ah yes

vapid cape
#

alright

restive otter
#

in pass what i put?

vapid cape
#

whatever you want

restive otter
#

ok

#

finished

vapid cape
#

now when you start your bot, you should see "webhook running at xxxx"

restive otter
#

ok

vapid cape
#

ok

#

and in the URL

#

put YOUR.VPS.IP.ADDRESS:50004/dblwebhook

pale fulcrum
#

and password is what your password was set to

vapid cape
#

and in Authorization, you put your password

pale fulcrum
#

oh its Authorization

restive otter
#

finished

vapid cape
#

yes

restive otter
#

i put the pass

vapid cape
#

now save

#

then press test

restive otter
#

saved

vapid cape
#

you should see a vote in your bot's console

restive otter
pale fulcrum
#

if your bot is running it should console log

restive otter
pale fulcrum
#

you restarted correct?

restive otter
#

yep

pale fulcrum
#

yes

green mantle
#

yes

restive otter
#

ok