feat(docs): add RESTApp

This commit is contained in:
grey-cat-1908 2022-04-22 08:45:49 +03:00
parent 5b601fae0b
commit e96ef5e058
3 changed files with 19 additions and 3 deletions

View file

@ -16,6 +16,15 @@ Client
:decorator: :decorator:
RESTApp
-------
.. attributetable:: RESTApp
.. autoclass:: Client
:inherited-members:
Event Reference Event Reference
--------------- ---------------

View file

@ -1,3 +1,6 @@
# Copyright MelisaDev 2022 - Present
# Full MIT License can be found in `LICENSE.txt` at the project root.
import asyncio import asyncio
import logging import logging
import signal import signal
@ -7,8 +10,8 @@ from typing import Dict, List, Union, Any, Iterable, Optional, Callable
from .rest import RESTApp from .rest import RESTApp
from .core.gateway import GatewayBotInfo from .core.gateway import GatewayBotInfo
from .models.guild.channel import Channel, ChannelType, channel_types_for_converting from .models.guild.channel import Channel
from .models import User, Guild, Activity from .models import Activity
from .models.app.shard import Shard from .models.app.shard import Shard
from .models.app.intents import Intents from .models.app.intents import Intents
from .utils.snowflake import Snowflake from .utils.snowflake import Snowflake
@ -277,9 +280,11 @@ class Client:
In case the event returns multiple arguments, a :class:`tuple` containing those In case the event returns multiple arguments, a :class:`tuple` containing those
arguments is returned instead. arguments is returned instead.
This function returns the **first event that meets the requirements**. This function returns the **first event that meets the requirements**.
Examples Examples
-------- --------
Waiting for a user reply: :: Waiting for a user reply: ::
@client.listen @client.listen
async def on_message_create(message): async def on_message_create(message):
if message.content.startswith('$greet'): if message.content.startswith('$greet'):
@ -289,6 +294,7 @@ class Client:
return m.content == "hello" and channel.id == message.channel_id return m.content == "hello" and channel.id == message.channel_id
msg = await client.wait_for('on_message_create', check=check, timeout=10.0) msg = await client.wait_for('on_message_create', check=check, timeout=10.0)
await channel.send(f'Hello man!') await channel.send(f'Hello man!')
Parameters Parameters
---------- ----------
event_name: :class:`str` event_name: :class:`str`
@ -299,6 +305,7 @@ class Client:
timeout: Optional[:class:`float`] timeout: Optional[:class:`float`]
The number of seconds to wait before timing out and raising The number of seconds to wait before timing out and raising
:exc:`asyncio.TimeoutError`. :exc:`asyncio.TimeoutError`.
Returns Returns
------ ------
Any Any

View file

@ -104,7 +104,7 @@ class Gateway:
try: try:
self.ws = await self.__session.ws_connect( self.ws = await self.__session.ws_connect(
"wss://gateway.discord.gg/?v=10&encoding=json&compress=zlib-stream", "wss://gateway.discord.gg/?v=10&encoding=json&compress=zlib-stream",
timeout=30.0 timeout=30.0,
) )
_logger.debug("(Shard %s) Starting...", self.shard_id) _logger.debug("(Shard %s) Starting...", self.shard_id)