跳转至

格式化、颜色、CDN 等

bostie.fmt

TimestampStyle

TimestampStyle = Literal['t', 'T', 'd', 'D', 'f', 'F', 's', 'S', 'R']

GuildNavigation

GuildNavigation = Literal['customize', 'browse', 'guide', 'linked-roles']

timestamp

timestamp(when: datetime | float, style: TimestampStyle | None = None) -> str

A time each reader sees in their own time zone and language.

user

user(user_id: int) -> str

channel

channel(channel_id: int) -> str

role

role(role_id: int) -> str

game_profile

game_profile(game_id: int) -> str

command

command(name: str, command_id: int) -> str

A clickable slash command; name may hold a group and subcommand.

emoji

emoji(name: str, emoji_id: int, *, animated: bool = False) -> str

guild_navigation

guild_navigation(kind: GuildNavigation, role_id: int | None = None) -> str

A link to a tab of the server; role_id opens one linked role.

store

store(application_id: int, sku_id: int | None = None) -> str

A link to the app's store page, or one SKU; chat shows it as a card.

escape_markdown

escape_markdown(text: str) -> str

The text shown as typed, with links left working.

remove_markdown

remove_markdown(text: str) -> str

The text without markdown, with links left working.

escape_mentions

escape_mentions(text: str) -> str

The text with @everyone, @here and user and role mentions that cannot ping.

mentioned_users

mentioned_users(text: str) -> list[int]

mentioned_roles

mentioned_roles(text: str) -> list[int]

mentioned_channels

mentioned_channels(text: str) -> list[int]

bostie.color

BLURPLE module-attribute

BLURPLE = 5793266

GREEN module-attribute

GREEN = 5763719

YELLOW module-attribute

YELLOW = 16705372

FUCHSIA module-attribute

FUCHSIA = 15418782

RED module-attribute

RED = 15548997

rgb

rgb(red: int, green: int, blue: int) -> int

A color from red, green and blue, each from 0 to 255.

hsv

hsv(hue: float, saturation: float, value: float) -> int

A color from hue, saturation and value, each from 0 to 1.

parse

parse(text: str) -> int

A color from hex such as "#5865F2" or "0x5865F2".

bostie.cdn

ImageFormat

ImageFormat = Literal['png', 'jpg', 'jpeg', 'webp', 'gif']

emoji

emoji(emoji_id: int, *, animated: bool = False, size: int | None = None, format: ImageFormat = 'webp') -> str

guild_icon

guild_icon(guild_id: int, icon: str, *, size: int | None = None, format: ImageFormat = 'webp') -> str

guild_splash

guild_splash(guild_id: int, splash: str, *, size: int | None = None, format: ImageFormat = 'webp') -> str

guild_discovery_splash

guild_discovery_splash(guild_id: int, splash: str, *, size: int | None = None, format: ImageFormat = 'webp') -> str

guild_banner

guild_banner(guild_id: int, banner: str, *, size: int | None = None, format: ImageFormat = 'webp') -> str

user_banner

user_banner(user_id: int, banner: str, *, size: int | None = None, format: ImageFormat = 'webp') -> str

default_avatar

default_avatar(user_id: int, discriminator: str = '0') -> str

The avatar of a user who has not set one; bots pass their discriminator.

user_avatar

user_avatar(user_id: int, avatar: str, *, size: int | None = None, format: ImageFormat = 'webp') -> str

display_avatar

display_avatar(user: PartialUser, *, size: int | None = None, format: ImageFormat = 'webp') -> str

The user's avatar, or the default one when they have not set any.

member_avatar

member_avatar(guild_id: int, user_id: int, avatar: str, *, size: int | None = None, format: ImageFormat = 'webp') -> str

member_banner

member_banner(guild_id: int, user_id: int, banner: str, *, size: int | None = None, format: ImageFormat = 'webp') -> str

avatar_decoration

avatar_decoration(asset: str, *, size: int | None = None) -> str

application_icon

application_icon(application_id: int, icon: str, *, size: int | None = None, format: ImageFormat = 'webp') -> str

