Defectio Models#

Models are classes that are received from Revolt and are not meant to be created by the user of the library.

Danger

The classes listed below are not intended to be created by users and are also read-only.

For example, this means that you should not make your own User instances nor should you modify the User instance yourself.

If you want to get one of these model classes instances they’d have to be through the cache, and a common way of doing so is through the utils.find() function or attributes of model classes that you receive from the events specified in the Event Reference.

Note

Nearly all classes here have __slots__ defined which means that it is impossible to have dynamic attributes to the data classes.

User#

class defectio.User[source]#
property display_name#

Returns the user’s display name.

For regular users this is just their username, but if they have a server specific nickname then that is returned instead.

Type

str

await fetch_message(id)#

This function is a coroutine.

Retrieves a single Message from the destination.

Parameters

id (int) – The message ID to look for.

Raises
  • NotFound – The specified message was not found.

  • Forbidden – You do not have the permissions required to get a message.

  • HTTPException – Retrieving the message failed.

Returns

The message asked for.

Return type

Message

get_relationship(user_id)#

Get the relationship with a user

Parameters

user_id (str) – User ID

Returns

Our relationship with them

Return type

Optional[Relationship]

property mention#

Returns a string that allows you to mention the given user.

Type

str

mentioned_in(message)#

Checks if the user is mentioned in the specified message.

Parameters

message (Message) – The message to check if you’re mentioned in.

Returns

Indicates if the user is mentioned in the message.

Return type

bool

property dm_channel#

Returns the channel associated with this user if it exists.

If this returns None, you can create a DM channel by calling the create_dm() coroutine function.

Type

Optional[DMChannel]

await create_dm()[source]#

This function is a coroutine. Creates a DMChannel with this user.

Returns

The channel that was created.

Return type

DMChannel

Message#

class defectio.Message[source]#

Server#

class defectio.Server[source]#
property channels#

All channels in the server

Returns

list of all channels

Return type

[type]

property text_channels#

All text channels in the server

Returns

list of all text channels

Return type

[type]

property voice_channels#

All voice channels in the server

Returns

list of all voice channels

Return type

[type]

property members#

All cached members in the server.

Returns

list of all cached members in the server.

Return type

list[Member]

property categories#

All categories in the server

Returns

list of all categories

Return type

list[Category]

Member#

Methods
class defectio.Member[source]#
await fetch_message(id)#

This function is a coroutine.

Retrieves a single Message from the destination.

Parameters

id (int) – The message ID to look for.

Raises
  • NotFound – The specified message was not found.

  • Forbidden – You do not have the permissions required to get a message.

  • HTTPException – Retrieving the message failed.

Returns

The message asked for.

Return type

Message

Role#

class defectio.Role[source]#

TextChannel#

Attributes
Methods
class defectio.TextChannel[source]#
property category#

The category this channel belongs to.

If there is no category then this is None.

Type

Optional[Category]

await fetch_message(id)#

This function is a coroutine.

Retrieves a single Message from the destination.

Parameters

id (int) – The message ID to look for.

Raises
  • NotFound – The specified message was not found.

  • Forbidden – You do not have the permissions required to get a message.

  • HTTPException – Retrieving the message failed.

Returns

The message asked for.

Return type

Message

DMChannel#

Methods
class defectio.DMChannel[source]#
await fetch_message(id)#

This function is a coroutine.

Retrieves a single Message from the destination.

Parameters

id (int) – The message ID to look for.

Raises
  • NotFound – The specified message was not found.

  • Forbidden – You do not have the permissions required to get a message.

  • HTTPException – Retrieving the message failed.

Returns

The message asked for.

Return type

Message

GroupChannel#

Methods
class defectio.GroupChannel[source]#
await fetch_message(id)#

This function is a coroutine.

Retrieves a single Message from the destination.

Parameters

id (int) – The message ID to look for.

Raises
  • NotFound – The specified message was not found.

  • Forbidden – You do not have the permissions required to get a message.

  • HTTPException – Retrieving the message failed.

Returns

The message asked for.

Return type

Message

RawMessageDeleteEvent#

class defectio.RawMessageDeleteEvent[source]#

Represents the event payload for a on_raw_message_delete() event. .. attribute:: channel_id

The channel ID where the deletion took place.

type

str

message_id#

The message ID that got deleted.

Type

str

cached_message#

The cached message, if found in the internal message cache.

Type

Optional[Message]

RawMessageUpdateEvent#

class defectio.RawMessageUpdateEvent[source]#

Represents the payload for a on_raw_message_edit() event.

message_id#

The message ID that got updated.

Type

str

data#

The raw data given by the gateway https://developers.revolt.chat/api#tag/Messaging/paths/~1channels~1:channel~1messages/get

Type

dict

cached_message#

The cached message, if found in the internal message cache. Represents the message before it is modified by the data in RawMessageUpdateEvent.data.

Type

Optional[Message]