A modern, async-ready Python API wrapper for Discord with comprehensive bot development features
Overall
score
93%
Utility functions, enumerations, flags, audio support, color handling, and various helper functions for Discord bot development. These utilities provide essential tools and constants for working with Discord's API and building robust applications.
Helper functions for common Discord operations, time handling, search operations, and text processing.
# Search and Retrieval Functions
def find(predicate: Callable[[Any], bool], iterable: Iterable[Any]) -> Optional[Any]:
"""
Find the first item in an iterable that matches the predicate.
Parameters:
- predicate: Callable - Function that returns True for the desired item
- iterable: Iterable - Collection to search
Returns:
Optional[Any] - First matching item or None
"""
def get(iterable: Iterable[Any], **attrs) -> Optional[Any]:
"""
Get an item from an iterable by attribute values.
Parameters:
- iterable: Iterable - Collection to search
**attrs: Attribute name-value pairs to match
Returns:
Optional[Any] - First matching item or None
Example:
member = discord.utils.get(guild.members, name='Foo')
channel = discord.utils.get(guild.channels, name='general', type=ChannelType.text)
"""
async def get_or_fetch(
guild: Guild,
attribute: str,
id: int,
*,
default: Any = None
) -> Any:
"""
Get an object from cache or fetch from API if not found.
Parameters:
- guild: Guild - Guild to search in
- attribute: str - Attribute name ('members', 'channels', etc.)
- id: int - Object ID to find
- default: Any - Default value if not found
"""
# Time and Snowflake Functions
def snowflake_time(id: int) -> datetime:
"""
Get the creation time of a Discord snowflake ID.
Parameters:
- id: int - Discord snowflake ID
Returns:
datetime - When the snowflake was created
"""
def time_snowflake(dt: datetime, *, high: bool = False) -> int:
"""
Generate a snowflake ID for a given datetime.
Parameters:
- dt: datetime - Timestamp to convert
- high: bool - Whether to use high or low end of millisecond
Returns:
int - Generated snowflake ID
"""
def generate_snowflake() -> int:
"""
Generate a unique Discord snowflake ID.
Returns:
int - New snowflake ID
"""
def parse_time(timestamp: str) -> Optional[datetime]:
"""
Parse an ISO 8601 timestamp string.
Parameters:
- timestamp: str - ISO timestamp string
Returns:
Optional[datetime] - Parsed datetime or None if invalid
"""
def utcnow() -> datetime:
"""
Get the current UTC time.
Returns:
datetime - Current UTC time
"""
async def sleep_until(when: datetime, result: Any = None) -> Any:
"""
Sleep until a specific datetime.
Parameters:
- when: datetime - Time to sleep until
- result: Any - Value to return after sleeping
Returns:
Any - The result parameter
"""
def format_dt(dt: datetime, /, style: str = None) -> str:
"""
Format a datetime for Discord's timestamp formatting.
Parameters:
- dt: datetime - Datetime to format
- style: str - Format style ('f', 'F', 'd', 'D', 't', 'T', 'R')
Returns:
str - Discord timestamp string
Styles:
- 'f': Short date/time (default)
- 'F': Long date/time
- 'd': Short date
- 'D': Long date
- 't': Short time
- 'T': Long time
- 'R': Relative time
"""
# Text Processing Functions
def remove_markdown(text: str, *, ignore_links: bool = True) -> str:
"""
Remove Discord markdown formatting from text.
Parameters:
- text: str - Text with markdown
- ignore_links: bool - Whether to ignore link formatting
Returns:
str - Text with markdown removed
"""
def escape_markdown(
text: str,
*,
as_needed: bool = False,
ignore_links: bool = True
) -> str:
"""
Escape Discord markdown characters in text.
Parameters:
- text: str - Text to escape
- as_needed: bool - Only escape characters that would cause formatting
- ignore_links: bool - Don't escape characters in links
Returns:
str - Text with markdown characters escaped
"""
def escape_mentions(text: str) -> str:
"""
Escape Discord mentions in text.
Parameters:
- text: str - Text with mentions
Returns:
str - Text with mentions escaped
"""
# Mention Extraction Functions
def raw_mentions(text: str) -> List[str]:
"""
Extract raw user mentions from text.
Parameters:
- text: str - Text containing mentions
Returns:
List[str] - List of mention strings
"""
def raw_channel_mentions(text: str) -> List[str]:
"""
Extract raw channel mentions from text.
Parameters:
- text: str - Text containing channel mentions
Returns:
List[str] - List of channel mention strings
"""
def raw_role_mentions(text: str) -> List[str]:
"""
Extract raw role mentions from text.
Parameters:
- text: str - Text containing role mentions
Returns:
List[str] - List of role mention strings
"""
# URL Generation Functions
def oauth_url(
client_id: int,
*,
permissions: Permissions = None,
guild: Snowflake = None,
redirect_uri: str = None,
scopes: Iterable[str] = None,
disable_guild_select: bool = False,
state: str = None
) -> str:
"""
Generate an OAuth2 authorization URL for a bot.
Parameters:
- client_id: int - Bot's client ID
- permissions: Permissions - Permissions to request
- guild: Snowflake - Pre-select a guild
- redirect_uri: str - Redirect URI after authorization
- scopes: Iterable[str] - OAuth2 scopes to request
- disable_guild_select: bool - Disable guild selection
- state: str - State parameter for security
Returns:
str - OAuth2 authorization URL
"""
def resolve_invite(invite: Union[Invite, str]) -> str:
"""
Resolve an invite to its full URL.
Parameters:
- invite: Union[Invite, str] - Invite object or code
Returns:
str - Full invite URL
"""
def resolve_template(code: str) -> str:
"""
Resolve a template code to its full URL.
Parameters:
- code: str - Template code
Returns:
str - Full template URL
"""
# General Utilities
def as_chunks(iterator: Iterable[Any], max_size: int) -> List[List[Any]]:
"""
Split an iterable into chunks of maximum size.
Parameters:
- iterator: Iterable - Collection to split
- max_size: int - Maximum size per chunk
Returns:
List[List[Any]] - List of chunks
"""
async def basic_autocomplete(
ctx: AutocompleteContext,
choices: List[str],
*,
current_input: str = None
) -> List[OptionChoice]:
"""
Basic autocomplete implementation for slash commands.
Parameters:
- ctx: AutocompleteContext - Autocomplete context
- choices: List[str] - Available choices
- current_input: str - Current user input (defaults to ctx.value)
Returns:
List[OptionChoice] - Filtered choices
"""
def filter_params(params: Dict[str, Any], **filters) -> Dict[str, Any]:
"""
Filter function parameters based on criteria.
Parameters:
- params: Dict - Parameters to filter
**filters: Filter criteria
Returns:
Dict[str, Any] - Filtered parameters
"""
# Deprecation Utilities
def warn_deprecated(
name: str,
instead: str = None,
*,
since: str = None,
removed: str = None
) -> None:
"""
Issue a deprecation warning.
Parameters:
- name: str - Name of deprecated feature
- instead: str - What to use instead
- since: str - Version when deprecation started
- removed: str - Version when feature will be removed
"""
def deprecated(instead: str = None) -> Callable:
"""
Decorator to mark functions as deprecated.
Parameters:
- instead: str - What to use instead
"""Color representation and manipulation for embeds and other visual elements.
class Colour:
"""
Represents a color with Discord color constants and utilities.
"""
def __init__(self, value: int) -> None:
"""
Create a color from an integer value.
Parameters:
- value: int - RGB color value (0x000000 to 0xFFFFFF)
"""
@classmethod
def from_rgb(cls, r: int, g: int, b: int) -> Colour:
"""
Create a color from RGB values.
Parameters:
- r: int - Red component (0-255)
- g: int - Green component (0-255)
- b: int - Blue component (0-255)
"""
@classmethod
def from_hsv(cls, h: float, s: float, v: float) -> Colour:
"""
Create a color from HSV values.
Parameters:
- h: float - Hue (0.0-1.0)
- s: float - Saturation (0.0-1.0)
- v: float - Value (0.0-1.0)
"""
@classmethod
def random(cls, *, seed: Union[int, str, float, bytes, bytearray] = None) -> Colour:
"""
Generate a random color.
Parameters:
- seed: Union[int, str, float, bytes, bytearray] - Random seed
"""
@property
def value(self) -> int:
"""The raw integer color value."""
@property
def r(self) -> int:
"""Red component (0-255)."""
@property
def g(self) -> int:
"""Green component (0-255)."""
@property
def b(self) -> int:
"""Blue component (0-255)."""
def to_rgb(self) -> Tuple[int, int, int]:
"""Get RGB tuple."""
def to_hsv(self) -> Tuple[float, float, float]:
"""Get HSV tuple."""
# Discord Brand Colors
@classmethod
def teal(cls) -> Colour: ...
@classmethod
def dark_teal(cls) -> Colour: ...
@classmethod
def brand_green(cls) -> Colour: ...
@classmethod
def green(cls) -> Colour: ...
@classmethod
def dark_green(cls) -> Colour: ...
@classmethod
def blue(cls) -> Colour: ...
@classmethod
def dark_blue(cls) -> Colour: ...
@classmethod
def purple(cls) -> Colour: ...
@classmethod
def dark_purple(cls) -> Colour: ...
@classmethod
def magenta(cls) -> Colour: ...
@classmethod
def dark_magenta(cls) -> Colour: ...
@classmethod
def gold(cls) -> Colour: ...
@classmethod
def dark_gold(cls) -> Colour: ...
@classmethod
def orange(cls) -> Colour: ...
@classmethod
def dark_orange(cls) -> Colour: ...
@classmethod
def brand_red(cls) -> Colour: ...
@classmethod
def red(cls) -> Colour: ...
@classmethod
def dark_red(cls) -> Colour: ...
@classmethod
def lighter_grey(cls) -> Colour: ...
@classmethod
def lighter_gray(cls) -> Colour: ...
@classmethod
def dark_grey(cls) -> Colour: ...
@classmethod
def dark_gray(cls) -> Colour: ...
@classmethod
def light_grey(cls) -> Colour: ...
@classmethod
def light_gray(cls) -> Colour: ...
@classmethod
def darker_grey(cls) -> Colour: ...
@classmethod
def darker_gray(cls) -> Colour: ...
@classmethod
def og_blurple(cls) -> Colour: ...
@classmethod
def blurple(cls) -> Colour: ...
@classmethod
def greyple(cls) -> Colour: ...
@classmethod
def grayple(cls) -> Colour: ...
@classmethod
def dark_theme(cls) -> Colour: ...
@classmethod
def fuchsia(cls) -> Colour: ...
@classmethod
def yellow(cls) -> Colour: ...
@classmethod
def nitro_pink(cls) -> Colour: ...
@classmethod
def hypesquad_bravery(cls) -> Colour: ...
@classmethod
def hypesquad_brilliance(cls) -> Colour: ...
@classmethod
def hypesquad_balance(cls) -> Colour: ...
class Color(Colour):
"""Alias for Colour using American spelling."""
passRich embed creation and manipulation for enhanced message formatting.
class Embed:
"""
Represents a Discord embed for rich message formatting.
"""
def __init__(
self,
*,
title: str = None,
description: str = None,
url: str = None,
timestamp: datetime = None,
color: Union[int, Colour] = None,
colour: Union[int, Colour] = None
) -> None:
"""
Create an embed.
Parameters:
- title: str - Embed title
- description: str - Embed description
- url: str - URL for title link
- timestamp: datetime - Embed timestamp
- color: Union[int, Colour] - Embed color
- colour: Union[int, Colour] - Embed colour (same as color)
"""
@classmethod
def from_dict(cls, data: Dict[str, Any]) -> Embed:
"""Create an embed from a dictionary."""
def to_dict(self) -> Dict[str, Any]:
"""Convert the embed to a dictionary."""
def copy(self) -> Embed:
"""Create a copy of the embed."""
@property
def title(self) -> Optional[str]: ...
@property
def description(self) -> Optional[str]: ...
@property
def url(self) -> Optional[str]: ...
@property
def timestamp(self) -> Optional[datetime]: ...
@property
def color(self) -> Optional[Colour]: ...
@property
def colour(self) -> Optional[Colour]: ...
@property
def footer(self) -> Optional[EmbedFooter]: ...
@property
def image(self) -> Optional[EmbedMedia]: ...
@property
def thumbnail(self) -> Optional[EmbedMedia]: ...
@property
def video(self) -> Optional[EmbedMedia]: ...
@property
def provider(self) -> Optional[EmbedProvider]: ...
@property
def author(self) -> Optional[EmbedAuthor]: ...
@property
def fields(self) -> List[EmbedField]: ...
def set_footer(
self,
*,
text: str = None,
icon_url: str = None
) -> Embed:
"""
Set the embed footer.
Parameters:
- text: str - Footer text
- icon_url: str - Footer icon URL
"""
def set_image(self, *, url: str) -> Embed:
"""
Set the embed image.
Parameters:
- url: str - Image URL
"""
def set_thumbnail(self, *, url: str) -> Embed:
"""
Set the embed thumbnail.
Parameters:
- url: str - Thumbnail URL
"""
def set_author(
self,
*,
name: str,
url: str = None,
icon_url: str = None
) -> Embed:
"""
Set the embed author.
Parameters:
- name: str - Author name
- url: str - Author URL
- icon_url: str - Author icon URL
"""
def add_field(
self,
*,
name: str,
value: str,
inline: bool = True
) -> Embed:
"""
Add a field to the embed.
Parameters:
- name: str - Field name
- value: str - Field value
- inline: bool - Whether the field is inline
"""
def insert_field_at(
self,
index: int,
*,
name: str,
value: str,
inline: bool = True
) -> Embed:
"""Insert a field at a specific position."""
def set_field_at(
self,
index: int,
*,
name: str,
value: str,
inline: bool = True
) -> Embed:
"""Set a field at a specific position."""
def remove_field(self, index: int) -> Embed:
"""Remove a field by index."""
def clear_fields(self) -> Embed:
"""Remove all fields from the embed."""
class EmbedField:
"""Represents an embed field."""
@property
def name(self) -> str: ...
@property
def value(self) -> str: ...
@property
def inline(self) -> bool: ...
class EmbedAuthor:
"""Represents embed author information."""
@property
def name(self) -> str: ...
@property
def url(self) -> Optional[str]: ...
@property
def icon_url(self) -> Optional[str]: ...
@property
def proxy_icon_url(self) -> Optional[str]: ...
class EmbedFooter:
"""Represents embed footer information."""
@property
def text(self) -> str: ...
@property
def icon_url(self) -> Optional[str]: ...
@property
def proxy_icon_url(self) -> Optional[str]: ...
class EmbedMedia:
"""Represents embed media (image, thumbnail, video)."""
@property
def url(self) -> str: ...
@property
def proxy_url(self) -> Optional[str]: ...
@property
def height(self) -> Optional[int]: ...
@property
def width(self) -> Optional[int]: ...
class EmbedProvider:
"""Represents embed provider information."""
@property
def name(self) -> Optional[str]: ...
@property
def url(self) -> Optional[str]: ...File attachment system for sending files with messages.
class File:
"""
Represents a file attachment for Discord messages.
"""
def __init__(
self,
fp: Union[str, bytes, os.PathLike, io.IOBase],
filename: str = None,
*,
description: str = None,
spoiler: bool = False
) -> None:
"""
Create a file attachment.
Parameters:
- fp: Union[str, bytes, PathLike, IOBase] - File path, bytes, or file-like object
- filename: str - Custom filename
- description: str - File description
- spoiler: bool - Whether the file is a spoiler
"""
@property
def filename(self) -> Optional[str]: ...
@property
def description(self) -> Optional[str]: ...
@property
def spoiler(self) -> bool: ...
@property
def fp(self) -> io.IOBase: ...
def reset(self, *, seek: Union[int, bool] = True) -> None:
"""Reset the file pointer."""
def close(self) -> None:
"""Close the file."""Asset handling for avatars, icons, and other Discord CDN resources.
class Asset:
"""
Represents a Discord CDN asset (avatar, icon, banner, etc.).
"""
@property
def url(self) -> str:
"""The asset's URL."""
@property
def key(self) -> str:
"""The asset's hash key."""
@property
def is_animated(self) -> bool:
"""Whether the asset is animated (GIF)."""
def replace(
self,
*,
size: int = None,
format: str = None,
static_format: str = None
) -> Asset:
"""
Create a new asset with different parameters.
Parameters:
- size: int - Image size (must be power of 2, 16-4096)
- format: str - Image format ('png', 'jpg', 'jpeg', 'webp', 'gif')
- static_format: str - Format for static version of animated assets
"""
def with_size(self, size: int) -> Asset:
"""Create asset with different size."""
def with_format(self, format: str) -> Asset:
"""Create asset with different format."""
def with_static_format(self, format: str) -> Asset:
"""Create asset with static format."""
async def save(
self,
fp: Union[str, bytes, os.PathLike, io.BufferedIOBase],
*,
seek_begin: bool = True
) -> int:
"""
Save the asset to a file.
Parameters:
- fp: Union[str, bytes, PathLike, BufferedIOBase] - File path or file object
- seek_begin: bool - Whether to seek to beginning of file
Returns:
int - Number of bytes written
"""
async def read(self) -> bytes:
"""
Read the asset data.
Returns:
bytes - Asset data
"""
async def to_file(
self,
*,
filename: str = None,
description: str = None,
spoiler: bool = False
) -> File:
"""
Convert the asset to a File object.
Parameters:
- filename: str - Custom filename
- description: str - File description
- spoiler: bool - Whether it's a spoiler
"""Important enumerations and constants used throughout py-cord.
class Status(Enum):
"""User online status."""
online = "online"
offline = "offline"
idle = "idle"
dnd = "dnd"
do_not_disturb = "dnd"
invisible = "invisible"
class ChannelType(Enum):
"""Discord channel types."""
text = 0
private = 1
voice = 2
group = 3
category = 4
news = 5
news_thread = 10
public_thread = 11
private_thread = 12
stage_voice = 13
forum = 15
class MessageType(Enum):
"""Discord message types."""
default = 0
recipient_add = 1
recipient_remove = 2
call = 3
channel_name_change = 4
channel_icon_change = 5
pins_add = 6
new_member = 7
premium_guild_subscription = 8
premium_guild_tier_1 = 9
premium_guild_tier_2 = 10
premium_guild_tier_3 = 11
channel_follow_add = 12
guild_discovery_disqualified = 14
guild_discovery_requalified = 15
guild_discovery_grace_period_initial_warning = 16
guild_discovery_grace_period_final_warning = 17
thread_created = 18
reply = 19
chat_input_command = 20
thread_starter_message = 21
guild_invite_reminder = 22
context_menu_command = 23
auto_moderation_action = 24
class ActivityType(Enum):
"""Activity types for user presence."""
unknown = -1
playing = 0
streaming = 1
listening = 2
watching = 3
custom = 4
competing = 5
class VerificationLevel(Enum):
"""Guild verification levels."""
none = 0
low = 1
medium = 2
high = 3
highest = 4
class ContentFilter(Enum):
"""Explicit content filter levels."""
disabled = 0
no_role = 1
all_members = 2
class NotificationLevel(Enum):
"""Default notification levels."""
all_messages = 0
only_mentions = 1
class NSFWLevel(Enum):
"""NSFW content levels."""
default = 0
explicit = 1
safe = 2
age_restricted = 3
class VideoQualityMode(Enum):
"""Voice channel video quality."""
auto = 1
full = 2
class WebhookType(Enum):
"""Webhook types."""
incoming = 1
channel_follower = 2
application = 3
class ExpireBehaviour(Enum):
"""Integration expire behavior."""
remove_role = 0
kick = 1
ExpireBehavior = ExpireBehaviour # American spelling alias
class StickerType(Enum):
"""Sticker types."""
standard = 1
guild = 2
class StickerFormatType(Enum):
"""Sticker format types."""
png = 1
apng = 2
lottie = 3
gif = 4
class InviteTarget(Enum):
"""Invite target types."""
unknown = 0
stream = 1
embedded_application = 2
class VoiceRegion(Enum):
"""Voice server regions."""
amsterdam = "amsterdam"
brazil = "brazil"
dubai = "dubai"
eu_central = "eu-central"
eu_west = "eu-west"
europe = "europe"
frankfurt = "frankfurt"
hongkong = "hongkong"
india = "india"
japan = "japan"
london = "london"
russia = "russia"
singapore = "singapore"
southafrica = "southafrica"
sydney = "sydney"
us_central = "us-central"
us_east = "us-east"
us_south = "us-south"
us_west = "us-west"
vip_amsterdam = "vip-amsterdam"
vip_us_east = "vip-us-east"
vip_us_west = "vip-us-west"Flag classes for representing Discord's bitfield flags.
class SystemChannelFlags:
"""System channel behavior flags."""
@property
def suppress_join_notifications(self) -> bool: ...
@property
def suppress_premium_subscriptions(self) -> bool: ...
@property
def suppress_guild_reminder_notifications(self) -> bool: ...
@property
def suppress_join_notification_replies(self) -> bool: ...
@property
def suppress_role_subscription_purchase_notifications(self) -> bool: ...
@property
def suppress_role_subscription_purchase_notification_replies(self) -> bool: ...
class MessageFlags:
"""Message feature flags."""
@property
def crossposted(self) -> bool: ...
@property
def is_crosspost(self) -> bool: ...
@property
def suppress_embeds(self) -> bool: ...
@property
def source_message_deleted(self) -> bool: ...
@property
def urgent(self) -> bool: ...
@property
def has_thread(self) -> bool: ...
@property
def ephemeral(self) -> bool: ...
@property
def loading(self) -> bool: ...
@property
def failed_to_mention_some_roles_in_thread(self) -> bool: ...
@property
def suppress_notifications(self) -> bool: ...
class PublicUserFlags:
"""Publicly visible user flags."""
@property
def staff(self) -> bool: ...
@property
def partner(self) -> bool: ...
@property
def hypesquad(self) -> bool: ...
@property
def bug_hunter(self) -> bool: ...
@property
def hypesquad_bravery(self) -> bool: ...
@property
def hypesquad_brilliance(self) -> bool: ...
@property
def hypesquad_balance(self) -> bool: ...
@property
def early_supporter(self) -> bool: ...
@property
def team_user(self) -> bool: ...
@property
def bug_hunter_level_2(self) -> bool: ...
@property
def verified_bot(self) -> bool: ...
@property
def verified_bot_developer(self) -> bool: ...
@property
def discord_certified_moderator(self) -> bool: ...
@property
def bot_http_interactions(self) -> bool: ...
@property
def spammer(self) -> bool: ...
@property
def active_developer(self) -> bool: ...
class ApplicationFlags:
"""Application feature flags."""
@property
def gateway_presence(self) -> bool: ...
@property
def gateway_presence_limited(self) -> bool: ...
@property
def gateway_guild_members(self) -> bool: ...
@property
def gateway_guild_members_limited(self) -> bool: ...
@property
def verification_pending_guild_limit(self) -> bool: ...
@property
def embedded(self) -> bool: ...
@property
def gateway_message_content(self) -> bool: ...
@property
def gateway_message_content_limited(self) -> bool: ...
@property
def application_command_badge(self) -> bool: ...
class ChannelFlags:
"""Channel feature flags."""
@property
def pinned(self) -> bool: ...
@property
def require_tag(self) -> bool: ...
class AttachmentFlags:
"""File attachment flags."""
@property
def is_remix(self) -> bool: ...
class RoleFlags:
"""Role feature flags."""
@property
def in_prompt(self) -> bool: ...
class SKUFlags:
"""SKU feature flags."""
@property
def available(self) -> bool: ...
@property
def guild_subscription(self) -> bool: ...
@property
def user_subscription(self) -> bool: ...
class MemberFlags:
"""Guild member flags."""
@property
def did_rejoin(self) -> bool: ...
@property
def completed_onboarding(self) -> bool: ...
@property
def bypasses_verification(self) -> bool: ...
@property
def started_onboarding(self) -> bool: ...Audio-related utilities and voice connection support.
# Basic Audio Support
class AudioSource:
"""Base class for audio sources."""
def read(self) -> bytes:
"""Read 20ms of audio data."""
def is_opus(self) -> bool:
"""Whether the source provides Opus data."""
def cleanup(self) -> None:
"""Clean up the audio source."""
class PCMAudio(AudioSource):
"""Raw PCM audio source."""
def __init__(self, stream: io.IOBase) -> None: ...
class FFmpegAudio(AudioSource):
"""Audio processed through FFmpeg."""
def __init__(self, source: str, **kwargs) -> None: ...
class FFmpegPCMAudio(AudioSource):
"""PCM audio processed through FFmpeg."""
def __init__(self, source: str, **kwargs) -> None: ...
class FFmpegOpusAudio(AudioSource):
"""Opus audio processed through FFmpeg."""
def __init__(self, source: str, **kwargs) -> None: ...
class PCMVolumeTransformer(AudioSource):
"""Volume control for PCM audio."""
def __init__(self, original: AudioSource, volume: float = 1.0) -> None: ...
@property
def volume(self) -> float: ...
@volume.setter
def volume(self, value: float) -> None: ...
# Voice Client Support
class VoiceClient:
"""Voice connection client."""
@property
def latency(self) -> float: ...
@property
def average_latency(self) -> float: ...
def is_connected(self) -> bool: ...
def is_playing(self) -> bool: ...
def is_paused(self) -> bool: ...
def play(self, source: AudioSource, *, after: Callable = None) -> None: ...
def pause(self) -> None: ...
def resume(self) -> None: ...
def stop(self) -> None: ...
async def disconnect(self, *, force: bool = False) -> None: ...
async def move_to(self, channel: VoiceChannel) -> None: ...
class VoiceProtocol:
"""Base voice protocol class."""
passUtility context managers for common operations.
class Typing:
"""
Context manager for showing typing indicator.
"""
def __init__(self, messageable: Messageable) -> None: ...
async def __aenter__(self) -> Typing: ...
async def __aexit__(self, exc_type, exc_val, exc_tb) -> None: ...
def __enter__(self) -> Typing: ...
def __exit__(self, exc_type, exc_val, exc_tb) -> None: ...
# Generic Discord Object
class Object:
"""
Generic Discord object with just an ID.
Useful for operations that only need an ID.
"""
def __init__(self, id: int) -> None: ...
@property
def id(self) -> int: ...
@property
def created_at(self) -> datetime: ...Control which mentions are allowed in messages.
class AllowedMentions:
"""
Controls which mentions are processed in messages.
"""
def __init__(
self,
*,
everyone: bool = None,
users: Union[bool, List[Snowflake]] = None,
roles: Union[bool, List[Snowflake]] = None,
replied_user: bool = None
) -> None:
"""
Create allowed mentions configuration.
Parameters:
- everyone: bool - Whether to allow @everyone/@here mentions
- users: Union[bool, List[Snowflake]] - User mention settings
- roles: Union[bool, List[Snowflake]] - Role mention settings
- replied_user: bool - Whether to mention the replied-to user
"""
@classmethod
def all(cls) -> AllowedMentions:
"""Allow all mentions."""
@classmethod
def none(cls) -> AllowedMentions:
"""Allow no mentions."""
@property
def everyone(self) -> bool: ...
@property
def users(self) -> Union[bool, List[Snowflake]]: ...
@property
def roles(self) -> Union[bool, List[Snowflake]]: ...
@property
def replied_user(self) -> bool: ...The utilities and helpers provide essential tools, constants, and helper functions that make Discord bot development more efficient and provide access to Discord's rich feature set including colors, embeds, file handling, audio support, and comprehensive utility functions for common operations.
Install with Tessl CLI
npx tessl i tessl/pypi-py-corddocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10