3333
3434import aiohttp
3535from aiohttp import ClientResponse
36- from .ratelimiter import AsyncRateLimiter
3736
3837from . import __version__ , errors
38+ from .ratelimiter import AsyncRateLimiter
3939
4040log = logging .getLogger (__name__ )
4141
@@ -85,15 +85,12 @@ def __init__(self, token, **kwargs):
8585 self ._global_over = asyncio .Event ()
8686 self ._global_over .set ()
8787
88- user_agent = 'topggpy (https://github.com/top-gg/python-sdk {0}) Python/{1[0]}.{1[' \
89- '1]} aiohttp/{2}'
90- self .user_agent = user_agent .format (__version__ , sys .version_info , aiohttp .__version__ )
91-
92- # NOTE: current implementation doesn't maintain state over restart
88+ self .user_agent = f"topggpy (https://github.com/top-gg/python-sdk { __version__ } ) Python/" \
89+ f"{ sys .version_info [0 ]} .{ sys .version_info [1 ]} aiohttp/{ aiohttp .__version__ } "
9390
9491 async def request (self , method , url , ** kwargs ) -> Union [dict , str ]:
9592 """Handles requests to the API."""
96- url = "{0}{1}" . format ( self .BASE , url )
93+ url = f" { self .BASE } { url } "
9794
9895 # handles rate limits.
9996 # max_calls is set to 59 because current implementation will retry in 60s
@@ -182,11 +179,11 @@ async def get_weekend_status(self):
182179
183180 async def get_guild_count (self , bot_id ):
184181 """Gets the guild count of the given Bot ID."""
185- return await self .request ('GET' , '/bots/{}/stats' . format ( bot_id ) )
182+ return await self .request ('GET' , f '/bots/{ bot_id } /stats' )
186183
187184 async def get_bot_info (self , bot_id ):
188185 """Gets the information of a bot under given bot ID on top.gg."""
189- resp : Union [dict , str ] = await self .request ('GET' , '/bots/{}' . format ( bot_id ) )
186+ resp : Union [dict , str ] = await self .request ('GET' , f '/bots/{ bot_id } ' )
190187 resp ['date' ] = datetime .strptime (resp ['date' ], '%Y-%m-%dT%H:%M:%S.%fZ' )
191188 for k in resp :
192189 if resp [k ] == '' :
@@ -195,26 +192,26 @@ async def get_bot_info(self, bot_id):
195192
196193 async def get_bot_upvotes (self , bot_id ):
197194 """Gets your bot's last 1000 votes on top.gg."""
198- return await self .request ('GET' , '/bots/{}/votes' . format ( bot_id ) )
195+ return await self .request ('GET' , f '/bots/{ bot_id } /votes' )
199196
200197 async def get_bots (self , limit , offset , sort , search , fields ):
201198 """Gets an object of bots on top.gg."""
202199 if limit > 500 :
203200 limit = 50
204201 fields = ', ' .join (fields )
205- search = ' ' .join (['{ }: {}' . format ( field , value ) for field , value in search .items ()])
202+ search = ' ' .join ([f' { field } : { value } ' for field , value in search .items ()])
206203
207204 return await self .request ('GET' , '/bots' , params = {
208205 'limit' : limit , 'offset' : offset , 'sort' : sort , 'search' : search , 'fields' : fields
209206 })
210207
211208 async def get_user_info (self , user_id ):
212209 """Gets an object of the user on top.gg."""
213- return await self .request ('GET' , '/users/{}' . format ( user_id ) )
210+ return await self .request ('GET' , f '/users/{ user_id } ' )
214211
215212 async def get_user_vote (self , bot_id , user_id ):
216213 """Gets info whether the user has upvoted your bot."""
217- return await self .request ('GET' , '/bots/{}/check' . format ( bot_id ) , params = {'userId' : user_id })
214+ return await self .request ('GET' , f '/bots/{ bot_id } /check' , params = {'userId' : user_id })
218215
219216
220217async def _ratelimit_handler (until ):
0 commit comments