While editing the duration of an infraction, the scheduler will throw an exception when trying to set a new task for the infraction. The reason is that we're currently calling a Scheduler method that expects a coroutine as the second argument, but we're actually passing the infraction dictionary:
|
self.infractions_cog.scheduler.schedule(new_infraction['id'], new_infraction) |
|
def schedule(self, task_id: t.Hashable, coroutine: t.Coroutine) -> None: |
|
""" |
|
Schedule the execution of a `coroutine`. |
|
|
|
If a task with `task_id` already exists, close `coroutine` instead of scheduling it. This |
|
prevents unawaited coroutine warnings. Don't pass a coroutine that'll be re-used elsewhere. |
|
""" |
This results in the following exception:
2020-07-13 06:28:15 | bot.cogs.error_handler | ERROR | Error executing command invoked by Ves Zappa#3787: !infr edit 9288 3d
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/bot/bot/cogs/moderation/management.py", line 142, in infraction_edit
self.infractions_cog.scheduler.schedule(new_infraction['id'], new_infraction)
File "/bot/bot/utils/scheduling.py", line 47, in schedule
assert inspect.getcoroutinestate(coroutine) == "CORO_CREATED", msg
File "/usr/local/lib/python3.8/inspect.py", line 1671, in getcoroutinestate
if coroutine.cr_running:
AttributeError: 'dict' object has no attribute 'cr_running'
According to @MarkKoz, the dict should probably have been passed to a coroutine that is then scheduled. I haven't looked into it too closely yet, as I'm currently working, but I did notice that there are also other methods in the moderation scheduler that schedule something based on an expiry value.
While editing the duration of an infraction, the scheduler will throw an exception when trying to set a new task for the infraction. The reason is that we're currently calling a
Schedulermethod that expects a coroutine as the second argument, but we're actually passing the infraction dictionary:bot/bot/cogs/moderation/management.py
Line 142 in c975104
bot/bot/utils/scheduling.py
Lines 37 to 43 in c975104
This results in the following exception:
According to @MarkKoz, the dict should probably have been passed to a coroutine that is then scheduled. I haven't looked into it too closely yet, as I'm currently working, but I did notice that there are also other methods in the moderation scheduler that schedule something based on an
expiryvalue.