#topgg-api

1 messages · Page 124 of 1

hot axle
#

dblapi.js is deprecated

#

They should change the examples on the api page KEKW

#

You should use @top-gg/sdk instead

rare quiver
#

oof okay

timber bear
#

Benim Botum 50 Sunucuda Var

#

Ama Sitede 3 Sunucu Diye Gözüküyor

#

Nasıl Düzeltebilirim

restive otter
#

How i can give me a API of Youtube

odd carbon
#

Hello

#

is there a Java API?

#

I really need it

hot axle
#

JDA

odd carbon
#

no no

hot axle
odd carbon
#

I am already using JDA

hot axle
#

KEKW nvm

odd carbon
hot axle
#

pretty sure theres one

odd carbon
#

any idea where it's docs?

hot axle
#

yeah there is

flint olive
#

hey, does anyone have the code for how to do the bot api without cogs?

celest solstice
#

Yarım saat oldu koyalı %50 de

glossy mantle
#

yarım saatde %50 zor bu arada minimum 9 gün sürüyor zaten her gün %10 oluyor

flint olive
#

hey, does anyone have the code for how to do the bot api without cogs?

restive otter
#

What's a good interval for posting guild stats?

#

5 mins maybe

loud flint
#

I want to give rewards when users vote using the vote api. Is this possible?

rain heart
restive otter
#

ohh i won't be hitting that

rain heart
#

though 5 minutes is definitely acceptable

rain heart
regal swallow
#

vote = await self.dblpy.get_user_vote(user_id=ctx.author.id)

Why is this returning false? When the user voted?

rain heart
#

Testvotes do not have a impact in that

regal swallow
#

I voted for my bot.

#

Didn't do test.

#

Nvm found the issue. Thanks @rain heart

loud flint
#

@rain heart i setup webhook send test but not show vps console

rain heart
#

did you enter the webhook url in your bot page settings correctly?

loud flint
#

yes

rain heart
#

Dm me the url you entered

#

Your webhook url doesn't seem to work, make sure that it is running etc

#

check for the logline that says "webhook started" or something similar

loud flint
#

@rain heart

rain heart
#

Make sure that 8000 isn't blocked

loud flint
#

tcp6 0 0 :::8000 :::* LISTEN

#

@rain heart

rain heart
#

do a wget in your vps through localhost, wget http://localhost:8000/dblwebhook

fast agate
#

do u use python 3.9?

#

or +

#

?

flint olive
#

Python 3.9

#

@fast agate

fast agate
#

Pyfthon 3.9 isn't supported by dblpy yet

flint olive
#

O

#

Shoot

#

When will they?

fast agate
#

for this reason it doesnt works

fast agate
flint olive
#

Bruu

#

That sucks

fast agate
#

u can use 3.8.6 or lower...

flint olive
#

K well do u have the code for that?

fast agate
#

yup

flint olive
#

W/ no cogs?

fast agate
#

I dont use cogs and it works for me

#

wait

flint olive
#

Oh ok

#

What

fast agate
#

I put this con my code

#

look

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

    def __init__(self, bot):
        self.bot = bot
        self.token = 'bot token' # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes

    async def on_guild_post():
        print("Server count posted successfully")



client.add_cog(TopGG(client)) 
#

and it works

flint olive
#

Thx man

fast agate
#

I dont use cogs on my bot

#

my code is like

flint olive
#

Do u know how I can change the python file version repl.it?

fast agate
#
client = commands.Bot(command_prefix='//', intents=intents)
prefix = "//"
Client = discord.Client()


@client.event
async def on_member_join(user):
bla bla bla

@client.event
async def on_ready():

@client.command()
async def lang(ctx, lang=None):

@client.command(aliases=['helpme'])
async def help(ctx):
    guild_id = ctx.author.guild.id

@client.command(aliases=['8ball'])
async def _8ball(ctx, *, question = None):



client.run('dasdasdadas') 
flint olive
#

Bruh yeh I have my bot

fast agate
#

but

flint olive
#

?

fast agate
#

try

flint olive
#

I can’t rn

rain heart
#

@loud flint could you try test-voting again? there had been an issue with voting recently

fast agate
#

try to put this on the top ogf ur code

#

maybe works

#

wait

flint olive
#

I already have that code for it to start

fast agate
#

#!/usr/bin/python3.8.6

flint olive
fast agate
#

yep in ur blt code

#

on the top or ur code

fast agate
flint olive
#

No the code

#

Now that I found out I cannot use 3.9

#

So imma try it out tomorrow

#

Thx for ur help

fast agate
fast agate
frozen mica
#

can i use topgg sdk for server vote?

willow spindle
#

yes

frozen mica
#

ty

restive otter
#

ch!help

restive otter
#

[H] Dam od 650 gredytów do 1000 [W] za fenneca

rain heart
#

@restive otter this ain't a trading server

mellow matrix
#

Guys

#

How can i make vote log

fast meteor
#

ive got 169 votes this month, however when i do a get request on the api for my bot's votes, with limit 1000, it returns 115 votes

rapid kettle
#

could be doubled votes over the weekend

fast meteor
#

ahh

#

yes

#

yeah probably

#

thanks

rare quiver
#

hey since the dblapi.js getting deprecated how do I make a vote logging system?

