Skip to content

Conversation

@JacobCoffee
Copy link
Owner

@JacobCoffee JacobCoffee commented Jun 14, 2025

Description

This adds setting management through discord ui
image
then goes into modals
image

this is partially done but works (no linking into db or at least not fully workign)

going to merge though

Close Issue(s)

Summary by Sourcery

Provide full guild-setting management APIs, enhance bot configuration and scheduling features, refactor UI/embed utilities and CSS, and tighten logging and error handling.

New Features:

  • Add REST endpoints and services to fetch guild details and specific configurations (GitHub, StackOverflow tags, allowed users, forum)
  • Introduce an interactive /config slash command with UI views and modals for guild administrators to configure bot settings
  • Implement /schedule-office-hours slash command to schedule recurring 'Office Hours' events
  • Add GitHub issue creation via context menu and new modal in a dedicated GitHub plugin

Bug Fixes:

  • Prevent welcome DM to bot accounts and improve error handling when adding new guilds

Enhancements:

  • Refactor CSS style resets, update Tailwind base and remove deprecated forced-color queries
  • Unify and extend embed helpers with ButtonEmbedView and ExtendedEmbed classes
  • Consolidate mention utilities into a common module and extract type definitions into dedicated types packages
  • Introduce get_next_friday utility for scheduling logic

Build:

  • Add HTTP core and HTTPX logging levels to logging configuration

Chores:

  • Reorganize imports and move settings (DEV_GUILD_INTERNAL_ID, BUILD_NUMBER) and common configuration options to central modules
  • Remove redundant utility functions and streamline service and repository classes

JacobCoffee and others added 24 commits June 13, 2025 19:24
chore(ui): increase byte screen logo size
* feat: add guild configuration command

* feat: add litestar office hours command

* fix: centralize options for slashcmd and dropdown

* ci: apply pre-commit

* chore: dependency updates

* chore: clean up utils

* fix: move moved import

* fix: attempt to fix broken modal submission

* feat:  finalize working config selection and sub selections

* ci: for some reason pre-commit is stupid and changed every fucking file
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jun 14, 2025

Reviewer's Guide

This PR refactors and modularizes the Byte bot by reorganizing style assets, extracting and cleaning up core type logic, extending the Guild configuration API and interactive config UI, enhancing logging/settings, revamping embed views, improving join event handling, and updating registry to support new plugins and views.

Sequence Diagram for Guild Join Process

sequenceDiagram
    actor DiscordServer as Discord Server
    participant ByteBot as Byte Bot
    participant BackendAPI as Backend API (Litestar)
    participant DevChannel as Dev Discord Channel

    DiscordServer->>ByteBot: Guild Join Event (guild)
    ByteBot->>BackendAPI: POST /api/guilds/create?guild_id={id}&guild_name={name}
    alt Creation Successful
        BackendAPI-->>ByteBot: 201 CREATED
        ByteBot->>DevChannel: Send Embed (Guild Joined Successfully)
    else Creation Failed
        BackendAPI-->>ByteBot: Error Response
        ByteBot->>DevChannel: Send Embed (Guild Join Failed to Add to DB)
    else API Connection Error
        ByteBot-->>ByteBot: Log Exception
        ByteBot->>DevChannel: Send Embed (Guild Join Failed - API Connect Error)
    end
    ByteBot->>ByteBot: Sync App Commands for Guild
Loading

Sequence Diagram for Member Join Process

sequenceDiagram
    actor DiscordUser as New User
    participant ByteBot as Byte Bot

    DiscordUser->>ByteBot: Member Join Event (member)
    alt User is not a Bot
        ByteBot->>DiscordUser: Send DM (Welcome Message)
    end
Loading

Sequence Diagram for Help Thread View Setup

sequenceDiagram
    participant User as User
    participant DiscordClient as Discord Client
    participant HelpThreadView as HelpThreadView
    participant GuildsService as GuildsService
    participant Database as Database

    User->>DiscordClient: Creates a help thread
    DiscordClient->>HelpThreadView: Instantiate HelpThreadView(author, guild_id, bot)
    HelpThreadView->>HelpThreadView: call setup()
    HelpThreadView->>GuildsService: get(guild_id)
    GuildsService->>Database: Fetch guild_settings for guild_id
    Database-->>GuildsService: guild_settings
    GuildsService-->>HelpThreadView: guild_settings
    alt Guild settings and GitHub config found
        HelpThreadView->>HelpThreadView: Add Button("Open GitHub Issue", url)
    else No GitHub config
        HelpThreadView->>HelpThreadView: Log warning
    end
    HelpThreadView-->>DiscordClient: View with/without button
    DiscordClient-->>User: Display thread message with view
