API

Client

Method

class pyrevolt.Method

Bases: enum.Enum

Values:
  • GET

  • POST

  • PUT

  • DELETE

  • PATCH

Request

class pyrevolt.Request(method, url, **kwargs)

A request to be sent to the server. The URL should include the leading slash.

Parameters:
  • method (Method The HTTP method to use when sending the request) –

  • url (str The URL to send the request to.) –

  • kwargs

    • data: Optional - POST data to be sent.

    • headers: Optional - HTTP headers to be sent.

    • params: Optional - GET parameters to be sent.

Returns:

Request The request object.

AddAuthentication(token, bot)

Adds authentication to the request.

Parameters:
  • token (str The bot token.) –

  • bot (bool Whether the request is made to be executed by a bot.) –

Returns None:

None

HTTPClient

class pyrevolt.HTTPClient

A client for sending requests to the server.

Returns:

HTTPClient The client object.

Request(request)

This method is a coroutine.

Sends a request to the given request URL.

Parameters:

request (Request The request to send.) –

Returns:

dict The JSON response from the server.

Close()

This method is a coroutine.

Closes the client.

Returns None:

None

Gateway

GatewayEvent

class pyrevolt.GatewayEvent

Bases: enum.Enum

Values:
  • Authenticate

  • BeginTyping

  • EndTyping

  • Ping

  • Error

  • Authenticated

  • Bulk

  • Pong

  • Ready

  • ReadySimplified

  • OnMessage

  • MessageUpdate

  • MessageDelete

  • ChannelCreate

  • ChannelUpdate

  • ChannelDelete

  • ChannelGroupJoin

  • ChannelGroupLeave

  • ChannelStartTyping

  • ChannelStopTyping

  • ChannelAck

  • ServerCreate

  • ServerUpdate

  • ServerDelete

  • ServerMemberJoin

  • ServerMemberLeave

  • ServerMemberUpdate

  • ServerRoleUpdate

  • ServerRoleDelete

  • UserUpdate

  • UserRelationship

GatewayKeepAlive

class pyrevolt.GatewayKeepAlive(*args, gateway, interval, **kwargs)

Bases: threading.Thread

A thread that keeps the gateway alive by sending a ping for every defined interval.

Parameters:
  • args (tuple The arguments to pass to the thread.) –

  • gateway (Gateway The gateway to keep alive.) –

  • interval (float The interval in seconds to send a ping.) –

  • kwargs – The keyword arguments to pass to the thread.

Return GatewayKeepAlive:

The gateway keep alive thread.

run()

The thread’s main run loop. This method executes a ping every interval seconds.

Returns None:

None

GetPayload()

Gets the payload to send to the gateway.

Returns:

dict The payload to send to the gateway.

Gateway

class pyrevolt.Gateway

A gateway to connect to the Revolt API.

Returns:

Gateway The gateway object.

GetWebsocketURL()

This method is a coroutine.

Gets the websocket URL to connect to from the Revolt API. This method is automatically called before connecting.

Returns:

str The websocket URL to connect to.

Connect()

This method is a coroutine.

Connects to the websocket and starts the GatewayKeepAlive thread.

Returns None:

None

Close()

This method is a coroutine.

Closes the websocket and stops the GatewayKeepAlive thread.

Returns None:

None

Send(payload)

This method is a coroutine.

Sends a payload to the websocket.

Parameters:

payload (dict The payload to send.) –

Returns None:

None

Receive()

This method is a coroutine.

Receives a payload from the websocket.

Returns:

dict The payload received from the websocket.

Authenticate(token)

This method is a coroutine.

Authenticates the gateway with an existing token.

Parameters:

token (str The bot token.) –

Returns None:

None

Structures

User

Relationship

class pyrevolt.Relationship

Bases: enum.Enum

Values:
  • Blocked

  • BlockedOther

  • Friend

  • Incoming

  • Outgoing

  • NoRelationship

  • User

Presence

class pyrevolt.Presence

Bases: enum.Enum

Values:
  • Busy

  • Idle

  • Invisible

  • Online

Status

class pyrevolt.Status(presence, **kwargs)

The status a user can have. This includes their presence and any custom text.

