Skip to content

Commit 0db87d4

Browse files
authored
Add service: Discord Labs (#7)
1 parent 05c50b3 commit 0db87d4

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ See more examples [here](/examples).
121121
- [discordbotlist.com](https://discordbotlist.com) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.DiscordBotList))
122122
- [discordbot.world](https://discordbot.world) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.DiscordBotWorld))
123123
- [discordextremelist.xyz](https://discordextremelist.xyz) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.DiscordExtremeList))
124+
- [bots.discordlabs.org](https://bots.discordlabs.org) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.DiscordLabs))
124125
- [glennbotlist.xyz](https://glennbotlist.xyz) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.GlennBotList))
125126
- [lbots.org](https://lbots.org) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.LBots))
126127
- [listmybots.com](https://listmybots.com) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.ListMyBots))

dbots/service.py

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,51 @@ def get_user(self, user_id: str) -> HTTPResponse:
13311331
requires_token = True
13321332
)
13331333

1334+
class DiscordLabs(Service):
1335+
"""
1336+
Represents the Discord Labs service.
1337+
1338+
.. seealso::
1339+
- `Discord Labs Website <https://bots.discordlabs.org/>`_
1340+
- `Discord Labs API Documentation <https://docs.discordlabs.org/docs/api/api>`_
1341+
"""
1342+
1343+
BASE_URL = 'https://bots.discordlabs.org/v2'
1344+
1345+
@staticmethod
1346+
def aliases() -> list:
1347+
return ['discordlabs', 'discord-labs', 'discordlabs.org', 'bots.discordlabs.org']
1348+
1349+
@staticmethod
1350+
def _post(
1351+
http_client: HTTPClient, bot_id: str, token: str,
1352+
server_count = 0, user_count = 0,
1353+
voice_connections = 0, shard_count: int = None,
1354+
shard_id: int = None
1355+
) -> HTTPResponse:
1356+
payload = { 'server_count': server_count, 'token': token }
1357+
if shard_id and shard_count:
1358+
payload['shard_count'] = shard_count
1359+
return http_client.request(
1360+
method = 'POST',
1361+
path = f'{DiscordLabs.BASE_URL}/bot/{bot_id}/stats',
1362+
json = payload
1363+
)
1364+
1365+
def get_bot(self, bot_id: str) -> HTTPResponse:
1366+
"""|httpres|\n
1367+
Gets the bot listed on this service.
1368+
1369+
Parameters
1370+
-----------
1371+
bot_id: :class:`str`
1372+
The bot's ID.
1373+
"""
1374+
return self._request(
1375+
method = 'GET',
1376+
path = f'/bot/{bot_id}',
1377+
)
1378+
13341379
class GlennBotList(Service):
13351380
"""
13361381
Represents the Glenn Bot List service.
@@ -2087,6 +2132,6 @@ def get_unverified_bots(self) -> HTTPResponse:
20872132
Service.SERVICES = [
20882133
Arcane, Blist, BotListSpace, BotsDataBase, BotsForDiscord, BotsOnDiscord, Carbon,
20892134
DBLista, DiscordBotsCo, DiscordBotsGG, DiscordAppsDev, DiscordBoats,
2090-
DiscordBotList, DiscordBotWorld, DiscordExtremeList, GlennBotList,
2135+
DiscordBotList, DiscordBotWorld, DiscordExtremeList, DiscordLabs, GlennBotList,
20912136
LBots, ListMyBots, MythicalBots, SpaceBotsList, TopGG, WonderBotList, YABL
20922137
]

docs/api.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ Services
9191
.. autoclass:: DiscordExtremeList
9292
:members:
9393

94+
.. autoclass:: DiscordLabs
95+
:members:
96+
9497
.. autoclass:: GlennBotList
9598
:members:
9699

0 commit comments

Comments
 (0)