starboard ¶
Starboard message highlighting controller.
This controller manages starboard functionality for Discord guilds, allowing popular messages to be automatically posted to designated starboard channels based on reaction thresholds and user preferences.
Classes:
-
StarboardController–Clean Starboard controller using the new BaseController pattern.
-
StarboardMessageController–Clean StarboardMessage controller using the new BaseController pattern.
Classes¶
StarboardController ¶
StarboardController(db: DatabaseService | None = None)
Bases: BaseController[Starboard]
Clean Starboard controller using the new BaseController pattern.
Initialize the starboard controller.
Parameters:
-
db(DatabaseService | None, default:None) –The database service instance. If None, uses the default service.
Methods:
-
get_starboard_by_guild–Get starboard configuration for a guild.
-
get_or_create_starboard–Get starboard configuration, or create it with defaults if it doesn't exist.
-
update_starboard–Update starboard configuration.
-
delete_starboard–Delete starboard configuration for a guild.
-
get_all_starboards–Get all starboard configurations.
-
get_starboard_count–Get the total number of starboard configurations.
-
create_or_update_starboard–Create or update starboard configuration for a guild.
-
delete_starboard_by_guild_id–Delete starboard configuration for a guild.
-
get_starboard_by_guild_id–Get starboard configuration by guild ID - alias for get_starboard_by_guild.
-
create–Create a new record.
-
get_by_id–Get a record by ID.
-
update_by_id–Update a record by ID.
-
delete_by_id–Delete a record by ID.
-
exists–Check if a record exists.
-
find_one–Find one record.
-
find_all–Find all records with performance optimizations.
-
find_all_with_options–Find all records with relationship loading options.
-
count–Count records.
-
get_all–Get all records (alias for find_all without pagination).
-
execute_query–Execute a custom query.
-
find_with_json_query–Find records using JSON column queries.
-
find_with_array_contains–Find records where array column contains value.
-
find_with_full_text_search–Find records using full-text search.
-
paginate–Paginate records with metadata.
-
find_paginated–Find paginated records with relationship loading.
-
bulk_create–Create multiple records in bulk.
-
bulk_update–Update multiple records in bulk.
-
bulk_delete–Delete multiple records in bulk.
-
update_where–Update records matching filters.
-
delete_where–Delete records matching filters.
-
bulk_upsert_with_conflict_resolution–Bulk upsert with conflict resolution.
-
with_session–Execute operation within a session context.
-
with_transaction–Execute operation within a transaction context.
-
execute_transaction–Execute a callback within a transaction.
-
get_table_statistics–Get comprehensive table statistics.
-
explain_query_performance–Explain query performance with optional analysis.
-
upsert_by_field–Upsert a record by a specific field.
-
upsert_by_id–Upsert a record by ID.
-
get_or_create_by_field–Get existing record or create new one by field.
-
get_or_create–Get existing record or create new one.
-
upsert–Upsert a record.
Attributes:
-
db_service(DatabaseService) –Database service property for test compatibility.
-
model_class(type[ModelT]) –Model class property for test compatibility.
Attributes¶
db_service property ¶
db_service: DatabaseService
Database service property for test compatibility.
Returns:
-
DatabaseService–The database service instance.
Functions¶
get_starboard_by_guild async ¶
Get starboard configuration for a guild.
Returns:
-
Starboard | None–The starboard configuration if found, None otherwise.
get_or_create_starboard async ¶
Get starboard configuration, or create it with defaults if it doesn't exist.
Returns:
-
Starboard–The starboard configuration (existing or newly created).
update_starboard async ¶
Update starboard configuration.
Returns:
-
Starboard | None–The updated starboard configuration, or None if not found.
delete_starboard async ¶
Delete starboard configuration for a guild.
Returns:
-
bool–True if deleted successfully, False otherwise.
get_all_starboards async ¶
_get_pagination ¶
_get_pagination() -> PaginationController[ModelT]
Get or create pagination controller.
Returns:
-
PaginationController[ModelT]–The pagination controller instance.
get_starboard_count async ¶
get_starboard_count() -> int
Get the total number of starboard configurations.
Returns:
-
int–The total count of starboard configurations.
_get_bulk ¶
_get_bulk() -> BulkOperationsController[ModelT]
Get or create bulk operations controller.
Returns:
-
BulkOperationsController[ModelT]–The bulk operations controller instance.
create_or_update_starboard async ¶
Create or update starboard configuration for a guild.
Returns:
-
Starboard–The starboard configuration (created or updated).
_get_transaction ¶
_get_transaction() -> TransactionController[ModelT]
Get or create transaction controller.
Returns:
-
TransactionController[ModelT]–The transaction controller instance.
delete_starboard_by_guild_id async ¶
Delete starboard configuration for a guild.
Returns:
-
bool–True if deleted successfully, False otherwise.
_get_performance ¶
_get_performance() -> PerformanceController[ModelT]
Get or create performance controller.
Returns:
-
PerformanceController[ModelT]–The performance controller instance.
get_starboard_by_guild_id async ¶
Get starboard configuration by guild ID - alias for get_starboard_by_guild.
Returns:
-
Starboard | None–The starboard configuration if found, None otherwise.
_get_upsert ¶
_get_upsert() -> UpsertController[ModelT]
Get or create upsert controller.
Returns:
-
UpsertController[ModelT]–The upsert controller instance.
create async ¶
create(**kwargs: Any) -> ModelT
Create a new record.
Returns:
-
ModelT–The newly created record.
get_by_id async ¶
get_by_id(record_id: Any) -> ModelT | None
Get a record by ID.
Returns:
-
ModelT | None–The record if found, None otherwise.
update_by_id async ¶
Update a record by ID.
Returns:
-
ModelT | None–The updated record, or None if not found.
delete_by_id async ¶
exists async ¶
find_one async ¶
Find one record.
Returns:
-
ModelT | None–The found record, or None if not found.
find_all async ¶
find_all_with_options async ¶
find_all_with_options(
filters: Any | None = None,
order_by: Any | None = None,
limit: int | None = None,
offset: int | None = None,
load_relationships: list[str] | None = None,
) -> list[ModelT]
Find all records with relationship loading options.
Returns:
-
list[ModelT]–List of found records with loaded relationships.
count async ¶
get_all async ¶
Get all records (alias for find_all without pagination).
Returns:
-
list[ModelT]–List of all matching records.
execute_query async ¶
find_with_json_query async ¶
find_with_json_query(
json_column: str, json_path: str, value: Any, filters: Any | None = None
) -> list[ModelT]
Find records using JSON column queries.
Returns:
-
list[ModelT]–List of records matching the JSON query.
find_with_array_contains async ¶
find_with_array_contains(
array_column: str, value: Any, filters: Any | None = None
) -> list[ModelT]
Find records where array column contains value.
Returns:
-
list[ModelT]–List of records with matching array values.
find_with_full_text_search async ¶
find_with_full_text_search(
search_columns: list[str], search_term: str, filters: Any | None = None
) -> list[ModelT]
Find records using full-text search.
Returns:
-
list[ModelT]–List of records matching the search term.
paginate async ¶
paginate(
page: int = 1,
per_page: int = 20,
filters: Any | None = None,
order_by: Any | None = None,
) -> PaginationResult[ModelT]
Paginate records with metadata.
Returns:
-
PaginationResult[ModelT]–Pagination result with items, total, and page info.
find_paginated async ¶
find_paginated(
page: int = 1,
per_page: int = 20,
filters: Any | None = None,
order_by: Any | None = None,
load_relationships: list[str] | None = None,
) -> PaginationResult[ModelT]
Find paginated records with relationship loading.
Returns:
-
PaginationResult[ModelT]–Pagination result with items and relationships loaded.
bulk_create async ¶
bulk_update async ¶
bulk_delete async ¶
update_where async ¶
delete_where async ¶
bulk_upsert_with_conflict_resolution async ¶
with_session async ¶
Execute operation within a session context.
Returns:
-
R–The result of the operation.
with_transaction async ¶
Execute operation within a transaction context.
Returns:
-
R–The result of the operation.
execute_transaction async ¶
get_table_statistics async ¶
explain_query_performance async ¶
upsert_by_field async ¶
upsert_by_id async ¶
get_or_create_by_field async ¶
StarboardMessageController ¶
StarboardMessageController(db: DatabaseService | None = None)
Bases: BaseController[StarboardMessage]
Clean StarboardMessage controller using the new BaseController pattern.
Initialize the starboard message controller.
Parameters:
-
db(DatabaseService | None, default:None) –The database service instance. If None, uses the default service.
Methods:
-
create–Create a new record.
-
get_message_by_id–Get a starboard message by its ID.
-
get_by_id–Get a record by ID.
-
get_message_by_original–Get a starboard message by its original message ID and guild.
-
update_by_id–Update a record by ID.
-
get_messages_by_guild–Get all starboard messages in a guild.
-
delete_by_id–Delete a record by ID.
-
create_starboard_message–Create a new starboard message.
-
exists–Check if a record exists.
-
find_one–Find one record.
-
update_star_count–Update the star count for a starboard message.
-
find_all–Find all records with performance optimizations.
-
delete_starboard_message–Delete a starboard message.
-
get_top_messages–Get top starboard messages by star count in a guild.
-
find_all_with_options–Find all records with relationship loading options.
-
get_message_count_by_guild–Get the total number of starboard messages in a guild.
-
count–Count records.
-
get_messages_by_channel–Get all starboard messages in a specific channel.
-
get_all–Get all records (alias for find_all without pagination).
-
get_starboard_message_by_id–Get a starboard message by its ID.
-
execute_query–Execute a custom query.
-
create_or_update_starboard_message–Create or update a starboard message.
-
find_with_json_query–Find records using JSON column queries.
-
find_with_array_contains–Find records where array column contains value.
-
find_with_full_text_search–Find records using full-text search.
-
paginate–Paginate records with metadata.
-
find_paginated–Find paginated records with relationship loading.
-
bulk_create–Create multiple records in bulk.
-
bulk_update–Update multiple records in bulk.
-
bulk_delete–Delete multiple records in bulk.
-
update_where–Update records matching filters.
-
delete_where–Delete records matching filters.
-
bulk_upsert_with_conflict_resolution–Bulk upsert with conflict resolution.
-
with_session–Execute operation within a session context.
-
with_transaction–Execute operation within a transaction context.
-
execute_transaction–Execute a callback within a transaction.
-
get_table_statistics–Get comprehensive table statistics.
-
explain_query_performance–Explain query performance with optional analysis.
-
upsert_by_field–Upsert a record by a specific field.
-
upsert_by_id–Upsert a record by ID.
-
get_or_create_by_field–Get existing record or create new one by field.
-
get_or_create–Get existing record or create new one.
-
upsert–Upsert a record.
Attributes:
-
db_service(DatabaseService) –Database service property for test compatibility.
-
model_class(type[ModelT]) –Model class property for test compatibility.
Attributes¶
db_service property ¶
db_service: DatabaseService
Database service property for test compatibility.
Returns:
-
DatabaseService–The database service instance.
Functions¶
_get_pagination ¶
_get_pagination() -> PaginationController[ModelT]
Get or create pagination controller.
Returns:
-
PaginationController[ModelT]–The pagination controller instance.
_get_bulk ¶
_get_bulk() -> BulkOperationsController[ModelT]
Get or create bulk operations controller.
Returns:
-
BulkOperationsController[ModelT]–The bulk operations controller instance.
_get_transaction ¶
_get_transaction() -> TransactionController[ModelT]
Get or create transaction controller.
Returns:
-
TransactionController[ModelT]–The transaction controller instance.
_get_performance ¶
_get_performance() -> PerformanceController[ModelT]
Get or create performance controller.
Returns:
-
PerformanceController[ModelT]–The performance controller instance.
_get_upsert ¶
_get_upsert() -> UpsertController[ModelT]
Get or create upsert controller.
Returns:
-
UpsertController[ModelT]–The upsert controller instance.
create async ¶
create(**kwargs: Any) -> ModelT
Create a new record.
Returns:
-
ModelT–The newly created record.
get_message_by_id async ¶
get_message_by_id(message_id: int) -> StarboardMessage | None
Get a starboard message by its ID.
Returns:
-
StarboardMessage | None–The starboard message if found, None otherwise.
get_by_id async ¶
get_by_id(record_id: Any) -> ModelT | None
Get a record by ID.
Returns:
-
ModelT | None–The record if found, None otherwise.
get_message_by_original async ¶
get_message_by_original(
original_message_id: int, guild_id: int
) -> StarboardMessage | None
Get a starboard message by its original message ID and guild.
Returns:
-
StarboardMessage | None–The starboard message if found, None otherwise.
update_by_id async ¶
Update a record by ID.
Returns:
-
ModelT | None–The updated record, or None if not found.
get_messages_by_guild async ¶
get_messages_by_guild(
guild_id: int, limit: int | None = None
) -> list[StarboardMessage]
Get all starboard messages in a guild.
Returns:
-
list[StarboardMessage]–List of starboard messages sorted by star count (limited if specified).
delete_by_id async ¶
create_starboard_message async ¶
exists async ¶
find_one async ¶
Find one record.
Returns:
-
ModelT | None–The found record, or None if not found.
update_star_count async ¶
update_star_count(message_id: int, new_star_count: int) -> StarboardMessage | None
Update the star count for a starboard message.
Returns:
-
StarboardMessage | None–The updated starboard message, or None if not found.
find_all async ¶
delete_starboard_message async ¶
get_top_messages async ¶
get_top_messages(guild_id: int, limit: int = 10) -> list[StarboardMessage]
Get top starboard messages by star count in a guild.
Returns:
-
list[StarboardMessage]–List of top starboard messages sorted by star count.
find_all_with_options async ¶
find_all_with_options(
filters: Any | None = None,
order_by: Any | None = None,
limit: int | None = None,
offset: int | None = None,
load_relationships: list[str] | None = None,
) -> list[ModelT]
Find all records with relationship loading options.
Returns:
-
list[ModelT]–List of found records with loaded relationships.
get_message_count_by_guild async ¶
Get the total number of starboard messages in a guild.
Returns:
-
int–The total count of starboard messages in the guild.
count async ¶
get_messages_by_channel async ¶
get_messages_by_channel(channel_id: int) -> list[StarboardMessage]
Get all starboard messages in a specific channel.
Returns:
-
list[StarboardMessage]–List of all starboard messages in the channel.
get_all async ¶
Get all records (alias for find_all without pagination).
Returns:
-
list[ModelT]–List of all matching records.
get_starboard_message_by_id async ¶
get_starboard_message_by_id(message_id: int) -> StarboardMessage | None
Get a starboard message by its ID.
Returns:
-
StarboardMessage | None–The starboard message if found, None otherwise.
execute_query async ¶
create_or_update_starboard_message async ¶
create_or_update_starboard_message(**kwargs: Any) -> StarboardMessage
Create or update a starboard message.
Returns:
-
StarboardMessage–The starboard message (created or updated).
find_with_json_query async ¶
find_with_json_query(
json_column: str, json_path: str, value: Any, filters: Any | None = None
) -> list[ModelT]
Find records using JSON column queries.
Returns:
-
list[ModelT]–List of records matching the JSON query.
find_with_array_contains async ¶
find_with_array_contains(
array_column: str, value: Any, filters: Any | None = None
) -> list[ModelT]
Find records where array column contains value.
Returns:
-
list[ModelT]–List of records with matching array values.
find_with_full_text_search async ¶
find_with_full_text_search(
search_columns: list[str], search_term: str, filters: Any | None = None
) -> list[ModelT]
Find records using full-text search.
Returns:
-
list[ModelT]–List of records matching the search term.
paginate async ¶
paginate(
page: int = 1,
per_page: int = 20,
filters: Any | None = None,
order_by: Any | None = None,
) -> PaginationResult[ModelT]
Paginate records with metadata.
Returns:
-
PaginationResult[ModelT]–Pagination result with items, total, and page info.
find_paginated async ¶
find_paginated(
page: int = 1,
per_page: int = 20,
filters: Any | None = None,
order_by: Any | None = None,
load_relationships: list[str] | None = None,
) -> PaginationResult[ModelT]
Find paginated records with relationship loading.
Returns:
-
PaginationResult[ModelT]–Pagination result with items and relationships loaded.
bulk_create async ¶
bulk_update async ¶
bulk_delete async ¶
update_where async ¶
delete_where async ¶
bulk_upsert_with_conflict_resolution async ¶
with_session async ¶
Execute operation within a session context.
Returns:
-
R–The result of the operation.
with_transaction async ¶
Execute operation within a transaction context.
Returns:
-
R–The result of the operation.