Skip to content

Commit 08b5c5e

Browse files
authored
Add service: BotsDataBase (#3)
1 parent f73af84 commit 08b5c5e

File tree

3 files changed

+81
-1
lines changed

3 files changed

+81
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ See more examples [here](/examples).
108108
### Supported Services
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))
111+
- [botsdatabase.com](https://botsdatabase.com/) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.BotsDataBase))
111112
- [botsfordiscord.com](https://botsfordiscord.com) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.BotsForDiscord))
112113
- [bots.ondiscord.xyz](https://bots.ondiscord.xyz) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.BotsOnDiscord))
113114
- [carbonitex.net](https://www.carbonitex.net/Discord/bots) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.Carbon))

dbots/service.py

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,82 @@ def get_widget_url(self, bot_id: str, style = 1, **query) -> str:
264264
"""
265265
return f'https://api.botlist.space/widget/{bot_id}/{style}?{_encode_query(query)}'
266266

267+
class BotsDataBase(Service):
268+
"""
269+
Represents the BotsDataBase service.
270+
271+
.. seealso::
272+
- `BotsDataBase Website <https://botsdatabase.com/>`_
273+
- `BotsDataBase API Documentation <https://docs.botsdatabase.com/>`_
274+
"""
275+
276+
BASE_URL = 'https://api.botsdatabase.com/v1'
277+
278+
@staticmethod
279+
def aliases() -> list:
280+
return ['botsdatabase', 'bdb']
281+
282+
@staticmethod
283+
def _post(
284+
http_client: HTTPClient, bot_id: str, token: str,
285+
server_count = 0, user_count = 0,
286+
voice_connections = 0, shard_count: int = None,
287+
shard_id: int = None
288+
) -> HTTPResponse:
289+
return http_client.request(
290+
method = 'POST',
291+
path = f'{BotsDataBase.BASE_URL}/bots/{bot_id}',
292+
headers = {
293+
'Authorization': token,
294+
'Content-Type': 'application/json'
295+
},
296+
json = { 'servers': server_count }
297+
)
298+
299+
def get_user(self, user_id: str) -> HTTPResponse:
300+
"""|httpres|\n
301+
Gets the user listed on this service.
302+
303+
Parameters
304+
-----------
305+
user_id: :class:`str`
306+
The user's ID.
307+
"""
308+
return self._request(
309+
method = 'GET',
310+
path = f'/users/{user_id}'
311+
)
312+
313+
def get_bot(self, user_id: str) -> HTTPResponse:
314+
"""|httpres|\n
315+
Gets the bot listed on this service.
316+
317+
Parameters
318+
-----------
319+
bot_id: :class:`str`
320+
The bot's ID.
321+
"""
322+
return self._request(
323+
method = 'GET',
324+
path = f'/bots/{user_id}'
325+
)
326+
327+
def get_bot_votes(self, bot_id: str) -> HTTPResponse:
328+
"""|httpres|\n
329+
Gets the list of people who voted this bot on this service.
330+
331+
Parameters
332+
-----------
333+
bot_id: :class:`str`
334+
The bot's ID.
335+
"""
336+
return self._request(
337+
method = 'GET',
338+
path = f'/bots/{bot_id}/votes',
339+
headers = { 'Authorization': self.token },
340+
requires_token = True
341+
)
342+
267343
class BotsForDiscord(Service):
268344
"""
269345
Represents the Bots For Discord service.
@@ -1869,7 +1945,7 @@ def get_unverified_bots(self) -> HTTPResponse:
18691945
)
18701946

18711947
Service.SERVICES = [
1872-
Arcane, BotListSpace, BotsForDiscord, BotsOnDiscord, Carbon,
1948+
Arcane, BotListSpace, BotsDataBase, BotsForDiscord, BotsOnDiscord, Carbon,
18731949
DBLista, DiscordBotsGG, DiscordAppsDev, DiscordBoats,
18741950
DiscordBotList, DiscordBotWorld, DiscordExtremeList, GlennBotList,
18751951
LBots, ListMyBots, MythicalBots, SpaceBotsList, TopGG, WonderBotList, YABL

docs/api.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ Services
5252
.. autoclass:: BotListSpace
5353
:members:
5454

55+
.. autoclass:: BotsDataBase
56+
:members:
57+
5558
.. autoclass:: BotsForDiscord
5659
:members:
5760

0 commit comments

Comments
 (0)