| 1 |
\page using_timers Using Timers |
| 2 |
|
| 3 |
Timers are a great way to run something every x seconds, from setting the bot's status, to maybe even doing a http request! Luckily, D++ makes this incredibly easy by providing an easy-to-use timer system! This tutorial will show you a couple examples on how to use timers! |
| 4 |
|
| 5 |
First, we'll cover sending the D++ logo every 10 seconds! |
| 6 |
|
| 7 |
\include{cpp} timers_example1.cpp |
| 8 |
|
| 9 |
If all went well, you should get the D++ logo sent every 10 seconds to your desired channel! |
| 10 |
|
| 11 |
\image html timers_example1.png |
| 12 |
|
| 13 |
Now, let's make the same timer a one-shot timer, meaning it will only run once! |
| 14 |
|
| 15 |
\include{cpp} timers_example2.cpp |
| 16 |
|
| 17 |
Great! Now we've learnt the basics of timers and how to stop them! |
| 18 |
|
| 19 |
To finish off, let's make a timer that you can start and stop with commands. This example will store the timer in a map where the user is the owner of the timer! |
| 20 |
|
| 21 |
\include{cpp} timers_example3.cpp |
| 22 |
|
| 23 |
If that went well, it should work something like below! |
| 24 |
|
| 25 |
\image html timers_example3.png |
| 26 |
|
| 27 |
Great, now you've learnt how to store timers to manage at a later point! |