Parameters:
  • presence (Presence The presence of the user.) –

  • kwargs

    • text: Optional - The custom text of the status.

__repr__()

Gets the string representation of the status.

Returns:

str The string representation of the status.

<pyrevolt.Status presence={self.presence.value} text={self.text}>

static FromJSON(data)

This method is a coroutine.

Creates a status from a JSON object.

Parameters:

data (dict The JSON object.) –

Returns:

Status The status.

BotUser

class pyrevolt.BotUser(ownerID)

A bot user.

Parameters:

ownerID (str The ID of the bot owner.) –

Returns:

BotUser The bot user.

__repr__()

Gets the string representation of the bot user.

Returns:

str The string representation of the bot user.

<pyrevolt.Bot owner={self.ownerID}>

User

class pyrevolt.User(userID, username, **kwargs)

A user.

Parameters:
  • userID (str The ID of the user.) –

  • username (str The username of the user.) –

  • kwargs

    • badges: Optional - The badges of the user in int form.

    • online: Optional - Whether the user is online in bool form.

    • relationship: Optional - The Relationship of the user.

    • status: Optional - The Status of the user.

    • flags: Optional - The flags of the user in int form.

    • bot: Optional - The BotUser object, if a user is a bot.

__repr__()

Gets the string representation of the user.

Returns:

str The string representation of the user.

<pyrevolt.User id={self.userID} username={self.username} badges={self.badges} relationship={self.relationship} online={self.online} bot={self.bot}>

__str__()

Get the username of the user.

Returns:

str The username of the user.

copy()

Creates a copy of the user.

Returns:

User The copy of the user.

update(updateData, clear)

Updates the user with the data from the update data.

Parameters:
  • updateData (dict The update data.) –

  • clear (list[str] Items to clear data from.) –

Returns None:

None

property mention

Returns a string format to mention the user.

Type:

str

static FromJSON(jsonData, session)

This method is a coroutine.

Creates a user from a JSON object.

Parameters:
  • jsonData (str|bytes The JSON formatted string.) –

  • session (Session The session object.) –

Returns:

User The user.

static FromID(userID, session)

This method is a coroutine.

Get a user from a user ID. This will attempt to fetch from the cache first.

Parameters:
  • userID (str The ID of the user.) –

  • session (Session The session object.) –

Returns:

User The user.

static AttemptParse(content, session)

This method is a coroutine.

Attempts to parse a user from a string.

Parameters:
  • content (str The string to parse.) –

  • session (Session The session object.) –

Returns:

User|bool The user or False if there is no user in the content.

Channels

ChannelType

class pyrevolt.ChannelType

Bases: enum.Enum

Values:
  • SavedMessages

  • DirectMessages

  • Group

  • TextChannel

  • VoiceChannel

Channel

class pyrevolt.Channel(channelID, type, **kwargs)

A channel with an associated type.

Parameters:
  • channelID (str The ID of the channel.) –

  • type (ChannelType The type of the channel.) –

  • kwargs

    • session: Optional - A Session object.

update(updateData, clear)

Updates the channel with the data from the update data.

Parameters:
  • updateData (dict The update data.) –

  • clear (list[str] Items to clear data from.) –

Returns None:

None

static FromJSON(jsonData, session)

This method is a coroutine.

Creates a channel from a JSON object.

Parameters:
  • jsonData (str|bytes The JSON formatted string.) –

  • session (Session The session object.) –

Returns:

Channel The channel.

static FromID(channelID, session)

This method is a coroutine.

Get a channel from a channel ID. This will attempt to fetch from the cache first.

Parameters:
  • channelID (str The ID of the channel.) –

  • session (Session The session object.) –

Returns:

Channel The channel.

static AttemptParse(content, session)

This method is a coroutine.

Attempts to parse a channel from a string.

Parameters:
  • content (str The string to parse.) –

  • session (Session The session object.) –

Returns:

Channel|bool The channel or False if there is no channel in the content.

Send(**kwargs)

Sends a message to the channel.

Parameters:

kwargs (dict The message data.) –

Returns None:

None

SavedMessages

class pyrevolt.SavedMessages(channelID, user, **kwargs)

Bases: Channel

A saved messages channel.

