Team

Represents a Team on the Discord developer portal.

Attributes

icon_hash : int

The team's icon's hash as uint128. Defaults to 0.

icon_type : IconType

The team's icon's type.

id : int

The unique identifier number of the team.

members : tuple of TeamMember

The members of the team. Includes invited members as well.

name : str

The teams name.

owner_id : int

The team's owner's id.

Notes

Team objects support weakreferencing.

Properties

accepted

A list of the users, who accepted their invite to the team.

Returns

users : list of ClientUserBase

created_at

When the entity was created.

Returns

created_at : datetime

icon

Returns the respective icon.

Returns

icon : Icon

icon_url

Returns the team's icon's url. If the team has no icon, then returns None.

This function is a shared property of Team-s.

Returns

url : None, str

invited

A list of the invited users to the team.

Returns

users : list of ClientUserBase

owner

Returns the team's owner.

Returns

owner : ClientUserBase

partial

Returns whether the team is partial.

Returns

partial : bool

Methods

__new__(...)

Creates a partial team instance.

ParameterTypeOptionalKeyword onlyDescription
icon

None, Icon, str, bytes-like

The team's icon.

members

None, iterable of TeamMember

The members of the team.

name

str

The team's name.

owner_id

int, ClientUserBase

The team's owner's identifier.

Returns

self : instance<cls>

Raises

TypeError

  • If a parameter's type is incorrect.

ValueError

  • If a parameter's value is incorrect.

copy()

Copies the team.

Returns

new : instance<type<self>>

copy_with(...)

Copies the team with the defined fields.

ParameterTypeOptionalKeyword onlyDescription
icon

None, Icon, str, bytes-like

The team's icon.

members

None, iterable of TeamMember

The members of the team.

name

str

The team's name.

owner_id

int, ClientUserBase

The team's owner's identifier.

Returns

new : instance<type<self>>

Raises

TypeError

  • If a parameter's type is incorrect.

ValueError

  • If a parameter's value is incorrect.

from_data(data)

Creates a new team from the given data.

ParameterTypeDescription
data

dict of (str, object) items

Team data.

Returns

team : Team

icon_url_as(...)

Returns the team's icon's url. If the team has no icon, then returns None.

This function is a shared method of Team-s.

ParameterTypeOptionalDefaultDescription
ext

None, str

None

The extension of the icon's url. Can be any of: 'jpg', 'jpeg', 'png', 'webp'.

size

None, int

None

The preferred minimal size of the icon's url.

Returns

url : None, str

Raises

ValueError

If ext, size was not passed as any of the expected values.

iter_members()

Iterates over the team members of team.

This method is an iterable generator.

Yields

team_member : TeamMember

precreate(team_id, ...)

Creates a cached team instance.

ParameterTypeOptionalKeyword onlyDescription
team_id

int

The team's identifier.

**keyword_parameters

Keyword parameters

Additional keyword parameters.

icon

None, Icon, str, bytes-like

The team's icon.

members

None, iterable of TeamMember

The members of the team.

name

str

The team's name.

owner_id

int, ClientUserBase

The team's owner's identifier.

Returns

self : instance<cls>

Raises

TypeError

  • If a parameter's type is incorrect.

ValueError

  • If a parameter's value is incorrect.

to_data(...)

Converts the team into a json serializable object.

ParameterTypeOptionalKeyword onlyDefaultDescription
defaults

bool

False

Whether default field values should be included.

include_internals

bool

False

Whether internal fields should be included.

Returns

data : dict of (str, object) items

to_data_user()

Converts the team into a json serializable object as it would be a user.

Returns

data : dict of (str, object) items

_create_empty(team_id)

Creates a new team instance with it's attribute set to their default values.

ParameterTypeDescription
team_id

int

The team's identifier.

Returns

self : instance<cls>

_get_hash_partial()

Calculates the team's hash based on their fields.

This method is called by .__hash__ if the team has no .id set.

Returns

hash_value : int

_is_equal_same_type(other)

Returns whether self is equal to other. Other must be same type as self.

ParameterTypeDescription
other

instance<type<self>>

The other instance.

Returns

is_equal : bool

_set_attributes(data)

Sets the team's attributes from the given data (except .id).

ParameterTypeDescription
data

None, dict of (str, object) items

Team dat.

__eq__()

Returns whether the two teams are equal.

__ge__()

Whether this entity's id is greater or equal than the other's.

__getattr__()

Drops a rich attribute error.

__gt__()

Whether this entity's id is greater than the other's.

__hash__()

Returns the team's hash value.

__le__()

Whether this entity's id is less or equal than the other's.

__lt__()

Whether this entity's id is less than the other's.

__ne__()

Returns whether the two teams are not equal.

__repr__()

Returns the team's representation.