application_cover

application_cover(application_id: int, cover_image: str, *, size: int | None = None, format: ImageFormat = 'webp') -> str

application_asset

application_asset(application_id: int, asset_id: str, *, size: int | None = None, format: ImageFormat = 'webp') -> str

store_page_asset

store_page_asset(application_id: int, asset_id: int, *, size: int | None = None, format: ImageFormat = 'webp') -> str

sticker_pack_banner

sticker_pack_banner(banner_asset_id: int, *, size: int | None = None, format: ImageFormat = 'webp') -> str

team_icon

team_icon(team_id: int, icon: str, *, size: int | None = None, format: ImageFormat = 'webp') -> str

sticker

sticker(sticker_id: int, format_type: StickerFormatType) -> str

A PNG, Lottie JSON or GIF, as the sticker's format type says.

role_icon

role_icon(role_id: int, icon: str, *, size: int | None = None, format: ImageFormat = 'webp') -> str

scheduled_event_cover

scheduled_event_cover(event_id: int, image: str, *, size: int | None = None, format: ImageFormat = 'webp') -> str

guild_tag_badge

guild_tag_badge(guild_id: int, badge: str, *, size: int | None = None, format: ImageFormat = 'webp') -> str

soundboard_sound

soundboard_sound(sound_id: int) -> str

bostie.activity

ActivityDict

Bases: TypedDict

name instance-attribute

name: str

type instance-attribute

state instance-attribute

state: NotRequired[str]

url instance-attribute

playing

playing(name: str, *, state: str | None = None) -> ActivityDict

streaming

streaming(name: str, url: str, *, state: str | None = None) -> ActivityDict

A stream on url; Discord accepts only Twitch and YouTube URLs.

listening

listening(name: str, *, state: str | None = None) -> ActivityDict

watching

watching(name: str, *, state: str | None = None) -> ActivityDict

competing

competing(name: str, *, state: str | None = None) -> ActivityDict

custom

custom(state: str) -> ActivityDict

A custom status that shows state as its text.

bostie.oauth2

authorize_url

authorize_url(client_id: int, *, scopes: Iterable[OAuth2Scope | str], redirect_uri: str | None = None, state: str | None = None, prompt: Literal['consent', 'none'] | None = None, integration_type: ApplicationIntegrationType | None = None, code_challenge: str | None = None) -> str

The code grant URL for scopes; code_challenge is an S256 PKCE challenge.

invite_url

invite_url(client_id: int, *, permissions: Permissions | None = None, scopes: Iterable[OAuth2Scope | str] | None = None, integration_type: ApplicationIntegrationType | None = None, guild_id: int | None = None, disable_guild_select: bool | None = None) -> str

The URL that installs the app; its Developer Portal settings fill in the rest.

bostie.permissions

ALL module-attribute

NONE module-attribute

NONE = Permissions(0)

TIMED_OUT module-attribute

AnyMember

AnyMember = Member | ResolvedMember

compute_permissions

compute_permissions(guild: Guild, member: AnyMember, channel: Channel | None = None, *, parent: Channel | None = None) -> Permissions

The member's permissions guild-wide, or in channel; a thread needs parent.

top_role

top_role(guild: Guild, member: AnyMember) -> Role | None

The member's highest role, or None when it has only @everyone.

display_colors

display_colors(guild: Guild, member: AnyMember) -> RoleColors | None

The colors of the member's highest colored role, which its name shows.

can_act_on

can_act_on(guild: Guild, actor: AnyMember, target: AnyMember | Role) -> bool

Whether actor outranks a member or a role: the owner all, nobody the owner.

bostie.snowflake

snowflake_time

snowflake_time(snowflake: int) -> datetime

When the object with this id was created, in UTC.

time_snowflake

time_snowflake(when: datetime, *, high: bool = False) -> int

The lowest id made at when, or with high the highest; naive is local time.

shard_of

shard_of(guild_id: int, shard_count: int) -> int

The shard, out of shard_count, that Discord sends a guild's events to.