API
Client
Method
Request
HTTPClient
- class pyrevolt.HTTPClient
A client for sending requests to the server.
- Returns:
HTTPClientThe client object.
- Request(request)
This method is a coroutine.
Sends a request to the given request URL.
- 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.ThreadA thread that keeps the gateway alive by sending a ping for every defined interval.
- Parameters:
- Return GatewayKeepAlive:
The gateway keep alive thread.
- run()
The thread’s main run loop. This method executes a ping every
intervalseconds.- Returns None:
None
Gateway
- class pyrevolt.Gateway
A gateway to connect to the Revolt API.
- Returns:
GatewayThe 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:
strThe 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 (
dictThe payload to send.) –- Returns None:
None
Structures
User
Relationship
Presence
Status
- class pyrevolt.Status(presence, **kwargs)
The status a user can have. This includes their presence and any custom text.
- Parameters:
presence (
PresenceThe presence of the user.) –kwargs –
text: Optional - The custom text of the status.
BotUser
User
- class pyrevolt.User(userID, username, **kwargs)
A user.
- Parameters:
userID (
strThe ID of the user.) –username (
strThe 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:
strThe 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}>
- update(updateData, clear)
Updates the user with the data from the update data.
- Parameters:
updateData (
dictThe update data.) –clear (
list[str]Items to clear data from.) –
- Returns None:
None
- static FromJSON(jsonData, session)
This method is a coroutine.
Creates a user from a JSON object.
- 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.
Channels
ChannelType
Channel
- class pyrevolt.Channel(channelID, type, **kwargs)
A channel with an associated type.
- Parameters:
channelID (
strThe ID of the channel.) –type (
ChannelTypeThe 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 (
dictThe 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.
- 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.
- static AttemptParse(content, session)
This method is a coroutine.
Attempts to parse a channel from a string.
SavedMessages
- class pyrevolt.SavedMessages(channelID, user, **kwargs)
Bases:
ChannelA saved messages channel.
- Parameters:
- __repr__()
Gets the string representation of the channel.
- Returns:
strThe string representation of the channel.<pyrevolt.SavedMessages id={self.channelID} user={self.user}>
- copy()
Creates a copy of the channel.
- Returns:
SavedMessagesThe copy of the channel.
DirectMessage
- class pyrevolt.DirectMessage(channelID, active, recipients, **kwargs)
Bases:
ChannelA direct message channel.
- Parameters:
- __repr__()
Gets the string representation of the channel.
- Returns:
strThe string representation of the channel.<pyrevolt.DirectMessage id={self.channelID} active={self.active} recipients={self.recipients}>
- copy()
Creates a copy of the channel.
- Returns:
DirectMessageThe copy of the channel.
Group
- class pyrevolt.Group(channelID, name, recipients, owner, **kwargs)
Bases:
ChannelA group channel.
- Parameters:
channelID (
strThe ID of the channel.) –name (
strThe name of the group.) –recipients (
list[User]The users the group is with.) –owner (
UserThe 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.
ServerChannel
- class pyrevolt.ServerChannel(channelID, type, server, name, **kwargs)
Bases:
ChannelA server channel.
- Parameters:
channelID (
strThe ID of the channel.) –type (
ChannelTypeThe type of the channel.) –server (
ServerThe server the channel is in.) –name (
strThe 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.
TextChannel
- class pyrevolt.TextChannel(channelID, server, name, **kwargs)
Bases:
ServerChannelA text channel.
- Parameters:
channelID (
strThe ID of the channel.) –server (
ServerThe server the channel is in.) –name (
strThe 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:
strThe 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:
TextChannelThe copy of the channel.
VoiceChannel
- class pyrevolt.VoiceChannel(channelID, server, name, **kwargs)
Bases:
ServerChannelA voice channel.
- Parameters:
channelID (
strThe ID of the channel.) –server (
ServerThe server the channel is in.) –name (
strThe 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:
strThe 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:
VoiceChannelThe copy of the channel.
Messages
EmbedType
EmbedImageSize
Embed
- class pyrevolt.Embed(type, **kwargs)
An embed in a message.
- Parameters:
type (
EmbedTypeThe 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:
strThe string representation of the embed.<pyrevolt.Embed type={self.type}>
- toJSON()
Gets the JSON representation of the embed.
- Returns:
strThe JSON representation of the embed.
- static FromJSON(jsonData)
Creates an embed from the JSON representation.
- Parameters:
json (
str|bytesThe JSON representation of the embed.) –- Returns:
EmbedThe 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:
MasqueradeThe masquerade.
- static FromJSON(jsonData)
Creates a masquerade from the JSON representation.
- Parameters:
json (
str|bytesThe JSON representation of the masquerade.) –- Returns:
MasqueradeThe masquerade.
Reply
Message
- class pyrevolt.Message(messageID, channel, author, **kwargs)
A message.
- Parameters:
messageID (
strThe ID of the message.) –channel (
ChannelThe channel the message is in.) –author (
UserThe 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:
strThe string representation of the message.<pyrevolt.Message id={self.messageID} channel={self.channel} author={self.author}>
- update(updatedData)
This method is a coroutine.
Updates the message with the specified data.
- Parameters:
updatedData (
dictThe updated data.) –- Returns None:
None.
- static FromJSON(jsonData, session)
This method is a coroutine.
Creates a message from the JSON representation.
- 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.
- 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:
MessageThe sent message.
- static Create(channel, **kwargs)
This method is a coroutine.
Creates a message.
- Parameters:
channel (
ChannelThe 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:
MessageThe created message.
Server
Category
- class pyrevolt.Category(categoryID, title, channels)
A category holds multiple channels in a server.
- Parameters:
- Return None:
None.
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:
strThe 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|bytesThe JSON representation of the system messages.) –session (
SessionThe session to cache the system messages.) –
- Returns:
SystemMessagesThe system messages.
Role
- class pyrevolt.Role(roleID, name, permissions, **kwargs)
A role in a server.
- Parameters:
- __repr__()
Gets the string representation of the role.
- Returns:
strThe 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}>
Server
- class pyrevolt.Server(serverID, owner, name, channels, defaultPermissions, **kwargs)
A server.
- Parameters:
serverID (
strThe ID of the server.) –owner (
UserThe owner of the server.) –name (
strThe 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 serverdiscoverable: Optional - Whether the server is discoverable.
- __repr__()
Gets the string representation of the server.
- Returns:
strThe string representation of the server.<pyrevolt.Server id={self.serverID} owner={self.owner} name={self.name} channels={self.channels} defaultPermissions={self.defaultPermissions}>
- update(updatedData, clear)
This method is a coroutine.
Updates the server.
- Parameters:
updatedData (
dictThe 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.
Member
- class pyrevolt.Member(user, server, **kwargs)
A member of a server.
- Parameters:
- __repr__()
Gets the string representation of the member.
- Returns:
strThe string representation of the member.<pyrevolt.Member id={self.memberID} user={self.user} server={self.server} nickname={self.nickname} roles={self.roles}>
- update(updatedData, clear)
This method is a coroutine.
Updates the member.
- Parameters:
updatedData (
dictThe 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.
Session
- class pyrevolt.Session
A session which manages and handles the HTTPClient and Gateway objects.
- Returns:
SessionThe 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 (
strThe 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.
- ProcessGateway(data)
This method is a coroutine.
Processes a gateway payload and dispatches the event.
- GatewayReceive()
This method is a coroutine.
Receives a gateway payload and executes ProcessGateway.
- Returns:
dictThe 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.
- 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.
- 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.
- 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.
- 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.
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 (
BotThe 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.
- 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 (
GatewayEventThe 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 (
strThe user’s ID.) –- Return User:
The user.
- GetChannel(channelID)
This method is a coroutine.
Asynchronously gets a channel from the bot.
- Parameters:
channelID (
strThe channel’s ID.) –- Return Channel:
The channel.
- GetServer(serverID)
This method is a coroutine.
Asynchronously gets a server from the bot.
- Parameters:
serverID (
strThe server’s ID.) –- Return Server:
The server.