Loading

Sequence Diagram for Schedule Office Hours Command

sequenceDiagram
    actor User
    participant DiscordClient as Discord Client
    participant LitestarCommands as LitestarCommands Cog
    participant DiscordAPI as Discord API

    User->>DiscordClient: Executes /schedule-office-hours command (delay?)
    DiscordClient->>LitestarCommands: schedule_office_hours(interaction, delay)
    LitestarCommands->>LitestarCommands: Calculate next Friday's start/end time (start_dt, end_dt)
    LitestarCommands->>DiscordAPI: Get existing scheduled events for guild
    DiscordAPI-->>LitestarCommands: existing_events
    alt No existing Office Hours event for that day
        LitestarCommands->>DiscordAPI: create_scheduled_event(name="Office Hours", start_time, end_time, ...)
        DiscordAPI-->>LitestarCommands: Event created
        LitestarCommands->>DiscordClient: Send Message("Office Hours event scheduled: ...")
    else Event already exists
        LitestarCommands->>DiscordClient: Send Message("An Office Hours event is already scheduled...", ephemeral=true)
    end
Loading

Sequence Diagram for Create GitHub Issue Context Menu

sequenceDiagram
    actor User
    participant DiscordClient as Discord Client
    participant GitHubCommands as GitHubCommands Cog
    participant GitHubIssueModal as GitHubIssue Modal
    participant GitHubAPI as GitHub API

    User->>DiscordClient: Right-click message -> "Create GitHub Issue"
    DiscordClient->>GitHubCommands: create_github_issue_modal(interaction, message)
    GitHubCommands->>DiscordClient: interaction.response.send_modal(GitHubIssueModal(message))
    User->>GitHubIssueModal: Fills out Title, Description, MCVE, Logs, Version
    GitHubIssueModal->>User: Submits Modal
    GitHubIssueModal->>GitHubAPI: POST /repos/{owner}/{repo}/issues (title, body)
    alt Issue Creation Successful
        GitHubAPI-->>GitHubIssueModal: Success Response (issue_url)
        GitHubIssueModal->>DiscordClient: interaction.response.send_message("GitHub Issue created: {issue_url}")
    else Issue Creation Failed
        GitHubAPI-->>GitHubIssueModal: Error Response
        GitHubIssueModal->>DiscordClient: interaction.response.send_message("Issue creation failed.", ephemeral=true)
    else Exception
        GitHubIssueModal->>GitHubIssueModal: Log Exception
        GitHubIssueModal->>DiscordClient: interaction.response.send_message("An error occurred: {error}", ephemeral=true)
    end
Loading

Class Diagram for New Configuration UI (byte_bot.byte.views.config)

classDiagram
    direction LR
    class View~discord.ui.View~
    class Modal~discord.ui.Modal~
    class Button~discord.ui.Button~
    class Select~discord.ui.Select~
    class TextInput~discord.ui.TextInput~

    class ConfigView {
        +__init__(preselected: str | None)
    }
    ConfigView --|> View
    ConfigView o-- ConfigSelect
    ConfigView o-- FinishButton
    ConfigView o-- CancelButton

    class ConfigKeyView {
        +__init__(option: dict)
    }
    ConfigKeyView --|> View
    ConfigKeyView o-- ConfigKeySelect
    ConfigKeyView o-- BackButton
    ConfigKeyView o-- CancelButton

    class ConfigModal {
        +__init__(title: str, sub_setting: dict | None, sub_settings: list[dict] | None, option: dict | None)
        +on_submit(interaction: Interaction)
        +on_error(interaction: Interaction, error: Exception)
    }
    ConfigModal --|> Modal
    ConfigModal o-- TextInput

    class FinishButton {
        +__init__()
        +callback(interaction: Interaction)
    }
    FinishButton --|> Button

    class BackButton {
        +__init__()
        +callback(interaction: Interaction)
    }
    BackButton --|> Button

    class CancelButton {
        +__init__()
        +callback(interaction: Interaction)
    }
    CancelButton --|> Button

    class ConfigSelect {
        +__init__(preselected: str | None)
        +callback(interaction: Interaction)
    }
    ConfigSelect --|> Select

    class ConfigKeySelect {
        +__init__(option: dict)
        +callback(interaction: Interaction)
    }
    ConfigKeySelect --|> Select
