Open
Description
Summary
You cannot change the interval of a task if it has not executed at least once.
Reproduction Steps
Create a loop, start it, and change its interval before it has time to execute even once.
Minimal Reproducible Code
import os
import disnake
from disnake.ext import tasks, commands
import dotenv
dotenv.load_dotenv()
TOKEN = os.getenv('BOT_TOKEN')
bot_intent = disnake.Intents.none()
bot = commands.InteractionBot(intents=bot_intent)
@bot.event
async def on_ready():
test_loop.start()
test_loop.change_interval(minutes=1)
@tasks.loop(minutes=5)
async def test_loop():
return
def main():
bot.run(TOKEN)
if __name__ == '__main__':
main()
Expected Results
The interval should be changed without error.
Actual Results
Ignoring exception in on_ready
Traceback (most recent call last):
File "venv\Lib\site-packages\disnake\client.py", line 738, in _run_event
await coro(*args, **kwargs)
File "main.py", line 18, in on_ready
test_loop.change_interval(minutes=1)
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
File "venv\Lib\site-packages\disnake\ext\tasks\__init__.py", line 697, in change_interval
self._next_iteration = self._get_next_sleep_time()
~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "venv\Lib\site-packages\disnake\ext\tasks\__init__.py", line 563, in _get_next_sleep_time
return self._last_iteration + datetime.timedelta(seconds=self._sleep)
~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for +: '_MissingSentinel' and 'datetime.timedelta'
Intents
None
System Information
- Python v3.13.0-final
- disnake v2.10.1-final
- disnake importlib.metadata: v2.10.1
- aiohttp v3.11.16
- system info: Windows 10 10.0.19045 AMD64
Checklist
- I have searched the open issues for duplicates.
- I have shown the entire traceback, if possible.
- I have removed my token from display, if visible.
Additional Context
No response