#topgg-api

1 messages ยท Page 44 of 1

quiet egret
#

@mystic wing awh man

restive otter
quiet egret
#

i am completely confused

#

im sorry but

#

what

#

Gets the guild count from the bot object

#

where the heck does the bot object come from???

#

at no point do i pass the bot object to the client

#

good god, im annoyed at this

arctic arch
#

you do when you init the client?

quiet egret
#

eh, i just went into the HTTP part and did the request myself

plain timber
#

Tonkku can u fix the docs link for the python lib

sullen nymph
#

@quiet egret Just in case, your Bot object is what you declare commands.Bot or discord.Client as

#

You usually declare that as bot or client

quiet egret
#

may i quote the zen of python

#

"Beautiful is better than ugly.
Explicit is better than implicit."

sullen nymph
#

"at no point do i pass the bot object to the client"
Do I see trust issues

signal hawk
#

i'm struggling a little bit trying to get a webhook created to process when a new vote comes in and send the user a dm saying thank you, is there anyone willing to help me out

#

(using discord.js)

plain timber
#

Have you looked at the dblapi.js docs?

signal hawk
#

yeah i have, and ive done what i think is correct (and i had someone else help me with it as well who is familiar) and i thought i had it set up right, but when i test it, it should output a vote received! in console but i get nothing

#

yeah i have, and ive done what i think is correct (and i had someone else help me with it as well who is familiar) and i thought i had it set up right, but when i test it, it should output a vote received! in console but i get nothing

#

let me try again and follow the docs

old river
#

so its recommended to use the webhook for votes right

#

no matter how many you plan on getting

signal hawk
#
const DBL_TOKEN = botconfig.dbltoken
const webhookAuth = botconfig.dblauth
const dbl = new DBL(botconfig.dbltoken, { webhookPort: 5000, webhookAuth: botconfig.dblauth });```

is this not right?
plain timber
#

Did you set the webhook settings in your bot edit page?

signal hawk
#

yeah, i have it as (publicip):5000/dblwebhook

#

thats what the person who helped me before told me to put, is that not correct?

#

i think i figured out why it isn't working, im pretty sure my vps isn't set to accept incoming requests from ports

#

i need to set that up first

restive otter
#

sudo ufw status

#

sudo ufw allow 5000

signal hawk
#

ufw command not found >.>

#

i'm really new to all of this so im sorry if i come off as dumb or i dont know something simple

signal hawk
#

I got it to tell me that the webhook is running with a path of /dblwebhook
but when i test it, it doesn't console.log(user with id ${vote.user} just voted)

#

and after like 30-40 seconds it gave me this error:

0|jobsbot  |     at item.request.gen.end (/home/ec2-user/environment/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:79:15)
0|jobsbot  |     at then (/home/ec2-user/environment/node_modules/discord.js/node_modules/snekfetch/src/index.js:215:21)
0|jobsbot  |     at <anonymous>
0|jobsbot  |     at process._tickCallback (internal/process/next_tick.js:182:7)
0|jobsbot  |   name: 'DiscordAPIError',
0|jobsbot  |   message: 'Missing Permissions',
0|jobsbot  |   path: '/api/v7/channels/265156286406983680/messages',
0|jobsbot  |   code: 50013,
0|jobsbot  |   method: 'POST' }```
chrome canyon
#

it says

#

Missing Permissions to POST in a channel

#

๐Ÿค”

#

also why does d.js still use snekfetch smh

signal hawk
#

im not trying to have it post in a channel which is why im really confused

#

let server = http.createServer(app).listen(5000)

  bot.dbl = new DBL(DBL_TOKEN, {webhookAuth: webhookAuth, webhookServer: server})

  bot.dbl.webhook.on("ready", hook => console.log(`Webhook running with path ${hook.path}`))

  bot.dbl.webhook.on("vote", async vote => {
    console.log('New Vote!', vote)

    if (vote.bot !== bot.user.id) return
    //if (vote.type !== "upvote") return

    let user = await bot.users.fetch(vote.user)

    //Do stuff here...
    //db.add(`briefcases_${user.id}`, 1)
    //user.send(`Thank you for voting! You have receieved a briefcase.`)
  }) ```
#

this is what i have

#

with this above:

const express = require("express")
const app = express()
const DBL = require("dblapi.js")
const DBL_TOKEN = botconfig.dbltoken
const webhookAuth = botconfig.dblauth```
plain timber
#

@chrome canyon d.js uses node-fetch now

chrome canyon
#

his version apparently doesn't.

#

also superagent > node-fetch

#

in speed as well as syntax

#

so why the heck

#

and also in promise support

signal hawk
#

i was under the impression i had the newest version of d.js

chrome canyon
#

@signal hawk then that error's unrelated to your webhook

#

@signal hawk did you install discord.js or discordjs/discord.js?

signal hawk
#

discord.js

#

if the error isn't related to my webhook, then what is causing it, and why isnt my webhook working >.<

#

oh i know whats causing the error message

#

more important is why isnt my webhook working lol

shut ibex
#

@signal hawk you're trying to preform an action but your not doesn't have permission

#

@chrome canyon master uses node fetch I believe

chrome canyon
#

nono the perm error is unrelated

median flicker
#

Hello

median flicker
#
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your discordbots.org token', client);```
#

i'm confused on how this works

median flicker
#

How do I make my command not available if they havn't voted

#

anyone?

plain timber
#

@median flicker you can use dbl.hasVoted(user ID) to check if they have voted

restive otter
#

use webhooks

plain timber
#

Yeah you could also use webhooks and store votes in a db

