Attachment
Function
Attachment option. file_types filters on Discord's side, allowed_extensions and max_size on the bot's side.
from discord_interactions import AttachmentSignature
def Attachment( name: str, description: str, *, required: bool = True, allowed_extensions: List[str] | None = None, max_size: int | None = None, file_types: List[str] | None = None, localizations: Dict[str, Tuple[str, str]] | None = None,) -> AttachmentOptionParameters
| Name | Type | Default | Description |
|---|---|---|---|
name | str | required | |
description | str | required | |
required | bool | True | |
allowed_extensions | List[str] | None | None | Accepted extensions, checked by the bot. |
max_size | int | None | None | Maximum size in bytes. |
file_types | List[str] | None | None | Types offered by Discord: "image", "video", "audio" or extensions. |
localizations | Dict[str, Tuple[str, str]] | None | None |
Returns
AttachmentOption
Example
from discord_interactions.slash import Attachment, option @slash.command(description="Analyser une image")@option(Attachment("image", "Image", file_types=["image"], max_size=8_000_000))async def analyser(ctx, image): await ctx.respond(f"{image.filename} : {image.width}×{image.height}")