Open JamesAib opened 2 years ago
Another sulotion from the docs that did not work
@client.event async def on_ready(): schedule.every(1).seconds.do(self.local, script_path, update()) self.job_func = functools.partial(job_func, *args, **kwargs) schedule.run_pending()
def do(self, job_func: callable, *args, *kwargs): """ Specifies the job_func that should be called every time the job runs. Any additional arguments are passed on to job_func when the job runs. :param job_func: The function to be scheduled :return: The invoked job instance """ self.job_func = functools.partial(job_func, args, **kwargs) functools.update_wrapper(self.job_func, job_func) self._schedule_next_run() if self.scheduler is None: raise ScheduleError("Unable to a add job to schedule.\n Job is not associated with an scheduler.") self.scheduler.jobs.append(self) return
The error
Ignoring exception in on_ready Traceback (most recent call last): File "D:\Præpositi\venv\lib\site-packages\discord\client.py", line 343, in _run_event await coro(*args, **kwargs) File "D:/Præpositi/Global-Guard/Global-Guard.py", line 122, in on_ready schedule.every(1).seconds.do(self.local, script_path, update()) NameError: name 'self' is not defined
This is the code nothing seems to work
@client.event async def on_ready(self): schedule.every(1).seconds.do(self.local, script_path, update()) self.job_func = functools.partial(job_func, *args, **kwargs) schedule.run_pending()
-----------------------------------------------------------------------------------------------------------------------
def do(self, job_func, *args, *kwargs): """ Specifies the job_func that should be called every time the job runs. Any additional arguments are passed on to job_func when the job runs. :param job_func: The function to be scheduled :return: The invoked job instance """ self.job_func = functools.partial(job_func, args, **kwargs) functools.update_wrapper(self.job_func, job_func) self._schedule_next_run() if self.scheduler is None: raise ScheduleError("Unable to a add job to schedule.\n Job is not associated with an scheduler.") self.scheduler.jobs.append(self) return