@@ -9,15 +9,16 @@ The community-maintained Python library for Top.gg.
99- [ Usage] ( #usage )
1010 - [ Getting a bot] ( #getting-a-bot )
1111 - [ Getting several bots] ( #getting-several-bots )
12- - [ Getting your bot 's voters] ( #getting-your-bots -voters )
13- - [ Check if a user has voted for your bot ] ( #check-if-a-user-has-voted-for-your-bot )
12+ - [ Getting your project 's voters] ( #getting-your-projects -voters )
13+ - [ Getting your project's vote information of a user ] ( #getting-your-projects-vote-information-of-a-user )
1414 - [ Getting your bot's server count] ( #getting-your-bots-server-count )
1515 - [ Posting your bot's server count] ( #posting-your-bots-server-count )
16+ - [ Posting your bot's application commands list] ( #posting-your-bots-application-commands-list )
1617 - [ Automatically posting your bot's server count every few minutes] ( #automatically-posting-your-bots-server-count-every-few-minutes )
1718 - [ Checking if the weekend vote multiplier is active] ( #checking-if-the-weekend-vote-multiplier-is-active )
1819 - [ Generating widget URLs] ( #generating-widget-urls )
1920 - [ Webhooks] ( #webhooks )
20- - [ Being notified whenever someone voted for your bot ] ( #being-notified-whenever-someone-voted-for-your-bot )
21+ - [ Being notified whenever someone voted for your project ] ( #being-notified-whenever-someone-voted-for-your-project )
2122
2223## Installation
2324
@@ -34,7 +35,6 @@ import topgg
3435
3536import os
3637
37-
3838async with topgg.Client(os.getenv(' TOPGG_TOKEN' )) as client:
3939 # ...
4040```
@@ -46,7 +46,6 @@ import topgg
4646
4747import os
4848
49-
5049client = topgg.Client(os.getenv(' TOPGG_TOKEN' ))
5150
5251# ...
@@ -82,7 +81,7 @@ for bot in bots:
8281 print (bot)
8382```
8483
85- ### Getting your bot 's voters
84+ ### Getting your project 's voters
8685
8786#### First page
8887
@@ -102,44 +101,88 @@ for voter in voters:
102101 print (voter)
103102```
104103
105- ### Check if a user has voted for your bot
104+ ### Getting your project's vote information of a user
105+
106+ #### Discord ID
106107
107108``` py
108- has_voted = await client.has_voted(661200758510977084 )
109+ vote = await client.get_vote(661200758510977084 )
110+
111+ if vote:
112+ print (f ' User has voted: { vote!r } ' )
113+ ```
114+
115+ #### Top.gg ID
116+
117+ ``` py
118+ vote = await client.get_vote(8226924471638491136 , source = topgg.UserSource.TOPGG )
119+
120+ if vote:
121+ print (f ' User has voted: { vote!r } ' )
109122```
110123
111124### Getting your bot's server count
112125
113126``` py
114- posted_server_count = await client.get_server_count ()
127+ posted_server_count = await client.get_bot_server_count ()
115128```
116129
117130### Posting your bot's server count
118131
119132``` py
120- await client.post_server_count(bot.server_count)
133+ await client.post_bot_server_count(bot.server_count)
134+ ```
135+
136+ ### Posting your bot's application commands list
137+
138+ #### Discord.py/Pycord/Nextcord/Disnake
139+
140+ ``` py
141+ app_id = bot.user.id
142+ commands = await bot.http.get_global_commands(app_id)
143+
144+ await client.post_bot_commands(commands)
145+ ```
146+
147+ #### Hikari
148+
149+ ``` py
150+ app_id = ...
151+ commands = await bot.rest.request(' GET' , f ' /applications/ { app_id} /commands ' )
152+
153+ await client.post_bot_commands(commands)
154+ ```
155+
156+ #### Discord.http
157+
158+ ``` py
159+ http = discordhttp.HTTP(f ' BOT { os.getenv(" BOT_TOKEN" )} ' )
160+ app_id = ...
161+ commands = await http.get(f ' /applications/ { app_id} /commands ' )
162+
163+ await client.post_bot_commands(commands)
121164```
122165
123166### Automatically posting your bot's server count every few minutes
124167
125168``` py
126- @client.autopost_retrieval
169+ @client.bot_autopost_retrieval
127170def get_server_count () -> int :
128171 return bot.server_count
129172
130- @client.autopost_success
173+ @client.bot_autopost_success
131174def success (server_count : int ) -> None :
132175 print (f ' Successfully posted { server_count} servers to Top.gg! ' )
133176
134- @client.autopost_error
177+ @client.bot_autopost_error
135178def error (error : topgg.Error) -> None :
136179 print (f ' Error: { error!r } ' )
137180
138- client.start_autoposter ()
181+ client.start_bot_autoposter ()
139182
140183# ...
141184
142- client.stop_autoposter () # Optional
185+ client.stop_bot_autoposter () # Optional
143186```
144187
145188### Checking if the weekend vote multiplier is active
@@ -176,19 +219,18 @@ widget_url = topgg.widget.social(topgg.WidgetType.DISCORD_BOT, 57465275174577766
176219
177220### Webhooks
178221
179- #### Being notified whenever someone voted for your bot
222+ #### Being notified whenever someone voted for your project
180223
181224``` py
182225import topgg
183226
184227import asyncio
185228import os
186229
187-
188230webhooks = topgg.Webhooks(os.getenv(' MY_TOPGG_WEBHOOK_SECRET' ), 8080 )
189231
190232@webhooks.on_vote (' /votes' )
191- def voted (vote : topgg.Vote ) -> None :
233+ def voted (vote : topgg.VoteEvent ) -> None :
192234 print (f ' A user with the ID of { vote.voter_id} has voted us on Top.gg! ' )
193235
194236async def main () -> None :
0 commit comments