-
Notifications
You must be signed in to change notification settings - Fork 60
Added a guide for ext.tasks #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, here are some changes that you might wanna make
docs/Extensions/Tasks/tasks.mdx
Outdated
With the tasks extension you can make background tasks without worrying about the asyncio hell and stuff like "what if my internet dies" and "how do I handle reconnecting" with the added benifit of alot of useful additions that are one line of code away! | ||
|
||
### Example Usage | ||
```py title="Example Usage" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the title field is needed
docs/Extensions/Tasks/tasks.mdx
Outdated
|
||
If you do run this code in your terminal you should see something like this after about 15 seconds: | ||
|
||
```sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sh code block indicator is also not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's okay
docs/Extensions/Tasks/tasks.mdx
Outdated
async def very_useful_task(): | ||
print('doing very useful stuff.') | ||
|
||
bot.run(your token) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe replace the your token
text with "TOKEN"
# ... | ||
``` | ||
|
||
## [Tasks](https://docs.pycord.dev/en/master/ext/tasks/index.html) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an extra newline after this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be fixed with formatting
|
||
These attributes serve as a really powerful asset to get info about your loop. | ||
|
||
### Example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an extra newline after this line.
docs/Extensions/Tasks/tasks.mdx
Outdated
``` | ||
|
||
For a more usful example here's a task in a cog context ripped straight from the [docs](https://docs.pycord.dev/en/master/ext/tasks/index.html#recepies): | ||
```py title="Cog Example" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the title field is needed
docs/Extensions/Tasks/tasks.mdx
Outdated
Now let's create a cog that handles a leaderboard we have in our bot using Tasks then explain what we did after that and also provide a refresher of how slash commands groups work in cogs. | ||
|
||
For the sake of this example let's pretend that we have a leaderboard module that does all the leaderboard handling for us and that computing the leaderboard is very expensive computationally wise so we want to store one version of it that gets regularly updated insetad of generating it every time someone calls the `/leaderboard view` command. | ||
```py title="Using Tasks" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the title field is needed
@emretech @BruceCodesGithub how's this |
No description provided.