#

Would it be the same code as before with the new @top-gg/sdk

willow spindle
#

read docs

rapid kettle
#

you'd need to setup an express server

rare quiver
#

okay

rapid kettle
#
const express = require('express')
const Topgg = require('@top-gg/sdk')

const app = express() // Your express app

const webhook = new Topgg.Webhook('topggauth123') // add your top.gg webhook authorization (not bot token)

app.post('/dblwebhook', webhook.middleware(), (req, res) => {
  // req.vote is your vote object e.g
  console.log(req.vote.user) // 221221226561929217
}) // attach the middleware

app.listen(3000) // your port```
rare quiver
#

yup gotcha tysm! Heart4

rapid kettle
#

np

loud flint
#

I gave up without coding the api service because the problem continued @rain heart

restive otter
bold quiver
#

@rapid kettle Hello, my system no fonctionnaly (i am french, sorry)

#

I have put what is written in the documentation.

latent mirage
#

@restive otter well you put the url your bot listens on in the url and something secret in authorization

#

you need a http server on your bot and have it accessible from the internet so top.gg can make POST requests to it

#

when you receive a POST you check if the authorization header is what you put in the authorization field and then you know the request is coming from top.gg

#

this is how webhooks work, check a tutorial on youtube or read up on how webhooks work

cyan wyvern
#

why the webhooks is not working?

#

🤔

latent mirage
#

@cyan wyvern something is not set up properly probably

cyan wyvern
#

im a python user

latent mirage
#

i think it's serverip:port/dblwebhook

bold quiver
#

Can someone help me with webhooks?

cyan wyvern
cyan wyvern
#

but idk it added / itself

latent mirage
#

yes that looks correct

cyan wyvern
#

but it not work

#

🤔

latent mirage
#

well something else is wrong then

cyan wyvern
latent mirage
#

haha you have to put an actual IP not serverip

#

like 128.1.2.3

cyan wyvern
#

yes

#

because i don't want to show in here

latent mirage
#

i see

bold quiver
#

Can someone help me with webhooks? (sorry for repeat the question)

latent mirage
#

@bold quiver say what you need help with, what you tried, why it didnt work

#

otherwise nobody can help

#

if you can't answer those 3 questions you can probably help yourself by trying something first

bold quiver
#

code for page js : ```js
this.get('/', function(req, res) {
res.status(200).render('votes.ejs', {
config: req.config,
bot: req.bot,
user: req.user,
is_logged: (req.isAuthenticated())
});
});
this.post('/', webhook.middleware(), (req, res) => {

        console.log(req.vote.user) // 221221226561929217
        
    });
#

Sorry, my problem is that when I do a test with the site, this post well on my site, but no action is done, it just post (no console.log is done)

#
const Topgg = require('@top-gg/sdk');
const webhook = new Topgg.Webhook(config.bot.dbl.authorize);```
restive otter
#

what about js? how to do it too??

restive otter
#

where i can get token for topgg-autoposter?

#

oh i have

hot axle
#

go to the api page and go to "my bots" or something

restive otter
#

Why does top.gg api sometimes 404. I assume this isn’t a problem on my end as it only happens every now and then

ripe ether
#
const tk = "my_token"

const dbl = new DBL(tk, { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
  console.log(`Webhook running`);
});

dbl.webhook.on('vote', async vote => {
  const time = Math.floor(new Date().getTime() / 1000)
  votes.set(vote.user, time);
  console.log(`${vote.user} voted!`)
});``` I tried using this, but it is not receiving votes, why?
restive otter
#

use new library for js

worn silo
#

helo

#

so

#

im trying to make a currency system for my bot

#

and when i do npm i quick.db in terminal i get a bunch of errors

#

and i dont get quick.db anywhere

restive otter
worn silo
#

ok

dusty roost
#

i've followed the new d.js webhook nearly exactly to the T and it still doesn't work

#

d.js v12:

const Topgg = require(`@top-gg/sdk`);

const webhook = new Topgg.Webhook(config.WEBHOOK_AUTH);

const api = new Topgg.Api(config.DBL_TOKEN);

app.post(`/dblwebhook`, webhook.middleware(), async (req, res) => {

  let vote = req.vote;
  console.log(`User with ID ${vote.user} just voted!`)
});

is something wrong here

restive otter
dusty roost
#

what

restive otter
dusty roost
#

are you using glitch or do you have a server

restive otter
#

Glitch

dusty roost
#

then your webhook url is http://your_project_name.glitch.me/dblwehook

restive otter
#

Ooh

dusty roost
#

yep

#

make sure you install the correct packages

restive otter
#

Wait let me do first

dusty roost
restive otter
#

Yes i install

#

@dusty roost can u help me here ?

dusty roost
#

why are you doing this on your phone

restive otter
#

Its 3am in the morning why

#

Thats why im in phone

dusty roost
#

it'd be easier if you just waited until you got on a computer

restive otter
#

Oh apepesadrain

#

Goodnyt

dusty roost
#

👋

#

d.js v12:

const app = express();

const Topgg = require(`@top-gg/sdk`);

const webhook = new Topgg.Webhook(config.WEBHOOK_AUTH);

const api = new Topgg.Api(config.DBL_TOKEN);

app.post(`/dblwebhook`, webhook.middleware(), async (req, res) => {

  let vote = req.vote;
  console.log(`User with ID ${vote.user} just voted!`);
});

app.listen(5000, function() {
  console.log(`Listening on port 5000`);
});

is something wrong here

restive otter
rapid kettle
#

not by the looks of it @dusty roost

dusty roost
#

it doesn't work at all

#

i haven't changed anything in my bot's top.gg settings

#

no errors or anything

#

it just doesn't work

rapid kettle
#

what doesnt work?

dusty roost
#

the voting event

rapid kettle
#

did it work before?

dusty roost
#

yep

#

randomly stopped working yesterday, and this morning i found out they changed the api

rapid kettle
#

weird

dusty roost
#

oh i fixed it

#

elsewhere i had an express app listening on another port

#

guess that was the issue

#

still annoyed that they changed it for seemingly no reason

rapid kettle
#

they didn't change the api

#

they changed the lib

dusky spoke
#

which one is the updated library now?

rapid kettle
#

@waxen widget-gg/sdk

#

fuck off discord

dusky spoke
#

lol

#

thanks`

