Skip to content

Commit 9b063bb

Browse files
committed
Add botsfordiscord
1 parent 49e5dd7 commit 9b063bb

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ See more examples [here](/examples).
107107

108108
### Supported Services
109109
- [botlist.space](https://botlist.space)
110-
- [top.gg (formerly discordbots.org)](https://top.gg)
110+
- [botsfordiscord.com](https://botsfordiscord.com)
111+
- [top.gg](https://top.gg)
111112
- [discord.bots.gg](https://discord.bots.gg)
112113
- *More services will be supported in a future release...*
113114

dbots/service.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,59 @@ def get_user_bots(self, user_id) -> HTTPResponse:
109109
def get_widget_url(self, bot_id, style = 1, **query) -> str:
110110
return f'https://api.botlist.space/widget/{bot_id}/{style}?{_encode_query(query)}'
111111

112+
class BotsForDiscord(Service):
113+
"""
114+
Represents the Bots For Discord's service.
115+
116+
.. seealso::
117+
`Service's API Documentation <https://docs.botsfordiscord.com/>`_
118+
API Documentation for Bots For Discord
119+
"""
120+
121+
BASE_URL = 'https://botsfordiscord.com/api'
122+
123+
@staticmethod
124+
def _post(
125+
http_client, bot_id, token,
126+
server_count = 0, user_count = 0,
127+
voice_connections = 0, shard_count = None,
128+
shard_id = None
129+
):
130+
return http_client.request(
131+
method = 'POST',
132+
path = f'{BotsForDiscord.BASE_URL}/bot/{bot_id}',
133+
headers = { 'Authorization': token },
134+
json = { 'server_count': server_count }
135+
)
136+
137+
def get_bot(self, bot_id) -> HTTPResponse:
138+
return self._request(
139+
method = 'GET',
140+
path = f'/bot/{bot_id}'
141+
)
142+
143+
def get_bot_votes(self, bot_id) -> HTTPResponse:
144+
return self._request(
145+
method = 'GET',
146+
path = f'/bot/{bot_id}/votes',
147+
requires_token = True
148+
)
149+
150+
def get_user(self, user_id) -> HTTPResponse:
151+
return self._request(
152+
method = 'GET',
153+
path = f'/user/{user_id}'
154+
)
155+
156+
def get_user_bots(self, user_id) -> HTTPResponse:
157+
return self._request(
158+
method = 'GET',
159+
path = f'/user/{user_id}/bots'
160+
)
161+
162+
def get_widget_url(self, bot_id, **query) -> str:
163+
return f'{BotsForDiscord.BASE_URL}/bot/{bot_id}/widget?{_encode_query(query)}'
164+
112165
class DiscordBotsGG(Service):
113166
"""
114167
Represents the discord.bots.gg service.
@@ -236,6 +289,10 @@ def get_widget_url(self, bot_id, small_widget = None, **query) -> str:
236289
'botlist.space': BotListSpace,
237290
'bls': BotListSpace,
238291

292+
'botsfordiscord': BotsForDiscord,
293+
'botsfordiscord.com': BotsForDiscord,
294+
'bfd': BotsForDiscord,
295+
239296
'discordbotsgg': DiscordBotsGG,
240297
'discord.bots.gg': DiscordBotsGG,
241298
'dbotsgg': DiscordBotsGG,

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ Services
120120
Supported Services
121121
~~~~~~~~~~~~~~~~~~
122122
- `botlist.space <https://botlist.space>`_
123+
- `botsfordiscord.com <botsfordiscord.com>`_
123124
- `top.gg <https://top.gg>`_
124125
- `discord.bots.gg <https://discord.bots.gg>`_
125126
- *More services will be supported in a future release...*

0 commit comments

Comments
 (0)