def set_channel_language(id, language): channel_ref = DB.collection("channels").document(str(id)) channel_ref.set( { "language" : language }, merge=True )
def set_combat_state(id, combat): channel_ref = DB.collection("channels").document(str(id)) channel_ref.set( { "combat" : { "in_combat" : combat } }, merge=True )
def add_combatant(id, name, init): channel_ref = DB.collection("channels").document(str(id)) channel_ref.set( { "combat" : { "combatants" : { "name" : name, "iscore" : init } } }, merge=True )
def get_channel_language(id): channel_ref = DB.collection("channels").document(str(id)) channel = channel_ref.get() if channel.exists: return channel.to_dict()["language"] else: channel_ref.set( { "language" : "en" }, merge=True ) return "en"
def get_combat_state(id): channel_ref = DB.collection("channels").document(str(id)) channel = channel_ref.get() if channel.exists: if channel.to_dict()["combat"]["in_combat"] is not None: return channel.to_dict()["combat"]["in_combat"] else: channel_ref.set( { "combat" : { "in_combat" : False } }, merge=True ) return False