diff --git a/bot.py b/bot.py index 502237a..fa9f11f 100644 --- a/bot.py +++ b/bot.py @@ -3,6 +3,7 @@ from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By from time import sleep +import time import disnake import random from urllib.parse import urlparse @@ -60,9 +61,10 @@ def play_video(videourl): pass try: endscreen = driver.find_element(By.CLASS_NAME, "html5-endscreen") + timeout = (float(os.getenv("MAX_MIN")) * 60) + time.time() - 10 #subtract 10 since 10 seconds of the video has played by this point except Exception: return #same as above - while str(endscreen.get_attribute('style')) == "display: none;": + while str(endscreen.get_attribute('style')) == "display: none;" and time.time() < timeout: pass sleep(2) return @@ -155,9 +157,9 @@ async def button_listener(inter: disnake.MessageInteraction): except IndexError: break message = message + f"{int(page[0])-1} of {math.ceil((len(queue)-1)/10) if (len(queue)-1)/10 > 1 else 1}" - if (int(page[0])-1) <= 1 and int(page[1] == 1): + if (int(page[0])-1) <= 1 and int(int(page[1]) == 1): await inter.response.edit_message(message) - elif (int(page[0])-1) <= 1 and int(page[1] > 1): + elif (int(page[0])-1) <= 1 and int(int(page[1]) > 1): await inter.response.edit_message(message, components=[disnake.ui.Button(label=">>", style=disnake.ButtonStyle.primary, custom_id="Forward"),]) else: await inter.response.edit_message(message, components=[disnake.ui.Button(label="<<", style=disnake.ButtonStyle.primary, custom_id="Backward"),