Loading

Class Diagram for Guild Configuration Schemas (byte_bot.server.domain.guilds.schemas)

classDiagram
    class CamelizedBaseModel

    class GitHubConfigSchema {
        +guild_id: UUID
        +discussion_sync: bool
        +github_organization: str | None
        +github_repository: str | None
    }
    GitHubConfigSchema --|> CamelizedBaseModel

    class SOTagsConfigSchema {
        +guild_id: UUID
        +tag_name: str
    }
    SOTagsConfigSchema --|> CamelizedBaseModel

    class AllowedUsersConfigSchema {
        +guild_id: UUID
        +user_id: UUID
    }
    AllowedUsersConfigSchema --|> CamelizedBaseModel

    class ForumConfigSchema {
        +guild_id: UUID
        +help_forum: bool
        +help_forum_category: str
        +help_thread_auto_close: bool
        +help_thread_auto_close_days: int
        +help_thread_notify: bool
        +help_thread_notify_roles: list[int]
        +help_thread_notify_days: int
        +help_thread_sync: bool
        +showcase_forum: bool
        +showcase_forum_category: str
        +showcase_thread_auto_close: bool
        +showcase_thread_auto_close_days: int
    }
    ForumConfigSchema --|> CamelizedBaseModel

    class UpdateableGuildSetting {
        +help_forum: bool
        +help_forum_category: str
        +help_thread_auto_close: bool
        +help_thread_auto_close_days: int
        +help_thread_notify: bool
        +help_thread_notify_roles: list[int]
        +help_thread_notify_days: int
        +help_thread_sync: bool
        +showcase_forum: bool
        +showcase_forum_category: str
        +showcase_thread_auto_close: bool
        +showcase_thread_auto_close_days: int
    }
    UpdateableGuildSetting --|> CamelizedBaseModel
Loading

Class Diagram for Guild Configuration Services (byte_bot.server.domain.guilds.services)

classDiagram
    direction BT
    class SQLAlchemyAsyncRepositoryService
    class SQLAlchemyAsyncRepository
    class SQLAlchemyAsyncSlugRepository

    class GuildsService
    GuildsService --|> SQLAlchemyAsyncRepositoryService
    GuildsService o-- GuildsRepository

    class GuildsRepository {
      model_type: Guild
    }
    GuildsRepository --|> SQLAlchemyAsyncSlugRepository

    class GitHubConfigService {
      repository_type: GitHubConfigRepository
      match_fields: list
      +to_model(data, operation) GitHubConfig
    }
    GitHubConfigService --|> SQLAlchemyAsyncRepositoryService
    GitHubConfigService o-- GitHubConfigRepository

    class GitHubConfigRepository {
      model_type: GitHubConfig
    }
    GitHubConfigRepository --|> SQLAlchemyAsyncRepository

    class SOTagsConfigService {
      repository_type: SOTagsConfigRepository
      match_fields: list
      +to_model(data, operation) SOTagsConfig
    }
    SOTagsConfigService --|> SQLAlchemyAsyncRepositoryService
    SOTagsConfigService o-- SOTagsConfigRepository

    class SOTagsConfigRepository {
      model_type: SOTagsConfig
    }
    SOTagsConfigRepository --|> SQLAlchemyAsyncRepository

    class AllowedUsersConfigService {
      repository_type: AllowedUsersConfigRepository
      match_fields: list
      +to_model(data, operation) AllowedUsersConfig
    }
    AllowedUsersConfigService --|> SQLAlchemyAsyncRepositoryService
    AllowedUsersConfigService o-- AllowedUsersConfigRepository

    class AllowedUsersConfigRepository {
      model_type: AllowedUsersConfig
    }
    AllowedUsersConfigRepository --|> SQLAlchemyAsyncRepository

    class ForumConfigService {
      repository_type: ForumConfigRepository
      match_fields: list
      +to_model(data, operation) ForumConfig
    }
    ForumConfigService --|> SQLAlchemyAsyncRepositoryService
    ForumConfigService o-- ForumConfigRepository

    class ForumConfigRepository {
      model_type: ForumConfig
    }
    ForumConfigRepository --|> SQLAlchemyAsyncRepository