rapid kettle
#

np

odd carbon
#

what is the token and bot Id?

#

how to get them?

worn silo
#

that's simple

#

so you made a bot right?

odd carbon
#

Yes

#

And coded it

#

But

worn silo
#

wait

#

if you coded it

odd carbon
#

It is not accepted yet

worn silo
#

then you should know this

#

??

#

wait

odd carbon
#

It said token

#

Not bot token

#

So im confused

worn silo
#

screenshot

odd carbon
#

In java library

worn silo
#

screenshot what it says what to do

odd carbon
#

This

worn silo
#

ohh

#

that's not neccesary

odd carbon
#

I want to check if the person voted

worn silo
#

ok

#

i recommend trying after it's accepted

odd carbon
#

Ok

worn silo
#

because actually

#

you can ONLY do that after it's accepted

#

anyway

#

i came here because of another problem

#

so for my bot i'm making a currency system

#

and im using quick.db like basically everyone does

#
        console.log('someone did ;bobux command')
        let user = message.mentions.users.first() || message.author;

        let bobux = db.fetch(`money_${message.guild.id}_${user.id}`)

        if (bobux === null) bobux = 0;

        const embed = new Discord.MessageEmbed()
        .setColor('#f0ff00')
        .setTitle(`${user.username}'s bobux`)
        .setDescription(`***${bobux} bobux***`);
        return message.channel.send(embed);```
#

and i made a command to check your balance, it'll always be 0 because i haven't made any way to get money

#

it works

#

but i tried to make this command

#
        let bobuxisyouhave = 0;
        if (bobux < 500) bobuxisyouhave = 0;
        else bobuxisyouhave = 1;
        let scammedBobux = Math.floor(Math.random() * 500) + 1

        if (bobuxisyouhave === 1){
            db.subtract(`money_${message.guild.id}_${message.user.id}`, scammedBobux)
            const embed = new Discord.MessageEmbed()
            .setColor('#ff0000')
            .setTitle(`haha get scammed`)
            .setDescription(`you lost **${scammedBobux} bobux** for being scammed lol\nnow you have **${bobux} bobux**`);
            return message.channel.send(embed);
        }else{
            db.subtract(`money_${message.guild.id}_${message.user.id}`, scammedBobux)
            const embed = new Discord.MessageEmbed()
            .setColor('#f0ff00')
            .setTitle(`noob`)
            .setDescription(`lol you noob don't even have 500 bobux not even scammable`);
            return message.channel.send(embed);
        }
    }```
#

and in terminal when i do the command it says that 'bobux is undefined'

#

i think the problem is that bobux is defined only in one command

#

so it can't be in others

#

wait

#

lemme try something

hot axle
#

ah yes

#

the bobux currency

worn silo
#

lol

#

ok but new error

#

i changed it so that this chunk of code:

let bobux = db.fetch(`money_${message.guild.id}_${user.id}`)
if (bobux === null) bobux = 0;``` is at the near start of the command handler
#

and the ;bobux command still works

#

but new error when i do ;freebobux

median ocean
#

what is your error ?

#

ok

#

replace 'user' by 'author'

worn silo
#

to you mean?

median ocean
worn silo
#

ok

odd carbon
#

I code in JDA so i cant help u

worn silo
#

now it says the same thing except instead of id it says author

median ocean
#

can i see the updated code ?

worn silo
#

one sec

#

waaaaaaaaaait

#

gWAIT

#

i figured what was wrong

#

yayyayayaya

#

now it work

#

s

median ocean
#

noice

median ocean
worn silo
#

basically same thing i think

median ocean
#

oh

#

but better-sqlite3 uses SQL syntax to interact with the database

worn silo
#

whatverer

median badger
worn silo
#

i needed api support...

#

also no point i already fixed

restive otter
#
const app = express();

const Topgg = require(`@top-gg/sdk`);

const webhook = new Topgg.Webhook(config.WEBHOOK_AUTH);

const api = new Topgg.Api(config.DBL_TOKEN);

app.post(`/dblwebhook`, webhook.middleware(), async (req, res) => {

  let vote = req.vote;
  console.log(`User with ID ${vote.user} just voted!`);
});