median flicker
#
  dbl.hasVoted(message.author.id).then(async voted => {
    if (voted) {
//your code
}else {
//Error code 
}
#

@plain timber ?

plain timber
#

Yeah

harsh glen
#

wut ๐Ÿ˜„

restive otter
#

yo when i do .getVotes() on the js lib i get an object that contains over 900 votes, however my bot only has <100 lifetime votes, does anyone know why that happens? do i need to pass an id to it?

arctic arch
#

what bot

restive otter
#

337959793106878464 bigshaq

sacred maple
#

Hello, I got the following error:

<Name redacted>:~ <Name redacted>$ pip install dbl
You are using pip version 6.1.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting dbl
  Could not find a version that satisfies the requirement dbl (from versions: )
  No matching distribution found for dbl
topaz wyvern
sacred maple
#
<Name redacted>:~ <Name redacted>$ pip install dblpy
You are using pip version 6.1.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting dblpy
  Using cached https://files.pythonhosted.org/packages/aa/2e/d136bd593a1fe545d6e82c9317169beef2729ecb2878352c58cd8f7b374f/dblpy-0.1.6.tar.gz
Collecting aiohttp>=2.3.9 (from dblpy)
  Using cached https://files.pythonhosted.org/packages/70/27/6098b4b60a3302a97f8ec97eb85d42f55a2fa904da4a369235a8e3b84352/aiohttp-3.4.4.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 20, in <module
    
    ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/sd/gjs1t8tx7hg3t1h6wmfr_9k00000gn/T/pip-build-xRnDcv/aiohttp
#

@topaz wyvern

#

???

soft talon
#

Hello I have a problem with webhooks. While I set webhookAuth (js library) on my password and clicking "Test" without fill password field, my webhook receiving message, but shouldn't.

arctic arch
#

@soft talon did you save before hitting test

soft talon
#

@arctic arch ok, my bad. ๐Ÿ˜„ I've testing without saving

soft talon
#

btw. it could be useful to set querystring while test :/

sacred maple
#

Can anyone help me?

#

I just keep getting the above errors...

sullen nymph
sacred maple
#

I USED GOOGLE!!!

sullen nymph
#

Can you do pip show aiohttp

little ice
#

i tried to update the stats of my bot

#

but doesn't seems to show up

sacred maple
#

@sullen nymph I'm getting these errors whilst downloading the API...

You are using pip version 6.1.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.```
sullen nymph
#

Either your cache trolling you or your status update is just dead Think

#

@sacred maple Nothing helpful. Did it show anything else

sacred maple
#

And I already tried upgrading:

pip install --upgrade pip
You are using pip version 6.1.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting pip
  Using cached https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 6.1.1
    Uninstalling pip-6.1.1:
      Exception:
      Traceback (most recent call last):
        File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 246, in main
          status = self.run(options, args)
        File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 352, in run
          root=options.root_path,
        File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 687, in install
          requirement.uninstall(auto_confirm=True)
        File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 730, in uninstall
          paths_to_remove.remove(auto_confirm)
        File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 126, in remove
          renames(path, new_path)
        File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 292, in renames
          shutil.move(old, new)
        File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 303, in move
          os.unlink(src)
      OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip-6.1.1.dist-info/DESCRIPTION.rst'
sullen nymph
#

Python/2.7

#

I get it

#

Try pip3 install dblpy instead

sacred maple
#

Yay! It works!

little ice
#

any idea why ? does it take time ?

sacred maple
#

I got another error:

dblpy 0.1.6 has requirement aiohttp>=2.3.9, but you'll have aiohttp 1.0.5 which is incompatible.
sullen nymph
#

pip3 show aiohttp

sacred maple
#

Flip$ pip3 show aiohttp
Name: aiohttp
Version: 1.0.5
Summary: http client/server for asyncio
Home-page: https://github.com/KeepSafe/aiohttp/
Author: Nikolay Kim
Author-email: fafhrd91@gmail.com
License: Apache 2
Location: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
Requires: chardet, multidict, async-timeout
Required-by: discord.py, dblpy
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

plain timber
#

So update it

sullen nymph
#

Yep, you should be good if you update aiohttp

sacred maple
#

How can I get the normal pip

#

Got it now...

#

Thanks @sullen nymph and @plain timber

sullen nymph
sacred maple
#

AAAAAAARGH!!!

========= RESTART: /Users/gebruiker/Documents/Python/Flipp3rrrBot.py =========
Traceback (most recent call last):
  File "/Users/gebruiker/Documents/Python/Flipp3rrrBot.py", line 1, in <module>
    import dbl
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/dbl/__init__.py", line 19, in <module>
    from .client import Client
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/dbl/client.py", line 33, in <module>
    from .http import HTTPClient
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/dbl/http.py", line 36, in <module>
    import aiohttp
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/aiohttp/__init__.py", line 10, in <module>
    from .protocol import *  # noqa
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/aiohttp/protocol.py", line 18, in <module>
    from .helpers import reify
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/aiohttp/helpers.py", line 25
    ensure_future = asyncio.async
                                ^
SyntaxError: invalid syntax
sullen nymph
#

Or wait

#

pip3 show discord.py please

sacred maple
#
pip3 show discord.py
Name: discord.py
Version: 0.16.12
Summary: A python wrapper for the Discord API
Home-page: https://github.com/Rapptz/discord.py
Author: Rapptz
Author-email: None
License: MIT
Location: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
Requires: aiohttp, websockets
Required-by: discord
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
sullen nymph
#

Oh

#

Yep, that's the freaking async branch

#

You might wanna use discord.py rewrite instead to get access to more features etc.

pip3 install -U git+https://github.com/Rapptz/discord.py@rewrite#egg=discord.py[voice]
sacred maple
#

@sullen nymph I got everything working, thanks!

calm zodiac
#

is the .getVotes() sorted by when a person voted?

#

test

#

@amber dune a bot responds when you type anything into a channel it cant talk in

amber dune
#

it was taken care of

calm zodiac
#

k

hushed salmon
#

who's have discord api invite pls ?

fleet tide
#

/discord-api

raw sparrow
#

i hope this is the right channel.
Trying to test a webhook from the dbl website.
However i do not receive the post request.
If i try it from another source i get the request.
(same url checked multiple times :D)

is there a step i am missing for the test on the dbl website?

Thank you in advance

plain timber
#

You need to press save then test

raw sparrow
#

i was wrong sry didnt work after save + test still nothing (i dont get a error on the site though)

plain timber
#

Does it say request sent?

raw sparrow
#

yep i get the alert box with request sent .. may take a few seconds

#

or am i forced to receive the request through the dblapi itself with the vote event from dbl.webhook --> meaning i can't receive it with a normal express app.post... event?

restive otter
#

Are you behind a firewall?

raw sparrow
#

not that i am aware of FeelsThinkingMan
all i do is creating a express server and listening for post requests for /dbl like this:

  app.post("/dbl", function (req, res) {
    console.log("post from dbl incoming")
    // other stuff...
  })

and if i send a post request from a local program on my computer i receive it on my VPS if i try to send one from the dbl website i dont get any.

arctic arch
#

have you saved

raw sparrow
#

yep

arctic arch
#

are you sure

raw sparrow
arctic arch
#

yea now you did

#

you're missing http:// as well

raw sparrow
#

oof thank you tonkku the protocol did the trick... didnt need it in the external program and copied the url from there thank you very much dareLove

restive otter
#

Exposed

signal hawk
#

is there a reason that my server count on the website would be different than the server count bot.guilds.size gives me from my bot? >.>

topaz wyvern
#

Are you sharding?

signal hawk
#

nope

#

the website says 57 but my bot gives me 82

topaz wyvern
#

wha-

#

give link

signal hawk
topaz wyvern
#

@signal hawk Can you show the code where you post the stats?

signal hawk
#

  bot.dbl = new DBL(dBL_TOKEN, {webhookAuth: webhookAuth, webhookServer: server})  

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

app is express

topaz wyvern
#

hmm

#

try letting dblapi.js post it for you

signal hawk
#

wha

#

isnt that what that is doing above

plain timber
#

no

#

just include your client as the last thing in the new DBL

signal hawk
#

like new DBL(dBL_TOKEN, {webhookAuth: webhookAuth, webhookServer: server}, bot) ?

plain timber
#

yes

signal hawk
#

will try, thank you!

restive otter
#

Its been since monday

#

they havent reviewed

#

lo

plain timber
#

@restive otter this channel is only for help with the DBL api

restive otter
#

oh

#

oops

signal hawk
#

That didn't work, the website still says 57 :/

#

i have it set to update every 30 minutes

plain timber
#

hm

#

are you sure youre using the right token?

#

what if u eval the poststats

signal hawk
#

i dont have an eval in my bot >.> yet

and yes im sure im using the right token because votes are coming through

signal hawk
#

i didnt change anything but now its updating correctly so thanks for your help xD

plain timber
#

lol yw

signal hawk
#

...it went back down to what it was before

#

it showed 94 (which is correct) and now went back to 57 xD

copper stag
#

i use a php script that sends it to a discord webhook in a channel that my bot reads, and then it handles that and sends a message in another channel that everyone sees

#

it's php because that's the only backend scripting namecheap has and I hate nodejs

frail lance
#

Is there a way to get a list of everyone that has voted for your bot (JS)

restive otter
#

@copper stag why do you hate Node.js?

plain timber
#

@frail lance you can only get the last 1000 voters in this month

#

Unless you saved all of them

gentle rain
#

hi

copper stag
#

@restive otter javascript is for the browser

#

Node runs in a sandbox too

restive otter
#

But...Node.js exists

copper stag
#

So?

restive otter
#

so?

#

You run can javascript on the server

copper stag
#

But why would you

#

Javascript was invented for the browser

#

Would you run SQL as a web server

plain timber
#

the internet wasnt invented to chat with people so dont chat with people on the internet

#

discord wasnt invented for bots so dont use bots on discord

restive otter
#

@copper stag Ok...what

#

SQL is a query language

#

Not even comparable in this scenario

#

JavaScript is a scripting language.

#

Node.js is so awesome because it takes that same JavaScript code, and utilizes V8 to compile this code into machine code,. With that being said, this helps web applications greatly, because it executes JavaScript very efficiently.

#

Why do you think that popular companies such as Microsoft PayPal and Netflix use Node.js?

loud gulch
#

not right channel mate

plain timber
#

it started with a convo about the dbl api

median flicker
#

I have a really important question about dblapi.js
I am having trouble finding out where to incude

    if (votes.find(vote => vote.id == "95579865788456960")) console.log("Tonkku has voted!!!")
});```
 in my if / else statement ( This is my music command I am talking about )
#

Ping me if you can help

hearty perch
#

what "if else" statement

#

what is dblapi.js
sorry, I just joined the server

distant ibex
#

discord bot list api, it's basically so you can know when someone upvotes your bot (at least that's what most people use it for)

hearty perch
#

Are you talking about the es6 syntax there?

#

the single line bracketless if?

#

ok

#

so you have a dbl api, with an async getter for seeing if you've been upvoted
what do you mean "where should I include this?"
if there's no event listener, you have no choice but to put it in a time interval

median flicker
#

well

#

all of my music commands are in the server.js

hearty perch
#

ok, they're in your file
what does that tell me

#

sorry im just trying to help

median flicker
#

Do I need to put that in every statement

hearty perch
#

Ok, so I assume you're parsing that in the on 'message' event listener

#

wait wh

median flicker
#

Im just confused on how this dblapi.js thing works

#

I want users to vote before using music

hearty perch
#

why would this be with your message parsing logic, if you dont mind me asking?

median flicker
#

honestly idk

hearty perch
#

oh
I thought you were talking about the upvotes on the DBL website

median flicker
#

yes!

hearty perch
#

are you?

median flicker
#

yes!

hearty perch
#

so this would have absolutely nothing to do with parsing commands from users

#

you want to log the upvotes you get from the dbl website

#

on your bot's page

median flicker
#

I want users to upvote the bot before using the music commands

hearty perch
#

aah

median flicker
#

Is that possible?

hearty perch
#

ofc

median flicker
#

yay

hearty perch
#

you could wrap all of your message parsing inside of that promise and just do a simple check for the parameter

#

i would modularize it though

median flicker
#

I probably won't get this right

#

but worth a shot

hearty perch
#
dbl.getVotes().then(votes => {
    if (votes.find(vote => vote.id == "95579865788456960")) console.log("Tonkku has voted!!!")
    else {
            ....
    }
});
median flicker
#

hmm..

hearty perch
#

yea?

median flicker
#

I will try

hearty perch
#

uhhh sorry clarification

#

reverse the upper condition

median flicker
#

woah wha?

hearty perch
#
dbl.getVotes().then(votes => {
    if ( !votes.find(vote => vote.id == "95579865788456960")) console.log("Tonkku has voted!!!")
    else {
            ....
    }
});
#

check if it's false (not found)

#

otherwise, continue on with whatever

median flicker
#

Everything looks fine

#

I just need to figure out how to put everything in that

hearty perch
#

are you using a wrapper like commando

#

if you're just using the discord.js API then just encapsulate your logic inside of it

median flicker
#

sure

#

I don't think I use commando

#

Would you like to see my code..?

#

I'm not very good at this

#

if you don't have time, I understand

hearty perch
#
client.on("message", function(message) {
    dbl.getVotes().then(votes => {
        if ( !votes.find(vote => vote.id == message.author.id)) message.reply("Sorry, upvote the bot first!")//not found
       else {
                //call your normal logic here
        }
})
median flicker
#

wait

#

basically just put everything from music inside?

hearty perch
#

you are using discord.js, right?

#

what??

median flicker
#

yes

#

discord.js

hearty perch
#

put everything from music

#

wdym

median flicker
#

in else statement

hearty perch
#

did you write this code?

median flicker
#

for the most part, no

hearty perch
#

in whatever you referenced

#

there should be event listeners for messages, reactions, etc.

#

you want to make users upvote the bot before they use commands

#

so yes
you encapsulate your message parsing logic inside of the db.getVotes().then() promise

median flicker
#

aaaanddd

#

error.

#

cannot use awai outside of an async function

#

oh

hearty perch
#

search up MDN promises and async if you want to get a grasp of basic NodeJS server arch

median flicker
#

Okay

#

I'm stuck

hearty perch
#

okay

distant ibex
median flicker
#

I can get this

hearty perch
distant ibex
median flicker
distant ibex
#

r/whoosh

median flicker
#

That's exactly what I was expecting to hear

#

something on the lines of "learn js"

#

so close

#

๐Ÿ˜ญ

restive otter
#

Hello.

median flicker
#

hi?

restive otter
#

How are you.

median flicker
#

good, how are you.?

restive otter
#

Im alright.

#

Basically ive been around for a little and i was wondering if you could help me out.

median flicker
#

๐Ÿ˜ญ

restive otter
#

Are you ok?

median flicker
#

I can't help

#

I suck at this

restive otter
#

Oh.

median flicker
#

I'm sorry

restive otter
#

Feels bad lol.

median flicker
#

Yeah idk im just looking for some help but I just get "learn js"

#

or some weird whatever

#

anyway..

#

ask away

restive otter
median flicker
#

What is it doing

restive otter
#

Ive tried learning multiple ways of making js and lua etc, but my mind works different and its hard for me to process.

#

Its basically a reacting/tally bot.

#

So basically you have a sertain amount of time like 5 mins, to goto a channel called "3 letters", You type the last three letters and then you get put in the sections, so basically if 2 people said " 200" they would get put under the Id of "200" and 3 others said " 313 " they would get put under the Id of "313".

plain timber
restive otter
#

Ok, thank you.

plain timber
#

this is for help with the dbl api, see the channel topic

median flicker
#

@hearty perch Is there away I can finish this? DizzyScared that maybe isn't "learn JS?"

#

๐Ÿ˜ญ

hearty perch
#

If you've been told on other occasions to first learn JS, maybe there is merit to the advice
Do you have experience with programming at all?

median flicker
#

Yes

#

I do

#

I have multiple bots

#

I just don't know how dblapi.js works ๐Ÿ˜ญ

hearty perch
#

what about it do you not understand??

#

if you've coded multiple bots you should know what a promise and a callback is
literally just wrap your logic inside of the callback

#

mfw

median flicker
#

Sorry to waist your time

hearty perch
#

no, im using free time
but you could save a lot of your own time by investing in learning a bit of basics first

#

and stuff like this will be a breeze

median flicker
#

You know what

#

I don't need people to upvote my bot

restive otter
#

ok

median flicker
#

this is stupid

restive otter
#

what is

hearty perch
#

ok you do you

#

good luck

median flicker
#

I mean

#

what else

restive otter
#

what else what

median flicker
#
client.on("message", function(message) {
    dbl.getVotes().then(votes => {
        if ( !votes.find(vote => vote.id == message.author.id)) message.reply("Sorry, upvote the bot first!")//not found
       else {
       };
#

I can't figure out my else statement

hearty perch
#

first of all

#

why is there a semicolon there

#

secondly
you forgot to enclose the callback

#

thirdly, you didn't enclose the outer method

topaz wyvern
#

wew

median flicker
#
dbl.getVotes().then(votes => {
    if (votes.find(vote => vote.id == "message.author.id")) console.log("Tonkku has voted!!!")
});
hearty perch
#

ok , so you fixed one part of it

#

now enclose the callback and outer method

median flicker
#
client.on("message", function(message) {
   dbl.getVotes().then(votes => {
    if ( !votes.find(vote => vote.id == "message.author.id")) message.reply("vote for bot")
});

#

there?

#


client.on("message", function(message) {
   dbl.getVotes().then(votes => {
    if ( !votes.find(vote => vote.id == message.author.id)) message.reply("vote for bot")
  
    else {

    }
});



#

there.

restive otter
#

just drop the quotation marks

median flicker
#

Alright, I get that

#

Since all of my music commands are together in server.js, it is making it hard for me to find out what goes where

#

its just the classical music bot commands

#

nothing special

hearty perch
#

perhaps if you wrote it you would have a clear sense of your own code

median flicker
#

I understand it

hearty perch
#

that's just me tho

median flicker
#

Am I trying to put all of it in 1 callback? or do I put multiple...

hearty perch
median flicker
#

Yes.

hearty perch
#

i'm not sure you understand what a callback is

median flicker
#

I do

#

If / Else

hearty perch
#

you jsut asked me if you should "put multiple callbacks"

#

no.

#

read the website

median flicker
#

if I don't then I get an error

hearty perch
#

a callback is a function, typically anonymous, passed into a method as a parameter

#

so that you know when an operation is finished. asynchronously

#

it has nothing to do with if/else

median flicker
#

alright

#

await error

hearty perch
#
function sayHello(myCallback) {
    setTimeout(function() {
        myCallback("hello!")
    }, 1000)
}
funcion run() {
    sayHello( function(str) {
        console.log(str)
    })
}
#

this is the easiest way i could think of to explain a callback

#

if you don't know how async works you shouldn't even be using await

median flicker
#

well

hearty perch
#

that's why callbacks are so powerful for servers
because nothing is instantaneous, and a lot of things you have to wait until you are ready to complete the operation

#

that's why db.getVotes takes a callback function as a parameter, because it is sending a request to the DBL website and waiting for a response

#

Ok I'm don here

#

good luck on your project fam

median flicker
hearty perch
#

I appreciate your enthusiasm, but you really need to understand the basics
You may have gotten by on luck randomly copy and pasting features from other people's code, but it won't do anything for you in the long run

#

I don't say this to discourage you, but because I hope you will try to write your own programs
It will feel great, trust me

ripe fjord
#

How to get dblapi ?

karmic hound
shadow flame
#

How do I display voters on the channel I want ?

#

similarly

sand hazel
#

webhook + send to channel

#

tada

shadow flame
#

I don't know how.

plain timber
#

You will need to code it

#

What library do you use?

shadow flame
#

discord.js

plain timber
#

Use the dblapi.js package

#

Look at "example of using webhooks to receive vote updates"

shadow flame
#

webhook error

#

@plain timber

plain timber
#

?

shadow flame
#

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

                    ^


ReferenceError: yourDBLTokenHere is not defined

at Object.<anonymous> (/app/bot.js:752:21)

    at Module._compile (internal/modules/cjs/loader.js:688:30)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)

    at Module.load (internal/modules/cjs/loader.js:598:32)

    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)

    at Function.Module._load (internal/modules/cjs/loader.js:529:3)

    at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)

    at startup (internal/bootstrap/node.js:285:19)

    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)

plain timber
#

...

#

Are you dumb

#

You need to change yourdbltokenhere to your DBL token

sand hazel
#

lmao

plain timber
#

You can't just copy paste an example exactly and expect it to work smh

sand hazel
#

is that not how it works blurryeyes

runic grove
#

Lmfaoooo

shadow flame
#

I'm not on the computer. I can't encode

#

that's why I asked you

#

๐Ÿ˜ค

sand hazel
#

encode blurryeyes

ocean patrol
#

would it be possible to have webhooks as sockets instead?

shadow flame
#

for translate

sand hazel
#

i mean

#

webhook is technically socket

little harbor
#

encode what, and why do you need a pc to do that? bingT the token is right there, in plain text, on the page. You don't need to encode anything

sand hazel
#

just without keep-alive

little harbor
#

unless js needs that but i don't think so?

#

and click on your bot

#

and copy the key

ocean patrol
#

webhooks are kind of tricky to do

#

last time i asked how to do it you need a very large library

sand hazel
#

what

ocean patrol
#

for java

sand hazel
#

java doesn't have in built http server?

ocean patrol
#

java has a http server

#

i suppose it could be done

sand hazel
#

that's all it need

ocean patrol
#

it's just kind of awkward

#

and there isn't even a libary for it

sand hazel
#

it's just simple method check + credential check

onyx sky
#

generate the image by the discord bot?

sand hazel
#

image manipulation in whatever lang

arctic arch
onyx sky
#

ok

restive otter
#

For some reason my server count stopped being send to DBL, Any changes on DBL's side?

stray sierra
#

I dont think so...

#

It works for me

#

make sure your code is in the proper event

#

@restive otter aka the event that runs your bot

#

the server count code must look like this

const DBL = require("dblapi.js");
const dbl = new DBL('YOUR DBL TOKEN HERE !', client);

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

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

//Error Event (To not trigger errors that will end your process, you must handle this event)
client.on('error', console.error);
sand hazel
#

is he even using js

restive otter
#

Ye

stray sierra
#

@restive otter dose it work now?

restive otter
#

Didn't check yet

stray sierra
#

K

plucky field
#

The following message was sent to everyone in my discord server before kick/banning them and deleting all my channels and information. I am very patiently trying to figure out two things. Is there any possible way to retrieve any of my data from the channels from discord? How can I prevent this from happening again? Can someon please direct me to the correct channel or server to discuss such matters. I was using a Python Pot and I used Redis (NoSQL) to store my discord key so the key was not visable in the code. The code was available on github. I need to find out what I did wrong with storing information in Redis. The message is quite large I will on ly post what I see as being important.

Helo! im wiktor#9004 and i just ddosed this bot and your server! :) Subscribe to my YouTube channel :D "then it has a youtube address" and come to my house "then it has a google maps address location"

sand hazel
#

wtf

#

you leaked your token or something

plucky field
#

OK

#

thank you

runic grove
#

@plucky field yup, definitely leaked token, the guy did this to another bot before

plucky field
#

@runic grove Oh really? Yea, I'm going through and double/triple checking everything. Already reset my token. Redoing my Roles. Not gonna bring my Bot up for awhile.

sand hazel
#

Discord will prob know more if you email them

plucky field
#

It had to be something I pushed to github because I just did a push last night after making a few changes. Don't know how but the only thing I can think is I pushed my Redis db file.

sand hazel
#

IP origin

plucky field
#

Ok

plucky field
#

I found the leak. I had a "test" version of my bot when I first started working on it and really didn't know too much about it. I ended up starting over at some point and I created another repository but didn't delete the first "test" version. I had my token secure on the new version but the original had the token right there in the damn code.

#

And I never reset the token in between. Live and learn I guess.

radiant forge
#

!coins

unkempt python
#

@plucky field I know the feeling also happened to me when I just started making bots

hearty perch
#

@plucky field same!

#

Exact same thing happened to me

#

Except the person who first got the leak invited me to a whitehat server and didnโ€™t give it away

#

Epic

plucky field
#

Well I feel a little better. Thanks. Plus we've got the Discord Server almost fully functional again and I've removed any posibilities that anyone would have access to my token by deleting all the old files and adding extra security on my Redis server which is where I keep my token. Bots back up and running. Yikes though. What a nightmare. I learned a lot though. So there is that!

barren merlin
#

I just got kicked from a big server by the big man himself

#

I was trying to get to be one of the mods

storm shuttle
#

Not even related to api

restive otter
#

Now for the id is it the bots id or person id?

#
dbl.hasVoted("95579865788456960").then(voted => {
    if (voted) console.log("Tonkku has voted!!!")
});```
#

alright im an idiot i didnt look well

sand hazel
#

user

stray sierra
#

How do I make it so that my bot will send a message in a certain channel that someone has upvoted or invited the bot?

plain timber
#

For upvoted, just use dbl's webhooks

#

You can't for invited since there's no way to know who added it

stray sierra
#

Well, MrAugu did the invite for his bot

plain timber
#

?

humble bison
#

you can send a message when a bot is invited

#

but its long winded

stray sierra
#

whats long winded?

sand hazel
#

long story

stray sierra
#

lol

plain timber
#

You'd probably need to mess with oauth on your site and stuff

humble bison
#

no

#

a simple glitch site would do

#

basically you use it as your invite, the user goes there, it detects the invite source via url param and redirects

plain timber
#

That's easily fakable though

#

It only guarantees that they clicked the link

sand hazel
#

i gotta look into oauth invite for v2

humble bison
#

i guess you can use it for basic analytics anyways

restive otter
#

@stray sierra You'll have to proxy this throught a server endpoint, is my thought

#

Then you can send a message to the channel

#

so you will need an http server to receive the webhook

stray sierra
#

Oh ok

crimson geode
#
 const data = new Date();
if (db.get(message.author.id + "adwe" + data.getDate()) > 0) return message.channel.send("Odebraล‚eล› juลผ nagrode na dziล›!");
#

SyntaxError: Illegal return statement

#

why?

vast zodiac
#

is it in a function?

uneven furnace
#

(node:4302) UnhandledPromiseRejectionWarning: Error: 401 Unauthorized why am i getting this?

vast zodiac
#

probably a bad token

sullen nymph
#

Either:
โ€ข Bad token used for authorization.
โ€ข No token used for authorization at all.

uneven furnace
#

.-. i have good token, it wasnt reading it xD

sullen nymph
fleet tide
#

@crimson geode em, you have db in file or module?

lilac arrow
#

When I create a new dbl object and I set up client and statsInterval using dblapi.js, does it instantly push server count?

plain timber
#

yes

lilac arrow
#

got it thank u!

restive otter
#

How do i get monthly votes since when i used points structure on the bot obj, it gives me the total votes

plain timber
#

@restive otter monthlyPoints

restive otter
#

bot.points.monthlyPoints or just bot.monthlyPoints

plain timber
#

bot.monthlyPoints

glad bolt
#

Question: is there a way to get the API to send a simple text line to a discord channel via webhook when someone donates? I read through docs and all I saw was the example using express. I don't personally use it and would love an alternate option.

plain timber
#

If you're using js, you can use dblapi.js

restive otter
plain timber
#

Is client.shard.count a thing

#

Can you eval it

restive otter
#
client.shard.fetchClientValues('guilds.size')
  .then(results => {
    var totalGuilds = results.reduce((prev, val) => prev + val, 0);

const snekfetch = require('snekfetch')

snekfetch.post(`https://discordbots.org/api/bots/405349279331254282/stats`)
  .set('Authorization', 'token')
  .send({
        server_count: totalGuilds,
        shard_count: client.shard.count
  })
  .then(() => console.log('Updated discordbots.org stats.'))
  })```
#

What am I doing wrong

#

@plain timber

plain timber
#

@restive otter totalGuilds is the amount on all shards?

restive otter
#

Ye

plain timber
#

๐Ÿค”

#

How would it get the amount for just 1 though

restive otter
#
client.shard.fetchClientValues('guilds.size')
.then(results => {
    var output = results.reduce(function(accumulator, currentValue){
      return accumulator + currentValue;
    });
}).catch(console.error);```
#

I don't know

dark summit
#

I think it is client.shards.size ๐Ÿค” @restive otter

#

Nvm

#

It is client.shard.count

#

Oh wait

finite fiber
#

the website seems kida broken

#

the server count always changes when i refresh my bots page

elfin solstice
#

thats the caching from different clusters

royal vigil
#

What i need to do for get the server count

#

of my bot

#

this

humble bison
#

post to the api

blazing totem
#

pls bal

topaz wyvern
restive otter
#

I have been having a lot of trouble with people not able to claim their daily claim after voting.. It's like dbl and my bot aren't communicating.. Is there any known issues at the moment? Or honestly i don't even know where to start with this.. It worked just fine before.. I'm on js if that makes a difference

mossy lichen
#

@royal vigil haha wanted to ask the same thing ๐Ÿ˜„

#

looks to me like it seems to be activated at a certain time/amount/whatever

uneven furnace
#

What is this

mossy lichen
#

how did you get this info

uneven furnace
#

I did dbl.getVotes XD probably wrong

mossy lichen
#

ah is this a command?

#

dbl.getVotes

uneven furnace
#

No ...

#

Its code

mossy lichen
#

ah, your bots code ?

uneven furnace
#

im trying to use the websites API to get the number of votes my bot has and instead it responded with that

topaz wyvern
#

getVotes is a function...

uneven furnace
#

I know ๐Ÿ˜‚ I had a stupid moment

#

I forgot the ()

#

now I'm getting object promise ๐Ÿค” hmm

sudden rampart
#

await it

topaz wyvern
#

what

vast wedge
#

what

weary ember
#

learn js

jagged warren
royal vigil
#

pls

jagged warren
plain timber
royal vigil
#

K

mossy lichen
#

ahhhh so we need to update it our selves! thanks etcroot

crisp river
#

What to do after generating API key?

sand hazel
#

Whatever thonkang

copper vapor
#

@crisp river just look in the doc for your language

crisp river
#

My language is python

chrome canyon
#

No it's not

jagged warren
#

np dammi

tender garnet
#

Hey, is API up to date about 12Hours voting ? because I see 24 hours on the docs

restive otter
#
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your discordbots.org token', client);

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

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

here is api

#

with this you can show ur bot like this

#

if u dont do , you will see this:

uneven furnace
#

Is there a way to just get the number of votes a bot has instead of who's voted?

loud gulch
#

i dont think you can

#

get for

#

a bot

uneven furnace
#

Fuck.

#

I just want the number of votes that my bot has

loud gulch
#

ok ur bot

#

use the api

uneven furnace
#

Thats what I'm asking if its possible. BC getVotes lists everyone who has voted. Not the NUMBER of votes

loud gulch
#

is it an

#

array

#

wait its a object

#

a

humble bison
#

@uneven furnace what language

uneven furnace
#

@humble bison js

humble bison
#

i'm pretty sure it's an object anyways, try Object.keys(your vote thing).length

plain timber
#

Or just get the bot object and check the points or monthlyPoints

#

Works for any bot

dusk jetty
#

Hello sir ?

topaz wyvern
#

uh hi

dusk jetty
#

Anyone can help me to turn on webhook upvote ?

#

I'm hosting on Glitch

ripe night
#

reee someone help me with the weebhook for bot bot's server count, I have no experience at all

tidal burrow
#

webhook for server count?

#

these 2 don't go together

ripe night
#

No to get the server count to the discord bot list website

restive otter
#

post to the api

tidal burrow
#

learn about API and how you can use it with your programming language

ripe night
#

What api

#

wait discord bot list has an api?

#

nvm

restive otter
#

yes

#

what

tidal burrow
#

application programming interface

ripe night
#

Lmfao I have already finished it

restive otter
#

nvm

ripe night
#

Wait a minute

#

How do you get that token?

#

My bot is approved

tidal burrow
#

you are hard to understand; first you said what an api is, then you said you already finished it, and now asking for a token thonkang_cat

ripe night
#

Yes because there was literally code to copy paste on the api page

#

how ever

#

I didnt see that

tidal burrow
#

unrelated, but are you using better discord?

ripe night
#

Your discordbots.or token

topaz wyvern
ripe night
#

Where tf do I find that

topaz wyvern
ripe night
#

oh

#

thx bb

topaz wyvern
#

yw

tidal burrow
#

I swear I didn't ever see your typing event Thonk

#

that's some pretty obvious bd

topaz wyvern
#

@ripe night start typing pls

#

and send a message

ripe night
#

what

restive otter
#

Hey

#

I'm trying to generate an API key, but the generate button doesn't work

#

Anyone know why?

plain timber
#

what browser?

#

and what page are you on

restive otter
#

Microsoft Edge

plain timber
#

pls dont use edge, many sites wont work properly on it (they're working on a newer version tho)

restive otter
#

oh okay, thanks!

old river
#

is there a way to test the voting system for a bot

signal hawk
#

there is a test button, if you are on the edit page all the way at the bottom underneath the webhook setup

old river
#

oh thanks

restive otter
#

.

#

Aw cuz I alt+f4 my bot ;3;

woven pendant
#
const DBL = require('dblapi.js');
const express = require('express');
const http = require('http');

const app = express();
const server = http.createServer(app);
const dbl = new DBL(yourDBLTokenHere, { webhookAuth: 'password', webhookServer: server });

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

app.get('/', (req, res) => {
  // ...
});

server.listen(5000, () => {
  console.log('Listening');
});

Can someone tell me why this code does not work with me ?

runic grove
#

@woven pendant yet another one, you didnt replace yourDBLTokenHere with your toke

#

N

woven pendant
#

no

#

I have replace the token

#

but what's the 'password' and where I can find this ?

sand hazel
#

Perhaps read the doc

#

You are supposed to choose a password that corresponds to the authentication password on the bot page

woven pendant
#

a random password?

restive otter
#

Hello how can i get the Authorization password ?

arctic arch
#

you decide what it is

restive otter
#

ok

light pollen
restive otter
#

ok

#

How Can i login to webhook?

#

{ webhookPort: 5000, webhookAuth: "" });

#

?

#

what is error

limpid swallow
#

How to get the ID referred in the docs?

#

What ID is it?

restive otter
limpid swallow
#

The ID in this

#

Which Id is that referring to

#

@restive otter

restive otter
#

really idk

limpid swallow
#

Okay

#

Someone help

sand hazel
#

Bot prob

plain timber
#

@limpid swallow your bot id obviously

#

It gives you the correct code in your bots edit page

restive otter
#

i get

Oops! Error: 403 Forbidden

in console, when the bot tries to post stats

#

and i checked api key

#

i have this

const DBL = require("dblapi.js");
const dbl = new DBL("api key is here", client);
setInterval(() => {
    dbl.postStats(client.guilds.size);
}, 800000)
dbl.on('posted', () => {
    console.log('Server count posted!');
  })
  
  dbl.on('error', e => {
   console.log(`Oops! ${e}`);
  });
plain timber
#

403 means wrong API key @restive otter

shut ibex
#

Make sure you're using your dbl key and not bot token

restive otter
#

Do I have to use an API key now

restive otter
#

401 Unauthorized
I believe i has regen the token
help me ๐Ÿ˜ง

plain timber
#

401 means you didn't send a token @restive otter

restive otter
#

send?

plain timber
#

In your API request

restive otter
#

i do

const DBL = require('dblapi.js') 
const dbl = new DBL(process.env.DBL_TOKEN, client);
dbl.getStats(id).then(stats => 
console.log(stats))
#

its wrong? ๐Ÿ˜ง

plain timber
#

What if you try logging process.env.DBL_TOKEN

restive otter
#

the token at .env
DBL token

#

of my bot

plain timber
#

Try logging it to make sure it works

restive otter
#

its work to post stats
but to get the stats etc
the error always happen

plain timber
#

Also make sure you're using the latest version of dblapi.js

restive otter
#

Oh alright lemme try update it

#

Aww its work thanks :)

willow ruin
#

Does "get bot api" require authentication? If yes, how long?

plain timber
#

It will need authentication soon iirc

willow ruin
#

I got 'unauthorized' now

plain timber
#

Oh yeah it already does need it

willow ruin
#

Thanks for info

restive otter
#

i using .getBot

humble bison
#

no permission

restive otter
#

im already regen the DBL Token

#

but still 403 forbidden

sand hazel
#

sh0w c0de

restive otter
#
if (args[0] === "info") {
  
        let user;
    if (message.mentions.users.first()) {
      user = message.mentions.users.first();
    }
  if (!user) return message.reply("Please input a valid DBL Bot")
  
  let dblpage = `https://discordbots.org/bot/${user.id}`;
    
dbl.getBot(user.id).then(bot => {
  
  let supports = `[Support Server](https://discord.gg/${bot.support})`;
  if (!bot.support) {supports = "No Support Server"}
  
  let web = `[Website](${bot.website})`
  if (!bot.website) {web = "No Website"}
  
  let githubs = `[GitHub Repository](${bot.github})`
  if (!bot.github) {githubs = "No GitHub Repository"}
  
  if(bot.server_count === undefined) {bot._count = 0}
  if(bot.shards === undefined) {bot.shards = 0}
  
    let embed = new Discord.RichEmbed()
    .setAuthor(`${bot.username} DBL Information`, "https://images-ext-2.discordapp.net/external/8BBeTTZachdfvV_pRM7BuN7B8Xa7oH-wyk8j7PLyFhA/https/cdn.discordapp.com/icons/264445053596991498/f98ebaaa7f46cca0d412c26b3da4a286.jpg")
    .setDescription(bot.shortdesc)
    .addField("General Info", `-> **Bot Username**: ${bot.username} \n-> **Bot Discrim**: ${bot.discriminator} \n-> **Lib Used**: ${bot.lib} \n-> **Bot Prefix**: ${bot.prefix}`, true)
    .addField("Bot Stats", `-> **Server Count**: ${bot.server_count} servers \n-> **Shard Count**: ${bot.shards.length} Shard(s) \n-> **Upvotes**: ${bot.monthlyPoints} upvotes (This Month) | ${bot.points} upvotes (Total Upvotes)`, true)
    .addField("Links", `[DBL Page](${dblpage}) | [Bot Invite](${bot.invite}) | ${supports} | ${web} | ${githubs}`)
    .setThumbnail(user.displayAvatarURL)
    .setFooter(`This Command using DBL API. Requested by: ${message.author.tag}`, message.author.displayAvatarURL)
    .setColor("AQUA")
    
    message.channel.send(embed)
    
});
  }```
#

the post stats func also 403 forbidden

sand hazel
#

what are you trying to do with this bot

#

like something similar to luca?

restive otter
#

i just want to check my bot / my friend bot at DBL without open the page

sand hazel
#

can you show where dbl is defined

restive otter
#
const DBL = require('dblapi.js');
const dbl = new DBL(process.env.DBL_TOKEN);
const Discord = require('discord.js')

exports.run = async (client, message, args) => {
  
  if (!args[0]) return message.channel.send(`
\`\`\`Use my!dbl [option] [Tag @ Bot]

- info
- widget
\`\`\`
`)
  
  
  if (args[0] === "info") {
sand hazel
#

can you dump the dbl token

#

and where are you obtaining the token from

restive otter
#

from the edit bot page

sand hazel
#

alright, can you dump it to check the value

restive otter
#

@sand hazel my post_stats also 403 forbidden

#

i already post the stats more than 4 month, but nothing happen like this

sand hazel
#

so, dump the value?

restive otter
sand hazel
#

so, can you dump the value (for the 4th time)

restive otter
#

what the meaning of "dump the value" ?

sand hazel
#

dump process.env.DBL_TOKEN, make sure it's not truncated and it's the expected value

#

in addition, you can add a line to dump the dblapi options, in src/index.js, L104

restive otter
#

@sand hazel btw my dbl webhook is working well

sand hazel
#

ok?

#

webhook doesn't use api token?

restive otter
#

it use the api token

sand hazel
#

webhook does not use the API token generated by DBL

restive otter
#

yourDBLTokenHere

sand hazel
#

ok? but webhook doesn't use that?

restive otter
#

i cant run the webhook if i delete the token

sand hazel
#

I honestly don't see anything regarding that DBL token

restive otter
sand hazel
#

The DBL token constructor parameter is purely for payloads to DBL API

#

nor does the dblwebhook constructor takes the dbl token

restive otter
#

i need to afk

#

thanks for helping me

restive otter
#

how it changed the background and color of letters where the bot appears on the discord bots page

sick egret
#

can anyone help me?

#

I'm getting unauthorized error on votes

restive otter
#

Vote api broken

sick egret
#

ah

restive otter
#

I cant get votes

sick egret
#

but I still see bit bots like mudae increasing

#

big*

restive otter
#

I dont know

#

I cant get my votes for upvote

sick egret
#

when vote api will be fixed will votes get issued again? My users want their voting bonus and I'd like to have those votes I got this morning

restive otter
#

My users too

#

@sick egret you perhaps using deprecated api look at new one

sick egret
#

new one is already released?

restive otter
#

idk then :/

sick egret
#
const express = require('express');
const http = require('http');
const app = express();
const server = http.createServer(app);
const DBL = require('dblapi.js');
const dbl = new DBL(`Token that I wont share`, { webhookAuth: 'no' ,webhookServer: server, webhookPort: 5000});
dbl.webhook.on('ready', hook => {
  console.log(`Succes, webhook running on http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
    console.log(`User with ID ${vote.user} just voted!`);
    dbl.getUser(vote.user).then(user => {```
restive otter
#

Ok

sick egret
#

that's my code

restive otter
sick egret
#

yes

restive otter
#

So thats not your code

sick egret
#

and it used to work fine until this morning

#
User with ID 150590205437411329 just voted!
(node:31316) UnhandledPromiseRejectionWarning: Error: 401 Unauthorized
    at IncomingMessage.res.on (/root/overseerbot/node_modules/dblapi.js/src/index.js:115:25)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
(node:31316) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
#

that's the error

#

if someone can help I would be grateful

arctic arch
#

which function are you using

sick egret
#

code is up

#

and as I said it always worked

arctic arch
#

update the module

sick egret
#

ok

arctic arch
#

to 2.3.0

sick egret
#

votes issued in that time are lost, right?

arctic arch
#

and I recommend using client.users.get() instead of the DBL api to get a user

sick egret
#

okk

autumn sage
#

is the discordbots api built to allow plugin customization when managing bots in your server?
or is it a way to display it in the website?

#

I've made a couple of bots using the discord API so I'm trying to figure out what the discordbot API is for

arctic arch
#

our api is mainly for posting your server count to our site so it displays on your bot page and on the lists and for checking who has voted for your bot

autumn sage
#

ah cool

#

so publishing my bot in the website and using the API are not dependent on one another?

arctic arch
#

using the api is optional

autumn sage
#

ok, thank you

sick egret
#

updating api fixed problem, thanks tonkku

autumn sage
#

I'll come back with some other questions eventually ๐Ÿ˜…

restive otter
#

How do i open a port for discordbots using ubuntu vps on ovh?

#

Like, what are the IPs of discordbots.org so i can make only that site allow to send requests to my vps

#

or does it do that automaticly

#

@arctic arch ?

arctic arch
#

just allow all IPs

#

the IP is not guaranteed to stay the same

restive otter
#

theres no option for that

arctic arch
#

wouldnt that be the ip to your server

restive otter
#

idk..

arctic arch
#

hmm

restive otter
#

well all i know is it doesnt work

arctic arch
#

I dont use OVH, but those options look similiar to something else

#

0.0.0.0 might allow all

restive otter
#

Bruh

arctic arch
#

and set protocol to tcp

restive otter
#

i appearently dont even need to set an ip

#

cuz it somehow just recieved the vote

chrome canyon
#

BRUH

restive otter
#

wait no

#

i allowed port 5000 ofc for the voting

#

nvm xD

chrome canyon
#

I just wanted to set it up for Vyan but I remembered he's not on DBL

arctic arch
#

is Vyan your bot

chrome canyon
#

ye

#

is good botum

lilac badger
#

I want HQ trivia lives bot

chrome canyon
#

@arctic arch why u askin

light pollen
#

How can I do that?

plain timber
#

@light pollen you need to set up a webserver to accept the POST request sent by DBL

#

if you use js then you can use the dblapi.js package, or set up a post route in express

light pollen
#

Discord.js-commando ?

chrome canyon
#

dblapi.js

#

like that

light pollen
#

@jaunty depot translate please

#

@plain timber Please turkish translate?

jaunty depot
restive otter
#

api saying error 403

#

token is 100% definetly correct

#

even tried new one

#

and have set the thing up correctly, because it used to work

#

ping me*

plain timber
#

@restive otter 403 means wrong token blobshrug

restive otter
#

ive tried a new token

#

many times

sand hazel
#

alright, then add a debug line in dblapi

#

dumping the request options

hoary timber
#

It should show the monthly and total votes and not ?

sand hazel
#

idk, check your logs

#

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

hoary timber
#

I got that right now on starting the bot:
Accumulating suspicious amounts of cached events during guild setup, something might be wrong. Cached: 2000 GuildId: 264445053596991498

#

The ID is this guild

#

Something doesn't seem right, because no matter what I do, it returns ? which means, that the returned JSON is wrong somehow

#

Any way to receive the info now?

arctic arch
#

api requests require a token now

hoary timber
#

Even through the page mentioned above?

#

I remember asking that (if those requests would require a token now) and the response was No.

#

How should it be send?

humble bison
#

auth header

hoary timber
#

What key? "auth"?

humble bison
#

Authorization

hoary timber
#

alright, that fixed it

#

thx

distant ibex
#

const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' }); on the site, it says password (webhookAuth), where exactly do you get this password (or do you just set it to a random thing?)

plain timber
#

@distant ibex you can set it to anything but it needs to be the same in your code and your bot edit page

#

hey @arctic arch does dblapi.js have something for the Get Bot Stats endpoint

#

i dont see it in docs

arctic arch
#

maybe maybe not

plain timber
restive otter
#

!server

cosmic tulip
#

hmm....

restive otter
restive otter
#

lol x3

tidal burrow
#

Are you intentionally refreshing the page? Cause I can't even tell what's happening or what you are trying to show

little ice
#

he try to show that the vote counter is changing every refresh

#

but that is basicaly because of multiple servers cache right ?

#

it is explained here

#

@restive otter

restive otter
#

Yes @tidal burrow

shut ibex
#

It's caching

sand hazel
#

reminds me of the cloudbleed

zenith river
#

how do I get the discord bot list webhook server pass and port?

tidal burrow
#

weird that you asked that, considering you don't have a bot listed here

polar mirage
#
dbl.getBot("478202666355523585").then(bot => {
    points = bot.points;
});```
#

Unauthorized

#

While it wasn't before

#

My token is right, I've checked

#

Also I'm pretty sure posting my server count wouldn't work if my token was wrong.

#

Do we not have access to .getBot() anymore?

arctic arch
#

update to v2.3.0

polar mirage
#

oh

#

ty sir

restive otter
#

For some reason API stopped working for me while ago, I removed all of the codes, And now when I set the server count by postman, It changes itself!

#

@arctic arch You might wanna take a look

arctic arch
#

cache

restive otter
#

I cleared the cache

arctic arch
#

not on your end

#

server-side cache

restive otter
#

Then what should I do?
It's nearly impossible to use it now, I had to remove codes and it's not kinda updating it due to cache

arctic arch
#

it is updating

restive otter
#

Also I didn't send 2?

#

and 14583

#

Check the numbers

arctic arch
#

you're just not seeing it right away because we're serving a cached version for a while

restive otter
#

They are not the same

#

But what about the numbers?

#

I've sent 7

#

And it shows 2

#

I've sent 16476

#

It shows 16483

arctic arch
#

you're posting two server_counts

#

which means an array

#

which means server counts for individual shards

signal hawk
#

so, on the api documentation, it sas .hasVoted returns if the person has voted in the past 24 hours. is that actually 24 hours or is it 12, because you can vote every 12 hours?

plain timber
#

@signal hawk iirc its 12

#

Docs are outdated

signal hawk
#

okay because i have a .hasVoted set up , so if someone does my vote command, if hasvoted comes back true, it tells them "thank you for voting" and if it comes back false, it displays the vote link

but i tested it today when i knew i hadnt voted for 12+ hours and it gave me the thank you message

#

ill have to check my code

#

thanks

polar mirage
#

But what if I spam your vote command

#

Your bot will spam the dbl api โ“

median dragon
#

Hello,
I would need a person who takes care of checking the bots for the meters on the site of discordbots and, who speaks French please. Thank you.

runic wraith
restive otter
#
(node:1046) UnhandledPromiseRejectionWarning: Error: 403 Forbidden

    at IncomingMessage.res.on (/rbd/pnpm-volume/badc03b8-a538-46b8-a786-efd67ab85be3/node_modules/.registry.npmjs.org/dblapi.js/2.3.0/node_modules/dblapi.js/src/index.js:118:25)

    at IncomingMessage.emit (events.js:187:15)

    at endReadableNT (_stream_readable.js:1094:12)

    at process._tickCallback (internal/process/next_tick.js:63:19)

(node:1046) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

(node:1046) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

TOKEN IS NOT WRONG, ive tested and checked many times
Im using glitch, and this has worked befoe

#

i have it set up like this

const DBL = require("dblapi.js");
const dbl = new DBL("a token that is here and correct", client);


setInterval(() => {
    dbl.postStats(client.guilds.size);
}, 800000)
dbl.on('posted', () => {
    console.log('Server count posted!');
  })
  
  dbl.on('error', e => {
   console.log(`Oops! ${e}`);
  })
#

its for a bots stats

plain timber
#

You don't need the set interval or post stats if you include client in the new DBL code

restive otter
#

either way it does not work, i need a fix

sand hazel
#

how about adding debug line to the lib

#

like a sane person would do

restive otter
#

logged it

DBLAPI {

  _events: { posted: [Function], error: [Function] },

  _eventsCount: 2,

  _maxListeners: undefined,

  token:

   'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjQ4MDQyMTQ4MzU3NTkwMjIwOCIsIvdCI6dHJ1ZSwiaWF0IjoxNTQ0MTI0NzQ0fQ.HRPvPW1US8by9BX0fdmK2m_eaNO8lcvpRUGkyJnAP2Q',

  options: {} }
#

got that

#

took 2 things from token btw, dont bother tryin it

sand hazel
#

can you log the options in the _request

arctic arch
#

if you only removed two things it could still be found out

restive otter
#

i dont care, im changing it as soon as its fixed

#

why am i getting incorrect token error

#

if the token is correct

arctic arch
#

so you're posting stats?

restive otter
#

yes

arctic arch
#

looking at recent logs I see no requests that result in a 403

restive otter
#
Oops! Error: 403 Forbidden
sand hazel
#

it'd be so much easier if the request options were known so you can attempt to reproduce it in postman

arctic arch
#

can you log e.body

restive otter
#

e is undefined

#

..

arctic arch
#

its not undefined if you get the forbidden logged

#
dbl.on('error', e => {
   console.log(e.body);
  })
restive otter
#

nvm i see

#

ye so, now my log is filled with bunch of html

arctic arch
#

post it all

#

it's the cloudflare IP ban thing

restive otter
#

so why is my ip banned?

arctic arch
#

yeah

#

it was banned for request spam

#

could be you

restive otter
#

and what was the spam?

arctic arch
#

could be someone else using glitch

restive otter
#

maybe

#

so, can it be unbanned?

arctic arch
#

well

#

I could

#

but if there's someone else spamming I might have to re-block it

sand hazel
#

lmao

#

glitch blurryeyes