tessl install tessl/pypi-py-cord@2.6.0A modern, async-ready Python API wrapper for Discord with comprehensive bot development features
Agent Success
Agent success rate when using this tile
93%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.11x
Baseline
Agent success rate without this tile
84%
Build a utility module for a Discord bot that provides helper functions for common operations involving Discord IDs, timestamps, and user mentions.
Extract timestamp information from Discord snowflake IDs.
175928847299117063, return a datetime object representing 2016-04-30 11:18:25.796 UTC @test1234567890123456789, correctly extract and return its creation timestamp as a datetime @testClean user input to prevent markdown injection and unintended mentions.
**Hello** _world_, return \\*\\*Hello\\*\\* \\_world\\_ (escaped markdown) @test@everyone look at this!, return text that won't trigger the everyone mention @testFormat datetime objects as Discord timestamps with different display styles.
2024-01-15 10:30:00 UTC with short time style, return <t:1705314600:t> @test2024-01-15 10:30:00 UTC with relative style, return <t:1705314600:R> @testImplement efficient resource fetching that checks cache before making API calls.
@generates
from datetime import datetime
from typing import Optional
import discord
def extract_id_timestamp(snowflake_id: int) -> datetime:
"""
Convert a Discord snowflake ID to a datetime object.
Args:
snowflake_id: The Discord snowflake ID
Returns:
A datetime object representing when the ID was created
"""
pass
def sanitize_markdown(text: str) -> str:
"""
Escape markdown formatting characters in text.
Args:
text: The text to escape
Returns:
Text with markdown characters escaped
"""
pass
def sanitize_mentions(text: str) -> str:
"""
Escape user, role, and everyone/here mentions in text.
Args:
text: The text to escape
Returns:
Text with mentions escaped to prevent pinging
"""
pass
def create_discord_timestamp(dt: datetime, style: str = "f") -> str:
"""
Format a datetime as a Discord timestamp string.
Args:
dt: The datetime to format
style: Display style - 't' (short time), 'T' (long time),
'd' (short date), 'D' (long date),
'f' (short datetime), 'F' (long datetime),
'R' (relative)
Returns:
Discord timestamp string like <t:1234567890:R>
"""
pass
async def fetch_user_smart(bot: discord.Bot, user_id: int) -> Optional[discord.User]:
"""
Get a user from cache or fetch from API if not cached.
Args:
bot: The Discord bot instance
user_id: The user ID to fetch
Returns:
The User object, or None if not found
"""
passProvides Discord API wrapper functionality for bot operations and utility functions.
@satisfied-by