Esempio n. 1
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()
Esempio n. 2
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
Esempio n. 3
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
Esempio n. 4
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
Esempio n. 5
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
Esempio n. 6
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
Esempio n. 7
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
Esempio n. 8
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()
Esempio n. 9
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
Esempio n. 10
0
 async def get_ban_list(cls):
     session = Session()
     bans = session.query(Bans).all()
     return bans
Esempio n. 11
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