API Reference¶
Discord.py IPC Extension¶
A upgraded version of discord-ext-ipc that now works with discord.py v2.
- copyright:
2020-present Ext-Creators, No767
- license:
Apache-2.0, see LICENSE for more details
Client¶
- class discord.ext.ipcx.Client(host: str = 'localhost', port: int | None = None, multicast_port: int = 20000, secret_key: str | None = None)¶
Handles webserver side requests to the bot process.
Operations with
async withwill automatically initialize the client and automatically cleans up.- Parameters:
host (str) – The IP or host of the IPC server, defaults to localhost
Optional[port] (int) – The port of the IPC server. If not supplied the port will be found automatically, defaults to None
multicast_port (Optional[int]) – The mutlicast post of the IPC server. If not supplied, the port used will be 20000.
secret_key (Union[str, bytes]) – The secret key for your IPC server. Must match the server secret_key or requests will not go ahead, defaults to None
- async close() None¶
Properly closes the
aiohttp.ClientSessionsession used for connectionsWarning
This is required in order to clean up any remaining connections held in
aiohttp.ClientSession. Without doing so, your webserver will complain about having an unclosed client session, which is the result of not closing it manually.
Server¶
- class discord.ext.ipcx.Server(bot: Bot, host: str = 'localhost', port: int = 8765, secret_key: str | None = None, do_multicast: bool = True, multicast_port: int = 20000)¶
The IPC server. Usually used on the bot process for receiving requests from the client.
- secret_key¶
A secret key. Used for authentication and should be the same as your client’s secret key.
- Type:
- async handle_accept(request: Request)¶
Handles websocket requests from the client process.
- Parameters:
request (
Request) – The request made by the client, parsed by aiohttp.
- async handle_multicast(request: Request)¶
Handles multicasting websocket requests from the client.
- Parameters:
request (
Request) – The request made by the client, parsed by aiohttp.
- route(name=None)¶
Used to register a coroutine as an endpoint when you have access to an instance of
Server.- Parameters:
name (str) – The endpoint name. If not provided the method name will be used.
- update_endpoints()¶
Called internally to update the server’s endpoints for cog routes.
Exceptions¶
- exception discord.ext.ipcx.errors.IPCError¶
Base IPC exception class
- exception discord.ext.ipcx.errors.JSONEncodeError¶
Raise upon un-serializable objects are given to the IPC
- exception discord.ext.ipcx.errors.NoEndpointFoundError¶
Raised upon requesting an invalid endpoint
- exception discord.ext.ipcx.errors.NotConnectedError¶
Raised upon websocket not connected
- exception discord.ext.ipcx.errors.ServerConnectionRefusedError¶
Raised upon a server refusing to connect / not being found