Parameters:
  • channelID (str The ID of the channel.) –

  • user (User The user the saved messages are with.) –

  • kwargs

    • session: Optional - Parameters to pass to Channel.

__repr__()

Gets the string representation of the channel.

Returns:

str The string representation of the channel.

<pyrevolt.SavedMessages id={self.channelID} user={self.user}>

copy()

Creates a copy of the channel.

Returns:

SavedMessages The copy of the channel.

DirectMessage

class pyrevolt.DirectMessage(channelID, active, recipients, **kwargs)

Bases: Channel

A direct message channel.

Parameters:
  • channelID (str The ID of the channel.) –

  • active (bool Whether the direct message is active or not.) –

  • recipients (list[User] The users the direct message is with.) –

  • kwargs

    • session: Optional - Session to pass to Channel constructor.

__repr__()

Gets the string representation of the channel.

Returns:

str The string representation of the channel.

<pyrevolt.DirectMessage id={self.channelID} active={self.active} recipients={self.recipients}>

copy()

Creates a copy of the channel.

Returns:

DirectMessage The copy of the channel.

Group

class pyrevolt.Group(channelID, name, recipients, owner, **kwargs)

Bases: Channel

A group channel.

Parameters:
  • channelID (str The ID of the channel.) –

  • name (str The name of the group.) –

  • recipients (list[User] The users the group is with.) –

  • owner (User The owner of the group.) –

  • kwargs

    • session: Optional - Session to pass to Channel constructor.

    • description: Optional - The description in str form for the group.

    • lastMessageID: Optional - The str ID of the last message in the group.

    • permissions: Optional - The permissions in int form for the group.

    • nsfw: Optional - A bool the group is NSFW or not.

__repr__()

Gets the string representation of the channel.

Returns:

str The string representation of the channel.

<pyrevolt.Group id={self.channelID} name={self.name} recipients={self.recipients} owner={self.owner}>

__str__()

Get the name of the group.

Returns:

str The name of the group.

copy()

Creates a copy of the channel.

Returns:

Group The copy of the channel.

ServerChannel

class pyrevolt.ServerChannel(channelID, type, server, name, **kwargs)

Bases: Channel

A server channel.

Parameters:
  • channelID (str The ID of the channel.) –

  • type (ChannelType The type of the channel.) –

  • server (Server The server the channel is in.) –

  • name (str The name of the channel.) –

  • kwargs

    • session: Optional - Session to pass to Channel constructor.

    • description: Optional - The description in str form for the channel.

    • defaultPermissions: Optional - The default permissions in int form for the channel.

    • nsfw: Optional - A bool the channel is NSFW or not.

__str__()

Get the name of the channel.

Returns:

str The name of the channel.

TextChannel

class pyrevolt.TextChannel(channelID, server, name, **kwargs)

Bases: ServerChannel

A text channel.

Parameters:
  • channelID (str The ID of the channel.) –

  • server (Server The server the channel is in.) –

  • name (str The name of the channel.) –

  • kwargs

    • session: Optional - Session to pass to ServerChannel constructor.

    • description: Optional - The description in str form for the channel.

    • defaultPermissions: Optional - The default permissions in int form for the channel.

    • nsfw: Optional - A bool the channel is NSFW or not.

    • lastMessageID: Optional - The str ID of the last message in the channel.

__repr__()

Gets the string representation of the channel.

Returns:

str The string representation of the channel.

<pyrevolt.TextChannel id={self.channelID} server={self.server.serverID} name={self.name}>

copy()

Creates a copy of the channel.

Returns:

TextChannel The copy of the channel.

VoiceChannel

class pyrevolt.VoiceChannel(channelID, server, name, **kwargs)

Bases: ServerChannel

A voice channel.

Parameters:
  • channelID (str The ID of the channel.) –

  • server (Server The server the channel is in.) –

  • name (str The name of the channel.) –

  • kwargs

    • session: Optional - Session to pass to ServerChannel constructor.

    • description: Optional - The description in str form for the channel.

    • defaultPermissions: Optional - The default permissions in int form for the channel.

    • nsfw: Optional - A bool the channel is NSFW or not.

__repr__()

Gets the string representation of the channel.

Returns:

str The string representation of the channel.

<pyrevolt.VoiceChannel id={self.channelID} server={self.server.serverID} name={self.name}>

