utils¶
Utilities to be used by the other modules.
Byte utilities.
- src.byte.lib.utils.is_byte_dev() Check[Any] [source]¶
Check if the user is a Byte developer.
- Returns:
A check function.
- src.byte.lib.utils.linker(title: str, link: str, show_embed: bool = False) str [source]¶
Create a Markdown link, optionally with an embed.
- Parameters:
title – The title of the link.
link – The URL of the link.
show_embed – Whether to show the embed or not.
- Returns:
A Markdown link.
- src.byte.lib.utils.mention_user(user_id: int) str [source]¶
Mention a user by ID.
- Parameters:
user_id – The unique identifier for the user.
- Returns:
A formatted string that mentions the user.
- src.byte.lib.utils.mention_user_nickname(user_id: int) str [source]¶
Mention a user by ID with a nickname.
- Parameters:
user_id – The unique identifier for the user.
- Returns:
A formatted string that mentions the user with a nickname.
- src.byte.lib.utils.mention_channel(channel_id: int) str [source]¶
Mention a channel by ID.
- Parameters:
channel_id – The unique identifier for the channel.
- Returns:
A formatted string that mentions the channel.
- src.byte.lib.utils.mention_role(role_id: int) str [source]¶
Mention a role by ID.
- Parameters:
role_id – The unique identifier for the role.
- Returns:
A formatted string that mentions the role.
- src.byte.lib.utils.mention_slash_command(name: str, command_id: int) str [source]¶
Mention a slash command by name and ID.
- Parameters:
name – The name of the slash command.
command_id – The unique identifier for the slash command.
- Returns:
A formatted string that mentions the slash command.
- src.byte.lib.utils.mention_custom_emoji(name: str, emoji_id: int) str [source]¶
Mention a custom emoji by name and ID.
- Parameters:
name – The name of the emoji.
emoji_id – The unique identifier for the emoji.
- Returns:
A formatted string that mentions the custom emoji.
- src.byte.lib.utils.mention_custom_emoji_animated(name: str, emoji_id: int) str [source]¶
Mention an animated custom emoji by name and ID.
- Parameters:
name – The name of the animated emoji.
emoji_id – The unique identifier for the animated emoji.
- Returns:
A formatted string that mentions the animated custom emoji.
- src.byte.lib.utils.mention_timestamp(timestamp: int, style: str = '') str [source]¶
Mention a timestamp, optionally with a style.
- Parameters:
timestamp – The Unix timestamp to format.
style – An optional string representing the timestamp style. (Default ``
, valid styles: ``t
,T
,d
,D
,f
,F
,R
)
- Returns:
A formatted string that represents the timestamp.
Mention a guild navigation element by type and ID.
- Parameters:
guild_nav_type – The type of the guild navigation element.
guild_element_id – The unique identifier for the element.
- Returns:
A formatted string that mentions the guild navigation element.
- src.byte.lib.utils.format_ruff_rule(rule_data: RuffRule) FormattedRuffRule [source]¶
Format ruff rule data for embed-friendly output and append rule link.
- Parameters:
rule_data – The ruff rule data.
- Returns:
The formatted rule data.
- Return type:
- async src.byte.lib.utils.query_all_ruff_rules() list[RuffRule] [source]¶
Query all Ruff linting rules.
- src.byte.lib.utils.run_ruff_format(code: str) str [source]¶
Formats code using Ruff.
- Parameters:
code – The code to format.
- Returns:
The formatted code.
- Return type:
- async src.byte.lib.utils.paste(code: str) str [source]¶
Uploads the given code to paste.pythondiscord.com.
- Parameters:
code – The formatted code to upload.
- Returns:
The URL of the uploaded paste.
- Return type: