Skip to content

Modal.remove_item() always raises AttributeError #3356

Description

@vmphase

Summary

Modal.remove_item() crashes with AttributeError: 'Modal' object has no attribute '_Modal__weights'

Reproduction Steps

  1. Create a discord.ui.Modal, add two InputText children (e.g.)
  2. Call modal.remove_item(modal.children[0])
  3. Every call crashes with AttributeError: 'Modal' object has no attribute '_Modal__weights'

Minimal Reproducible Code

async def main():
    modal = discord.ui.Modal(title="Test")
    modal.add_item(discord.ui.InputText(label="A"))
    modal.add_item(discord.ui.InputText(label="B"))
    modal.remove_item(modal.children[0])

Expected Results

Removes the item from the modal, returning self (same as BaseModal.remove_item does for _children).

Actual Results

AttributeError: 'Modal' object has no attribute '_Modal__weights'

Intents

All

System Information

- Python v3.13.6
- py-cord master

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.
  • I have read the Contributing Guidelines.

Additional Context

This issue wasn't found by me, as I am not a discord bot developer, I just delegate.
However, I believe this bug is critical.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

  • Status
    In Progress

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions