#topgg-api

1 messages · Page 9 of 1

restive otter
#

Use ps instead of bash:

Install-Package DiscordBotsList.Api
tidal idol
brisk summit
#

How can I make a top.gg vote logs come in webhook

woven coral
#

sanz left iara_ded_lost

tidal idol
#

who is sanz

woven coral
tidal idol
#

oh :c

woven coral
#

oh well

#

rip to that project

#

abandoned again

restive otter
#

wooooohoooo yet another ded library

tidal idol
#

just like

#

inspect elements on the preview link

#

its using a tailwindui template but modified quite a bit

#

yes

#

no mac already replied and said it won't be happening why

#

i don't see where the maintenance will be needed seeing as it will be rendered as a static site because its not making db requests etc

#

but yeah thats the ruling

tidal idol
#

i'm not gonna bother contesting it shrug

restive otter
#

I should start a seer service

golden adder
#

If it were docs for a lib I wouldn't have an issue with it but since this is for the API docs, there's no reason to. "If it ain't broke don't fix it" is the approach here. What we have has worked perfectly fine up until now so there's no reason to take the risk of completely overhauling it.

Again, if it were a lib this would already be merged because it does look better and it's not as big a problem if it breaks. I really do appreciate the time and effort put in! I just wish we had had this conversation about such a major change before sinking your time into it. But since this is about our core API docs, we cannot take that risk. I hope you understand that reasoning, but unfortunately it's not up for debate.

cc @tidal idol

restive otter
#

My question is why have years old PRs never been merged. Worth noting that those are PRs that are needed.

#

If someone would actually care about the documentation, those would've been merged since a long time.

Now I have to admit that if people don't merge the most basic and needed PRs, the complete redesign will be a mess in keeping it maintained and up-to-date, even if bun would actively work on it and opening PRs consistently.

hollow slate
#

how to update bot's name on top.gg

rain heart
#

-refreshdata

abstract mothBOT
#

topgg Fetching Your New Bot Data

To fetch your bot's new name or avatar, please follow these steps:
topggDotRed Click the Refresh Data button in the sidebar on the right.
topggDotRed Click Edit on your bot page and then Save.

💡 Please note: If it still doesn't seem to change, make sure you actually changed the bot's avatar / name on your Discord Developer Portal and not the application's icon / name.

hollow slate
rain heart
#

-api

abstract mothBOT
#

topgg This channel is for suggestions, help, and bugs related to our official API libraries and documentation found at https://docs.top.gg/

If you need help with other development, please use #development.

hearty lintel
#

please read up on what i said in the discussion on this

rain heart
# abstract moth

by the way, was referring to another user who posted a gif, which I deleted

hearty lintel
#

@lament pawn

dim pollen
#

server count is not updating even i used topgg-autoposter

tidal idol
#

it can take time to update due to cache

dim pollen
hexed lichen
#

for the api server count, does it count how many servers the bot in, or how many people invites the bot since i put the Authorization?

rain heart
#

The server count is posted by you

#

By literally guilds.length, so thr current amount of guilds your bot has

#

The site does not track that itself

hexed lichen
#

how long it take to update

#

more than day ?

rain heart
#

Cache should take half an hour to an hour

#

Again, it does not update itself, you need to post the statistics yourself

#

I can currently see 8 servers on the statistics you have posted

hexed lichen
#

yes got u

#

if i regenerate the token does the server count stay in the bot

rain heart
#

Yeah

hexed lichen
#

alright thanks

upbeat palm
#

Can anyone help me with the /dblwebhook webhook stuff?

#

as i am currently having issues

restive otter
runic creek
#

It would be easier if you wrote what issues you have instead of writing that you have them because it doesn't make things easier

restive otter
#

And they were never heard from again, typical

marble shuttle
#

re: posting the stats, I've got some current logic for including stats in presence updates, but obviously that errs on the side of more frequent potentially partial updates around a shard restart, would it be fine on top.gg to just hook that in the same place, or should I try and be careful to not post partial numbers and wait some time for them to stabilise?

woven coral
#

no

rustic whale
#

No ads

novel yoke
#

