mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-19 07:26:17 +00:00
Add FAQ entry for after
being called right away.
This commit is contained in:
parent
adbf2c720f
commit
e2e6d7182e
21
docs/faq.rst
21
docs/faq.rst
@ -163,6 +163,27 @@ this together we can do the following: ::
|
||||
player = await voice.create_ytdl_player(url, after=my_after)
|
||||
player.start()
|
||||
|
||||
Why is my "after" function being called right away?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The ``after`` keyword argument expects a *function object* to be passed in. Similar to how ``threading.Thread`` expects a
|
||||
callable in its ``target`` keyword argument. This means that the following are invalid:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
player = await voice.create_ytdl_player(url, after=self.foo())
|
||||
other = await voice.create_ytdl_player(url, after=self.bar(10))
|
||||
|
||||
However the following are correct:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
player = await voice.create_ytdl_player(url, after=self.foo)
|
||||
other = await voice.create_ytdl_player(url, after=lambda: self.bar(10))
|
||||
|
||||
Basically, these functions should not be called.
|
||||
|
||||
|
||||
How do I run something in the background?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user