def remove_welcome_channel(self): ''' Removes the current home channel msg in the database. Args: None. Returns: None. ''' with self.session() as session: guild_query = session.query(AdminOptions).filter( AdminOptions.guild_id == self.guild_id).one_or_none() # if there are already entries for this guild, updates them if guild_query is not None: if guild_query.home_msg_id: guild_query.home_msg_id = "0" session.commit() # if there are no entries for this guild, creates entry else: admin_options = AdminOptions() admin_options.guild_id = self.guild_id admin_options.home_msg_id = "0" session.add(admin_options) session.commit()
def set_welcome_channel(self, home_msg_id): ''' Adds/Updates the current home channel msg in the database. Args: - home_msg_id (int): ID of home channel message. Returns: None. ''' home_msg_id = str(home_msg_id) with self.session() as session: guild_query = session.query(AdminOptions).filter( AdminOptions.guild_id == self.guild_id).one_or_none() # if there are already entries for this guild, updates them if guild_query is not None: guild_query.home_msg_id = home_msg_id session.commit() # if there are no entries for this guild, creates entry else: admin_options = AdminOptions() admin_options.guild_id = self.guild_id admin_options.home_msg_id = home_msg_id session.add(admin_options) session.commit()