emoji_manager ¶
Emoji Manager Service for Tux Bot.
This module provides comprehensive emoji management functionality for the Tux Discord bot, including creating, updating, and managing custom emojis across guilds. It supports bulk operations, file-based emoji storage, and automatic cleanup.
Classes:
-
EmojiManager–Manages application emojis, caching, and synchronization from local files.
Classes¶
EmojiManager ¶
Manages application emojis, caching, and synchronization from local files.
Initialize the EmojiManager.
Parameters:
-
bot(Bot) –The discord bot instance.
-
emojis_path(Optional[Path], default:None) –Path to the directory containing local emoji files. Defaults to DEFAULT_EMOJI_ASSETS_PATH.
-
create_delay(Optional[float], default:None) –Delay in seconds before creating an emoji to mitigate rate limits. Defaults to DEFAULT_EMOJI_CREATE_DELAY.
Methods:
-
init–Initialize the emoji cache by fetching application emojis.
-
get–Retrieve an emoji from the cache.
-
sync_emojis–Synchronize emojis from the local assets directory to the application.
-
resync_emoji–Resync a specific emoji: Deletes existing, finds local file, creates new.
-
delete_all_emojis–Delete all application emojis that match names from the emoji assets directory.
Functions¶
init async ¶
init() -> bool
Initialize the emoji cache by fetching application emojis.
Ensures the cache reflects the current state of application emojis on Discord. This method is locked to prevent concurrent initialization attempts.
Returns:
-
bool–True if initialization was successful or already done, False otherwise.
get ¶
_create_discord_emoji async ¶
_process_emoji_file async ¶
sync_emojis async ¶
Synchronize emojis from the local assets directory to the application.
Ensures the cache is initialized, then iterates through local emoji files. If an emoji with the same name doesn't exist in the cache, it attempts to create it.
Returns:
_ensure_initialized async ¶
_ensure_initialized() -> bool
Check if cache is initialized, logs warning if not.
Returns:
-
bool–True if initialized, False otherwise.
_delete_discord_emoji async ¶
resync_emoji async ¶
delete_all_emojis async ¶
Delete all application emojis that match names from the emoji assets directory.
This method: 1. Ensures the emoji cache is initialized 2. Finds all potential emoji names from the assets directory 3. Deletes any matching emojis from Discord and updates the cache
Returns:
Functions¶
_is_valid_emoji_name ¶
Check if an emoji name meets basic validity criteria.
Returns:
-
bool–True if the name is valid, False otherwise.