Skip to content

Commit 16a6045

Browse files
committed
fix select inst check
1 parent 0c73b36 commit 16a6045

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

discord/components.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -629,12 +629,17 @@ def _handle_model(
629629
if isinstance(model, Object):
630630
obj_type = model.type
631631

632-
try:
633-
sel_types, def_type = instances_mapping[obj_type]
634-
except KeyError:
635-
raise TypeError(
636-
f"{model.__class__.__name__} is not a valid instance for a select default value",
637-
)
632+
sel_types = None
633+
def_type = None
634+
635+
for typ, (st, dt) in instances_mapping.items():
636+
if isinstance(model, typ):
637+
sel_types = st
638+
def_type = dt
639+
break
640+
641+
if sel_types is None or def_type is None:
642+
raise TypeError(f"{obj_type.__name__} is not a valid instance for a select default value")
638643

639644
# we can't actually check select types when not in a select context
640645
if select_type is not None and select_type not in sel_types:

0 commit comments

Comments
 (0)