Can anyone tell why isWeekend is returning undefined? (I'm new to webhook stuff)

rustic whale
#

no self promotion

novel yoke
#
app.post(
  "/dblwebhook",
  webhook.listener(async (vote) => {
      console.log(vote);
      console.log(vote.isWeekend);
    let olduser = await User.findOne({ userId: vote.user }) || new User({userId: vote.user }).save();
     
    //  olduser.corals += 2;
//await olduser.save();
    if (!vote.isWeekend) {
            
        olduser.voteTime = Date.now();
        olduser.voteStreak += 1;
        olduser.corals+= 1;      
      await olduser.save();
  
    } else if (vote.isWeekend) {
        
      olduser.voteTime = Date.now();
      olduser.corals += 2;
      olduser.voteStreak += 2;
      await olduser.save();
    }
#

Here's the code

#

@rustic whale hello can u help?

rustic whale
novel yoke
#

Uh 🥲

restive otter
#

Then it's most likely not the weekend krShrug

#
let streak = vote.isWeekend ? 2 : 1;
novel yoke
#

@restive otter but the embed that is sending says that it is weekend lol

restive otter
#

Embed?

woven coral
#

isn't isWeekend documented as a required property

#

ig another known issue no eta again mmLol

restive otter
#

yeh

plucky lance
#

The property isWeekend will not/never be sent with the test webhook

#

@novel yoke

#

It will (only) be available when receiving a regular webhook (not your test webhook)

#

In other words if somebody actually votes

novel yoke
#

i was sending a test webhook and it was only giving one credit

#

so i was confused

rain heart
#

isWeekend is not provided on thr zest webhooks

rain heart
#

Cant be bothered to fix the grammatical error if the answer was already given lmao

#

But yeah consider it a bug

restive otter
rain heart
#

I mean why shouldn't it be in it when its used as a test

jaunty vale
#

how to setup commands that requires vote in js ?

woven coral
#

prs left abandoned for years

woven coral
#

gotta love that question is always ignored

woven coral
#

also this doesn't make any sense

The client methods should not be async as it serves no benefits, just makes it more difficult to debug and test.

#

most discord bots written in Rust are async anyway onesieKEKW

flat owl
#

None

restive otter
#

Also your merge

#

me when no rebase done when getting merged CH_Dead

restive otter
#

Sounds like someone just didn't wanted to get their implementation edited

#

When you publish something that isn't working in the first place krShrug

#

@woven coral how about you just ask for collaborator lmao

#

other sdks just merge when they believe it's fine, can do the same for yours

restive otter
restive otter
#

normally when someone merges

#

they merge as a single commit

#

hence rebase and merge

woven coral
#

eh that's fine

restive otter
#

yeah, though just horrible KEKW

#

you rebase nowadays when you want to merge a pr

#

especially when you made some commits in response to reviews or issues you've seen

#

though real chads just force push into main

woven coral
#

fr

surreal harbor
#

hmm

abstract gorge
#

how to show server count on top.gg

runic creek
#

Read pinned messages

#

Everything you need is there

abstract gorge
#

also

restive otter
#

It works in any language that can make POST HTTP requests

coarse elm
#

Pada

woven coral
restive otter
#

new pr needed bravemmlol

woven coral
#

what

restive otter
#

isn't 1.0.3 the latest

woven coral
#

Cargo automatically resolves it to the latest version iirc

restive otter
#

ah okay

woven coral
#

topgg = "1" also does the same

restive otter
#

Probably better to just tell them to use

cargo add topgg

instead

#

rebase moment

woven coral
#

what

restive otter
#

Xetera got a fair point as well

restive otter
woven coral
#

idk how to rebase iara_ded_lost

restive otter
#

you are not the one who's supposed to do it

#

it's when you merge

#

instead of just clicking on the merge button

#

you click on rebase and merge

woven coral
#

icic

woven coral
restive otter
woven coral
#

FFS

#

i hate git sometimes

#

@golden adder sorry, but can you change it yourself? i don't think i wanna make another pull request :)))) i'll make another one

restive otter
#

Should be HTTP/2

woven coral
#

HTTP/2.0?

restive otter
#

Nope

#

Just 2

woven coral
#

oh alright

woven coral
#

@restive otter ok so apparently HTTP/2 returns a 505 (HTTP Version Not Supported) and HTTP/1.1 just never returns

#

guess it's a wontfix

restive otter
#

lmfao

#

so scuffed

#

can try HTTP/3 /s

hearty lintel
woven coral
# woven coral nvm apparently i was dumb

@restive otter apparently i forgot to add the Connection: close header sdForgor HTTP/1.1 uses Connection: keep-alive by default https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Connection

The Connection general header controls whether the
network connection stays open after the current transaction finishes. If the value sent
is keep-alive, the connection is persistent and not closed, allowing for
subsequent requests to the same server to be done.

restive otter
#

Interesting that is allows you though

#

Meaning the server doesn't respond with anything

#

Just hangs

woven coral
#

that's the point of keep-alive mmLol

restive otter
#

yeah but there's surely something that drops it in the end

#

other than you stopping/cancelling the request

tepid kindle
#

Wow man verify my bot Anison

restive otter
#

Wow man wait longer

rustic whale
jaunty plank
#

@exotic wyvern
are you possibly setting the auth header/url to something that contains an accented character?

ex: á

#

Old issue we dont see often.

exotic wyvern
#

Nope, I just realised that it was error on my end, I got the bot new domain and was making the old domain redirect to the new one which was causing this error

#

Sorry!

jaunty plank
#

ah, well glad you figured it out ^_^

exotic wyvern
#

Thank you!

woven coral
#

Will the endpoint return a 403 if this condition occurs or nothing will happen and everything will return as intended (but everything is truncated to 1000 votes)?

#

i don't have a bot with over 1000 monthly votes to test this mimu_thisisfine

tidal idol
woven coral
#

but you cannot use this endpoint sounds otherwise

#

it should've been worded as "you shouldn't use this endpoint"

jaunty vale
#

emm

flint musk
#

where do i find all endpoints for posting stats to top.gg?

neat lotus
flint musk
sharp wedge
#

I have the same thing

#

I wonder why lol ||you know me dj ||

versed sentinel
#

Hey guys - regarding the votes endpoint /bot/{id}/check?userID

How up to date is the information queried? For example, if a user votes and then I trigger this endpoint around ~5 seconds later, will I get the most up to date information about a user's voting status? What's a reasonable timeframe in which the read on this endpoint will be accurate after the vote occurs?

rain heart
#

Should be basically instant

keen lintel
#

Hey, im using 2.1.2 API for Java, but when i want to call method Builder() it wont found.

DiscordBotListAPI api = new DiscordBotListAPI.Builder()
.token("token")
.botId("botId")
.build();

#

Can someone help me?

rain heart
#

Then you did not install the dependency

keen lintel
rain heart
#

Does it actually go to the class if you inspect it?

keen lintel
#

noo 😭 I forgot that i have file named same like topgg object

#

u got me

#

thanks

restive otter
#

can anyone help me?

#

when i try to go to applications it takes me to a discord login page

narrow zenith
#

you would have to login, assuming you're in the discord developer portal?

flint musk
#

Is it possible to have a command that votes for the user instead of them going to the site? I want to make it easier for them to vote

narrow zenith
#

That sort of is on the line of topgg TOS

gusty edge
#

someone help me, I can't get my top.gg account api key

#

how to get

restive otter
#

Bot Page > Edit > Webhook

gusty edge
#

I don't have bot

#

I am trying to get my account api key

restive otter
#

Then you cannot use the API

rain heart
#

You need an approved bot to use the api

gusty edge
flint musk
rain heart
#

Not possible either

upbeat palm
#

How does this work
Like how do i use it?
to send the webhook to a channel i want to send it to?

willow spindle
#

second one is password to make sure that request came from top.gg

upbeat palm
willow spindle
#

it could be a https website or your server's IP

#

it is 3rd party source but it is useful

upbeat palm
#

so how do i use it in an actual code?

#

I use Javascript @willow spindle

#

like a https:// domain that i own

willow spindle
steep cove
#

04.05 09:39:03 [Bot] Hybrid command raised an error: Command 'freelance' raised an exception: JSONDecodeError: Expecting value: line 1 column 1 (char 0) - started happening with my votecheck command - is this a api overload? Command has been working fine ever since last morning

steep cove
#

i get 04.05 10:26:35 [Bot] Error checking vote for user 1098285669937315910: 'voted'
04.05 10:26:35 [Bot] Response content: b'{"error":"Unauthorized"}'

steep cove
#

Reset the token x2

rain heart
#

Press regenerate, refresh the site, then copy that token

#

The site does not directly show the new token

steep cove
#

I have - same error

rain heart
#

Then you're not correctly providing the token within your code

steep cove
#

Can it get overloaded

steep cove
rain heart
#

It does not

rain heart
#

You can get ratelimited

#

But thats not the error

rain heart
#

You're either not passing the token correctly or using the still invalid one

#

Post your code

steep cove
#

import discord
from discord.ext import commands
import requests
import time
import asyncio

class Topgg(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.top_gg_api_token = 'TOKEN HERE'
        self.last_voted = {}
        self.thanked_users = {}

    @commands.Cog.listener()
    async def on_ready(self):
        print('VoteCog is ready!')

    async def has_voted(self, user_id):
        if user_id in self.last_voted and time.time() - self.last_voted[user_id] <= 43200:
            return True
            
        headers = {'Authorization': f'Bearer {self.top_gg_api_token}'}
        try:
            response = requests.get(f'https://top.gg/api/bots/{self.bot.user.id}/check?userId={user_id}', headers=headers)
            voted = response.json()['voted'] == 1
            if voted:
                self.last_voted[user_id] = time.time()
            return voted
        except Exception as e:
            print(f'Error checking vote for user {user_id}: {e}')
            print(f'Response content: {response.content}')
            return False


    async def check_votes(self):
        await self.bot.wait_until_ready()
        while not self.bot.is_closed():
            for user_id in self.last_voted.keys():
                voted = await self.has_voted(user_id)
                if voted:
                    if user_id in self.thanked_users:
                        # check if 12 hours have passed since the user was last thanked
                        if time.time() - self.thanked_users[user_id] >= 43200:
                            self.thanked_users.pop(user_id)
                        else:
                            continue
                    channel = self.bot.get_channel(1103061831465046076) # Replace with your channel ID
                    member = self.bot.get_user(int(user_id))
                    await channel.send(f'Dear {member.mention}, I want to express my heartfelt gratitude for taking the time to vote. Your contribution is highly valued and appreciated. Thank you so much! :redheart:')
                    self.thanked_users[user_id] = time.time()
            await asyncio.sleep(10) # Check every 60 seconds

    @commands.hybrid_command()
    async def votecheck(self, ctx):
        """To check if you have voted."""
        has_voted = await self.has_voted(ctx.author.id) 
        if has_voted:
            await ctx.send("`You have voted for the bot!`")
        else:
            await ctx.send("`You haven't voted for the bot yet.`")

async def setup(bot):
    cog = Topgg(bot)
    bot.loop.create_task(cog.check_votes())
    await bot.add_cog(cog)
rain heart
#

You're not providing a content type

#

Include the json content type on your request

steep cove
# rain heart Include the json content type on your request

async def has_voted(self, user_id):
    if user_id in self.last_voted and time.time() - self.last_voted[user_id] <= 43200:
        return True
        
    headers = {'Authorization': f'Bearer {self.top_gg_api_token}', 'Content-Type': 'application/json'}
    try:
        response = requests.get(f'https://top.gg/api/bots/{self.bot.user.id}/check?userId={user_id}', headers=headers)
        voted = response.json()['voted'] == 1
        if voted:
            self.last_voted[user_id] = time.time()
        return voted
    except Exception as e:
        print(f'Error checking vote for user {user_id}: {e}')
        print(f'Response content: {response.content}')
        return False
```?
rain heart
#

Yes

steep cove
# rain heart Yes

i get '04.05 10:52:55 [Bot] Error checking vote for user 276793117481369610: 'voted'
04.05 10:52:55 [Bot] Response content: b'{"error":"Unauthorized"}''

#

token is correct 100%

rain heart
#

Its also not a bearer token either

#

Its a normal API token

steep cove
# rain heart Its also not a bearer token either

04.05 10:59:59 [Bot] Error checking vote for user 276793117481369610: 'voted'
04.05 10:59:59 [Bot] Response content: b'{"error":"Unauthorized"}'

    @commands.Cog.listener()
    async def has_voted(self, user_id):
        if user_id in self.last_voted and time.time() - self.last_voted[user_id] <= 43200:
            return True
            
        headers = {'Authorization': f'{self.top_gg_api_token}', 'Content-Type': 'application/json'}
        try:
            response = requests.get(f'https://top.gg/api/bots/{self.bot.user.id}/check?userId={user_id}', headers=headers)
            voted = response.json()['voted'] == 1
            if voted:
                self.last_voted[user_id] = time.time()
            return voted
        except Exception as e:
            print(f'Error checking vote for user {user_id}: {e}')
            print(f'Response content: {response.content}')
            return False```
#

I think the api is just 🪦

rain heart
#

It's not, its either your token still being invalid or still something wrong in the code

steep cove
#

Same code was working fine all yesterday and days before untill it stopped this morning

onyx locust
#

Get a new api key and try again

steep cove
#

i have 3 times

rain heart
#

How did you obtain them

steep cove
#

Webhooks "token for this bot"

#

regenerate

#

page refresh

steep cove
rain heart
#

Ensure it doesn't have any weird characters in it

#

If it is the api itself, other people would start complaining in support

steep cove
#

ive regenrated it but so don't worry:

        self.top_gg_api_token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjczMzgwODAyNzY1MTgwMTExMCIsImJvdCI6dHJ1ZSwiaWF0IjoxNjgzMTk1ODEwfQ.mu4dAteuZOgy03dDcBIXuy1v8jvnrwGamKsyuD7f31Q'```
steep cove
#

I ran it through GPT4, and all it says the code is the correct contact top.gg support team for further assistance with backend API

onyx locust
#

Well gpt isn’t always right

steep cove
onyx locust
#

Well idk maybe there’s something wrong with the api time will tell

steep cove
#

People are not to happy in my server 💀

onyx locust
#

Shouldn’t be a issue

steep cove
#

I know

onyx locust
#

Why do they need to vote? Some sort of premium ?

steep cove
onyx locust
#

Just give it to them until u fixed it

steep cove
#

everyone hates when they cannot get the bonuses lmao

steep cove
onyx locust
#

Then idk

steep cove
#

I will have to wait for TOP.GG staff members to look into it

#

Just keep getting ```
04.05 11:26:54 [Bot] Error checking vote for user 276793117481369610: 'voted'
04.05 11:26:54 [Bot] Response content: b'{"error":"Unauthorized"}'
04.05 11:26:57 [Bot] Error checking vote for user 276793117481369610: 'voted'
04.05 11:26:57 [Bot] Response content: b'{"error":"Unauthorized"}'

dim kettle
#
{
  "Authorization": "your-topgg-token-here"
}
steep cove
# dim kettle ``` { "Authorization": "your-topgg-token-here" } ```
 @commands.Cog.listener()
    async def has_voted(self, user_id):
        if user_id in self.last_voted and time.time() - self.last_voted[user_id] <= 43200:
            return True
            
        headers = {'Authorization': f'{self.top_gg_api_token}', 'Content-Type': 'application/json'}
        try:
            response = requests.get(f'https://top.gg/api/bots/{self.bot.user.id}/check?userId={user_id}', headers=headers)
            voted = response.json()['voted'] == 1
            if voted:
                self.last_voted[user_id] = time.time()
            return voted
        except Exception as e:
            print(f'Error checking vote for user {user_id}: {e}')
            print(f'Response content: {response.content}')
            return False```
#

Yeh

dim kettle
#

Try re-generating the token for your bot. (You may want to refresh the site before copying the new token)

steep cove
#

same code has been working for a week now but stopped this morning

dim kettle
#

Thats weird. Stupid question, have you validated self.bot.user.id returns the correct ID?

#

Also may be worth logging self.top_gg_api_token to make sure thats also being passed

steep cove
#

Ill try setting it as the direct id

steep cove
#

otherwise it would not print the errors in exception im pretty sure

dim kettle
rain heart
#

Is the token even the correct one for the corresponding id? Keep in mind you cant use the same token for different bots

dim kettle
abstract mothBOT
#

topgg How to clear browser cache

In order to clear your cache for the site, press CTRL+F5.

If this does not work, try one of these resources below:
topggDotRed Instructions on Microsoft Edge
topggDotRed Instructions on Google Chrome
topggDotRed Instructions on Mozilla Firefox
topggDotRed Instructions on Safari on iOS or Safari on MacOS
topggDotRed Instructions on Opera
topggDotRed Instructions on Brave

topgg_ico_bulb If you are unable to find instructions for your specific browser above, please refer to your browser's manual or help documentation to find out how to clear your browsers cache.

steep cove
#

Also just used GPT4 to check if code token matches with the one on top.gg and it matches correctly.

dim kettle
#

Then I got no idea

#

Make sure when your checking if they match that you are looking at the entire string, as only part of it changes

#

Try logging the raw outgoing response to make sure all headers get sent etc, or try doing the call in curl, postman etc to see if the token on the site works elsewhere

steep cove
dim kettle
steep cove
#

That's actually possible with my bot usage in servers ngl

steep cove
dim kettle
#

That way there is no rate-limit

steep cove
dim kettle
#

Yeah, with webhooks you would be able to get votes sent to your webserver/bot :)

#

That way you can give rewards without asking the API for vote info

#

So if you need to store rewards over time, just push the votes into your own db when you receive a webhook

steep cove
#

Are you arl to help implement that with me if i get any errors

dim kettle
#

I am about to head out to camp in 30min until Sunday evening 😅
So I wont be able to unfortunatly

steep cove
#

no worries

steep cove
#

The vote command now works - but the freelance command that i have now does not its like the api breaking has swapped commands lmao

#

& if i reset the bot again the vote command does not work and the freelance command does and this can be completely random both commands use the same logic

#

I guess i will give it 24hrs or smth for it to calm down & both commands might work then

inland ruin
#

قصدي

restive otter
#

Hi guys, i want to make the vote system inside the bot in py, ik only the way with the webhook but i seen it inside the bot without webhook and i was curious how

rain heart
#

Only way is using the check endpoint, which is subject to ratelimits

#

The best way is webhooks nonetheless

uneven cobalt
#

anyone has a code example, how i can trigger a function in python nextcord when someone votes for my bot?

uneven cobalt
#

Seems uncompatible to me idk

fair osprey
woven coral
#

why can't lib devs make their library work with every discord library mm_sip

rain heart
#

ah yes lemme just

#

support 10-20 libs

#

especially support libs that love to have breaking changes

#

cough djs

woven coral
#

i mean like instead of passing in a lib-specific bot object just pass in like a discord ID or something

rain heart
#

oh yeah

onyx locust
uneven cobalt
rain heart
#

yes

#

hosting your own flask instance

uneven cobalt
rain heart
#

unlikely

#

never had issues with it

#

thats essentially what the normal library does

uneven cobalt
rain heart
#

just check their docs, its not difficult

quick trellis
#

only me or is the top.gg api documentation outdated with both missing paths and paths that are not working as they should?

rain heart
#

Which ones?

quick trellis
#

/api/bots -> always getting the same results with searches.
/api/bots/stats & /api/weekend -> not in docs

rain heart
#

First one is a bug

restive otter
#

Known issue
Don't know about the others

rain heart
#

api/bots should return your own bots stats correct?

#

And api weekend is in the docs though no?

restive otter
#

Considering the API documentation doesn't get any attention at all, wouldn't be surprised it's not documented yet could be useful

restive otter
quick trellis
#

its not

quick trellis
restive otter
#

Probably meant /api/bots/stats

quick trellis
#

oh yea then yes it should be your own bot

restive otter
#

The search endpoint giving the same results is a known bug as mentioned above

#

Yeah it's good information to know, not worth creating a PR or whatever

#

PRs that are needed don't get merged, and that for years - documentation is pretty much dead and nobody really cares

rain heart
#

feel free to pr if you want to

quick trellis
#

yea, im just adding tests to the node sdk and find these errors while creating them

rain heart
#

and pong mac then

restive otter
#

2-3 years old PRs never got merged krThumbsUp

#

Asked a question around those and why they never get merged, never got a response and still waiting for one

#

But when it's regarding an entire, good, rewrite of the documentation - there the refusal is instant at least

quick trellis
#

yea i saw that someone is doing that

restive otter
#

Should probably ask my question there so that maybe it gets some more attention as it's on GitHub and can't be ghosted like on Discord 🙃

quick trellis
#

no reason in not trying 😉

restive otter
#

Just sad that it has to go like that to not get your question ghosted for no reason

#

But yeah, I guess it's the only solution

hearty lintel
#

the reason the answer was quick was because i was active about it and expressed my problems with it, mac agreed

#

im going to try and get some solutions for docs when mac gets back

#

need a new system but there needs to be some discussion around it first obviously

#

the individual sdks are maintained alright

restive otter
#

But yeah I do agree that a complete rewrite can't be better managed than an already completely dead project, as already said previously as well

hearty lintel
# restive otter Well my question was for Mac, no you

yeah, i’m saying the reason the answer was so quick was because while this was going on, i said what i had to say, and then when everyone was asking mac about it i brought it up and be agreed. mac isn’t necessarily inactive, but we had to push for an answer but once he was there it was ez to answer

#

the issue isn’t with anyone here right now like mac, it’s that OSS was severely deprioritized when people were shifted and leaving

restive otter
#

Absolutely, though I'd expect a small question to be at least answered ^-^ I guess it's not something I should expect in the the future and it's good knowing it

hearty lintel
#

to atleast get through the PRs there and have somebody able to merge in changes

restive otter
#

definitely yeah

forest geyser
onyx locust
#

you must code a script to acces it

golden stratus
#

Oque que eu tenho que colocar, aqui no Webhook URL, porque quando eu mando um teste, não retorna nada no terminal.

golden adder
#

@restive otter i don't think you appreciate how I can't be working 2 jobs for 2 companies at the same time and do them both to 100%, especially when one of the companies you work for has a workload that used to be for a team of about 13 people who you now basically have to stand in for on a part-time basis with one other colleague. So sorry if I missed your question, but that exact situation I explained above is also why we won't be overhauling something that already works in its current state.

#

Things will get better from here but @hearty lintel very much hit the nail on the head when he said OSS was deprioritized. The truth is it wasn't even considered (and barely still is although I've also been trying my hardest to improve this), because we have bigger issues to deal with.

#

I don't think maintaining a docs repo is a high priority when the API itself hasn't seen any updates or changes since it first released.

woven coral
#

that's very sad

hearty lintel
# golden adder I don't think maintaining a docs repo is a high priority when the API itself has...

I think it's necessary to have at least someone or multiple people have the ability to merge in docs. "when the API itself hasn't seen any updates or changes since it first released" also isn't true, there are multiple changes, some of which are sitting in the PRs right now. Server webhooks are still not documented for example. Even if this was true, general maintenance, language updating, library updates (big one) are all things that still change in the docs often enough to warrant some kind of mechanism to get change onto the site. Even if it's not fast that's fine, because really there aren't that many changes coming in, but at least something. PRs can't even build today
We were talking in os chat about mechanisms for which merges can be made, there were only really two. 3+ library developers approve = merge or a specific mod who can merge. I agree I don't think it's fair to make you the defacto merger. These wouldn't be fast but they'd at least allow for some kind of mergeability. Though, again, it certainly wouldn't be fast enough to maintain a complete rewrite of the site

golden adder
shadow jetty
#

Neutrino log is not working

#

Is everyone is facing same problem ot not

#

🥺

rain heart
#

-wrongserver

abstract mothBOT
#

topggDotRed Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Discord Support Server" button on the bot's page of the bot you need support for. If there isn't a button that says "Discord Support Server" or nothing else mentioned about a support server, the server invite is invalid or you were banned from the bot's support server, then we can't help you. Sorry :(

hearty lintel
restive otter
#

hi

rain heart
#

-api

abstract mothBOT
#

topgg This channel is for suggestions, help, and bugs related to our official API libraries and documentation found at https://docs.top.gg/

If you need help with other development, please use #development.

rain heart
#

Sure

#

-m @restive otter decided to react "Fuck yo" on my message for no reason | 3 days

abstract mothBOT
#

upvote Sammy Lammy#9508 was successfully muted

subtle falcon
#

Hi

scarlet cobalt
#

One message removed from a suspended account.

rain heart
#

-api again

abstract mothBOT
#

topgg This channel is for suggestions, help, and bugs related to our official API libraries and documentation found at https://docs.top.gg/

If you need help with other development, please use #development.

rain heart
golden stratus
#

Let me see if I understand, do I need to make a server using express, and connect from my bot to see the member who voted for my bot?

solid imp
pallid swan
#

Though I am using the 'Send test' as a test, unless that does not include the authorization string

#

It includes the bot, the user, the type, query is empty and thats all

solid imp
rain heart
#

Auth is included when testing webhook requests

#

As testing it would otherwise not make sense

woven coral
#

the authorization header?

rain heart
#

Yes

#

The one you provided in your webhook settings

#

I'm pretty certain that gets sent too

woven linden
#

Hi, in Top.gg Python library, autopost doesn't support shard_id, right?

I got 5 shards each one handling a little bit more of 1k guilds but, only the amount of a single shard is being posted on the website, they do not add up

neat lotus
#

The endpoint for shards or guilds don't add up. It just takes in the value you give to it so you could put 1 shard or 1 server and it accepts that I believe

#

Ideally you want to calculate the total shards and total guilds across all shards and post that to the API.

I'm not sure what the top.gg python lib does but you could implement this fairly easily without a lib if necessary

woven linden
#

so I was trying to accomplish that with autopost

neat lotus
#

Not that I know of 🤔
I post my guild count to Top.gg everyday at 12:00 am and it's never added up

#

Though I use raw requests and not an auto poster so py or node js shouldn't affect it

#

I'd say calculate all the guilds from the shards and then post the full number

#

maybe submitting some array works but that's something I never did myself so I'm unsure on that one

woven linden
#

alr, tysm 🙂

neat lotus
#

no worries

fervent imp
#

how to when anyone vote my bot my bot send message in member dm?

runic creek
#

Read pinned Waiting

rain heart
#

No, sounds like a clear path to a tos violation

shut hornet
dapper copper
visual verge
#
TopGGAPIError: 504 Gateway Timeout
    at Api._request (/home/container/node_modules/@top-gg/sdk/dist/structs/Api.js:61:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Api.postStats (/home/container/node_modules/@top-gg/sdk/dist/structs/Api.js:86:9) {
  response: {
    statusCode: 504,
    headers: {
      date: 'Fri, 12 May 2023 11:50:50 GMT',
      'content-type': 'text/plain',
      'content-length': '14',
      connection: 'keep-alive',
      'cf-cache-status': 'DYNAMIC',
      'strict-transport-security': 'max-age=15552000; includeSubDomains; preload',
      'x-content-type-options': 'nosniff',
      server: 'cloudflare',
      'cf-ray': '7c6270cc9a0f23e8-LHR',
      'alt-svc': 'h3=":443"; ma=86400, h3-29=":443"; ma=86400'
    },
    trailers: {},
    opaque: null,
    body: BodyReadable {
      _readableState: [ReadableState],
      _read: [Function: bound resume],
      _events: [Object: null prototype],
      _eventsCount: 3,
      _maxListeners: undefined,
      [Symbol(kCapture)]: false,
      [Symbol(abort)]: [Function (anonymous)],
      [Symbol(kConsume)]: [Object],
      [Symbol(kBody)]: null,
      [Symbol(kContentType)]: 'text/plain',
      [Symbol(kReading)]: false
    },
    context: undefined
  }
}
#

anyone knkows why im getting this error?

runic creek
restive otter
#

where can i find my token for the Authorization?

rain heart
#

Check the pinned messages

restive otter
#

Wdt

#

Owo dt

rain heart
#

-botcommanda

#

-botcommands

abstract mothBOT
#

Hey! Bots aren't given permissions to send responses in this channel. Please use #commands to run commands.

dapper copper
dapper copper
shut hornet
#

pls topgg config your cloudflare

scarlet cobalt
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

restive otter
#

I have also problem with top.gg

#

I can’t vote

#

Also I can’t login

scarlet cobalt
dapper copper
# visual verge ??

like for sometime bot was working fine after the issue was fixed in #site-status but now its again showing either Gateway Timeout or Forbidden

rain heart
scarlet cobalt
rain heart
#

Yeah dw

visual verge
dapper copper
visual verge
#

can any1 give me the docs to topgg new vote required cmd system?

jaunty plank
#

New vote required command system?
I've not heard of a new system?

visual verge
jaunty plank
#

in a library? or an api endpoint?

rose night
#

@wild lantern invite

quick trellis
#

@subtle pulsar ^

tidal idol
#

all channels SickBro

violet sun
#

what do I have to put in here? await topgg_webhook.run(HERE)

rain heart
#

port

novel cape
#

trying to get a webhook running with my express server but it doesn't seem to be working. I tried using the public ip for my vps to no avail, I've also tried using my websites domain with nothing working yet everything else on the site works fine. I can't seem to get my bot to receive a post request test submitted by top.gg. I do however have several other post requests that work on my website :/

neat lotus
#

and the request is 100% post and not GET

#

You need to just put your webserver url and endpoint in the webhooks section and ideally it should work 🤔

novel cape
neat lotus
#

Try to verify that your endpoint works first by sending a POST request to it

novel cape
#

okay so I found out what it was

#

I had something that restricted http traffic and automatically routed it to https

#

so I have fixed it to allow the webhook to actually post. Thanks!

rain heart
#

one channel above this one

#

lmao dw

violet sun
#

can someone help me setting up the vote webhook?

rain heart
#

ask what you need help with

violet sun
#

In topgg.webhook.run() what do I have to put in the brackets? And what do i have to put as the webhook url on topgg

signal urchin
spark mulch
#

I have a similar question? Where do I get started with using webhooks on a VPS?

plucky lance
#

Your webserver is receiving the POST request aka. webhook from topgg and then it's up to you to do whatever u like with the content you get

#

Very simple forms of webhook listeners (webservers) can be found in the api docs

#

The URL u have to enter is your endpoint, literally your server IP (and/or port) or hostname topgg sends the requests to

restive otter
#

is there a way to simulate votes so i can test my webhook implementation, i havent seen anything about it on the website or docs?

onyx locust
#

make a post req to your webserver

rain heart
plucky lance
restive otter
#

ohh, i missed that

#

im sorry

#

thank you

spark mulch
jaunty plank
#

It generally depends on your setup.

Assuming you're not using something that restricts ports you can use any valid port.

spark mulch
#

I guess if I choose the port 1555 and my vps ip is 127.0.0.1 (for example) and my path is /dblwebhook then my address is http://127.0.0.1:1555/dblwebhook right?

jaunty plank
#

yep

wild void
#

Hey how do i show user tag and total votes on webhook server

onyx locust
#

Well u should probably save the votes yourself but I guess u get the id of the user that voted idk for sure

rain heart
#

get the id of the user who voted, fetch the user, use the tag

#

the id is provided in the webhook data sent

onyx locust
#

Let user = client.users.cache.find(u => u.id == data)

wild void
#
const Topgg = require('@top-gg/sdk');
const app = express();

const webhook = new Topgg.Webhook('hddidjdn5');

app.post('/vote', webhook.listener(async (vote) => {
  console.log("User with id - " + vote.user + " Voted!");

  const ProfileImgUrl = 'https://media.discordapp.net/attachments/1071392326355800126/1107763713173360670/topgg.png?width=250&height=250';

  let value = JSON.stringify({
    embeds: [
      {
        //title: "Another Vote!!",
        description: `[Vote](https://top.gg/bot/810540985032627248/vote) Added For @carmine wedge :shiba_tada:`, // Replace YourBotID with your bot's ID and YourCustomEmoji with your desired emoji ID or name
        color: "7815903", // Hex -> Decimal
        author: {
          name: `Top.gg`,
          icon_url: ProfileImgUrl,
        },
      },
    ],
  });

  try {
    const { default: fetch } = await import('node-fetch');
    const response = await fetch("https://discord.com/api/webhooks/", {
      method: 'POST',
      headers: {
        'Content-type': 'application/json',
      },
      body: value,
    });

    if (response.ok) {
      console.log('Webhook posted successfully');
    } else {
      console.log('Error occurred while posting webhook. Status:', response.status);
    }
  } catch (error) {
    console.log('Error occurred while posting webhook:', error);
  }
}));

app.listen(56887); // Port
console.log("Your app is ready to log votes :D");```
#

Here is my code

wild void
onyx locust
#

Idk if you discord bot is in the same file but if it is you could do let user <bot/client>.users.cache.find(u => u.id == vote.user) and then include it in you message

onyx locust
#

You save them in a json file or something and every time the user id is the same as in the database/json file and add the count

restive otter
onyx locust
#

😂

onyx locust
#

For testing purposes he could use json

rain heart
#

Check the pinned messages

restive otter
#

What's wrong with json?

onyx locust
#

Ive used json for a bot with over 100 guilds😂😂

#

Just because im to lazy to setup a db xD

onyx locust
#

Just add stuff to make sure it doesn’t

green python
#

is there a python version for top.gg api

solid imp
green python
#

thank

#

god

steel sapphire
#

@solid imp where i can get a top.gg api key

runic creek
#

Navigate to /webhooks on your bot link

#

Of course, the bot must be approved on top.gg

robust yacht
#
    @commands.Cog.listener('on_dbl_vote')
    async def on_dbl_vote(self, data):
        print(1)
        bot = self.bot.get_user(1059793976271577229)

        if int(data['bot']) != bot.id: return

        user_id = int(data['user'])
        user = await self.bot.fetch_user(int(user_id))

        vote_url = 'https://top.gg/bot/1059793976271577229/vote'


        embed = discord.Embed(color=config.color)

        embed.add_field(
            name=f"New Vote",
            value=f"`{user} [{user.id}]`\nThanks for the vote! Your single vote is very precious for us!",
            inline=False
        )
        
        embed.set_author(
            name=user,
            icon_url=user.display_avatar.url,
            url=f"https://discord.com/users/{user.id}"
        )
        embed.timestamp = datetime.datetime.utcnow()

        channel = self.bot.get_channel(1108334800730849372)

        view = discord.ui.View().add_item(discord.ui.Button(label="Vote", url=vote_url))

        await channel.send(embed=embed, view=view)

this event is not getting triggered

#

@runic creek

runic creek
#

I'm not familiar with python so I can't help you with that

robust yacht
#

ok

visual verge
#

how do i transfer team ownership to another account?

onyx locust
#

You don’t

#

Resubmit

visual verge
steel sapphire
steel sapphire
runic creek
steel sapphire
atomic nacelle
#

If your bot is on topgg you must use this code
npm i @top-gg/sdk
Index.js part >>>

const topgg = require('@top-gg/sdk');
const topggtoken = "Your Top.gg Bot Api Key";
client.topgg = new topgg.Api(`${topggtoken}`);
const { AutoPoster } = require("topgg-autoposter");
AutoPoster(`${topggtoken}`, client).on("posted", () => {
 console.log("Posted stats to Top.gg");
});```

**InteractionCreate.js part**
```js
let hasVoted = await client.topgg.hasVoted(interaction.user.id);
    const voteme = new EmbedBuilder()
      .setTitle('Vote me to use this command')
      .setDescription(`You must vote me on [TOP.GG](https://top.gg/bot/1016392200516550736/vote) to use this command`)
      .setColor('#03fcdb')
       const actionRow = new ActionRowBuilder()
      .addComponents([
        new ButtonBuilder()
          .setLabel('Vote')
          .setURL("https://top.gg/bot/1016392200516550736")
          .setStyle(ButtonStyle.Link)
          .setEmoji('1056991776428282027')
          .setDisabled(false)
      ])
if(slashCommand.voters && !hasVoted){
return interaction.reply({embeds: [voteme] , components: [actionRow]}
  );
}```
onyx locust
#

You need to setup a webserver so top.gg can send a request every time someone has voted

upper token
#

Can anyone help me with this error please?

Error: Missing Server Count
at Api.postStats (/workspace/FWbot/node_modules/@top-gg/sdk/dist/structs/Api.js:84:19)
at DJSPoster.post (/workspace/FWbot/node_modules/topgg-autoposter/dist/structs/BasePoster.js:64:18)

restive owl
#

how to add server count

#

and member count

runic creek
#

You can't add member count

#

The number of members on the server is sent by top.gg bot

#

As for the number of servers your bot is on, read the pinned messages

#

There are all the links you need along with code examples

upper token
willow spindle
#

Did you read it

atomic nacelle
rain heart
#

You require a webserver to receive a webhook request from top.gg

#

Aka live vote events

restive otter
#

Hello, my bot is the economy bot, I want the bot to give money when they vote on top.gg, what is the code for this?

rain heart
restive otter
#

Thanks you

pseudo karma
#

Channel Create js code?

rain heart
#

-api

abstract mothBOT
#

topgg This channel is for suggestions, help, and bugs related to our official API libraries and documentation found at https://docs.top.gg/

If you need help with other development, please use #development.

onyx locust
#
interaction.guild.channels.create()```
#

interaction.guild.channels.create*

rain heart
#

this is the wrong channel

onyx locust
#

sorry Aurel 😄

steel sapphire
#

@jaunty plank can you help me

main karma
steel sapphire
steel sapphire
#

Okcat_ok

hushed acorn
#

idk why it isn't boolean

steel sapphire
tidal idol
#

also the api has been like that for years, would be worse to just switch one day

#

there was going to be a new api version but we are still waiting for that

onyx locust
#

One person at top.gg thought uhhh lets use 1 and 0 😂

tidal idol
#

well do remember it used to be a passion project

edgy dome
#

e

solid imp
#

@queen isle basically

runic creek
#

What if someone votes without this parameter, let's say from a notification on the website?

queen isle
queen isle
solid imp
solid imp
robust yacht
#

topggpy doesnt work?

median timber
#

Hi everyone am new here

uneven hatch
#

how do you set which channel top gg displays when someone votes for your server?

#

nvm i remember now

main karma
median timber
crude fractal
#

i got a question how can i setup a webhook channel wich sends if a user votes for my bot?

#

or have i to code it by myself?

rain heart
#

You have to code it yourself

clear pecan
#

hello I have do this code to detect webhook from top.gg with fastapi

#

but topgg made everytime a post request 😦

#

even If I rep with 200 status

rain heart
#

then you're not properly responding to it

clear pecan
#

I have tested a lot of thing xD

rain heart
#

top.gg will retry the request if it either timed out of was not responded to it at all

#

check your logs if it is correctly responded to

clear pecan
jaunty plank
#

Some status codes also will cause a retry, typically people use 200 or 204.
I'm not 100% sure 201 is on the list

clear pecan
#

okay I will try

#

oh I have found my issue thank you xD

jaunty plank
clear pecan
#

My fault, when I send the event to the ipc I have added an asyncio.sleep in my code so ipc_client.request(route="on_vote", source='Alpha', user_id=data.user) take 30 seconds to make a response

#

and during this time topgg retry

jaunty plank
#

Ah, I see.
Good to know

ivory belfry
#

/stats

restive otter
#

Hello, I couldn't find the bdfd API on the site, can someone send it to me or show it to me?

rain heart
#

Theres none for that library

runic creek
#

This is probably the only option to use top.gg api

#

But I have no idea how exactly to do it with this script

#

You'd have to handle it yourself

restive owl
#
[ERROR] Failed to fetch server count from top.gg: TypeError: topggAPI.getMe is not a function
rain heart
#

Doesn't sound like a official Library

random ingot
#

@rain heart hey where do i get the api

rain heart
#

docs? token?

random ingot
#

token

rain heart
#

check the pinned messages

random ingot
#

alr

hearty estuary
rain heart
#

last 12 hours

#

if you want to check if someone has ever voted, consider using webhooks and tracking that yourself

hearty estuary
onyx locust
#

Setup a webhook and give a reward to the user that voted

faint juniper
onyx locust
#

Why would you want that?

#

Just but the code for the webhook above your ready event or something

faint juniper
onyx locust
#

But you won’t have to

faint juniper
#

Any way to log vot throw bot?

#

Not webhook?

#

@onyx locust you have any idea?

onyx locust
#

Just use the webhook

#

Then when you receive the webhook get the userid and then find the user and then send the message 🤷‍♂️

faint juniper
onyx locust
#

Yes

faint juniper
#

But not working

onyx locust
#

Then you did something wrong

faint juniper
#

Oh

onyx locust
#

Show your code and error message

faint juniper
onyx locust
#

Otherwise nobody is gonna be able to help you

faint juniper
#
const express = require('express');
const Topgg = require('@top-gg/sdk');
const app = express();

const webhook = new Topgg.Webhook('count');

app.post('/vote', webhook.listener(async (vote) => {
  console.log(vote.user);

}));

app.listen(19261); 
#

@onyx locust

#

I add this under the index

narrow zenith
#

where under the index

#

looks like it wouldn't cause errors and runs as it should

onyx locust
#

Where do you host it

faint juniper
onyx locust
#

Where do you host it?

faint juniper
#

Panel

onyx locust
#

Yes where

faint juniper
#

P....

#

W8

ashen sparrow
#

heyy

#

how can i get api?

plucky lance
ashen sparrow
restive otter
#

how to get topgg api

#

bot's

rain heart
#

get what

atomic nacelle
#

In this I'm doing like premium users can bypass the voting requirement but it is not working can anyone help me?

if (slashCommand.voters && !hasVoted || !premiumuser) {
    return interaction.reply({ embeds: [voteme], components: [actionRow] });
  }```
plucky lance
atomic nacelle
#

premiumuser is for bypass that hasVoted so is used ||

plucky lance
#

When the var Premiumuser is always available then edit the logic like so (other than i wrote above)

if (slashCommand.voters && !hasVoted && !premiumuser) {
atomic nacelle
plucky lance
#

Without providing details what the vars return this is only guessing expecting a result based on the vars name

atomic nacelle
#
let premiumuser = client.premium.get(interaction.user.id);
let hasVoted = await client.topgg.hasVoted(interaction.user.id);
   
  if (slashCommand.voters && !hasVoted && !premiumuser) {
    return interaction.reply({ embeds: [voteme], components: [actionRow] });
  }```
#

@plucky lance

#

This. Is the full code

#

@lament pawn

plucky lance
#

Yeah this logic is about right

#

If voters is true AND user has not voted AND is not premium

#

I just slightly misunderstood what the var does regarding my first message

#

Once one condition will fail let's say the user has premium then your vote embed isn't shown

onyx locust
#

Hey guys would this be a correct way to get when a user has voted ?

#
const express = require('express');
const app = express();
const port = 3000; // Replace with your desired port

// Handle POST requests to the webhook URL
app.post('/webhook', (req, res) => {
  // Check if the request is coming from top.gg
  if (req.header('Authorization') === 'YOUR_TOPGG_WEBHOOK_AUTH') {
    // Retrieve the payload data
    const voteData = req.body;
    
    // Process the vote data
    console.log('User voted:', voteData.user);
    
    // You can perform additional actions here, such as granting rewards or sending a thank-you message to the user
    
    res.sendStatus(200); // Respond with a success status code
  } else {
    res.sendStatus(401); // Respond with an unauthorized status code if the request is not from top.gg
  }
});

// Start the server
app.listen(port, () => {
  console.log(`Webhook server listening on port ${port}`);
});```
hearty lintel
#

but this looks like it’d work

tidal idol
#

req.header('Authorization')
why not just req.header.authorization panic

onyx locust
#

No idea

#

😂

hearty lintel
onyx locust
#

Thnx I’ll give it a try

tidal idol
#
const express = require('express');
const app = express();
const port = 3000; // Replace with your desired port

// Handle POST requests to the webhook URL
app.post('/webhook', (req, res) => {
  // Check if the request is coming from top.gg
  if (req.headers.authorization === 'YOUR_TOPGG_WEBHOOK_AUTH') {
    // Retrieve the payload data
    const { user } = req.body
    
    // Process the vote data
    console.log('User voted:', user);
    
    // You can perform additional actions here, such as granting rewards or sending a thank-you message to the user
    
    res.sendStatus(200); // Respond with a success status code
  } else {
    res.sendStatus(401); // Respond with an unauthorized status code if the request is not from top.gg
  }
});

// Start the server
app.listen(port, () => {
  console.log(`Webhook server listening on port ${port}`);
});```
#

or yeah the main lib

#

probably makes more sense to use the package

tidal idol
#

i took from their code so blame them

hearty lintel
#

tho generally req.header() makes more sense

#

or

#

more people use it

onyx locust
hearty lintel
#

don’t have to worry about cases

onyx locust
#

Thnx guys

rain heart
#

It is chatgpt

tidal idol
#

i do

jaunty plank
tidal idol
#

i leave comments

#

at least on my newer projects

#

mostly because i have the memory of a goldfish and will forget when i've implimented something

jaunty plank
#

Ideally code should just be readable though.

res.sendStatus(200); // Respond with a success status code
will take longer to read and understand than
res.sendStatus(200);

Sure, if you have a function or some weird bit of code comment, but not every line

tidal idol
#

well in CS class for GCSEs we were forced to add comments too

#

we were told to add comments under everything

#

same as the first few months of the college class for CS before I dropped out

jaunty plank
#

thats what is taught? wtf 👀

tidal idol
#

we were not given marks until comments added

#

yeah

#

we were told it was industry standard 😭

#

this was both Python and C#

jaunty plank
#

Thats actually wild

#

I love documenting stuff, but that's so overkill to the point its useless.

tidal idol
#

this was two diff teachers with two diff langs in two diff schools

golden stratus
#

Hello!
I've been sending tests, and I've been receiving them, now how do I make it so that when someone votes for my bot, it returns a message in a channel?

rain heart
#

Fetch the channel you wanna send it in, then just send it

golden stratus
#

But I put the app.post part in my api, and I wanted to add a value in the db as well

golden stratus
rain heart
#

ohh so your webhook webserver isnt directly within your bot itself?

golden stratus
#

Yes

rain heart
#

then I'd suggest just using webhooks

#

aka discord webhooks

#

to send the message in a channel

golden stratus
jaunty plank
#

Theres no reason you cant use mongodb and add a discord webhook to your code

golden stratus
jaunty plank
#

are you asking for help with doing that?

rain heart
#

then connect your server handling the vote requests to your mongodb and just write to your database

golden stratus
#

And then how do I do it right after voting for him that a message is sent on the channel

#

After having saved the value in the database of course

rain heart
#

add value to database
make webhook request to said discord webhook

onyx locust
#

It is just wanted an example KEKWDisco

small wraith
#

        
        id = interaction.user.id
        load_dotenv()
        key = str(os.environ.get("TOPTOKEN"))
        url = f"https://top.gg/api/bots/1063461122553942077/check?userId={id}"
        print(url)
        payload = {"Authorization": key}
        response = requests.get(url=url,headers=payload)
        print(response)

Error 401 ,key is correct

#

if I open the url in the webrowser it works

rain heart
#

the webbrowser one is entirely different from the api requests

#

also ensure to provide the content type json

#

in the headers

small wraith
rain heart
#

not what I meant

#

I means the headers should include the content type json

small wraith
rain heart
#

Ensure to provide Content-Type: application/json on your headers

small wraith
rain heart
#

yes

small wraith
#

same result

rain heart
#

then the token is actually invalid, press regenerate, refresh the site, then use the token visible

rain heart
#

the first part of your api token is always the same

#

just press regenerate, then refresh the site and the token there is then the new one

small wraith
#

ah sorry

small wraith
small wraith
rain heart
#

1 means has voted in the last 12 hours, 0 means didnt

#

bit weird but yeah

small wraith
#

ah very good thank you

dire bridge
#

Topggapi 😭

small wraith
rain heart
#

It does so after 12 hours

#

If you're planning on tracking if someone has voted and tried to use the command, either check that locally or use webhooks

small wraith
#

Okay I read the docs

small wraith
rain heart
#

using the test button

#

on the same page

small wraith
rain heart
#

nope not possible

small wraith
#

okay thank you very much

hearty estuary
#

Hey,
How can i set the Authorization in Webhooks?
I set the Authorization Header right?

rain heart
#

yes

last galleon
#

None

#

None

scarlet cobalt
#

One message removed from a suspended account.

queen isle
#

Hey folks,
how to test bot vote on development, with query parameters added to the url

TIA

onyx locust
#

On the top.gg website you should find a button “test” or something next to the webhook

queen isle
onyx locust
#

No you can’t

#

You need a public ip

queen isle
#

Noted, thank you!

restive otter
#

Hello, where can I find the top.gg token?

onyx locust
queen isle
#

Interesting, thanks for sharing this 💡

willow spindle
tough sparrow
#

I didn't do anything, but I was blocked by a probot, so they asked me to contact them via email on the probot site, what is the email?

rain heart
#

-wrongserver

abstract mothBOT
#

topggDotRed Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Discord Support Server" button on the bot's page of the bot you need support for. If there isn't a button that says "Discord Support Server" or nothing else mentioned about a support server, the server invite is invalid or you were banned from the bot's support server, then we can't help you. Sorry :(

rain heart
#

we cannot help

spare lion
#

Hello, I'm coding in Discord.js and have difficulties setting up an event listener for votes using webhooks.

In the dashboard in top.gg I've filled out my webhook URL to http://replace.this.my.public.ip:3000/vote using the IPv4 as IP from this https://whatismyipaddress.com/

In Authorization I've put in a random string or numbers and letters.

This is my code

const express = require('express');
const Topgg = require('@top-gg/sdk');
const app = express();

const webhook = new Topgg.Webhook(process.env.TopGG_Auth);

app.post('/vote', webhook.listener(async (vote) => {
    console.log(vote.user);

}));

app.listen(3000, () => {
    console.log('Webhook server is running.');
});

When I click "Send test" my bot doesn't do anything. What did I do wrong? I don't get any errors either.

#

Also it does log "Webhook server is running"

#

Ok I simplified it because that first code was ass KEKhands

#

I think it might have to do with my IP, but not sure

plucky lance
#

Do you run your code on PC at home or on a server with a static IP address?

#

Either way you have to allow incoming connections for this port (TCP)

#

A muss on your PC but optional on a server depending on your default INBOUND policy

#

The requirements of hosting at home is a public accessible IPv4 and port forwarding in your router

spare lion
#

Ah so I also need port forwarding on top of the public IPv4?

plucky lance
#

Yes else your router will drop the incoming connection on this port as it doesn't know where it belongs to

spare lion
#

Oh makes sense now why I didn't recieve anything when I hit send test

plucky lance
#

That's literally the worst advice you can give anyone

Opening a tunnel to a shady provider giving them access to your network

In the past they were at least an open source project but not anymore

Also there's nothing known about the company, employees etc.

You're literally allowing a stranger network to bypass NAT mapping and firewall restrictions

spare lion
#

Is it safe to just port forward in my router settings like so?

#

Or should I use something else like some kind of service?

#

I plan to also run the bot on my raspberri pi later

#

Well for now I added it and it seems to work, thanks for the help FaKE!

spare lion
jaunty plank
#

Just a 200/204 status code response.
Our webhooks retry if no response is sent

spare lion
# jaunty plank Just a 200/204 status code response. Our webhooks retry if no response is sent

It only logs the test once, does that mean it automatically sends a response when the code finishes?

When the code crashes within the listener it keeps trying to resending it and the same happens when the bot is offline. while when online with no crashes it only logs once.

const express = require('express');
const Topgg = require('@top-gg/sdk');
const app = express();

const webhook = new Topgg.Webhook(process.env.TopGG_Auth);

app.post('/vote', webhook.listener(async (vote) => {
    console.log(vote);
}));

app.listen(3000, () => {
    console.log('Webhook server is running.');
});
#

Mb if it's a dumb question, I'm still kinda new to this stuff KEKhands

jaunty plank
#

I dont belive test votes use the retrial system, since they are not "critical"

#

Only real votes

plucky lance
onyx locust
#

you can port forward it like that but make sure not to share your ip KEKWDisco

plucky lance
#

No he's successfully using his public IP together with his port forwarding

#

That's a controlled way of access not like exposing your device and network to some shady tunnel provider that been abused in past and today

#

It's technically even easier to use a 6to4 broker if you don't have a native IPv4 anymore than using such a service

#

I would also never recommend anyone routing his traffic through cloudflare
Not through any US company at all, especially not through services you can expect to fail

rain heart
#

also

#

EU laws

#

mm

plucky lance
#

Exactly

#

But respecting GDPR is far more complicated than that

#

This is api not development freerealestate

#

If parts of the name still contains your search pattern then yes it's correct

paper elk
#

having a problem with the topgg auto poster on nodejs

rain heart
#

Yes we're aware

#

site issues

#

-status

abstract mothBOT
#

topgg We are presently encountering a service disruption.
For additional details, kindly refer to the #site-status channel.

To receive notifications regarding future incidents or updates, you may assign the "Site Status" role to yourself by going here: id:customize.

paper elk
#

ah ok thanks

plucky lance
#

there ain't no time without issues mmLol

sinful lark
#

not sure if this is API related, but how do i add my bot's server count to top.gg?

#

for comparison, here's one that has server count

#

and here's mine that doesn't have server count

rain heart
#

-servercount

abstract mothBOT
waxen burrow
#

Im not sure if this is an issue with my end or topgg, but I got an error saying "No server is available to hand this request", is there any way of knowing what caused it?

plucky lance
#

The API might have some issues at the moment

#

Not sure if it's still up to date but probably

waxen burrow
#

Alright, thank you

meager helm
#

Hello, I need help with the api that checks if the user has voted, I'm doing a vote reward for my bot, but the api should be working, but in my case it always says: {"error":"Unauthorized"} , what could it be? a friend of mine said that it could be the bot not approved, but the bot was approved, could you help me with that?

onyx locust
#

I don’t think it was approved since you don’t have the bot dev role

#

The logs say it was approved

#

Idk

rain heart
#

You would not be able to obtain a API key in the first place if your bot isn't approved

rocky bough
vestal wasp
#

Yeah I’ve done that like 2 months ago already lol

rocky bough
meager helm
meager helm
restive otter
#

Not working for me

rain heart
#

What not working for you

broken topaz
#

Hello, I am wondering is this the correct way to post my bots server count to Top.gg? First I created a function called update_topgg() here: async def update_topgg():
url = f"https://top.gg/api/bots/{bot.user.id}/stats"
headers = {
"Authorization": config['topgg']['token'] # Use token from config
}
payload = {
"server_count" : len(bot.guilds)
}

async with aiohttp.ClientSession() as session:
    await session.post(url, data=payload, headers=headers) Then I create a call to that function when the bot starts here: @bot.event

async def on_ready():
try:
await bot.tree.sync()
logging.info('Bot is ready')
await update_topgg() # Update server count on top.gg
except Exception as e:
logging.error(f'Error occurred during on_ready event: {e}\n{traceback.format_exc()}') As a side note I don't know how to wrap code in this server so sorry for the incorrect formatting

rain heart
#

missing the application/json header in the headers

#

but seems fine

broken topaz
#

Thank you

#

Once I call this how long should I expect it to take for top.gg to update the server count? Also how do you guys handle people coding the message to lie and say the bot is in a hugh number of servers when it is not?

runic creek
rain heart
#

we do not remove the bot directly, we will reach out first

#

but yes we do not allow posting the wrong servercount

#

if it does happen accidentally or just varies between the actual servercount, thats entirely fine

#

unless its something like servercount being 50 on the bot, but posted was 50000

broken topaz
#

How do you guys cross check the number of servers the bot is in?

jaunty plank
#

discord provides server counts on the invite link

broken topaz
#

yeah, i see that thank you 🙂

mild canyon
#

-servercount

#

im having a problem with my server count i dont know how to fix it can anyone help me?

plucky lance
#

there's no issue with it, you have to actively post your server count to the topgg api

rain heart
plucky lance
#

u gotta post them frequently of course

mild canyon
mild canyon
#

ok now having a another problem idk how to get Top.gg token ?

plucky lance
#

it's on the website, edit your bot -> left menu -> webhook(s)

echo sparrow
rain heart
mossy osprey
rain heart
#

?

grave junco
mossy osprey
#

Esque me aparecía error en la pagina

rain heart
#

What error

visual verge
#

resolve Promise { { error: 'Unauthorized' } } undefined
TopGGAPIError: 401 Unauthorized (You need a token for this endpoint)

#

anyone knows why im getting this?

rain heart
#

Invalid token

#

If any token provided at all

visual verge
#

wait lemme recheck

plucky lance
#

If that's the correct path to your endpoint then yes, adding your public IP(v4) will work

#

Make sure to allow incoming connections on your system for port 8080

#

Is this a (static) server IP or your home IP?

#

Ok, so when trying to contact your own public IP form home 2 things need to be done/work

1st you need to forward the incoming port (8080) to the right network device (your PC) or the router will drop the packages as it doesn't know the recipient, since any of your network devices has the same public IP

2nd the router needs to support hairpinning aka NAT loopback in order to resolve your own public IP which many cheaper routers do not support

To "bypass" the 2nd issue you can try accessing this from your mobile phone for example not being connected to your home WiFi

However the 1st thing is necessary needed

#

Port forwarding can be done accessing your router's control panel/website

#

You simply configure to forward incoming data on TCP port 8080 being sent to your network device (PC)

#

Then this is technically impossible

#

Any carrier around the world uses it's mobile network just as gateway to get access their own network

Port forwarding is not possible here

gleaming rune
#

how to enable ad blocker

grizzled geyser
#
const par = {
    method: "POST",
    headers: {
        Authorization: "token_top_gg",
    },
    body: JSON.stringify({
        server_count: client.guilds.cache.size,
    }),
};

await fetch("https://top.gg/api/bots/id_bot/stats", par)
    .then((r) => r.json())
    .then(console.log);```
```json
{ "error": "Required parameter server_count or shards missing" }```
jaunty plank
dusk peak
#

How can I make my bot send a message on my server when someone vote for the bot ?

jaunty plank
dusk peak
jaunty plank
#

app.post just needs to be the path of the url, you do not need to include the ip

jaunty plank
#

Just the path you want to use.

/dblwebhook
/webhook
/anything

As long as its the same path you use in your url

dusk peak
#

I don't understand what url I should use

jaunty plank
# dusk peak I don't understand what url I should use

The url will be to your host.
ie; http://SERVERIP:PORT/PATH

The webhook url goes in the red area

Your authorization goes here & in the blue area
const webhook = new Topgg.Webhook("your webhook auth")

The auth can be anything as long as its the same between both.

jaunty plank
jaunty plank
golden stratus
jaunty plank
#

If you're unsure about your specific hosting method I might be able to look into it for you.

dapper copper
#

even after giving token this is the error .. can anyone help?

rain heart
#

Press regenerate on top.gg, refresh the page, then copy the new token there

brazen apex
rain heart
#

yup, needs a token

#

press regenerate, then refresh the page, then copy the token from there

random plank
#

pls can someone tell me which webhook its asking for like discord server webhook ?

rain heart
#

its not a discord webhook, its a webhook hosted by yourself through a webserver

rain heart
#

a webserver hosted on a vps for example yes

random plank
#

kk so what should be in the ULR cause its nothing there in the VPS called webhook

server address ?

rain heart
#

You might have seen webhooks mentioned in your apps' settings and wondered if they're something you should use. The answer, in a nutshell, is probably yes.
Webhooks are one way that apps can send automated messages or information to other apps. It's how PayPal tells your accounting app when your...

dapper copper
sick rune
#

same problem even the test on the top.gg website says unauhorized when it goes through for me

ruby light
#

is it possible to fetch reviews with the api?

willow spindle
#

no

somber sphinx
#
self.bot_webhook = topgg.WebhookManager(self).dbl_webhook("/dblwebook", str(read_json("databases","secrets")["topgg"]))
async def setup_hook(self):
    print(await self.bot_webhook.run(30854)) ```
```py
    @commands.Cog.listener()
    async def on_dbl_test(self, data):
        print(f"Received a test vote:\n{data}")

could you pease tell me if this is the correct way to implement webhook
ive tried this its printing None (and obviously not triggering the test vote event)

small wraith
#

What is the easiest Methode to Trigger a Event one time per User Vote?

runic creek
#

Webhook

devout gulch
#

How often would you recommend pushing the Stats to topgg?

#

Because of Ratelimits

lucid nova
#

i do every 10 min

jaunty plank
#

Every hour is fine too, many bots also do daily.

It's not really something that needs to be updated extremely often.

narrow zenith
#

I usually update it once a day

tulip quartz
#

Where can I suggest things? I am wondering why this endpoint wouldn't include something like last_voted timestamp:

rain heart
#

can be done by having your own webhook track that

#
tulip quartz
restive otter
#

ا

pliant flicker
#

is there a way for when a user vote or someone write a review it send in a channel with the webhook ?

#

because when i click on test nothing happen

runic creek
#

Because it's not that kind of webhook if you mean top.gg votes

#

You have to host such a webhook yourself on your vps to receive votes

#

Read the pinned messages, if you only need the messages without adding anything to the database then you can use the page that is given in the pinned