Skip to content

Commit 2f9bae2

Browse files
committed
chore: reorder services
1 parent 007b610 commit 2f9bae2

File tree

1 file changed

+74
-74
lines changed

1 file changed

+74
-74
lines changed

dbots/service.py

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -350,20 +350,20 @@ def get_bots(self) -> HTTPResponse:
350350
)
351351

352352

353-
class DiscordBotsGG(Service):
353+
class DiscordBoats(Service):
354354
"""
355-
Represents the Discord Bots service.
355+
Represents the Discord Boats service.
356356
357357
.. seealso::
358-
- `Discord Bots Website <https://discord.bots.gg/>`_
359-
- `Discord Bots API Documentation <https://discord.bots.gg/docs>`_
358+
- `Discord Boats Website <https://discord.boats/>`_
359+
- `Discord Boats API Documentation <https://discord.boats/api/docs/>`_
360360
"""
361361

362-
BASE_URL = 'https://discord.bots.gg/api/v1'
362+
BASE_URL = 'https://discord.boats/api/v2'
363363

364364
@staticmethod
365365
def aliases() -> list:
366-
return ['discordbotsgg', 'discord.bots.gg']
366+
return ['discordboats', 'discord.boats']
367367

368368
@staticmethod
369369
def _post(
@@ -372,53 +372,71 @@ def _post(
372372
voice_connections: int = 0, shard_count: int = None,
373373
shard_id: int = None
374374
) -> HTTPResponse:
375-
payload = {'guildCount': server_count}
376-
if shard_id and shard_count:
377-
payload['shardId'] = shard_id
378-
payload['shardCount'] = shard_count
379375
return http_client.request(
380376
method='POST',
381-
path=f'{DiscordBotsGG.BASE_URL}/bots/{bot_id}/stats',
377+
path=f'{DiscordBoats.BASE_URL}/bot/{bot_id}',
382378
headers={'Authorization': token},
383-
json=payload
379+
json={'server_count': server_count}
384380
)
385381

386-
def get_bots(self, **query) -> HTTPResponse:
382+
def get_bot(self, bot_id: str) -> HTTPResponse:
387383
"""|httpres|\n
388-
Gets a list of bots on this service.
384+
Gets the bot listed on this service.
389385
390386
Parameters
391387
-----------
392-
**query
393-
The query string to append to the URL.
388+
bot_id: :class:`str`
389+
The bot's ID.
394390
"""
395391
return self._request(
396392
method='GET',
397-
path='/bots',
398-
query=query,
399-
headers={'Authorization': self.token},
400-
requires_token=True
393+
path=f'/bot/{bot_id}'
401394
)
402395

403-
def get_bot(self, bot_id: str, **query) -> HTTPResponse:
396+
def get_user(self, user_id: str) -> HTTPResponse:
404397
"""|httpres|\n
405-
Gets the bot listed on this service.
398+
Gets the user listed on this service.
399+
400+
Parameters
401+
-----------
402+
user_id: :class:`str`
403+
The user's ID.
404+
"""
405+
return self._request(
406+
method='GET',
407+
path=f'/user/{user_id}'
408+
)
409+
410+
def user_voted(self, bot_id: str, user_id: str) -> HTTPResponse:
411+
"""|httpres|\n
412+
Checks whether or not a user has reviewed a bot.
406413
407414
Parameters
408415
-----------
409416
bot_id: :class:`str`
410417
The bot's ID.
411-
**query
412-
The query string to append to the URL.
418+
user_id: :class:`str`
419+
The user's ID.
413420
"""
414421
return self._request(
415422
method='GET',
416-
path=f'/bots/{bot_id}',
417-
query=query,
418-
headers={'Authorization': self.token},
419-
requires_token=True
423+
path=f'/bot/{bot_id}/voted',
424+
query={'id': user_id}
420425
)
421426

427+
def get_widget_url(self, bot_id: str, **query) -> str:
428+
"""
429+
Gets the widget URL for this bot.
430+
431+
Parameters
432+
-----------
433+
bot_id: :class:`str`
434+
The bot's ID.
435+
**query
436+
The query string to append to the URL.
437+
"""
438+
return f'{DiscordBoats.BASE_URL}/widget/{bot_id}.svg?{_encode_query(query)}'
439+
422440

423441
class DiscordBotList(Service):
424442
"""
@@ -457,20 +475,20 @@ def _post(
457475
)
458476

459477

460-
class DiscordBoats(Service):
478+
class DiscordBotsGG(Service):
461479
"""
462-
Represents the Discord Boats service.
480+
Represents the Discord Bots service.
463481
464482
.. seealso::
465-
- `Discord Boats Website <https://discord.boats/>`_
466-
- `Discord Boats API Documentation <https://discord.boats/api/docs/>`_
483+
- `Discord Bots Website <https://discord.bots.gg/>`_
484+
- `Discord Bots API Documentation <https://discord.bots.gg/docs>`_
467485
"""
468486

469-
BASE_URL = 'https://discord.boats/api/v2'
487+
BASE_URL = 'https://discord.bots.gg/api/v1'
470488

471489
@staticmethod
472490
def aliases() -> list:
473-
return ['discordboats', 'discord.boats']
491+
return ['discordbotsgg', 'discord.bots.gg']
474492

475493
@staticmethod
476494
def _post(
@@ -479,71 +497,53 @@ def _post(
479497
voice_connections: int = 0, shard_count: int = None,
480498
shard_id: int = None
481499
) -> HTTPResponse:
500+
payload = {'guildCount': server_count}
501+
if shard_id and shard_count:
502+
payload['shardId'] = shard_id
503+
payload['shardCount'] = shard_count
482504
return http_client.request(
483505
method='POST',
484-
path=f'{DiscordBoats.BASE_URL}/bot/{bot_id}',
506+
path=f'{DiscordBotsGG.BASE_URL}/bots/{bot_id}/stats',
485507
headers={'Authorization': token},
486-
json={'server_count': server_count}
487-
)
488-
489-
def get_bot(self, bot_id: str) -> HTTPResponse:
490-
"""|httpres|\n
491-
Gets the bot listed on this service.
492-
493-
Parameters
494-
-----------
495-
bot_id: :class:`str`
496-
The bot's ID.
497-
"""
498-
return self._request(
499-
method='GET',
500-
path=f'/bot/{bot_id}'
508+
json=payload
501509
)
502510

503-
def get_user(self, user_id: str) -> HTTPResponse:
511+
def get_bots(self, **query) -> HTTPResponse:
504512
"""|httpres|\n
505-
Gets the user listed on this service.
513+
Gets a list of bots on this service.
506514
507515
Parameters
508516
-----------
509-
user_id: :class:`str`
510-
The user's ID.
517+
**query
518+
The query string to append to the URL.
511519
"""
512520
return self._request(
513521
method='GET',
514-
path=f'/user/{user_id}'
522+
path='/bots',
523+
query=query,
524+
headers={'Authorization': self.token},
525+
requires_token=True
515526
)
516527

517-
def user_voted(self, bot_id: str, user_id: str) -> HTTPResponse:
528+
def get_bot(self, bot_id: str, **query) -> HTTPResponse:
518529
"""|httpres|\n
519-
Checks whether or not a user has reviewed a bot.
530+
Gets the bot listed on this service.
520531
521532
Parameters
522533
-----------
523534
bot_id: :class:`str`
524535
The bot's ID.
525-
user_id: :class:`str`
526-
The user's ID.
536+
**query
537+
The query string to append to the URL.
527538
"""
528539
return self._request(
529540
method='GET',
530-
path=f'/bot/{bot_id}/voted',
531-
query={'id': user_id}
541+
path=f'/bots/{bot_id}',
542+
query=query,
543+
headers={'Authorization': self.token},
544+
requires_token=True
532545
)
533546

534-
def get_widget_url(self, bot_id: str, **query) -> str:
535-
"""
536-
Gets the widget URL for this bot.
537-
538-
Parameters
539-
-----------
540-
bot_id: :class:`str`
541-
The bot's ID.
542-
**query
543-
The query string to append to the URL.
544-
"""
545-
return f'{DiscordBoats.BASE_URL}/widget/{bot_id}.svg?{_encode_query(query)}'
546-
547547

548548
class DiscordExtremeList(Service):
549549
"""

0 commit comments

Comments
 (0)