Skip to content

Commit 3c6f979

Browse files
authored
Add service: DiscordListology (#9)
1 parent 0db87d4 commit 3c6f979

File tree

3 files changed

+94
-2
lines changed

3 files changed

+94
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ See more examples [here](/examples).
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))
124124
- [bots.discordlabs.org](https://bots.discordlabs.org) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.DiscordLabs))
125+
- [discordlistology.com](https://discordlistology.com) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.DiscordListology))
125126
- [glennbotlist.xyz](https://glennbotlist.xyz) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.GlennBotList))
126127
- [lbots.org](https://lbots.org) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.LBots))
127128
- [listmybots.com](https://listmybots.com) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.ListMyBots))

dbots/service.py

Lines changed: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,94 @@ def get_bot(self, bot_id: str) -> HTTPResponse:
13761376
path = f'/bot/{bot_id}',
13771377
)
13781378

1379+
class DiscordListology(Service):
1380+
"""
1381+
Represents the DiscordListology service.
1382+
1383+
.. seealso::
1384+
- `DiscordListology Website <https://discordlistology.com/>`_
1385+
- `DiscordListology API Documentation <https://discordlistology.com/developer/documentation/>`_
1386+
"""
1387+
1388+
BASE_URL = 'https://discordlistology.com/api/v1'
1389+
1390+
@staticmethod
1391+
def aliases() -> list:
1392+
return ['discordlistology']
1393+
1394+
@staticmethod
1395+
def _post(
1396+
http_client: HTTPClient, bot_id: str, token: str,
1397+
server_count = 0, user_count = 0,
1398+
voice_connections = 0, shard_count: int = None,
1399+
shard_id: int = None
1400+
) -> HTTPResponse:
1401+
payload = { 'servers': server_count }
1402+
if shard_id and shard_count:
1403+
payload['shards'] = shard_count
1404+
return http_client.request(
1405+
method = 'POST',
1406+
path = f'{DiscordListology.BASE_URL}/bots/{bot_id}/stats',
1407+
headers = { 'Authorization': token },
1408+
json = payload
1409+
)
1410+
1411+
def get_bot_stats(self, bot_id: str) -> HTTPResponse:
1412+
"""|httpres|\n
1413+
Gets the bot's stats listed on this service.
1414+
Parameters
1415+
-----------
1416+
bot_id: :class:`str`
1417+
The bot's ID.
1418+
"""
1419+
return self._request(
1420+
method = 'GET',
1421+
path = f'/bots/{bot_id}/stats',
1422+
)
1423+
1424+
def user_voted_bot(self, bot_id: str, user_id: str) -> HTTPResponse:
1425+
"""|httpres|\n
1426+
Checks whether or not a user has voted for a bot on this service.
1427+
Parameters
1428+
-----------
1429+
bot_id: :class:`str`
1430+
The bot's ID.
1431+
user_id: :class:`str`
1432+
The user's ID.
1433+
"""
1434+
return self._request(
1435+
method = 'GET',
1436+
path = f'/bots/{bot_id}/hasvoted/{user_id}'
1437+
)
1438+
1439+
def get_guild_stats(self, guild_id: str) -> HTTPResponse:
1440+
"""|httpres|\n
1441+
Gets the guild's stats listed on this service.
1442+
Parameters
1443+
-----------
1444+
guild_id: :class:`str`
1445+
The guild's ID.
1446+
"""
1447+
return self._request(
1448+
method = 'GET',
1449+
path = f'/guilds/{bot_id}/stats',
1450+
)
1451+
1452+
def user_voted_guild(self, guild_id: str, user_id: str) -> HTTPResponse:
1453+
"""|httpres|\n
1454+
Checks whether or not a user has voted for a guild on this service.
1455+
Parameters
1456+
-----------
1457+
guild_id: :class:`str`
1458+
The guild's ID.
1459+
user_id: :class:`str`
1460+
The user's ID.
1461+
"""
1462+
return self._request(
1463+
method = 'GET',
1464+
path = f'/guilds/{bot_id}/hasvoted/{user_id}'
1465+
)
1466+
13791467
class GlennBotList(Service):
13801468
"""
13811469
Represents the Glenn Bot List service.
@@ -2132,6 +2220,6 @@ def get_unverified_bots(self) -> HTTPResponse:
21322220
Service.SERVICES = [
21332221
Arcane, Blist, BotListSpace, BotsDataBase, BotsForDiscord, BotsOnDiscord, Carbon,
21342222
DBLista, DiscordBotsCo, DiscordBotsGG, DiscordAppsDev, DiscordBoats,
2135-
DiscordBotList, DiscordBotWorld, DiscordExtremeList, DiscordLabs, GlennBotList,
2136-
LBots, ListMyBots, MythicalBots, SpaceBotsList, TopGG, WonderBotList, YABL
2223+
DiscordBotList, DiscordBotWorld, DiscordExtremeList, DiscordLabs, DiscordListology,
2224+
GlennBotList, LBots, ListMyBots, MythicalBots, SpaceBotsList, TopGG, WonderBotList, YABL
21372225
]

docs/api.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ Services
9494
.. autoclass:: DiscordLabs
9595
:members:
9696

97+
.. autoclass:: DiscordListology
98+
:members:
99+
97100
.. autoclass:: GlennBotList
98101
:members:
99102

0 commit comments

Comments
 (0)