Loading

Class Diagram for Abstract and Plugin Views

classDiagram
    class View~discord.ui.View~
    class Embed~discord.Embed~
    class Button~discord.ui.Button~
    class Member~discord.Member~
    class Bot~discord.ext.commands.Bot~

    class ButtonEmbedView {
        -author: int
        -bot: Bot
        -original_embed: Embed
        -minified_embed: Embed
        +__init__(author, bot, original_embed, minified_embed)
        +delete_interaction_check(interaction: Interaction) bool
        +delete_button_callback(interaction: Interaction)
        +learn_more_button_callback(interaction: Interaction)
    }
    ButtonEmbedView --|> View
    ButtonEmbedView o-- Button : delete_button
    ButtonEmbedView o-- Button : learn_more_button

    class Field~TypedDict~

    class ExtendedEmbed {
        +add_field_dict(field: Field) Self
        +add_field_dicts(fields: list[Field]) Self
        +from_field_dicts(...) Self
        +deepcopy() Self
    }
    ExtendedEmbed --|> Embed
    ExtendedEmbed ..> Field : uses

    class RuffView
    RuffView --|> ButtonEmbedView

    class PEPView
    PEPView --|> ButtonEmbedView

    class HelpThreadView {
        -author: Member
        -bot: Bot
        -guild_id: int
        +__init__(author, guild_id, bot)
        +setup()
        +delete_interaction_check(interaction: Interaction) bool
        +solve_button_callback(interaction: Interaction, button: Button)
        +remove_button_callback(interaction: Interaction, button: Button)
    }
    HelpThreadView --|> View
    HelpThreadView o-- Button : solve_button
    HelpThreadView o-- Button : remove_button
    HelpThreadView o-- Button : "may add Open GitHub Issue button"
Loading

Class Diagram for New Plugins (github.py, config.py)

classDiagram
    class Cog~discord.ext.commands.Cog~
    class Modal~discord.ui.Modal~
    class Bot~discord.ext.commands.Bot~
    class ContextMenu~discord.app_commands.ContextMenu~
    class ConfigView

    class GitHubIssue {
        +title_: TextInput
        +description: TextInput
        +mcve: TextInput
        +logs: TextInput
        +version: TextInput
        +__init__(message: Message | None)
        +on_submit(interaction: Interaction)
    }
    GitHubIssue --|> Modal

    class GitHubCommands {
        -bot: Bot
        -context_menu: ContextMenu
        +__init__(bot: Bot)
        +create_github_issue_modal(interaction: Interaction, message: Message)
    }
    GitHubCommands --|> Cog
    GitHubCommands o-- GitHubIssue : creates

    class Config {
        -bot: Bot
        -config_options: list[dict]
        +__init__(bot: Bot)
        +_config_autocomplete(interaction: Interaction, current: str) list[Choice]
        +config_rule(interaction: Interaction, setting: str | None)
    }
    Config --|> Cog
    Config ..> ConfigView : uses
Loading

Class Diagram for Bot Core and Event Handler Changes (byte_bot.byte.bot)

classDiagram
    class Bot~discord.ext.commands.Bot~
    class Member~discord.Member~
    class Guild~discord.Guild~
    class AsyncClient~httpx.AsyncClient~

    class Byte {
        +setup_hook()
        +on_ready()
        +on_command_error(ctx: Context, error: CommandError)
        +on_member_join(member: Member)
        +on_guild_join(guild: Guild)
    }
    Byte --|> Bot
    Byte ..> AsyncClient : uses in on_guild_join
Loading

Class Diagram for LitestarCommands Plugin Changes (byte_bot.byte.plugins.custom.litestar)

classDiagram
    class Cog~discord.ext.commands.Cog~
    class Bot~discord.ext.commands.Bot~

    class LitestarCommands {
        -bot: Bot
        +__init__(bot: Bot)
        +litestar_group()
        +apply_role_embed(ctx: Context)
        +schedule_office_hours(interaction: Interaction, delay: int | None)
    }
    LitestarCommands --|> Cog
Loading

File-Level Changes

