Skip to content

Commit 2e9e388

Browse files
committed
fix!: update BotsForDiscord to DiscordsCom
1 parent 3375ca5 commit 2e9e388

File tree

2 files changed

+123
-106
lines changed

2 files changed

+123
-106
lines changed

dbots/service.py

Lines changed: 120 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -248,106 +248,6 @@ def get_widget_url(self, bot_id: str, widget_type: str = 'normal', **query) -> s
248248
return f'{Blist.BASE_URL}/widget/{bot_id}.svg?{_encode_query(query)}'
249249

250250

251-
class BotsForDiscord(Service):
252-
"""
253-
Represents the Bots For Discord service.
254-
255-
.. seealso::
256-
- `Bots For Discord Website <https://botsfordiscord.com/>`_
257-
- `Bots For Discord API Documentation <https://docs.botsfordiscord.com/>`_
258-
"""
259-
260-
BASE_URL = 'https://botsfordiscord.com/api'
261-
262-
@staticmethod
263-
def aliases() -> list:
264-
return ['botsfordiscord', 'botsfordiscord.com']
265-
266-
@staticmethod
267-
def _post(
268-
http_client: HTTPClient, bot_id: str, token: str,
269-
server_count: int = 0, user_count: int = 0,
270-
voice_connections: int = 0, shard_count: int = None,
271-
shard_id: int = None
272-
) -> HTTPResponse:
273-
return http_client.request(
274-
method='POST',
275-
path=f'{BotsForDiscord.BASE_URL}/bot/{bot_id}',
276-
headers={'Authorization': token},
277-
json={'server_count': server_count}
278-
)
279-
280-
def get_bot(self, bot_id: str) -> HTTPResponse:
281-
"""|httpres|\n
282-
Gets the bot listed on this service.
283-
284-
Parameters
285-
-----------
286-
bot_id: :class:`str`
287-
The bot's ID.
288-
"""
289-
return self._request(
290-
method='GET',
291-
path=f'/bot/{bot_id}'
292-
)
293-
294-
def get_bot_votes(self, bot_id: str) -> HTTPResponse:
295-
"""|httpres|\n
296-
Gets the list of people who voted this bot on this service.
297-
298-
Parameters
299-
-----------
300-
bot_id: :class:`str`
301-
The bot's ID.
302-
"""
303-
return self._request(
304-
method='GET',
305-
path=f'/bot/{bot_id}/votes',
306-
requires_token=True
307-
)
308-
309-
def get_user(self, user_id: str) -> HTTPResponse:
310-
"""|httpres|\n
311-
Gets the user listed on this service.
312-
313-
Parameters
314-
-----------
315-
user_id: :class:`str`
316-
The user's ID.
317-
"""
318-
return self._request(
319-
method='GET',
320-
path=f'/user/{user_id}'
321-
)
322-
323-
def get_user_bots(self, user_id: str) -> HTTPResponse:
324-
"""|httpres|\n
325-
Gets the user's bots listed for this service.
326-
327-
Parameters
328-
-----------
329-
user_id: :class:`str`
330-
The user's ID.
331-
"""
332-
return self._request(
333-
method='GET',
334-
path=f'/user/{user_id}/bots'
335-
)
336-
337-
def get_widget_url(self, bot_id: str, **query) -> str:
338-
"""
339-
Gets the widget URL for this bot.
340-
341-
Parameters
342-
-----------
343-
bot_id: :class:`str`
344-
The bot's ID.
345-
**query
346-
The query string to append to the URL.
347-
"""
348-
return f'{BotsForDiscord.BASE_URL}/bot/{bot_id}/widget?{_encode_query(query)}'
349-
350-
351251
class BotsOnDiscord(Service):
352252
"""
353253
Represents the Bots On Discord service.
@@ -822,7 +722,7 @@ def _post(
822722
return http_client.request(
823723
method='POST',
824724
path=f'{DiscordListSpace.BASE_URL}/bots/{bot_id}',
825-
headers={'Authorization': token},
725+
headers={'Authorization': token, 'Content-Type': 'application/json'},
826726
json={'server_count': server_count}
827727
)
828728

@@ -1150,6 +1050,123 @@ def user_voted_guild(self, guild_id: str, user_id: str) -> HTTPResponse:
11501050
)
11511051

11521052

1053+
class DiscordsCom(Service):
1054+
"""
1055+
Represents the Discords.com service (formerly Bots For Discord).
1056+
1057+
.. seealso::
1058+
- `Discords.com service Website <https://discords.com/bots>`_
1059+
- `Discords.com service API Documentation <https://docs.botsfordiscord.com/>`_
1060+
"""
1061+
1062+
BASE_URL = 'https://discords.com/bots/api'
1063+
1064+
@staticmethod
1065+
def aliases() -> list:
1066+
return ['botsfordiscord', 'botsfordiscord.com', 'discords', 'discords.com']
1067+
1068+
@staticmethod
1069+
def _post(
1070+
http_client: HTTPClient, bot_id: str, token: str,
1071+
server_count: int = 0, user_count: int = 0,
1072+
voice_connections: int = 0, shard_count: int = None,
1073+
shard_id: int = None
1074+
) -> HTTPResponse:
1075+
return http_client.request(
1076+
method='POST',
1077+
path=f'{DiscordsCom.BASE_URL}/bot/{bot_id}',
1078+
headers={'Authorization': token, 'Content-Type': 'application/json'},
1079+
json={'server_count': server_count}
1080+
)
1081+
1082+
def get_bot(self, bot_id: str) -> HTTPResponse:
1083+
"""|httpres|\n
1084+
Gets the bot listed on this service.
1085+
1086+
Parameters
1087+
-----------
1088+
bot_id: :class:`str`
1089+
The bot's ID.
1090+
"""
1091+
return self._request(
1092+
method='GET',
1093+
path=f'/bot/{bot_id}'
1094+
)
1095+
1096+
def get_bot_votes(self, bot_id: str) -> HTTPResponse:
1097+
"""|httpres|\n
1098+
Gets the list of people who voted a bot.
1099+
1100+
Parameters
1101+
-----------
1102+
bot_id: :class:`str`
1103+
The bot's ID.
1104+
"""
1105+
return self._request(
1106+
method='GET',
1107+
path=f'/bot/{bot_id}/votes',
1108+
headers={'Authorization': self.token, 'Content-Type': 'application/json'},
1109+
requires_token=True
1110+
)
1111+
1112+
def get_bot_votes_12h(self, bot_id: str) -> HTTPResponse:
1113+
"""|httpres|\n
1114+
Gets the list of people who voted a bot in the last 12 hours.
1115+
1116+
Parameters
1117+
-----------
1118+
bot_id: :class:`str`
1119+
The bot's ID.
1120+
"""
1121+
return self._request(
1122+
method='GET',
1123+
path=f'/bot/{bot_id}/votes12h',
1124+
headers={'Authorization': self.token, 'Content-Type': 'application/json'},
1125+
requires_token=True
1126+
)
1127+
1128+
def get_user(self, user_id: str) -> HTTPResponse:
1129+
"""|httpres|\n
1130+
Gets the user listed on this service.
1131+
1132+
Parameters
1133+
-----------
1134+
user_id: :class:`str`
1135+
The user's ID.
1136+
"""
1137+
return self._request(
1138+
method='GET',
1139+
path=f'/user/{user_id}'
1140+
)
1141+
1142+
def get_user_bots(self, user_id: str) -> HTTPResponse:
1143+
"""|httpres|\n
1144+
Gets the user's bots listed for this service.
1145+
1146+
Parameters
1147+
-----------
1148+
user_id: :class:`str`
1149+
The user's ID.
1150+
"""
1151+
return self._request(
1152+
method='GET',
1153+
path=f'/user/{user_id}/bots'
1154+
)
1155+
1156+
def get_widget_url(self, bot_id: str, **query) -> str:
1157+
"""
1158+
Gets the widget URL for this bot.
1159+
1160+
Parameters
1161+
-----------
1162+
bot_id: :class:`str`
1163+
The bot's ID.
1164+
**query
1165+
The query string to append to the URL.
1166+
"""
1167+
return f'{DiscordsCom.BASE_URL}/bot/{bot_id}/widget?{_encode_query(query)}'
1168+
1169+
11531170
class SpaceBotsList(Service):
11541171
"""
11551172
Represents the Space Bots List service.
@@ -1573,8 +1590,8 @@ def get_unverified_bots(self) -> HTTPResponse:
15731590

15741591

15751592
Service.SERVICES = [
1576-
Blist, BotsForDiscord, BotsOnDiscord, Carbon,
1593+
Blist, BotsOnDiscord, Carbon,
15771594
DiscordBotsGG, DiscordBoats, DiscordBotList,
15781595
DiscordExtremeList, DiscordLabs, DiscordListSpace, DiscordListology,
1579-
SpaceBotsList, TopCord, TopGG, WonderBotList, YABL
1596+
DiscordsCom, SpaceBotsList, TopCord, TopGG, WonderBotList, YABL
15801597
]

docs/api.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ Services
4949
.. autoclass:: Blist
5050
:members:
5151

52-
.. autoclass:: BotsForDiscord
53-
:members:
54-
5552
.. autoclass:: BotsOnDiscord
5653
:members:
5754

@@ -79,6 +76,9 @@ Services
7976
.. autoclass:: DiscordListology
8077
:members:
8178

79+
.. autoclass:: DiscordsCom
80+
:members:
81+
8282
.. autoclass:: SpaceBotsList
8383
:members:
8484

0 commit comments

Comments
 (0)