Exemple #1
0
 async def setmile(cls, user, guild_id: int, time: str):
     session = Session()
     fitness = await cls.get_user(user.lower(), guild_id)
     fitness.mile = time
     session.add(fitness)
     session.commit()
     session.close()
Exemple #2
0
 async def auto_remove_event(cls, guild_id: int, event_id):
     session = Session()
     event = session.query(CountdownEvents).filter_by(id=event_id,
                                                      guild_id=guild_id).first()
     session.delete(event)
     session.commit()
     session.close()
Exemple #3
0
 async def auto_get_reminders(cls, guild_id: int):
     session = Session()
     # Reminders.when < datetime.today() because we don't actually fetch the reminder
     # until the next minute-interval check following the reminder time.
     results = session.query(Reminders).filter_by(guild_id=guild_id).filter(
         Reminders.when < datetime.today()).all()
     return results
Exemple #4
0
 async def setohp(cls, user, guild_id: int, weight: float):
     session = Session()
     fitness = await cls.get_user(user.lower(), guild_id)
     fitness.ohp = weight
     session.add(fitness)
     session.commit()
     session.close()
Exemple #5
0
 async def setgender(cls, user, guild_id: int, gender: str):
     session = Session()
     fitness = await cls.get_user(user.lower(), guild_id)
     fitness.gender = gender.lower()
     session.add(fitness)
     session.commit()
     session.close()
Exemple #6
0
 async def setburpees(cls, user, guild_id: int, count: int):
     session = Session()
     fitness = await cls.get_user(user.lower(), guild_id)
     fitness.burpess_1m = count
     session.add(fitness)
     session.commit()
     session.close()
Exemple #7
0
 async def add_event(cls, guild_id: int, event_name: str, event_date: date):
     session = Session()
     event = CountdownEvents()
     event.guild_id = guild_id
     event.event_name = event_name
     event.event_date = event_date
     session.add(event)
     session.commit()
     session.close()
Exemple #8
0
 async def remove_event(cls, guild_id: int, event_name: str, event_date: date):
     session = Session()
     event = session.query(CountdownEvents).filter_by(
         guild_id=guild_id, event_name=event_name, event_date=event_date).first()
     if event is not None:
         session.delete(event)
         session.commit()
         session.close()
         return True
     return False
Exemple #9
0
 async def add_reminder(cls, guild_id, user, reminder_msg, channel,
                        reminder_time):
     session = Session()
     reminder = Reminders()
     reminder.guild_id = guild_id
     reminder.user = user
     reminder.message = reminder_msg
     reminder.channel = channel
     reminder.when = reminder_time
     session.add(reminder)
     session.commit()
     session.close()
Exemple #10
0
 async def ban_user(cls, user: str, banned_by: str, ban_reason, ban_time):
     session = Session()
     ban = session.query(Bans).filter_by(user=user).first()
     if ban is None:
         ban = Bans()
     ban.user = user
     ban.banned_by = banned_by.lower()
     ban.ban_reason = ban_reason
     ban.banned_on = datetime.datetime.now()
     ban.ban_time = ban_time
     session.add(ban)
     session.commit()
     return
Exemple #11
0
 async def get_user(cls, user, guild_id: int):
     """
     Checks to see if a user exists already. If not, it creates a new record. Returns
     user record.
     :param user: the user to fetch
     :param guild_id: the id of the discord server the user belongs to
     :return: the user record
     """
     session = Session()
     fitness = session.query(Fitness).filter_by(user=user.lower(),
                                                guild_id=guild_id).first()
     if fitness is None:
         fitness = Fitness()
         fitness.user = user.lower()
         fitness.guild_id = guild_id
         session.close()
         return fitness
     session.close()
     return fitness
Exemple #12
0
 async def remove_reminder(cls, reminder_id):
     session = Session()
     reminder = session.query(Reminders).filter_by(id=reminder_id).first()
     session.delete(reminder)
     session.commit()
     session.close()
Exemple #13
0
 async def get_progress(cls, user, guild_id: int):
     session = Session()
     fitness = await cls.get_user(user.lower(), guild_id)
     session.add(fitness)
     session.commit()
     return fitness
Exemple #14
0
 async def get_ban_list(cls):
     session = Session()
     bans = session.query(Bans).all()
     return bans
Exemple #15
0
 async def unban_user(cls, user: str):
     session = Session()
     ban = session.query(Bans).filter_by(user=user).first()
     session.delete(ban)
     session.commit()
     return
Exemple #16
0
 async def get_event(cls, guild_id: int, event_name: str):
     session = Session()
     event = session.query(CountdownEvents).filter_by(guild_id=guild_id).filter(
         CountdownEvents.event_name.ilike(f'%{event_name}%')).order_by(
         asc(CountdownEvents.event_date)).all()
     return event
Exemple #17
0
 async def get_all_events(cls, guild_id: int):
     session = Session()
     events = session.query(CountdownEvents).filter_by(guild_id=guild_id).all()
     return events
Exemple #18
0
 async def user_is_banned(cls, user: str):
     session = Session()
     results = session.query(Bans).filter_by(user=user).first()
     if results is None:
         return False
     return True