diff --git a/docs/doctrees/creatingacommand.doctree b/docs/doctrees/creatingacommand.doctree index 0898c66f..1a465175 100644 Binary files a/docs/doctrees/creatingacommand.doctree and b/docs/doctrees/creatingacommand.doctree differ diff --git a/docs/doctrees/environment.pickle b/docs/doctrees/environment.pickle index 4e9f7c4f..b9053252 100644 Binary files a/docs/doctrees/environment.pickle and b/docs/doctrees/environment.pickle differ diff --git a/docs/html/_sources/creatingacommand.rst.txt b/docs/html/_sources/creatingacommand.rst.txt index e617e69f..7034ea1e 100644 --- a/docs/html/_sources/creatingacommand.rst.txt +++ b/docs/html/_sources/creatingacommand.rst.txt @@ -64,19 +64,23 @@ To send a message in the chat the command was called in, you can use the :py:met And... it's done! The command is ready to be added to a bot! +Command arguments +------------------------------------ + + Coroutines and slow operations ------------------------------------ You may have noticed that in the previous example I wrote ``await data.reply("๐Ÿ")`` instead of just ``data.reply("๐Ÿ")``. This is because :py:meth:`CommandData.reply` isn't a simple method: it is a coroutine, a special kind of function that - can be executed separately from the rest of the code, allowing the bot to do other things in the meantime. +can be executed separately from the rest of the code, allowing the bot to do other things in the meantime. By adding the ``await`` keyword before the ``data.reply("๐Ÿ")``, we tell the bot that it can do other things, like - receiving new messages, while the message is being sent. +receiving new messages, while the message is being sent. You should avoid running slow normal functions inside bot commands, as they will stop the bot from working until they - are finished and may cause bugs in other parts of the code! :: +are finished and may cause bugs in other parts of the code! :: async def run(self, args, data): # Don't do this! @@ -84,7 +88,7 @@ You should avoid running slow normal functions inside bot commands, as they will ... If the slow function you want does not cause any side effect, you can wrap it with the :ref:`royalnet.utils.asyncify` - function: :: +function: :: async def run(self, args, data): # If the called function has no side effect, you can do this! @@ -92,4 +96,10 @@ If the slow function you want does not cause any side effect, you can wrap it wi ... Avoid using :py:func:`time.sleep` function, as it is considered a slow operation: use instead :py:func:`asyncio.sleep`, - a coroutine that does the same exact thing. +a coroutine that does the same exact thing. + +Accessing the database +------------------------------------ + +Comunicating via Royalnet +------------------------------------ diff --git a/docs/html/creatingacommand.html b/docs/html/creatingacommand.html index d2dc83fb..9376a39c 100644 --- a/docs/html/creatingacommand.html +++ b/docs/html/creatingacommand.html @@ -84,7 +84,10 @@