CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-py-cord

A modern, async-ready Python API wrapper for Discord with comprehensive bot development features

Overall
score

93%

Overview
Eval results
Files

discord-objects.mddocs/

Discord Objects and Entities

Comprehensive representation of Discord's object model including guilds, channels, messages, users, members, roles, and all their associated properties and methods. These classes provide the core data structures for interacting with Discord's API.

Capabilities

Guilds (Servers)

Discord guilds represent servers - communities with channels, members, roles, and various settings.

class Guild:
    """
    Represents a Discord guild (server).
    """
    
    @property
    def id(self) -> int:
        """The guild's ID."""
    
    @property
    def name(self) -> str:
        """The guild's name."""
    
    @property
    def description(self) -> Optional[str]:
        """The guild's description."""
    
    @property
    def icon(self) -> Optional[Asset]:
        """The guild's icon."""
    
    @property
    def banner(self) -> Optional[Asset]:
        """The guild's banner."""
    
    @property
    def owner_id(self) -> int:
        """The ID of the guild owner."""
    
    @property
    def owner(self) -> Optional[Member]:
        """The guild owner."""
    
    @property
    def member_count(self) -> int:
        """The number of members in the guild."""
    
    @property
    def members(self) -> List[Member]:
        """A list of guild members."""
    
    @property
    def channels(self) -> List[GuildChannel]:
        """A list of guild channels."""
    
    @property
    def text_channels(self) -> List[TextChannel]:
        """A list of text channels."""
    
    @property
    def voice_channels(self) -> List[VoiceChannel]:
        """A list of voice channels."""
    
    @property
    def categories(self) -> List[CategoryChannel]:
        """A list of category channels."""
    
    @property
    def threads(self) -> List[Thread]:
        """A list of threads in the guild."""
    
    @property
    def roles(self) -> List[Role]:
        """A list of guild roles."""
    
    @property
    def emojis(self) -> List[Emoji]:
        """A list of custom emojis."""
    
    @property
    def stickers(self) -> List[GuildSticker]:
        """A list of guild stickers."""
    
    @property
    def verification_level(self) -> VerificationLevel:
        """The guild's verification level."""
    
    @property
    def default_notifications(self) -> NotificationLevel:
        """Default notification level."""
    
    @property
    def explicit_content_filter(self) -> ContentFilter:
        """Explicit content filter level."""
    
    def get_channel(self, channel_id: int) -> Optional[GuildChannel]:
        """Get a channel by ID."""
    
    def get_member(self, user_id: int) -> Optional[Member]:
        """Get a member by user ID."""
    
    def get_role(self, role_id: int) -> Optional[Role]:
        """Get a role by ID."""
    
    async def create_text_channel(
        self,
        name: str,
        *,
        category: Optional[CategoryChannel] = None,
        position: int = None,
        topic: str = None,
        slowmode_delay: int = None,
        nsfw: bool = None,
        overwrites: Dict[Union[Role, Member], PermissionOverwrite] = None,
        **kwargs
    ) -> TextChannel:
        """
        Create a text channel.
        
        Parameters:
        - name: str - Channel name
        - category: CategoryChannel - Parent category
        - position: int - Channel position
        - topic: str - Channel topic
        - slowmode_delay: int - Slowmode delay in seconds
        - nsfw: bool - Whether the channel is NSFW
        - overwrites: Dict - Permission overwrites
        """
    
    async def create_voice_channel(
        self,
        name: str,
        *,
        category: Optional[CategoryChannel] = None,
        position: int = None,
        bitrate: int = None,
        user_limit: int = None,
        overwrites: Dict[Union[Role, Member], PermissionOverwrite] = None,
        **kwargs
    ) -> VoiceChannel:
        """
        Create a voice channel.
        
        Parameters:
        - name: str - Channel name
        - category: CategoryChannel - Parent category
        - position: int - Channel position
        - bitrate: int - Voice bitrate
        - user_limit: int - Maximum users
        - overwrites: Dict - Permission overwrites
        """
    
    async def create_category(
        self,
        name: str,
        *,
        overwrites: Dict[Union[Role, Member], PermissionOverwrite] = None,
        position: int = None,
        **kwargs
    ) -> CategoryChannel:
        """Create a category channel."""
    
    async def create_forum_channel(
        self,
        name: str,
        *,
        category: Optional[CategoryChannel] = None,
        topic: str = None,
        position: int = None,
        slowmode_delay: int = None,
        nsfw: bool = None,
        available_tags: List[ForumTag] = None,
        default_reaction_emoji: Union[str, Emoji, PartialEmoji] = None,
        **kwargs
    ) -> ForumChannel:
        """Create a forum channel."""
    
    async def create_role(
        self,
        *,
        name: str = "new role",
        permissions: Permissions = None,
        color: Union[Colour, int] = None,
        hoist: bool = None,
        mentionable: bool = None,
        **kwargs
    ) -> Role:
        """
        Create a role.
        
        Parameters:
        - name: str - Role name
        - permissions: Permissions - Role permissions
        - color: Union[Colour, int] - Role color
        - hoist: bool - Whether the role is hoisted
        - mentionable: bool - Whether the role is mentionable
        """
    
    async def ban(
        self,
        user: Union[User, Member, Object],
        *,
        reason: str = None,
        delete_message_days: int = None,
        delete_message_seconds: int = None
    ) -> None:
        """Ban a user from the guild."""
    
    async def unban(self, user: Union[User, Object], *, reason: str = None) -> None:
        """Unban a user from the guild."""
    
    async def kick(self, user: Member, *, reason: str = None) -> None:
        """Kick a member from the guild."""
    
    async def edit(
        self,
        *,
        name: str = None,
        description: str = None,
        icon: bytes = None,
        banner: bytes = None,
        **kwargs
    ) -> Guild:
        """Edit the guild."""
    
    async def leave(self) -> None:
        """Leave the guild."""
    
    async def delete(self) -> None:
        """Delete the guild (owner only)."""