app.listen(5000, function() {
  console.log(`Listening on port 5000`);
});```
#

@dusty roost can u help me now? im in pc :>

#

btw sry for the ping ;v

dusty roost
#

ok so on the top.gg bot edit page, put an auth code

#

it can be anything

#

but the auth code in here:

const api = new Topgg.Api(your_auth_code);
restive otter
#
const app = express();

const Topgg = require(`@top-gg/sdk`);

const webhook = new Topgg.Webhook(config.WEBHOOK_AUTH);

const api = new Topgg.Api('I Will Put My Auth Code Here? Like 123?');

app.post(`/dblwebhook`, webhook.middleware(), async (req, res) => {

  let vote = req.vote;
  console.log(`User with ID ${vote.user} just voted!`);
});

app.listen(5000, function() {
  console.log(`Listening on port 5000`);
});```
dusty roost
#

yes

restive otter
#

ill put this in main file or make new file?

dusty roost
#

main file

restive otter
#

kk

#

@dusty roost const app = require('express'); or const app = express();

#

app.post(/dblwebhook, webhook.middleware(), async (req, res) => {
^
TypeError: app.post is not a function

dusty roost
#

const express = require(`express`)

restive otter
dusty roost
#

express should already be downloaded on glitch

restive otter
#

ye

dusty roost
#

then const app = express();

restive otter
#

express is not defind

#

;v

dusty roost
#

then just npm i express

restive otter
#

const app = express();
^
ReferenceError: express is not defined

#

still

#

hmmm.

dusty roost
#

const express = require(`express`); ?

restive otter
#

const app = require("express");

#

this one ?

dusty roost
#

no

restive otter
#

i didnt put express

dusty roost
#

you need to define express before

#

then const app = require('express')

#
const express = require(`express`);
const app = express();
restive otter
#

const express = require('express')

const app = express();

#

done

#

what ill put here?

const webhook = new Topgg.Webhook('here :<');```
dusty roost
#

that's actually where you put your auth code

#

you put the top.gg token in the other one

restive otter
#

okk

crimson pike
#

is the topgg api ez

restive otter
#
const webhook = new Topgg.Webhook('Auth COde Here?');

const api = new Topgg.Api('Token Here?');```
dusty roost
#

yep

restive otter
#

kk

crimson pike
#

what can you do with the api

dusty roost
restive otter
dusty roost
#

bad

restive otter
#

kk

dusty roost
#

wait no

#

https://your_project_name.glitch.me:5000/dblwebhook

#

mb

restive otter
#

what?

#

kk

#

let me put 5000 first

dusty roost
#

pretty sure you can use the 5000 port on glitch

restive otter
#

right?

dusty roost
#

yep

restive otter
#

kk

#

and its done?

dusty roost
#

try it

#

click "test"

crimson pike
#

it would be port 443 for https

dusty roost
#

check glitch console

#

and yeah it might be http instead

restive otter
#

log?

#

console log?

dusty roost
#

yeah

restive otter
#

iget nothing :V

#

[ Event Loaded: ready.js ]
ZeroOne#3871 Is Now Ready !

dusty roost
#

does it say "Listening on port 5000"?

restive otter
#

no its not

#

only [ Event Loaded: ready.js ]
ZeroOne#3871 Is Now Ready !

crimson pike
#

it's not supposed to with glitch

#

did you add app.use(8080) at the end @restive otter

restive otter
#

noo

#
  console.log(`Listening on port 5000`);```
#

i use this

crimson pike
#

okay, do you have } before the ;

restive otter
#

app.listen(5000, function() {
console.log(Listening on port 5000);
});

#
app.listen(5000, function() {
  console.log(`Listening on port 5000`);
});
crimson pike
#

did you click run

restive otter
#

huh

#

what run?

crimson pike
#

or go to the console and enter node index.js

restive otter
#

its automatic running

crimson pike
#

the ui is way easier to use than Glitch

restive otter
#

why?

crimson pike
#

and you also get access to way more features than Glitch offers

restive otter
#

Listening on port 5000

#

i see the listening on port 500

#

5000

#

if i run it again

restive otter
dusty roost
#

change the webhook url top.gg on top.gg to http://your_project_name.glitch.me:5000/dblwebhook

restive otter
#

okk

#

k done

dusty roost
#

now click test

restive otter
#

done

dusty roost
#

does it say anything in the logs

restive otter
#

and i check the log

restive otter
dusty roost
#

you should delete that

restive otter
#

ye

#

and i will regen the token too

dusty roost
#

but yeah that looks right

restive otter
#

reeeeeeeeeeeeeeee

#

this is weird ;v

dusty roost
#

do you have app.listen anywhere else in your code

restive otter
dusty roost
#

uhh then idk

restive otter
#

aaaaaaaaa weird

dusty roost
#

you sure it's not listening on another port somewhere? that was an issue for me

restive otter
#

yes im sure

#

only listening in port 5000

keen vale
#

sorry i dont understand

rain heart
#

read the topic

#

of this channel

keen vale
#

this is a error?

jaunty plank
#

nope, you need to post your server count using the api.

keen vale
#

what is a api?

#

xd

jaunty plank
#

its how programs talk over the web, and locally.

#

we are using the discord api to talk right now, so does your bot to function.

keen vale
#

ohhh thanks

#

but i have a create a api??

#

o

jaunty plank
keen vale
#

ok

#

ohh i have a question

#

in the api

#

say a token

#

is a token for mi bot? or i generate a token?

jaunty plank
#

you use the api key/token provided by top.gg

keen vale
#

ohh

#

ok in the api says a library javascript
I have to enter the code that tells me no?

restive otter
#

helpppppppppppppp me in api im glitch user :<

jaunty plank
keen vale
#

ohh thanks

#

i have a new question

#

forget it i solved it

#

ehh h

#

error

#

helpppp

restive otter
#

check pins ;>

keen vale
#

ok

#

men

#

what is the command require?

#

is it the same code ?? if not, please send it to me

rain heart
#

read the documentation

#

that is mentioned in the url on this channel's topic

#

if you're unable to understand it, you're not ready to do that yet

keen vale
#

i am not ready :c

restive otter
#

same ;c

keen vale
#

:c i dont understand very god

#

i am trash for bot developer :c

desert gorge
#

Seems like my bot fails to get user votes
After it got kicked from here
Is it a temporary issue or I should fix it myself in the bot code?

keen vale
#

i need a server count for mi bot

restive otter
#

me too but its not easy ! :<

keen vale
#

:c

jaunty plank
#

just use the code examples

jaunty plank
restive otter
#

lol

keen vale
#

i have a api xd

restive otter
jaunty plank
#

why do you have an api for making a request to an api 🤔

keen vale
#

ehhh a im wrong

#

is a token

#

no a api

jaunty plank
#

yeah, youll need to use that in the code example

keen vale
#

yeah

desert gorge
#

But maybe I'm wrong

keen vale
#

tomorrow i need create a webhooks

jaunty plank
keen vale
#

for the votes

#

help

#

what?

jaunty plank
#

:ID would be your bots id

keen vale
#

ahh ok thanks

fringe cove
#

how can I make my bot dm someone once they voted for the bot?

fringe cove
#

@sour ore

proper sapphire
#

hi chat

rain heart
#

and authorization is your webhook authorization

fringe cove
#

yeah

rain heart
fringe cove
#

but where can i get my webhook url?

#

its discord's webhook?

rain heart
#

It is not discords webhook

#

it is a webhook you need to make yourself

fringe cove
#

where tho?

rain heart
#

in your bots code

#

or wherever you would like to handle votes

#

for example in a separate bot, sending it in a voting channel for example

fringe cove
#

well

#

i did do this:

dbl.on.webhook('vote', (vote) => {
       console.log(`${vote.user} voted for me!`)
       
       const webhook = new Discord.WebhookClient(some numbers here, "from discord's webhook idk")
       webhook.send(this.client.embed().setTitle('Upvote!').setDescription(`I got voted by ${vote.user} on [top.gg](https://top.gg/bot/mybot'sid/vote)`))

     })```
#

but well where can I get the url?

#

do i console.log it?

#

or?

rain heart
#

It is your servers ip the bot is running on

#

with the webhook port

fringe cove
#

ah

#

so my IP address ig?

rain heart
#

something like http://91.11.11.1:5000/dblwebhook for example

#

Your servers ip address, yes

fringe cove
#

ahh okay

#

ty

#

what if i use heroku for hosting?

rain heart
#

Not sure how it was on heroku, but i think your project url

#

not sure tho

fringe cove
#

okay ty

#

anyone know how I get my server ip on heroku?

sullen nymph
#

You have a project URL that points to your Heroku application

restive otter
fringe cove
#

oh okay

#

ty

restive otter
#

because you need to run the app with web dyno on

fringe cove
#

how do i turn web dyno on?

#

npm start or?

restive otter
fringe cove
#

okay

#

i turn both node . and npm start on?

restive otter
#

yes

#

but when its inactive it will turn off

fringe cove
#

okay let me see

restive otter
#

oh btw you just leaked ur ip so delete the pics

#

this too

fringe cove
#

i,

restive otter
#

what was the crash reason

fringe cove
#

this i think

restive otter
#

no like above that

#

it shows why it crashed

fringe cove
#

will this help?

restive otter
#

nope

#

idk why the app crashed sooo

fringe cove
#

oop

#

okay

#

ty for the help

sullen nymph
#

Enable the web dyno

fringe cove
#

in resources?

#

i did

#

i enabled npm start

sullen nymph
#

I didn't read the conversation, pardon

fringe cove
#

its okay

#

np

#

do you know the cause?

#

@sullen nymph

sullen nymph
#

Nope, generally not familiar with Heroku either

fringe cove
#

okay

#

anyone know the cause of that error?

restive otter
#

ok damn i understand lol

restive otter
#

YEEEEEEEEEES FINALLY!

restive otter
#

how to check total inv in req.vote.???

gusty bolt
#

Can you help me how I put my webhook to work when someone votes?

#

I've tryed this

const DBL = require('dblapi.js');
const { dbltoken } = require('./config.json')
const dbl = new DBL(dbltoken, { 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 => {
client.guilds.get('736544975969583197').channels.get('790560884258111508').send(`User with ID ${vote.user} just voted!`)
})

And there wasn't any error.

#

But no message posted.

restive otter
#

use new lib for js

gusty bolt
#

Aight thanks

fringe cove
#

@restive otter could my error be that its just like samu's code?

restive otter
#

¯_(ツ)_/¯

gusty bolt
#

Now I have the other, but how do I get to check if some1 upvoted?

uncut oxide
#

Uhh can anyone suggest me what's the best Corona API?

#

And weather api

fallen thistle
#

Offtopic

restive otter
#

?

restive otter
#

How To Check Total Invites ?? Using Command?

iron merlin
#

I want to make a voting reward system for my bot, how would I contact the top.gg api?

hot axle
iron merlin
#

Ohk

#

Thanks

pulsar flume
#

hey, I wanted to send a console.log to the user who voted my bot in top.gg I am using the dbl and top.gg package and read the docs and did the same, but I keep getting this error in console

#

error code=H14 desc="No web processes running" method=POST path="/dblwebhook" host=greedow5148.herokuapp.com request_id=615e3c87-7446-4b22-9ceb-fa4b2d4c80ae fwd="165.22.130.154" dyno= connect= service= status=503 bytes= protocol=http

#

can someone help me fix it? pls

#

🙂

hot axle
#

your app must run on a web process, not worker

pulsar flume
#

Oooo

#

so how to add a web process

#

in heroku

#

@hot axle

tribal sky
#

for this do we make a random one?

#

or do we get it from somewhere

pulsar flume
#

random one

#

@tribal sky

tribal sky
#

oh ok

hot axle
#

and use it to run the web server

pulsar flume
#

Oook

#

ty

willow oracle
#

Hi

#

how i can check if user vote or not?

pulsar flume
hot axle
#

yea

#

but add a space after web:

pulsar flume
#

instead of

Worker: node index.js

hot axle
#

and its lowercase

pulsar flume
#

or add both

hot axle
#

you can have both in the same file

pulsar flume
#

ook

#

let me try

hot axle
#

but

pulsar flume
#

yes...

hot axle
#

one of them should just run the bot

#

the other one should just run the server

pulsar flume
#

Oooo so u mean this is the file

Procfile

Inside the file:

Web: node index.js
Worker: node index.js

#

upvote so is this fine?

hot axle
#

i dont think so

#

like

#

you should have two parts to your project

pulsar flume
#

two parts? I don't understand

#

🙁

hot axle
#

if they both run the same file you'll have two instances of the bot running

#

split the server and the bot into separate files or something

pulsar flume
#

so I will create two apps

#

in heroku

#

one should run worker

#

And other the web

hot axle
#

well you can create two apps

#

but like

#

if its something this small im pretty sure you can just do it in one app

pulsar flume
#

so one the first, I will add
Worker: node index.js

The second app
Web: node index.js

#

so wont my bot reply twice?

hot axle
#

so you'll use two apps?

pulsar flume
#

How can we do in one app?

#

I guess one app is easier

hot axle
#
worker: node my-bot.js
web: node server.js
#

thats what i mean

#

one process runs the bot

#

the other one runs the server

pulsar flume
#

Ooo

#

so what will be in server.js

hot axle
#

idk

#

its an example

pulsar flume
#

Hmm

hot axle
#

you should code your server

#

in another separate file

pulsar flume
#

I just want to recieve votes from top.gg

#

and console.log them

#

but it comes with a error

#

in heroku logs

hot axle
#

o

pulsar flume
#

so how do I fix the error

hot axle
#

yeah that happens because you don't have any web processes yet

#

it shouldn't happen after you enable the web process from your procfile

pulsar flume
#

so I will keep the worker

#

Also

#

And add the web

hot axle
#

yea

pulsar flume
#

what will be in the web?

Web: node index.js

#

so is this fine

hot axle
#

your server file

pulsar flume
#

I dont have server file

#

I just want to check top.gg votes

#

For my bot

hot axle
#

then how are you running your webhook

pulsar flume
pulsar flume
#

for seeing votes

#

And did the same

#

but got this error in heroku

hot axle
#

but like

#

what have you coded

mint fractal
#

sorry, but could someone help me with the webhook? how did I create the link exactly?

pulsar flume
#
const dbl = "new token", { webhookPort: 5000, webhookAuth: 'pass123' })

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!`); 
});

