diff --git a/litecord/pubsub/utils.py b/litecord/pubsub/utils.py index 636ba36..1d6bca6 100644 --- a/litecord/pubsub/utils.py +++ b/litecord/pubsub/utils.py @@ -30,11 +30,12 @@ async def send_event_to_states( """Dispatch an event to a list of states.""" res = [] + event, data = event_data for state in states: try: - event, data = event_data - await state.ws.dispatch(event, data) - res.append(state.session_id) + if state.ws: + await state.ws.dispatch(event, data) + res.append(state.session_id) except Exception: log.exception("error while dispatching")