Skip to content

Commit 5b51d22

Browse files
committed
Fix oversight in loading Components
1 parent b513d4c commit 5b51d22

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

twitchio/ext/commands/bot.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ def _cleanup_component(self, component: Component, /) -> None:
288288
self.remove_listener(listener)
289289

290290
async def _add_component(self, component: Component, /) -> None:
291+
if component.__component_name__ in self._components:
292+
raise ComponentLoadError(f'A component named "{component.__component_name__}" has already been loaded.')
293+
291294
for command in component.__all_commands__.values():
292295
command._injected = component
293296

@@ -328,6 +331,10 @@ async def add_component(self, component: Component, /) -> None:
328331
await self._add_component(component)
329332
except Exception as e:
330333
self._cleanup_component(component)
334+
335+
if isinstance(e, ComponentLoadError):
336+
raise e
337+
331338
raise ComponentLoadError from e
332339

333340
self._components[component.__component_name__] = component

0 commit comments

Comments
 (0)