Skip to content

Commit 20232ec

Browse files
committed
Widget section in documentation added
1 parent 19abf60 commit 20232ec

1 file changed

Lines changed: 22 additions & 12 deletions

File tree

docs/api.rst

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ Client
3030
:members:
3131

3232

33-
3433
Event reference
3534
---------------
3635

@@ -50,32 +49,43 @@ Event reference
5049
async def on_dbl_vote(data):
5150
print(data)
5251

53-
The data returned can be found `here`_.
52+
The returned data can be found `here`_.
5453

5554
.. _here: https://top.gg/api/docs#webhooks
5655

57-
.. function:: on_dbl_test(data)
56+
Widgets
57+
-------
5858

59-
Called when someone tests webhook system for your bot on top.gg
59+
.. note:: General information about top.gg widgets can be in `top.gg docs`_.
6060

61-
:param data: The data with test info returned in dict object
61+
In topggpy, :class:`DBLClient` has a :meth:`generate_widget` method that takes an ``options`` dictionary as a parameter.
6262

63-
Example: ::
63+
All available values for each key:
64+
* ``bot_id``: ID of a bot to generate widget for. Must resolve to an ID of a valid bot when converted to a string;
65+
* ``format``: must be either ``png`` and ``svg``. Defaults to ``png``;
66+
* ``type``: used for short widgets (``). For large widget, must be an empty string;
67+
* ``noavatar``: indicates whether to exclude bot avatar from short widgets. Must be of type ``bool``;
68+
* ``colors``: a dictionary consisting of a parameter as a key and HEX color as value. ``color`` will be appended to the key in case ``key.endswith("color")`` returns False. All available fields are mentioned in `top.gg docs`_.
6469

65-
@bot.event
66-
async def on_dbl_test(data):
67-
print(data)
70+
Example: ::
6871

69-
The data returned can be found `here`_.
72+
print(await self.topggpy.generate_widget(
73+
{"id": 270904126974590976,
74+
format: "svg",
75+
colors: {
76+
"username": 0xFFFFFF,
77+
"top": 0x000000
78+
}
79+
}))
7080

71-
.. _here: https://top.gg/api/docs#webhooks
81+
.. _top.gg docs: https://top.gg/api/docs#widgets
7282

7383
Exceptions
7484
----------
7585

7686
The following exceptions are thrown by the library.
7787

78-
.. autoexception:: DBLException
88+
.. autoexception:: TopGGException
7989

8090
.. autoexception:: UnauthorizedDetected
8191

0 commit comments

Comments
 (0)