copy()

Creates a copy of the channel.

Returns:

VoiceChannel The copy of the channel.

Messages

EmbedType

class pyrevolt.EmbedType

Bases: enum.Enum

Values:
  • Website

  • Image

  • Text

EmbedImageSize

class pyrevolt.EmbedImageSize

Bases: enum.Enum

Values:
  • Large

  • Preview

Embed

class pyrevolt.Embed(type, **kwargs)

An embed in a message.

Parameters:
  • type (EmbedType The type of the embed.) –

  • kwargs

    • url - Optional - The URL in str form for the embed (Required for EmbedType.Image).

    • specials - Optional - A dict of special embed types, only applicable to EmbedType.Website.

    • title - Optional - The title in str form for the embed.

    • description - Optional - The description in str form for the embed.

    • siteName - Optional - The site name in str form for the embed.

    • iconURL - Optional - The icon URL in str form for the embed.

    • colour - Optional - The colour in str form (#xxxxxx) for the embed.

    • width - Required for `EmbedType.Image` - The width in int form for the embed.

    • height - Required for `EmbedType.Image` - The height in int form for the embed.

    • size - Required for `EmbedType.Image` - The size in EmbedImageSize form for the embed.

__repr__()

Gets the string representation of the embed.

Returns:

str The string representation of the embed.

<pyrevolt.Embed type={self.type}>

toJSON()

Gets the JSON representation of the embed.

Returns:

str The JSON representation of the embed.

static FromJSON(jsonData)

Creates an embed from the JSON representation.

Parameters:

json (str|bytes The JSON representation of the embed.) –

Returns:

Embed The embed.

static Create(**kwargs)

Create a Text embed from the specified kwargs

Parameters:

kwargs

  • iconURL: Optional - The icon URL in str form for the embed.

  • url: Optional - The URL in str form for the embed.

  • title: Optional - The title in str form for the embed.

  • description: Optional - The description in str form for the embed.

  • colour: Optional - The colour in str form (#xxxxxx) for the embed.

Masquerade

class pyrevolt.Masquerade(**kwargs)

Masquerade with a different avatar and/or name.

Parameters:

kwargs

  • avatar: Optional - The avatar URL in str form for the masquerade.

  • name: Optional - The name in str form for the masquerade.

Returns:

Masquerade The masquerade.

static FromJSON(jsonData)

Creates a masquerade from the JSON representation.

Parameters:

json (str|bytes The JSON representation of the masquerade.) –

Returns:

Masquerade The masquerade.

Reply

class pyrevolt.Reply(messageID, mention)

A reply to a message.

Parameters:
  • messageID (str The ID of the message.) –

  • mention (str The mention in str form for the reply.) –

Returns:

Reply The reply.

static FromJSON(jsonData)

Creates a reply from the JSON representation.

Parameters:

json (str|bytes The JSON representation of the reply.) –

Returns:

Reply The reply.

Message

class pyrevolt.Message(messageID, channel, author, **kwargs)

A message.

Parameters:
  • messageID (str The ID of the message.) –

  • channel (Channel The channel the message is in.) –

  • author (User The author of the message.) –

  • kwargs

    • content: Optional - The str content for the message.

    • nonce - Optional - The nonce (number used once) in str form for the message.

    • edited - Optional - The time the message was edited in datetime form.

    • embeds - Optional - A list of embeds in Embed form for the message.

    • mentions - Optional - A list of mentions in User form for the message.

    • replies - Optional - A list of replies in Reply form for the message.

    • masquerade - Optional - The masquerade in Masquerade form for the message.

    • session - Optional - The Session to cache the message.

__repr__()

Gets the string representation of the message.

Returns:

str The string representation of the message.

<pyrevolt.Message id={self.messageID} channel={self.channel} author={self.author}>

copy()

Gets a copy of the message.

Returns:

Message The copy of the message.

update(updatedData)

This method is a coroutine.

Updates the message with the specified data.

Parameters:

updatedData (dict The updated data.) –

Returns None:

None.

property url

The URL of the message in str form.

Type:

str

static FromJSON(jsonData, session)

This method is a coroutine.

Creates a message from the JSON representation.

Parameters:
  • json (str|bytes The JSON representation of the message.) –

  • session (Session The session to cache the message.) –

Returns:

Message The message.

static FromID(channelID, messageID, session)

This method is a coroutine.

Gets a message from the specified channel and ID. If the message is not cached, it will be fetched from the API.

Parameters:
  • channelID (str The ID of the channel.) –

  • messageID (str The ID of the message.) –

  • session (Session The session to cache the message.) –

Returns:

Message The message.

static generateMessageData(**kwargs)

This method is a coroutine.

Generates a dictionary with the message data for the given kwargs.

Parameters:

kwargs

  • content: Optional - The content in str form for the message.

  • replies: Optional - A list of replies in Reply form for the message.

  • embed: Optional - An Embed to attach with the message.

  • embeds: Optional - A list of embeds in Embed form for the message.

  • masquerade: Optional - The Masquerade of which to alter the bot to.

Send(**kwargs)

This method is a coroutine.

Sends the message.

Parameters:

kwargs

  • content: Optional - The content in str form for the message.

  • replies: Optional - A list of replies in Reply form for the message.

  • embed: Optional - An Embed to attach with the message.

  • embeds: Optional - A list of embeds in Embed form for the message.

  • masquerade: Optional - The Masquerade of which to alter the bot to.

Returns:

Message The sent message.

static Create(channel, **kwargs)

This method is a coroutine.

Creates a message.

Parameters:
  • channel (Channel The channel to create the message in.) –

  • kwargs

    • content: Optional - The content in str form for the message.

    • replies: Optional - A list of replies in Reply form for the message.

    • embed: Optional - An Embed to attach with the message.

    • embeds: Optional - A list of embeds in Embed form for the message.

    • masquerade: Optional - The Masquerade of which to alter the bot to.

Returns:

Message The created message.

Server

Category

class pyrevolt.Category(categoryID, title, channels)

A category holds multiple channels in a server.

Parameters:
  • categoryID (str The ID of the category.) –

  • title (str The title of the category.) –

  • channels (list[ServerChannel] The channels in the category.) –

Return None:

None.

__repr__()

Gets the string representation of the category.

Returns:

str The string representation of the category.

<pyrevolt.Category id={self.categoryID} title={self.title} channels={self.channels}>

static FromJSON(jsonData, session)

This method is a coroutine.

Creates a category from the JSON representation.

Parameters:
  • json (str|bytes The JSON representation of the category.) –

  • session (Session The session to cache the category.) –

Returns:

Category The category.

SystemMessages

class pyrevolt.SystemMessages(**kwargs)

A object to hold which channels get sent system messages for the server.

Parameters:

kwargs

  • userJoinedChannel: Optional - The ServerChannel that user join messages are sent to.

  • userLeftChannel: Optional - The ServerChannel that user leave messages are sent to.

  • userKickedChannel: Optional - The ServerChannel that user kick messages are sent to.

  • userBannedChannel: Optional - The ServerChannel that user ban messages are sent to.

__repr__()

Gets the string representation of the system messages.

Returns:

str The string representation of the system messages.

<pyrevolt.SystemMessages userJoinedChannel={self.userJoinedChannel} userLeftChannel={self.userLeftChannel} userKickedChannel={self.userKickedChannel} userBannedChannel={self.userBannedChannel}>

static FromJSON(jsonData, session)

This method is a coroutine.

Creates a system messages from the JSON representation.

Parameters:
  • json (str|bytes The JSON representation of the system messages.) –

  • session (Session The session to cache the system messages.) –

Returns:

SystemMessages The system messages.

Role

class pyrevolt.Role(roleID, name, permissions, **kwargs)

A role in a server.

Parameters:
  • roleID (str The ID of the role.) –

  • name (str The name of the role.) –

  • permissions – The permissions of the role.

  • kwargs

    • colour: Optional - The colour of the role.

    • hoist: Optional - Whether the role is hoisted.

    • rank: Optional - The rank of the role.

__repr__()

Gets the string representation of the role.

Returns:

str The string representation of the role.

<pyrevolt.Role id={self.roleID} name={self.name} permissions={self.permissions} colour={self.colour} hoist={self.hoist} rank={self.rank}>

update(updatedData, clear)

This method is a coroutine.

Updates the role.

Parameters:
  • updatedData (dict The updated data for the role.) –

  • clear (list[str] The keys to clear from the role.) –

Return None:

None.

static FromJSON(jsonData)

This method is a coroutine.

Creates a role from the JSON representation.

Parameters:

json (str|bytes The JSON representation of the role.) –

Returns:

Role The role.

Server

class pyrevolt.Server(serverID, owner, name, channels, defaultPermissions, **kwargs)

A server.

Parameters:
  • serverID (str The ID of the server.) –

  • owner (User The owner of the server.) –

  • name (str The name of the server.) –

  • channels (list[ServerChannel] The channels in the server.) –

  • defaultPermissions – The default permissions of the server.

  • kwargs

    • description: Optional - The str description of the server.

    • categories: Optional - The list of Category in the server.

    • systemMessages: Optional - The SystemMessages of the server.

    • roles: Optional - The list of Role in the server.

    • nsfw: Optional - Whether the server is nsfw.

    • flags: Optional - The int flags of the server.

    • analytics: Optional - Whether analytics are being collected from the server

    • discoverable: Optional - Whether the server is discoverable.

__repr__()

Gets the string representation of the server.

Returns:

str The string representation of the server.

<pyrevolt.Server id={self.serverID} owner={self.owner} name={self.name} channels={self.channels} defaultPermissions={self.defaultPermissions}>

copy()

Copies the server.

Returns:

Server The server.

update(updatedData, clear)

This method is a coroutine.

Updates the server.

Parameters:
  • updatedData (dict The updated data for the server.) –

  • clear (list[str] The keys to clear from the server.) –

Return None:

None.

static FromJSON(jsonData, session)

This method is a coroutine.

Creates a server from the JSON representation.

Parameters:
  • json (str|bytes The JSON representation of the server.) –

  • session (Session The session to cache the server.) –

Returns:

Server The server.

static FromID(serverID, session)

This method is a coroutine.

Gets the server from the ID.

Parameters:
  • serverID (str The ID of the server.) –

  • session (Session The session to cache the server.) –

Returns:

Server The server.

Member

class pyrevolt.Member(user, server, **kwargs)

A member of a server.

Parameters:
  • user (User The user of the member.) –

  • server (Server The server of the member.) –

  • kwargs

    • nickname: Optional - The nickname of the member.

    • roles: Optional - The list of Role of the member.

__repr__()

Gets the string representation of the member.

Returns:

str The string representation of the member.

<pyrevolt.Member id={self.memberID} user={self.user} server={self.server} nickname={self.nickname} roles={self.roles}>

__str__()

Get the members username

Returns:

str The username of the member.

property memberID

The ID of the member.

Type:

str

copy()

Copies the member.

Returns:

Member The member.

update(updatedData, clear)

This method is a coroutine.

Updates the member.

Parameters:
  • updatedData (dict The updated data for the member.) –

  • clear (list[str] The keys to clear from the member.) –

static FromJSON(jsonData, session)

This method is a coroutine.

Creates a member from the JSON representation.

Parameters:
  • json (str|bytes The JSON representation of the member.) –

  • session (Session The session to cache the member.) –

Returns:

Member The member.

static FromID(memberID, session)

This method is a coroutine.

Gets the member from the ID.

Parameters:
  • memberID (str The ID of the member.) –

  • session (Session The session to cache the member.) –

Returns:

Member The member.

Session

class pyrevolt.Session

A session which manages and handles the HTTPClient and Gateway objects.

Returns:

Session The session object.

Connect()

This method is a coroutine.

Connect the Gateway.

Returns None:

None

Start(token)

This method is a coroutine.

Starts the Gateway and HTTPClient.

Parameters:

token (str The bot token.) –

Returns None:

None

Close()

This method is a coroutine.

Closes the Gateway and HTTPClient.

Returns None:

None

Request(method, url, **kwargs)

This method is a coroutine.

Sends a request through the HTTPClient.

Parameters:
  • method (Method The HTTP method to use when sending the request.) –

  • url (str The URL to send the request to.) –

  • kwargs – The keyword arguments to pass to the HTTPClient.

Returns:

dict The JSON response from the server.

ProcessGateway(data)

This method is a coroutine.

Processes a gateway payload and dispatches the event.

Parameters:

data (dict The payload to process.) –

Returns:

dict None

GatewayReceive()

This method is a coroutine.

Receives a gateway payload and executes ProcessGateway.

Returns:

dict The payload received from the gateway.

GetUser(userID)

This method is a coroutine.

Gets a user from the cache. If the user is not present in the cache, it will be fetched from the API.

Parameters:

userID (str The user ID to get information from.) –

Returns:

User The user object.

GetChannel(channelID)

This method is a coroutine.

Gets a channel from the cache. If the channel is not present in the cache, it will be fetched from the API.

Parameters:

channelID (str The channel ID to get information from.) –

Returns:

Channel The channel object.

GetServer(serverID)

This method is a coroutine.

Gets a server from the cache. If the server is not present in the cache, it will be fetched from the API.

Parameters:

serverID (str The server ID to get information from.) –

Returns:

Server The server object.

GetRole(roleID)

This method is a coroutine.

Gets a role from the cache. If the role is not present in the cache, it will be fetched from the API.

Parameters:

roleID (str The role ID to get information from.) –

Returns:

Role The role object.

GetMember(serverID, userID)

This method is a coroutine.

Gets a member from the cache. If the member is not present in the cache, it will be fetched from the API.

Parameters:
  • serverID (str The server ID to get information from.) –

  • userID (str The user ID to get information from.) –

Returns:

Member The member object.

Bot

class pyrevolt.Bot(**kwargs)

Represents a Bot and its connection to Revolt. Most interaction will be performed through this object at the highest abstraction level.

Parameters:

kwargs

  • prefix: Optional - The prefix to use for all commands. (Default to blank str)

Return Bot:

A Bot object.

class Commands(bot, **kwargs)

A class contained by the Bot object responsible for registering and handling commands and errors that occur during command execution.

Parameters:
  • bot (Bot The Bot object that this Commands object is associated with.) –

  • kwargs

    • prefix: Optional - The prefix to use for all commands. (Default to blank str)

Return Commands:

A Commands object.

@Command(**kwargs)

Register a command for the given command. The command will be registered with the given kwargs

Params kwargs:
  • name: Required - The name of the command.

  • aliases: Optional - A list of aliases for the command. (Default to blank list)

Return callable:

A decorator that registers the given command.

@Error(**kwargs)

Register an error handler for the given command. The error handler will be registered to the command function it is called by.

Params kwargs:
  • name: Required - The name of the function to receive the errors from.

Return callable:

A decorator that registers the given error handler.

dispatchCommand(context)

This method is a coroutine.

Dispatches the given command to the appropriate functions.

Parameters:

context (Message The context of the command.) –

Return None:

None

commands

The Commands object associated with this Bot.

Type:

Commands

Start(**kwargs)

This method is a coroutine.

Asynchronously starts the bot. This method will block the current thread until the bot has been stopped in order to receive gateway information.

Parameters:

kwargs

  • token: The bot’s token.

Return None:

None.

Run(**kwargs)

Runs the Bot.Start() function asynchronously.

Parameters:

kwargs

  • token: The bot’s token.

Return None:

None.

@on(event)

Registers a callback for a given event.

Parameters:

event (GatewayEvent The event to register the callback for.) –

Return callable:

The callback function.

GetUser(userID)

This method is a coroutine.

Asynchronously gets a user from the bot.

Parameters:

userID (str The user’s ID.) –

Return User:

The user.

GetChannel(channelID)

This method is a coroutine.

Asynchronously gets a channel from the bot.

Parameters:

channelID (str The channel’s ID.) –

Return Channel:

The channel.

GetServer(serverID)

This method is a coroutine.

Asynchronously gets a server from the bot.

Parameters:

serverID (str The server’s ID.) –

Return Server:

The server.

GetMember(memberID)

This method is a coroutine.

Asynchronously gets a member from the bot.

Parameters:

memberID (str The member’s ID.) –

Return Member:

The member.

GetRole(serverID, roleID)

This method is a coroutine.

Asynchronously gets a role from the bot.

Parameters:
  • serverID (str The server’s ID.) –

  • roleID (str The role’s ID.) –

Return Role:

The role.