|
81 | 81 |
|
82 | 82 | This Event will be triggered if a Button, that is attached to a Message wich is in the internal Cache, is pressed.
|
83 | 83 |
|
84 |
| - :param interaction: The `Interaction <./interaction.html#interaction>`_-object with all his attributes and methods to respond to the interaction |
| 84 | + :param interaction: The `Interaction <./interaction.html#Interaction>`_-object with all his attributes and methods to respond to the interaction |
85 | 85 | :type interaction: :class:`discord.Interaction`
|
86 | 86 | :param button: The `ButtonClick <./interaction.html#ButtonClick>`_ if the message is ephemeral else `Button <./components.html#Button>`_. (this is also in the first parameter under ``component``).
|
87 | 87 | :type button: Union[:class:`Button`, :class:`ButtonClick`]
|
|
303 | 303 | :param embeds: A list of up to 10 :class:`discord.Embed`'s to replace the previous ones(This is also usable for normal Messages).
|
304 | 304 | :type embeds: Optional[List[:class:`discord.Embed`]]
|
305 | 305 |
|
306 |
| -.. toctree:: |
| 306 | +utils |
| 307 | +~~~~~ |
| 308 | + |
| 309 | +.. function:: styled_timestamp(timestamp, style) |
| 310 | + |
| 311 | + A small function that returns a styled timestamp for discord, this will be displayed accordingly in the Discord client depending on the :attr:`style` specified. |
| 312 | + |
| 313 | + Timestamps will display the given timestamp in the user's timezone and locale. |
| 314 | + |
| 315 | + :param timestamp: Union[`datetime.datetime <https://docs.python.org/3/library/datetime.html>`_, :class:`int`] |
| 316 | + The timestamp; A :class:`datetime.datetime` object or an already completed timestamp. |
| 317 | + |
| 318 | + :param style: Optional[Union[:class:`TimestampStyle`, :class:`str`]] |
| 319 | + How the timestamp should be displayed in Discord; this can either be a :class:`TimestampStyle` or directly the associated value. |
| 320 | + |
| 321 | + :default: :class:`TimestampStyle.short` |
| 322 | + |
| 323 | + **Example** |
| 324 | + |
| 325 | + .. code-block:: python |
| 326 | +
|
| 327 | + @client.command() |
| 328 | + async def time(ctx): |
| 329 | + await ctx.send(discord.utils.styled_timestamp(datetime.now(), discord.TimestampStyle.long)) |
| 330 | +
|
| 331 | +.. class:: TimestampStyle |
| 332 | + |
| 333 | + .. note:: |
| 334 | + This is located in discord.enums but i place it here |
| 335 | + |
| 336 | + The Styles you could use for the :attr:`style` of a :class:`styled_timestamp` |
| 337 | + |
| 338 | + See also in the `Discord-Documentation <https://discord.com/developers/docs/reference#message-formatting-timestamp-styles>`_ |
| 339 | + |
| 340 | + +----------------------------------+-------+-----------------+--------------------------------+ |
| 341 | + | NAME | VALUE | DESCRIPTION | EXAMPLE | |
| 342 | + +==================================+=======+=================+================================+ |
| 343 | + | .. attribute:: short_time | 't' | Short Time | .. image:: imgs/short_time.png | |
| 344 | + +----------------------------------+-------+-----------------+--------------------------------+ |
| 345 | + | .. attribute:: long_time | 'T' | Long Time | .. image:: imgs/long_time.png | |
| 346 | + +----------------------------------+-------+-----------------+--------------------------------+ |
| 347 | + | .. attribute:: short_date | 'd' | Short Date | .. image:: imgs/short_date.png | |
| 348 | + +----------------------------------+-------+-----------------+--------------------------------+ |
| 349 | + | .. attribute:: long_date | 'D' | Long Date | .. image:: imgs/long_date.png | |
| 350 | + +----------------------------------+-------+-----------------+--------------------------------+ |
| 351 | + | .. attribute:: short | 'f' | Short Date/Time | .. image:: imgs/short.png | |
| 352 | + +----------------------------------+-------+-----------------+--------------------------------+ |
| 353 | + | .. attribute:: long | 'F' | Long Date/Time | .. image:: imgs/long.png | |
| 354 | + +----------------------------------+-------+-----------------+--------------------------------+ |
| 355 | + | .. attribute:: relative | 'R' | Relative Time | .. image:: imgs/relative.png | |
| 356 | + +----------------------------------+-------+-----------------+--------------------------------+ |
| 357 | + |
| 358 | +.. toctree:: |
307 | 359 | :maxdepth: 3
|
308 | 360 | :caption: Contents:
|
309 | 361 |
|
|
0 commit comments