#topgg-api
1 messages Β· Page 41 of 1
why is this in api
I am trying to post the server count to my bot from a test bot and getting a Forbidden (status code: 403) error, is this because I am using a different bot?
incorrect and/or no token provided iirc
yes its because you are using a different bot
you post to a stats endpoint and the url includes the bots id
if it doesnt match your token
then it wont work
you can just drop the id from the url

Oof
Are web hooks down?
hm
@plain timber can u do smth for me
can u updoot my bot
I need to check if my upvote thing if bork
press test button u meme
I block test requests
oof
one min
it doesnt work for me tho
maybe its ur code?
fuck
and I borked my code
rip
ytho
@ thonkku beep tortle is ADVERTISING pls BEAN him kthx
wow
@shut ibex done
thank it went through
u have premium on me bot for 48 hours but it doesnt do anything yet
lol
and i ask you for a favor and you treat me like this
i just give a role + message in the official server
inb4 ping, help, about, and donate
I'll also gib role
AttributeError: 'Client' object has no attribute 'post_guild_count' someone explain
My bot joined two bot farms yesterday
can i has link plz
Failed to post server count
Unauthorized: Unauthorized (status code: 401): {"error":"Unauthorized"}
Traceback (most recent call last):
File "C:\Users\no name\Desktop\UltraBot\bot.py", line 76, in update_stats
await self.dblpy.post_server_count()
File "C:\Users\no name\AppData\Local\Programs\Python\Python36\lib\site-packages\dbl\client.py", line 100, in post_server_count
await self.http.post_server_count(self.bot_id, self.guild_count(), shard_count, shard_no)
File "C:\Users\no name\AppData\Local\Programs\Python\Python36\lib\site-packages\dbl\http.py", line 189, in post_server_count
await self.request('POST', '{}/bots/{}/stats'.format(self.BASE, bot_id), json=payload)
File "C:\Users\no name\AppData\Local\Programs\Python\Python36\lib\site-packages\dbl\http.py", line 158, in request
raise Unauthorized(resp, data)
dbl.errors.Unauthorized: Unauthorized (status code: 401): {"error":"Unauthorized"}
``` help
def __init__(self, bot):
self.bot = bot
self.token = its correct no worries
self.dblpy = dbl.Client(self.bot, self.token)
self.bot.loop.create_task(self.update_stats())```
am i doing anything wrong?
not ur bot token ur dbl token

self.bot
yes, my dbl token
your dbl token isn't your bot token
What link are u posting to
idk, i'm using the api
what coding lang @placid mist ?
PHP
isnt php frontend?
i dont do php sowwy

@placid mist it sounds like you know already
https://cdn.discordapp.com/attachments/412006692125933568/503897429943386113/unknown.png
here you're json_encoding but you should be decoding
$inputJSON = file_get_contents('php://input');
$input = json_decode($inputJSON, TRUE); //convert JSON into array
read the docsβ’
I just said
Read the docs

