Skip to content

Commit 02a3c92

Browse files
committed
Add BotsOfDiscord service
1 parent dcd5a0e commit 02a3c92

File tree

3 files changed

+73
-2
lines changed

3 files changed

+73
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ See more examples [here](/examples).
109109
- [arcane-center.xyz](https://arcane-center.xyz) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.Arcane))
110110
- [botlist.space](https://botlist.space) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.BotListSpace))
111111
- [botsfordiscord.com](https://botsfordiscord.com) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.BotsForDiscord))
112+
- [b-o-d.cf](https://b-o-d.cf) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.BotsOfDiscord))
112113
- [top.gg](https://top.gg) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.TopGG))
113114
- [discord.bots.gg](https://discord.bots.gg) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.DiscordBotsGG))
114115
- *More services will be supported in a future release...*

dbots/service.py

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ def aliases() -> list:
118118
def _post(
119119
http_client: HTTPClient, bot_id: str, token: str,
120120
server_count = 0, user_count = 0,
121-
voice_connections = 0, shard_count: int = None,
122-
shard_id: int = None
121+
shard_count: int = None, shard_id: int = None
123122
) -> HTTPResponse:
124123
payload = {
125124
'server_count': server_count,
@@ -358,6 +357,74 @@ def get_widget_url(self, bot_id: str, **query) -> str:
358357
"""
359358
return f'{BotsForDiscord.BASE_URL}/bot/{bot_id}/widget?{_encode_query(query)}'
360359

360+
class BotsOfDiscord(Service):
361+
"""
362+
Represents the Bots Of Discord service.
363+
364+
.. seealso::
365+
- `Bots Of Discord Website <https://b-o-d.cf/>`_
366+
"""
367+
368+
BASE_URL = 'https://www.b-o-d.cf/api'
369+
370+
@staticmethod
371+
def aliases() -> list:
372+
return ['botsofdiscord', 'b-o-d', 'b-o-d.cf']
373+
374+
@staticmethod
375+
def _post(
376+
http_client: HTTPClient, bot_id: str, token: str,
377+
server_count = 0, shard_count: int = None,
378+
shard_id: int = None
379+
) -> HTTPResponse:
380+
payload = { 'server_count': server_count }
381+
if shard_id and shard_count:
382+
payload['shard_count'] = shard_count
383+
return http_client.request(
384+
method = 'POST',
385+
path = f'{BotsOfDiscord.BASE_URL}/bots/stats',
386+
headers = { 'Authorization': token },
387+
json = payload
388+
)
389+
390+
def get_bot(self, bot_id: str) -> HTTPResponse:
391+
"""|httpres|\n
392+
Gets the bot's stats on this service.
393+
394+
Parameters
395+
-----------
396+
bot_id: :class:`str`
397+
The bot's ID.
398+
"""
399+
return self._request(
400+
method = 'GET',
401+
path = f'/bot/{bot_id}/stats'
402+
)
403+
404+
def get_bot_votes(self) -> HTTPResponse:
405+
"""|httpres|\n
406+
Gets the list of people who voted this bot on this service.
407+
"""
408+
return self._request(
409+
method = 'GET',
410+
path = f'/bot/votes',
411+
requires_token = True
412+
)
413+
414+
def get_user(self, user_id: str) -> HTTPResponse:
415+
"""|httpres|\n
416+
Gets the user listed on this service.
417+
418+
Parameters
419+
-----------
420+
user_id: :class:`str`
421+
The user's ID.
422+
"""
423+
return self._request(
424+
method = 'GET',
425+
path = f'/users/{user_id}'
426+
)
427+
361428
class DiscordBotsGG(Service):
362429
"""
363430
Represents the Discord Bots service.

docs/api.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ Services
5555
.. autoclass:: BotsForDiscord
5656
:members:
5757

58+
.. autoclass:: BotsOfDiscord
59+
:members:
60+
5861
.. autoclass:: DiscordBotsGG
5962
:members:
6063

0 commit comments

Comments
 (0)