class PartialInviteGuild:
    """Partial guild information from an invite."""
    
    @property
    def id(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def icon(self) -> Optional[Asset]: ...
    @property
    def banner(self) -> Optional[Asset]: ...

Channels

Different types of communication channels within Discord guilds.

class TextChannel:
    """
    Represents a Discord text channel.
    """
    
    @property
    def id(self) -> int:
        """The channel's ID."""
    
    @property
    def name(self) -> str:
        """The channel's name."""
    
    @property
    def guild(self) -> Guild:
        """The guild this channel belongs to."""
    
    @property
    def topic(self) -> Optional[str]:
        """The channel's topic."""
    
    @property
    def position(self) -> int:
        """The channel's position."""
    
    @property
    def category(self) -> Optional[CategoryChannel]:
        """The category this channel belongs to."""
    
    @property
    def slowmode_delay(self) -> int:
        """Slowmode delay in seconds."""
    
    @property
    def nsfw(self) -> bool:
        """Whether the channel is NSFW."""
    
    @property
    def last_message_id(self) -> Optional[int]:
        """The ID of the last message."""
    
    @property
    def last_message(self) -> Optional[Message]:
        """The last message sent in the channel."""
    
    async def send(
        self,
        content: str = None,
        *,
        tts: bool = False,
        embed: Embed = None,
        embeds: List[Embed] = None,
        file: File = None,
        files: List[File] = None,
        view: View = None,
        allowed_mentions: AllowedMentions = None,
        reference: Union[Message, MessageReference] = None,
        mention_author: bool = None,
        suppress_embeds: bool = False,
        silent: bool = False,
        **kwargs
    ) -> Message:
        """
        Send a message to the channel.
        
        Parameters:
        - content: str - Message content
        - tts: bool - Whether the message uses text-to-speech
        - embed: Embed - Rich embed
        - embeds: List[Embed] - List of embeds
        - file: File - File attachment
        - files: List[File] - Multiple file attachments
        - view: View - UI components
        - allowed_mentions: AllowedMentions - Mention settings
        - reference: Message - Message to reply to
        - mention_author: bool - Whether to mention the author when replying
        - suppress_embeds: bool - Whether to suppress embeds
        - silent: bool - Whether the message should not trigger notifications
        """
    
    async def fetch_message(self, id: int) -> Message:
        """Fetch a message by ID."""
    
    def history(
        self,
        *,
        limit: int = 100,
        before: Union[Snowflake, datetime] = None,
        after: Union[Snowflake, datetime] = None,
        around: Union[Snowflake, datetime] = None,
        oldest_first: bool = None
    ) -> HistoryIterator:
        """
        Returns an async iterator for message history.
        
        Parameters:
        - limit: int - Maximum messages to retrieve
        - before: Snowflake - Get messages before this message/time
        - after: Snowflake - Get messages after this message/time
        - around: Snowflake - Get messages around this message/time
        - oldest_first: bool - Whether to get oldest messages first
        """
    
    async def purge(
        self,
        *,
        limit: int = 100,
        check: Callable[[Message], bool] = None,
        before: Union[Snowflake, datetime] = None,
        after: Union[Snowflake, datetime] = None,
        around: Union[Snowflake, datetime] = None,
        oldest_first: bool = False,
        bulk: bool = True
    ) -> List[Message]:
        """
        Purge messages from the channel.
        
        Parameters:
        - limit: int - Maximum messages to delete
        - check: Callable - Function to check if a message should be deleted
        - before: Snowflake - Delete messages before this message/time
        - after: Snowflake - Delete messages after this message/time
        - around: Snowflake - Delete messages around this message/time
        - oldest_first: bool - Whether to delete oldest messages first
        - bulk: bool - Whether to use bulk delete
        """
    
    async def create_thread(
        self,
        *,
        name: str,
        message: Message = None,
        auto_archive_duration: int = None,
        type: ChannelType = None,
        slowmode_delay: int = None,
        **kwargs
    ) -> Thread:
        """
        Create a thread in this channel.
        
        Parameters:
        - name: str - Thread name
        - message: Message - Message to create thread from
        - auto_archive_duration: int - Minutes before auto-archiving
        - type: ChannelType - Thread type
        - slowmode_delay: int - Slowmode delay in seconds
        """
    
    async def edit(
        self,
        *,
        name: str = None,
        topic: str = None,
        position: int = None,
        nsfw: bool = None,
        sync_permissions: bool = None,
        category: CategoryChannel = None,
        slowmode_delay: int = None,
        type: ChannelType = None,
        overwrites: Dict[Union[Role, Member], PermissionOverwrite] = None,
        **kwargs
    ) -> TextChannel:
        """Edit the channel."""
    
    async def delete(self, *, reason: str = None) -> None:
        """Delete the channel."""

class VoiceChannel:
    """
    Represents a Discord voice channel.
    """
    
    @property
    def id(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def guild(self) -> Guild: ...
    @property
    def bitrate(self) -> int:
        """The channel's bitrate."""
    
    @property
    def user_limit(self) -> int:
        """The channel's user limit."""
    
    @property
    def members(self) -> List[Member]:
        """Members currently in the voice channel."""
    
    async def connect(
        self,
        *,
        timeout: float = 60.0,
        reconnect: bool = True,
        cls: Callable = None
    ) -> VoiceClient:
        """Connect to the voice channel."""
    
    async def edit(
        self,
        *,
        name: str = None,
        bitrate: int = None,
        user_limit: int = None,
        position: int = None,
        sync_permissions: bool = None,
        category: CategoryChannel = None,
        overwrites: Dict[Union[Role, Member], PermissionOverwrite] = None,
        **kwargs
    ) -> VoiceChannel:
        """Edit the voice channel."""

class StageChannel:
    """
    Represents a Discord stage channel for presentations.
    """
    
    @property
    def id(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def guild(self) -> Guild: ...
    @property
    def topic(self) -> Optional[str]: ...
    @property
    def bitrate(self) -> int: ...
    @property
    def user_limit(self) -> int: ...
    @property
    def instance(self) -> Optional[StageInstance]: ...
    
    async def create_instance(
        self,
        *,
        topic: str,
        privacy_level: StagePrivacyLevel = StagePrivacyLevel.guild_only,
        send_start_notification: bool = False,
        **kwargs
    ) -> StageInstance:
        """Create a stage instance."""

class ForumChannel:
    """
    Represents a Discord forum channel.
    """
    
    @property
    def id(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def guild(self) -> Guild: ...
    @property
    def topic(self) -> Optional[str]: ...
    @property
    def available_tags(self) -> List[ForumTag]: ...
    @property
    def default_reaction_emoji(self) -> Optional[Union[Emoji, PartialEmoji, str]]: ...
    @property
    def threads(self) -> List[Thread]: ...
    
    async def create_thread(
        self,
        *,
        name: str,
        content: str = None,
        embed: Embed = None,
        embeds: List[Embed] = None,
        file: File = None,
        files: List[File] = None,
        view: View = None,
        applied_tags: List[ForumTag] = None,
        slowmode_delay: int = None,
        auto_archive_duration: int = None,
        **kwargs
    ) -> Thread:
        """Create a forum post (thread)."""

class CategoryChannel:
    """
    Represents a Discord category channel.
    """
    
    @property
    def id(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def guild(self) -> Guild: ...
    @property
    def channels(self) -> List[GuildChannel]: ...
    @property
    def text_channels(self) -> List[TextChannel]: ...
    @property
    def voice_channels(self) -> List[VoiceChannel]: ...

class DMChannel:
    """
    Represents a Discord direct message channel.
    """
    
    @property
    def id(self) -> int: ...
    @property
    def recipient(self) -> User: ...
    
    async def send(
        self,
        content: str = None,
        *,
        tts: bool = False,
        embed: Embed = None,
        embeds: List[Embed] = None,
        file: File = None,
        files: List[File] = None,
        view: View = None,
        **kwargs
    ) -> Message:
        """Send a message to the DM channel."""

class GroupChannel:
    """
    Represents a Discord group direct message channel.
    """
    
    @property
    def id(self) -> int: ...
    @property
    def name(self) -> Optional[str]: ...
    @property
    def recipients(self) -> List[User]: ...
    @property
    def owner(self) -> Optional[User]: ...

Messages and Communication

Messages represent content sent in Discord channels, including text, embeds, attachments, and interactive components.

class Message:
    """
    Represents a Discord message.
    """
    
    @property
    def id(self) -> int:
        """The message's ID."""
    
    @property
    def content(self) -> str:
        """The message content."""
    
    @property
    def author(self) -> Union[User, Member]:
        """The message author."""
    
    @property
    def channel(self) -> Union[TextChannel, DMChannel, GroupChannel, Thread]:
        """The channel where the message was sent."""
    
    @property
    def guild(self) -> Optional[Guild]:
        """The guild where the message was sent."""
    
    @property
    def created_at(self) -> datetime:
        """When the message was created."""
    
    @property
    def edited_at(self) -> Optional[datetime]:
        """When the message was last edited."""
    
    @property
    def embeds(self) -> List[Embed]:
        """A list of embeds in the message."""
    
    @property
    def attachments(self) -> List[Attachment]:
        """A list of file attachments."""
    
    @property
    def reactions(self) -> List[Reaction]:
        """A list of reactions on the message."""
    
    @property
    def mentions(self) -> List[Union[User, Member]]:
        """Users mentioned in the message."""
    
    @property
    def channel_mentions(self) -> List[GuildChannel]:
        """Channels mentioned in the message."""
    
    @property
    def role_mentions(self) -> List[Role]:
        """Roles mentioned in the message."""
    
    @property
    def mention_everyone(self) -> bool:
        """Whether the message mentions everyone."""
    
    @property
    def pinned(self) -> bool:
        """Whether the message is pinned."""
    
    @property
    def tts(self) -> bool:
        """Whether the message uses text-to-speech."""
    
    @property
    def type(self) -> MessageType:
        """The message type."""
    
    @property
    def flags(self) -> MessageFlags:
        """The message flags."""
    
    @property
    def reference(self) -> Optional[MessageReference]:
        """The message being replied to."""
    
    @property
    def thread(self) -> Optional[Thread]:
        """The thread created from this message."""
    
    @property
    def components(self) -> List[Component]:
        """UI components attached to the message."""
    
    @property
    def stickers(self) -> List[StickerItem]:
        """Stickers in the message."""
    
    async def reply(
        self,
        content: str = None,
        *,
        tts: bool = False,
        embed: Embed = None,
        embeds: List[Embed] = None,
        file: File = None,
        files: List[File] = None,
        view: View = None,
        allowed_mentions: AllowedMentions = None,
        mention_author: bool = None,
        **kwargs
    ) -> Message:
        """Reply to the message."""
    
    async def edit(
        self,
        *,
        content: str = None,
        embed: Embed = None,
        embeds: List[Embed] = None,
        attachments: List[Attachment] = None,
        view: View = None,
        allowed_mentions: AllowedMentions = None,
        suppress: bool = None,
        **kwargs
    ) -> Message:
        """Edit the message."""
    
    async def delete(self, *, delay: float = None) -> None:
        """Delete the message."""
    
    async def add_reaction(self, emoji: Union[Emoji, Reaction, PartialEmoji, str]) -> None:
        """Add a reaction to the message."""
    
    async def remove_reaction(
        self,
        emoji: Union[Emoji, Reaction, PartialEmoji, str],
        member: Union[Member, User]
    ) -> None:
        """Remove a reaction from the message."""
    
    async def clear_reactions(self) -> None:
        """Clear all reactions from the message."""
    
    async def pin(self, *, reason: str = None) -> None:
        """Pin the message."""
    
    async def unpin(self, *, reason: str = None) -> None:
        """Unpin the message."""
    
    async def create_thread(
        self,
        *,
        name: str,
        auto_archive_duration: int = None,
        slowmode_delay: int = None,
        **kwargs
    ) -> Thread:
        """Create a thread from this message."""

class PartialMessage:
    """
    Represents a partial message object.
    """
    
    @property
    def id(self) -> int: ...
    @property
    def channel(self) -> Union[PartialMessageable, TextChannel, DMChannel, Thread]: ...
    @property
    def guild(self) -> Optional[Guild]: ...
    
    async def fetch(self) -> Message:
        """Fetch the full message."""
    
    async def edit(self, **kwargs) -> Message:
        """Edit the message."""
    
    async def delete(self, *, delay: float = None) -> None:
        """Delete the message."""

class MessageReference:
    """
    Represents a reference to another message.
    """
    
    @property
    def message_id(self) -> Optional[int]: ...
    @property
    def channel_id(self) -> int: ...
    @property
    def guild_id(self) -> Optional[int]: ...
    @property
    def resolved(self) -> Optional[Message]: ...

class Attachment:
    """
    Represents a file attachment to a message.
    """
    
    @property
    def id(self) -> int: ...
    @property
    def filename(self) -> str: ...
    @property
    def description(self) -> Optional[str]: ...
    @property
    def content_type(self) -> Optional[str]: ...
    @property
    def size(self) -> int: ...
    @property
    def url(self) -> str: ...
    @property
    def proxy_url(self) -> str: ...
    @property
    def height(self) -> Optional[int]: ...
    @property
    def width(self) -> Optional[int]: ...
    @property
    def ephemeral(self) -> bool: ...
    
    async def save(
        self,
        fp: Union[str, bytes, os.PathLike, io.BufferedIOBase],
        *,
        seek_begin: bool = True,
        use_cached: bool = False
    ) -> int:
        """Save the attachment to a file."""
    
    async def read(self, *, use_cached: bool = False) -> bytes:
        """Read the attachment data."""
    
    async def to_file(
        self,
        *,
        filename: str = None,
        description: str = None,
        use_cached: bool = False,
        spoiler: bool = False
    ) -> File:
        """Convert to a File object."""

class Reaction:
    """
    Represents a message reaction.
    """
    
    @property
    def emoji(self) -> Union[Emoji, PartialEmoji, str]: ...
    @property
    def count(self) -> int: ...
    @property
    def me(self) -> bool: ...
    @property
    def message(self) -> Message: ...
    
    def users(self, *, limit: int = None, after: Snowflake = None) -> ReactionIterator:
        """Get users who reacted with this emoji."""
    
    async def remove(self, user: Union[Member, User]) -> None:
        """Remove the reaction from a user."""
    
    async def clear(self) -> None:
        """Clear this reaction from the message."""

Users and Members

Users represent Discord accounts, while Members represent users within the context of a specific guild.

class User:
    """
    Represents a Discord user.
    """
    
    @property
    def id(self) -> int:
        """The user's ID."""
    
    @property
    def name(self) -> str:
        """The user's username."""
    
    @property
    def discriminator(self) -> str:
        """The user's discriminator."""
    
    @property
    def global_name(self) -> Optional[str]:
        """The user's global display name."""
    
    @property
    def display_name(self) -> str:
        """The user's display name."""
    
    @property
    def avatar(self) -> Optional[Asset]:
        """The user's avatar."""
    
    @property
    def banner(self) -> Optional[Asset]:
        """The user's banner."""
    
    @property
    def accent_color(self) -> Optional[Colour]:
        """The user's accent color."""
    
    @property
    def bot(self) -> bool:
        """Whether the user is a bot."""
    
    @property
    def system(self) -> bool:
        """Whether the user is a Discord system user."""
    
    @property
    def verified(self) -> bool:
        """Whether the user has a verified email."""
    
    @property
    def mfa_enabled(self) -> bool:
        """Whether the user has MFA enabled."""
    
    @property
    def public_flags(self) -> PublicUserFlags:
        """The user's public flags."""
    
    @property
    def created_at(self) -> datetime:
        """When the user account was created."""
    
    async def send(
        self,
        content: str = None,
        *,
        tts: bool = False,
        embed: Embed = None,
        embeds: List[Embed] = None,
        file: File = None,
        files: List[File] = None,
        view: View = None,
        **kwargs
    ) -> Message:
        """Send a direct message to the user."""
    
    async def create_dm(self) -> DMChannel:
        """Create a DM channel with the user."""

class Member(User):
    """
    Represents a Discord guild member.
    """
    
    @property
    def guild(self) -> Guild:
        """The guild this member belongs to."""
    
    @property
    def nick(self) -> Optional[str]:
        """The member's nickname."""
    
    @property
    def display_name(self) -> str:
        """The member's display name (nickname or username)."""
    
    @property
    def roles(self) -> List[Role]:
        """The member's roles."""
    
    @property
    def joined_at(self) -> Optional[datetime]:
        """When the member joined the guild."""
    
    @property
    def premium_since(self) -> Optional[datetime]:
        """When the member started boosting."""
    
    @property
    def pending(self) -> bool:
        """Whether the member is pending verification."""
    
    @property
    def timed_out_until(self) -> Optional[datetime]:
        """When the member's timeout expires."""
    
    @property
    def voice(self) -> Optional[VoiceState]:
        """The member's voice state."""
    
    @property
    def activities(self) -> List[BaseActivity]:
        """The member's activities."""
    
    @property
    def status(self) -> Status:
        """The member's status."""
    
    @property
    def colour(self) -> Colour:
        """The member's color from their highest role."""
    
    @property
    def color(self) -> Colour:
        """Alias for colour."""
    
    @property
    def top_role(self) -> Role:
        """The member's highest role."""
    
    @property
    def guild_permissions(self) -> Permissions:
        """The member's guild permissions."""
    
    def permissions_in(self, channel: GuildChannel) -> Permissions:
        """Get the member's permissions in a channel."""
    
    async def add_roles(
        self,
        *roles: Role,
        reason: str = None,
        atomic: bool = True
    ) -> None:
        """Add roles to the member."""
    
    async def remove_roles(
        self,
        *roles: Role,
        reason: str = None,
        atomic: bool = True
    ) -> None:
        """Remove roles from the member."""
    
    async def edit(
        self,
        *,
        nick: str = None,
        mute: bool = None,
        deafen: bool = None,
        suppress: bool = None,
        roles: List[Role] = None,
        voice_channel: Optional[VoiceChannel] = None,
        timed_out_until: Optional[Union[float, datetime]] = None,
        **kwargs
    ) -> Member:
        """Edit the member."""
    
    async def timeout(
        self,
        until: Union[float, datetime, timedelta],
        *,
        reason: str = None
    ) -> Member:
        """Timeout the member."""
    
    async def remove_timeout(self, *, reason: str = None) -> Member:
        """Remove the member's timeout."""
    
    async def kick(self, *, reason: str = None) -> None:
        """Kick the member from the guild."""
    
    async def ban(
        self,
        *,
        reason: str = None,
        delete_message_days: int = None,
        delete_message_seconds: int = None
    ) -> None:
        """Ban the member from the guild."""
    
    async def move_to(
        self,
        channel: Optional[VoiceChannel],
        *,
        reason: str = None
    ) -> None:
        """Move the member to a voice channel."""

class VoiceState:
    """
    Represents a member's voice connection state.
    """
    
    @property
    def session_id(self) -> str: ...
    @property
    def channel(self) -> Optional[Union[VoiceChannel, StageChannel]]: ...
    @property
    def user_id(self) -> int: ...
    @property
    def member(self) -> Optional[Member]: ...
    @property
    def deaf(self) -> bool: ...
    @property
    def mute(self) -> bool: ...
    @property
    def self_deaf(self) -> bool: ...
    @property
    def self_mute(self) -> bool: ...
    @property
    def self_stream(self) -> bool: ...
    @property
    def self_video(self) -> bool: ...
    @property
    def suppress(self) -> bool: ...
    @property
    def requested_to_speak_at(self) -> Optional[datetime]: ...

Roles and Permissions

Roles define permissions and organizational structure within guilds.

class Role:
    """
    Represents a Discord role.
    """
    
    @property
    def id(self) -> int:
        """The role's ID."""
    
    @property
    def name(self) -> str:
        """The role's name."""
    
    @property
    def guild(self) -> Guild:
        """The guild this role belongs to."""
    
    @property
    def color(self) -> Colour:
        """The role's color."""
    
    @property
    def colour(self) -> Colour:
        """Alias for color."""
    
    @property
    def hoist(self) -> bool:
        """Whether the role is hoisted."""
    
    @property
    def position(self) -> int:
        """The role's position."""
    
    @property
    def managed(self) -> bool:
        """Whether the role is managed by an integration."""
    
    @property
    def mentionable(self) -> bool:
        """Whether the role is mentionable."""
    
    @property
    def permissions(self) -> Permissions:
        """The role's permissions."""
    
    @property
    def tags(self) -> Optional[RoleTags]:
        """The role's tags."""
    
    @property
    def members(self) -> List[Member]:
        """Members with this role."""
    
    @property
    def created_at(self) -> datetime:
        """When the role was created."""
    
    @property
    def mention(self) -> str:
        """The role's mention string."""
    
    async def edit(
        self,
        *,
        name: str = None,
        permissions: Permissions = None,
        color: Union[Colour, int] = None,
        colour: Union[Colour, int] = None,
        hoist: bool = None,
        mentionable: bool = None,
        position: int = None,
        **kwargs
    ) -> Role:
        """Edit the role."""
    
    async def delete(self, *, reason: str = None) -> None:
        """Delete the role."""

class RoleTags:
    """
    Represents role tags that give information about a role.
    """
    
    @property
    def bot_id(self) -> Optional[int]: ...
    @property
    def integration_id(self) -> Optional[int]: ...
    @property
    def premium_subscriber(self) -> bool: ...
    @property
    def available_for_purchase(self) -> bool: ...
    @property
    def guild_connections(self) -> bool: ...

class Permissions:
    """
    Represents Discord permissions.
    """
    
    def __init__(self, permissions: int = 0, **kwargs) -> None: ...
    
    @classmethod
    def none(cls) -> Permissions: ...
    @classmethod
    def all(cls) -> Permissions: ...
    @classmethod
    def all_channel(cls) -> Permissions: ...
    @classmethod
    def general(cls) -> Permissions: ...
    @classmethod
    def text(cls) -> Permissions: ...
    @classmethod
    def voice(cls) -> Permissions: ...
    @classmethod
    def stage(cls) -> Permissions: ...
    @classmethod
    def stage_moderator(cls) -> Permissions: ...
    @classmethod
    def elevated(cls) -> Permissions: ...
    @classmethod
    def advanced(cls) -> Permissions: ...
    
    @property
    def value(self) -> int: ...
    
    # Permission flags
    @property
    def create_instant_invite(self) -> bool: ...
    @property
    def kick_members(self) -> bool: ...
    @property
    def ban_members(self) -> bool: ...
    @property
    def administrator(self) -> bool: ...
    @property
    def manage_channels(self) -> bool: ...
    @property
    def manage_guild(self) -> bool: ...
    @property
    def add_reactions(self) -> bool: ...
    @property
    def view_audit_log(self) -> bool: ...
    @property
    def priority_speaker(self) -> bool: ...
    @property
    def stream(self) -> bool: ...
    @property
    def read_messages(self) -> bool: ...
    @property
    def view_channel(self) -> bool: ...
    @property
    def send_messages(self) -> bool: ...
    @property
    def send_tts_messages(self) -> bool: ...
    @property
    def manage_messages(self) -> bool: ...
    @property
    def embed_links(self) -> bool: ...
    @property
    def attach_files(self) -> bool: ...
    @property
    def read_message_history(self) -> bool: ...
    @property
    def mention_everyone(self) -> bool: ...
    @property
    def external_emojis(self) -> bool: ...
    @property
    def use_external_emojis(self) -> bool: ...
    @property
    def view_guild_insights(self) -> bool: ...
    @property
    def connect(self) -> bool: ...
    @property
    def speak(self) -> bool: ...
    @property
    def mute_members(self) -> bool: ...
    @property
    def deafen_members(self) -> bool: ...
    @property
    def move_members(self) -> bool: ...
    @property
    def use_voice_activation(self) -> bool: ...
    @property
    def change_nickname(self) -> bool: ...
    @property
    def manage_nicknames(self) -> bool: ...
    @property
    def manage_roles(self) -> bool: ...
    @property
    def manage_permissions(self) -> bool: ...
    @property
    def manage_webhooks(self) -> bool: ...
    @property
    def manage_emojis(self) -> bool: ...
    @property
    def manage_emojis_and_stickers(self) -> bool: ...
    @property
    def use_slash_commands(self) -> bool: ...
    @property
    def use_application_commands(self) -> bool: ...
    @property
    def request_to_speak(self) -> bool: ...
    @property
    def manage_events(self) -> bool: ...
    @property
    def manage_threads(self) -> bool: ...
    @property
    def create_public_threads(self) -> bool: ...
    @property
    def create_private_threads(self) -> bool: ...
    @property
    def external_stickers(self) -> bool: ...
    @property
    def use_external_stickers(self) -> bool: ...
    @property
    def send_messages_in_threads(self) -> bool: ...
    @property
    def use_embedded_activities(self) -> bool: ...
    @property
    def moderate_members(self) -> bool: ...

class PermissionOverwrite:
    """
    Represents a channel permission overwrite.
    """
    
    def __init__(self, *, allow: Permissions = None, deny: Permissions = None) -> None: ...
    
    @property
    def allow(self) -> Permissions: ...
    @property
    def deny(self) -> Permissions: ...
    @property
    def pair(self) -> Tuple[Permissions, Permissions]: ...
    
    @classmethod
    def from_pair(cls, allow: Permissions, deny: Permissions) -> PermissionOverwrite: ...

Threads

Threads provide focused discussion spaces within channels.

class Thread:
    """
    Represents a Discord thread.
    """
    
    @property
    def id(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def guild(self) -> Guild: ...
    @property
    def parent(self) -> Union[TextChannel, ForumChannel]: ...
    @property
    def owner_id(self) -> int: ...
    @property
    def owner(self) -> Optional[Member]: ...
    @property
    def last_message_id(self) -> Optional[int]: ...
    @property
    def slowmode_delay(self) -> int: ...
    @property
    def message_count(self) -> int: ...
    @property
    def member_count(self) -> int: ...
    @property
    def archived(self) -> bool: ...
    @property
    def locked(self) -> bool: ...
    @property
    def invitable(self) -> bool: ...
    @property
    def archive_timestamp(self) -> datetime: ...
    @property
    def auto_archive_duration(self) -> int: ...
    @property
    def applied_tags(self) -> List[ForumTag]: ...
    
    async def send(
        self,
        content: str = None,
        *,
        tts: bool = False,
        embed: Embed = None,
        embeds: List[Embed] = None,
        file: File = None,
        files: List[File] = None,
        view: View = None,
        **kwargs
    ) -> Message:
        """Send a message to the thread."""
    
    async def join(self) -> None:
        """Join the thread."""
    
    async def leave(self) -> None:
        """Leave the thread."""
    
    async def add_user(self, user: Union[Member, User]) -> None:
        """Add a user to the thread."""
    
    async def remove_user(self, user: Union[Member, User]) -> None:
        """Remove a user from the thread."""
    
    async def edit(
        self,
        *,
        name: str = None,
        archived: bool = None,
        locked: bool = None,
        invitable: bool = None,
        slowmode_delay: int = None,
        auto_archive_duration: int = None,
        applied_tags: List[ForumTag] = None,
        **kwargs
    ) -> Thread:
        """Edit the thread."""
    
    async def delete(self) -> None:
        """Delete the thread."""

class ThreadMember:
    """
    Represents a member of a thread.
    """
    
    @property
    def id(self) -> int: ...
    @property
    def user_id(self) -> int: ...
    @property
    def thread(self) -> Thread: ...
    @property
    def joined_at(self) -> datetime: ...

Webhooks and External Integrations

Webhook support for external integrations and message posting.

class Webhook:
    """
    Represents a Discord webhook for external integrations.
    """
    
    @property
    def id(self) -> int: ...
    @property
    def name(self) -> Optional[str]: ...
    @property
    def avatar(self) -> Optional[str]: ...
    @property
    def channel_id(self) -> Optional[int]: ...
    @property
    def guild_id(self) -> Optional[int]: ...
    @property
    def user(self) -> Optional[User]: ...
    @property
    def token(self) -> Optional[str]: ...
    @property
    def type(self) -> WebhookType: ...
    @property
    def source_guild(self) -> Optional[PartialWebhookGuild]: ...
    @property
    def source_channel(self) -> Optional[PartialWebhookChannel]: ...
    
    async def send(
        self,
        content: str = None,
        *,
        username: str = None,
        avatar_url: str = None,
        tts: bool = False,
        embed: Embed = None,
        embeds: List[Embed] = None,
        file: File = None,
        files: List[File] = None,
        view: View = None,
        allowed_mentions: AllowedMentions = None,
        thread: Snowflake = None,
        wait: bool = False,
        **kwargs
    ) -> Optional[WebhookMessage]:
        """Send a message via webhook."""
    
    async def edit_message(
        self,
        message_id: int,
        *,
        content: str = None,
        embed: Embed = None,
        embeds: List[Embed] = None,
        view: View = None,
        allowed_mentions: AllowedMentions = None,
        **kwargs
    ) -> WebhookMessage:
        """Edit a webhook message."""
    
    async def delete_message(self, message_id: int) -> None:
        """Delete a webhook message."""
    
    async def fetch_message(self, message_id: int) -> WebhookMessage:
        """Fetch a webhook message."""

class WebhookMessage:
    """
    Represents a message sent by a webhook.
    """
    
    @property
    def id(self) -> int: ...
    @property
    def content(self) -> str: ...
    @property
    def embeds(self) -> List[Embed]: ...
    @property
    def author(self) -> WebhookAuthor: ...
    
    async def edit(self, **kwargs) -> WebhookMessage: ...
    async def delete(self, *, delay: float = None) -> None: ...

class SyncWebhook:
    """Synchronous webhook client for non-async environments."""
    
    def send(self, **kwargs) -> Optional[WebhookMessage]: ...
    def edit_message(self, message_id: int, **kwargs) -> WebhookMessage: ...
    def delete_message(self, message_id: int) -> None: ...

Invites and Templates

Discord invite links and server templates for server creation and sharing.

class Invite:
    """
    Represents a Discord invite.
    """
    
    @property
    def code(self) -> str: ...
    @property
    def guild(self) -> Optional[Union[Guild, PartialInviteGuild]]: ...
    @property
    def channel(self) -> Optional[Union[GuildChannel, PartialInviteChannel]]: ...
    @property
    def inviter(self) -> Optional[User]: ...
    @property
    def uses(self) -> Optional[int]: ...
    @property
    def max_uses(self) -> Optional[int]: ...
    @property
    def max_age(self) -> Optional[int]: ...
    @property
    def temporary(self) -> Optional[bool]: ...
    @property
    def created_at(self) -> Optional[datetime]: ...
    @property
    def expires_at(self) -> Optional[datetime]: ...
    @property
    def url(self) -> str: ...
    
    async def delete(self, *, reason: str = None) -> None:
        """Delete the invite."""

class Template:
    """
    Represents a Discord guild template.
    """
    
    @property
    def code(self) -> str: ...
    @property
    def name(self) -> str: ...
    @property
    def description(self) -> Optional[str]: ...
    @property
    def usage_count(self) -> int: ...
    @property
    def creator(self) -> User: ...
    @property
    def created_at(self) -> datetime: ...
    @property
    def updated_at(self) -> datetime: ...
    @property
    def source_guild(self) -> Guild: ...
    @property
    def url(self) -> str: ...
    
    async def create_guild(self, name: str, icon: bytes = None) -> Guild:
        """Create a guild from this template."""
    
    async def sync(self) -> Template:
        """Sync the template with the source guild."""
    
    async def edit(
        self,
        *,
        name: str = None,
        description: str = None
    ) -> Template:
        """Edit the template."""
    
    async def delete(self) -> None:
        """Delete the template."""

Scheduled Events

Guild scheduled events for community organization.

class ScheduledEvent:
    """
    Represents a Discord scheduled event.
    """
    
    @property
    def id(self) -> int: ...
    @property
    def guild_id(self) -> int: ...
    @property
    def guild(self) -> Optional[Guild]: ...
    @property
    def channel_id(self) -> Optional[int]: ...
    @property
    def channel(self) -> Optional[Union[VoiceChannel, StageChannel]]: ...
    @property
    def creator_id(self) -> Optional[int]: ...
    @property
    def creator(self) -> Optional[User]: ...
    @property
    def name(self) -> str: ...
    @property
    def description(self) -> Optional[str]: ...
    @property
    def start_time(self) -> datetime: ...
    @property
    def end_time(self) -> Optional[datetime]: ...
    @property
    def privacy_level(self) -> ScheduledEventPrivacyLevel: ...
    @property
    def status(self) -> ScheduledEventStatus: ...
    @property
    def location(self) -> Optional[ScheduledEventLocation]: ...
    @property
    def user_count(self) -> Optional[int]: ...
    @property
    def cover_image(self) -> Optional[Asset]: ...
    
    async def edit(
        self,
        *,
        name: str = None,
        description: str = None,
        start_time: datetime = None,
        end_time: datetime = None,
        privacy_level: ScheduledEventPrivacyLevel = None,
        status: ScheduledEventStatus = None,
        location: str = None,
        cover_image: bytes = None,
        **kwargs
    ) -> ScheduledEvent:
        """Edit the scheduled event."""
    
    async def delete(self) -> None:
        """Delete the scheduled event."""
    
    async def start(self) -> ScheduledEvent:
        """Start the scheduled event."""
    
    async def end(self) -> ScheduledEvent:
        """End the scheduled event."""
    
    async def cancel(self) -> ScheduledEvent:
        """Cancel the scheduled event."""
    
    def subscribers(self, *, limit: int = 100, before: Snowflake = None, after: Snowflake = None) -> ScheduledEventSubscribersIterator:
        """Get subscribers to the event."""

Auto-Moderation

Auto-moderation rules and actions for content filtering.

class AutoModRule:
    """
    Represents an auto-moderation rule.
    """
    
    @property
    def id(self) -> int: ...
    @property
    def guild_id(self) -> int: ...
    @property
    def guild(self) -> Guild: ...
    @property
    def name(self) -> str: ...
    @property
    def creator_id(self) -> int: ...
    @property
    def creator(self) -> Optional[Member]: ...
    @property
    def trigger(self) -> AutoModTrigger: ...
    @property
    def actions(self) -> List[AutoModAction]: ...
    @property
    def enabled(self) -> bool: ...
    @property
    def exempt_roles(self) -> List[Role]: ...
    @property
    def exempt_channels(self) -> List[GuildChannel]: ...
    
    async def edit(
        self,
        *,
        name: str = None,
        trigger: AutoModTrigger = None,
        actions: List[AutoModAction] = None,
        enabled: bool = None,
        exempt_roles: List[Snowflake] = None,
        exempt_channels: List[Snowflake] = None,
        **kwargs
    ) -> AutoModRule:
        """Edit the auto-mod rule."""
    
    async def delete(self) -> None:
        """Delete the auto-mod rule."""

class AutoModAction:
    """
    Represents an auto-moderation action.
    """
    
    @property
    def type(self) -> AutoModActionType: ...
    @property
    def metadata(self) -> Optional[AutoModActionMetadata]: ...

Application Information and Teams

Bot application information and developer team management.

class AppInfo:
    """
    Represents Discord application information.
    """
    
    @property
    def id(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def icon(self) -> Optional[Asset]: ...
    @property
    def description(self) -> str: ...
    @property
    def rpc_origins(self) -> List[str]: ...
    @property
    def bot_public(self) -> bool: ...
    @property
    def bot_require_code_grant(self) -> bool: ...
    @property
    def owner(self) -> Optional[User]: ...
    @property
    def team(self) -> Optional[Team]: ...
    @property
    def verify_key(self) -> str: ...
    @property
    def guild_id(self) -> Optional[int]: ...
    @property
    def guild(self) -> Optional[Guild]: ...
    @property
    def primary_sku_id(self) -> Optional[int]: ...
    @property
    def slug(self) -> Optional[str]: ...
    @property
    def cover_image(self) -> Optional[Asset]: ...
    @property
    def flags(self) -> ApplicationFlags: ...

class Team:
    """
    Represents a Discord developer team.
    """
    
    @property
    def id(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def icon(self) -> Optional[Asset]: ...
    @property
    def owner_id(self) -> int: ...
    @property
    def owner(self) -> Optional[TeamMember]: ...
    @property
    def members(self) -> List[TeamMember]: ...

class TeamMember:
    """
    Represents a member of a developer team.
    """
    
    @property
    def membership_state(self) -> TeamMembershipState: ...
    @property
    def permissions(self) -> List[str]: ...
    @property
    def team_id(self) -> int: ...
    @property
    def user(self) -> User: ...

Monetization and SKUs

Discord's monetization features for premium applications.

class SKU:
    """
    Represents a Stock Keeping Unit (purchasable product).
    """
    
    @property
    def id(self) -> int: ...
    @property
    def type(self) -> SKUType: ...
    @property
    def application_id(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def slug(self) -> str: ...
    @property
    def flags(self) -> SKUFlags: ...

class Entitlement:
    """
    Represents a user's entitlement to a product.
    """
    
    @property
    def id(self) -> int: ...
    @property
    def sku_id(self) -> int: ...
    @property
    def application_id(self) -> int: ...
    @property
    def user_id(self) -> Optional[int]: ...
    @property
    def user(self) -> Optional[User]: ...
    @property
    def guild_id(self) -> Optional[int]: ...
    @property
    def guild(self) -> Optional[Guild]: ...
    @property
    def type(self) -> EntitlementType: ...
    @property
    def deleted(self) -> bool: ...
    @property
    def starts_at(self) -> Optional[datetime]: ...
    @property
    def ends_at(self) -> Optional[datetime]: ...

These Discord objects form the core data model for interacting with Discord's API, providing comprehensive access to all aspects of Discord servers, channels, messages, users, and their relationships.

Install with Tessl CLI

npx tessl i tessl/pypi-py-cord

docs

commands-interactions.md

core-clients.md

discord-objects.md

error-handling.md

extensions.md

index.md

ui-components.md

utilities-helpers.md

tile.json