I don't understand webhooks ( I want to use the npm module dblapi.js )
Someone can explain me?
plz :v
hightlighted in yellow = I don't understand π
And of course I don't understand what it say in the api > webhooks
Was wondering why DiscordBotListAPI#getVoters(String) is deprecated?
in the Java library
It's not my faut, explain me instead of saying that
well thats what everyone tells me
dbl webhooks are different from bots
o
point taken
Question: When posting to the API, it is considered good practise to return a 204 instead of a 200.
Why is it returning a 200?
return 204 if the request was successfull and you have nothing to reply back with
I`ve generated a Token and used the Code from the API Docs but i always get 403 Error "unauthorized"
Send your code @sacred path
basically its just the example here https://discordbots.org/api/docs#pylib
i only inserted the token where i should do
You're using Python ?
yes
I'm using JS so I don't know how to help u. Sorry bro
nvm... regenerated token again now it works
π€·
first 3 tokens wont work xD now this one works
Lol
I don't understand how to set up a webhook with DBL π€ Can someone explain me please ? (JavaScript)
do i need to install anything for webhooks
i want to make a daily command that requires them to upvote the bot
What's to stop someone from forging fake POST information to boost stats
Nothing afaik, person does get on trouble if caught though
mk
well you can't really be 100% sure they post accurate data but you know when they extremly ovverrate the bot like when a bot with 2 commands has 50k servers they probaly wanna see proof and if they caught you get in big trouble
@lilac summit you can use the dblapi.js library (https://discordbots.org/api/docs#jslib) or add a route to your webserver
but i wanted the daily to be auto without me having to check every minute
@topaz wyvern webhooks are recommended, using the api to check for votes can lead to api spam and also you cant automatically give rewards
how do i use webhooks
Oh
how do i use webhooks?
^
@tepid garden what language do you use for your bot
javascript
you can use the dblapi.js library (https://discordbots.org/api/docs#jslib) or add a route to your webserver
do i need to install anything?
on your computer or on your server
the computer and server
if you haven't already installed dblapi.js through npm on your server, you'll have to
npm install dblapi.js
ok
so with this 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 would put it in the bot.on('message', message => {//stuff in there})
i want to make a daily command with it
so when they use the command it will check if they voted?
yea
then you would need to add an entry to your database when someone votes
and check it when someone uses the command
i dont have a data base π
they you cant make a command use the webhooks
you could just use the check endpoint but thats not really recommended
well then how would i do it :b
how to i get my bots token
thats all i need to know
Your dbl token?
yea
Under api on the website click you bots and click create api token
how do i get the pass
i have 2 more questions how do i get the pass and do i put the dbl token in " "
@tepid garden the pass is only for webhooks, its whatever you set as the webhook auth in your edit page
oh...
how can i run my bot 24/7?
you run your bot on a server, and also these type of questions should do to #development and not here
how to i attach my dbl bot webhook to glitch?
@late prawn Stop sending memes here
what's the point in saying that after they stopped over 6 hours ago 
you are only attracting more unwanted attention
Hello good sirs
const Eris = require('eris');
const bot = new Eris(CLIENT_TOKEN);
const DBL = require("dblapi.js");
const dbl = new DBL(DBLKEY, bot);
Will that work?
Can I use eris with dblapi?
If no one answers I'll asume yes
If it doesn't work I'll spank yall
that should work yes
dbl.on('posted', () => {
console.log('Server count posted!');
})
Is this posting automatically when bot is added to server? Or I need to setup an interval to do this even X hours?
if you have your bot client passed to the DBL constructor, the library will post automatically
That event will notify you of successful posts and is optional
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('123123123', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
client.login('123123123');
I did like this, should be correct, right?
yes
what exactly is a webhook?
i just want to use the vote listener
can i just use any url, eg. my bot's website as the webhook url so i can get info within my bot to see whenever someone voted?
if you set up a listener in your website
@civic harbor all you need to do is receive a POST request on the endpoint, if you are using JS you can use the official dblapi.js library and it will receive the requests for you
I am using js
and the npm package
i tried
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!`);
});
and i replaced yourDBLTokenHere with my api key
however, i did not get anything when someone voted
did you set the URL and auth in your bot's edit page?
what did it console.log
yes
oh okay
yes
change that to the ip/domain of your server
so like my ip address?
do i just leave the port the same?
well thanks for your help
webhooks not working for anyone?
Yes
oof
spam tonkku
you only need the id, not the url
with getVotes you can only get the latest 1000
use .length
it's an array, not a collection
wouldn't it be like total votes though
I literally says webhook url
Serkan is my girl
Why this DBL library uses a lot of CPU for basic script? There are only 5 lines of code
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('123123123', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
client.login('123123123');
I don't even think that the reason
Any idea on how to post images in on your bot page in HTML or Markdown while resizing them?
The current way i've been using on all my pages in HTML (as show below) doesn't resize the image like it does on github for some reason
btw that's not a line, it's my cursor
Could you use a style thingy? style="height:200px" or something
how come my bot is saying it has 1 upvote this month and 5 total, but /bots/328904846541586432/votes returns an empty array 
because dbl
okay now its anoying... i always get an Unauthorized Error from the Api and couldnt figgure out whats wrong
Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}
Traceback (most recent call last):
File "/home/noir/moderation/modules/dblapi.py", line 25, in update_stats
await self.dblpy.post_server_count()
File "/home/noir/.local/lib/python3.6/site-packages/dbl/client.py", line 100, in post_server_count
await self.http.post_server_count(self.bot_id, self.guild_count(), shard_count, shard_no)
File "/home/noir/.local/lib/python3.6/site-packages/dbl/http.py", line 189, in post_server_count
await self.request('POST', '{}/bots/{}/stats'.format(self.BASE, bot_id), json=payload)
File "/home/noir/.local/lib/python3.6/site-packages/dbl/http.py", line 160, in request
raise Forbidden(resp, data)
dbl.errors.Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}
Hum π first i only want to moan a bit =D
actally im not understanding why this happens
i generated a new token, and i only use the example from
https://discordbots.org/api/docs#pylib
nothing else just the server count
Would help if you post your code
import logging
import dbl
from misc.config import cfg
class DiscordBotsOrgAPI:
"""Handles interactions with the discordbots.org API"""
def __init__(self, bot):
self.bot = bot
self.token = 'TOKEN HERE'
self.dblpy = dbl.Client(self.bot, self.token)
self.bot.loop.create_task(self.update_stats())
print('Addon "{}" loaded'.format(self.__class__.__name__))
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count"""
while True:
logger.info('attempting to post server count')
try:
await self.dblpy.post_server_count()
logger.info('posted server count ({})'.format(len(self.bot.guilds)))
except Exception as e:
logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
await asyncio.sleep(1800)
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(DiscordBotsOrgAPI(bot))```
its the absolut basic example from the Page
You're using rewrite?
So, supernoob question incoming: how do I add the auth token? lmao
let options = {
url: 'https://discordbots.org/api/bots/432533456807919639',
Authorization: 'token'
}
https.get(options, (resp) => {
What's wrong?
just guessing, but probably
{
url: 'https://discordbots.org/api/bots/432533456807919639',
headers: {
Authorization: 'token'
}
}
Any way I can check if a user has voted, via API?
my bot gives a error about api and websockets how i need to fix?
you fix it
yes
I can sue
whoops
Where i can get dbl token?
How to fix websockets error?
can someone tell me why my server count isnt updating https://i.imgur.com/ft2HTsl.png
ok
@restive otter whats your code
ok i am using python and aiohttp
header = {"Authorization" : config["dbltoken"]}
payload = {"server_count" : len(self.guilds)}
baseurl = "https://discordbots.org/api/bots/501191721456107531/stats"
await self.change_presence(activity=discord.Activity(name=f".help in {len(self.guilds)} Servers!", url="https://www.twitch.tv/EnterNewName",type=1))
async with aiohttp.ClientSession() as session:
await session.post(baseurl, data=payload, headers=header)```
its not giving any errors when i did try except
try using the official lib
alright
https://discordbots.org/api/docs#pylib
https://github.com/DiscordBotList/DBL-Python-Library
https://dblpy.rtfd.io/
A simple API wrapper for discordbots.org written in Python - DiscordBotList/DBL-Python-Library
i would rather use aiohttp but ok
Guys, what affects the value of mfa_level for a guild?
btw how long does it take to post stats
i tried doing
dbl.hasVoted(`${message.author.id}`).then(voted => {
if (!voted) return message.channel.send(`Hey! Please Vote For Us To Use This Command! [**Click Here**](https://discordbots.org/bot/469385784042979328/vote)`);
});
but it keeps saying dbl.hasVoted is not a faction
0|index | TypeError: DBL.hasVoted is not a function
0|index | at Query.con.query (/root/dbot/commands/hentai.js:152:5)
0|index | at Query.<anonymous> (/root/dbot/node_modules/mysql/lib/Connection.js:502:10)
0|index | at Query._callback (/root/dbot/node_modules/mysql/lib/Connection.js:468:16)
0|index | at Query.Sequence.end (/root/dbot/node_modules/mysql/lib/protocol/sequences/Sequence.js:83:24)
0|index | at Query._handleFinalResultPacket (/root/dbot/node_modules/mysql/lib/protocol/sequences/Query.js:139:8)
0|index | at Query.EofPacket (/root/dbot/node_modules/mysql/lib/protocol/sequences/Query.js:123:8)
0|index | at Protocol._parsePacket (/root/dbot/node_modules/mysql/lib/protocol/Protocol.js:278:23)
0|index | at Parser.write (/root/dbot/node_modules/mysql/lib/protocol/Parser.js:76:12)
0|index | at Protocol.write (/root/dbot/node_modules/mysql/lib/protocol/Protocol.js:38:16)
0|index | at Socket.<anonymous> (/root/dbot/node_modules/mysql/lib/Connection.js:91:28)
0|index | at Socket.<anonymous> (/root/dbot/node_modules/mysql/lib/Connection.js:502:10)
0|index | at Socket.emit (events.js:182:13)
0|index | at Socket.EventEmitter.emit (domain.js:442:20)
0|index | at addChunk (_stream_readable.js:283:12)
0|index | at readableAddChunk (_stream_readable.js:264:11)
0|index | at Socket.Readable.push (_stream_readable.js:219:10)
``` any ideas?
define dbl
Oh i did it was the wrong error
0|index | TypeError: dbl.hasVoted is not a function
0|index | at Query.con.query (/root/dbot/commands/hentai.js:152:5)
0|index | at Query.<anonymous> (/root/dbot/node_modules/mysql/lib/Connection.js:502:10)
0|index | at Query._callback (/root/dbot/node_modules/mysql/lib/Connection.js:468:16)
0|index | at Query.Sequence.end (/root/dbot/node_modules/mysql/lib/protocol/sequences/Sequence.js:83:24)
0|index | at Query._handleFinalResultPacket (/root/dbot/node_modules/mysql/lib/protocol/sequences/Query.js:139:8)
0|index | at Query.EofPacket (/root/dbot/node_modules/mysql/lib/protocol/sequences/Query.js:123:8)
0|index | at Protocol._parsePacket (/root/dbot/node_modules/mysql/lib/protocol/Protocol.js:278:23)
0|index | at Parser.write (/root/dbot/node_modules/mysql/lib/protocol/Parser.js:76:12)
0|index | at Protocol.write (/root/dbot/node_modules/mysql/lib/protocol/Protocol.js:38:16)
0|index | at Socket.<anonymous> (/root/dbot/node_modules/mysql/lib/Connection.js:91:28)
0|index | at Socket.<anonymous> (/root/dbot/node_modules/mysql/lib/Connection.js:502:10)
0|index | at Socket.emit (events.js:182:13)
0|index | at Socket.EventEmitter.emit (domain.js:442:20)
0|index | at addChunk (_stream_readable.js:283:12)
0|index | at readableAddChunk (_stream_readable.js:264:11)
0|index | at Socket.Readable.push (_stream_readable.js:219:10)
please tag me if you can help
I canΒ΄t help sry
:C
@lunar tide can you show the code where you defined dbl
ye
const DBL = require("dblapi.js");
const dbl = new DBL("CODE", { webhookPort: 56571, webhookAuth: '**********' }, client);
i have that in my main file
then
commandfile.run(client, message, args, con, cmd, DBL, dbl, errors);
in the main file to
module.exports.run = async(bot, message, args, con, dbl, DBL) => {
in a command file
then this
dbl.hasVoted(`${message.author.id}`).then(voted => {
if (!voted) return message.channel.send(`Hey! Please Vote For Us To Use This Command! [**Click Here**](https://discordbots.org/bot/469385784042979328/vote)`);
});
in the command file
@plain timber
are you on the latest version of dblapi.js?
what if you console.log(dbl)
it gives me the prefix and command name :/
0|index | !testfile
nvm i fixed it @plain timber sorry to bother
where did the webhook documentation go?
i found it, but why is it not easily accessible on the docs page?
what lang
English
@restive otter https://discordbots.org/api/docs#webhooks ?
yeah i found that eventually through the bot edit page
but it doesn't show on the left menu bar
It's right on the API docs page
kk
@azure pollen
down the chain it goes
thanks
you should know I dont frontend lol
Is there any way to send an image when a user enters the server of discord? my bot is created in discord.js
the code is ?
:/
Sorry Man
:/
You know Collection#find: pass a function instead
Error
Bot working
Ok
The api of dbl have bug?
What kind of bug?
a flying bug
A ladybug π
π€
Why does the API keep rejecting my request to post my bot's server count?
I send a POST request to https://discordbots.org/api/bots/botid/stats
with the headers
Authorization: token
Check the response?
401 = Unauthorized
ik
Your token isn't right
Is it that Im not using the correct token?
kk
It worked.
Ty for ur help
I made my own API wrapper
!play Caught my a rythem
h!play Nobody Can Save Me
h!stop
My code:
require('snekfetch').get(`https://discordbots.org/api/users/242734840829575169`)
.then(r => {
const body = JSON.parse(r.body)
console.log(body.username)
})```
@amber dune
It gives me this:
(node:379) UnhandledPromiseRejectionWarning: Error: 404 Not Found
at _response.transport.request.then (/home/runner/node_modules/snekfetch/src/index.js:193:21)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:182:7)
(node:379) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:379) [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.```
seems to be working for me π
brb
also i dont know node
@amber dune what lang do u use weeb
weak
says the person using a fad language 
go is not a fad lang
@novel carbon
imo just use request / html
and promisify it yourself
or require('util').promisfy(function);
snekfetch is deprecated
it still works
this channel is for the discordbots.org api. For questions about the discord api, go to #development
oh sorry will change it
So, I got my bot approved earlier today, but when I try to post my server count I get a 403 forbidden error, and I'm not sure why. Anyone got any idea? (I'm using Python), and I basically copied the layout that is on the website (as a cog) and just pasted my API key (token) into the code
try regen
u don did a gooferino somewhere down the line
but it looks fine π©
Well 403 is forbidden
Which means the server acknowledges your request but it rejects it
It has been approved
could I get the API token otherwise?
I can't see what I could do wrong
wouldn't rate limit be another type of exception anyways
not 403 forbidden
@azure pollen This doesn't look too goofed up does it?

fek
I'll dig some in the API wrapper then
see if I can find anything
lol ok
@azure pollen Ok, so I found the issue, and the "Python Library" example might want to be updated
Alright
The reason for the 403 Forbidden error:
So, what happened was, when you initialize the dbl client, it will wait until the bot is done with setting up (in the dbl lib for python, there is a method waiting for this, before assigning the id), before it assigns the bots id to one of it's attributes (in the Python lib it's bot_id).
And while the client is waiting for this id, the code will continue, and the bot's loop will create the self.update_stats() task in the example, and try to post the server count, when the bot's id, and server count for that matter have not been registered yet.
So the reason for the error is because the bot_id value is None, when you try to make the POST request. So by just waiting for 30min it will actually work, but on startup you will get an error, unless you add a line of code in the update_stats() method
@arctic arch
class DiscordBotsOrgAPI:
"""Handles interactions with the discordbots.org API"""
def __init__(self, bot):
self.bot = bot
self.token = '' # set this to your DBL token
self.dblpy = dbl.Client(self.bot, self.token)
self.bot.loop.create_task(self.update_stats())
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count"""
"""Add this line here so it won't attempt to post before the dbl client is properly set up"""
await self.bot.wait_until_ready()
while True:
logger.info('attempting to post server count')
try:
await self.dblpy.post_server_count()
logger.info('posted server count ({})'.format(len(self.bot.guilds)))
except Exception as e:
logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
await asyncio.sleep(1800)
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(DiscordBotsOrgAPI(bot))```
@azure pollen Is there any API related feature that makes the bot show as "online" on the website, or how is that done?
As my bot is online, but with a grey mark with 3 questionmarks
on the website that is
This was another question though
@restive otter did you just ping me with a solution
Yes.
and the status comes from this server
oh it does?
Yeah I gave you a brief explanation of the problem, and the solution
Dug around in the Python lib and found the flaw so, not sure if others have experienced it
I am pretty sure dblpy already does that
ah the python lib is made by francis but idk if they're in this server anymore
I tested it myself. When the first request was made, the bot_id didn't exist in the dbl client
because the bot wasn't done setting up
so if you try to post the server count before it is done setting up, there will be issues
aka the __ainit__ method
class Client:
def __init__(self, bot, token, **kwargs):
self.bot = bot
self.bot_id = None
self.loop = kwargs.get('loop') or bot.loop
self.http = HTTPClient(token, loop=self.loop, session=kwargs.get('session'))
self._is_closed = False
self.loop.create_task(self.__ainit__())
async def __ainit__(self):
await self.bot.wait_until_ready()
self.bot_id = self.bot.user.id```
So here when you initialize the client, it will create a task (ainit) which won't finish until the bot is done registering all the guilds, members etc
Ah right
Just explaining what makes it not work as well as it could
as I assume, you see it too
well, it can be solved either way by just entering the same line of code in the example that is on the API page
the await self.bot.wait_until_ready()
before the while loop
Did somebody got a python example for a vote webhook listener?
@arctic arch how i can create a command with permission only for those who voted?
@winged star don't mention admins, and always say what language you're using
node.js (discord.js)
okay and where i can find the ip and port
...
http://${hook.hostname}:${hook.port}${hook.path}
ip is your public IP afaik
{mc}help
@jaunty depot
If I want to check if a specific member id have voted in the recent 24h, how do I use the /bots/{bot.id?}/check endpoint appropriately?
Is my bot? muted
because I realized the python lib doesn't support this feature, so I'm going to make my own
ok I might have figured it out
nvm me
@winged star are you gonna use a we hook and store votes in a database or will you just check the API to see if they have voted
hmm
dbl.hasVoted("95579865788456960").then(voted => {
if (voted) console.log("Tonkku has voted!!!")
});
Here is the Tonkku's id
Ok?
i can use ${message.author.id} ?
no
Yes
how frequently does the api post the server count?
The python library didn't even have any method for checking if a single user has voted lmao
@restive otter then just make a request to the api
Yeah I already made my own custom class and inherited the original and created my own methods
it's fine 
@ripe linden the api doesnt post anything, your bot makes requests to the api. If you are using a library for the api then you can probably set the interval but it may have a default, you should check the docs for that library
that way I don't have to fuck around with the rate limiting etc
and just use the pre-existing request method
which should already handle those things

