Browse Source

Copy select options when creating View class

pull/10143/head
Leonardo Cavenago 3 weeks ago
parent
commit
a369fd0724
Failed to extract signature
  1. 3
      discord/components.py
  2. 3
      discord/ui/view.py

3
discord/components.py

@ -442,6 +442,9 @@ class SelectOption:
return payload
def copy(self) -> SelectOption:
return self.__class__.from_dict(self.to_dict())
class TextInput(Component):
"""Represents a text input from the Discord Bot UI Kit.

3
discord/ui/view.py

@ -33,6 +33,7 @@ import sys
import time
import os
from .item import Item, ItemCallbackType
from .select import Select
from .dynamic import DynamicItem
from ..components import (
Component,
@ -179,6 +180,8 @@ class View:
item: Item = func.__discord_ui_model_type__(**func.__discord_ui_model_kwargs__)
item.callback = _ViewCallback(func, self, item) # type: ignore
item._view = self
if isinstance(item, Select):
item.options = [option.copy() for option in item.options]
setattr(self, func.__name__, item)
children.append(item)
return children

Loading…
Cancel
Save