Python package¶
Modules of the Discord Proxy package that are relevant for clients.
Client¶
Client API for external apps using discordproxy.
- class DiscordClient(target: str = None, options=None, timeout=None)¶
Client for interacting with Discord.
- Raises:
DiscordProxyHttpError – HTTP error from the Discord API
DiscordProxyGrpcError – gRPC error from the gRPC protocol
- Parameters:
target – The address of the Discord Proxy gRPC server. Default is: “localhost:50051”
options – An optional list of key-value pairs to configure the gRPC channel.
timeout – Default timeout for gRPC method invocations in seconds. If not specified the timeout is about 30 minutes.
- create_channel_message(channel_id: int, content: str = '', embed: Embed = None) Message ¶
Create new message in a channel.
- Parameters:
channel_id – ID of channel to create message in
content – Text of the message
embed – Embed of the message
- Returns:
Created message
- create_direct_message(user_id: int, content: str = '', embed: Embed = None) Message ¶
Create new direct message.
- Parameters:
user_id – ID of user to create direct message for
content – Text of the message
embed – Embed of the message
- Returns:
Created message
- get_guild_channels(guild_id: int) Iterable[Channel] ¶
Get all channels.
- Parameters:
guild_id – ID of guild to get the channel for
- Returns:
Guild channels
Exceptions¶
Custom exceptions for discordproxy.
- exception DiscordProxyException¶
An exception generated by Discord Proxy.
- exception DiscordProxyGrpcError(status: StatusCode, details: str)¶
gRPC error created by the gRPC protocol.
These are usually caused by issues with the Discord Proxy gRPC server, e.g. a failed network connection.
- property details: str¶
Details about the error state.
- property status: StatusCode¶
GRPC status code. See also: Status codes and their use in gRPC
- exception DiscordProxyHttpError(status: int, code: int, text: str)¶
HTTP error created by the Discord API.
These are usually caused by API errors on the Discord server.
- property code: str¶
JSON error code.
- property status: int¶
HTTP status code.
- property text: str¶
Error message.
- exception DiscordProxyTimeoutError(status: StatusCode, details: str)¶
The gRPC method timed out.
- to_discord_proxy_exception(ex: Exception) DiscordProxyException ¶
Convert gRPC exception to a discordproxy exception.
Will remain unchanged if it is not a gRPC exception.
gRPC classes¶
Client and server classes corresponding to protobuf-defined services.
- class DiscordApi¶
Provides access to the Discord API
- class DiscordApiServicer¶
Provides access to the Discord API
- GetGuildChannels(request, context)¶
Get the list of channel for a guild
- SendChannelMessage(request, context)¶
Send a message to a guild channel
- SendDirectMessage(request, context)¶
Send a direct message to a user
- class DiscordApiStub(channel)¶
Provides access to the Discord API
Constructor.
- Parameters:
channel – A grpc.Channel.
Generated protocol buffer code.
Helpers¶
Helpers for client apps.
- class GrpcErrorDetails(type, status, code, text)¶
Create new instance of GrpcErrorDetails(type, status, code, text)
- code¶
Alias for field number 2
- status¶
Alias for field number 1
- text¶
Alias for field number 3
- type¶
Alias for field number 0
- parse_error_details(grpc_error: RpcError) GrpcErrorDetails ¶
Helper for parsing the details of a gRPC error exception into a named tuple. Recognizes a Discord error encoded as JSON