ye
idk how to
it's an event, ask in #development I don't do d.py
@wary ether what if your bot gets a guild every minute or more
every 3 minutes wont ratelimit you
Then do it every hour or so. When I started I did it on guild join
i post every 30 seconds
the lowest i'd be going is 15 or 30 seconds
1 hour is stupid
why? You don't need to post your count every 30 seconds, what's the point?
yeah 15-30 seconds is idiotic
Β―_(γ)_/Β―
how do i use webhooks to get votes?
I mean u can simply post on guild add
I don't bother with this votes.
my bot is not for prizes.
but I know its helpful for a community like this.
Guys I need help on getting a webhook, I've searched through google and found nothing, what website can I register/make a webhook?
And I have a VPS running so will it be possible to host a webhook with my VPS?, Thanks
use express
express app sir
app.post("/hook", function (req, res) {
And you can get them there
Epic
Why does express use app.post to anyways, it should be app.route
to only handle post requests
I code in Python... not JS
create a web server
just use js fqsgqgfqz
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static('public'));
app.get("/", function (req, res) {
res.send("tf u doing here")
});
app.post("/hook", function (req, res) {
if (req.headers.authorization !== process.env.WEBHOOKAUTH) return res.send({code: "invalid auth"})
var user_id = req.body.user;
var bot = req.body.bot;
//DO SOME EPIC STUFF HERE
res.send({code: "success"});
});
var listener = app.listen(process.env.PORT, function () {
console.log('Your app is listening on port ' + listener.address().port);
});
π© π©
stop
dblapi.js has been updated to support the upcoming API change
Which is?
idk app.route makes more sense to me @sudden rampart
and you specify the type of the route
My thoughts: A darn good idea. You can trace back misbehaving API requests back to the people who generated them, and punish them accordingly.
You get it banned for spamming
so im new to the api, and how do i setup webhooks? for things like Votes (btw i read the docs, but im confused)
@restive otter you need to set up a webserver to handle requests, if you are using js then the dblapi.js does this for you
does it really?
oof omg thats convenient
so what do i add to the Webhook URL in my bot settings?
iirc the example logs the url to your console
but if it says 0.0.0.0 you need to change it to the ip or domain
ty very much
Possible to Upvote in Discord using API
instead of opening website & upvote
Like
-upvote Voted try again in 12 h
@ripe estuary no
ok
hello i have a question how long does it take for the api to show on dbl ?
i think im being a fuck tard but question witch one is witch
i use: https://www.npmjs.com/package/dblapi.js
but i found: https://www.npmjs.com/package/dbl-api
witch one is the real one
ok good then
const DBL = require('dblapi.js');
const dbl = new DBL(yourDBLTokenHere, { webhookPort: PORT, webhookAuth: 'password' });
if you already put an webhook auth password do you need to change the code in any way for the new update?
The API now needs your token to get data for a bot or user
you mean the webHookAuth?
OHH XD yourDBLTokenHere
It doesn't affect webhooks or posting stats
ahh oki
OHH so like
api.discordbots.org or whater the link is]
Well dblapi.js handles it for you
oki ty
what i meen was my api has been on the bot for 24 hours but still my api doesnt show on dbl webpage π¦ @plain timber
@grizzled agate are you talking about the server count or what
yes
is there something wrong with the api ??? because my bot doesnt seem to show the servers on the webpage π¦
@cobalt ruin @arctic arch
are you posting
sorry for the ping
im just asking because my code seems fine to advaith but my bot still doesnt show my servers π¦
what's the code
give me a min need to log in the server to get it
const dbl = new DBL('dbl token', client);
thats my code but will change it now
i moved the dbl to the bottom
http://prntscr.com/ld932m
i allready have change the dbl token so its fine
i also did install all dependecy and all the npm both dblapi.js and dblapi
@arctic arch
are you seeing those logs
what logs are you looking for sorry for asking as im using the vps to access everything for you
check that your token is valid
hi tonkku
@arctic arch must i only use 1 part before the . in the api code ?
?
already have change it @arctic arch
i give up hay π’ i have change the token 5 times and it still give me that error π’
ok
Why does the endpoint keep rejecting my POST request?
it's https://discordbots.org/api/bots/mybotid/stats
My token is correct
and yes, I replaced mybotid with my bot's id
I'm getting 403 Forbidden
brb
back
Not in here please
Oh sorry.
Could someone please answer my question?
well @novel carbon im gettint the error 401 and my token it correct but still keeps getting it after i have change the token 6 times
@novel carbon check that the id is the same as the bot the token is for
@arctic arch i still get that error after i have change the token 6 times already π’ not sure why
401
@grizzled agate DM me your token and I'll investigate when I can
@novel carbon 403 is def wrong token, did u try regening it?
Was wondering if anyone saw my PR here https://github.com/DiscordBotList/DBL-Java-Library/pull/6 - it's been 10 days
https://cdn.discordapp.com/attachments/264445053596991498/507835718450544642/unknown.png someone upvoted my bot
https://cdn.discordapp.com/attachments/264445053596991498/507835802886340608/unknown.png but it says they havent
because of cache
take time to update
use a webhook
dont be a brainlet and use the api to check if a user voted
I don't know how to make my own webhook
there is a library
I've asked multiple times
top of your screen
huh
the channel topic
for this channel
in all caps
"API LIBRARIES AND DOCS FOUDN AT <link>"
the library has webhook
I know, but I code in Python and it doesnt say anything about webhooks in the Python docs
alright well best to get googling how to make a web server then
its a better option
omg...
python would work
i already explained why your way isnt working as you expect
yeah, takes time to update
@restive otter that endpoint if for the last 24 hours I think
the voted like 23 minutes before.... @shut ibex
It is possible that the webhook does not send to every vote? Because some votes are not compatibiliser. By my script that retrieves the votes ...
compatibiliser? do you mean compatible? all the votes sent through webhooks are in json form so as long as you're able to use json, you should be fine
Does DBL use cookies?
yes
Hmm
Welp https://discordbots.org/api/bots/yourbotid/stats doesn't work
and
https://discordbots.org/api/bots/stats
does work
/stats without id isn't a thing afaik
if you can't use /stats you can post without /stats
If you send a POST request to it, trying to post ur server count, it'll work
So, It seems that it takes a couple of minutes to actually detect if a user has voted, is this going to be fixed or is this staying the way it is?
As when users vote, they have to wait like 3 minutes before getting access to vote restricted commands
hmm
webhooks right?
Would be cool if it was instant and yeah, webhooks
alright
Why does the api keep on rejecting my POST request to the stats endpoint? My token is correct, and my bot's ID is correct.
It will not work!
If I try https://discordbots.org/api/bots/stats it gives a 400. If I try https://discordbots.org/api/bots/mybotid/stats it gives me a 403.
and yes I replaced mybotid with my bot's id.
I also made sure to include headers!
("Authorization","mytoken")
and yes, I read the docs.
@novel carbon 403 means wrong token
No it's not
I JUST copy/pasted it from the site.
It's your DBL token not your discord token right
You're sure it's the correct bot?
It worked. I figured it out.
help me using webhooks
https://discordbots.org/bot/:ID/edit my app
in webhook i added webhook url & set auth
but it not posted anything
i added this url
dbl webhooks arent compatible with discord webhooks
you will have to create your own webhook server
whatever programming language you're using to make your bot probably has a webserver package/dependency/module you can use
nodejs
then you can use the basic http server (require("http")) or express (npm i express and require("express"))
or any other webserver of your choosing
i have express
yes that probably works
Is there any way to search for users by their username thru the api?
Afaik, no
Who wanna join my great discord sever
Nobody
yes true

i dnno
any good api's
wrong channel
const DBL = require('dblapi.js');
const express = require('express');
const http = require('http');
const config = require(`${process.cwd()}/config.js`);
const app = express();
const server = http.createServer(app);
const dbl = new DBL(config.dbltoken, { webhookAuth: 'Password', webhookServer: server });
const hook = new Discord.WebhookClient('ID', 'Token');
dbl.webhook.on('ready', hook => {
console.log(`Webhook running with path ${hook.path}`);
});
dbl.webhook.on('vote', vote => {
hook.send(`User with ID ${vote.user} just voted!`)
console.log(`User with ID ${vote.user} just voted!`);
});
app.get('/', (req, res) => {
res.sendStatus(200)
});
this not sending even user voted help
is it listening
@ripe estuary can you post the webhook link on your bot page?
I don't see you even listening on a port, though
https://i.imgur.com/7nGkP0F.png
hoping this isn't purposeful
@mystic wing
π€¦
who pinged
by making one
no
https://discordapp.com/channels/470207676052144128/
Lol. They just said. You need a URL that points to your server, @ripe estuary
discord webhook url points to my server
??
const DBL = require('dblapi.js');
const express = require('express');
const http = require('http');
const config = require(`${process.cwd()}/config.js`);
const app = express();
const server = http.createServer(app);
const dbl = new DBL(config.dbltoken, { webhookAuth: 'Password', webhookServer: server });
const hook = new Discord.WebhookClient('ID', 'Token');
dbl.webhook.on('ready', hook => {
console.log(`Webhook running with path ${hook.path}`);
});
dbl.webhook.on('vote', vote => {
hook.send(`User with ID ${vote.user} just voted!`)
console.log(`User with ID ${vote.user} just voted!`);
});
app.get('/', (req, res) => {
res.sendStatus(200)
});
are you listening on a port?
app.get('/dblwebhook', function (req, res) {
res.send(req.params)
})
will this work?
yes its says listening
i honestly hate people that just can't understand stuff
i pointed to dbl \π
set your webhooks URL on your page as the IP and port your listening to
i don't know ip but port 5500
server.listen(5500, () => {
console.log('Listening');
});
you need to work out your hosts IP then
127.0.0.1 = ip?
tony u have alot of patience
Sorry l'll stop this l'll try \π¦ Thank you for Help \β₯
shrug
@app.route('/hook', methods=['POST'])
def votes():
request.data = request.data.decode("utf-8")
user_id = request.json['user']
cur.execute("UPDATE users SET voted=(%s) WHERE u_id = (%s)", (False, user_id));
conn.commit()
cur.close()
print(f"Received this: {request.data}")
return "", 200```
I have this as the webhook in my Linode VPS, but when I test it with ``http://ip:port/hook`` nothing happens
specifically http://linode_public_ip:5000/hook
It works when I use this url http://127.0.0.1:5000/hook
.
So for the webhook url
what do i use?
am kinda confused on that
as a discord webhook dont seem to work
a url to your own webserver
port is frm what?
the port your webserver is listening on
ok
if your server is listening on port 5000
ok
then you should be able to use 80 (for unencrypted http) or 443 (for encrypted http/https)
which is the standard
what you recommend?
probably get a certificate and use 443
mhm
then if you make a website later people can access it without typing in a port
could i use a couldflare certificate?
what u using?
oh lol
just not all the time
mhm thats confusing since i tried doing my ip in cloudflare and said enter a domain am prob just dumb tbh
if the cloudflare certificate doesn't work, try using let's encrypt
oh for cloudflare you need a domain for which you can edit the nameservers
if you plan on making a website at some point and want that sweet green padlock, use lets encrypt
otherwise port 80 should work fine
(note that you will have to start your bot with sudo or root permission if you want to use 80 or 443)
what node express no i dont think so
ok
ok started my bot with that
hello again
seems to work
yeh and port 80
what?
what did you use to start it on port 80
yeah
is what right
if you mean the command yes, thats correct
but you need to edit the code to create a webserver that listens on port 80
if you need help with the code to make one just ask in #topgg-api or #development
ok gotcha ty ma man
yw
Please add discord webhook support for bot votes, it would be very good !
thank you
you can always make your own webserver and trigger the discord webhook
quick question i was in the wrong section, can we vote using commands in discord?
tru
Turkish
Snekfetch is deprecated tho
If I want to use webhooks for voting, do I have to create my own webserver to do so or is there an easier way?
create your own
K thx
this would be correct right?
https://discordbots.org/api/bots/${bot.user.id}/check?userid=${user.id}
?userId
@indigo trout if you are using js then dblapi.js can handle it for you
How would I authenticate myself when using the /bots/{bot.id?}/check endpoint
because it "Requires authentication."
Does that mean i need to be logged in
set token
yes
@marble urchin wrong token
okay
mmm
I regenerated the token
but I still have the forbidden error
I copy pasted the code on the python doc
https://discordbots.org/bot/506395536778330115 is my server count appearing here?
no
okay
dunno what's up there
async postCounts() {
const { botlists } = require('../../config.json');
try {
// discordbots.org
await this.util.p({
url: `https://discordbots.org/api/bots/${this.user.id}/stats`,
method: 'POST',
headers: {
'Authorization': botlists['discordbots.org']
},
body: {
server_count: this.guilds.size
}
});
} catch(err) { console.log(err); }
}
honestly, can someone try explain what's up here
it won't post
but no errors come out in logs
details correct?
You use node-fetch right?
You know that this lib dont reject on 3xx-5xx status codes?
@humble bison
axios does
Nope
Axios does reject on 500 codes



