aboutsummaryrefslogtreecommitdiffstats
path: root/output/botcore.html
diff options
context:
space:
mode:
Diffstat (limited to 'output/botcore.html')
-rw-r--r--output/botcore.html166
1 files changed, 164 insertions, 2 deletions
diff --git a/output/botcore.html b/output/botcore.html
index bab52adf..5b50ce0d 100644
--- a/output/botcore.html
+++ b/output/botcore.html
@@ -163,13 +163,13 @@
<li class="toctree-l2 has-children"><a class="reference internal" href="botcore.utils.html">Utils</a><input class="toctree-checkbox" id="toctree-checkbox-2" name="toctree-checkbox-2" role="switch" type="checkbox"/><label for="toctree-checkbox-2"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
<li class="toctree-l3"><a class="reference internal" href="botcore.utils.caching.html">caching</a></li>
<li class="toctree-l3"><a class="reference internal" href="botcore.utils.channel.html">channel</a></li>
-<li class="toctree-l3"><a class="reference internal" href="botcore.utils.extensions.html">extensions</a></li>
<li class="toctree-l3"><a class="reference internal" href="botcore.utils.logging.html">logging</a></li>
<li class="toctree-l3"><a class="reference internal" href="botcore.utils.members.html">members</a></li>
<li class="toctree-l3"><a class="reference internal" href="botcore.utils.regex.html">regex</a></li>
<li class="toctree-l3"><a class="reference internal" href="botcore.utils.scheduling.html">scheduling</a></li>
</ul>
</li>
+<li class="toctree-l2"><a class="reference internal" href="botcore.async_stats.html">async_stats</a></li>
<li class="toctree-l2"><a class="reference internal" href="botcore.site_api.html">site_api</a></li>
</ul>
</li>
@@ -212,6 +212,168 @@
<section id="module-botcore">
<span id="botcore"></span><h1>Botcore<a class="headerlink" href="#module-botcore" title="Permalink to this headline">#</a></h1>
<p>Useful utilities and tools for Discord bot development.</p>
+<dl class="py class">
+<dt class="sig sig-object py" id="botcore.BotBase">
+<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">BotBase</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">guild_id</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">allowed_roles</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">http_session</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">redis_session</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/python-discord/bot-core/blob/765284a5e436f7786619a5ba4c312d75df5e9dee/botcore/__init__.py#L33-L263"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#botcore.BotBase" title="Permalink to this definition">#</a></dt>
+<dd><p>Bases: <a class="reference external" href="https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot" title="(in discord.py v2.0.0a)"><code class="xref py py-class docutils literal notranslate"><span class="pre">discord.ext.commands.bot.Bot</span></code></a></p>
+<p>A sub-class that implements many common features that Python Discord bots use.</p>
+<dl class="py method">
+<dt class="sig sig-object py" id="botcore.BotBase.__init__">
+<span class="sig-name descname"><span class="pre">__init__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">guild_id</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">allowed_roles</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">http_session</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">redis_session</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/python-discord/bot-core/blob/765284a5e436f7786619a5ba4c312d75df5e9dee/botcore/__init__.py#L36-L86"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#botcore.BotBase.__init__" title="Permalink to this definition">#</a></dt>
+<dd><p>Initialise the base bot instance.</p>
+<dl class="field-list simple">
+<dt class="field-odd">Parameters</dt>
+<dd class="field-odd"><ul class="simple">
+<li><p><strong>guild_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a>) – The ID of the guild use for <a class="reference internal" href="#botcore.BotBase.wait_until_guild_available" title="botcore.BotBase.wait_until_guild_available"><code class="xref py py-func docutils literal notranslate"><span class="pre">wait_until_guild_available()</span></code></a>.</p></li>
+<li><p><strong>allowed_roles</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a>) – A list of role IDs that the bot is allowed to mention.</p></li>
+<li><p><strong>http_session</strong> (<a class="reference external" href="https://docs.aiohttp.org/en/stable/client_reference.html#aiohttp.ClientSession" title="(in aiohttp v3.8)"><em>aiohttp.ClientSession</em></a>) – The session to use for the bot.</p></li>
+<li><p><strong>redis_session</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.10)"><code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code></a>[<code class="xref py py-class docutils literal notranslate"><span class="pre">RedisSession</span></code>]) – The
+<code class="docutils literal notranslate"><span class="pre">[async_rediscache.RedisSession](https://github.com/SebastiaanZ/async-rediscache#creating-a-redissession)</span></code>
+to use for the bot.</p></li>
+</ul>
+</dd>
+</dl>
+</dd></dl>
+<dl class="py method">
+<dt class="sig sig-object py" id="botcore.BotBase.add_cog">
+<em class="property"><span class="pre">async</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">add_cog</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cog</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/python-discord/bot-core/blob/765284a5e436f7786619a5ba4c312d75df5e9dee/botcore/__init__.py#L140-L144"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#botcore.BotBase.add_cog" title="Permalink to this definition">#</a></dt>
+<dd><p>Add the given <code class="docutils literal notranslate"><span class="pre">cog</span></code> to the bot and log the operation.</p>
+<dl class="field-list simple">
+<dt class="field-odd">Return type</dt>
+<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.10)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></a></p>
+</dd>
+</dl>
+</dd></dl>
+<dl class="py method">
+<dt class="sig sig-object py" id="botcore.BotBase.add_command">
+<span class="sig-name descname"><span class="pre">add_command</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">command</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/python-discord/bot-core/blob/765284a5e436f7786619a5ba4c312d75df5e9dee/botcore/__init__.py#L145-L149"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#botcore.BotBase.add_command" title="Permalink to this definition">#</a></dt>
+<dd><p>Add <code class="docutils literal notranslate"><span class="pre">command</span></code> as normal and then add its root aliases to the bot.</p>
+<dl class="field-list simple">
+<dt class="field-odd">Return type</dt>
+<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.10)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></a></p>
+</dd>
+</dl>
+</dd></dl>
+<dl class="py method">
+<dt class="sig sig-object py" id="botcore.BotBase.clear">
+<span class="sig-name descname"><span class="pre">clear</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/python-discord/bot-core/blob/765284a5e436f7786619a5ba4c312d75df5e9dee/botcore/__init__.py#L165-L168"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#botcore.BotBase.clear" title="Permalink to this definition">#</a></dt>
+<dd><p>Not implemented! Re-instantiate the bot instead of attempting to re-use a closed one.</p>
+<dl class="field-list simple">
+<dt class="field-odd">Return type</dt>
+<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.10)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></a></p>
+</dd>
+</dl>
+</dd></dl>
+<dl class="py method">
+<dt class="sig sig-object py" id="botcore.BotBase.close">
+<em class="property"><span class="pre">async</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">close</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/python-discord/bot-core/blob/765284a5e436f7786619a5ba4c312d75df5e9dee/botcore/__init__.py#L229-L263"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#botcore.BotBase.close" title="Permalink to this definition">#</a></dt>
+<dd><p>Close the Discord connection, and the aiohttp session, connector, statsd client, and resolver.</p>
+<dl class="field-list simple">
+<dt class="field-odd">Return type</dt>
+<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.10)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></a></p>
+</dd>
+</dl>
+</dd></dl>
+<dl class="py method">
+<dt class="sig sig-object py" id="botcore.BotBase.load_extensions">
+<em class="property"><span class="pre">async</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">load_extensions</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">module</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/python-discord/bot-core/blob/765284a5e436f7786619a5ba4c312d75df5e9dee/botcore/__init__.py#L112-L118"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#botcore.BotBase.load_extensions" title="Permalink to this definition">#</a></dt>
+<dd><p>Load all the extensions within the given module and save them to <code class="docutils literal notranslate"><span class="pre">self.all_extensions</span></code>.</p>
+<dl class="field-list simple">
+<dt class="field-odd">Return type</dt>
+<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.10)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></a></p>
+</dd>
+</dl>
+</dd></dl>
+<dl class="py method">
+<dt class="sig sig-object py" id="botcore.BotBase.log_to_dev_log">
+<em class="property"><span class="pre">async</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">log_to_dev_log</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">message</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/python-discord/bot-core/blob/765284a5e436f7786619a5ba4c312d75df5e9dee/botcore/__init__.py#L193-L196"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#botcore.BotBase.log_to_dev_log" title="Permalink to this definition">#</a></dt>
+<dd><p>Log the given message to #dev-log.</p>
+<dl class="field-list simple">
+<dt class="field-odd">Return type</dt>
+<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.10)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></a></p>
+</dd>
+</dl>
+</dd></dl>
+<dl class="py method">
+<dt class="sig sig-object py" id="botcore.BotBase.on_guild_available">
+<em class="property"><span class="pre">async</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">on_guild_available</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">guild</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/python-discord/bot-core/blob/765284a5e436f7786619a5ba4c312d75df5e9dee/botcore/__init__.py#L176-L192"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#botcore.BotBase.on_guild_available" title="Permalink to this definition">#</a></dt>
+<dd><p>Set the internal guild available event when self.guild_id becomes available.</p>
+<p>If the cache appears to still be empty (no members, no channels, or no roles), the event
+will not be set and <cite>guild_available_but_cache_empty</cite> event will be emitted.</p>
+<dl class="field-list simple">
+<dt class="field-odd">Return type</dt>
+<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.10)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></a></p>
+</dd>
+</dl>
+</dd></dl>
+<dl class="py method">
+<dt class="sig sig-object py" id="botcore.BotBase.on_guild_unavailable">
+<em class="property"><span class="pre">async</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">on_guild_unavailable</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">guild</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/python-discord/bot-core/blob/765284a5e436f7786619a5ba4c312d75df5e9dee/botcore/__init__.py#L169-L175"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#botcore.BotBase.on_guild_unavailable" title="Permalink to this definition">#</a></dt>
+<dd><p>Clear the internal guild available event when self.guild_id becomes unavailable.</p>
+<dl class="field-list simple">
+<dt class="field-odd">Return type</dt>
+<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.10)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></a></p>
+</dd>
+</dl>
+</dd></dl>
+<dl class="py method">
+<dt class="sig sig-object py" id="botcore.BotBase.ping_services">
+<em class="property"><span class="pre">async</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">ping_services</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/python-discord/bot-core/blob/765284a5e436f7786619a5ba4c312d75df5e9dee/botcore/__init__.py#L225-L228"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#botcore.BotBase.ping_services" title="Permalink to this definition">#</a></dt>
+<dd><p>Ping all required services on setup to ensure they are up before starting.</p>
+<dl class="field-list simple">
+<dt class="field-odd">Return type</dt>
+<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.10)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></a></p>
+</dd>
+</dl>
+</dd></dl>
+<dl class="py method">
+<dt class="sig sig-object py" id="botcore.BotBase.remove_command">
+<span class="sig-name descname"><span class="pre">remove_command</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/python-discord/bot-core/blob/765284a5e436f7786619a5ba4c312d75df5e9dee/botcore/__init__.py#L150-L164"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#botcore.BotBase.remove_command" title="Permalink to this definition">#</a></dt>
+<dd><p>Remove a command/alias as normal and then remove its root aliases from the bot.</p>
+<p>Individual root aliases cannot be removed by this function.
+To remove them, either remove the entire command or manually edit <cite>bot.all_commands</cite>.</p>
+<dl class="field-list simple">
+<dt class="field-odd">Return type</dt>
+<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.10)"><code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code></a>[<a class="reference external" href="https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command" title="(in discord.py v2.0.0a)"><code class="xref py py-class docutils literal notranslate"><span class="pre">Command</span></code></a>]</p>
+</dd>
+</dl>
+</dd></dl>
+<dl class="py method">
+<dt class="sig sig-object py" id="botcore.BotBase.setup_hook">
+<em class="property"><span class="pre">async</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">setup_hook</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/python-discord/bot-core/blob/765284a5e436f7786619a5ba4c312d75df5e9dee/botcore/__init__.py#L206-L224"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#botcore.BotBase.setup_hook" title="Permalink to this definition">#</a></dt>
+<dd><p>An async init to startup generic services.</p>
+<p>Connects to statsd, and calls
+<a class="reference internal" href="botcore.async_stats.html#botcore.async_stats.AsyncStatsClient.create_socket" title="botcore.async_stats.AsyncStatsClient.create_socket"><code class="xref py py-func docutils literal notranslate"><span class="pre">AsyncStatsClient.create_socket</span></code></a>
+and <a class="reference internal" href="#botcore.BotBase.ping_services" title="botcore.BotBase.ping_services"><code class="xref py py-func docutils literal notranslate"><span class="pre">ping_services()</span></code></a>.</p>
+<dl class="field-list simple">
+<dt class="field-odd">Return type</dt>
+<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.10)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></a></p>
+</dd>
+</dl>
+</dd></dl>
+<dl class="py method">
+<dt class="sig sig-object py" id="botcore.BotBase.wait_until_guild_available">
+<em class="property"><span class="pre">async</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">wait_until_guild_available</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/python-discord/bot-core/blob/765284a5e436f7786619a5ba4c312d75df5e9dee/botcore/__init__.py#L197-L205"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#botcore.BotBase.wait_until_guild_available" title="Permalink to this definition">#</a></dt>
+<dd><p>Wait until the guild that matches the <code class="docutils literal notranslate"><span class="pre">guild_id</span></code> given at init is available (and the cache is ready).</p>
+<p>The on_ready event is inadequate because it only waits 2 seconds for a GUILD_CREATE
+gateway event before giving up and thus not populating the cache for unavailable guilds.</p>
+<dl class="field-list simple">
+<dt class="field-odd">Return type</dt>
+<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.10)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></a></p>
+</dd>
+</dl>
+</dd></dl>
+</dd></dl>
+<dl class="py exception">
+<dt class="sig sig-object py" id="botcore.StartupError">
+<em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">StartupError</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">base</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/python-discord/bot-core/blob/765284a5e436f7786619a5ba4c312d75df5e9dee/botcore/__init__.py#L25-L31"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#botcore.StartupError" title="Permalink to this definition">#</a></dt>
+<dd><p>Bases: <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#Exception" title="(in Python v3.10)"><code class="xref py py-class docutils literal notranslate"><span class="pre">Exception</span></code></a></p>
+<p>Exception class for startup errors.</p>
+<dl class="py method">
+<dt class="sig sig-object py" id="botcore.StartupError.__init__">
+<span class="sig-name descname"><span class="pre">__init__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">base</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/python-discord/bot-core/blob/765284a5e436f7786619a5ba4c312d75df5e9dee/botcore/__init__.py#L28-L31"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#botcore.StartupError.__init__" title="Permalink to this definition">#</a></dt>
+<dd></dd></dl>
+</dd></dl>
<section id="subpackages">
<h2>Subpackages<a class="headerlink" href="#subpackages" title="Permalink to this headline">#</a></h2>
<div class="toctree-wrapper compound">
@@ -221,7 +383,6 @@
<li class="toctree-l2"><a class="reference internal" href="botcore.utils.html#submodules">Submodules</a><ul>
<li class="toctree-l3"><a class="reference internal" href="botcore.utils.caching.html">caching</a></li>
<li class="toctree-l3"><a class="reference internal" href="botcore.utils.channel.html">channel</a></li>
-<li class="toctree-l3"><a class="reference internal" href="botcore.utils.extensions.html">extensions</a></li>
<li class="toctree-l3"><a class="reference internal" href="botcore.utils.logging.html">logging</a></li>
<li class="toctree-l3"><a class="reference internal" href="botcore.utils.members.html">members</a></li>
<li class="toctree-l3"><a class="reference internal" href="botcore.utils.regex.html">regex</a></li>
@@ -237,6 +398,7 @@
<h2>Submodules<a class="headerlink" href="#submodules" title="Permalink to this headline">#</a></h2>
<div class="toctree-wrapper compound">
<ul>
+<li class="toctree-l1"><a class="reference internal" href="botcore.async_stats.html">async_stats</a></li>
<li class="toctree-l1"><a class="reference internal" href="botcore.site_api.html">site_api</a></li>
</ul>
</div>