Skip to content

Commit aadb4c6

Browse files
authored
Add service: TopCord (#8)
1 parent 3c6f979 commit aadb4c6

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ See more examples [here](/examples).
128128
- [listmybots.com](https://listmybots.com) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.ListMyBots))
129129
- [mythicalbots.xyz](https://mythicalbots.xyz) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.MythicalBots))
130130
- [space-bot-list.xyz](https://space-bot-list.xyz) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.SpaceBotsList))
131+
- [topcord.xyz](https://topcord.xyz) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.TopCord))
131132
- [top.gg](https://top.gg) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.TopGG))
132133
- [wonderbotlist.com](https://wonderbotlist.com) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.WonderBotList))
133134
- [yabl.xyz](yabl.xyz) ([docs](https://dbots.readthedocs.io/en/latest/api.html#dbots.YABL))

dbots/service.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1892,6 +1892,52 @@ def get_bot(self, bot_id: str) -> HTTPResponse:
18921892
path = f'/bots/{bot_id}'
18931893
)
18941894

1895+
class TopCord(Service):
1896+
"""
1897+
Represents the TopCord service.
1898+
1899+
.. seealso::
1900+
- `TopCord Website <https://topcord.xyz/>`_
1901+
- `TopCord API Documentation <https://docs.topcord.xyz/#/API>`_
1902+
"""
1903+
1904+
BASE_URL = 'https://topcord.xyz/api'
1905+
1906+
@staticmethod
1907+
def aliases() -> list:
1908+
return ['topcord', 'topcord.xyz']
1909+
1910+
@staticmethod
1911+
def _post(
1912+
http_client: HTTPClient, bot_id: str, token: str,
1913+
server_count = 0, user_count = 0,
1914+
voice_connections = 0, shard_count: int = None,
1915+
shard_id: int = None
1916+
) -> HTTPResponse:
1917+
payload = { 'guilds': server_count }
1918+
if shard_id and shard_count:
1919+
payload['shards'] = shard_count
1920+
return http_client.request(
1921+
method = 'POST',
1922+
path = f'{TopCord.BASE_URL}/bot/stats/{bot_id}',
1923+
headers = { 'Authorization': token },
1924+
json = payload
1925+
)
1926+
1927+
def get_bot(self, bot_id: str) -> HTTPResponse:
1928+
"""|httpres|\n
1929+
Gets the bot listed on this service.
1930+
1931+
Parameters
1932+
-----------
1933+
bot_id: :class:`str`
1934+
The bot's ID.
1935+
"""
1936+
return self._request(
1937+
method = 'GET',
1938+
path = f'/bot/{bot_id}',
1939+
)
1940+
18951941
class TopGG(Service):
18961942
"""
18971943
Represents the Top.gg service.
@@ -2221,5 +2267,5 @@ def get_unverified_bots(self) -> HTTPResponse:
22212267
Arcane, Blist, BotListSpace, BotsDataBase, BotsForDiscord, BotsOnDiscord, Carbon,
22222268
DBLista, DiscordBotsCo, DiscordBotsGG, DiscordAppsDev, DiscordBoats,
22232269
DiscordBotList, DiscordBotWorld, DiscordExtremeList, DiscordLabs, DiscordListology,
2224-
GlennBotList, LBots, ListMyBots, MythicalBots, SpaceBotsList, TopGG, WonderBotList, YABL
2270+
GlennBotList, LBots, ListMyBots, MythicalBots, SpaceBotsList, TopCord, TopGG, WonderBotList, YABL
22252271
]

docs/api.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ Services
112112
.. autoclass:: SpaceBotsList
113113
:members:
114114

115+
.. autoclass:: TopCord
116+
:members:
117+
115118
.. autoclass:: TopGG
116119
:members:
117120

0 commit comments

Comments
 (0)