diff --git a/utils/commands.py b/utils/commands.py index 1669b0f..f3e010b 100644 --- a/utils/commands.py +++ b/utils/commands.py @@ -65,14 +65,13 @@ async def random_quote(bot: object) -> str: """ Get a random quote from the database. """ - quotes = get_quotes(quote_id_stack) - stack_limit = int((len(quotes) * .25)) + chosen_one = get_quotes(quote_id_stack) stack_len = len(quote_id_stack) - if not quotes and stack_len > 0: + if not chosen_one and stack_len > 0: quote_id_stack.pop(0) - quotes = get_quotes(quote_id_stack) - elif not quotes: + chosen_one = get_quotes(quote_id_stack) + elif not chosen_one: return await bot.send('You\'ve got no quotes saved yet.\n(Save quotes by using '\ '`--q tuple: ids: List of quote ID's """ with Session(SQLACHEMY) as session: - response = session.query(Quotes).filter(Quotes.id.not_in(ids)) - return [item for item in response] + response = session.query(Quotes).filter(Quotes.id.not_in(ids)).order_by(func.random()).first() + return response def get_by_id(id: int) -> object: