utils.django_permissions module

Django Permission Integration for Discord Bot

This module provides integration with the Django web interface’s admin panel permission system, allowing the Discord bot to use the same server-specific permission configuration that users set through the web interface.

utils.django_permissions.get_django_database_path()[source]

Get the Django database path from configuration.

Returns:

Path to Django SQLite database, None if not found.

Return type:

Optional[str]

utils.django_permissions.get_server_permission_config(guild_id)[source]

Get server permission configuration from Django database.

Parameters:

guild_id (int) – Discord guild ID to get permissions for.

Returns:

Permission configuration dict, None if not found.

Return type:

Optional[Dict]

utils.django_permissions.check_server_permission(member, guild_id, permission_type)[source]

Check if a Discord member has the specified permission for a server.

Parameters:
  • member (Member) – Discord member to check permissions for.

  • guild_id (int) – Discord guild ID.

  • permission_type (str) – Type of permission (‘create_macros’, ‘edit_macros’, ‘delete_macros’, etc.).

Returns:

True if user has the specified permission, False otherwise.

Return type:

bool

utils.django_permissions.get_permission_error_message(permission_type, config=None)[source]

Get a user-friendly error message for permission denial.

Parameters:
  • permission_type (str) – Type of permission that was denied.

  • config (dict | None) – Server permission configuration (optional).

Returns:

User-friendly error message explaining what’s required.

Return type:

str