API Reference¶
- class Client(session, token, *, api_url='https://api.revolt.chat', max_messages=5000, bot=True)¶
The client for interacting with revolt
- Parameters:
session (
aiohttp.ClientSession
) – The aiohttp session to use for http request and the websockettoken (
str
) – The bots tokenapi_url (
str
) – The api url for the revolt instance you are connecting to, by default it uses the offical instance hosted at revolt.chatmax_messages (
int
) – The max amount of messages stored in the cache, by default this is 5k
- dispatch(event, *args)¶
Dispatch an event, this is typically used for testing and internals.
- Parameters:
event (class:str) – The name of the event to dispatch, not including on_
args (
Any
) – The arguments passed to the event
- async edit_profile(**kwargs)¶
Edits the client’s own profile
- Parameters:
content (Optional[
str
]) – The new content for the profile, passing inNone
will remove the profile contentbackground (Optional[
File
]) – The new background for the profile, passing inNone
will remove the profile background
- async edit_self(**kwargs)¶
Edits the client’s own user
- Parameters:
avatar (Optional[
File
]) – The avatar to change to, passing inNone
will remove the avatar
- async edit_status(**kwargs)¶
Edits the client’s own status
- Parameters:
presence (
PresenceType
) – The presence to change totext (Optional[
str
]) – The text to change the status to, passing inNone
will remove the status
- async fetch_channel(channel_id)¶
Fetches a channel
- Parameters:
channel_id (
str
) – The id of the channel- Returns:
The channel with the matching id
- Return type:
Union[
DMChannel
,GroupDMChannel
,SavedMessageChannel
,TextChannel
,VoiceChannel
]
- async fetch_dm_channels()¶
Fetchs all dm channels the client has made
- Returns:
A list of
DMChannel
or :class`GroupDMChannel`- Return type:
list[Union[
DMChanel
,GroupDMChannel
]]
- async fetch_emoji(emoji_id)¶
Fetches an emoji
- Parameters:
emoji_id (str) – The id of the emoji
- Returns:
The emoji with the corrasponding id
- Return type:
- async fetch_invite(code)¶
Fetchs an invite
- Parameters:
code (
str
) – The code of the invite you are fetching- Returns:
The invite with the matching code
- Return type:
- async fetch_server(server_id)¶
Fetchs a server
- Parameters:
server_id (
str
) – The id of the server you are fetching- Returns:
The server with the matching id
- Return type:
- async fetch_user(user_id)¶
Fetchs a user
- Parameters:
user_id (
str
) – The id of the user you are fetching- Returns:
The user with the matching id
- Return type:
- get_channel(id)¶
Gets a channel from the cache
- Parameters:
id (
str
) – The id of the channel- Returns:
The channel
- Return type:
- get_message(message_id)¶
Gets a message from the cache
- Parameters:
message_id (
str
) – The id of the message you are getting- Returns:
The message with the matching id
- Return type:
- Raises:
LookupError – This raises if the message is not found in the cache
- get_server(id)¶
Gets a server from the cache
- Parameters:
id (
str
) – The id of the server- Returns:
The server
- Return type:
- get_user(id)¶
Gets a user from the cache
- Parameters:
id (
str
) – The id of the user- Returns:
The user
- Return type:
- listen(name=None)¶
Registers a listener for an event, multiple listeners can be registered to the same event without conflict
- Parameters:
name (Optional[
str
]) – The name of the event to register this under, this defaults to the function’s name
- remove_listener(func, *, event=None)¶
Removes a listener registered, if the event parameter is passed, the listener will only be removed from that event, this can be used if the same listener is registed to multiple events at once.
- Parameters:
func (Callable) – The function for the listener to be removed
event (Optional[
str
]) – The name of the event to remove this from, passing None will make this remove the listener from all events this is registered under
- property servers¶
‘Server’] All servers the client can see
- Type:
list[
- Type:
class
- async start(*, reconnect=True)¶
Starts the client
- async upload_file(file, tag)¶
Uploads a file to revolt
- Parameters:
file (
File
) – The file to uploadtag (
str
) – The type of file to upload, this should a string of either ‘attachments’, ‘avatars’, ‘backgrounds’, ‘icons’, ‘banners’ or ‘emojis’
- Returns:
The id of the file that was uploaded
- Return type:
Ulid
- async wait_for(event, *, check=None, timeout=None)¶
Waits for an event
- Parameters:
event (
str
) – The name of the event to wait for, without the on_check (Optional[Callable[…,
bool
]]) – A function that says what event to wait_for, this function takes the same parameters as the event you are waiting for and should return a bool saying if that is the event you wanttimeout (Optional[
float
]) – Time in seconds to wait for the event. By default it waits forever
- Raises:
asyncio.TimeoutError – If timeout is provided and it was reached
- Returns:
The parameters of the event
- Return type:
Any
- class Asset(data, state)¶
Represents a file on revolt
- id¶
The id of the asset
- Type:
str
- tag¶
The tag of the asset, this corresponds to where the asset is used
- Type:
str
- size¶
Amount of bytes in the file
- Type:
int
- filename¶
The name of the file
- Type:
str
- height¶
The height of the file if it is an image or video
- Type:
Optional[
int
]
- width¶
The width of the file if it is an image or video
- Type:
Optional[
int
]
- content_type¶
The content type of the file
- Type:
str
- url¶
The asset’s url
- Type:
str
- async read()¶
Reads the files content into bytes
- async save(fp)¶
Reads the files content and saves it to a file
- Parameters:
fp (IOBase) – The file to write to
- class PartialAsset(url, state)¶
Partial asset for when we get limited data about the asset
- id¶
The id of the asset, this will always be
"0"
- Type:
str
- size¶
Amount of bytes in the file, this will always be
0
- Type:
int
- filename¶
The name of the file, this be always be
""
- Type:
str
- height¶
The height of the file if it is an image or video, this will always be
None
- Type:
Optional[
int
]
- width¶
The width of the file if it is an image or video, this will always be
None
- Type:
Optional[
int
]
- content_type¶
The content type of the file, this is guessed from the url’s file extension if it has one
- Type:
Optional[
str
]
- async read()¶
Reads the files content into bytes
- async save(fp)¶
Reads the files content and saves it to a file
- Parameters:
fp (IOBase) – The file to write to
- class Channel(data, state)¶
Base class for all channels
- id¶
The id of the channel
- Type:
str
- channel_type¶
The type of the channel
- Type:
- server_id¶
The server id of the chanel, if any
- Type:
Optional[
str
]
- async delete()¶
Deletes or closes the channel
- property mention¶
Returns a string that allows you to mention the given channel.
- Type:
str
- class ServerChannel(data, state)¶
Base class for all guild channels
- server_id¶
The id of the server this text channel belongs to
- Type:
str
- name¶
The name of the text channel
- Type:
str
- description¶
The description of the channel, if any
- Type:
Optional[
str
]
- nsfw¶
Sets whether the channel is nsfw or not
- Type:
bool
- default_permissions¶
The default permissions for all users in the text channel
- Type:
ChannelPermissions
- async delete()¶
Deletes or closes the channel
- property mention¶
Returns a string that allows you to mention the given channel.
- Type:
str
- property server¶
Server
The server this voice channel belongs too- Raises:
LookupError – Raises if the channel is not part of a server
- async set_default_permissions(permissions)¶
Sets the default permissions for the channel. :param permissions: The new default channel permissions :type permissions:
ChannelPermissions
- async set_role_permissions(role, permissions)¶
Sets the permissions for a role in the channel. :param permissions: The new channel permissions :type permissions:
ChannelPermissions
- class SavedMessageChannel(data, state)¶
The Saved Message Channel
- async delete()¶
Deletes or closes the channel
- async delete_messages(messages)¶
Bulk deletes messages from the channel
Note
The messages must have been sent in the last 7 days.
- Parameters:
messages (list[
Message
]) – The messages for deletion, this can be up to 100 messages
- async fetch_message(message_id)¶
Fetches a message from the channel
- Parameters:
message_id (
str
) – The id of the message you want to fetch- Returns:
The message with the matching id
- Return type:
- async history(*, sort=SortType.latest, limit=100, before=None, after=None, nearby=None)¶
Fetches multiple messages from the channel’s history
- Parameters:
sort (
SortType
) – The order to sort the messages inlimit (
int
) – How many messages to fetchbefore (Optional[
str
]) – The id of the message which should come before all the messages to be fetchedafter (Optional[
str
]) – The id of the message which should come after all the messages to be fetchednearby (Optional[
str
]) – The id of the message which should be nearby all the messages to be fetched
- Returns:
The messages found in order of the sort parameter
- Return type:
list[
Message
]
- property mention¶
Returns a string that allows you to mention the given channel.
- Type:
str
- async search(query, *, sort=SortType.latest, limit=100, before=None, after=None)¶
searches the channel for a query
- Parameters:
query (
str
) – The query to search for in the channelsort (
SortType
) – The order to sort the messages inlimit (
int
) – How many messages to fetchbefore (Optional[
str
]) – The id of the message which should come before all the messages to be fetchedafter (Optional[
str
]) – The id of the message which should come after all the messages to be fetched
- Returns:
The messages found in order of the sort parameter
- Return type:
list[
Message
]
- async send(content=None, *, embeds=None, embed=None, attachments=None, replies=None, reply=None, masquerade=None, interactions=None)¶
Sends a message in a channel, you must send at least one of either content, embeds or attachments
- Parameters:
content (Optional[
str
]) – The content of the message, this will not include system message’s contentattachments (Optional[list[
File
]]) – The attachments of the messageembed (Optional[
SendableEmbed
]) – The embed to send with the messageembeds (Optional[list[
SendableEmbed
]]) – The embeds to send with the messagereplies (Optional[list[
MessageReply
]]) – The list of messages to reply to.masquerade (Optional[
Masquerade
]) – The masquerade for the message, this can overwrite the username and avatar showninteractions (Optional[
MessageInteractions
]) – The interactions for the message
- Returns:
The message that was just sent
- Return type:
- class DMChannel(data, state)¶
A DM channel
- last_message_id¶
The id of the last message in this channel, if any
- Type:
Optional[
str
]
- async delete()¶
Deletes or closes the channel
- async delete_messages(messages)¶
Bulk deletes messages from the channel
Note
The messages must have been sent in the last 7 days.
- Parameters:
messages (list[
Message
]) – The messages for deletion, this can be up to 100 messages
- async fetch_message(message_id)¶
Fetches a message from the channel
- Parameters:
message_id (
str
) – The id of the message you want to fetch- Returns:
The message with the matching id
- Return type:
- async history(*, sort=SortType.latest, limit=100, before=None, after=None, nearby=None)¶
Fetches multiple messages from the channel’s history
- Parameters:
sort (
SortType
) – The order to sort the messages inlimit (
int
) – How many messages to fetchbefore (Optional[
str
]) – The id of the message which should come before all the messages to be fetchedafter (Optional[
str
]) – The id of the message which should come after all the messages to be fetchednearby (Optional[
str
]) – The id of the message which should be nearby all the messages to be fetched
- Returns:
The messages found in order of the sort parameter
- Return type:
list[
Message
]
- property last_message¶
Gets the last message from the channel, shorthand for client.get_message(channel.last_message_id)
- Return type:
Message
the last message in the channel
- property mention¶
Returns a string that allows you to mention the given channel.
- Type:
str
- async search(query, *, sort=SortType.latest, limit=100, before=None, after=None)¶
searches the channel for a query
- Parameters:
query (
str
) – The query to search for in the channelsort (
SortType
) – The order to sort the messages inlimit (
int
) – How many messages to fetchbefore (Optional[
str
]) – The id of the message which should come before all the messages to be fetchedafter (Optional[
str
]) – The id of the message which should come after all the messages to be fetched
- Returns:
The messages found in order of the sort parameter
- Return type:
list[
Message
]
- async send(content=None, *, embeds=None, embed=None, attachments=None, replies=None, reply=None, masquerade=None, interactions=None)¶
Sends a message in a channel, you must send at least one of either content, embeds or attachments
- Parameters:
content (Optional[
str
]) – The content of the message, this will not include system message’s contentattachments (Optional[list[
File
]]) – The attachments of the messageembed (Optional[
SendableEmbed
]) – The embed to send with the messageembeds (Optional[list[
SendableEmbed
]]) – The embeds to send with the messagereplies (Optional[list[
MessageReply
]]) – The list of messages to reply to.masquerade (Optional[
Masquerade
]) – The masquerade for the message, this can overwrite the username and avatar showninteractions (Optional[
MessageInteractions
]) – The interactions for the message
- Returns:
The message that was just sent
- Return type:
- class GroupDMChannel(data, state)¶
A group DM channel
- name¶
The name of the group dm channel
- Type:
str
- permissions¶
The permissions of the users inside the group dm channel
- Type:
ChannelPermissions
- description¶
The description of the channel, if any
- Type:
Optional[
str
]
- last_message_id¶
The id of the last message in this channel, if any
- Type:
Optional[
str
]
- async delete()¶
Deletes or closes the channel
- async delete_messages(messages)¶
Bulk deletes messages from the channel
Note
The messages must have been sent in the last 7 days.
- Parameters:
messages (list[
Message
]) – The messages for deletion, this can be up to 100 messages
- async edit(**kwargs)¶
Edits the channel
Passing
None
to the parameters that accept it will remove them.
- async fetch_message(message_id)¶
Fetches a message from the channel
- Parameters:
message_id (
str
) – The id of the message you want to fetch- Returns:
The message with the matching id
- Return type:
- async history(*, sort=SortType.latest, limit=100, before=None, after=None, nearby=None)¶
Fetches multiple messages from the channel’s history
- Parameters:
sort (
SortType
) – The order to sort the messages inlimit (
int
) – How many messages to fetchbefore (Optional[
str
]) – The id of the message which should come before all the messages to be fetchedafter (Optional[
str
]) – The id of the message which should come after all the messages to be fetchednearby (Optional[
str
]) – The id of the message which should be nearby all the messages to be fetched
- Returns:
The messages found in order of the sort parameter
- Return type:
list[
Message
]
- property last_message¶
Gets the last message from the channel, shorthand for client.get_message(channel.last_message_id)
- Return type:
Message
the last message in the channel
- property mention¶
Returns a string that allows you to mention the given channel.
- Type:
str
- async search(query, *, sort=SortType.latest, limit=100, before=None, after=None)¶
searches the channel for a query
- Parameters:
query (
str
) – The query to search for in the channelsort (
SortType
) – The order to sort the messages inlimit (
int
) – How many messages to fetchbefore (Optional[
str
]) – The id of the message which should come before all the messages to be fetchedafter (Optional[
str
]) – The id of the message which should come after all the messages to be fetched
- Returns:
The messages found in order of the sort parameter
- Return type:
list[
Message
]
- async send(content=None, *, embeds=None, embed=None, attachments=None, replies=None, reply=None, masquerade=None, interactions=None)¶
Sends a message in a channel, you must send at least one of either content, embeds or attachments
- Parameters:
content (Optional[
str
]) – The content of the message, this will not include system message’s contentattachments (Optional[list[
File
]]) – The attachments of the messageembed (Optional[
SendableEmbed
]) – The embed to send with the messageembeds (Optional[list[
SendableEmbed
]]) – The embeds to send with the messagereplies (Optional[list[
MessageReply
]]) – The list of messages to reply to.masquerade (Optional[
Masquerade
]) – The masquerade for the message, this can overwrite the username and avatar showninteractions (Optional[
MessageInteractions
]) – The interactions for the message
- Returns:
The message that was just sent
- Return type:
- property server¶
Server
The server this voice channel belongs too- Raises:
LookupError – Raises if the channel is not part of a server
- async set_default_permissions(permissions)¶
Sets the default permissions for a group. :param permissions: The new default group permissions :type permissions:
ChannelPermissions
- class TextChannel(data, state)¶
A text channel
Subclasses
ServerChannel
andMessageable
- name¶
The name of the text channel
- Type:
str
- server_id¶
The id of the server this text channel belongs to
- Type:
str
- last_message_id¶
The id of the last message in this channel, if any
- Type:
Optional[
str
]
- default_permissions¶
The default permissions for all users in the text channel
- Type:
ChannelPermissions
- role_permissions¶
A dictionary of role id’s to the permissions of that role in the text channel
- Type:
dict[
str
,ChannelPermissions
]
- description¶
The description of the channel, if any
- Type:
Optional[
str
]
- async delete()¶
Deletes or closes the channel
- async delete_messages(messages)¶
Bulk deletes messages from the channel
Note
The messages must have been sent in the last 7 days.
- Parameters:
messages (list[
Message
]) – The messages for deletion, this can be up to 100 messages
- async edit(**kwargs)¶
Edits the channel
Passing
None
to the parameters that accept it will remove them.
- async fetch_message(message_id)¶
Fetches a message from the channel
- Parameters:
message_id (
str
) – The id of the message you want to fetch- Returns:
The message with the matching id
- Return type:
- async history(*, sort=SortType.latest, limit=100, before=None, after=None, nearby=None)¶
Fetches multiple messages from the channel’s history
- Parameters:
sort (
SortType
) – The order to sort the messages inlimit (
int
) – How many messages to fetchbefore (Optional[
str
]) – The id of the message which should come before all the messages to be fetchedafter (Optional[
str
]) – The id of the message which should come after all the messages to be fetchednearby (Optional[
str
]) – The id of the message which should be nearby all the messages to be fetched
- Returns:
The messages found in order of the sort parameter
- Return type:
list[
Message
]
- property last_message¶
Gets the last message from the channel, shorthand for client.get_message(channel.last_message_id)
- Return type:
Message
the last message in the channel
- property mention¶
Returns a string that allows you to mention the given channel.
- Type:
str
- async search(query, *, sort=SortType.latest, limit=100, before=None, after=None)¶
searches the channel for a query
- Parameters:
query (
str
) – The query to search for in the channelsort (
SortType
) – The order to sort the messages inlimit (
int
) – How many messages to fetchbefore (Optional[
str
]) – The id of the message which should come before all the messages to be fetchedafter (Optional[
str
]) – The id of the message which should come after all the messages to be fetched
- Returns:
The messages found in order of the sort parameter
- Return type:
list[
Message
]
- async send(content=None, *, embeds=None, embed=None, attachments=None, replies=None, reply=None, masquerade=None, interactions=None)¶
Sends a message in a channel, you must send at least one of either content, embeds or attachments
- Parameters:
content (Optional[
str
]) – The content of the message, this will not include system message’s contentattachments (Optional[list[
File
]]) – The attachments of the messageembed (Optional[
SendableEmbed
]) – The embed to send with the messageembeds (Optional[list[
SendableEmbed
]]) – The embeds to send with the messagereplies (Optional[list[
MessageReply
]]) – The list of messages to reply to.masquerade (Optional[
Masquerade
]) – The masquerade for the message, this can overwrite the username and avatar showninteractions (Optional[
MessageInteractions
]) – The interactions for the message
- Returns:
The message that was just sent
- Return type:
- property server¶
Server
The server this voice channel belongs too- Raises:
LookupError – Raises if the channel is not part of a server
- async set_default_permissions(permissions)¶
Sets the default permissions for the channel. :param permissions: The new default channel permissions :type permissions:
ChannelPermissions
- async set_role_permissions(role, permissions)¶
Sets the permissions for a role in the channel. :param permissions: The new channel permissions :type permissions:
ChannelPermissions
- class VoiceChannel(data, state)¶
A voice channel
Subclasses
ServerChannel
- name¶
The name of the voice channel
- Type:
str
- server_id¶
The id of the server this voice channel belongs to
- Type:
str
- last_message_id¶
The id of the last message in this channel, if any
- Type:
Optional[
str
]
- default_permissions¶
The default permissions for all users in the voice channel
- Type:
ChannelPermissions
- role_permissions¶
A dictionary of role id’s to the permissions of that role in the voice channel
- Type:
dict[
str
,ChannelPermissions
]
- description¶
The description of the channel, if any
- Type:
Optional[
str
]
- async delete()¶
Deletes or closes the channel
- async edit(**kwargs)¶
Edits the channel
Passing
None
to the parameters that accept it will remove them.
- property mention¶
Returns a string that allows you to mention the given channel.
- Type:
str
- property server¶
Server
The server this voice channel belongs too- Raises:
LookupError – Raises if the channel is not part of a server
- async set_default_permissions(permissions)¶
Sets the default permissions for the channel. :param permissions: The new default channel permissions :type permissions:
ChannelPermissions
- async set_role_permissions(role, permissions)¶
Sets the permissions for a role in the channel. :param permissions: The new channel permissions :type permissions:
ChannelPermissions
- Embed¶
alias of
Union
[WebsiteEmbed
,ImageEmbed
,TextEmbed
,NoneEmbed
]
- class WebsiteEmbed(embed)¶
- class ImageEmbed(image)¶
- class TextEmbed(embed, state)¶
- class NoneEmbed¶
- class SendableEmbed(**attrs)¶
Represents an embed that can be sent in a message, you will never receive this, you will receive
Embed
.- title¶
The title of the embed
- Type:
Optional[
str
]
- description¶
The description of the embed
- Type:
Optional[
str
]
- media¶
The file inside the embed, this is the ID of the file, you can use
Client.upload_file()
to get an ID.- Type:
Optional[
str
]
- icon_url¶
The url of the icon url
- Type:
Optional[
str
]
- url¶
URL for hyperlinking the embed’s title
- Type:
Optional[
str
]
- to_dict()¶
Converts the embed to a dictionary which Revolt accepts
- Returns:
The embed
- Return type:
dict[str, Any]
- class File(file, *, filename=None, spoiler=False)¶
Respresents a file about to be uploaded to revolt
- Parameters:
file (Union[str, bytes]) – The name of the file or the content of the file in bytes, text files will be need to be encoded
filename (Optional[str]) – The filename of the file when being uploaded, this will default to the name of the file if one exists
spoiler (bool) – Determines if the file will be a spoiler, this prefexes the filename with SPOILER_
- class Member(data, server, state)¶
Represents a member of a server, subclasses
User
- nickname¶
The nickname of the member if any
- Type:
Optional[
str
]
- property avatar¶
Optional[
Asset
] The avatar the member is displaying, this includes guild avatars and masqueraded avatar
- async ban(*, reason=None)¶
Bans the member from the server
- Parameters:
reason (Optional[
str
]) – The reason for the ban
- async default_avatar()¶
Returns the default avatar for this user
- Returns:
The bytes of the image
- Return type:
bytes
- async delete_messages(messages)¶
Bulk deletes messages from the channel
Note
The messages must have been sent in the last 7 days.
- Parameters:
messages (list[
Message
]) – The messages for deletion, this can be up to 100 messages
- async edit(*, nickname=<Missing>, roles=<Missing>, avatar=<Missing>, timeout=<Missing>)¶
Edits the member
- Parameters:
nickname (Union[
str
,None
]) – The new nickname, orNone
to reset itroles (Union[list[
Role
],None
]) – The new roles for the member, orNone
to clear itavatar (Union[
File
,None
]) – The new server avatar, orNone
to reset ittimeout (Union[
datetime.timedelta
,None
]) – The new timeout length for the member, orNone
to reset it
- async fetch_message(message_id)¶
Fetches a message from the channel
- Parameters:
message_id (
str
) – The id of the message you want to fetch- Returns:
The message with the matching id
- Return type:
- async fetch_profile()¶
Fetches the user’s profile
- Returns:
The user’s profile
- Return type:
- get_channel_permissions(channel)¶
Gets the permissions for the member in the server taking into account the channel as well
- Parameters:
channel (
Channel
) – The channel to calculate permissions with- Returns:
The members permissions
- Return type:
- get_permissions()¶
Gets the permissions for the member in the server
- Returns:
The members permissions
- Return type:
- has_channel_permissions(channel, **permissions)¶
Computes if the member has the specified permissions, taking into account the channel as well
- Parameters:
channel (
Channel
) – The channel to calculate permissions withpermissions (
bool
) – The permissions to check, this also accepted False if you need to check if the member does not have the permission
- Returns:
Whether or not they have the permissions
- Return type:
bool
- has_permissions(**permissions)¶
Computes if the member has the specified permissions
- Parameters:
permissions (
bool
) – The permissions to check, this also accepted False if you need to check if the member does not have the permission- Returns:
Whether or not they have the permissions
- Return type:
bool
- async history(*, sort=SortType.latest, limit=100, before=None, after=None, nearby=None)¶
Fetches multiple messages from the channel’s history
- Parameters:
sort (
SortType
) – The order to sort the messages inlimit (
int
) – How many messages to fetchbefore (Optional[
str
]) – The id of the message which should come before all the messages to be fetchedafter (Optional[
str
]) – The id of the message which should come after all the messages to be fetchednearby (Optional[
str
]) – The id of the message which should be nearby all the messages to be fetched
- Returns:
The messages found in order of the sort parameter
- Return type:
list[
Message
]
- async kick()¶
Kicks the member from the server
- property mention¶
Returns a string that allows you to mention the given member.
- Type:
str
- property name¶
str
The name the user is displaying, this includes (in order) their masqueraded name, display name and orginal name
- async open_dm()¶
Opens a dm with the user, if this user is the current user this will return
SavedMessageChannel
Note
using this function is discouraged as
User.send()
does this implicitally.- Return type:
Union[
DMChannel
,SavedMessageChannel
]
- async search(query, *, sort=SortType.latest, limit=100, before=None, after=None)¶
searches the channel for a query
- Parameters:
query (
str
) – The query to search for in the channelsort (
SortType
) – The order to sort the messages inlimit (
int
) – How many messages to fetchbefore (Optional[
str
]) – The id of the message which should come before all the messages to be fetchedafter (Optional[
str
]) – The id of the message which should come after all the messages to be fetched
- Returns:
The messages found in order of the sort parameter
- Return type:
list[
Message
]
- async send(content=None, *, embeds=None, embed=None, attachments=None, replies=None, reply=None, masquerade=None, interactions=None)¶
Sends a message in a channel, you must send at least one of either content, embeds or attachments
- Parameters:
content (Optional[
str
]) – The content of the message, this will not include system message’s contentattachments (Optional[list[
File
]]) – The attachments of the messageembed (Optional[
SendableEmbed
]) – The embed to send with the messageembeds (Optional[list[
SendableEmbed
]]) – The embeds to send with the messagereplies (Optional[list[
MessageReply
]]) – The list of messages to reply to.masquerade (Optional[
Masquerade
]) – The masquerade for the message, this can overwrite the username and avatar showninteractions (Optional[
MessageInteractions
]) – The interactions for the message
- Returns:
The message that was just sent
- Return type:
- async timeout(length)¶
Timeouts the member
- Parameters:
length (
datetime.timedelta
) – The length of the timeout
- to_member(server)¶
Gets the member instance for this user for a specific server.
Roughly equivelent to:
member = server.get_member(user.id)
- async unban()¶
Unbans the member from the server
- class Message(data, state)¶
Represents a message
- id¶
The id of the message
- Type:
str
- content¶
The content of the message, this will not include system message’s content
- Type:
str
- embeds¶
The embeds of the message
- Type:
list[Union[
WebsiteEmbed
,ImageEmbed
,TextEmbed
,NoneEmbed
]]
- channel¶
The channel the message was sent in
- Type:
- edited_at¶
The time at which the message was edited, will be None if the message has not been edited
- Type:
Optional[
datetime.datetime
]
- raw_mentions¶
A list of ids of the mentions in this message
- Type:
list[
str
]
- replies¶
The message’s this message has replied to, this may not contain all the messages if they are outside the cache
- Type:
list[
Message
]
- reply_ids¶
The message’s ids this message has replies to
- Type:
list[
str
]
- interactions¶
The interactions on the message, if any
- Type:
Optional[
MessageInteractions
]
- async add_reaction(emoji)¶
Adds a reaction to the message
- Parameters:
emoji (
str
) – The emoji to add as a reaction
- async delete()¶
Deletes the message. The bot can only delete its own messages and messages it has permission to delete
- async edit(*, content=None, embeds=None)¶
Edits the message. The bot can only edit its own message
- Parameters:
content (
str
) – The new content of the messageembeds (list[
SendableEmbed
]) – The new embeds of the message
- property mentions¶
The users or members that where mentioned in the message
- async remove_all_reactions()¶
Removes all reactions from the message
- async remove_reaction(emoji, user=None, remove_all=False)¶
Removes a reaction from the message, this can remove either a specific users, the current users reaction or all of a specific emoji
- Parameters:
emoji (
str
) – The emoji to removeuser (Optional[
User
]) – The user to use for removing a reaction fromremove_all (bool) – Whether or not to remove all reactions for that specific emoji
- reply(*args, mention=False, **kwargs)¶
Replies to this message, equivilant to:
await channel.send(..., replies=[MessageReply(message, mention)])
- class MessageReply(message, mention=False)¶
represents a reply to a message.
- Parameters:
message (
Message
) – The message being replied to.mention (
bool
) – Whether the reply should mention the author of the message. Defaults to false.
- class Masquerade(name=None, avatar=None, colour=None)¶
represents a message’s masquerade.
- Parameters:
name (Optional[
str
]) – The name to display for the messageavatar (Optional[
str
]) – The avatar’s url to display for the messagecolour (Optional[
str
]) – The colour of the name, similar to role colours
- class Messageable¶
Base class for all channels that you can send messages in
- id¶
The id of the channel
- Type:
str
- async delete_messages(messages)¶
Bulk deletes messages from the channel
Note
The messages must have been sent in the last 7 days.
- Parameters:
messages (list[
Message
]) – The messages for deletion, this can be up to 100 messages
- async fetch_message(message_id)¶
Fetches a message from the channel
- Parameters:
message_id (
str
) – The id of the message you want to fetch- Returns:
The message with the matching id
- Return type:
- async history(*, sort=SortType.latest, limit=100, before=None, after=None, nearby=None)¶
Fetches multiple messages from the channel’s history
- Parameters:
sort (
SortType
) – The order to sort the messages inlimit (
int
) – How many messages to fetchbefore (Optional[
str
]) – The id of the message which should come before all the messages to be fetchedafter (Optional[
str
]) – The id of the message which should come after all the messages to be fetchednearby (Optional[
str
]) – The id of the message which should be nearby all the messages to be fetched
- Returns:
The messages found in order of the sort parameter
- Return type:
list[
Message
]
- async search(query, *, sort=SortType.latest, limit=100, before=None, after=None)¶
searches the channel for a query
- Parameters:
query (
str
) – The query to search for in the channelsort (
SortType
) – The order to sort the messages inlimit (
int
) – How many messages to fetchbefore (Optional[
str
]) – The id of the message which should come before all the messages to be fetchedafter (Optional[
str
]) – The id of the message which should come after all the messages to be fetched
- Returns:
The messages found in order of the sort parameter
- Return type:
list[
Message
]
- async send(content=None, *, embeds=None, embed=None, attachments=None, replies=None, reply=None, masquerade=None, interactions=None)¶
Sends a message in a channel, you must send at least one of either content, embeds or attachments
- Parameters:
content (Optional[
str
]) – The content of the message, this will not include system message’s contentattachments (Optional[list[
File
]]) – The attachments of the messageembed (Optional[
SendableEmbed
]) – The embed to send with the messageembeds (Optional[list[
SendableEmbed
]]) – The embeds to send with the messagereplies (Optional[list[
MessageReply
]]) – The list of messages to reply to.masquerade (Optional[
Masquerade
]) – The masquerade for the message, this can overwrite the username and avatar showninteractions (Optional[
MessageInteractions
]) – The interactions for the message
- Returns:
The message that was just sent
- Return type:
- class Permissions(value=0, **flags)¶
Server permissions for members and roles
- class UserPermissions(value=0, **flags)¶
Permissions for users
- class PermissionsOverwrite(allow, deny)¶
A permissions overwrite in a channel
- class Role(data, role_id, server, state)¶
Represents a role
- id¶
The id of the role
- Type:
str
- name¶
The name of the role
- Type:
str
- colour¶
The colour of the role
- Type:
Optional[
str
]
- hoist¶
Whether members with the role will display seperate from everyone else
- Type:
bool
- rank¶
The position of the role in the role heirarchy
- Type:
int
- server_permissions¶
The server permissions for the role
- Type:
ServerPermissions
- channel_permissions¶
The channel permissions for the role
- Type:
ChannelPermissions
- async delete()¶
Deletes the role
- async edit(**kwargs)¶
Edits the role
- Parameters:
name (str) – The name of the role
colour (str) – The colour of the role
hoist (bool) – Whether the role should make the member display seperately in the member list
rank (int) – The position of the role
- async set_permissions_overwrite(*, permissions)¶
Sets the permissions for a role in a server. :param server_permissions: The new server permissions for the role :type server_permissions: Optional[
ServerPermissions
] :param channel_permissions: The new channel permissions for the role :type channel_permissions: Optional[ChannelPermissions
]
- class Server(data, state)¶
Represents a server
- id¶
The id of the server
- Type:
str
- name¶
The name of the server
- Type:
str
- owner_id¶
The owner’s id of the server
- Type:
str
- description¶
The servers description
- Type:
Optional[
str
]
- nsfw¶
Whether the server is nsfw or not
- Type:
bool
- system_messages¶
The system message config for the server
- Type:
- default_permissions¶
The permissions for the default role
- Type:
- async create_emoji(name, file, *, nsfw=False)¶
Creates an emoji
- Parameters:
name (
str
) – The name for the emojifile (
File
) – The image for the emojinsfw (
bool
) – Whether or not the emoji is nsfw
- async create_role(name)¶
Creates a role in the server
- Parameters:
name (
str
) – The name of the role- Returns:
The role that was just created
- Return type:
- async create_text_channel(*, name, description=None)¶
Creates a text channel in the server
- Parameters:
name (
str
) – The name of the channeldescription (Optional[
str
]) – The channel’s description
- Returns:
The text channel that was just created
- Return type:
- async create_voice_channel(*, name, description=None)¶
Creates a voice channel in the server
- Parameters:
name (
str
) – The name of the channeldescription (Optional[
str
]) – The channel’s description
- Returns:
The voice channel that was just created
- Return type:
- async delete_server()¶
Leaves or deletes a server, alias to :meth`Server.leave_server`
- async fetch_member(member_id)¶
Fetches a member from this server
- Parameters:
member_id (
str
) – The id of the member you are fetching- Returns:
The member with the matching id
- Return type:
- get_category(category_id)¶
Gets a category from the cache
- Parameters:
id (
str
) – The id of the category- Returns:
The category
- Return type:
- get_channel(channel_id)¶
Gets a channel from the cache
- Parameters:
id (
str
) – The id of the channel- Returns:
The channel
- Return type:
- get_emoji(emoji_id)¶
Gets a emoji from the cache
- Parameters:
id (
str
) – The id of the emoji- Returns:
The emoji
- Return type:
- get_member(member_id)¶
Gets a member from the cache
- Parameters:
id (
str
) – The id of the member- Returns:
The member
- Return type:
- get_role(role_id)¶
Gets a role from the cache
- Parameters:
id (
str
) – The id of the role- Returns:
The role
- Return type:
- async leave_server()¶
Leaves or deletes the server
- async set_default_permissions(permissions)¶
Sets the default server permissions. :param server_permissions: The new default server permissions :type server_permissions: Optional[
ServerPermissions
] :param channel_permissions: the new default channel permissions :type channel_permissions: Optional[ChannelPermissions
]
- class ServerBan(ban, state)¶
Represents a server ban
- reason¶
The reason the user was banned
- Type:
Optional[
str
]
- user_id¶
The id of the user who was banned
- Type:
str
- async unban()¶
Unbans the user
- class Category(data, state)¶
Represents a category in a server that stores channels.
- name¶
The name of the category
- Type:
str
- id¶
The id of the category
- Type:
str
- channel_ids¶
The ids of channels that are inside the category
- Type:
list[
str
]
- property channels¶
Returns a list of channels that the category contains
- class SystemMessages(data, state)¶
Holds all the configuration for the server’s system message channels
- property user_banned¶
The channel which user ban messages get sent in
- Returns:
The channel
- Return type:
Optional[
TextChannel
]
- property user_joined¶
The channel which user join messages get sent in
- Returns:
The channel
- Return type:
Optional[
TextChannel
]
- property user_kicked¶
The channel which user kick messages get sent in
- Returns:
The channel
- Return type:
Optional[
TextChannel
]
- property user_left¶
The channel which user leave messages get sent in
- Returns:
The channel
- Return type:
Optional[
TextChannel
]
- class User(data, state)¶
Represents a user
- id¶
The user’s id
- Type:
str
- discriminator¶
The user’s discriminator
- Type:
str
- display_name¶
The user’s display name if they have one
- Type:
Optional[
str
]
- bot¶
Whether or not the user is a bot
- Type:
bool
- owner_id¶
The bot’s owner id if the user is a bot
- Type:
Optional[
str
]
- badges¶
The users badges
- Type:
- online¶
Whether or not the user is online
- Type:
bool
- flags¶
The user flags
- Type:
int
- relationship¶
The relationship between the user and the bot
- Type:
Optional[
RelationshipType
]
- dm_channel¶
The dm channel between the client and the user, this will only be set if the client has dm’ed the user or
User.open_dm()
was run- Type:
Optional[
DMChannel
]
- privileged¶
Whether the user is privileged
- Type:
bool
- property avatar¶
Optional[
Asset
] The avatar the member is displaying, this includes there orginal avatar and masqueraded avatar
- async default_avatar()¶
Returns the default avatar for this user
- Returns:
The bytes of the image
- Return type:
bytes
- async delete_messages(messages)¶
Bulk deletes messages from the channel
Note
The messages must have been sent in the last 7 days.
- Parameters:
messages (list[
Message
]) – The messages for deletion, this can be up to 100 messages
- async fetch_message(message_id)¶
Fetches a message from the channel
- Parameters:
message_id (
str
) – The id of the message you want to fetch- Returns:
The message with the matching id
- Return type:
- async fetch_profile()¶
Fetches the user’s profile
- Returns:
The user’s profile
- Return type:
- get_permissions()¶
Gets the permissions for the user
- Returns:
The users permissions
- Return type:
- has_permissions(**permissions)¶
Computes if the user has the specified permissions
- Parameters:
permissions (
bool
) – The permissions to check, this also accepted False if you need to check if the user does not have the permission- Returns:
Whether or not they have the permissions
- Return type:
bool
- async history(*, sort=SortType.latest, limit=100, before=None, after=None, nearby=None)¶
Fetches multiple messages from the channel’s history
- Parameters:
sort (
SortType
) – The order to sort the messages inlimit (
int
) – How many messages to fetchbefore (Optional[
str
]) – The id of the message which should come before all the messages to be fetchedafter (Optional[
str
]) – The id of the message which should come after all the messages to be fetchednearby (Optional[
str
]) – The id of the message which should be nearby all the messages to be fetched
- Returns:
The messages found in order of the sort parameter
- Return type:
list[
Message
]
- property mention¶
Returns a string that allows you to mention the given user.
- Type:
str
- property name¶
str
The name the user is displaying, this includes (in order) their masqueraded name, display name and orginal name
- async open_dm()¶
Opens a dm with the user, if this user is the current user this will return
SavedMessageChannel
Note
using this function is discouraged as
User.send()
does this implicitally.- Return type:
Union[
DMChannel
,SavedMessageChannel
]
- async search(query, *, sort=SortType.latest, limit=100, before=None, after=None)¶
searches the channel for a query
- Parameters:
query (
str
) – The query to search for in the channelsort (
SortType
) – The order to sort the messages inlimit (
int
) – How many messages to fetchbefore (Optional[
str
]) – The id of the message which should come before all the messages to be fetchedafter (Optional[
str
]) – The id of the message which should come after all the messages to be fetched
- Returns:
The messages found in order of the sort parameter
- Return type:
list[
Message
]
- async send(content=None, *, embeds=None, embed=None, attachments=None, replies=None, reply=None, masquerade=None, interactions=None)¶
Sends a message in a channel, you must send at least one of either content, embeds or attachments
- Parameters:
content (Optional[
str
]) – The content of the message, this will not include system message’s contentattachments (Optional[list[
File
]]) – The attachments of the messageembed (Optional[
SendableEmbed
]) – The embed to send with the messageembeds (Optional[list[
SendableEmbed
]]) – The embeds to send with the messagereplies (Optional[list[
MessageReply
]]) – The list of messages to reply to.masquerade (Optional[
Masquerade
]) – The masquerade for the message, this can overwrite the username and avatar showninteractions (Optional[
MessageInteractions
]) – The interactions for the message
- Returns:
The message that was just sent
- Return type:
- namedtuple Relation(type, user)¶
A namedtuple representing a relation between the bot and a user
- Fields:
type (
RelationshipType
) – Alias for field number 0user (
User
) – Alias for field number 1
- namedtuple Status(text, presence)¶
A namedtuple representing a users status
- Fields:
text (
Optional
[str
]) – Alias for field number 0presence (
Optional
[PresenceType
]) – Alias for field number 1
- class UserBadges(value=0, **flags)¶
Contains all user badges
- active_supporter¶
bool
The active supporter badge.
- developer¶
bool
The developer badge.
- early_adopter¶
bool
The early adopter badge.
- founder¶
bool
The founder badge.
- paw¶
bool
The paw badge.
- platform_moderation¶
bool
The platform moderation badge.
- reserved_relevant_joke_badge_1¶
bool
The reserved relevant joke badge 1 badge.
- responsible_disclosure¶
bool
The responsible disclosure badge.
- supporter¶
bool
The supporter badge.
- translator¶
bool
The translator badge.
- class UserProfile(content, background)¶
A namedtuple representing a users profile
- background¶
Alias for field number 1
- content¶
Alias for field number 0
- class Invite(data, code, state)¶
Represents a server invite.
- code¶
The code for the invite
- Type:
str
- user_name¶
The name of the user who made the invite
- Type:
str
- user¶
The user who made the invite, this is only set if this was fetched via
Server.fetch_invites()
- Type:
Optional[
User
]
- member_count¶
The member count of the server this invite is for
- Type:
int
- async delete()¶
Deletes the invite
- class Emoji(payload, state)¶
Represents a custom emoji.
- id¶
The id of the emoji
- Type:
str
- author_id¶
The id of the of user who created the emoji
- Type:
str
- name¶
The name of the emoji
- Type:
str
- animated¶
Whether or not the emoji is animated
- Type:
bool
- nsfw¶
Whether or not the emoji is nsfw
- Type:
bool
- server_id¶
The server id this emoji belongs to, if any
- Type:
Optional[
str
]
- async delete()¶
Deletes the emoji.
- class MessageInteractions(*, reactions=None, restrict_reactions=False)¶
Represents a message’s interactions, this is for allowing preset reactions and restricting adding reactions to only those.
- Parameters:
reactions (Optional[list[
str
]]) – The preset reactions on the messagerestrict_reactions (bool) – Whether or not users can only react to the interaction’s reactions
Enums¶
The api uses enums to say what variant of something is, these represent those enums
All enums subclass aenum.Enum.
- class ChannelType¶
Specifies the type of channel.
- saved_message¶
A private channel only you can access.
- direct_message¶
A private direct message channel between you and another user
- group¶
A private group channel for messages between a group of users
- text_channel¶
A text channel in a server
- voice_channel¶
A voice only channel
- class PresenceType¶
Specifies what a users presence is
- busy¶
The user is busy and wont receive notification
- idle¶
The user is idle
- invisible¶
The user is invisible, you will never receive this, instead they will appear offline
- online¶
The user is online
- offline¶
The user is offline or invisible
- class RelationshipType¶
Specifies the relationship between two users
- blocked¶
You have blocked them
- blocked_other¶
They have blocked you
- friend¶
You are friends with them
- incoming_friend_request¶
They are sending you a friend request
- none¶
You have no relationship with them
- outgoing_friend_request¶
You are sending them a friend request
- user¶
That user is yourself
- class AssetType¶
Specifies the type of asset
- image¶
The asset is an image
- video¶
The asset is a video
- text¶
The asset is a text file
- audio¶
The asset is an audio file
- file¶
The asset is a generic file
Utils¶
A collection a utility functions and classes to aid in making your bot
- get(iterable, **attrs)¶
A convenience function to help get a value from an iterable with a specific attribute
Examples
from revolt import utils channel = utils.get(server.channels, name="General") await channel.send("Hello general chat.")
- Parameters:
iterable (Iterable) – The values to search though
**attrs (Any) – The attributes to check
- Returns:
The value from the iterable with the met attributes
- Return type:
Any
- Raises:
LookupError – Raises when none of the values in the iterable matches the attributes
- client_session()¶
A context manager that creates a new aiohttp.ClientSession() and closes it when exiting the context.
Examples
async def main(): async with client_session() as session: client = revolt.Client(session, "TOKEN") await client.start() asyncio.run(main())