module.exports.config = {
    displayName: 'voting',
    dbName: 'greedow-2',
  }
#

this is the xode

hot axle
#

dblapi.js is deprecated doubt

#

use @top-gg/sdk

red glacier
#

so what im looking at it has in the examples class TopGG(commands.cog) what do i use if i dont use cogs?

red glacier
#

What im wanting to do is get a guild counter up to top.gg

red glacier
#

@ me with an answer please

forest shard
#

@red glacier send the GitHub link

#

for the code

red glacier
#

My bot code?

forest shard
#

no

red glacier
#

Ok good haha, I dont have my code on git

#

Yeah give me a second

#

I havent looked too much at the github, but it seems the same as the example in the docs

#

So same question

forest shard
#

@red glacier you can use classes without cogs

#

btw

#

just replace @commands.Cogs.listener with “@bot.evet”

red glacier
#

Ok

#

Ok

#

And that last bit

forest shard
#

also

#

it’s pretty easy to switch to cogs

red glacier
#

The def setup(bot) bot.add_cog(TopGG(bot))
Do I just remove add_cog?

red glacier
#

Gonna stay like that till I get bored and try cogs out

#

@forest shard

forest shard
#

ok

red glacier
#

How do I remove the cog

#

In the bot.add_cog thingy

#

Can I just remove it...?