Change Details Files
Update and restructure Tailwind CSS reset and version declaration.
  • Remove duplicated global reset at top
  • Change Tailwind version comment from v3.4.13 to v3.4.1
  • Eliminate deprecated selectors and simplify input styles
  • Reinsert reset rules at bottom for ordering consistency
byte_bot/server/domain/web/resources/style.css
Modularize type definitions and clean up utils module.
  • Remove inline TypedDicts for PEP and Ruff rules
  • Import PEP, PEPType, PEPStatus, PEPHistoryItem, RuffRule, FormattedRuffRule from new types modules
  • Adjust imports across utilities to reference external types
  • Add new get_next_friday helper function
byte_bot/byte/lib/utils.py
byte_bot/byte/lib/types/astral.py
byte_bot/byte/lib/types/python.py
byte_bot/byte/lib/__init__.py
Introduce /schedule-office-hours slash command and deprecate old context menu in Litestar plugin.
  • Add schedule_office_hours method using get_next_friday to compute times
  • Check for duplicates and create scheduled events with stage instance setup
  • Remove context menu registration for GitHub issue creation
  • Swap hard-coded color for litestar_yellow constant
byte_bot/byte/plugins/custom/litestar.py
Expose per-guild configuration endpoints and corresponding services.
  • Add GET routes in guilds/controllers for guild detail and GitHub/SO tags/allowed users/forum configs
  • Implement new repository and service classes for each config resource
  • Define Pydantic schemas for GitHubConfig, SOTagsConfig, AllowedUsersConfig, ForumConfig
  • Update dependencies to use GuildsService and eager‐load related configs
byte_bot/server/domain/guilds/controllers.py
byte_bot/server/domain/guilds/services.py
byte_bot/server/domain/guilds/schemas.py
byte_bot/server/domain/guilds/dependencies.py
Add interactive configuration UI for guild admins.
  • Create ConfigView, ConfigKeyView, ConfigModal in views/config.py
  • Implement config slash command and autocomplete in plugins/config.py
  • Export config_options constant for dropdown options
byte_bot/byte/views/config.py
byte_bot/byte/plugins/config.py
byte_bot/byte/lib/common/__init__.py
Extend logging and settings configuration.
  • Add httpcore and httpx loggers to logging setup
  • Introduce DEV_GUILD_INTERNAL_ID in Discord settings
  • Add HTTP_CORE_LEVEL and HTTPX_LEVEL in log settings
byte_bot/byte/lib/log.py
byte_bot/byte/lib/settings.py
Refactor embed base view and add ExtendedEmbed utility.
  • Rename BaseEmbedView to ButtonEmbedView
  • Split interaction_check into delete_interaction_check
  • Add ExtendedEmbed with methods for dict-based field handling and deepcopy
  • Update astral/python views and plugins to import ButtonEmbedView and ExtendedEmbed
byte_bot/byte/views/abstract_views.py
byte_bot/byte/views/astral.py
byte_bot/byte/views/python.py
byte_bot/byte/plugins/astral.py
byte_bot/byte/plugins/python.py
byte_bot/byte/plugins/admin.py
Improve member and guild join event handling in bot core.
  • Skip sending welcome DMs to bot accounts
  • Wrap API calls in try/except and use embeds for success/failure
  • Post guild join status to development guild channel
byte_bot/byte/bot.py
Enhance HelpThreadView to fetch guild config and add dynamic buttons.
  • Include guild_id in view constructor
  • Implement async setup to load GitHub repo from config
  • Add Open GitHub Issue button when config exists
  • Adjust events plugin to pass guild_id and call setup
byte_bot/byte/views/forums.py
byte_bot/byte/plugins/events.py
Update module registry to register new views and plugins.
  • Add astral, python, github, config plugins in plugins/init.py
  • Expose abstract_views, astral, python in byte/views/init.py
  • Include views and plugins in byte/init.py
  • Extend system/init.py imports to include dtos and helpers
byte_bot/byte/plugins/__init__.py
byte_bot/byte/views/__init__.py
byte_bot/byte/__init__.py
byte_bot/server/domain/system/__init__.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @JacobCoffee - I've reviewed your changes - here's some feedback:

  • You’ve defined get_guild_forum_config twice in GuildsController (once at the top and again at the bottom), which will shadow the first—please remove the duplicate or consolidate logic into a single handler.
  • In ForumConfigService you set repository_type = AllowedUsersConfigRepository instead of ForumConfigRepository, causing the wrong repo to be used for forum configs—please correct that.
  • The new except ConnectError in on_guild_join isn’t imported (will cause a NameError)—add from httpx import ConnectError or import from the appropriate module.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- You’ve defined get_guild_forum_config twice in GuildsController (once at the top and again at the bottom), which will shadow the first—please remove the duplicate or consolidate logic into a single handler.
