def __new__(mcs, name, parents, dct): obj = super(GatewayEventMeta, mcs).__new__(mcs, name, parents, dct) if name != 'GatewayEvent': EVENTS_MAP[underscore(name).upper()] = obj return obj
def bind(self): """ Binds all events for this state object, storing the listeners for later unbinding. """ assert not len(self.listeners), 'Binding while already bound is dangerous' for event in self.EVENTS: func = 'on_' + underscore(event) self.listeners.append(self.client.events.on(event, getattr(self, func)))