#

@forest shard sorry for another ping haha

forest shard
#

mhm

restive otter
#

I'm trying to figure out how to post my shard count in dbl.py but I can't quite wrap my head around this

jaunty plank
red glacier
#

@forest shard if you can, can you join vc and help me out?

forest shard
#

Can’t rn

red glacier
#

ok

red glacier
restive otter
#

I'm reading the documents and it's not that clear right now

forest shard
red glacier
#

lol

#

and i replaced

jaunty plank
#

guild count is posted with shard count

red glacier
#

class TopGG(commands.cog) with class TopGG()

#

is that a problem, cause it isnt working

restive otter
#

what am i doing wrong lol

red glacier
#

what are shards?

restive otter
#

Shards are a thing that are needed for 2500+ guild bots

#

I'm trying to figure out how to display my shard count

restive otter
#

It basically separates your bot into a lot of different connections for discord

red glacier
#

ok

restive otter
#

Right I can clearly doing something wrong

#

post_shard_count

jaunty plank
#

why not just use post_guild_count

#

like the page shows

restive otter
#

already am

jaunty plank
#

and your using the shard_count parameter?

restive otter
#

no

jaunty plank
#

then do that

#

lol

restive otter
#

I realize what I've done wrong

#

Thanks woo I think I'm dumb as a rock wheeze