- In ForumConfigService you set repository_type = AllowedUsersConfigRepository instead of ForumConfigRepository, causing the wrong repo to be used for forum configs—please correct that.
- The new except ConnectError in on_guild_join isn’t imported (will cause a NameError)—add `from httpx import ConnectError` or import from the appropriate module.

## Individual Comments

### Comment 1
<location> `byte_bot/server/domain/guilds/services.py:202` </location>
<code_context>
+class AllowedUsersConfigService(SQLAlchemyAsyncRepositoryService[AllowedUsersConfig]):
+    """Handles basic operations for the guilds' Allowed Users config."""
+
+    repository_type = AllowedUsersConfigRepository
+    match_fields = ["guild_id"]
+
</code_context>

<issue_to_address>
ForumConfigService uses the wrong repository_type

It should use ForumConfigRepository to handle ForumConfig models correctly.
</issue_to_address>

### Comment 2
<location> `byte_bot/server/domain/guilds/dependencies.py:79` </location>
<code_context>
         GitHubConfigService: GitHubConfig-based service
     """
-    async with GitHubConfigService.new(
+    async with GuildsService.new(
         session=db_session,
-        statement=select(GitHubConfig)
</code_context>

<issue_to_address>
provides_github_config_service uses GuildsService instead of GitHubConfigService

Replace GuildsService.new with GitHubConfigService.new to ensure the correct service is used.
</issue_to_address>

### Comment 3
<location> `byte_bot/server/domain/guilds/controllers.py:392` </location>
<code_context>
+        summary="Get forum config for a guild.",
+        path=urls.GUILD_FORUM_DETAIL,
+    )
+    async def get_guild_forum_config(
+        self,
+        forum_service: ForumConfigService,
</code_context>

<issue_to_address>
Duplicate get_guild_forum_config method detected

This will cause route conflicts. Please remove or rename one of the implementations.
</issue_to_address>

### Comment 4
<location> `byte_bot/byte/views/abstract_views.py:44` </location>
<code_context>
         self.minified_embed = minified_embed

-    async def interaction_check(self, interaction: Interaction) -> bool:
+    async def delete_interaction_check(self, interaction: Interaction) -> bool:
         """Check if the user is the author or a guild admin.

</code_context>

<issue_to_address>
Renamed interaction_check may break base behavior

Renaming the method means you no longer override the base `View.interaction_check`, which could leave other buttons unprotected. Override `interaction_check` and branch on `interaction.data["custom_id"]` to maintain proper checks.

Suggested implementation:

```python
    async def interaction_check(self, interaction: Interaction) -> bool:
        """Override to check if the user is the author or a guild admin for delete, or allow for other buttons.

        Args:
            interaction (Interaction): The interaction to check.

        Returns:
            bool: True if the interaction is allowed, False otherwise.
        """
        custom_id = interaction.data.get("custom_id")
        # Replace 'delete_button_custom_id' with the actual custom_id for your delete button
        if custom_id == "delete_button_custom_id":
            # Check if the user is the author or a guild admin
            if interaction.user.id == self.author:
                return True
            if interaction.guild and interaction.user.guild_permissions.administrator:
                return True
            return False
        # Default: allow other buttons (or add more checks as needed)
        return True

```

- Replace `"delete_button_custom_id"` with the actual custom_id string used for your delete button.
- If there are other buttons that need specific checks, add additional branches for their custom_ids.
- Remove any references to `delete_interaction_check` elsewhere in the codebase, as it is now merged into `interaction_check`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@JacobCoffee JacobCoffee changed the title Guild settings after uv feat: allow guild setting apis (partial) Jun 14, 2025
@JacobCoffee JacobCoffee enabled auto-merge (squash) June 14, 2025 01:20
@JacobCoffee JacobCoffee merged commit fd9b92f into main Jun 14, 2025
3 of 4 checks passed
@JacobCoffee JacobCoffee deleted the guild-settings-after-uv branch June 14, 2025 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants