guild_config ¶
Guild configuration management controller.
This controller manages Discord guild configuration settings, including bot preferences, moderation settings, and feature toggles for each guild.
Classes:
-
GuildConfigController–Clean GuildConfig controller using the new BaseController pattern.
Classes¶
GuildConfigController ¶
GuildConfigController(db: DatabaseService | None = None)
Bases: BaseController[GuildConfig]
Clean GuildConfig controller using the new BaseController pattern.
Initialize the guild config controller.
Parameters:
-
db(DatabaseService | None, default:None) –The database service instance. If None, uses the default service.
Methods:
-
get_config_by_guild_id–Get guild configuration by guild ID.
-
get_or_create_config–Get guild configuration, or create it with defaults if it doesn't exist.
-
update_config–Update guild configuration.
-
delete_config–Delete guild configuration.
-
get_all_configs–Get all guild configurations.
-
get_config_count–Get the total number of guild configurations.
-
find_configs_by_field–Find configurations by a specific field value.
-
update_config_field–Update a specific field in guild configuration.
-
update_onboarding_stage–Update the onboarding stage for a guild.
-
mark_onboarding_completed–Mark onboarding as completed for a guild.
-
reset_onboarding–Reset onboarding status for a guild.
-
get_onboarding_status–Get onboarding status for a guild.
-
create–Create a new record.
-
update_channel_field–Update a channel field in guild configuration.
-
get_by_id–Get a record by ID.
-
get_configs_by_prefix–Get configurations where guild ID starts with a prefix.
-
update_by_id–Update a record by ID.
-
delete_by_id–Delete a record by ID.
-
update_perm_level_role–Update permission level role for a guild.
-
exists–Check if a record exists.
-
find_one–Find one record.
-
get_config_field–Get any field from guild configuration.
-
find_all–Find all records with performance optimizations.
-
get_jail_role_id–Get jail role ID for a guild.
-
find_all_with_options–Find all records with relationship loading options.
-
get_perm_level_role–Get role ID for a specific permission level.
-
get_jail_channel_id–Get jail channel ID for a guild.
-
count–Count records.
-
update_private_log_id–Update private log channel ID.
-
get_all–Get all records (alias for find_all without pagination).
-
update_report_log_id–Update report log channel ID.
-
execute_query–Execute a custom query.
-
update_dev_log_id–Update dev log channel ID.
-
find_with_json_query–Find records using JSON column queries.
-
update_mod_log_id–Update mod log channel ID.
-
find_with_array_contains–Find records where array column contains value.
-
update_audit_log_id–Update audit log channel ID.
-
update_join_log_id–Update join log channel ID.
-
find_with_full_text_search–Find records using full-text search.
-
update_jail_channel_id–Update jail channel ID.
-
paginate–Paginate records with metadata.
-
update_starboard_channel_id–Update starboard channel ID.
-
update_general_channel_id–Update general channel ID.
-
find_paginated–Find paginated records with relationship loading.
-
get_starboard_channel_id–Get starboard channel ID for a guild.
-
get_general_channel_id–Get general channel ID for a guild.
-
bulk_create–Create multiple records in bulk.
-
get_join_log_id–Get join log channel ID for a guild.
-
bulk_update–Update multiple records in bulk.
-
get_audit_log_id–Get audit log channel ID for a guild.
-
bulk_delete–Delete multiple records in bulk.
-
get_mod_log_id–Get mod log channel ID for a guild.
-
update_where–Update records matching filters.
-
get_private_log_id–Get private log channel ID for a guild.
-
delete_where–Delete records matching filters.
-
get_report_log_id–Get report log channel ID for a guild.
-
bulk_upsert_with_conflict_resolution–Bulk upsert with conflict resolution.
-
get_dev_log_id–Get dev log channel ID for a guild.
-
update_guild_prefix–Update guild prefix.
-
with_session–Execute operation within a session context.
-
delete_guild_prefix–Delete guild prefix (set to default).
-
with_transaction–Execute operation within a transaction context.
-
get_log_channel–Get log channel ID for a guild based on log type.
-
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_config_by_guild_id async ¶
get_config_by_guild_id(guild_id: int) -> GuildConfig | None
Get guild configuration by guild ID.
Returns:
-
GuildConfig | None–The guild configuration if found, None otherwise.
get_or_create_config async ¶
get_or_create_config(guild_id: int, **defaults: Any) -> GuildConfig
Get guild configuration, or create it with defaults if it doesn't exist.
Returns:
-
GuildConfig–The guild configuration (existing or newly created).
update_config async ¶
update_config(guild_id: int, **updates: Any) -> GuildConfig | None
Update guild configuration.
Returns:
-
GuildConfig | None–The updated configuration, or None if not found.
delete_config async ¶
get_all_configs async ¶
get_all_configs() -> list[GuildConfig]
get_config_count async ¶
get_config_count() -> int
Get the total number of guild configurations.
Returns:
-
int–The total count of guild configurations.
_get_pagination ¶
_get_pagination() -> PaginationController[ModelT]
Get or create pagination controller.
Returns:
-
PaginationController[ModelT]–The pagination controller instance.
find_configs_by_field async ¶
find_configs_by_field(field_name: str, field_value: Any) -> list[GuildConfig]
Find configurations by a specific field value.
Returns:
-
list[GuildConfig]–List of configurations with matching field value.
_get_bulk ¶
_get_bulk() -> BulkOperationsController[ModelT]
Get or create bulk operations controller.
Returns:
-
BulkOperationsController[ModelT]–The bulk operations controller instance.
update_config_field async ¶
update_config_field(
guild_id: int, field_name: str, field_value: Any
) -> GuildConfig | None
Update a specific field in guild configuration.
Returns:
-
GuildConfig | None–The updated configuration, or None if not found.
_get_transaction ¶
_get_transaction() -> TransactionController[ModelT]
Get or create transaction controller.
Returns:
-
TransactionController[ModelT]–The transaction controller instance.
update_onboarding_stage async ¶
update_onboarding_stage(guild_id: int, stage: str) -> GuildConfig | None
Update the onboarding stage for a guild.
Returns:
-
GuildConfig | None–The updated configuration, or None if not found.
_get_performance ¶
_get_performance() -> PerformanceController[ModelT]
Get or create performance controller.
Returns:
-
PerformanceController[ModelT]–The performance controller instance.
mark_onboarding_completed async ¶
mark_onboarding_completed(guild_id: int) -> GuildConfig | None
Mark onboarding as completed for a guild.
Returns:
-
GuildConfig | None–The updated configuration, or None if not found.
_get_upsert ¶
_get_upsert() -> UpsertController[ModelT]
Get or create upsert controller.
Returns:
-
UpsertController[ModelT]–The upsert controller instance.
reset_onboarding async ¶
reset_onboarding(guild_id: int) -> GuildConfig | None
Reset onboarding status for a guild.
Returns:
-
GuildConfig | None–The updated configuration, or None if not found.
get_onboarding_status async ¶
create async ¶
create(**kwargs: Any) -> ModelT
Create a new record.
Returns:
-
ModelT–The newly created record.
update_channel_field async ¶
update_channel_field(
guild_id: int, channel_field: str, channel_id: int
) -> GuildConfig | None
Update a channel field in guild configuration.
Returns:
-
GuildConfig | None–The updated configuration, or None if not found.
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_configs_by_prefix async ¶
get_configs_by_prefix(prefix: str) -> list[GuildConfig]
Get configurations where guild ID starts with a prefix.
Returns:
-
list[GuildConfig]–List of configurations with matching guild ID prefix.
update_by_id async ¶
Update a record by ID.
Returns:
-
ModelT | None–The updated record, or None if not found.
delete_by_id async ¶
update_perm_level_role async ¶
update_perm_level_role(
guild_id: int, role_id: int | str, perm_level: int | str
) -> GuildConfig | None
Update permission level role for a guild.
Returns:
-
GuildConfig | None–The updated configuration, or None if not found.
exists async ¶
find_one async ¶
Find one record.
Returns:
-
ModelT | None–The found record, or None if not found.
get_config_field async ¶
Get any field from guild configuration.
Returns:
-
Any–The field value, or None if configuration or field not found.
find_all async ¶
get_jail_role_id 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.
get_perm_level_role async ¶
Get role ID for a specific permission level.
Returns:
-
int | None–The role ID for the permission level, or None if not configured.
get_jail_channel_id async ¶
Get jail channel ID for a guild.
Returns:
-
int | None–The jail channel ID, or None if not configured.
count async ¶
update_private_log_id async ¶
update_private_log_id(guild_id: int, channel_id: int) -> GuildConfig | None
Update private log channel ID.
Returns:
-
GuildConfig | None–The updated configuration, or None if not found.
get_all async ¶
Get all records (alias for find_all without pagination).
Returns:
-
list[ModelT]–List of all matching records.
update_report_log_id async ¶
update_report_log_id(guild_id: int, channel_id: int) -> GuildConfig | None
Update report log channel ID.
Returns:
-
GuildConfig | None–The updated configuration, or None if not found.
execute_query async ¶
update_dev_log_id async ¶
update_dev_log_id(guild_id: int, channel_id: int) -> GuildConfig | None
Update dev log channel ID.
Returns:
-
GuildConfig | None–The updated configuration, or None if not found.
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.
update_mod_log_id async ¶
update_mod_log_id(guild_id: int, channel_id: int) -> GuildConfig | None
Update mod log channel ID.
Returns:
-
GuildConfig | None–The updated configuration, or None if not found.
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.
update_audit_log_id async ¶
update_audit_log_id(guild_id: int, channel_id: int) -> GuildConfig | None
Update audit log channel ID.
Returns:
-
GuildConfig | None–The updated configuration, or None if not found.
update_join_log_id async ¶
update_join_log_id(guild_id: int, channel_id: int) -> GuildConfig | None
Update join log channel ID.
Returns:
-
GuildConfig | None–The updated configuration, or None if not found.
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.
update_jail_channel_id async ¶
update_jail_channel_id(guild_id: int, channel_id: int) -> GuildConfig | None
Update jail channel ID.
Returns:
-
GuildConfig | None–The updated configuration, or None if not found.
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.
update_starboard_channel_id async ¶
update_starboard_channel_id(guild_id: int, channel_id: int) -> GuildConfig | None
Update starboard channel ID.
Returns:
-
GuildConfig | None–The updated configuration, or None if not found.
update_general_channel_id async ¶
update_general_channel_id(guild_id: int, channel_id: int) -> GuildConfig | None
Update general channel ID.
Returns:
-
GuildConfig | None–The updated configuration, or None if not found.
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.
get_starboard_channel_id async ¶
Get starboard channel ID for a guild.
Returns:
-
int | None–The starboard channel ID, or None if not configured.
get_general_channel_id async ¶
Get general channel ID for a guild.
Returns:
-
int | None–The general channel ID, or None if not configured.
bulk_create async ¶
get_join_log_id async ¶
Get join log channel ID for a guild.
Returns:
-
int | None–The join log channel ID, or None if not configured.
bulk_update async ¶
get_audit_log_id async ¶
Get audit log channel ID for a guild.
Returns:
-
int | None–The audit log channel ID, or None if not configured.
bulk_delete async ¶
get_mod_log_id async ¶
Get mod log channel ID for a guild.
Returns:
-
int | None–The mod log channel ID, or None if not configured.
update_where async ¶
get_private_log_id async ¶
Get private log channel ID for a guild.
Returns:
-
int | None–The private log channel ID, or None if not configured.
delete_where async ¶
get_report_log_id async ¶
Get report log channel ID for a guild.
Returns:
-
int | None–The report log channel ID, or None if not configured.
bulk_upsert_with_conflict_resolution async ¶
get_dev_log_id async ¶
Get dev log channel ID for a guild.
Returns:
-
int | None–The dev log channel ID, or None if not configured.
update_guild_prefix async ¶
update_guild_prefix(guild_id: int, prefix: str) -> GuildConfig | None
with_session async ¶
Execute operation within a session context.
Returns:
-
R–The result of the operation.
delete_guild_prefix async ¶
delete_guild_prefix(guild_id: int) -> GuildConfig | None
Delete guild prefix (set to default).
Returns:
-
GuildConfig | None–The updated configuration, or None if not found.
with_transaction async ¶
Execute operation within a transaction context.
Returns:
-
R–The result of the operation.
get_log_channel async ¶
Get log channel ID for a guild based on log type.
Returns:
-
int | None–The log channel ID for the specified type, or None if not found.