jaunty plank
#

npnp, we all do it

restive otter
#

yeah thanks though seriously

jaunty plank
#

pretty sure i drive shiv crazy with my questions.

restive otter
#

well we are a community that help each other so

#

I've helped people too it goes around and comes around doesn't it

jaunty plank
#

100%

restive otter
#

we are all just equally dumb together

red glacier
#

haha

#

Ok so can somebody help me with getting a guild counter working

#

im being a dum dum

restive otter
red glacier
#

well im trying to put the code from with autopost

#

and i dont have cogs

#

so i have to edit it

#

and im not sure how to change all of it

restive otter
#

you can make a cog quickly it's not hard don't worry

red glacier
#

do i need a cog for the counter?

restive otter
#

make a folder in with your main file and then make a file called "gg.py"

#

its easy don't worry

#

I'll walk you through this

red glacier
#

can u join vc?

restive otter
#

it's 2 am for me

#

I'm sorry

red glacier
#

ok

#

its ifne

#

so just make a file called gg.py or any name

#

thats in the same folder as my bot.py

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


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

    def __init__(self, bot):
        self.bot = bot
        self.token = 'dbl_token' # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes

    async def on_guild_post():
        print("Server count posted successfully")

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

use this

#

let me get my actual bot open 1 second

#

so make a folder called anything maybe even just 'cogs'

red glacier
#

ok folder made

restive otter
#

now put that in there in a python file

#

yes

red glacier
#

ok

#

and do i paste that code into the gg.py?

restive otter
#

now you want to just load the cog

#

and you're done

#

yeah

#

it seems overwhelming it's not dw

red glacier
#

how do i load the cog?

restive otter
#

personally I use os

red glacier
#

yeah im fine with a cog

#

just didnt know how haha

restive otter
#

new to python?

red glacier
#

somewhat yeah

restive otter
#

we are supposed to not directly tell you

red glacier
#

started 2 months ago

restive otter
#

but I have no idea how to not wheeze

red glacier
#

ah

#

i see

restive otter
#

anyway since I got no idea

#

add at the top

red glacier
#

i mean

restive otter
#
import os
#

of your main file

red glacier
#

oh ok

#

btw this will work on a pi right?

restive otter
red glacier
#

oh cool

#

so import os

#

then...?

restive otter
#

then

for filename in os.listdir('./pers'):
    if filename.endswith('.py'):
        client.load_extension(f'pers.{filename[:-3]}')
#

change pers to whatever you use

#

for the folder name

#

and then run

#

and thats your guild count

#

=)

red glacier
#

cool

#

I can just put that before the rest of my code right

restive otter
#

I had no idea how to explain this without source code (I probably suck)

#

yeah

red glacier
#

so ./pers = /cogs?

restive otter
#

basically since I didn't do the whole you learn yourself

what you are doing is taking the file and setting up the cog by pulling all .pys in the folder (x)

#

so if you made another file in there you would add the setup and class

red glacier
#

ok

deep gazelle
#

Hey, why does on_dbl_test work, but on_dbl_vote doesnt? discord.py 😅

restive otter
#

and then use @commands.command() not @client.command / @bot.command

red glacier
#

use @commands.command() where?

restive otter
#

so that's an explanation of both cogs and servers

red glacier
#

in the cog?

restive otter
#

not for this

#

it's fine now

red glacier
#

oh ok

restive otter
#

That's me explainging how to cog since it's better for organisation

#

does what I said work?

red glacier
#

one second

#

first does ./pers = /cogs

restive otter
#

so pers

#

is something for my bot

#

change pers to whatever the folder is

red glacier
#

of the cog right

#

not the actual bot

restive otter
#

like "Folder" instead of pers

#

no

#

so one sec

#

you change pers to whatever your folder is called

red glacier
#

ok

#

is in Digibot

restive otter
#

and do that on both mentions of pers

#

yes

#

What?

red glacier
#

(my bot name)

restive otter
#

I don't know what that is it should run

#

doesn't matter

red glacier
#

ok ok

restive otter
#

you need to give it your top.gg token

red glacier
#

yeah i did that

restive otter
#

cool

#

make sure its in "" for a string

#

and now your guild count should have posted hopefullly

red glacier
#

yep

#

ok one sec

restive otter
#

it will update it every 30 minutes

red glacier
#

ok i bet this is just a dumb mis-interpretation, but what folder, do i put as /pers

restive otter
#

no you can put it as anything

#

what did you call the folder with the .py you made for this?

red glacier
#

cogs

restive otter
#

ok

#
for filename in os.listdir('./cogs'):
    if filename.endswith('.py'):
        client.load_extension(f'cogs.{filename[:-3]}')
#

you use this

#

pers / cogs is just the folder name

red glacier
#

oh i was erroring for a udmb reason

#

i was putting this code onto my second bot

#

but this needs to be on my first bot as i can use my second bot to test this with xD

restive otter
#

so if you ever want to code a lot of cogs you can seperate them by changing that

#

and using @commands.command() instead of @client.command()

red glacier
#

ok

#

discord.ext.commands.errors.NoEntryPointError: Extension 'cogs.gg' has no 'setup' function.

restive otter
#

wat

#

hold on what

red glacier
#

i dunno

restive otter
#

can you show me the folder

red glacier
#

cogs folder?

restive otter
#

with like the content

#

yeah all of it

red glacier
#

that first folder got created

restive otter
#

it is a 0 kb file

#

you have no idea how badly I as a Linux user hate the Windows GUI lol

#

Either way it should have the actual code I sent in

red glacier
#

yeah give me a second

#

make sure it is

deep gazelle
#

https://www.youtube.com/watch?v=vQw8cFfZPx0 maybe this video can help xD

but did u copy that in the gg.py file?

import dbl
import discord
from discord.ext import commands


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

    def __init__(self, bot):
        self.bot = bot
        self.token = 'dbl_token' # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes

    async def on_guild_post():
        print("Server count posted successfully")

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

In this video, we learn about cogs and how to implement them in a discord bot.

If you have any suggestions for future videos, leave it in the comments below.

GITHUB: https://github.com/Rapptz/discord.py
DOCUMENTATION: https://discordpy.readthedocs.io/en/latest/

OFFICIAL DISCORD.PY SERVER: https://discord.gg/r3sSKJJ
JOIN MY HELP SERVER: https:...

▶ Play video
red glacier
#

mightve forgotten to save he code

red glacier
#

yep

#

i forgot

#

._.

deep gazelle
#

^^

restive otter
#

that's fine dude

#

you're nearly done

#

Guddi I just walked him through it myself manually lol

red glacier
#

ok bot ran all good

restive otter
#

👍 good

red glacier
#

now i need to puit this into my actual bot to see if it actually works

restive otter
#

yes

#

make sure to use the correct token haha

red glacier
#

yeah my entire 26 servers

#

xD

restive otter
#

also it looks far nicer than N/A lol

red glacier
#

yeah

restive otter
#

even then it's an improvement

red glacier
#

Wooo

#

it works

deep gazelle
deep gazelle
#

sometimes the question solves the problem xD
now someone voted and it worked haha

#

wow.....

restive otter
#

ah

#

sorry @deep gazelle

deep gazelle
#

no problem xD

restive otter
#

whats the code you're using so I can put it into my dev build and do some troubleshooting

#

or just read it and go "oh"

jaunty plank
#

test button wont show up on the on dbl vote

#

as its a test

deep gazelle
#

yea i know

restive otter
#

or woo just destroys me

deep gazelle
#

_test worked on a test
_vote doesnt on a vote

but now it do shrug

jaunty plank
#

i do spend too much time here helping people with libs i dont use in languages i dont know 😄

red glacier
#

@restive otter ok it doesnt seem to work on the pi after i moved it over, but works on windows

#

any idea why?

restive otter
#

uh what

#

¯_(ツ)_/¯

#

no

red glacier
#

hmmm

restive otter
#

do you have the dbl extension installed?

red glacier
#

oh.

#

lmao

#

i forgot to install that on the p i

restive otter
#

yes

#

lol

red glacier
#

hmm

#

Could not find a version that satisfies the requirement dblpy (from versions:) How do i fix that @restive otter ?

restive otter
#

uhhhh

#

pip install dblpy

red glacier
#

i did that

#

thats the error

jaunty plank
#

i think that might be the error that happens when you have a specific python version

#

for some reason the lib doesnt work with a specific version of py

red glacier
red glacier
#

is the python3 part the problem..?

restive otter
#

uh

#

use a specific

#

it has a github thing

red glacier
#

use what?

restive otter
#

let me get the code

red glacier
#

ok

#

ah

#

python was 2.7.16.....

#

lmao

restive otter
#

uhhhhh

#

no idea

red glacier
#

i tried installing from github

#

and it says it required at least 3.5.3

#

so

#

hah

restive otter
#

lol

red glacier
#

ok

#

so